diff --git a/views/assets/scripts.js b/views/assets/scripts.js index 457e891..3a78047 100644 --- a/views/assets/scripts.js +++ b/views/assets/scripts.js @@ -1,11 +1,5566 @@ -var Ve = Object.defineProperty; -var ee = (r) => { - throw TypeError(r); +var wo = Object.defineProperty; +var ns = (s) => { + throw TypeError(s); }; -var Ue = (r, t, e) => t in r ? Ve(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e; -var C = (r, t, e) => Ue(r, typeof t != "symbol" ? t + "" : t, e), F = (r, t, e) => t.has(r) || ee("Cannot " + e); -var V = (r, t, e) => (F(r, t, "read from private field"), e ? e.call(r) : t.get(r)), I = (r, t, e) => t.has(r) ? ee("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), O = (r, t, e, i) => (F(r, t, "write to private field"), i ? i.call(r, e) : t.set(r, e), e), B = (r, t, e) => (F(r, t, "access private method"), e); -class ze extends HTMLElement { +var ko = (s, t, e) => t in s ? wo(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e; +var ee = (s, t, e) => ko(s, typeof t != "symbol" ? t + "" : t, e), yi = (s, t, e) => t.has(s) || ns("Cannot " + e); +var Ei = (s, t, e) => (yi(s, t, "read from private field"), e ? e.call(s) : t.get(s)), ie = (s, t, e) => t.has(s) ? ns("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), Me = (s, t, e, i) => (yi(s, t, "write to private field"), i ? i.call(s, e) : t.set(s, e), e), Be = (s, t, e) => (yi(s, t, "access private method"), e); +var Io = "2.1.16"; +const kt = "[data-trix-attachment]", yn = { preview: { presentation: "gallery", caption: { name: !0, size: !0 } }, file: { caption: { size: !0 } } }, G = { default: { tagName: "div", parse: !1 }, quote: { tagName: "blockquote", nestable: !0 }, heading1: { tagName: "h1", terminal: !0, breakOnReturn: !0, group: !1 }, code: { tagName: "pre", terminal: !0, htmlAttributes: ["language"], text: { plaintext: !0 } }, bulletList: { tagName: "ul", parse: !1 }, bullet: { tagName: "li", listAttribute: "bulletList", group: !1, nestable: !0, test(s) { + return ss(s.parentNode) === G[this.listAttribute].tagName; +} }, numberList: { tagName: "ol", parse: !1 }, number: { tagName: "li", listAttribute: "numberList", group: !1, nestable: !0, test(s) { + return ss(s.parentNode) === G[this.listAttribute].tagName; +} }, attachmentGallery: { tagName: "div", exclusive: !0, terminal: !0, parse: !1, group: !1 } }, ss = (s) => { + var t; + return s == null || (t = s.tagName) === null || t === void 0 ? void 0 : t.toLowerCase(); +}, rs = navigator.userAgent.match(/android\s([0-9]+.*Chrome)/i), Si = rs && parseInt(rs[1]); +var Ce = { composesExistingText: /Android.*Chrome/.test(navigator.userAgent), recentAndroid: Si && Si > 12, samsungAndroid: Si && navigator.userAgent.match(/Android.*SM-/), forcesObjectResizing: /Trident.*rv:11/.test(navigator.userAgent), supportsInputEvents: typeof InputEvent < "u" && ["data", "getTargetRanges", "inputType"].every((s) => s in InputEvent.prototype) }, br = { ADD_ATTR: ["language"], SAFE_FOR_XML: !1, RETURN_DOM: !0 }, b = { attachFiles: "Attach Files", bold: "Bold", bullets: "Bullets", byte: "Byte", bytes: "Bytes", captionPlaceholder: "Add a caption…", code: "Code", heading1: "Heading", indent: "Increase Level", italic: "Italic", link: "Link", numbers: "Numbers", outdent: "Decrease Level", quote: "Quote", redo: "Redo", remove: "Remove", strike: "Strikethrough", undo: "Undo", unlink: "Unlink", url: "URL", urlPlaceholder: "Enter a URL…", GB: "GB", KB: "KB", MB: "MB", PB: "PB", TB: "TB" }; +const Ro = [b.bytes, b.KB, b.MB, b.GB, b.TB, b.PB]; +var vr = { prefix: "IEC", precision: 2, formatter(s) { + switch (s) { + case 0: + return "0 ".concat(b.bytes); + case 1: + return "1 ".concat(b.byte); + default: + let t; + this.prefix === "SI" ? t = 1e3 : this.prefix === "IEC" && (t = 1024); + const e = Math.floor(Math.log(s) / Math.log(t)), i = (s / Math.pow(t, e)).toFixed(this.precision).replace(/0*$/, "").replace(/\.$/, ""); + return "".concat(i, " ").concat(Ro[e]); + } +} }; +const ii = "\uFEFF", _t = " ", _r = function(s) { + for (const t in s) { + const e = s[t]; + this[t] = e; + } + return this; +}, En = document.documentElement, Do = En.matches, k = function(s) { + let { onElement: t, matchingSelector: e, withCallback: i, inPhase: n, preventDefault: r, times: o } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + const a = t || En, c = e, h = n === "capturing", d = function(m) { + o != null && --o == 0 && d.destroy(); + const p = At(m.target, { matchingSelector: c }); + p != null && (i == null || i.call(p, m, p), r && m.preventDefault()); + }; + return d.destroy = () => a.removeEventListener(s, d, h), a.addEventListener(s, d, h), d; +}, Ar = function(s) { + let { bubbles: t, cancelable: e, attributes: i } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + t = t !== !1, e = e !== !1; + const n = document.createEvent("Events"); + return n.initEvent(s, t, e), i != null && _r.call(n, i), n; +}, me = function(s) { + let { onElement: t, bubbles: e, cancelable: i, attributes: n } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + const r = t ?? En, o = Ar(s, { bubbles: e, cancelable: i, attributes: n }); + return r.dispatchEvent(o); +}, yr = function(s, t) { + if ((s == null ? void 0 : s.nodeType) === 1) return Do.call(s, t); +}, At = function(s) { + let { matchingSelector: t, untilNode: e } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + for (; s && s.nodeType !== Node.ELEMENT_NODE; ) s = s.parentNode; + if (s != null) { + if (t == null) return s; + if (s.closest && e == null) return s.closest(t); + for (; s && s !== e; ) { + if (yr(s, t)) return s; + s = s.parentNode; + } + } +}, Sn = (s) => document.activeElement !== s && Tt(s, document.activeElement), Tt = function(s, t) { + if (s && t) for (; t; ) { + if (t === s) return !0; + t = t.parentNode; + } +}, xi = function(s) { + var t; + if ((t = s) === null || t === void 0 || !t.parentNode) return; + let e = 0; + for (s = s.previousSibling; s; ) e++, s = s.previousSibling; + return e; +}, yt = (s) => { + var t; + return s == null || (t = s.parentNode) === null || t === void 0 ? void 0 : t.removeChild(s); +}, Je = function(s) { + let { onlyNodesOfType: t, usingFilter: e, expandEntityReferences: i } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + const n = (() => { + switch (t) { + case "element": + return NodeFilter.SHOW_ELEMENT; + case "text": + return NodeFilter.SHOW_TEXT; + case "comment": + return NodeFilter.SHOW_COMMENT; + default: + return NodeFilter.SHOW_ALL; + } + })(); + return document.createTreeWalker(s, n, e ?? null, i === !0); +}, K = (s) => { + var t; + return s == null || (t = s.tagName) === null || t === void 0 ? void 0 : t.toLowerCase(); +}, _ = function(s) { + let t, e, i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + typeof s == "object" ? (i = s, s = i.tagName) : i = { attributes: i }; + const n = document.createElement(s); + if (i.editable != null && (i.attributes == null && (i.attributes = {}), i.attributes.contenteditable = i.editable), i.attributes) for (t in i.attributes) e = i.attributes[t], n.setAttribute(t, e); + if (i.style) for (t in i.style) e = i.style[t], n.style[t] = e; + if (i.data) for (t in i.data) e = i.data[t], n.dataset[t] = e; + return i.className && i.className.split(" ").forEach((r) => { + n.classList.add(r); + }), i.textContent && (n.textContent = i.textContent), i.childNodes && [].concat(i.childNodes).forEach((r) => { + n.appendChild(r); + }), n; +}; +let ne; +const ge = function() { + if (ne != null) return ne; + ne = []; + for (const s in G) { + const t = G[s]; + t.tagName && ne.push(t.tagName); + } + return ne; +}, Ci = (s) => zt(s == null ? void 0 : s.firstChild), os = function(s) { + let { strict: t } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { strict: !0 }; + return t ? zt(s) : zt(s) || !zt(s.firstChild) && function(e) { + return ge().includes(K(e)) && !ge().includes(K(e.firstChild)); + }(s); +}, zt = (s) => Oo(s) && (s == null ? void 0 : s.data) === "block", Oo = (s) => (s == null ? void 0 : s.nodeType) === Node.COMMENT_NODE, Kt = function(s) { + let { name: t } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + if (s) return pe(s) ? s.data === ii ? !t || s.parentNode.dataset.trixCursorTarget === t : void 0 : Kt(s.firstChild); +}, It = (s) => yr(s, kt), Er = (s) => pe(s) && (s == null ? void 0 : s.data) === "", pe = (s) => (s == null ? void 0 : s.nodeType) === Node.TEXT_NODE, xn = { level2Enabled: !0, getLevel() { + return this.level2Enabled && Ce.supportsInputEvents ? 2 : 0; +}, pickFiles(s) { + const t = _("input", { type: "file", multiple: !0, hidden: !0, id: this.fileInputId }); + t.addEventListener("change", () => { + s(t.files), yt(t); + }), yt(document.getElementById(this.fileInputId)), document.body.appendChild(t), t.click(); +} }; +var ze = { removeBlankTableCells: !1, tableCellSeparator: " | ", tableRowSeparator: ` +` }, Dt = { bold: { tagName: "strong", inheritable: !0, parser(s) { + const t = window.getComputedStyle(s); + return t.fontWeight === "bold" || t.fontWeight >= 600; +} }, italic: { tagName: "em", inheritable: !0, parser: (s) => window.getComputedStyle(s).fontStyle === "italic" }, href: { groupTagName: "a", parser(s) { + const t = "a:not(".concat(kt, ")"), e = s.closest(t); + if (e) return e.getAttribute("href"); +} }, strike: { tagName: "del", inheritable: !0 }, frozen: { style: { backgroundColor: "highlight" } } }, Sr = { getDefaultHTML: () => `
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
`) }; +const an = { interval: 5e3 }; +var Le = Object.freeze({ __proto__: null, attachments: yn, blockAttributes: G, browser: Ce, css: { attachment: "attachment", attachmentCaption: "attachment__caption", attachmentCaptionEditor: "attachment__caption-editor", attachmentMetadata: "attachment__metadata", attachmentMetadataContainer: "attachment__metadata-container", attachmentName: "attachment__name", attachmentProgress: "attachment__progress", attachmentSize: "attachment__size", attachmentToolbar: "attachment__toolbar", attachmentGallery: "attachment-gallery" }, dompurify: br, fileSize: vr, input: xn, keyNames: { 8: "backspace", 9: "tab", 13: "return", 27: "escape", 37: "left", 39: "right", 46: "delete", 68: "d", 72: "h", 79: "o" }, lang: b, parser: ze, textAttributes: Dt, toolbar: Sr, undo: an }); +class M { + static proxyMethod(t) { + const { name: e, toMethod: i, toProperty: n, optional: r } = Mo(t); + this.prototype[e] = function() { + let o, a; + var c, h; + return i ? a = r ? (c = this[i]) === null || c === void 0 ? void 0 : c.call(this) : this[i]() : n && (a = this[n]), r ? (o = (h = a) === null || h === void 0 ? void 0 : h[e], o ? as.call(o, a, arguments) : void 0) : (o = a[e], as.call(o, a, arguments)); + }; + } +} +const Mo = function(s) { + const t = s.match(Bo); + if (!t) throw new Error("can't parse @proxyMethod expression: ".concat(s)); + const e = { name: t[4] }; + return t[2] != null ? e.toMethod = t[1] : e.toProperty = t[1], t[3] != null && (e.optional = !0), e; +}, { apply: as } = Function.prototype, Bo = new RegExp("^(.+?)(\\(\\))?(\\?)?\\.(.+?)$"); +var Li, Ti, wi; +class ye extends M { + static box() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; + return t instanceof this ? t : this.fromUCS2String(t == null ? void 0 : t.toString()); + } + static fromUCS2String(t) { + return new this(t, ln(t)); + } + static fromCodepoints(t) { + return new this(cn(t), t); + } + constructor(t, e) { + super(...arguments), this.ucs2String = t, this.codepoints = e, this.length = this.codepoints.length, this.ucs2Length = this.ucs2String.length; + } + offsetToUCS2Offset(t) { + return cn(this.codepoints.slice(0, Math.max(0, t))).length; + } + offsetFromUCS2Offset(t) { + return ln(this.ucs2String.slice(0, Math.max(0, t))).length; + } + slice() { + return this.constructor.fromCodepoints(this.codepoints.slice(...arguments)); + } + charAt(t) { + return this.slice(t, t + 1); + } + isEqualTo(t) { + return this.constructor.box(t).ucs2String === this.ucs2String; + } + toJSON() { + return this.ucs2String; + } + getCacheKey() { + return this.ucs2String; + } + toString() { + return this.ucs2String; + } +} +const No = ((Li = Array.from) === null || Li === void 0 ? void 0 : Li.call(Array, "👼").length) === 1, Po = ((Ti = " ".codePointAt) === null || Ti === void 0 ? void 0 : Ti.call(" ", 0)) != null, Fo = ((wi = String.fromCodePoint) === null || wi === void 0 ? void 0 : wi.call(String, 32, 128124)) === " 👼"; +let ln, cn; +ln = No && Po ? (s) => Array.from(s).map((t) => t.codePointAt(0)) : function(s) { + const t = []; + let e = 0; + const { length: i } = s; + for (; e < i; ) { + let n = s.charCodeAt(e++); + if (55296 <= n && n <= 56319 && e < i) { + const r = s.charCodeAt(e++); + (64512 & r) == 56320 ? n = ((1023 & n) << 10) + (1023 & r) + 65536 : e--; + } + t.push(n); + } + return t; +}, cn = Fo ? (s) => String.fromCodePoint(...Array.from(s || [])) : function(s) { + return (() => { + const t = []; + return Array.from(s).forEach((e) => { + let i = ""; + e > 65535 && (e -= 65536, i += String.fromCharCode(e >>> 10 & 1023 | 55296), e = 56320 | 1023 & e), t.push(i + String.fromCharCode(e)); + }), t; + })().join(""); +}; +let qo = 0; +class Bt extends M { + static fromJSONString(t) { + return this.fromJSON(JSON.parse(t)); + } + constructor() { + super(...arguments), this.id = ++qo; + } + hasSameConstructorAs(t) { + return this.constructor === (t == null ? void 0 : t.constructor); + } + isEqualTo(t) { + return this === t; + } + inspect() { + const t = [], e = this.contentsForInspection() || {}; + for (const i in e) { + const n = e[i]; + t.push("".concat(i, "=").concat(n)); + } + return "#<".concat(this.constructor.name, ":").concat(this.id).concat(t.length ? " ".concat(t.join(", ")) : "", ">"); + } + contentsForInspection() { + } + toJSONString() { + return JSON.stringify(this); + } + toUTF16String() { + return ye.box(this); + } + getCacheKey() { + return this.id.toString(); + } +} +const Ot = function() { + let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; + if (s.length !== t.length) return !1; + for (let e = 0; e < s.length; e++) + if (s[e] !== t[e]) return !1; + return !0; +}, Cn = function(s) { + const t = s.slice(0); + for (var e = arguments.length, i = new Array(e > 1 ? e - 1 : 0), n = 1; n < e; n++) i[n - 1] = arguments[n]; + return t.splice(...i), t; +}, Ho = /[\u05BE\u05C0\u05C3\u05D0-\u05EA\u05F0-\u05F4\u061B\u061F\u0621-\u063A\u0640-\u064A\u066D\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D5\u06E5\u06E6\u200F\u202B\u202E\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE72\uFE74\uFE76-\uFEFC]/, $o = function() { + const s = _("input", { dir: "auto", name: "x", dirName: "x.dir" }), t = _("textarea", { dir: "auto", name: "y", dirName: "y.dir" }), e = _("form"); + e.appendChild(s), e.appendChild(t); + const i = function() { + try { + return new FormData(e).has(t.dirName); + } catch { + return !1; + } + }(), n = function() { + try { + return s.matches(":dir(ltr),:dir(rtl)"); + } catch { + return !1; + } + }(); + return i ? function(r) { + return t.value = r, new FormData(e).get(t.dirName); + } : n ? function(r) { + return s.value = r, s.matches(":dir(rtl)") ? "rtl" : "ltr"; + } : function(r) { + const o = r.trim().charAt(0); + return Ho.test(o) ? "rtl" : "ltr"; + }; +}(); +let ki = null, Ii = null, Ri = null, Ne = null; +const hn = () => (ki || (ki = jo().concat(Uo())), ki), D = (s) => G[s], Uo = () => (Ii || (Ii = Object.keys(G)), Ii), dn = (s) => Dt[s], jo = () => (Ri || (Ri = Object.keys(Dt)), Ri), xr = function(s, t) { + Vo(s).textContent = t.replace(/%t/g, s); +}, Vo = function(s) { + const t = document.createElement("style"); + t.setAttribute("type", "text/css"), t.setAttribute("data-tag-name", s.toLowerCase()); + const e = Wo(); + return e && t.setAttribute("nonce", e), document.head.insertBefore(t, document.head.firstChild), t; +}, Wo = function() { + const s = ls("trix-csp-nonce") || ls("csp-nonce"); + if (s) { + const { nonce: t, content: e } = s; + return t == "" ? e : t; + } +}, ls = (s) => document.head.querySelector("meta[name=".concat(s, "]")), cs = { "application/x-trix-feature-detection": "test" }, Cr = function(s) { + const t = s.getData("text/plain"), e = s.getData("text/html"); + if (!t || !e) return t == null ? void 0 : t.length; + { + const { body: i } = new DOMParser().parseFromString(e, "text/html"); + if (i.textContent === t) return !i.querySelector("*"); + } +}, Lr = /Mac|^iP/.test(navigator.platform) ? (s) => s.metaKey : (s) => s.ctrlKey, Ln = (s) => setTimeout(s, 1), Tr = function() { + let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + const t = {}; + for (const e in s) { + const i = s[e]; + t[e] = i; + } + return t; +}, Yt = function() { + let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + if (Object.keys(s).length !== Object.keys(t).length) return !1; + for (const e in s) + if (s[e] !== t[e]) return !1; + return !0; +}, x = function(s) { + if (s != null) return Array.isArray(s) || (s = [s, s]), [hs(s[0]), hs(s[1] != null ? s[1] : s[0])]; +}, gt = function(s) { + if (s == null) return; + const [t, e] = x(s); + return un(t, e); +}, Ye = function(s, t) { + if (s == null || t == null) return; + const [e, i] = x(s), [n, r] = x(t); + return un(e, n) && un(i, r); +}, hs = function(s) { + return typeof s == "number" ? s : Tr(s); +}, un = function(s, t) { + return typeof s == "number" ? s === t : Yt(s, t); +}; +class wr extends M { + constructor() { + super(...arguments), this.update = this.update.bind(this), this.selectionManagers = []; + } + start() { + this.started || (this.started = !0, document.addEventListener("selectionchange", this.update, !0)); + } + stop() { + if (this.started) return this.started = !1, document.removeEventListener("selectionchange", this.update, !0); + } + registerSelectionManager(t) { + if (!this.selectionManagers.includes(t)) return this.selectionManagers.push(t), this.start(); + } + unregisterSelectionManager(t) { + if (this.selectionManagers = this.selectionManagers.filter((e) => e !== t), this.selectionManagers.length === 0) return this.stop(); + } + notifySelectionManagersOfSelectionChange() { + return this.selectionManagers.map((t) => t.selectionDidChange()); + } + update() { + this.notifySelectionManagersOfSelectionChange(); + } + reset() { + this.update(); + } +} +const Mt = new wr(), kr = function() { + const s = window.getSelection(); + if (s.rangeCount > 0) return s; +}, fe = function() { + var s; + const t = (s = kr()) === null || s === void 0 ? void 0 : s.getRangeAt(0); + if (t && !zo(t)) return t; +}, Ir = function(s) { + const t = window.getSelection(); + return t.removeAllRanges(), t.addRange(s), Mt.update(); +}, zo = (s) => ds(s.startContainer) || ds(s.endContainer), ds = (s) => !Object.getPrototypeOf(s), ue = (s) => s.replace(new RegExp("".concat(ii), "g"), "").replace(new RegExp("".concat(_t), "g"), " "), Tn = new RegExp("[^\\S".concat(_t, "]")), wn = (s) => s.replace(new RegExp("".concat(Tn.source), "g"), " ").replace(/\ {2,}/g, " "), us = function(s, t) { + if (s.isEqualTo(t)) return ["", ""]; + const e = Di(s, t), { length: i } = e.utf16String; + let n; + if (i) { + const { offset: r } = e, o = s.codepoints.slice(0, r).concat(s.codepoints.slice(r + i)); + n = Di(t, ye.fromCodepoints(o)); + } else n = Di(t, s); + return [e.utf16String.toString(), n.utf16String.toString()]; +}, Di = function(s, t) { + let e = 0, i = s.length, n = t.length; + for (; e < i && s.charAt(e).isEqualTo(t.charAt(e)); ) e++; + for (; i > e + 1 && s.charAt(i - 1).isEqualTo(t.charAt(n - 1)); ) i--, n--; + return { utf16String: s.slice(e, i), offset: e }; +}; +class X extends Bt { + static fromCommonAttributesOfObjects() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; + if (!t.length) return new this(); + let e = se(t[0]), i = e.getKeys(); + return t.slice(1).forEach((n) => { + i = e.getKeysCommonToHash(se(n)), e = e.slice(i); + }), e; + } + static box(t) { + return se(t); + } + constructor() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + super(...arguments), this.values = Ke(t); + } + add(t, e) { + return this.merge(Ko(t, e)); + } + remove(t) { + return new X(Ke(this.values, t)); + } + get(t) { + return this.values[t]; + } + has(t) { + return t in this.values; + } + merge(t) { + return new X(Go(this.values, Jo(t))); + } + slice(t) { + const e = {}; + return Array.from(t).forEach((i) => { + this.has(i) && (e[i] = this.values[i]); + }), new X(e); + } + getKeys() { + return Object.keys(this.values); + } + getKeysCommonToHash(t) { + return t = se(t), this.getKeys().filter((e) => this.values[e] === t.values[e]); + } + isEqualTo(t) { + return Ot(this.toArray(), se(t).toArray()); + } + isEmpty() { + return this.getKeys().length === 0; + } + toArray() { + if (!this.array) { + const t = []; + for (const e in this.values) { + const i = this.values[e]; + t.push(t.push(e, i)); + } + this.array = t.slice(0); + } + return this.array; + } + toObject() { + return Ke(this.values); + } + toJSON() { + return this.toObject(); + } + contentsForInspection() { + return { values: JSON.stringify(this.values) }; + } +} +const Ko = function(s, t) { + const e = {}; + return e[s] = t, e; +}, Go = function(s, t) { + const e = Ke(s); + for (const i in t) { + const n = t[i]; + e[i] = n; + } + return e; +}, Ke = function(s, t) { + const e = {}; + return Object.keys(s).sort().forEach((i) => { + i !== t && (e[i] = s[i]); + }), e; +}, se = function(s) { + return s instanceof X ? s : new X(s); +}, Jo = function(s) { + return s instanceof X ? s.values : s; +}; +class kn { + static groupObjects() { + let t, e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], { depth: i, asTree: n } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + n && i == null && (i = 0); + const r = []; + return Array.from(e).forEach((o) => { + var a; + if (t) { + var c, h, d; + if ((c = o.canBeGrouped) !== null && c !== void 0 && c.call(o, i) && (h = (d = t[t.length - 1]).canBeGroupedWith) !== null && h !== void 0 && h.call(d, o, i)) return void t.push(o); + r.push(new this(t, { depth: i, asTree: n })), t = null; + } + (a = o.canBeGrouped) !== null && a !== void 0 && a.call(o, i) ? t = [o] : r.push(o); + }), t && r.push(new this(t, { depth: i, asTree: n })), r; + } + constructor() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], { depth: e, asTree: i } = arguments.length > 1 ? arguments[1] : void 0; + this.objects = t, i && (this.depth = e, this.objects = this.constructor.groupObjects(this.objects, { asTree: i, depth: this.depth + 1 })); + } + getObjects() { + return this.objects; + } + getDepth() { + return this.depth; + } + getCacheKey() { + const t = ["objectGroup"]; + return Array.from(this.getObjects()).forEach((e) => { + t.push(e.getCacheKey()); + }), t.join("/"); + } +} +class Yo extends M { + constructor() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; + super(...arguments), this.objects = {}, Array.from(t).forEach((e) => { + const i = JSON.stringify(e); + this.objects[i] == null && (this.objects[i] = e); + }); + } + find(t) { + const e = JSON.stringify(t); + return this.objects[e]; + } +} +class Xo { + constructor(t) { + this.reset(t); + } + add(t) { + const e = ms(t); + this.elements[e] = t; + } + remove(t) { + const e = ms(t), i = this.elements[e]; + if (i) return delete this.elements[e], i; + } + reset() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; + return this.elements = {}, Array.from(t).forEach((e) => { + this.add(e); + }), t; + } +} +const ms = (s) => s.dataset.trixStoreKey; +class Xe extends M { + isPerforming() { + return this.performing === !0; + } + hasPerformed() { + return this.performed === !0; + } + hasSucceeded() { + return this.performed && this.succeeded; + } + hasFailed() { + return this.performed && !this.succeeded; + } + getPromise() { + return this.promise || (this.promise = new Promise((t, e) => (this.performing = !0, this.perform((i, n) => { + this.succeeded = i, this.performing = !1, this.performed = !0, this.succeeded ? t(n) : e(n); + })))), this.promise; + } + perform(t) { + return t(!1); + } + release() { + var t, e; + (t = this.promise) === null || t === void 0 || (e = t.cancel) === null || e === void 0 || e.call(t), this.promise = null, this.performing = null, this.performed = null, this.succeeded = null; + } +} +Xe.proxyMethod("getPromise().then"), Xe.proxyMethod("getPromise().catch"); +class Nt extends M { + constructor(t) { + let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + super(...arguments), this.object = t, this.options = e, this.childViews = [], this.rootView = this; + } + getNodes() { + return this.nodes || (this.nodes = this.createNodes()), this.nodes.map((t) => t.cloneNode(!0)); + } + invalidate() { + var t; + return this.nodes = null, this.childViews = [], (t = this.parentView) === null || t === void 0 ? void 0 : t.invalidate(); + } + invalidateViewForObject(t) { + var e; + return (e = this.findViewForObject(t)) === null || e === void 0 ? void 0 : e.invalidate(); + } + findOrCreateCachedChildView(t, e, i) { + let n = this.getCachedViewForObject(e); + return n ? this.recordChildView(n) : (n = this.createChildView(...arguments), this.cacheViewForObject(n, e)), n; + } + createChildView(t, e) { + let i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; + e instanceof kn && (i.viewClass = t, t = Qo); + const n = new t(e, i); + return this.recordChildView(n); + } + recordChildView(t) { + return t.parentView = this, t.rootView = this.rootView, this.childViews.push(t), t; + } + getAllChildViews() { + let t = []; + return this.childViews.forEach((e) => { + t.push(e), t = t.concat(e.getAllChildViews()); + }), t; + } + findElement() { + return this.findElementForObject(this.object); + } + findElementForObject(t) { + const e = t == null ? void 0 : t.id; + if (e) return this.rootView.element.querySelector("[data-trix-id='".concat(e, "']")); + } + findViewForObject(t) { + for (const e of this.getAllChildViews()) if (e.object === t) return e; + } + getViewCache() { + return this.rootView !== this ? this.rootView.getViewCache() : this.isViewCachingEnabled() ? (this.viewCache || (this.viewCache = {}), this.viewCache) : void 0; + } + isViewCachingEnabled() { + return this.shouldCacheViews !== !1; + } + enableViewCaching() { + this.shouldCacheViews = !0; + } + disableViewCaching() { + this.shouldCacheViews = !1; + } + getCachedViewForObject(t) { + var e; + return (e = this.getViewCache()) === null || e === void 0 ? void 0 : e[t.getCacheKey()]; + } + cacheViewForObject(t, e) { + const i = this.getViewCache(); + i && (i[e.getCacheKey()] = t); + } + garbageCollectCachedViews() { + const t = this.getViewCache(); + if (t) { + const e = this.getAllChildViews().concat(this).map((i) => i.object.getCacheKey()); + for (const i in t) e.includes(i) || delete t[i]; + } + } +} +class Qo extends Nt { + constructor() { + super(...arguments), this.objectGroup = this.object, this.viewClass = this.options.viewClass, delete this.options.viewClass; + } + getChildViews() { + return this.childViews.length || Array.from(this.objectGroup.getObjects()).forEach((t) => { + this.findOrCreateCachedChildView(this.viewClass, t, this.options); + }), this.childViews; + } + createNodes() { + const t = this.createContainerElement(); + return this.getChildViews().forEach((e) => { + Array.from(e.getNodes()).forEach((i) => { + t.appendChild(i); + }); + }), [t]; + } + createContainerElement() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.objectGroup.getDepth(); + return this.getChildViews()[0].createContainerElement(t); + } +} +/*! @license DOMPurify 3.2.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.7/LICENSE */ +const { entries: Rr, setPrototypeOf: gs, isFrozen: Zo, getPrototypeOf: ta, getOwnPropertyDescriptor: ea } = Object; +let { freeze: J, seal: Z, create: Dr } = Object, { apply: mn, construct: gn } = typeof Reflect < "u" && Reflect; +J || (J = function(s) { + return s; +}), Z || (Z = function(s) { + return s; +}), mn || (mn = function(s, t) { + for (var e = arguments.length, i = new Array(e > 2 ? e - 2 : 0), n = 2; n < e; n++) i[n - 2] = arguments[n]; + return s.apply(t, i); +}), gn || (gn = function(s) { + for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++) e[i - 1] = arguments[i]; + return new s(...e); +}); +const Pe = Y(Array.prototype.forEach), ia = Y(Array.prototype.lastIndexOf), ps = Y(Array.prototype.pop), re = Y(Array.prototype.push), na = Y(Array.prototype.splice), Ge = Y(String.prototype.toLowerCase), Oi = Y(String.prototype.toString), Mi = Y(String.prototype.match), oe = Y(String.prototype.replace), sa = Y(String.prototype.indexOf), ra = Y(String.prototype.trim), rt = Y(Object.prototype.hasOwnProperty), z = Y(RegExp.prototype.test), ae = (fs = TypeError, function() { + for (var s = arguments.length, t = new Array(s), e = 0; e < s; e++) t[e] = arguments[e]; + return gn(fs, t); +}); +var fs; +function Y(s) { + return function(t) { + t instanceof RegExp && (t.lastIndex = 0); + for (var e = arguments.length, i = new Array(e > 1 ? e - 1 : 0), n = 1; n < e; n++) i[n - 1] = arguments[n]; + return mn(s, t, i); + }; +} +function A(s, t) { + let e = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Ge; + gs && gs(s, null); + let i = t.length; + for (; i--; ) { + let n = t[i]; + if (typeof n == "string") { + const r = e(n); + r !== n && (Zo(t) || (t[i] = r), n = r); + } + s[n] = !0; + } + return s; +} +function oa(s) { + for (let t = 0; t < s.length; t++) + rt(s, t) || (s[t] = null); + return s; +} +function ut(s) { + const t = Dr(null); + for (const [e, i] of Rr(s)) + rt(s, e) && (Array.isArray(i) ? t[e] = oa(i) : i && typeof i == "object" && i.constructor === Object ? t[e] = ut(i) : t[e] = i); + return t; +} +function le(s, t) { + for (; s !== null; ) { + const e = ea(s, t); + if (e) { + if (e.get) return Y(e.get); + if (typeof e.value == "function") return Y(e.value); + } + s = ta(s); + } + return function() { + return null; + }; +} +const bs = J(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Bi = J(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "slot", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Ni = J(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), aa = J(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Pi = J(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), la = J(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), vs = J(["#text"]), _s = J(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), Fi = J(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), As = J(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), Fe = J(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), ca = Z(/\{\{[\w\W]*|[\w\W]*\}\}/gm), ha = Z(/<%[\w\W]*|[\w\W]*%>/gm), da = Z(/\$\{[\w\W]*/gm), ua = Z(/^data-[\-\w.\u00B7-\uFFFF]+$/), ma = Z(/^aria-[\-\w]+$/), Or = Z(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i), ga = Z(/^(?:\w+script|data):/i), pa = Z(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g), Mr = Z(/^html$/i), fa = Z(/^[a-z][.\w]*(-[.\w]+)+$/i); +var ys = Object.freeze({ __proto__: null, ARIA_ATTR: ma, ATTR_WHITESPACE: pa, CUSTOM_ELEMENT: fa, DATA_ATTR: ua, DOCTYPE_NAME: Mr, ERB_EXPR: ha, IS_ALLOWED_URI: Or, IS_SCRIPT_OR_DATA: ga, MUSTACHE_EXPR: ca, TMPLIT_EXPR: da }); +const ba = 1, va = 3, _a = 7, Aa = 8, ya = 9, Ea = function() { + return typeof window > "u" ? null : window; +}; +var Ee = function s() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Ea(); + const e = (l) => s(l); + if (e.version = "3.2.7", e.removed = [], !t || !t.document || t.document.nodeType !== ya || !t.Element) return e.isSupported = !1, e; + let { document: i } = t; + const n = i, r = n.currentScript, { DocumentFragment: o, HTMLTemplateElement: a, Node: c, Element: h, NodeFilter: d, NamedNodeMap: m = t.NamedNodeMap || t.MozNamedAttrMap, HTMLFormElement: p, DOMParser: f, trustedTypes: C } = t, L = h.prototype, U = le(L, "cloneNode"), j = le(L, "remove"), q = le(L, "nextSibling"), N = le(L, "childNodes"), O = le(L, "parentNode"); + if (typeof a == "function") { + const l = i.createElement("template"); + l.content && l.content.ownerDocument && (i = l.content.ownerDocument); + } + let T, tt = ""; + const { implementation: ct, createNodeIterator: Et, createDocumentFragment: fo, getElementsByTagName: bo } = i, { importNode: vo } = n; + let W = { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; + e.isSupported = typeof Rr == "function" && typeof O == "function" && ct && ct.createHTMLDocument !== void 0; + const { MUSTACHE_EXPR: ai, ERB_EXPR: li, TMPLIT_EXPR: ci, DATA_ATTR: _o, ARIA_ATTR: Ao, IS_SCRIPT_OR_DATA: yo, ATTR_WHITESPACE: Dn, CUSTOM_ELEMENT: Eo } = ys; + let { IS_ALLOWED_URI: On } = ys, P = null; + const Mn = A({}, [...bs, ...Bi, ...Ni, ...Pi, ...vs]); + let H = null; + const Bn = A({}, [..._s, ...Fi, ...As, ...Fe]); + let I = Object.seal(Dr(null, { tagNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, attributeNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, allowCustomizedBuiltInElements: { writable: !0, configurable: !1, enumerable: !0, value: !1 } })), Qt = null, hi = null, Nn = !0, di = !0, Pn = !1, Fn = !0, Ft = !1, Te = !0, St = !1, ui = !1, mi = !1, qt = !1, we = !1, ke = !1, qn = !0, Hn = !1, gi = !0, Zt = !1, Ht = {}, $t = null; + const $n = A({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]); + let Un = null; + const jn = A({}, ["audio", "video", "img", "source", "image", "track"]); + let pi = null; + const Vn = A({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), Ie = "http://www.w3.org/1998/Math/MathML", Re = "http://www.w3.org/2000/svg", ht = "http://www.w3.org/1999/xhtml"; + let Ut = ht, fi = !1, bi = null; + const So = A({}, [Ie, Re, ht], Oi); + let De = A({}, ["mi", "mo", "mn", "ms", "mtext"]), Oe = A({}, ["annotation-xml"]); + const xo = A({}, ["title", "style", "font", "a", "script"]); + let te = null; + const Co = ["application/xhtml+xml", "text/html"]; + let F = null, jt = null; + const Lo = i.createElement("form"), Wn = function(l) { + return l instanceof RegExp || l instanceof Function; + }, vi = function() { + let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + if (!jt || jt !== l) { + if (l && typeof l == "object" || (l = {}), l = ut(l), te = Co.indexOf(l.PARSER_MEDIA_TYPE) === -1 ? "text/html" : l.PARSER_MEDIA_TYPE, F = te === "application/xhtml+xml" ? Oi : Ge, P = rt(l, "ALLOWED_TAGS") ? A({}, l.ALLOWED_TAGS, F) : Mn, H = rt(l, "ALLOWED_ATTR") ? A({}, l.ALLOWED_ATTR, F) : Bn, bi = rt(l, "ALLOWED_NAMESPACES") ? A({}, l.ALLOWED_NAMESPACES, Oi) : So, pi = rt(l, "ADD_URI_SAFE_ATTR") ? A(ut(Vn), l.ADD_URI_SAFE_ATTR, F) : Vn, Un = rt(l, "ADD_DATA_URI_TAGS") ? A(ut(jn), l.ADD_DATA_URI_TAGS, F) : jn, $t = rt(l, "FORBID_CONTENTS") ? A({}, l.FORBID_CONTENTS, F) : $n, Qt = rt(l, "FORBID_TAGS") ? A({}, l.FORBID_TAGS, F) : ut({}), hi = rt(l, "FORBID_ATTR") ? A({}, l.FORBID_ATTR, F) : ut({}), Ht = !!rt(l, "USE_PROFILES") && l.USE_PROFILES, Nn = l.ALLOW_ARIA_ATTR !== !1, di = l.ALLOW_DATA_ATTR !== !1, Pn = l.ALLOW_UNKNOWN_PROTOCOLS || !1, Fn = l.ALLOW_SELF_CLOSE_IN_ATTR !== !1, Ft = l.SAFE_FOR_TEMPLATES || !1, Te = l.SAFE_FOR_XML !== !1, St = l.WHOLE_DOCUMENT || !1, qt = l.RETURN_DOM || !1, we = l.RETURN_DOM_FRAGMENT || !1, ke = l.RETURN_TRUSTED_TYPE || !1, mi = l.FORCE_BODY || !1, qn = l.SANITIZE_DOM !== !1, Hn = l.SANITIZE_NAMED_PROPS || !1, gi = l.KEEP_CONTENT !== !1, Zt = l.IN_PLACE || !1, On = l.ALLOWED_URI_REGEXP || Or, Ut = l.NAMESPACE || ht, De = l.MATHML_TEXT_INTEGRATION_POINTS || De, Oe = l.HTML_INTEGRATION_POINTS || Oe, I = l.CUSTOM_ELEMENT_HANDLING || {}, l.CUSTOM_ELEMENT_HANDLING && Wn(l.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (I.tagNameCheck = l.CUSTOM_ELEMENT_HANDLING.tagNameCheck), l.CUSTOM_ELEMENT_HANDLING && Wn(l.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (I.attributeNameCheck = l.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), l.CUSTOM_ELEMENT_HANDLING && typeof l.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (I.allowCustomizedBuiltInElements = l.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), Ft && (di = !1), we && (qt = !0), Ht && (P = A({}, vs), H = [], Ht.html === !0 && (A(P, bs), A(H, _s)), Ht.svg === !0 && (A(P, Bi), A(H, Fi), A(H, Fe)), Ht.svgFilters === !0 && (A(P, Ni), A(H, Fi), A(H, Fe)), Ht.mathMl === !0 && (A(P, Pi), A(H, As), A(H, Fe))), l.ADD_TAGS && (P === Mn && (P = ut(P)), A(P, l.ADD_TAGS, F)), l.ADD_ATTR && (H === Bn && (H = ut(H)), A(H, l.ADD_ATTR, F)), l.ADD_URI_SAFE_ATTR && A(pi, l.ADD_URI_SAFE_ATTR, F), l.FORBID_CONTENTS && ($t === $n && ($t = ut($t)), A($t, l.FORBID_CONTENTS, F)), gi && (P["#text"] = !0), St && A(P, ["html", "head", "body"]), P.table && (A(P, ["tbody"]), delete Qt.tbody), l.TRUSTED_TYPES_POLICY) { + if (typeof l.TRUSTED_TYPES_POLICY.createHTML != "function") throw ae('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); + if (typeof l.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw ae('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); + T = l.TRUSTED_TYPES_POLICY, tt = T.createHTML(""); + } else T === void 0 && (T = function(g, u) { + if (typeof g != "object" || typeof g.createPolicy != "function") return null; + let y = null; + const S = "data-tt-policy-suffix"; + u && u.hasAttribute(S) && (y = u.getAttribute(S)); + const v = "dompurify" + (y ? "#" + y : ""); + try { + return g.createPolicy(v, { createHTML: (B) => B, createScriptURL: (B) => B }); + } catch { + return console.warn("TrustedTypes policy " + v + " could not be created."), null; + } + }(C, r)), T !== null && typeof tt == "string" && (tt = T.createHTML("")); + J && J(l), jt = l; + } + }, zn = A({}, [...Bi, ...Ni, ...aa]), Kn = A({}, [...Pi, ...la]), at = function(l) { + re(e.removed, { element: l }); + try { + O(l).removeChild(l); + } catch { + j(l); + } + }, xt = function(l, g) { + try { + re(e.removed, { attribute: g.getAttributeNode(l), from: g }); + } catch { + re(e.removed, { attribute: null, from: g }); + } + if (g.removeAttribute(l), l === "is") if (qt || we) try { + at(g); + } catch { + } + else try { + g.setAttribute(l, ""); + } catch { + } + }, Gn = function(l) { + let g = null, u = null; + if (mi) l = "" + l; + else { + const v = Mi(l, /^[\r\n\t ]+/); + u = v && v[0]; + } + te === "application/xhtml+xml" && Ut === ht && (l = '' + l + ""); + const y = T ? T.createHTML(l) : l; + if (Ut === ht) try { + g = new f().parseFromString(y, te); + } catch { + } + if (!g || !g.documentElement) { + g = ct.createDocument(Ut, "template", null); + try { + g.documentElement.innerHTML = fi ? tt : y; + } catch { + } + } + const S = g.body || g.documentElement; + return l && u && S.insertBefore(i.createTextNode(u), S.childNodes[0] || null), Ut === ht ? bo.call(g, St ? "html" : "body")[0] : St ? g.documentElement : S; + }, Jn = function(l) { + return Et.call(l.ownerDocument || l, l, d.SHOW_ELEMENT | d.SHOW_COMMENT | d.SHOW_TEXT | d.SHOW_PROCESSING_INSTRUCTION | d.SHOW_CDATA_SECTION, null); + }, _i = function(l) { + return l instanceof p && (typeof l.nodeName != "string" || typeof l.textContent != "string" || typeof l.removeChild != "function" || !(l.attributes instanceof m) || typeof l.removeAttribute != "function" || typeof l.setAttribute != "function" || typeof l.namespaceURI != "string" || typeof l.insertBefore != "function" || typeof l.hasChildNodes != "function"); + }, Yn = function(l) { + return typeof c == "function" && l instanceof c; + }; + function dt(l, g, u) { + Pe(l, (y) => { + y.call(e, g, u, jt); + }); + } + const Xn = function(l) { + let g = null; + if (dt(W.beforeSanitizeElements, l, null), _i(l)) return at(l), !0; + const u = F(l.nodeName); + if (dt(W.uponSanitizeElement, l, { tagName: u, allowedTags: P }), Te && l.hasChildNodes() && !Yn(l.firstElementChild) && z(/<[/\w!]/g, l.innerHTML) && z(/<[/\w!]/g, l.textContent) || l.nodeType === _a || Te && l.nodeType === Aa && z(/<[/\w]/g, l.data)) return at(l), !0; + if (!P[u] || Qt[u]) { + if (!Qt[u] && Zn(u) && (I.tagNameCheck instanceof RegExp && z(I.tagNameCheck, u) || I.tagNameCheck instanceof Function && I.tagNameCheck(u))) + return !1; + if (gi && !$t[u]) { + const y = O(l) || l.parentNode, S = N(l) || l.childNodes; + if (S && y) + for (let v = S.length - 1; v >= 0; --v) { + const B = U(S[v], !0); + B.__removalCount = (l.__removalCount || 0) + 1, y.insertBefore(B, q(l)); + } + } + return at(l), !0; + } + return l instanceof h && !function(y) { + let S = O(y); + S && S.tagName || (S = { namespaceURI: Ut, tagName: "template" }); + const v = Ge(y.tagName), B = Ge(S.tagName); + return !!bi[y.namespaceURI] && (y.namespaceURI === Re ? S.namespaceURI === ht ? v === "svg" : S.namespaceURI === Ie ? v === "svg" && (B === "annotation-xml" || De[B]) : !!zn[v] : y.namespaceURI === Ie ? S.namespaceURI === ht ? v === "math" : S.namespaceURI === Re ? v === "math" && Oe[B] : !!Kn[v] : y.namespaceURI === ht ? !(S.namespaceURI === Re && !Oe[B]) && !(S.namespaceURI === Ie && !De[B]) && !Kn[v] && (xo[v] || !zn[v]) : !(te !== "application/xhtml+xml" || !bi[y.namespaceURI])); + }(l) ? (at(l), !0) : u !== "noscript" && u !== "noembed" && u !== "noframes" || !z(/<\/no(script|embed|frames)/i, l.innerHTML) ? (Ft && l.nodeType === va && (g = l.textContent, Pe([ai, li, ci], (y) => { + g = oe(g, y, " "); + }), l.textContent !== g && (re(e.removed, { element: l.cloneNode() }), l.textContent = g)), dt(W.afterSanitizeElements, l, null), !1) : (at(l), !0); + }, Qn = function(l, g, u) { + if (qn && (g === "id" || g === "name") && (u in i || u in Lo)) return !1; + if (!(di && !hi[g] && z(_o, g))) { + if (!(Nn && z(Ao, g))) { + if (!H[g] || hi[g]) { + if (!(Zn(l) && (I.tagNameCheck instanceof RegExp && z(I.tagNameCheck, l) || I.tagNameCheck instanceof Function && I.tagNameCheck(l)) && (I.attributeNameCheck instanceof RegExp && z(I.attributeNameCheck, g) || I.attributeNameCheck instanceof Function && I.attributeNameCheck(g, l)) || g === "is" && I.allowCustomizedBuiltInElements && (I.tagNameCheck instanceof RegExp && z(I.tagNameCheck, u) || I.tagNameCheck instanceof Function && I.tagNameCheck(u)))) return !1; + } else if (!pi[g]) { + if (!z(On, oe(u, Dn, ""))) { + if ((g !== "src" && g !== "xlink:href" && g !== "href" || l === "script" || sa(u, "data:") !== 0 || !Un[l]) && !(Pn && !z(yo, oe(u, Dn, "")))) { + if (u) return !1; + } + } + } + } + } + return !0; + }, Zn = function(l) { + return l !== "annotation-xml" && Mi(l, Eo); + }, ts = function(l) { + dt(W.beforeSanitizeAttributes, l, null); + const { attributes: g } = l; + if (!g || _i(l)) return; + const u = { attrName: "", attrValue: "", keepAttr: !0, allowedAttributes: H, forceKeepAttr: void 0 }; + let y = g.length; + for (; y--; ) { + const S = g[y], { name: v, namespaceURI: B, value: pt } = S, et = F(v), Ai = pt; + let $ = v === "value" ? Ai : ra(Ai); + if (u.attrName = et, u.attrValue = $, u.keepAttr = !0, u.forceKeepAttr = void 0, dt(W.uponSanitizeAttribute, l, u), $ = u.attrValue, !Hn || et !== "id" && et !== "name" || (xt(v, l), $ = "user-content-" + $), Te && z(/((--!?|])>)|<\/(style|title|textarea)/i, $)) { + xt(v, l); + continue; + } + if (et === "attributename" && Mi($, "href")) { + xt(v, l); + continue; + } + if (u.forceKeepAttr) continue; + if (!u.keepAttr) { + xt(v, l); + continue; + } + if (!Fn && z(/\/>/i, $)) { + xt(v, l); + continue; + } + Ft && Pe([ai, li, ci], (is) => { + $ = oe($, is, " "); + }); + const es = F(l.nodeName); + if (Qn(es, et, $)) { + if (T && typeof C == "object" && typeof C.getAttributeType == "function" && !B) switch (C.getAttributeType(es, et)) { + case "TrustedHTML": + $ = T.createHTML($); + break; + case "TrustedScriptURL": + $ = T.createScriptURL($); + } + if ($ !== Ai) try { + B ? l.setAttributeNS(B, v, $) : l.setAttribute(v, $), _i(l) ? at(l) : ps(e.removed); + } catch { + xt(v, l); + } + } else xt(v, l); + } + dt(W.afterSanitizeAttributes, l, null); + }, To = function l(g) { + let u = null; + const y = Jn(g); + for (dt(W.beforeSanitizeShadowDOM, g, null); u = y.nextNode(); ) dt(W.uponSanitizeShadowNode, u, null), Xn(u), ts(u), u.content instanceof o && l(u.content); + dt(W.afterSanitizeShadowDOM, g, null); + }; + return e.sanitize = function(l) { + let g = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, u = null, y = null, S = null, v = null; + if (fi = !l, fi && (l = ""), typeof l != "string" && !Yn(l)) { + if (typeof l.toString != "function") throw ae("toString is not a function"); + if (typeof (l = l.toString()) != "string") throw ae("dirty is not a string, aborting"); + } + if (!e.isSupported) return l; + if (ui || vi(g), e.removed = [], typeof l == "string" && (Zt = !1), Zt) { + if (l.nodeName) { + const et = F(l.nodeName); + if (!P[et] || Qt[et]) throw ae("root node is forbidden and cannot be sanitized in-place"); + } + } else if (l instanceof c) u = Gn(""), y = u.ownerDocument.importNode(l, !0), y.nodeType === ba && y.nodeName === "BODY" || y.nodeName === "HTML" ? u = y : u.appendChild(y); + else { + if (!qt && !Ft && !St && l.indexOf("<") === -1) return T && ke ? T.createHTML(l) : l; + if (u = Gn(l), !u) return qt ? null : ke ? tt : ""; + } + u && mi && at(u.firstChild); + const B = Jn(Zt ? l : u); + for (; S = B.nextNode(); ) Xn(S), ts(S), S.content instanceof o && To(S.content); + if (Zt) return l; + if (qt) { + if (we) for (v = fo.call(u.ownerDocument); u.firstChild; ) v.appendChild(u.firstChild); + else v = u; + return (H.shadowroot || H.shadowrootmode) && (v = vo.call(n, v, !0)), v; + } + let pt = St ? u.outerHTML : u.innerHTML; + return St && P["!doctype"] && u.ownerDocument && u.ownerDocument.doctype && u.ownerDocument.doctype.name && z(Mr, u.ownerDocument.doctype.name) && (pt = " +` + pt), Ft && Pe([ai, li, ci], (et) => { + pt = oe(pt, et, " "); + }), T && ke ? T.createHTML(pt) : pt; + }, e.setConfig = function() { + vi(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), ui = !0; + }, e.clearConfig = function() { + jt = null, ui = !1; + }, e.isValidAttribute = function(l, g, u) { + jt || vi({}); + const y = F(l), S = F(g); + return Qn(y, S, u); + }, e.addHook = function(l, g) { + typeof g == "function" && re(W[l], g); + }, e.removeHook = function(l, g) { + if (g !== void 0) { + const u = ia(W[l], g); + return u === -1 ? void 0 : na(W[l], u, 1)[0]; + } + return ps(W[l]); + }, e.removeHooks = function(l) { + W[l] = []; + }, e.removeAllHooks = function() { + W = { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; + }, e; +}(); +Ee.addHook("uponSanitizeAttribute", function(s, t) { + /^data-trix-/.test(t.attrName) && (t.forceKeepAttr = !0); +}); +const Sa = "style href src width height language class".split(" "), xa = "javascript:".split(" "), Ca = "script iframe form noscript".split(" "); +class ni extends M { + static setHTML(t, e, i) { + const n = new this(e, i).sanitize(), r = n.getHTML ? n.getHTML() : n.outerHTML; + t.innerHTML = r; + } + static sanitize(t, e) { + const i = new this(t, e); + return i.sanitize(), i; + } + constructor(t) { + let { allowedAttributes: e, forbiddenProtocols: i, forbiddenElements: n, purifyOptions: r } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + super(...arguments), this.allowedAttributes = e || Sa, this.forbiddenProtocols = i || xa, this.forbiddenElements = n || Ca, this.purifyOptions = r || {}, this.body = La(t); + } + sanitize() { + this.sanitizeElements(), this.normalizeListElementNesting(); + const t = Object.assign({}, br, this.purifyOptions); + return Ee.setConfig(t), this.body = Ee.sanitize(this.body), this.body; + } + getHTML() { + return this.body.innerHTML; + } + getBody() { + return this.body; + } + sanitizeElements() { + const t = Je(this.body), e = []; + for (; t.nextNode(); ) { + const i = t.currentNode; + switch (i.nodeType) { + case Node.ELEMENT_NODE: + this.elementIsRemovable(i) ? e.push(i) : this.sanitizeElement(i); + break; + case Node.COMMENT_NODE: + e.push(i); + } + } + return e.forEach((i) => yt(i)), this.body; + } + sanitizeElement(t) { + return t.hasAttribute("href") && this.forbiddenProtocols.includes(t.protocol) && t.removeAttribute("href"), Array.from(t.attributes).forEach((e) => { + let { name: i } = e; + this.allowedAttributes.includes(i) || i.indexOf("data-trix") === 0 || t.removeAttribute(i); + }), t; + } + normalizeListElementNesting() { + return Array.from(this.body.querySelectorAll("ul,ol")).forEach((t) => { + const e = t.previousElementSibling; + e && K(e) === "li" && e.appendChild(t); + }), this.body; + } + elementIsRemovable(t) { + if ((t == null ? void 0 : t.nodeType) === Node.ELEMENT_NODE) return this.elementIsForbidden(t) || this.elementIsntSerializable(t); + } + elementIsForbidden(t) { + return this.forbiddenElements.includes(K(t)); + } + elementIsntSerializable(t) { + return t.getAttribute("data-trix-serialize") === "false" && !It(t); + } +} +const La = function() { + let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; + s = s.replace(/<\/html[^>]*>[^]*$/i, ""); + const t = document.implementation.createHTMLDocument(""); + return t.documentElement.innerHTML = s, Array.from(t.head.querySelectorAll("style")).forEach((e) => { + t.body.appendChild(e); + }), t.body; +}, { css: ft } = Le; +class In extends Nt { + constructor() { + super(...arguments), this.attachment = this.object, this.attachment.uploadProgressDelegate = this, this.attachmentPiece = this.options.piece; + } + createContentNodes() { + return []; + } + createNodes() { + let t; + const e = t = _({ tagName: "figure", className: this.getClassName(), data: this.getData(), editable: !1 }), i = this.getHref(); + return i && (t = _({ tagName: "a", editable: !1, attributes: { href: i, tabindex: -1 } }), e.appendChild(t)), this.attachment.hasContent() ? ni.setHTML(t, this.attachment.getContent()) : this.createContentNodes().forEach((n) => { + t.appendChild(n); + }), t.appendChild(this.createCaptionElement()), this.attachment.isPending() && (this.progressElement = _({ tagName: "progress", attributes: { class: ft.attachmentProgress, value: this.attachment.getUploadProgress(), max: 100 }, data: { trixMutable: !0, trixStoreKey: ["progressElement", this.attachment.id].join("/") } }), e.appendChild(this.progressElement)), [Es("left"), e, Es("right")]; + } + createCaptionElement() { + const t = _({ tagName: "figcaption", className: ft.attachmentCaption }), e = this.attachmentPiece.getCaption(); + if (e) t.classList.add("".concat(ft.attachmentCaption, "--edited")), t.textContent = e; + else { + let i, n; + const r = this.getCaptionConfig(); + if (r.name && (i = this.attachment.getFilename()), r.size && (n = this.attachment.getFormattedFilesize()), i) { + const o = _({ tagName: "span", className: ft.attachmentName, textContent: i }); + t.appendChild(o); + } + if (n) { + i && t.appendChild(document.createTextNode(" ")); + const o = _({ tagName: "span", className: ft.attachmentSize, textContent: n }); + t.appendChild(o); + } + } + return t; + } + getClassName() { + const t = [ft.attachment, "".concat(ft.attachment, "--").concat(this.attachment.getType())], e = this.attachment.getExtension(); + return e && t.push("".concat(ft.attachment, "--").concat(e)), t.join(" "); + } + getData() { + const t = { trixAttachment: JSON.stringify(this.attachment), trixContentType: this.attachment.getContentType(), trixId: this.attachment.id }, { attributes: e } = this.attachmentPiece; + return e.isEmpty() || (t.trixAttributes = JSON.stringify(e)), this.attachment.isPending() && (t.trixSerialize = !1), t; + } + getHref() { + if (!Ta(this.attachment.getContent(), "a")) { + const t = this.attachment.getHref(); + if (t && Ee.isValidAttribute("a", "href", t)) return t; + } + } + getCaptionConfig() { + var t; + const e = this.attachment.getType(), i = Tr((t = yn[e]) === null || t === void 0 ? void 0 : t.caption); + return e === "file" && (i.name = !0), i; + } + findProgressElement() { + var t; + return (t = this.findElement()) === null || t === void 0 ? void 0 : t.querySelector("progress"); + } + attachmentDidChangeUploadProgress() { + const t = this.attachment.getUploadProgress(), e = this.findProgressElement(); + e && (e.value = t); + } +} +const Es = (s) => _({ tagName: "span", textContent: ii, data: { trixCursorTarget: s, trixSerialize: !1 } }), Ta = function(s, t) { + const e = _("div"); + return ni.setHTML(e, s || ""), e.querySelector(t); +}; +class Br extends In { + constructor() { + super(...arguments), this.attachment.previewDelegate = this; + } + createContentNodes() { + return this.image = _({ tagName: "img", attributes: { src: "" }, data: { trixMutable: !0 } }), this.refresh(this.image), [this.image]; + } + createCaptionElement() { + const t = super.createCaptionElement(...arguments); + return t.textContent || t.setAttribute("data-trix-placeholder", b.captionPlaceholder), t; + } + refresh(t) { + var e; + if (t || (t = (e = this.findElement()) === null || e === void 0 ? void 0 : e.querySelector("img")), t) return this.updateAttributesForImage(t); + } + updateAttributesForImage(t) { + const e = this.attachment.getURL(), i = this.attachment.getPreviewURL(); + if (t.src = i || e, i === e) t.removeAttribute("data-trix-serialized-attributes"); + else { + const c = JSON.stringify({ src: e }); + t.setAttribute("data-trix-serialized-attributes", c); + } + const n = this.attachment.getWidth(), r = this.attachment.getHeight(), o = this.attachment.getAttribute("alt"); + n != null && (t.width = n), r != null && (t.height = r), o != null && (t.alt = o); + const a = ["imageElement", this.attachment.id, t.src, t.width, t.height].join("/"); + t.dataset.trixStoreKey = a; + } + attachmentDidChangeAttributes() { + return this.refresh(this.image), this.refresh(); + } +} +class Nr extends Nt { + constructor() { + super(...arguments), this.piece = this.object, this.attributes = this.piece.getAttributes(), this.textConfig = this.options.textConfig, this.context = this.options.context, this.piece.attachment ? this.attachment = this.piece.attachment : this.string = this.piece.toString(); + } + createNodes() { + let t = this.attachment ? this.createAttachmentNodes() : this.createStringNodes(); + const e = this.createElement(); + if (e) { + const i = function(n) { + for (; (r = n) !== null && r !== void 0 && r.firstElementChild; ) { + var r; + n = n.firstElementChild; + } + return n; + }(e); + Array.from(t).forEach((n) => { + i.appendChild(n); + }), t = [e]; + } + return t; + } + createAttachmentNodes() { + const t = this.attachment.isPreviewable() ? Br : In; + return this.createChildView(t, this.piece.attachment, { piece: this.piece }).getNodes(); + } + createStringNodes() { + var t; + if ((t = this.textConfig) !== null && t !== void 0 && t.plaintext) return [document.createTextNode(this.string)]; + { + const e = [], i = this.string.split(` +`); + for (let n = 0; n < i.length; n++) { + const r = i[n]; + if (n > 0) { + const o = _("br"); + e.push(o); + } + if (r.length) { + const o = document.createTextNode(this.preserveSpaces(r)); + e.push(o); + } + } + return e; + } + } + createElement() { + let t, e, i; + const n = {}; + for (e in this.attributes) { + i = this.attributes[e]; + const o = dn(e); + if (o) { + if (o.tagName) { + var r; + const a = _(o.tagName); + r ? (r.appendChild(a), r = a) : t = r = a; + } + if (o.styleProperty && (n[o.styleProperty] = i), o.style) for (e in o.style) i = o.style[e], n[e] = i; + } + } + if (Object.keys(n).length) for (e in t || (t = _("span")), n) i = n[e], t.style[e] = i; + return t; + } + createContainerElement() { + for (const t in this.attributes) { + const e = this.attributes[t], i = dn(t); + if (i && i.groupTagName) { + const n = {}; + return n[t] = e, _(i.groupTagName, n); + } + } + } + preserveSpaces(t) { + return this.context.isLast && (t = t.replace(/\ $/, _t)), t = t.replace(/(\S)\ {3}(\S)/g, "$1 ".concat(_t, " $2")).replace(/\ {2}/g, "".concat(_t, " ")).replace(/\ {2}/g, " ".concat(_t)), (this.context.isFirst || this.context.followsWhitespace) && (t = t.replace(/^\ /, _t)), t; + } +} +class Pr extends Nt { + constructor() { + super(...arguments), this.text = this.object, this.textConfig = this.options.textConfig; + } + createNodes() { + const t = [], e = kn.groupObjects(this.getPieces()), i = e.length - 1; + for (let r = 0; r < e.length; r++) { + const o = e[r], a = {}; + r === 0 && (a.isFirst = !0), r === i && (a.isLast = !0), wa(n) && (a.followsWhitespace = !0); + const c = this.findOrCreateCachedChildView(Nr, o, { textConfig: this.textConfig, context: a }); + t.push(...Array.from(c.getNodes() || [])); + var n = o; + } + return t; + } + getPieces() { + return Array.from(this.text.getPieces()).filter((t) => !t.hasAttribute("blockBreak")); + } +} +const wa = (s) => /\s$/.test(s == null ? void 0 : s.toString()), { css: Ss } = Le; +class Fr extends Nt { + constructor() { + super(...arguments), this.block = this.object, this.attributes = this.block.getAttributes(); + } + createNodes() { + const t = [document.createComment("block")]; + if (this.block.isEmpty()) t.push(_("br")); + else { + var e; + const i = (e = D(this.block.getLastAttribute())) === null || e === void 0 ? void 0 : e.text, n = this.findOrCreateCachedChildView(Pr, this.block.text, { textConfig: i }); + t.push(...Array.from(n.getNodes() || [])), this.shouldAddExtraNewlineElement() && t.push(_("br")); + } + if (this.attributes.length) return t; + { + let i; + const { tagName: n } = G.default; + this.block.isRTL() && (i = { dir: "rtl" }); + const r = _({ tagName: n, attributes: i }); + return t.forEach((o) => r.appendChild(o)), [r]; + } + } + createContainerElement(t) { + const e = {}; + let i; + const n = this.attributes[t], { tagName: r, htmlAttributes: o = [] } = D(n); + if (t === 0 && this.block.isRTL() && Object.assign(e, { dir: "rtl" }), n === "attachmentGallery") { + const a = this.block.getBlockBreakPosition(); + i = "".concat(Ss.attachmentGallery, " ").concat(Ss.attachmentGallery, "--").concat(a); + } + return Object.entries(this.block.htmlAttributes).forEach((a) => { + let [c, h] = a; + o.includes(c) && (e[c] = h); + }), _({ tagName: r, className: i, attributes: e }); + } + shouldAddExtraNewlineElement() { + return /\n\n$/.test(this.block.toString()); + } +} +class si extends Nt { + static render(t) { + const e = _("div"), i = new this(t, { element: e }); + return i.render(), i.sync(), e; + } + constructor() { + super(...arguments), this.element = this.options.element, this.elementStore = new Xo(), this.setDocument(this.object); + } + setDocument(t) { + t.isEqualTo(this.document) || (this.document = this.object = t); + } + render() { + if (this.childViews = [], this.shadowElement = _("div"), !this.document.isEmpty()) { + const t = kn.groupObjects(this.document.getBlocks(), { asTree: !0 }); + Array.from(t).forEach((e) => { + const i = this.findOrCreateCachedChildView(Fr, e); + Array.from(i.getNodes()).map((n) => this.shadowElement.appendChild(n)); + }); + } + } + isSynced() { + return ka(this.shadowElement, this.element); + } + sync() { + const t = Ar("trix-before-render", { cancelable: !1, attributes: { render: (i, n) => { + for (; i.lastChild; ) i.removeChild(i.lastChild); + i.appendChild(n); + } } }); + this.element.dispatchEvent(t); + const e = this.createDocumentFragmentForSync(); + return t.render(this.element, e), this.didSync(); + } + didSync() { + return this.elementStore.reset(xs(this.element)), Ln(() => this.garbageCollectCachedViews()); + } + createDocumentFragmentForSync() { + const t = document.createDocumentFragment(); + return Array.from(this.shadowElement.childNodes).forEach((e) => { + t.appendChild(e.cloneNode(!0)); + }), Array.from(xs(t)).forEach((e) => { + const i = this.elementStore.remove(e); + i && e.parentNode.replaceChild(i, e); + }), t; + } +} +const xs = (s) => s.querySelectorAll("[data-trix-store-key]"), ka = (s, t) => Cs(s.innerHTML) === Cs(t.innerHTML), Cs = (s) => s.replace(/ /g, " "); +function Ia(s) { + var t = function(e, i) { + if (typeof e != "object" || !e) return e; + var n = e[Symbol.toPrimitive]; + if (n !== void 0) { + var r = n.call(e, i); + if (typeof r != "object") return r; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (i === "string" ? String : Number)(e); + }(s, "string"); + return typeof t == "symbol" ? t : String(t); +} +function V(s, t, e) { + return (t = Ia(t)) in s ? Object.defineProperty(s, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : s[t] = e, s; +} +function E(s, t) { + return Ra(s, qr(s, t, "get")); +} +function be(s, t, e) { + return Da(s, qr(s, t, "set"), e), e; +} +function qr(s, t, e) { + if (!t.has(s)) throw new TypeError("attempted to " + e + " private field on non-instance"); + return t.get(s); +} +function Ra(s, t) { + return t.get ? t.get.call(s) : t.value; +} +function Da(s, t, e) { + if (t.set) t.set.call(s, e); + else { + if (!t.writable) throw new TypeError("attempted to set read only private field"); + t.value = e; + } +} +function qe(s, t, e) { + if (!t.has(s)) throw new TypeError("attempted to get private field on non-instance"); + return e; +} +function Hr(s, t) { + if (t.has(s)) throw new TypeError("Cannot initialize the same private elements twice on an object"); +} +function Gt(s, t, e) { + Hr(s, t), t.set(s, e); +} +class Pt extends Bt { + static registerType(t, e) { + e.type = t, this.types[t] = e; + } + static fromJSON(t) { + const e = this.types[t.type]; + if (e) return e.fromJSON(t); + } + constructor(t) { + let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + super(...arguments), this.attributes = X.box(e); + } + copyWithAttributes(t) { + return new this.constructor(this.getValue(), t); + } + copyWithAdditionalAttributes(t) { + return this.copyWithAttributes(this.attributes.merge(t)); + } + copyWithoutAttribute(t) { + return this.copyWithAttributes(this.attributes.remove(t)); + } + copy() { + return this.copyWithAttributes(this.attributes); + } + getAttribute(t) { + return this.attributes.get(t); + } + getAttributesHash() { + return this.attributes; + } + getAttributes() { + return this.attributes.toObject(); + } + hasAttribute(t) { + return this.attributes.has(t); + } + hasSameStringValueAsPiece(t) { + return t && this.toString() === t.toString(); + } + hasSameAttributesAsPiece(t) { + return t && (this.attributes === t.attributes || this.attributes.isEqualTo(t.attributes)); + } + isBlockBreak() { + return !1; + } + isEqualTo(t) { + return super.isEqualTo(...arguments) || this.hasSameConstructorAs(t) && this.hasSameStringValueAsPiece(t) && this.hasSameAttributesAsPiece(t); + } + isEmpty() { + return this.length === 0; + } + isSerializable() { + return !0; + } + toJSON() { + return { type: this.constructor.type, attributes: this.getAttributes() }; + } + contentsForInspection() { + return { type: this.constructor.type, attributes: this.attributes.inspect() }; + } + canBeGrouped() { + return this.hasAttribute("href"); + } + canBeGroupedWith(t) { + return this.getAttribute("href") === t.getAttribute("href"); + } + getLength() { + return this.length; + } + canBeConsolidatedWith(t) { + return !1; + } +} +V(Pt, "types", {}); +class $r extends Xe { + constructor(t) { + super(...arguments), this.url = t; + } + perform(t) { + const e = new Image(); + e.onload = () => (e.width = this.width = e.naturalWidth, e.height = this.height = e.naturalHeight, t(!0, e)), e.onerror = () => t(!1), e.src = this.url; + } +} +class Xt extends Bt { + static attachmentForFile(t) { + const e = new this(this.attributesForFile(t)); + return e.setFile(t), e; + } + static attributesForFile(t) { + return new X({ filename: t.name, filesize: t.size, contentType: t.type }); + } + static fromJSON(t) { + return new this(t); + } + constructor() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + super(t), this.releaseFile = this.releaseFile.bind(this), this.attributes = X.box(t), this.didChangeAttributes(); + } + setAttribute(t, e) { + this.setAttributes({ [t]: e }); + } + getAttribute(t) { + return this.attributes.get(t); + } + hasAttribute(t) { + return this.attributes.has(t); + } + getAttributes() { + return this.attributes.toObject(); + } + setAttributes() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + const e = this.attributes.merge(t); + var i, n, r, o; + if (!this.attributes.isEqualTo(e)) return this.attributes = e, this.didChangeAttributes(), (i = this.previewDelegate) === null || i === void 0 || (n = i.attachmentDidChangeAttributes) === null || n === void 0 || n.call(i, this), (r = this.delegate) === null || r === void 0 || (o = r.attachmentDidChangeAttributes) === null || o === void 0 ? void 0 : o.call(r, this); + } + didChangeAttributes() { + if (this.isPreviewable()) return this.preloadURL(); + } + isPending() { + return this.file != null && !(this.getURL() || this.getHref()); + } + isPreviewable() { + return this.attributes.has("previewable") ? this.attributes.get("previewable") : Xt.previewablePattern.test(this.getContentType()); + } + getType() { + return this.hasContent() ? "content" : this.isPreviewable() ? "preview" : "file"; + } + getURL() { + return this.attributes.get("url"); + } + getHref() { + return this.attributes.get("href"); + } + getFilename() { + return this.attributes.get("filename") || ""; + } + getFilesize() { + return this.attributes.get("filesize"); + } + getFormattedFilesize() { + const t = this.attributes.get("filesize"); + return typeof t == "number" ? vr.formatter(t) : ""; + } + getExtension() { + var t; + return (t = this.getFilename().match(/\.(\w+)$/)) === null || t === void 0 ? void 0 : t[1].toLowerCase(); + } + getContentType() { + return this.attributes.get("contentType"); + } + hasContent() { + return this.attributes.has("content"); + } + getContent() { + return this.attributes.get("content"); + } + getWidth() { + return this.attributes.get("width"); + } + getHeight() { + return this.attributes.get("height"); + } + getFile() { + return this.file; + } + setFile(t) { + if (this.file = t, this.isPreviewable()) return this.preloadFile(); + } + releaseFile() { + this.releasePreloadedFile(), this.file = null; + } + getUploadProgress() { + return this.uploadProgress != null ? this.uploadProgress : 0; + } + setUploadProgress(t) { + var e, i; + if (this.uploadProgress !== t) return this.uploadProgress = t, (e = this.uploadProgressDelegate) === null || e === void 0 || (i = e.attachmentDidChangeUploadProgress) === null || i === void 0 ? void 0 : i.call(e, this); + } + toJSON() { + return this.getAttributes(); + } + getCacheKey() { + return [super.getCacheKey(...arguments), this.attributes.getCacheKey(), this.getPreviewURL()].join("/"); + } + getPreviewURL() { + return this.previewURL || this.preloadingURL; + } + setPreviewURL(t) { + var e, i, n, r; + if (t !== this.getPreviewURL()) return this.previewURL = t, (e = this.previewDelegate) === null || e === void 0 || (i = e.attachmentDidChangeAttributes) === null || i === void 0 || i.call(e, this), (n = this.delegate) === null || n === void 0 || (r = n.attachmentDidChangePreviewURL) === null || r === void 0 ? void 0 : r.call(n, this); + } + preloadURL() { + return this.preload(this.getURL(), this.releaseFile); + } + preloadFile() { + if (this.file) return this.fileObjectURL = URL.createObjectURL(this.file), this.preload(this.fileObjectURL); + } + releasePreloadedFile() { + this.fileObjectURL && (URL.revokeObjectURL(this.fileObjectURL), this.fileObjectURL = null); + } + preload(t, e) { + if (t && t !== this.getPreviewURL()) + return this.preloadingURL = t, new $r(t).then((i) => { + let { width: n, height: r } = i; + return this.getWidth() && this.getHeight() || this.setAttributes({ width: n, height: r }), this.preloadingURL = null, this.setPreviewURL(t), e == null ? void 0 : e(); + }).catch(() => (this.preloadingURL = null, e == null ? void 0 : e())); + } +} +V(Xt, "previewablePattern", /^image(\/(gif|png|webp|jpe?g)|$)/); +class Jt extends Pt { + static fromJSON(t) { + return new this(Xt.fromJSON(t.attachment), t.attributes); + } + constructor(t) { + super(...arguments), this.attachment = t, this.length = 1, this.ensureAttachmentExclusivelyHasAttribute("href"), this.attachment.hasContent() || this.removeProhibitedAttributes(); + } + ensureAttachmentExclusivelyHasAttribute(t) { + this.hasAttribute(t) && (this.attachment.hasAttribute(t) || this.attachment.setAttributes(this.attributes.slice([t])), this.attributes = this.attributes.remove(t)); + } + removeProhibitedAttributes() { + const t = this.attributes.slice(Jt.permittedAttributes); + t.isEqualTo(this.attributes) || (this.attributes = t); + } + getValue() { + return this.attachment; + } + isSerializable() { + return !this.attachment.isPending(); + } + getCaption() { + return this.attributes.get("caption") || ""; + } + isEqualTo(t) { + var e; + return super.isEqualTo(t) && this.attachment.id === (t == null || (e = t.attachment) === null || e === void 0 ? void 0 : e.id); + } + toString() { + return ""; + } + toJSON() { + const t = super.toJSON(...arguments); + return t.attachment = this.attachment, t; + } + getCacheKey() { + return [super.getCacheKey(...arguments), this.attachment.getCacheKey()].join("/"); + } + toConsole() { + return JSON.stringify(this.toString()); + } +} +V(Jt, "permittedAttributes", ["caption", "presentation"]), Pt.registerType("attachment", Jt); +class Rn extends Pt { + static fromJSON(t) { + return new this(t.string, t.attributes); + } + constructor(t) { + super(...arguments), this.string = ((e) => e.replace(/\r\n?/g, ` +`))(t), this.length = this.string.length; + } + getValue() { + return this.string; + } + toString() { + return this.string.toString(); + } + isBlockBreak() { + return this.toString() === ` +` && this.getAttribute("blockBreak") === !0; + } + toJSON() { + const t = super.toJSON(...arguments); + return t.string = this.string, t; + } + canBeConsolidatedWith(t) { + return t && this.hasSameConstructorAs(t) && this.hasSameAttributesAsPiece(t); + } + consolidateWith(t) { + return new this.constructor(this.toString() + t.toString(), this.attributes); + } + splitAtOffset(t) { + let e, i; + return t === 0 ? (e = null, i = this) : t === this.length ? (e = this, i = null) : (e = new this.constructor(this.string.slice(0, t), this.attributes), i = new this.constructor(this.string.slice(t), this.attributes)), [e, i]; + } + toConsole() { + let { string: t } = this; + return t.length > 15 && (t = t.slice(0, 14) + "…"), JSON.stringify(t.toString()); + } +} +Pt.registerType("string", Rn); +class Qe extends Bt { + static box(t) { + return t instanceof this ? t : new this(t); + } + constructor() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; + super(...arguments), this.objects = t.slice(0), this.length = this.objects.length; + } + indexOf(t) { + return this.objects.indexOf(t); + } + splice() { + for (var t = arguments.length, e = new Array(t), i = 0; i < t; i++) e[i] = arguments[i]; + return new this.constructor(Cn(this.objects, ...e)); + } + eachObject(t) { + return this.objects.map((e, i) => t(e, i)); + } + insertObjectAtIndex(t, e) { + return this.splice(e, 0, t); + } + insertSplittableListAtIndex(t, e) { + return this.splice(e, 0, ...t.objects); + } + insertSplittableListAtPosition(t, e) { + const [i, n] = this.splitObjectAtPosition(e); + return new this.constructor(i).insertSplittableListAtIndex(t, n); + } + editObjectAtIndex(t, e) { + return this.replaceObjectAtIndex(e(this.objects[t]), t); + } + replaceObjectAtIndex(t, e) { + return this.splice(e, 1, t); + } + removeObjectAtIndex(t) { + return this.splice(t, 1); + } + getObjectAtIndex(t) { + return this.objects[t]; + } + getSplittableListInRange(t) { + const [e, i, n] = this.splitObjectsAtRange(t); + return new this.constructor(e.slice(i, n + 1)); + } + selectSplittableList(t) { + const e = this.objects.filter((i) => t(i)); + return new this.constructor(e); + } + removeObjectsInRange(t) { + const [e, i, n] = this.splitObjectsAtRange(t); + return new this.constructor(e).splice(i, n - i + 1); + } + transformObjectsInRange(t, e) { + const [i, n, r] = this.splitObjectsAtRange(t), o = i.map((a, c) => n <= c && c <= r ? e(a) : a); + return new this.constructor(o); + } + splitObjectsAtRange(t) { + let e, [i, n, r] = this.splitObjectAtPosition(Ma(t)); + return [i, e] = new this.constructor(i).splitObjectAtPosition(Ba(t) + r), [i, n, e - 1]; + } + getObjectAtPosition(t) { + const { index: e } = this.findIndexAndOffsetAtPosition(t); + return this.objects[e]; + } + splitObjectAtPosition(t) { + let e, i; + const { index: n, offset: r } = this.findIndexAndOffsetAtPosition(t), o = this.objects.slice(0); + if (n != null) if (r === 0) e = n, i = 0; + else { + const a = this.getObjectAtIndex(n), [c, h] = a.splitAtOffset(r); + o.splice(n, 1, c, h), e = n + 1, i = c.getLength() - r; + } + else e = o.length, i = 0; + return [o, e, i]; + } + consolidate() { + const t = []; + let e = this.objects[0]; + return this.objects.slice(1).forEach((i) => { + var n, r; + (n = (r = e).canBeConsolidatedWith) !== null && n !== void 0 && n.call(r, i) ? e = e.consolidateWith(i) : (t.push(e), e = i); + }), e && t.push(e), new this.constructor(t); + } + consolidateFromIndexToIndex(t, e) { + const i = this.objects.slice(0).slice(t, e + 1), n = new this.constructor(i).consolidate().toArray(); + return this.splice(t, i.length, ...n); + } + findIndexAndOffsetAtPosition(t) { + let e, i = 0; + for (e = 0; e < this.objects.length; e++) { + const n = i + this.objects[e].getLength(); + if (i <= t && t < n) return { index: e, offset: t - i }; + i = n; + } + return { index: null, offset: null }; + } + findPositionAtIndexAndOffset(t, e) { + let i = 0; + for (let n = 0; n < this.objects.length; n++) { + const r = this.objects[n]; + if (n < t) i += r.getLength(); + else if (n === t) { + i += e; + break; + } + } + return i; + } + getEndPosition() { + return this.endPosition == null && (this.endPosition = 0, this.objects.forEach((t) => this.endPosition += t.getLength())), this.endPosition; + } + toString() { + return this.objects.join(""); + } + toArray() { + return this.objects.slice(0); + } + toJSON() { + return this.toArray(); + } + isEqualTo(t) { + return super.isEqualTo(...arguments) || Oa(this.objects, t == null ? void 0 : t.objects); + } + contentsForInspection() { + return { objects: "[".concat(this.objects.map((t) => t.inspect()).join(", "), "]") }; + } +} +const Oa = function(s) { + let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; + if (s.length !== t.length) return !1; + let e = !0; + for (let i = 0; i < s.length; i++) { + const n = s[i]; + e && !n.isEqualTo(t[i]) && (e = !1); + } + return e; +}, Ma = (s) => s[0], Ba = (s) => s[1]; +class ot extends Bt { + static textForAttachmentWithAttributes(t, e) { + return new this([new Jt(t, e)]); + } + static textForStringWithAttributes(t, e) { + return new this([new Rn(t, e)]); + } + static fromJSON(t) { + return new this(Array.from(t).map((e) => Pt.fromJSON(e))); + } + constructor() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; + super(...arguments); + const e = t.filter((i) => !i.isEmpty()); + this.pieceList = new Qe(e); + } + copy() { + return this.copyWithPieceList(this.pieceList); + } + copyWithPieceList(t) { + return new this.constructor(t.consolidate().toArray()); + } + copyUsingObjectMap(t) { + const e = this.getPieces().map((i) => t.find(i) || i); + return new this.constructor(e); + } + appendText(t) { + return this.insertTextAtPosition(t, this.getLength()); + } + insertTextAtPosition(t, e) { + return this.copyWithPieceList(this.pieceList.insertSplittableListAtPosition(t.pieceList, e)); + } + removeTextAtRange(t) { + return this.copyWithPieceList(this.pieceList.removeObjectsInRange(t)); + } + replaceTextAtRange(t, e) { + return this.removeTextAtRange(e).insertTextAtPosition(t, e[0]); + } + moveTextFromRangeToPosition(t, e) { + if (t[0] <= e && e <= t[1]) return; + const i = this.getTextAtRange(t), n = i.getLength(); + return t[0] < e && (e -= n), this.removeTextAtRange(t).insertTextAtPosition(i, e); + } + addAttributeAtRange(t, e, i) { + const n = {}; + return n[t] = e, this.addAttributesAtRange(n, i); + } + addAttributesAtRange(t, e) { + return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e, (i) => i.copyWithAdditionalAttributes(t))); + } + removeAttributeAtRange(t, e) { + return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e, (i) => i.copyWithoutAttribute(t))); + } + setAttributesAtRange(t, e) { + return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e, (i) => i.copyWithAttributes(t))); + } + getAttributesAtPosition(t) { + var e; + return ((e = this.pieceList.getObjectAtPosition(t)) === null || e === void 0 ? void 0 : e.getAttributes()) || {}; + } + getCommonAttributes() { + const t = Array.from(this.pieceList.toArray()).map((e) => e.getAttributes()); + return X.fromCommonAttributesOfObjects(t).toObject(); + } + getCommonAttributesAtRange(t) { + return this.getTextAtRange(t).getCommonAttributes() || {}; + } + getExpandedRangeForAttributeAtOffset(t, e) { + let i, n = i = e; + const r = this.getLength(); + for (; n > 0 && this.getCommonAttributesAtRange([n - 1, i])[t]; ) n--; + for (; i < r && this.getCommonAttributesAtRange([e, i + 1])[t]; ) i++; + return [n, i]; + } + getTextAtRange(t) { + return this.copyWithPieceList(this.pieceList.getSplittableListInRange(t)); + } + getStringAtRange(t) { + return this.pieceList.getSplittableListInRange(t).toString(); + } + getStringAtPosition(t) { + return this.getStringAtRange([t, t + 1]); + } + startsWithString(t) { + return this.getStringAtRange([0, t.length]) === t; + } + endsWithString(t) { + const e = this.getLength(); + return this.getStringAtRange([e - t.length, e]) === t; + } + getAttachmentPieces() { + return this.pieceList.toArray().filter((t) => !!t.attachment); + } + getAttachments() { + return this.getAttachmentPieces().map((t) => t.attachment); + } + getAttachmentAndPositionById(t) { + let e = 0; + for (const n of this.pieceList.toArray()) { + var i; + if (((i = n.attachment) === null || i === void 0 ? void 0 : i.id) === t) return { attachment: n.attachment, position: e }; + e += n.length; + } + return { attachment: null, position: null }; + } + getAttachmentById(t) { + const { attachment: e } = this.getAttachmentAndPositionById(t); + return e; + } + getRangeOfAttachment(t) { + const e = this.getAttachmentAndPositionById(t.id), i = e.position; + if (t = e.attachment) return [i, i + 1]; + } + updateAttributesForAttachment(t, e) { + const i = this.getRangeOfAttachment(e); + return i ? this.addAttributesAtRange(t, i) : this; + } + getLength() { + return this.pieceList.getEndPosition(); + } + isEmpty() { + return this.getLength() === 0; + } + isEqualTo(t) { + var e; + return super.isEqualTo(t) || (t == null || (e = t.pieceList) === null || e === void 0 ? void 0 : e.isEqualTo(this.pieceList)); + } + isBlockBreak() { + return this.getLength() === 1 && this.pieceList.getObjectAtIndex(0).isBlockBreak(); + } + eachPiece(t) { + return this.pieceList.eachObject(t); + } + getPieces() { + return this.pieceList.toArray(); + } + getPieceAtPosition(t) { + return this.pieceList.getObjectAtPosition(t); + } + contentsForInspection() { + return { pieceList: this.pieceList.inspect() }; + } + toSerializableText() { + const t = this.pieceList.selectSplittableList((e) => e.isSerializable()); + return this.copyWithPieceList(t); + } + toString() { + return this.pieceList.toString(); + } + toJSON() { + return this.pieceList.toJSON(); + } + toConsole() { + return JSON.stringify(this.pieceList.toArray().map((t) => JSON.parse(t.toConsole()))); + } + getDirection() { + return $o(this.toString()); + } + isRTL() { + return this.getDirection() === "rtl"; + } +} +class lt extends Bt { + static fromJSON(t) { + return new this(ot.fromJSON(t.text), t.attributes, t.htmlAttributes); + } + constructor(t, e, i) { + super(...arguments), this.text = Na(t || new ot()), this.attributes = e || [], this.htmlAttributes = i || {}; + } + isEmpty() { + return this.text.isBlockBreak(); + } + isEqualTo(t) { + return !!super.isEqualTo(t) || this.text.isEqualTo(t == null ? void 0 : t.text) && Ot(this.attributes, t == null ? void 0 : t.attributes) && Yt(this.htmlAttributes, t == null ? void 0 : t.htmlAttributes); + } + copyWithText(t) { + return new lt(t, this.attributes, this.htmlAttributes); + } + copyWithoutText() { + return this.copyWithText(null); + } + copyWithAttributes(t) { + return new lt(this.text, t, this.htmlAttributes); + } + copyWithoutAttributes() { + return this.copyWithAttributes(null); + } + copyUsingObjectMap(t) { + const e = t.find(this.text); + return e ? this.copyWithText(e) : this.copyWithText(this.text.copyUsingObjectMap(t)); + } + addAttribute(t) { + const e = this.attributes.concat(Ls(t)); + return this.copyWithAttributes(e); + } + addHTMLAttribute(t, e) { + const i = Object.assign({}, this.htmlAttributes, { [t]: e }); + return new lt(this.text, this.attributes, i); + } + removeAttribute(t) { + const { listAttribute: e } = D(t), i = ws(ws(this.attributes, t), e); + return this.copyWithAttributes(i); + } + removeLastAttribute() { + return this.removeAttribute(this.getLastAttribute()); + } + getLastAttribute() { + return Ts(this.attributes); + } + getAttributes() { + return this.attributes.slice(0); + } + getAttributeLevel() { + return this.attributes.length; + } + getAttributeAtLevel(t) { + return this.attributes[t - 1]; + } + hasAttribute(t) { + return this.attributes.includes(t); + } + hasAttributes() { + return this.getAttributeLevel() > 0; + } + getLastNestableAttribute() { + return Ts(this.getNestableAttributes()); + } + getNestableAttributes() { + return this.attributes.filter((t) => D(t).nestable); + } + getNestingLevel() { + return this.getNestableAttributes().length; + } + decreaseNestingLevel() { + const t = this.getLastNestableAttribute(); + return t ? this.removeAttribute(t) : this; + } + increaseNestingLevel() { + const t = this.getLastNestableAttribute(); + if (t) { + const e = this.attributes.lastIndexOf(t), i = Cn(this.attributes, e + 1, 0, ...Ls(t)); + return this.copyWithAttributes(i); + } + return this; + } + getListItemAttributes() { + return this.attributes.filter((t) => D(t).listAttribute); + } + isListItem() { + var t; + return (t = D(this.getLastAttribute())) === null || t === void 0 ? void 0 : t.listAttribute; + } + isTerminalBlock() { + var t; + return (t = D(this.getLastAttribute())) === null || t === void 0 ? void 0 : t.terminal; + } + breaksOnReturn() { + var t; + return (t = D(this.getLastAttribute())) === null || t === void 0 ? void 0 : t.breakOnReturn; + } + findLineBreakInDirectionFromPosition(t, e) { + const i = this.toString(); + let n; + switch (t) { + case "forward": + n = i.indexOf(` +`, e); + break; + case "backward": + n = i.slice(0, e).lastIndexOf(` +`); + } + if (n !== -1) return n; + } + contentsForInspection() { + return { text: this.text.inspect(), attributes: this.attributes }; + } + toString() { + return this.text.toString(); + } + toJSON() { + return { text: this.text, attributes: this.attributes, htmlAttributes: this.htmlAttributes }; + } + getDirection() { + return this.text.getDirection(); + } + isRTL() { + return this.text.isRTL(); + } + getLength() { + return this.text.getLength(); + } + canBeConsolidatedWith(t) { + return !this.hasAttributes() && !t.hasAttributes() && this.getDirection() === t.getDirection(); + } + consolidateWith(t) { + const e = ot.textForStringWithAttributes(` +`), i = this.getTextWithoutBlockBreak().appendText(e); + return this.copyWithText(i.appendText(t.text)); + } + splitAtOffset(t) { + let e, i; + return t === 0 ? (e = null, i = this) : t === this.getLength() ? (e = this, i = null) : (e = this.copyWithText(this.text.getTextAtRange([0, t])), i = this.copyWithText(this.text.getTextAtRange([t, this.getLength()]))), [e, i]; + } + getBlockBreakPosition() { + return this.text.getLength() - 1; + } + getTextWithoutBlockBreak() { + return Ur(this.text) ? this.text.getTextAtRange([0, this.getBlockBreakPosition()]) : this.text.copy(); + } + canBeGrouped(t) { + return this.attributes[t]; + } + canBeGroupedWith(t, e) { + const i = t.getAttributes(), n = i[e], r = this.attributes[e]; + return r === n && !(D(r).group === !1 && !(() => { + if (!Ne) { + Ne = []; + for (const o in G) { + const { listAttribute: a } = G[o]; + a != null && Ne.push(a); + } + } + return Ne; + })().includes(i[e + 1])) && (this.getDirection() === t.getDirection() || t.isEmpty()); + } +} +const Na = function(s) { + return s = Pa(s), s = qa(s); +}, Pa = function(s) { + let t = !1; + const e = s.getPieces(); + let i = e.slice(0, e.length - 1); + const n = e[e.length - 1]; + return n ? (i = i.map((r) => r.isBlockBreak() ? (t = !0, Ha(r)) : r), t ? new ot([...i, n]) : s) : s; +}, Fa = ot.textForStringWithAttributes(` +`, { blockBreak: !0 }), qa = function(s) { + return Ur(s) ? s : s.appendText(Fa); +}, Ur = function(s) { + const t = s.getLength(); + return t === 0 ? !1 : s.getTextAtRange([t - 1, t]).isBlockBreak(); +}, Ha = (s) => s.copyWithoutAttribute("blockBreak"), Ls = function(s) { + const { listAttribute: t } = D(s); + return t ? [t, s] : [s]; +}, Ts = (s) => s.slice(-1)[0], ws = function(s, t) { + const e = s.lastIndexOf(t); + return e === -1 ? s : Cn(s, e, 1); +}; +class Q extends Bt { + static fromJSON(t) { + return new this(Array.from(t).map((e) => lt.fromJSON(e))); + } + static fromString(t, e) { + const i = ot.textForStringWithAttributes(t, e); + return new this([new lt(i)]); + } + constructor() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; + super(...arguments), t.length === 0 && (t = [new lt()]), this.blockList = Qe.box(t); + } + isEmpty() { + const t = this.getBlockAtIndex(0); + return this.blockList.length === 1 && t.isEmpty() && !t.hasAttributes(); + } + copy() { + const t = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}).consolidateBlocks ? this.blockList.consolidate().toArray() : this.blockList.toArray(); + return new this.constructor(t); + } + copyUsingObjectsFromDocument(t) { + const e = new Yo(t.getObjects()); + return this.copyUsingObjectMap(e); + } + copyUsingObjectMap(t) { + const e = this.getBlocks().map((i) => t.find(i) || i.copyUsingObjectMap(t)); + return new this.constructor(e); + } + copyWithBaseBlockAttributes() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; + const e = this.getBlocks().map((i) => { + const n = t.concat(i.getAttributes()); + return i.copyWithAttributes(n); + }); + return new this.constructor(e); + } + replaceBlock(t, e) { + const i = this.blockList.indexOf(t); + return i === -1 ? this : new this.constructor(this.blockList.replaceObjectAtIndex(e, i)); + } + insertDocumentAtRange(t, e) { + const { blockList: i } = t; + e = x(e); + let [n] = e; + const { index: r, offset: o } = this.locationFromPosition(n); + let a = this; + const c = this.getBlockAtPosition(n); + return gt(e) && c.isEmpty() && !c.hasAttributes() ? a = new this.constructor(a.blockList.removeObjectAtIndex(r)) : c.getBlockBreakPosition() === o && n++, a = a.removeTextAtRange(e), new this.constructor(a.blockList.insertSplittableListAtPosition(i, n)); + } + mergeDocumentAtRange(t, e) { + let i, n; + e = x(e); + const [r] = e, o = this.locationFromPosition(r), a = this.getBlockAtIndex(o.index).getAttributes(), c = t.getBaseBlockAttributes(), h = a.slice(-c.length); + if (Ot(c, h)) { + const p = a.slice(0, -c.length); + i = t.copyWithBaseBlockAttributes(p); + } else i = t.copy({ consolidateBlocks: !0 }).copyWithBaseBlockAttributes(a); + const d = i.getBlockCount(), m = i.getBlockAtIndex(0); + if (Ot(a, m.getAttributes())) { + const p = m.getTextWithoutBlockBreak(); + if (n = this.insertTextAtRange(p, e), d > 1) { + i = new this.constructor(i.getBlocks().slice(1)); + const f = r + p.getLength(); + n = n.insertDocumentAtRange(i, f); + } + } else n = this.insertDocumentAtRange(i, e); + return n; + } + insertTextAtRange(t, e) { + e = x(e); + const [i] = e, { index: n, offset: r } = this.locationFromPosition(i), o = this.removeTextAtRange(e); + return new this.constructor(o.blockList.editObjectAtIndex(n, (a) => a.copyWithText(a.text.insertTextAtPosition(t, r)))); + } + removeTextAtRange(t) { + let e; + t = x(t); + const [i, n] = t; + if (gt(t)) return this; + const [r, o] = Array.from(this.locationRangeFromRange(t)), a = r.index, c = r.offset, h = this.getBlockAtIndex(a), d = o.index, m = o.offset, p = this.getBlockAtIndex(d); + if (n - i == 1 && h.getBlockBreakPosition() === c && p.getBlockBreakPosition() !== m && p.text.getStringAtPosition(m) === ` +`) e = this.blockList.editObjectAtIndex(d, (f) => f.copyWithText(f.text.removeTextAtRange([m, m + 1]))); + else { + let f; + const C = h.text.getTextAtRange([0, c]), L = p.text.getTextAtRange([m, p.getLength()]), U = C.appendText(L); + f = a !== d && c === 0 && h.getAttributeLevel() >= p.getAttributeLevel() ? p.copyWithText(U) : h.copyWithText(U); + const j = d + 1 - a; + e = this.blockList.splice(a, j, f); + } + return new this.constructor(e); + } + moveTextFromRangeToPosition(t, e) { + let i; + t = x(t); + const [n, r] = t; + if (n <= e && e <= r) return this; + let o = this.getDocumentAtRange(t), a = this.removeTextAtRange(t); + const c = n < e; + c && (e -= o.getLength()); + const [h, ...d] = o.getBlocks(); + return d.length === 0 ? (i = h.getTextWithoutBlockBreak(), c && (e += 1)) : i = h.text, a = a.insertTextAtRange(i, e), d.length === 0 ? a : (o = new this.constructor(d), e += i.getLength(), a.insertDocumentAtRange(o, e)); + } + addAttributeAtRange(t, e, i) { + let { blockList: n } = this; + return this.eachBlockAtRange(i, (r, o, a) => n = n.editObjectAtIndex(a, function() { + return D(t) ? r.addAttribute(t, e) : o[0] === o[1] ? r : r.copyWithText(r.text.addAttributeAtRange(t, e, o)); + })), new this.constructor(n); + } + addAttribute(t, e) { + let { blockList: i } = this; + return this.eachBlock((n, r) => i = i.editObjectAtIndex(r, () => n.addAttribute(t, e))), new this.constructor(i); + } + removeAttributeAtRange(t, e) { + let { blockList: i } = this; + return this.eachBlockAtRange(e, function(n, r, o) { + D(t) ? i = i.editObjectAtIndex(o, () => n.removeAttribute(t)) : r[0] !== r[1] && (i = i.editObjectAtIndex(o, () => n.copyWithText(n.text.removeAttributeAtRange(t, r)))); + }), new this.constructor(i); + } + updateAttributesForAttachment(t, e) { + const i = this.getRangeOfAttachment(e), [n] = Array.from(i), { index: r } = this.locationFromPosition(n), o = this.getTextAtIndex(r); + return new this.constructor(this.blockList.editObjectAtIndex(r, (a) => a.copyWithText(o.updateAttributesForAttachment(t, e)))); + } + removeAttributeForAttachment(t, e) { + const i = this.getRangeOfAttachment(e); + return this.removeAttributeAtRange(t, i); + } + setHTMLAttributeAtPosition(t, e, i) { + const n = this.getBlockAtPosition(t), r = n.addHTMLAttribute(e, i); + return this.replaceBlock(n, r); + } + insertBlockBreakAtRange(t) { + let e; + t = x(t); + const [i] = t, { offset: n } = this.locationFromPosition(i), r = this.removeTextAtRange(t); + return n === 0 && (e = [new lt()]), new this.constructor(r.blockList.insertSplittableListAtPosition(new Qe(e), i)); + } + applyBlockAttributeAtRange(t, e, i) { + const n = this.expandRangeToLineBreaksAndSplitBlocks(i); + let r = n.document; + i = n.range; + const o = D(t); + if (o.listAttribute) { + r = r.removeLastListAttributeAtRange(i, { exceptAttributeName: t }); + const a = r.convertLineBreaksToBlockBreaksInRange(i); + r = a.document, i = a.range; + } else r = o.exclusive ? r.removeBlockAttributesAtRange(i) : o.terminal ? r.removeLastTerminalAttributeAtRange(i) : r.consolidateBlocksAtRange(i); + return r.addAttributeAtRange(t, e, i); + } + removeLastListAttributeAtRange(t) { + let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, { blockList: i } = this; + return this.eachBlockAtRange(t, function(n, r, o) { + const a = n.getLastAttribute(); + a && D(a).listAttribute && a !== e.exceptAttributeName && (i = i.editObjectAtIndex(o, () => n.removeAttribute(a))); + }), new this.constructor(i); + } + removeLastTerminalAttributeAtRange(t) { + let { blockList: e } = this; + return this.eachBlockAtRange(t, function(i, n, r) { + const o = i.getLastAttribute(); + o && D(o).terminal && (e = e.editObjectAtIndex(r, () => i.removeAttribute(o))); + }), new this.constructor(e); + } + removeBlockAttributesAtRange(t) { + let { blockList: e } = this; + return this.eachBlockAtRange(t, function(i, n, r) { + i.hasAttributes() && (e = e.editObjectAtIndex(r, () => i.copyWithoutAttributes())); + }), new this.constructor(e); + } + expandRangeToLineBreaksAndSplitBlocks(t) { + let e; + t = x(t); + let [i, n] = t; + const r = this.locationFromPosition(i), o = this.locationFromPosition(n); + let a = this; + const c = a.getBlockAtIndex(r.index); + if (r.offset = c.findLineBreakInDirectionFromPosition("backward", r.offset), r.offset != null && (e = a.positionFromLocation(r), a = a.insertBlockBreakAtRange([e, e + 1]), o.index += 1, o.offset -= a.getBlockAtIndex(r.index).getLength(), r.index += 1), r.offset = 0, o.offset === 0 && o.index > r.index) o.index -= 1, o.offset = a.getBlockAtIndex(o.index).getBlockBreakPosition(); + else { + const h = a.getBlockAtIndex(o.index); + h.text.getStringAtRange([o.offset - 1, o.offset]) === ` +` ? o.offset -= 1 : o.offset = h.findLineBreakInDirectionFromPosition("forward", o.offset), o.offset !== h.getBlockBreakPosition() && (e = a.positionFromLocation(o), a = a.insertBlockBreakAtRange([e, e + 1])); + } + return i = a.positionFromLocation(r), n = a.positionFromLocation(o), { document: a, range: t = x([i, n]) }; + } + convertLineBreaksToBlockBreaksInRange(t) { + t = x(t); + let [e] = t; + const i = this.getStringAtRange(t).slice(0, -1); + let n = this; + return i.replace(/.*?\n/g, function(r) { + e += r.length, n = n.insertBlockBreakAtRange([e - 1, e]); + }), { document: n, range: t }; + } + consolidateBlocksAtRange(t) { + t = x(t); + const [e, i] = t, n = this.locationFromPosition(e).index, r = this.locationFromPosition(i).index; + return new this.constructor(this.blockList.consolidateFromIndexToIndex(n, r)); + } + getDocumentAtRange(t) { + t = x(t); + const e = this.blockList.getSplittableListInRange(t).toArray(); + return new this.constructor(e); + } + getStringAtRange(t) { + let e; + const i = t = x(t); + return i[i.length - 1] !== this.getLength() && (e = -1), this.getDocumentAtRange(t).toString().slice(0, e); + } + getBlockAtIndex(t) { + return this.blockList.getObjectAtIndex(t); + } + getBlockAtPosition(t) { + const { index: e } = this.locationFromPosition(t); + return this.getBlockAtIndex(e); + } + getTextAtIndex(t) { + var e; + return (e = this.getBlockAtIndex(t)) === null || e === void 0 ? void 0 : e.text; + } + getTextAtPosition(t) { + const { index: e } = this.locationFromPosition(t); + return this.getTextAtIndex(e); + } + getPieceAtPosition(t) { + const { index: e, offset: i } = this.locationFromPosition(t); + return this.getTextAtIndex(e).getPieceAtPosition(i); + } + getCharacterAtPosition(t) { + const { index: e, offset: i } = this.locationFromPosition(t); + return this.getTextAtIndex(e).getStringAtRange([i, i + 1]); + } + getLength() { + return this.blockList.getEndPosition(); + } + getBlocks() { + return this.blockList.toArray(); + } + getBlockCount() { + return this.blockList.length; + } + getEditCount() { + return this.editCount; + } + eachBlock(t) { + return this.blockList.eachObject(t); + } + eachBlockAtRange(t, e) { + let i, n; + t = x(t); + const [r, o] = t, a = this.locationFromPosition(r), c = this.locationFromPosition(o); + if (a.index === c.index) return i = this.getBlockAtIndex(a.index), n = [a.offset, c.offset], e(i, n, a.index); + for (let h = a.index; h <= c.index; h++) if (i = this.getBlockAtIndex(h), i) { + switch (h) { + case a.index: + n = [a.offset, i.text.getLength()]; + break; + case c.index: + n = [0, c.offset]; + break; + default: + n = [0, i.text.getLength()]; + } + e(i, n, h); + } + } + getCommonAttributesAtRange(t) { + t = x(t); + const [e] = t; + if (gt(t)) return this.getCommonAttributesAtPosition(e); + { + const i = [], n = []; + return this.eachBlockAtRange(t, function(r, o) { + if (o[0] !== o[1]) return i.push(r.text.getCommonAttributesAtRange(o)), n.push(ks(r)); + }), X.fromCommonAttributesOfObjects(i).merge(X.fromCommonAttributesOfObjects(n)).toObject(); + } + } + getCommonAttributesAtPosition(t) { + let e, i; + const { index: n, offset: r } = this.locationFromPosition(t), o = this.getBlockAtIndex(n); + if (!o) return {}; + const a = ks(o), c = o.text.getAttributesAtPosition(r), h = o.text.getAttributesAtPosition(r - 1), d = Object.keys(Dt).filter((m) => Dt[m].inheritable); + for (e in h) i = h[e], (i === c[e] || d.includes(e)) && (a[e] = i); + return a; + } + getRangeOfCommonAttributeAtPosition(t, e) { + const { index: i, offset: n } = this.locationFromPosition(e), r = this.getTextAtIndex(i), [o, a] = Array.from(r.getExpandedRangeForAttributeAtOffset(t, n)), c = this.positionFromLocation({ index: i, offset: o }), h = this.positionFromLocation({ index: i, offset: a }); + return x([c, h]); + } + getBaseBlockAttributes() { + let t = this.getBlockAtIndex(0).getAttributes(); + for (let e = 1; e < this.getBlockCount(); e++) { + const i = this.getBlockAtIndex(e).getAttributes(), n = Math.min(t.length, i.length); + t = (() => { + const r = []; + for (let o = 0; o < n && i[o] === t[o]; o++) r.push(i[o]); + return r; + })(); + } + return t; + } + getAttachmentById(t) { + for (const e of this.getAttachments()) if (e.id === t) return e; + } + getAttachmentPieces() { + let t = []; + return this.blockList.eachObject((e) => { + let { text: i } = e; + return t = t.concat(i.getAttachmentPieces()); + }), t; + } + getAttachments() { + return this.getAttachmentPieces().map((t) => t.attachment); + } + getRangeOfAttachment(t) { + let e = 0; + const i = this.blockList.toArray(); + for (let n = 0; n < i.length; n++) { + const { text: r } = i[n], o = r.getRangeOfAttachment(t); + if (o) return x([e + o[0], e + o[1]]); + e += r.getLength(); + } + } + getLocationRangeOfAttachment(t) { + const e = this.getRangeOfAttachment(t); + return this.locationRangeFromRange(e); + } + getAttachmentPieceForAttachment(t) { + for (const e of this.getAttachmentPieces()) if (e.attachment === t) return e; + } + findRangesForBlockAttribute(t) { + let e = 0; + const i = []; + return this.getBlocks().forEach((n) => { + const r = n.getLength(); + n.hasAttribute(t) && i.push([e, e + r]), e += r; + }), i; + } + findRangesForTextAttribute(t) { + let { withValue: e } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = 0, n = []; + const r = []; + return this.getPieces().forEach((o) => { + const a = o.getLength(); + (function(c) { + return e ? c.getAttribute(t) === e : c.hasAttribute(t); + })(o) && (n[1] === i ? n[1] = i + a : r.push(n = [i, i + a])), i += a; + }), r; + } + locationFromPosition(t) { + const e = this.blockList.findIndexAndOffsetAtPosition(Math.max(0, t)); + if (e.index != null) return e; + { + const i = this.getBlocks(); + return { index: i.length - 1, offset: i[i.length - 1].getLength() }; + } + } + positionFromLocation(t) { + return this.blockList.findPositionAtIndexAndOffset(t.index, t.offset); + } + locationRangeFromPosition(t) { + return x(this.locationFromPosition(t)); + } + locationRangeFromRange(t) { + if (!(t = x(t))) return; + const [e, i] = Array.from(t), n = this.locationFromPosition(e), r = this.locationFromPosition(i); + return x([n, r]); + } + rangeFromLocationRange(t) { + let e; + t = x(t); + const i = this.positionFromLocation(t[0]); + return gt(t) || (e = this.positionFromLocation(t[1])), x([i, e]); + } + isEqualTo(t) { + return this.blockList.isEqualTo(t == null ? void 0 : t.blockList); + } + getTexts() { + return this.getBlocks().map((t) => t.text); + } + getPieces() { + const t = []; + return Array.from(this.getTexts()).forEach((e) => { + t.push(...Array.from(e.getPieces() || [])); + }), t; + } + getObjects() { + return this.getBlocks().concat(this.getTexts()).concat(this.getPieces()); + } + toSerializableDocument() { + const t = []; + return this.blockList.eachObject((e) => t.push(e.copyWithText(e.text.toSerializableText()))), new this.constructor(t); + } + toString() { + return this.blockList.toString(); + } + toJSON() { + return this.blockList.toJSON(); + } + toConsole() { + return JSON.stringify(this.blockList.toArray().map((t) => JSON.parse(t.text.toConsole()))); + } +} +const ks = function(s) { + const t = {}, e = s.getLastAttribute(); + return e && (t[e] = !0), t; +}, qi = function(s) { + let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + return { string: s = ue(s), attributes: t, type: "string" }; +}, Is = (s, t) => { + try { + return JSON.parse(s.getAttribute("data-trix-".concat(t))); + } catch { + return {}; + } +}; +class Se extends M { + static parse(t, e) { + const i = new this(t, e); + return i.parse(), i; + } + constructor(t) { + let { referenceElement: e, purifyOptions: i } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + super(...arguments), this.html = t, this.referenceElement = e, this.purifyOptions = i, this.blocks = [], this.blockElements = [], this.processedElements = []; + } + getDocument() { + return Q.fromJSON(this.blocks); + } + parse() { + try { + this.createHiddenContainer(), ni.setHTML(this.containerElement, this.html, { purifyOptions: this.purifyOptions }); + const t = Je(this.containerElement, { usingFilter: Ua }); + for (; t.nextNode(); ) this.processNode(t.currentNode); + return this.translateBlockElementMarginsToNewlines(); + } finally { + this.removeHiddenContainer(); + } + } + createHiddenContainer() { + return this.referenceElement ? (this.containerElement = this.referenceElement.cloneNode(!1), this.containerElement.removeAttribute("id"), this.containerElement.setAttribute("data-trix-internal", ""), this.containerElement.style.display = "none", this.referenceElement.parentNode.insertBefore(this.containerElement, this.referenceElement.nextSibling)) : (this.containerElement = _({ tagName: "div", style: { display: "none" } }), document.body.appendChild(this.containerElement)); + } + removeHiddenContainer() { + return yt(this.containerElement); + } + processNode(t) { + switch (t.nodeType) { + case Node.TEXT_NODE: + if (!this.isInsignificantTextNode(t)) return this.appendBlockForTextNode(t), this.processTextNode(t); + break; + case Node.ELEMENT_NODE: + return this.appendBlockForElement(t), this.processElement(t); + } + } + appendBlockForTextNode(t) { + const e = t.parentNode; + if (e === this.currentBlockElement && this.isBlockElement(t.previousSibling)) return this.appendStringWithAttributes(` +`); + if (e === this.containerElement || this.isBlockElement(e)) { + var i; + const n = this.getBlockAttributes(e), r = this.getBlockHTMLAttributes(e); + Ot(n, (i = this.currentBlock) === null || i === void 0 ? void 0 : i.attributes) || (this.currentBlock = this.appendBlockForAttributesWithElement(n, e, r), this.currentBlockElement = e); + } + } + appendBlockForElement(t) { + const e = this.isBlockElement(t), i = Tt(this.currentBlockElement, t); + if (e && !this.isBlockElement(t.firstChild)) { + if (!this.isInsignificantTextNode(t.firstChild) || !this.isBlockElement(t.firstElementChild)) { + const n = this.getBlockAttributes(t), r = this.getBlockHTMLAttributes(t); + if (t.firstChild) { + if (i && Ot(n, this.currentBlock.attributes)) return this.appendStringWithAttributes(` +`); + this.currentBlock = this.appendBlockForAttributesWithElement(n, t, r), this.currentBlockElement = t; + } + } + } else if (this.currentBlockElement && !i && !e) { + const n = this.findParentBlockElement(t); + if (n) return this.appendBlockForElement(n); + this.currentBlock = this.appendEmptyBlock(), this.currentBlockElement = null; + } + } + findParentBlockElement(t) { + let { parentElement: e } = t; + for (; e && e !== this.containerElement; ) { + if (this.isBlockElement(e) && this.blockElements.includes(e)) return e; + e = e.parentElement; + } + return null; + } + processTextNode(t) { + let e = t.data; + var i; + return Rs(t.parentNode) || (e = wn(e), jr((i = t.previousSibling) === null || i === void 0 ? void 0 : i.textContent) && (e = ja(e))), this.appendStringWithAttributes(e, this.getTextAttributes(t.parentNode)); + } + processElement(t) { + let e; + if (It(t)) { + if (e = Is(t, "attachment"), Object.keys(e).length) { + const i = this.getTextAttributes(t); + this.appendAttachmentWithAttributes(e, i), t.innerHTML = ""; + } + return this.processedElements.push(t); + } + switch (K(t)) { + case "br": + return this.isExtraBR(t) || this.isBlockElement(t.nextSibling) || this.appendStringWithAttributes(` +`, this.getTextAttributes(t)), this.processedElements.push(t); + case "img": + e = { url: t.getAttribute("src"), contentType: "image" }; + const i = ((n) => { + const r = n.getAttribute("width"), o = n.getAttribute("height"), a = {}; + return r && (a.width = parseInt(r, 10)), o && (a.height = parseInt(o, 10)), a; + })(t); + for (const n in i) { + const r = i[n]; + e[n] = r; + } + return this.appendAttachmentWithAttributes(e, this.getTextAttributes(t)), this.processedElements.push(t); + case "tr": + if (this.needsTableSeparator(t)) return this.appendStringWithAttributes(ze.tableRowSeparator); + break; + case "td": + if (this.needsTableSeparator(t)) return this.appendStringWithAttributes(ze.tableCellSeparator); + } + } + appendBlockForAttributesWithElement(t, e) { + let i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; + this.blockElements.push(e); + const n = function() { + return { text: [], attributes: arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, htmlAttributes: arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {} }; + }(t, i); + return this.blocks.push(n), n; + } + appendEmptyBlock() { + return this.appendBlockForAttributesWithElement([], null); + } + appendStringWithAttributes(t, e) { + return this.appendPiece(qi(t, e)); + } + appendAttachmentWithAttributes(t, e) { + return this.appendPiece(function(i) { + return { attachment: i, attributes: arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, type: "attachment" }; + }(t, e)); + } + appendPiece(t) { + return this.blocks.length === 0 && this.appendEmptyBlock(), this.blocks[this.blocks.length - 1].text.push(t); + } + appendStringToTextAtIndex(t, e) { + const { text: i } = this.blocks[e], n = i[i.length - 1]; + if ((n == null ? void 0 : n.type) !== "string") return i.push(qi(t)); + n.string += t; + } + prependStringToTextAtIndex(t, e) { + const { text: i } = this.blocks[e], n = i[0]; + if ((n == null ? void 0 : n.type) !== "string") return i.unshift(qi(t)); + n.string = t + n.string; + } + getTextAttributes(t) { + let e; + const i = {}; + for (const n in Dt) { + const r = Dt[n]; + if (r.tagName && At(t, { matchingSelector: r.tagName, untilNode: this.containerElement })) i[n] = !0; + else if (r.parser) { + if (e = r.parser(t), e) { + let o = !1; + for (const a of this.findBlockElementAncestors(t)) if (r.parser(a) === e) { + o = !0; + break; + } + o || (i[n] = e); + } + } else r.styleProperty && (e = t.style[r.styleProperty], e && (i[n] = e)); + } + if (It(t)) { + const n = Is(t, "attributes"); + for (const r in n) e = n[r], i[r] = e; + } + return i; + } + getBlockAttributes(t) { + const e = []; + for (; t && t !== this.containerElement; ) { + for (const n in G) { + const r = G[n]; + var i; + r.parse !== !1 && K(t) === r.tagName && ((i = r.test) !== null && i !== void 0 && i.call(r, t) || !r.test) && (e.push(n), r.listAttribute && e.push(r.listAttribute)); + } + t = t.parentNode; + } + return e.reverse(); + } + getBlockHTMLAttributes(t) { + const e = {}, i = Object.values(G).find((n) => n.tagName === K(t)); + return ((i == null ? void 0 : i.htmlAttributes) || []).forEach((n) => { + t.hasAttribute(n) && (e[n] = t.getAttribute(n)); + }), e; + } + findBlockElementAncestors(t) { + const e = []; + for (; t && t !== this.containerElement; ) { + const i = K(t); + ge().includes(i) && e.push(t), t = t.parentNode; + } + return e; + } + isBlockElement(t) { + if ((t == null ? void 0 : t.nodeType) === Node.ELEMENT_NODE && !It(t) && !At(t, { matchingSelector: "td", untilNode: this.containerElement })) return ge().includes(K(t)) || window.getComputedStyle(t).display === "block"; + } + isInsignificantTextNode(t) { + if ((t == null ? void 0 : t.nodeType) !== Node.TEXT_NODE || !Va(t.data)) return; + const { parentNode: e, previousSibling: i, nextSibling: n } = t; + return $a(e.previousSibling) && !this.isBlockElement(e.previousSibling) || Rs(e) ? void 0 : !i || this.isBlockElement(i) || !n || this.isBlockElement(n); + } + isExtraBR(t) { + return K(t) === "br" && this.isBlockElement(t.parentNode) && t.parentNode.lastChild === t; + } + needsTableSeparator(t) { + if (ze.removeBlankTableCells) { + var e; + const i = (e = t.previousSibling) === null || e === void 0 ? void 0 : e.textContent; + return i && /\S/.test(i); + } + return t.previousSibling; + } + translateBlockElementMarginsToNewlines() { + const t = this.getMarginOfDefaultBlockElement(); + for (let e = 0; e < this.blocks.length; e++) { + const i = this.getMarginOfBlockElementAtIndex(e); + i && (i.top > 2 * t.top && this.prependStringToTextAtIndex(` +`, e), i.bottom > 2 * t.bottom && this.appendStringToTextAtIndex(` +`, e)); + } + } + getMarginOfBlockElementAtIndex(t) { + const e = this.blockElements[t]; + if (e && e.textContent && !ge().includes(K(e)) && !this.processedElements.includes(e)) return Ds(e); + } + getMarginOfDefaultBlockElement() { + const t = _(G.default.tagName); + return this.containerElement.appendChild(t), Ds(t); + } +} +const Rs = function(s) { + const { whiteSpace: t } = window.getComputedStyle(s); + return ["pre", "pre-wrap", "pre-line"].includes(t); +}, $a = (s) => s && !jr(s.textContent), Ds = function(s) { + const t = window.getComputedStyle(s); + if (t.display === "block") return { top: parseInt(t.marginTop), bottom: parseInt(t.marginBottom) }; +}, Ua = function(s) { + return K(s) === "style" ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; +}, ja = (s) => s.replace(new RegExp("^".concat(Tn.source, "+")), ""), Va = (s) => new RegExp("^".concat(Tn.source, "*$")).test(s), jr = (s) => /\s$/.test(s), Wa = ["contenteditable", "data-trix-id", "data-trix-store-key", "data-trix-mutable", "data-trix-placeholder", "tabindex"], pn = "data-trix-serialized-attributes", za = "[".concat(pn, "]"), Ka = new RegExp("", "g"), Ga = { "application/json": function(s) { + let t; + if (s instanceof Q) t = s; + else { + if (!(s instanceof HTMLElement)) throw new Error("unserializable object"); + t = Se.parse(s.innerHTML).getDocument(); + } + return t.toSerializableDocument().toJSONString(); +}, "text/html": function(s) { + let t; + if (s instanceof Q) t = si.render(s); + else { + if (!(s instanceof HTMLElement)) throw new Error("unserializable object"); + t = s.cloneNode(!0); + } + return Array.from(t.querySelectorAll("[data-trix-serialize=false]")).forEach((e) => { + yt(e); + }), Wa.forEach((e) => { + Array.from(t.querySelectorAll("[".concat(e, "]"))).forEach((i) => { + i.removeAttribute(e); + }); + }), Array.from(t.querySelectorAll(za)).forEach((e) => { + try { + const i = JSON.parse(e.getAttribute(pn)); + e.removeAttribute(pn); + for (const n in i) { + const r = i[n]; + e.setAttribute(n, r); + } + } catch { + } + }), t.innerHTML.replace(Ka, ""); +} }; +var Ja = Object.freeze({ __proto__: null }); +class w extends M { + constructor(t, e) { + super(...arguments), this.attachmentManager = t, this.attachment = e, this.id = this.attachment.id, this.file = this.attachment.file; + } + remove() { + return this.attachmentManager.requestRemovalOfAttachment(this.attachment); + } +} +w.proxyMethod("attachment.getAttribute"), w.proxyMethod("attachment.hasAttribute"), w.proxyMethod("attachment.setAttribute"), w.proxyMethod("attachment.getAttributes"), w.proxyMethod("attachment.setAttributes"), w.proxyMethod("attachment.isPending"), w.proxyMethod("attachment.isPreviewable"), w.proxyMethod("attachment.getURL"), w.proxyMethod("attachment.getPreviewURL"), w.proxyMethod("attachment.setPreviewURL"), w.proxyMethod("attachment.getHref"), w.proxyMethod("attachment.getFilename"), w.proxyMethod("attachment.getFilesize"), w.proxyMethod("attachment.getFormattedFilesize"), w.proxyMethod("attachment.getExtension"), w.proxyMethod("attachment.getContentType"), w.proxyMethod("attachment.getFile"), w.proxyMethod("attachment.setFile"), w.proxyMethod("attachment.releaseFile"), w.proxyMethod("attachment.getUploadProgress"), w.proxyMethod("attachment.setUploadProgress"); +class Vr extends M { + constructor() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; + super(...arguments), this.managedAttachments = {}, Array.from(t).forEach((e) => { + this.manageAttachment(e); + }); + } + getAttachments() { + const t = []; + for (const e in this.managedAttachments) { + const i = this.managedAttachments[e]; + t.push(i); + } + return t; + } + manageAttachment(t) { + return this.managedAttachments[t.id] || (this.managedAttachments[t.id] = new w(this, t)), this.managedAttachments[t.id]; + } + attachmentIsManaged(t) { + return t.id in this.managedAttachments; + } + requestRemovalOfAttachment(t) { + var e, i; + if (this.attachmentIsManaged(t)) return (e = this.delegate) === null || e === void 0 || (i = e.attachmentManagerDidRequestRemovalOfAttachment) === null || i === void 0 ? void 0 : i.call(e, t); + } + unmanageAttachment(t) { + const e = this.managedAttachments[t.id]; + return delete this.managedAttachments[t.id], e; + } +} +class Wr { + constructor(t) { + this.composition = t, this.document = this.composition.document; + const e = this.composition.getSelectedRange(); + this.startPosition = e[0], this.endPosition = e[1], this.startLocation = this.document.locationFromPosition(this.startPosition), this.endLocation = this.document.locationFromPosition(this.endPosition), this.block = this.document.getBlockAtIndex(this.endLocation.index), this.breaksOnReturn = this.block.breaksOnReturn(), this.previousCharacter = this.block.text.getStringAtPosition(this.endLocation.offset - 1), this.nextCharacter = this.block.text.getStringAtPosition(this.endLocation.offset); + } + shouldInsertBlockBreak() { + return this.block.hasAttributes() && this.block.isListItem() && !this.block.isEmpty() ? this.startLocation.offset !== 0 : this.breaksOnReturn && this.nextCharacter !== ` +`; + } + shouldBreakFormattedBlock() { + return this.block.hasAttributes() && !this.block.isListItem() && (this.breaksOnReturn && this.nextCharacter === ` +` || this.previousCharacter === ` +`); + } + shouldDecreaseListLevel() { + return this.block.hasAttributes() && this.block.isListItem() && this.block.isEmpty(); + } + shouldPrependListItem() { + return this.block.isListItem() && this.startLocation.offset === 0 && !this.block.isEmpty(); + } + shouldRemoveLastBlockAttribute() { + return this.block.hasAttributes() && !this.block.isListItem() && this.block.isEmpty(); + } +} +class vt extends M { + constructor() { + super(...arguments), this.document = new Q(), this.attachments = [], this.currentAttributes = {}, this.revision = 0; + } + setDocument(t) { + var e, i; + if (!t.isEqualTo(this.document)) return this.document = t, this.refreshAttachments(), this.revision++, (e = this.delegate) === null || e === void 0 || (i = e.compositionDidChangeDocument) === null || i === void 0 ? void 0 : i.call(e, t); + } + getSnapshot() { + return { document: this.document, selectedRange: this.getSelectedRange() }; + } + loadSnapshot(t) { + var e, i, n, r; + let { document: o, selectedRange: a } = t; + return (e = this.delegate) === null || e === void 0 || (i = e.compositionWillLoadSnapshot) === null || i === void 0 || i.call(e), this.setDocument(o ?? new Q()), this.setSelection(a ?? [0, 0]), (n = this.delegate) === null || n === void 0 || (r = n.compositionDidLoadSnapshot) === null || r === void 0 ? void 0 : r.call(n); + } + insertText(t) { + let { updatePosition: e } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { updatePosition: !0 }; + const i = this.getSelectedRange(); + this.setDocument(this.document.insertTextAtRange(t, i)); + const n = i[0], r = n + t.getLength(); + return e && this.setSelection(r), this.notifyDelegateOfInsertionAtRange([n, r]); + } + insertBlock() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new lt(); + const e = new Q([t]); + return this.insertDocument(e); + } + insertDocument() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Q(); + const e = this.getSelectedRange(); + this.setDocument(this.document.insertDocumentAtRange(t, e)); + const i = e[0], n = i + t.getLength(); + return this.setSelection(n), this.notifyDelegateOfInsertionAtRange([i, n]); + } + insertString(t, e) { + const i = this.getCurrentTextAttributes(), n = ot.textForStringWithAttributes(t, i); + return this.insertText(n, e); + } + insertBlockBreak() { + const t = this.getSelectedRange(); + this.setDocument(this.document.insertBlockBreakAtRange(t)); + const e = t[0], i = e + 1; + return this.setSelection(i), this.notifyDelegateOfInsertionAtRange([e, i]); + } + insertLineBreak() { + const t = new Wr(this); + if (t.shouldDecreaseListLevel()) return this.decreaseListLevel(), this.setSelection(t.startPosition); + if (t.shouldPrependListItem()) { + const e = new Q([t.block.copyWithoutText()]); + return this.insertDocument(e); + } + return t.shouldInsertBlockBreak() ? this.insertBlockBreak() : t.shouldRemoveLastBlockAttribute() ? this.removeLastBlockAttribute() : t.shouldBreakFormattedBlock() ? this.breakFormattedBlock(t) : this.insertString(` +`); + } + insertHTML(t) { + const e = Se.parse(t, { purifyOptions: { SAFE_FOR_XML: !0 } }).getDocument(), i = this.getSelectedRange(); + this.setDocument(this.document.mergeDocumentAtRange(e, i)); + const n = i[0], r = n + e.getLength() - 1; + return this.setSelection(r), this.notifyDelegateOfInsertionAtRange([n, r]); + } + replaceHTML(t) { + const e = Se.parse(t).getDocument().copyUsingObjectsFromDocument(this.document), i = this.getLocationRange({ strict: !1 }), n = this.document.rangeFromLocationRange(i); + return this.setDocument(e), this.setSelection(n); + } + insertFile(t) { + return this.insertFiles([t]); + } + insertFiles(t) { + const e = []; + return Array.from(t).forEach((i) => { + var n; + if ((n = this.delegate) !== null && n !== void 0 && n.compositionShouldAcceptFile(i)) { + const r = Xt.attachmentForFile(i); + e.push(r); + } + }), this.insertAttachments(e); + } + insertAttachment(t) { + return this.insertAttachments([t]); + } + insertAttachments(t) { + let e = new ot(); + return Array.from(t).forEach((i) => { + var n; + const r = i.getType(), o = (n = yn[r]) === null || n === void 0 ? void 0 : n.presentation, a = this.getCurrentTextAttributes(); + o && (a.presentation = o); + const c = ot.textForAttachmentWithAttributes(i, a); + e = e.appendText(c); + }), this.insertText(e); + } + shouldManageDeletingInDirection(t) { + const e = this.getLocationRange(); + if (gt(e)) { + if (t === "backward" && e[0].offset === 0 || this.shouldManageMovingCursorInDirection(t)) return !0; + } else if (e[0].index !== e[1].index) return !0; + return !1; + } + deleteInDirection(t) { + let e, i, n, { length: r } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + const o = this.getLocationRange(); + let a = this.getSelectedRange(); + const c = gt(a); + if (c ? i = t === "backward" && o[0].offset === 0 : n = o[0].index !== o[1].index, i && this.canDecreaseBlockAttributeLevel()) { + const h = this.getBlock(); + if (h.isListItem() ? this.decreaseListLevel() : this.decreaseBlockAttributeLevel(), this.setSelection(a[0]), h.isEmpty()) return !1; + } + return c && (a = this.getExpandedRangeInDirection(t, { length: r }), t === "backward" && (e = this.getAttachmentAtRange(a))), e ? (this.editAttachment(e), !1) : (this.setDocument(this.document.removeTextAtRange(a)), this.setSelection(a[0]), !i && !n && void 0); + } + moveTextFromRange(t) { + const [e] = Array.from(this.getSelectedRange()); + return this.setDocument(this.document.moveTextFromRangeToPosition(t, e)), this.setSelection(e); + } + removeAttachment(t) { + const e = this.document.getRangeOfAttachment(t); + if (e) return this.stopEditingAttachment(), this.setDocument(this.document.removeTextAtRange(e)), this.setSelection(e[0]); + } + removeLastBlockAttribute() { + const [t, e] = Array.from(this.getSelectedRange()), i = this.document.getBlockAtPosition(e); + return this.removeCurrentAttribute(i.getLastAttribute()), this.setSelection(t); + } + insertPlaceholder() { + return this.placeholderPosition = this.getPosition(), this.insertString(" "); + } + selectPlaceholder() { + if (this.placeholderPosition != null) return this.setSelectedRange([this.placeholderPosition, this.placeholderPosition + 1]), this.getSelectedRange(); + } + forgetPlaceholder() { + this.placeholderPosition = null; + } + hasCurrentAttribute(t) { + const e = this.currentAttributes[t]; + return e != null && e !== !1; + } + toggleCurrentAttribute(t) { + const e = !this.currentAttributes[t]; + return e ? this.setCurrentAttribute(t, e) : this.removeCurrentAttribute(t); + } + canSetCurrentAttribute(t) { + return D(t) ? this.canSetCurrentBlockAttribute(t) : this.canSetCurrentTextAttribute(t); + } + canSetCurrentTextAttribute(t) { + const e = this.getSelectedDocument(); + if (e) { + for (const i of Array.from(e.getAttachments())) if (!i.hasContent()) return !1; + return !0; + } + } + canSetCurrentBlockAttribute(t) { + const e = this.getBlock(); + if (e) return !e.isTerminalBlock(); + } + setCurrentAttribute(t, e) { + return D(t) ? this.setBlockAttribute(t, e) : (this.setTextAttribute(t, e), this.currentAttributes[t] = e, this.notifyDelegateOfCurrentAttributesChange()); + } + setHTMLAtributeAtPosition(t, e, i) { + var n; + const r = this.document.getBlockAtPosition(t), o = (n = D(r.getLastAttribute())) === null || n === void 0 ? void 0 : n.htmlAttributes; + if (r && o != null && o.includes(e)) { + const a = this.document.setHTMLAttributeAtPosition(t, e, i); + this.setDocument(a); + } + } + setTextAttribute(t, e) { + const i = this.getSelectedRange(); + if (!i) return; + const [n, r] = Array.from(i); + if (n !== r) return this.setDocument(this.document.addAttributeAtRange(t, e, i)); + if (t === "href") { + const o = ot.textForStringWithAttributes(e, { href: e }); + return this.insertText(o); + } + } + setBlockAttribute(t, e) { + const i = this.getSelectedRange(); + if (this.canSetCurrentAttribute(t)) return this.setDocument(this.document.applyBlockAttributeAtRange(t, e, i)), this.setSelection(i); + } + removeCurrentAttribute(t) { + return D(t) ? (this.removeBlockAttribute(t), this.updateCurrentAttributes()) : (this.removeTextAttribute(t), delete this.currentAttributes[t], this.notifyDelegateOfCurrentAttributesChange()); + } + removeTextAttribute(t) { + const e = this.getSelectedRange(); + if (e) return this.setDocument(this.document.removeAttributeAtRange(t, e)); + } + removeBlockAttribute(t) { + const e = this.getSelectedRange(); + if (e) return this.setDocument(this.document.removeAttributeAtRange(t, e)); + } + canDecreaseNestingLevel() { + var t; + return ((t = this.getBlock()) === null || t === void 0 ? void 0 : t.getNestingLevel()) > 0; + } + canIncreaseNestingLevel() { + var t; + const e = this.getBlock(); + if (e) { + if ((t = D(e.getLastNestableAttribute())) === null || t === void 0 || !t.listAttribute) return e.getNestingLevel() > 0; + { + const i = this.getPreviousBlock(); + if (i) return function() { + let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; + return Ot((arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).slice(0, n.length), n); + }(i.getListItemAttributes(), e.getListItemAttributes()); + } + } + } + decreaseNestingLevel() { + const t = this.getBlock(); + if (t) return this.setDocument(this.document.replaceBlock(t, t.decreaseNestingLevel())); + } + increaseNestingLevel() { + const t = this.getBlock(); + if (t) return this.setDocument(this.document.replaceBlock(t, t.increaseNestingLevel())); + } + canDecreaseBlockAttributeLevel() { + var t; + return ((t = this.getBlock()) === null || t === void 0 ? void 0 : t.getAttributeLevel()) > 0; + } + decreaseBlockAttributeLevel() { + var t; + const e = (t = this.getBlock()) === null || t === void 0 ? void 0 : t.getLastAttribute(); + if (e) return this.removeCurrentAttribute(e); + } + decreaseListLevel() { + let [t] = Array.from(this.getSelectedRange()); + const { index: e } = this.document.locationFromPosition(t); + let i = e; + const n = this.getBlock().getAttributeLevel(); + let r = this.document.getBlockAtIndex(i + 1); + for (; r && r.isListItem() && !(r.getAttributeLevel() <= n); ) i++, r = this.document.getBlockAtIndex(i + 1); + t = this.document.positionFromLocation({ index: e, offset: 0 }); + const o = this.document.positionFromLocation({ index: i, offset: 0 }); + return this.setDocument(this.document.removeLastListAttributeAtRange([t, o])); + } + updateCurrentAttributes() { + const t = this.getSelectedRange({ ignoreLock: !0 }); + if (t) { + const e = this.document.getCommonAttributesAtRange(t); + if (Array.from(hn()).forEach((i) => { + e[i] || this.canSetCurrentAttribute(i) || (e[i] = !1); + }), !Yt(e, this.currentAttributes)) return this.currentAttributes = e, this.notifyDelegateOfCurrentAttributesChange(); + } + } + getCurrentAttributes() { + return _r.call({}, this.currentAttributes); + } + getCurrentTextAttributes() { + const t = {}; + for (const e in this.currentAttributes) { + const i = this.currentAttributes[e]; + i !== !1 && dn(e) && (t[e] = i); + } + return t; + } + freezeSelection() { + return this.setCurrentAttribute("frozen", !0); + } + thawSelection() { + return this.removeCurrentAttribute("frozen"); + } + hasFrozenSelection() { + return this.hasCurrentAttribute("frozen"); + } + setSelection(t) { + var e; + const i = this.document.locationRangeFromRange(t); + return (e = this.delegate) === null || e === void 0 ? void 0 : e.compositionDidRequestChangingSelectionToLocationRange(i); + } + getSelectedRange() { + const t = this.getLocationRange(); + if (t) return this.document.rangeFromLocationRange(t); + } + setSelectedRange(t) { + const e = this.document.locationRangeFromRange(t); + return this.getSelectionManager().setLocationRange(e); + } + getPosition() { + const t = this.getLocationRange(); + if (t) return this.document.positionFromLocation(t[0]); + } + getLocationRange(t) { + return this.targetLocationRange ? this.targetLocationRange : this.getSelectionManager().getLocationRange(t) || x({ index: 0, offset: 0 }); + } + withTargetLocationRange(t, e) { + let i; + this.targetLocationRange = t; + try { + i = e(); + } finally { + this.targetLocationRange = null; + } + return i; + } + withTargetRange(t, e) { + const i = this.document.locationRangeFromRange(t); + return this.withTargetLocationRange(i, e); + } + withTargetDOMRange(t, e) { + const i = this.createLocationRangeFromDOMRange(t, { strict: !1 }); + return this.withTargetLocationRange(i, e); + } + getExpandedRangeInDirection(t) { + let { length: e } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, [i, n] = Array.from(this.getSelectedRange()); + return t === "backward" ? e ? i -= e : i = this.translateUTF16PositionFromOffset(i, -1) : e ? n += e : n = this.translateUTF16PositionFromOffset(n, 1), x([i, n]); + } + shouldManageMovingCursorInDirection(t) { + if (this.editingAttachment) return !0; + const e = this.getExpandedRangeInDirection(t); + return this.getAttachmentAtRange(e) != null; + } + moveCursorInDirection(t) { + let e, i; + if (this.editingAttachment) i = this.document.getRangeOfAttachment(this.editingAttachment); + else { + const n = this.getSelectedRange(); + i = this.getExpandedRangeInDirection(t), e = !Ye(n, i); + } + if (t === "backward" ? this.setSelectedRange(i[0]) : this.setSelectedRange(i[1]), e) { + const n = this.getAttachmentAtRange(i); + if (n) return this.editAttachment(n); + } + } + expandSelectionInDirection(t) { + let { length: e } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + const i = this.getExpandedRangeInDirection(t, { length: e }); + return this.setSelectedRange(i); + } + expandSelectionForEditing() { + if (this.hasCurrentAttribute("href")) return this.expandSelectionAroundCommonAttribute("href"); + } + expandSelectionAroundCommonAttribute(t) { + const e = this.getPosition(), i = this.document.getRangeOfCommonAttributeAtPosition(t, e); + return this.setSelectedRange(i); + } + selectionContainsAttachments() { + var t; + return ((t = this.getSelectedAttachments()) === null || t === void 0 ? void 0 : t.length) > 0; + } + selectionIsInCursorTarget() { + return this.editingAttachment || this.positionIsCursorTarget(this.getPosition()); + } + positionIsCursorTarget(t) { + const e = this.document.locationFromPosition(t); + if (e) return this.locationIsCursorTarget(e); + } + positionIsBlockBreak(t) { + var e; + return (e = this.document.getPieceAtPosition(t)) === null || e === void 0 ? void 0 : e.isBlockBreak(); + } + getSelectedDocument() { + const t = this.getSelectedRange(); + if (t) return this.document.getDocumentAtRange(t); + } + getSelectedAttachments() { + var t; + return (t = this.getSelectedDocument()) === null || t === void 0 ? void 0 : t.getAttachments(); + } + getAttachments() { + return this.attachments.slice(0); + } + refreshAttachments() { + const t = this.document.getAttachments(), { added: e, removed: i } = function() { + let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; + const o = [], a = [], c = /* @__PURE__ */ new Set(); + n.forEach((d) => { + c.add(d); + }); + const h = /* @__PURE__ */ new Set(); + return r.forEach((d) => { + h.add(d), c.has(d) || o.push(d); + }), n.forEach((d) => { + h.has(d) || a.push(d); + }), { added: o, removed: a }; + }(this.attachments, t); + return this.attachments = t, Array.from(i).forEach((n) => { + var r, o; + n.delegate = null, (r = this.delegate) === null || r === void 0 || (o = r.compositionDidRemoveAttachment) === null || o === void 0 || o.call(r, n); + }), (() => { + const n = []; + return Array.from(e).forEach((r) => { + var o, a; + r.delegate = this, n.push((o = this.delegate) === null || o === void 0 || (a = o.compositionDidAddAttachment) === null || a === void 0 ? void 0 : a.call(o, r)); + }), n; + })(); + } + attachmentDidChangeAttributes(t) { + var e, i; + return this.revision++, (e = this.delegate) === null || e === void 0 || (i = e.compositionDidEditAttachment) === null || i === void 0 ? void 0 : i.call(e, t); + } + attachmentDidChangePreviewURL(t) { + var e, i; + return this.revision++, (e = this.delegate) === null || e === void 0 || (i = e.compositionDidChangeAttachmentPreviewURL) === null || i === void 0 ? void 0 : i.call(e, t); + } + editAttachment(t, e) { + var i, n; + if (t !== this.editingAttachment) return this.stopEditingAttachment(), this.editingAttachment = t, (i = this.delegate) === null || i === void 0 || (n = i.compositionDidStartEditingAttachment) === null || n === void 0 ? void 0 : n.call(i, this.editingAttachment, e); + } + stopEditingAttachment() { + var t, e; + this.editingAttachment && ((t = this.delegate) === null || t === void 0 || (e = t.compositionDidStopEditingAttachment) === null || e === void 0 || e.call(t, this.editingAttachment), this.editingAttachment = null); + } + updateAttributesForAttachment(t, e) { + return this.setDocument(this.document.updateAttributesForAttachment(t, e)); + } + removeAttributeForAttachment(t, e) { + return this.setDocument(this.document.removeAttributeForAttachment(t, e)); + } + breakFormattedBlock(t) { + let { document: e } = t; + const { block: i } = t; + let n = t.startPosition, r = [n - 1, n]; + i.getBlockBreakPosition() === t.startLocation.offset ? (i.breaksOnReturn() && t.nextCharacter === ` +` ? n += 1 : e = e.removeTextAtRange(r), r = [n, n]) : t.nextCharacter === ` +` ? t.previousCharacter === ` +` ? r = [n - 1, n + 1] : (r = [n, n + 1], n += 1) : t.startLocation.offset - 1 != 0 && (n += 1); + const o = new Q([i.removeLastAttribute().copyWithoutText()]); + return this.setDocument(e.insertDocumentAtRange(o, r)), this.setSelection(n); + } + getPreviousBlock() { + const t = this.getLocationRange(); + if (t) { + const { index: e } = t[0]; + if (e > 0) return this.document.getBlockAtIndex(e - 1); + } + } + getBlock() { + const t = this.getLocationRange(); + if (t) return this.document.getBlockAtIndex(t[0].index); + } + getAttachmentAtRange(t) { + const e = this.document.getDocumentAtRange(t); + if (e.toString() === "".concat("", ` +`)) return e.getAttachments()[0]; + } + notifyDelegateOfCurrentAttributesChange() { + var t, e; + return (t = this.delegate) === null || t === void 0 || (e = t.compositionDidChangeCurrentAttributes) === null || e === void 0 ? void 0 : e.call(t, this.currentAttributes); + } + notifyDelegateOfInsertionAtRange(t) { + var e, i; + return (e = this.delegate) === null || e === void 0 || (i = e.compositionDidPerformInsertionAtRange) === null || i === void 0 ? void 0 : i.call(e, t); + } + translateUTF16PositionFromOffset(t, e) { + const i = this.document.toUTF16String(), n = i.offsetFromUCS2Offset(t); + return i.offsetToUCS2Offset(n + e); + } +} +vt.proxyMethod("getSelectionManager().getPointRange"), vt.proxyMethod("getSelectionManager().setLocationRangeFromPointRange"), vt.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange"), vt.proxyMethod("getSelectionManager().locationIsCursorTarget"), vt.proxyMethod("getSelectionManager().selectionIsExpanded"), vt.proxyMethod("delegate?.getSelectionManager"); +class fn extends M { + constructor(t) { + super(...arguments), this.composition = t, this.undoEntries = [], this.redoEntries = []; + } + recordUndoEntry(t) { + let { context: e, consolidatable: i } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + const n = this.undoEntries.slice(-1)[0]; + if (!i || !Ya(n, t, e)) { + const r = this.createEntry({ description: t, context: e }); + this.undoEntries.push(r), this.redoEntries = []; + } + } + undo() { + const t = this.undoEntries.pop(); + if (t) { + const e = this.createEntry(t); + return this.redoEntries.push(e), this.composition.loadSnapshot(t.snapshot); + } + } + redo() { + const t = this.redoEntries.pop(); + if (t) { + const e = this.createEntry(t); + return this.undoEntries.push(e), this.composition.loadSnapshot(t.snapshot); + } + } + canUndo() { + return this.undoEntries.length > 0; + } + canRedo() { + return this.redoEntries.length > 0; + } + createEntry() { + let { description: t, context: e } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + return { description: t == null ? void 0 : t.toString(), context: JSON.stringify(e), snapshot: this.composition.getSnapshot() }; + } +} +const Ya = (s, t, e) => (s == null ? void 0 : s.description) === (t == null ? void 0 : t.toString()) && (s == null ? void 0 : s.context) === JSON.stringify(e), Hi = "attachmentGallery"; +class zr { + constructor(t) { + this.document = t.document, this.selectedRange = t.selectedRange; + } + perform() { + return this.removeBlockAttribute(), this.applyBlockAttribute(); + } + getSnapshot() { + return { document: this.document, selectedRange: this.selectedRange }; + } + removeBlockAttribute() { + return this.findRangesOfBlocks().map((t) => this.document = this.document.removeAttributeAtRange(Hi, t)); + } + applyBlockAttribute() { + let t = 0; + this.findRangesOfPieces().forEach((e) => { + e[1] - e[0] > 1 && (e[0] += t, e[1] += t, this.document.getCharacterAtPosition(e[1]) !== ` +` && (this.document = this.document.insertBlockBreakAtRange(e[1]), e[1] < this.selectedRange[1] && this.moveSelectedRangeForward(), e[1]++, t++), e[0] !== 0 && this.document.getCharacterAtPosition(e[0] - 1) !== ` +` && (this.document = this.document.insertBlockBreakAtRange(e[0]), e[0] < this.selectedRange[0] && this.moveSelectedRangeForward(), e[0]++, t++), this.document = this.document.applyBlockAttributeAtRange(Hi, !0, e)); + }); + } + findRangesOfBlocks() { + return this.document.findRangesForBlockAttribute(Hi); + } + findRangesOfPieces() { + return this.document.findRangesForTextAttribute("presentation", { withValue: "gallery" }); + } + moveSelectedRangeForward() { + this.selectedRange[0] += 1, this.selectedRange[1] += 1; + } +} +const Kr = function(s) { + const t = new zr(s); + return t.perform(), t.getSnapshot(); +}, Xa = [Kr]; +class Gr { + constructor(t, e, i) { + this.insertFiles = this.insertFiles.bind(this), this.composition = t, this.selectionManager = e, this.element = i, this.undoManager = new fn(this.composition), this.filters = Xa.slice(0); + } + loadDocument(t) { + return this.loadSnapshot({ document: t, selectedRange: [0, 0] }); + } + loadHTML() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; + const e = Se.parse(t, { referenceElement: this.element }).getDocument(); + return this.loadDocument(e); + } + loadJSON(t) { + let { document: e, selectedRange: i } = t; + return e = Q.fromJSON(e), this.loadSnapshot({ document: e, selectedRange: i }); + } + loadSnapshot(t) { + return this.undoManager = new fn(this.composition), this.composition.loadSnapshot(t); + } + getDocument() { + return this.composition.document; + } + getSelectedDocument() { + return this.composition.getSelectedDocument(); + } + getSnapshot() { + return this.composition.getSnapshot(); + } + toJSON() { + return this.getSnapshot(); + } + deleteInDirection(t) { + return this.composition.deleteInDirection(t); + } + insertAttachment(t) { + return this.composition.insertAttachment(t); + } + insertAttachments(t) { + return this.composition.insertAttachments(t); + } + insertDocument(t) { + return this.composition.insertDocument(t); + } + insertFile(t) { + return this.composition.insertFile(t); + } + insertFiles(t) { + return this.composition.insertFiles(t); + } + insertHTML(t) { + return this.composition.insertHTML(t); + } + insertString(t) { + return this.composition.insertString(t); + } + insertText(t) { + return this.composition.insertText(t); + } + insertLineBreak() { + return this.composition.insertLineBreak(); + } + getSelectedRange() { + return this.composition.getSelectedRange(); + } + getPosition() { + return this.composition.getPosition(); + } + getClientRectAtPosition(t) { + const e = this.getDocument().locationRangeFromRange([t, t + 1]); + return this.selectionManager.getClientRectAtLocationRange(e); + } + expandSelectionInDirection(t) { + return this.composition.expandSelectionInDirection(t); + } + moveCursorInDirection(t) { + return this.composition.moveCursorInDirection(t); + } + setSelectedRange(t) { + return this.composition.setSelectedRange(t); + } + activateAttribute(t) { + let e = !(arguments.length > 1 && arguments[1] !== void 0) || arguments[1]; + return this.composition.setCurrentAttribute(t, e); + } + attributeIsActive(t) { + return this.composition.hasCurrentAttribute(t); + } + canActivateAttribute(t) { + return this.composition.canSetCurrentAttribute(t); + } + deactivateAttribute(t) { + return this.composition.removeCurrentAttribute(t); + } + setHTMLAtributeAtPosition(t, e, i) { + this.composition.setHTMLAtributeAtPosition(t, e, i); + } + canDecreaseNestingLevel() { + return this.composition.canDecreaseNestingLevel(); + } + canIncreaseNestingLevel() { + return this.composition.canIncreaseNestingLevel(); + } + decreaseNestingLevel() { + if (this.canDecreaseNestingLevel()) return this.composition.decreaseNestingLevel(); + } + increaseNestingLevel() { + if (this.canIncreaseNestingLevel()) return this.composition.increaseNestingLevel(); + } + canRedo() { + return this.undoManager.canRedo(); + } + canUndo() { + return this.undoManager.canUndo(); + } + recordUndoEntry(t) { + let { context: e, consolidatable: i } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + return this.undoManager.recordUndoEntry(t, { context: e, consolidatable: i }); + } + redo() { + if (this.canRedo()) return this.undoManager.redo(); + } + undo() { + if (this.canUndo()) return this.undoManager.undo(); + } +} +class Jr { + constructor(t) { + this.element = t; + } + findLocationFromContainerAndOffset(t, e) { + let { strict: i } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : { strict: !0 }, n = 0, r = !1; + const o = { index: 0, offset: 0 }, a = this.findAttachmentElementParentForNode(t); + a && (t = a.parentNode, e = xi(a)); + const c = Je(this.element, { usingFilter: Yr }); + for (; c.nextNode(); ) { + const h = c.currentNode; + if (h === t && pe(t)) { + Kt(h) || (o.offset += e); + break; + } + if (h.parentNode === t) { + if (n++ === e) break; + } else if (!Tt(t, h) && n > 0) break; + os(h, { strict: i }) ? (r && o.index++, o.offset = 0, r = !0) : o.offset += $i(h); + } + return o; + } + findContainerAndOffsetFromLocation(t) { + let e, i; + if (t.index === 0 && t.offset === 0) { + for (e = this.element, i = 0; e.firstChild; ) if (e = e.firstChild, Ci(e)) { + i = 1; + break; + } + return [e, i]; + } + let [n, r] = this.findNodeAndOffsetFromLocation(t); + if (n) { + if (pe(n)) $i(n) === 0 ? (e = n.parentNode.parentNode, i = xi(n.parentNode), Kt(n, { name: "right" }) && i++) : (e = n, i = t.offset - r); + else { + if (e = n.parentNode, !os(n.previousSibling) && !Ci(e)) for (; n === e.lastChild && (n = e, e = e.parentNode, !Ci(e)); ) ; + i = xi(n), t.offset !== 0 && i++; + } + return [e, i]; + } + } + findNodeAndOffsetFromLocation(t) { + let e, i, n = 0; + for (const r of this.getSignificantNodesForIndex(t.index)) { + const o = $i(r); + if (t.offset <= n + o) if (pe(r)) { + if (e = r, i = n, t.offset === i && Kt(e)) break; + } else e || (e = r, i = n); + if (n += o, n > t.offset) break; + } + return [e, i]; + } + findAttachmentElementParentForNode(t) { + for (; t && t !== this.element; ) { + if (It(t)) return t; + t = t.parentNode; + } + } + getSignificantNodesForIndex(t) { + const e = [], i = Je(this.element, { usingFilter: Qa }); + let n = !1; + for (; i.nextNode(); ) { + const o = i.currentNode; + var r; + if (zt(o)) { + if (r != null ? r++ : r = 0, r === t) n = !0; + else if (n) break; + } else n && e.push(o); + } + return e; + } +} +const $i = function(s) { + return s.nodeType === Node.TEXT_NODE ? Kt(s) ? 0 : s.textContent.length : K(s) === "br" || It(s) ? 1 : 0; +}, Qa = function(s) { + return Za(s) === NodeFilter.FILTER_ACCEPT ? Yr(s) : NodeFilter.FILTER_REJECT; +}, Za = function(s) { + return Er(s) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; +}, Yr = function(s) { + return It(s.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; +}; +class Xr { + createDOMRangeFromPoint(t) { + let e, { x: i, y: n } = t; + if (document.caretPositionFromPoint) { + const { offsetNode: r, offset: o } = document.caretPositionFromPoint(i, n); + return e = document.createRange(), e.setStart(r, o), e; + } + if (document.caretRangeFromPoint) return document.caretRangeFromPoint(i, n); + if (document.body.createTextRange) { + const r = fe(); + try { + const o = document.body.createTextRange(); + o.moveToPoint(i, n), o.select(); + } catch { + } + return e = fe(), Ir(r), e; + } + } + getClientRectsForDOMRange(t) { + const e = Array.from(t.getClientRects()); + return [e[0], e[e.length - 1]]; + } +} +class Lt extends M { + constructor(t) { + super(...arguments), this.didMouseDown = this.didMouseDown.bind(this), this.selectionDidChange = this.selectionDidChange.bind(this), this.element = t, this.locationMapper = new Jr(this.element), this.pointMapper = new Xr(), this.lockCount = 0, k("mousedown", { onElement: this.element, withCallback: this.didMouseDown }); + } + getLocationRange() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + return t.strict === !1 ? this.createLocationRangeFromDOMRange(fe()) : t.ignoreLock ? this.currentLocationRange : this.lockedLocationRange ? this.lockedLocationRange : this.currentLocationRange; + } + setLocationRange(t) { + if (this.lockedLocationRange) return; + t = x(t); + const e = this.createDOMRangeFromLocationRange(t); + e && (Ir(e), this.updateCurrentLocationRange(t)); + } + setLocationRangeFromPointRange(t) { + t = x(t); + const e = this.getLocationAtPoint(t[0]), i = this.getLocationAtPoint(t[1]); + this.setLocationRange([e, i]); + } + getClientRectAtLocationRange(t) { + const e = this.createDOMRangeFromLocationRange(t); + if (e) return this.getClientRectsForDOMRange(e)[1]; + } + locationIsCursorTarget(t) { + const e = Array.from(this.findNodeAndOffsetFromLocation(t))[0]; + return Kt(e); + } + lock() { + this.lockCount++ == 0 && (this.updateCurrentLocationRange(), this.lockedLocationRange = this.getLocationRange()); + } + unlock() { + if (--this.lockCount == 0) { + const { lockedLocationRange: t } = this; + if (this.lockedLocationRange = null, t != null) return this.setLocationRange(t); + } + } + clearSelection() { + var t; + return (t = kr()) === null || t === void 0 ? void 0 : t.removeAllRanges(); + } + selectionIsCollapsed() { + var t; + return ((t = fe()) === null || t === void 0 ? void 0 : t.collapsed) === !0; + } + selectionIsExpanded() { + return !this.selectionIsCollapsed(); + } + createLocationRangeFromDOMRange(t, e) { + if (t == null || !this.domRangeWithinElement(t)) return; + const i = this.findLocationFromContainerAndOffset(t.startContainer, t.startOffset, e); + if (!i) return; + const n = t.collapsed ? void 0 : this.findLocationFromContainerAndOffset(t.endContainer, t.endOffset, e); + return x([i, n]); + } + didMouseDown() { + return this.pauseTemporarily(); + } + pauseTemporarily() { + let t; + this.paused = !0; + const e = () => { + if (this.paused = !1, clearTimeout(i), Array.from(t).forEach((n) => { + n.destroy(); + }), Tt(document, this.element)) return this.selectionDidChange(); + }, i = setTimeout(e, 200); + t = ["mousemove", "keydown"].map((n) => k(n, { onElement: document, withCallback: e })); + } + selectionDidChange() { + if (!this.paused && !Sn(this.element)) return this.updateCurrentLocationRange(); + } + updateCurrentLocationRange(t) { + var e, i; + if ((t ?? (t = this.createLocationRangeFromDOMRange(fe()))) && !Ye(t, this.currentLocationRange)) return this.currentLocationRange = t, (e = this.delegate) === null || e === void 0 || (i = e.locationRangeDidChange) === null || i === void 0 ? void 0 : i.call(e, this.currentLocationRange.slice(0)); + } + createDOMRangeFromLocationRange(t) { + const e = this.findContainerAndOffsetFromLocation(t[0]), i = gt(t) ? e : this.findContainerAndOffsetFromLocation(t[1]) || e; + if (e != null && i != null) { + const n = document.createRange(); + return n.setStart(...Array.from(e || [])), n.setEnd(...Array.from(i || [])), n; + } + } + getLocationAtPoint(t) { + const e = this.createDOMRangeFromPoint(t); + var i; + if (e) return (i = this.createLocationRangeFromDOMRange(e)) === null || i === void 0 ? void 0 : i[0]; + } + domRangeWithinElement(t) { + return t.collapsed ? Tt(this.element, t.startContainer) : Tt(this.element, t.startContainer) && Tt(this.element, t.endContainer); + } +} +Lt.proxyMethod("locationMapper.findLocationFromContainerAndOffset"), Lt.proxyMethod("locationMapper.findContainerAndOffsetFromLocation"), Lt.proxyMethod("locationMapper.findNodeAndOffsetFromLocation"), Lt.proxyMethod("pointMapper.createDOMRangeFromPoint"), Lt.proxyMethod("pointMapper.getClientRectsForDOMRange"); +var Qr = Object.freeze({ __proto__: null, Attachment: Xt, AttachmentManager: Vr, AttachmentPiece: Jt, Block: lt, Composition: vt, Document: Q, Editor: Gr, HTMLParser: Se, HTMLSanitizer: ni, LineBreakInsertion: Wr, LocationMapper: Jr, ManagedAttachment: w, Piece: Pt, PointMapper: Xr, SelectionManager: Lt, SplittableList: Qe, StringPiece: Rn, Text: ot, UndoManager: fn }), tl = Object.freeze({ __proto__: null, ObjectView: Nt, AttachmentView: In, BlockView: Fr, DocumentView: si, PieceView: Nr, PreviewableAttachmentView: Br, TextView: Pr }); +const { lang: Ui, css: Ct, keyNames: el } = Le, ji = function(s) { + return function() { + const t = s.apply(this, arguments); + t.do(), this.undos || (this.undos = []), this.undos.push(t.undo); + }; +}; +class Zr extends M { + constructor(t, e, i) { + let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; + super(...arguments), V(this, "makeElementMutable", ji(() => ({ do: () => { + this.element.dataset.trixMutable = !0; + }, undo: () => delete this.element.dataset.trixMutable }))), V(this, "addToolbar", ji(() => { + const r = _({ tagName: "div", className: Ct.attachmentToolbar, data: { trixMutable: !0 }, childNodes: _({ tagName: "div", className: "trix-button-row", childNodes: _({ tagName: "span", className: "trix-button-group trix-button-group--actions", childNodes: _({ tagName: "button", className: "trix-button trix-button--remove", textContent: Ui.remove, attributes: { title: Ui.remove }, data: { trixAction: "remove" } }) }) }) }); + return this.attachment.isPreviewable() && r.appendChild(_({ tagName: "div", className: Ct.attachmentMetadataContainer, childNodes: _({ tagName: "span", className: Ct.attachmentMetadata, childNodes: [_({ tagName: "span", className: Ct.attachmentName, textContent: this.attachment.getFilename(), attributes: { title: this.attachment.getFilename() } }), _({ tagName: "span", className: Ct.attachmentSize, textContent: this.attachment.getFormattedFilesize() })] }) })), k("click", { onElement: r, withCallback: this.didClickToolbar }), k("click", { onElement: r, matchingSelector: "[data-trix-action]", withCallback: this.didClickActionButton }), me("trix-attachment-before-toolbar", { onElement: this.element, attributes: { toolbar: r, attachment: this.attachment } }), { do: () => this.element.appendChild(r), undo: () => yt(r) }; + })), V(this, "installCaptionEditor", ji(() => { + const r = _({ tagName: "textarea", className: Ct.attachmentCaptionEditor, attributes: { placeholder: Ui.captionPlaceholder }, data: { trixMutable: !0 } }); + r.value = this.attachmentPiece.getCaption(); + const o = r.cloneNode(); + o.classList.add("trix-autoresize-clone"), o.tabIndex = -1; + const a = function() { + o.value = r.value, r.style.height = o.scrollHeight + "px"; + }; + k("input", { onElement: r, withCallback: a }), k("input", { onElement: r, withCallback: this.didInputCaption }), k("keydown", { onElement: r, withCallback: this.didKeyDownCaption }), k("change", { onElement: r, withCallback: this.didChangeCaption }), k("blur", { onElement: r, withCallback: this.didBlurCaption }); + const c = this.element.querySelector("figcaption"), h = c.cloneNode(); + return { do: () => { + if (c.style.display = "none", h.appendChild(r), h.appendChild(o), h.classList.add("".concat(Ct.attachmentCaption, "--editing")), c.parentElement.insertBefore(h, c), a(), this.options.editCaption) return Ln(() => r.focus()); + }, undo() { + yt(h), c.style.display = null; + } }; + })), this.didClickToolbar = this.didClickToolbar.bind(this), this.didClickActionButton = this.didClickActionButton.bind(this), this.didKeyDownCaption = this.didKeyDownCaption.bind(this), this.didInputCaption = this.didInputCaption.bind(this), this.didChangeCaption = this.didChangeCaption.bind(this), this.didBlurCaption = this.didBlurCaption.bind(this), this.attachmentPiece = t, this.element = e, this.container = i, this.options = n, this.attachment = this.attachmentPiece.attachment, K(this.element) === "a" && (this.element = this.element.firstChild), this.install(); + } + install() { + this.makeElementMutable(), this.addToolbar(), this.attachment.isPreviewable() && this.installCaptionEditor(); + } + uninstall() { + var t; + let e = this.undos.pop(); + for (this.savePendingCaption(); e; ) e(), e = this.undos.pop(); + (t = this.delegate) === null || t === void 0 || t.didUninstallAttachmentEditor(this); + } + savePendingCaption() { + if (this.pendingCaption != null) { + const r = this.pendingCaption; + var t, e, i, n; + this.pendingCaption = null, r ? (t = this.delegate) === null || t === void 0 || (e = t.attachmentEditorDidRequestUpdatingAttributesForAttachment) === null || e === void 0 || e.call(t, { caption: r }, this.attachment) : (i = this.delegate) === null || i === void 0 || (n = i.attachmentEditorDidRequestRemovingAttributeForAttachment) === null || n === void 0 || n.call(i, "caption", this.attachment); + } + } + didClickToolbar(t) { + return t.preventDefault(), t.stopPropagation(); + } + didClickActionButton(t) { + var e; + if (t.target.getAttribute("data-trix-action") === "remove") return (e = this.delegate) === null || e === void 0 ? void 0 : e.attachmentEditorDidRequestRemovalOfAttachment(this.attachment); + } + didKeyDownCaption(t) { + var e, i; + if (el[t.keyCode] === "return") return t.preventDefault(), this.savePendingCaption(), (e = this.delegate) === null || e === void 0 || (i = e.attachmentEditorDidRequestDeselectingAttachment) === null || i === void 0 ? void 0 : i.call(e, this.attachment); + } + didInputCaption(t) { + this.pendingCaption = t.target.value.replace(/\s/g, " ").trim(); + } + didChangeCaption(t) { + return this.savePendingCaption(); + } + didBlurCaption(t) { + return this.savePendingCaption(); + } +} +class to extends M { + constructor(t, e) { + super(...arguments), this.didFocus = this.didFocus.bind(this), this.didBlur = this.didBlur.bind(this), this.didClickAttachment = this.didClickAttachment.bind(this), this.element = t, this.composition = e, this.documentView = new si(this.composition.document, { element: this.element }), k("focus", { onElement: this.element, withCallback: this.didFocus }), k("blur", { onElement: this.element, withCallback: this.didBlur }), k("click", { onElement: this.element, matchingSelector: "a[contenteditable=false]", preventDefault: !0 }), k("mousedown", { onElement: this.element, matchingSelector: kt, withCallback: this.didClickAttachment }), k("click", { onElement: this.element, matchingSelector: "a".concat(kt), preventDefault: !0 }); + } + didFocus(t) { + var e; + const i = () => { + var n, r; + if (!this.focused) return this.focused = !0, (n = this.delegate) === null || n === void 0 || (r = n.compositionControllerDidFocus) === null || r === void 0 ? void 0 : r.call(n); + }; + return ((e = this.blurPromise) === null || e === void 0 ? void 0 : e.then(i)) || i(); + } + didBlur(t) { + this.blurPromise = new Promise((e) => Ln(() => { + var i, n; + return Sn(this.element) || (this.focused = null, (i = this.delegate) === null || i === void 0 || (n = i.compositionControllerDidBlur) === null || n === void 0 || n.call(i)), this.blurPromise = null, e(); + })); + } + didClickAttachment(t, e) { + var i, n; + const r = this.findAttachmentForElement(e), o = !!At(t.target, { matchingSelector: "figcaption" }); + return (i = this.delegate) === null || i === void 0 || (n = i.compositionControllerDidSelectAttachment) === null || n === void 0 ? void 0 : n.call(i, r, { editCaption: o }); + } + getSerializableElement() { + return this.isEditingAttachment() ? this.documentView.shadowElement : this.element; + } + render() { + var t, e, i, n, r, o; + return this.revision !== this.composition.revision && (this.documentView.setDocument(this.composition.document), this.documentView.render(), this.revision = this.composition.revision), this.canSyncDocumentView() && !this.documentView.isSynced() && ((i = this.delegate) === null || i === void 0 || (n = i.compositionControllerWillSyncDocumentView) === null || n === void 0 || n.call(i), this.documentView.sync(), (r = this.delegate) === null || r === void 0 || (o = r.compositionControllerDidSyncDocumentView) === null || o === void 0 || o.call(r)), (t = this.delegate) === null || t === void 0 || (e = t.compositionControllerDidRender) === null || e === void 0 ? void 0 : e.call(t); + } + rerenderViewForObject(t) { + return this.invalidateViewForObject(t), this.render(); + } + invalidateViewForObject(t) { + return this.documentView.invalidateViewForObject(t); + } + isViewCachingEnabled() { + return this.documentView.isViewCachingEnabled(); + } + enableViewCaching() { + return this.documentView.enableViewCaching(); + } + disableViewCaching() { + return this.documentView.disableViewCaching(); + } + refreshViewCache() { + return this.documentView.garbageCollectCachedViews(); + } + isEditingAttachment() { + return !!this.attachmentEditor; + } + installAttachmentEditorForAttachment(t, e) { + var i; + if (((i = this.attachmentEditor) === null || i === void 0 ? void 0 : i.attachment) === t) return; + const n = this.documentView.findElementForObject(t); + if (!n) return; + this.uninstallAttachmentEditor(); + const r = this.composition.document.getAttachmentPieceForAttachment(t); + this.attachmentEditor = new Zr(r, n, this.element, e), this.attachmentEditor.delegate = this; + } + uninstallAttachmentEditor() { + var t; + return (t = this.attachmentEditor) === null || t === void 0 ? void 0 : t.uninstall(); + } + didUninstallAttachmentEditor() { + return this.attachmentEditor = null, this.render(); + } + attachmentEditorDidRequestUpdatingAttributesForAttachment(t, e) { + var i, n; + return (i = this.delegate) === null || i === void 0 || (n = i.compositionControllerWillUpdateAttachment) === null || n === void 0 || n.call(i, e), this.composition.updateAttributesForAttachment(t, e); + } + attachmentEditorDidRequestRemovingAttributeForAttachment(t, e) { + var i, n; + return (i = this.delegate) === null || i === void 0 || (n = i.compositionControllerWillUpdateAttachment) === null || n === void 0 || n.call(i, e), this.composition.removeAttributeForAttachment(t, e); + } + attachmentEditorDidRequestRemovalOfAttachment(t) { + var e, i; + return (e = this.delegate) === null || e === void 0 || (i = e.compositionControllerDidRequestRemovalOfAttachment) === null || i === void 0 ? void 0 : i.call(e, t); + } + attachmentEditorDidRequestDeselectingAttachment(t) { + var e, i; + return (e = this.delegate) === null || e === void 0 || (i = e.compositionControllerDidRequestDeselectingAttachment) === null || i === void 0 ? void 0 : i.call(e, t); + } + canSyncDocumentView() { + return !this.isEditingAttachment(); + } + findAttachmentForElement(t) { + return this.composition.document.getAttachmentById(parseInt(t.dataset.trixId, 10)); + } +} +class eo extends M { +} +const io = "data-trix-mutable", il = "[".concat(io, "]"), nl = { attributes: !0, childList: !0, characterData: !0, characterDataOldValue: !0, subtree: !0 }; +class no extends M { + constructor(t) { + super(t), this.didMutate = this.didMutate.bind(this), this.element = t, this.observer = new window.MutationObserver(this.didMutate), this.start(); + } + start() { + return this.reset(), this.observer.observe(this.element, nl); + } + stop() { + return this.observer.disconnect(); + } + didMutate(t) { + var e, i; + if (this.mutations.push(...Array.from(this.findSignificantMutations(t) || [])), this.mutations.length) return (e = this.delegate) === null || e === void 0 || (i = e.elementDidMutate) === null || i === void 0 || i.call(e, this.getMutationSummary()), this.reset(); + } + reset() { + this.mutations = []; + } + findSignificantMutations(t) { + return t.filter((e) => this.mutationIsSignificant(e)); + } + mutationIsSignificant(t) { + if (this.nodeIsMutable(t.target)) return !1; + for (const e of Array.from(this.nodesModifiedByMutation(t))) if (this.nodeIsSignificant(e)) return !0; + return !1; + } + nodeIsSignificant(t) { + return t !== this.element && !this.nodeIsMutable(t) && !Er(t); + } + nodeIsMutable(t) { + return At(t, { matchingSelector: il }); + } + nodesModifiedByMutation(t) { + const e = []; + switch (t.type) { + case "attributes": + t.attributeName !== io && e.push(t.target); + break; + case "characterData": + e.push(t.target.parentNode), e.push(t.target); + break; + case "childList": + e.push(...Array.from(t.addedNodes || [])), e.push(...Array.from(t.removedNodes || [])); + } + return e; + } + getMutationSummary() { + return this.getTextMutationSummary(); + } + getTextMutationSummary() { + const { additions: t, deletions: e } = this.getTextChangesFromCharacterData(), i = this.getTextChangesFromChildList(); + Array.from(i.additions).forEach((a) => { + Array.from(t).includes(a) || t.push(a); + }), e.push(...Array.from(i.deletions || [])); + const n = {}, r = t.join(""); + r && (n.textAdded = r); + const o = e.join(""); + return o && (n.textDeleted = o), n; + } + getMutationsByType(t) { + return Array.from(this.mutations).filter((e) => e.type === t); + } + getTextChangesFromChildList() { + let t, e; + const i = [], n = []; + Array.from(this.getMutationsByType("childList")).forEach((a) => { + i.push(...Array.from(a.addedNodes || [])), n.push(...Array.from(a.removedNodes || [])); + }), i.length === 0 && n.length === 1 && zt(n[0]) ? (t = [], e = [` +`]) : (t = bn(i), e = bn(n)); + const r = t.filter((a, c) => a !== e[c]).map(ue), o = e.filter((a, c) => a !== t[c]).map(ue); + return { additions: r, deletions: o }; + } + getTextChangesFromCharacterData() { + let t, e; + const i = this.getMutationsByType("characterData"); + if (i.length) { + const n = i[0], r = i[i.length - 1], o = function(a, c) { + let h, d; + return a = ye.box(a), (c = ye.box(c)).length < a.length ? [d, h] = us(a, c) : [h, d] = us(c, a), { added: h, removed: d }; + }(ue(n.oldValue), ue(r.target.data)); + t = o.added, e = o.removed; + } + return { additions: t ? [t] : [], deletions: e ? [e] : [] }; + } +} +const bn = function() { + let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; + const t = []; + for (const e of Array.from(s)) switch (e.nodeType) { + case Node.TEXT_NODE: + t.push(e.data); + break; + case Node.ELEMENT_NODE: + K(e) === "br" ? t.push(` +`) : t.push(...Array.from(bn(e.childNodes) || [])); + } + return t; +}; +class so extends Xe { + constructor(t) { + super(...arguments), this.file = t; + } + perform(t) { + const e = new FileReader(); + return e.onerror = () => t(!1), e.onload = () => { + e.onerror = null; + try { + e.abort(); + } catch { + } + return t(!0, this.file); + }, e.readAsArrayBuffer(this.file); + } +} +class sl { + constructor(t) { + this.element = t; + } + shouldIgnore(t) { + return !!Ce.samsungAndroid && (this.previousEvent = this.event, this.event = t, this.checkSamsungKeyboardBuggyModeStart(), this.checkSamsungKeyboardBuggyModeEnd(), this.buggyMode); + } + checkSamsungKeyboardBuggyModeStart() { + this.insertingLongTextAfterUnidentifiedChar() && rl(this.element.innerText, this.event.data) && (this.buggyMode = !0, this.event.preventDefault()); + } + checkSamsungKeyboardBuggyModeEnd() { + this.buggyMode && this.event.inputType !== "insertText" && (this.buggyMode = !1); + } + insertingLongTextAfterUnidentifiedChar() { + var t; + return this.isBeforeInputInsertText() && this.previousEventWasUnidentifiedKeydown() && ((t = this.event.data) === null || t === void 0 ? void 0 : t.length) > 50; + } + isBeforeInputInsertText() { + return this.event.type === "beforeinput" && this.event.inputType === "insertText"; + } + previousEventWasUnidentifiedKeydown() { + var t, e; + return ((t = this.previousEvent) === null || t === void 0 ? void 0 : t.type) === "keydown" && ((e = this.previousEvent) === null || e === void 0 ? void 0 : e.key) === "Unidentified"; + } +} +const rl = (s, t) => Os(s) === Os(t), ol = new RegExp("(".concat("", "|").concat(ii, "|").concat(_t, "|\\s)+"), "g"), Os = (s) => s.replace(ol, " ").trim(); +class ri extends M { + constructor(t) { + super(...arguments), this.element = t, this.mutationObserver = new no(this.element), this.mutationObserver.delegate = this, this.flakyKeyboardDetector = new sl(this.element); + for (const e in this.constructor.events) k(e, { onElement: this.element, withCallback: this.handlerFor(e) }); + } + elementDidMutate(t) { + } + editorWillSyncDocumentView() { + return this.mutationObserver.stop(); + } + editorDidSyncDocumentView() { + return this.mutationObserver.start(); + } + requestRender() { + var t, e; + return (t = this.delegate) === null || t === void 0 || (e = t.inputControllerDidRequestRender) === null || e === void 0 ? void 0 : e.call(t); + } + requestReparse() { + var t, e; + return (t = this.delegate) === null || t === void 0 || (e = t.inputControllerDidRequestReparse) === null || e === void 0 || e.call(t), this.requestRender(); + } + attachFiles(t) { + const e = Array.from(t).map((i) => new so(i)); + return Promise.all(e).then((i) => { + this.handleInput(function() { + var n, r; + return (n = this.delegate) === null || n === void 0 || n.inputControllerWillAttachFiles(), (r = this.responder) === null || r === void 0 || r.insertFiles(i), this.requestRender(); + }); + }); + } + handlerFor(t) { + return (e) => { + e.defaultPrevented || this.handleInput(() => { + if (!Sn(this.element)) { + if (this.flakyKeyboardDetector.shouldIgnore(e)) return; + this.eventName = t, this.constructor.events[t].call(this, e); + } + }); + }; + } + handleInput(t) { + try { + var e; + (e = this.delegate) === null || e === void 0 || e.inputControllerWillHandleInput(), t.call(this); + } finally { + var i; + (i = this.delegate) === null || i === void 0 || i.inputControllerDidHandleInput(); + } + } + createLinkHTML(t, e) { + const i = document.createElement("a"); + return i.href = t, i.textContent = e || t, i.outerHTML; + } +} +var Vi; +V(ri, "events", {}); +const { browser: al, keyNames: ro } = Le; +let ll = 0; +class mt extends ri { + constructor() { + super(...arguments), this.resetInputSummary(); + } + setInputSummary() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + this.inputSummary.eventName = this.eventName; + for (const e in t) { + const i = t[e]; + this.inputSummary[e] = i; + } + return this.inputSummary; + } + resetInputSummary() { + this.inputSummary = {}; + } + reset() { + return this.resetInputSummary(), Mt.reset(); + } + elementDidMutate(t) { + var e, i; + return this.isComposing() ? (e = this.delegate) === null || e === void 0 || (i = e.inputControllerDidAllowUnhandledInput) === null || i === void 0 ? void 0 : i.call(e) : this.handleInput(function() { + return this.mutationIsSignificant(t) && (this.mutationIsExpected(t) ? this.requestRender() : this.requestReparse()), this.reset(); + }); + } + mutationIsExpected(t) { + let { textAdded: e, textDeleted: i } = t; + if (this.inputSummary.preferDocument) return !0; + const n = e != null ? e === this.inputSummary.textAdded : !this.inputSummary.textAdded, r = i != null ? this.inputSummary.didDelete : !this.inputSummary.didDelete, o = [` +`, ` +`].includes(e) && !n, a = i === ` +` && !r; + if (o && !a || a && !o) { + const h = this.getSelectedRange(); + if (h) { + var c; + const d = o ? e.replace(/\n$/, "").length || -1 : (e == null ? void 0 : e.length) || 1; + if ((c = this.responder) !== null && c !== void 0 && c.positionIsBlockBreak(h[1] + d)) return !0; + } + } + return n && r; + } + mutationIsSignificant(t) { + var e; + const i = Object.keys(t).length > 0, n = ((e = this.compositionInput) === null || e === void 0 ? void 0 : e.getEndData()) === ""; + return i || !n; + } + getCompositionInput() { + if (this.isComposing()) return this.compositionInput; + this.compositionInput = new bt(this); + } + isComposing() { + return this.compositionInput && !this.compositionInput.isEnded(); + } + deleteInDirection(t, e) { + var i; + return ((i = this.responder) === null || i === void 0 ? void 0 : i.deleteInDirection(t)) !== !1 ? this.setInputSummary({ didDelete: !0 }) : e ? (e.preventDefault(), this.requestRender()) : void 0; + } + serializeSelectionToDataTransfer(t) { + var e; + if (!function(n) { + if (n == null || !n.setData) return !1; + for (const r in cs) { + const o = cs[r]; + try { + if (n.setData(r, o), !n.getData(r) === o) return !1; + } catch { + return !1; + } + } + return !0; + }(t)) return; + const i = (e = this.responder) === null || e === void 0 ? void 0 : e.getSelectedDocument().toSerializableDocument(); + return t.setData("application/x-trix-document", JSON.stringify(i)), t.setData("text/html", si.render(i).innerHTML), t.setData("text/plain", i.toString().replace(/\n$/, "")), !0; + } + canAcceptDataTransfer(t) { + const e = {}; + return Array.from((t == null ? void 0 : t.types) || []).forEach((i) => { + e[i] = !0; + }), e.Files || e["application/x-trix-document"] || e["text/html"] || e["text/plain"]; + } + getPastedHTMLUsingHiddenElement(t) { + const e = this.getSelectedRange(), i = { position: "absolute", left: "".concat(window.pageXOffset, "px"), top: "".concat(window.pageYOffset, "px"), opacity: 0 }, n = _({ style: i, tagName: "div", editable: !0 }); + return document.body.appendChild(n), n.focus(), requestAnimationFrame(() => { + const r = n.innerHTML; + return yt(n), this.setSelectedRange(e), t(r); + }); + } +} +V(mt, "events", { keydown(s) { + this.isComposing() || this.resetInputSummary(), this.inputSummary.didInput = !0; + const t = ro[s.keyCode]; + if (t) { + var e; + let n = this.keys; + ["ctrl", "alt", "shift", "meta"].forEach((r) => { + var o; + s["".concat(r, "Key")] && (r === "ctrl" && (r = "control"), n = (o = n) === null || o === void 0 ? void 0 : o[r]); + }), ((e = n) === null || e === void 0 ? void 0 : e[t]) != null && (this.setInputSummary({ keyName: t }), Mt.reset(), n[t].call(this, s)); + } + if (Lr(s)) { + const n = String.fromCharCode(s.keyCode).toLowerCase(); + if (n) { + var i; + const r = ["alt", "shift"].map((o) => { + if (s["".concat(o, "Key")]) return o; + }).filter((o) => o); + r.push(n), (i = this.delegate) !== null && i !== void 0 && i.inputControllerDidReceiveKeyboardCommand(r) && s.preventDefault(); + } + } +}, keypress(s) { + if (this.inputSummary.eventName != null || s.metaKey || s.ctrlKey && !s.altKey) return; + const t = dl(s); + var e, i; + return t ? ((e = this.delegate) === null || e === void 0 || e.inputControllerWillPerformTyping(), (i = this.responder) === null || i === void 0 || i.insertString(t), this.setInputSummary({ textAdded: t, didDelete: this.selectionIsExpanded() })) : void 0; +}, textInput(s) { + const { data: t } = s, { textAdded: e } = this.inputSummary; + if (e && e !== t && e.toUpperCase() === t) { + var i; + const n = this.getSelectedRange(); + return this.setSelectedRange([n[0], n[1] + e.length]), (i = this.responder) === null || i === void 0 || i.insertString(t), this.setInputSummary({ textAdded: t }), this.setSelectedRange(n); + } +}, dragenter(s) { + s.preventDefault(); +}, dragstart(s) { + var t, e; + return this.serializeSelectionToDataTransfer(s.dataTransfer), this.draggedRange = this.getSelectedRange(), (t = this.delegate) === null || t === void 0 || (e = t.inputControllerDidStartDrag) === null || e === void 0 ? void 0 : e.call(t); +}, dragover(s) { + if (this.draggedRange || this.canAcceptDataTransfer(s.dataTransfer)) { + s.preventDefault(); + const i = { x: s.clientX, y: s.clientY }; + var t, e; + if (!Yt(i, this.draggingPoint)) return this.draggingPoint = i, (t = this.delegate) === null || t === void 0 || (e = t.inputControllerDidReceiveDragOverPoint) === null || e === void 0 ? void 0 : e.call(t, this.draggingPoint); + } +}, dragend(s) { + var t, e; + (t = this.delegate) === null || t === void 0 || (e = t.inputControllerDidCancelDrag) === null || e === void 0 || e.call(t), this.draggedRange = null, this.draggingPoint = null; +}, drop(s) { + var t, e; + s.preventDefault(); + const i = (t = s.dataTransfer) === null || t === void 0 ? void 0 : t.files, n = s.dataTransfer.getData("application/x-trix-document"), r = { x: s.clientX, y: s.clientY }; + if ((e = this.responder) === null || e === void 0 || e.setLocationRangeFromPointRange(r), i != null && i.length) this.attachFiles(i); + else if (this.draggedRange) { + var o, a; + (o = this.delegate) === null || o === void 0 || o.inputControllerWillMoveText(), (a = this.responder) === null || a === void 0 || a.moveTextFromRange(this.draggedRange), this.draggedRange = null, this.requestRender(); + } else if (n) { + var c; + const h = Q.fromJSONString(n); + (c = this.responder) === null || c === void 0 || c.insertDocument(h), this.requestRender(); + } + this.draggedRange = null, this.draggingPoint = null; +}, cut(s) { + var t, e; + if ((t = this.responder) !== null && t !== void 0 && t.selectionIsExpanded() && (this.serializeSelectionToDataTransfer(s.clipboardData) && s.preventDefault(), (e = this.delegate) === null || e === void 0 || e.inputControllerWillCutText(), this.deleteInDirection("backward"), s.defaultPrevented)) return this.requestRender(); +}, copy(s) { + var t; + (t = this.responder) !== null && t !== void 0 && t.selectionIsExpanded() && this.serializeSelectionToDataTransfer(s.clipboardData) && s.preventDefault(); +}, paste(s) { + const t = s.clipboardData || s.testClipboardData, e = { clipboard: t }; + if (!t || ul(s)) return void this.getPastedHTMLUsingHiddenElement((O) => { + var T, tt, ct; + return e.type = "text/html", e.html = O, (T = this.delegate) === null || T === void 0 || T.inputControllerWillPaste(e), (tt = this.responder) === null || tt === void 0 || tt.insertHTML(e.html), this.requestRender(), (ct = this.delegate) === null || ct === void 0 ? void 0 : ct.inputControllerDidPaste(e); + }); + const i = t.getData("URL"), n = t.getData("text/html"), r = t.getData("public.url-name"); + if (i) { + var o, a, c; + let O; + e.type = "text/html", O = r ? wn(r).trim() : i, e.html = this.createLinkHTML(i, O), (o = this.delegate) === null || o === void 0 || o.inputControllerWillPaste(e), this.setInputSummary({ textAdded: O, didDelete: this.selectionIsExpanded() }), (a = this.responder) === null || a === void 0 || a.insertHTML(e.html), this.requestRender(), (c = this.delegate) === null || c === void 0 || c.inputControllerDidPaste(e); + } else if (Cr(t)) { + var h, d, m; + e.type = "text/plain", e.string = t.getData("text/plain"), (h = this.delegate) === null || h === void 0 || h.inputControllerWillPaste(e), this.setInputSummary({ textAdded: e.string, didDelete: this.selectionIsExpanded() }), (d = this.responder) === null || d === void 0 || d.insertString(e.string), this.requestRender(), (m = this.delegate) === null || m === void 0 || m.inputControllerDidPaste(e); + } else if (n) { + var p, f, C; + e.type = "text/html", e.html = n, (p = this.delegate) === null || p === void 0 || p.inputControllerWillPaste(e), (f = this.responder) === null || f === void 0 || f.insertHTML(e.html), this.requestRender(), (C = this.delegate) === null || C === void 0 || C.inputControllerDidPaste(e); + } else if (Array.from(t.types).includes("Files")) { + var L, U; + const O = (L = t.items) === null || L === void 0 || (L = L[0]) === null || L === void 0 || (U = L.getAsFile) === null || U === void 0 ? void 0 : U.call(L); + if (O) { + var j, q, N; + const T = cl(O); + !O.name && T && (O.name = "pasted-file-".concat(++ll, ".").concat(T)), e.type = "File", e.file = O, (j = this.delegate) === null || j === void 0 || j.inputControllerWillAttachFiles(), (q = this.responder) === null || q === void 0 || q.insertFile(e.file), this.requestRender(), (N = this.delegate) === null || N === void 0 || N.inputControllerDidPaste(e); + } + } + s.preventDefault(); +}, compositionstart(s) { + return this.getCompositionInput().start(s.data); +}, compositionupdate(s) { + return this.getCompositionInput().update(s.data); +}, compositionend(s) { + return this.getCompositionInput().end(s.data); +}, beforeinput(s) { + this.inputSummary.didInput = !0; +}, input(s) { + return this.inputSummary.didInput = !0, s.stopPropagation(); +} }), V(mt, "keys", { backspace(s) { + var t; + return (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), this.deleteInDirection("backward", s); +}, delete(s) { + var t; + return (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), this.deleteInDirection("forward", s); +}, return(s) { + var t, e; + return this.setInputSummary({ preferDocument: !0 }), (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), (e = this.responder) === null || e === void 0 ? void 0 : e.insertLineBreak(); +}, tab(s) { + var t, e; + (t = this.responder) !== null && t !== void 0 && t.canIncreaseNestingLevel() && ((e = this.responder) === null || e === void 0 || e.increaseNestingLevel(), this.requestRender(), s.preventDefault()); +}, left(s) { + var t; + if (this.selectionIsInCursorTarget()) return s.preventDefault(), (t = this.responder) === null || t === void 0 ? void 0 : t.moveCursorInDirection("backward"); +}, right(s) { + var t; + if (this.selectionIsInCursorTarget()) return s.preventDefault(), (t = this.responder) === null || t === void 0 ? void 0 : t.moveCursorInDirection("forward"); +}, control: { d(s) { + var t; + return (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), this.deleteInDirection("forward", s); +}, h(s) { + var t; + return (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), this.deleteInDirection("backward", s); +}, o(s) { + var t, e; + return s.preventDefault(), (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), (e = this.responder) === null || e === void 0 || e.insertString(` +`, { updatePosition: !1 }), this.requestRender(); +} }, shift: { return(s) { + var t, e; + (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), (e = this.responder) === null || e === void 0 || e.insertString(` +`), this.requestRender(), s.preventDefault(); +}, tab(s) { + var t, e; + (t = this.responder) !== null && t !== void 0 && t.canDecreaseNestingLevel() && ((e = this.responder) === null || e === void 0 || e.decreaseNestingLevel(), this.requestRender(), s.preventDefault()); +}, left(s) { + if (this.selectionIsInCursorTarget()) return s.preventDefault(), this.expandSelectionInDirection("backward"); +}, right(s) { + if (this.selectionIsInCursorTarget()) return s.preventDefault(), this.expandSelectionInDirection("forward"); +} }, alt: { backspace(s) { + var t; + return this.setInputSummary({ preferDocument: !1 }), (t = this.delegate) === null || t === void 0 ? void 0 : t.inputControllerWillPerformTyping(); +} }, meta: { backspace(s) { + var t; + return this.setInputSummary({ preferDocument: !1 }), (t = this.delegate) === null || t === void 0 ? void 0 : t.inputControllerWillPerformTyping(); +} } }), mt.proxyMethod("responder?.getSelectedRange"), mt.proxyMethod("responder?.setSelectedRange"), mt.proxyMethod("responder?.expandSelectionInDirection"), mt.proxyMethod("responder?.selectionIsInCursorTarget"), mt.proxyMethod("responder?.selectionIsExpanded"); +const cl = (s) => { + var t; + return (t = s.type) === null || t === void 0 || (t = t.match(/\/(\w+)$/)) === null || t === void 0 ? void 0 : t[1]; +}, hl = !((Vi = " ".codePointAt) === null || Vi === void 0 || !Vi.call(" ", 0)), dl = function(s) { + if (s.key && hl && s.key.codePointAt(0) === s.keyCode) return s.key; + { + let t; + if (s.which === null ? t = s.keyCode : s.which !== 0 && s.charCode !== 0 && (t = s.charCode), t != null && ro[t] !== "escape") return ye.fromCodepoints([t]).toString(); + } +}, ul = function(s) { + const t = s.clipboardData; + if (t) { + if (t.types.includes("text/html")) { + for (const e of t.types) { + const i = /^CorePasteboardFlavorType/.test(e), n = /^dyn\./.test(e) && t.getData(e); + if (i || n) return !0; + } + return !1; + } + { + const e = t.types.includes("com.apple.webarchive"), i = t.types.includes("com.apple.flat-rtfd"); + return e || i; + } + } +}; +class bt extends M { + constructor(t) { + super(...arguments), this.inputController = t, this.responder = this.inputController.responder, this.delegate = this.inputController.delegate, this.inputSummary = this.inputController.inputSummary, this.data = {}; + } + start(t) { + if (this.data.start = t, this.isSignificant()) { + var e, i; + this.inputSummary.eventName === "keypress" && this.inputSummary.textAdded && ((i = this.responder) === null || i === void 0 || i.deleteInDirection("left")), this.selectionIsExpanded() || (this.insertPlaceholder(), this.requestRender()), this.range = (e = this.responder) === null || e === void 0 ? void 0 : e.getSelectedRange(); + } + } + update(t) { + if (this.data.update = t, this.isSignificant()) { + const e = this.selectPlaceholder(); + e && (this.forgetPlaceholder(), this.range = e); + } + } + end(t) { + return this.data.end = t, this.isSignificant() ? (this.forgetPlaceholder(), this.canApplyToDocument() ? (this.setInputSummary({ preferDocument: !0, didInput: !1 }), (e = this.delegate) === null || e === void 0 || e.inputControllerWillPerformTyping(), (i = this.responder) === null || i === void 0 || i.setSelectedRange(this.range), (n = this.responder) === null || n === void 0 || n.insertString(this.data.end), (r = this.responder) === null || r === void 0 ? void 0 : r.setSelectedRange(this.range[0] + this.data.end.length)) : this.data.start != null || this.data.update != null ? (this.requestReparse(), this.inputController.reset()) : void 0) : this.inputController.reset(); + var e, i, n, r; + } + getEndData() { + return this.data.end; + } + isEnded() { + return this.getEndData() != null; + } + isSignificant() { + return !al.composesExistingText || this.inputSummary.didInput; + } + canApplyToDocument() { + var t, e; + return ((t = this.data.start) === null || t === void 0 ? void 0 : t.length) === 0 && ((e = this.data.end) === null || e === void 0 ? void 0 : e.length) > 0 && this.range; + } +} +bt.proxyMethod("inputController.setInputSummary"), bt.proxyMethod("inputController.requestRender"), bt.proxyMethod("inputController.requestReparse"), bt.proxyMethod("responder?.selectionIsExpanded"), bt.proxyMethod("responder?.insertPlaceholder"), bt.proxyMethod("responder?.selectPlaceholder"), bt.proxyMethod("responder?.forgetPlaceholder"); +class ve extends ri { + constructor() { + super(...arguments), this.render = this.render.bind(this); + } + elementDidMutate() { + return this.scheduledRender ? this.composing ? (t = this.delegate) === null || t === void 0 || (e = t.inputControllerDidAllowUnhandledInput) === null || e === void 0 ? void 0 : e.call(t) : void 0 : this.reparse(); + var t, e; + } + scheduleRender() { + return this.scheduledRender ? this.scheduledRender : this.scheduledRender = requestAnimationFrame(this.render); + } + render() { + var t, e; + cancelAnimationFrame(this.scheduledRender), this.scheduledRender = null, this.composing || (e = this.delegate) === null || e === void 0 || e.render(), (t = this.afterRender) === null || t === void 0 || t.call(this), this.afterRender = null; + } + reparse() { + var t; + return (t = this.delegate) === null || t === void 0 ? void 0 : t.reparse(); + } + insertString() { + var t; + let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", i = arguments.length > 1 ? arguments[1] : void 0; + return (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), this.withTargetDOMRange(function() { + var n; + return (n = this.responder) === null || n === void 0 ? void 0 : n.insertString(e, i); + }); + } + toggleAttributeIfSupported(t) { + var e; + if (hn().includes(t)) return (e = this.delegate) === null || e === void 0 || e.inputControllerWillPerformFormatting(t), this.withTargetDOMRange(function() { + var i; + return (i = this.responder) === null || i === void 0 ? void 0 : i.toggleCurrentAttribute(t); + }); + } + activateAttributeIfSupported(t, e) { + var i; + if (hn().includes(t)) return (i = this.delegate) === null || i === void 0 || i.inputControllerWillPerformFormatting(t), this.withTargetDOMRange(function() { + var n; + return (n = this.responder) === null || n === void 0 ? void 0 : n.setCurrentAttribute(t, e); + }); + } + deleteInDirection(t) { + let { recordUndoEntry: e } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { recordUndoEntry: !0 }; + var i; + e && ((i = this.delegate) === null || i === void 0 || i.inputControllerWillPerformTyping()); + const n = () => { + var o; + return (o = this.responder) === null || o === void 0 ? void 0 : o.deleteInDirection(t); + }, r = this.getTargetDOMRange({ minLength: this.composing ? 1 : 2 }); + return r ? this.withTargetDOMRange(r, n) : n(); + } + withTargetDOMRange(t, e) { + var i; + return typeof t == "function" && (e = t, t = this.getTargetDOMRange()), t ? (i = this.responder) === null || i === void 0 ? void 0 : i.withTargetDOMRange(t, e.bind(this)) : (Mt.reset(), e.call(this)); + } + getTargetDOMRange() { + var t, e; + let { minLength: i } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { minLength: 0 }; + const n = (t = (e = this.event).getTargetRanges) === null || t === void 0 ? void 0 : t.call(e); + if (n && n.length) { + const r = ml(n[0]); + if (i === 0 || r.toString().length >= i) return r; + } + } + withEvent(t, e) { + let i; + this.event = t; + try { + i = e.call(this); + } finally { + this.event = null; + } + return i; + } +} +V(ve, "events", { keydown(s) { + if (Lr(s)) { + var t; + const e = fl(s); + (t = this.delegate) !== null && t !== void 0 && t.inputControllerDidReceiveKeyboardCommand(e) && s.preventDefault(); + } else { + let e = s.key; + s.altKey && (e += "+Alt"), s.shiftKey && (e += "+Shift"); + const i = this.constructor.keys[e]; + if (i) return this.withEvent(s, i); + } +}, paste(s) { + var t; + let e; + const i = (t = s.clipboardData) === null || t === void 0 ? void 0 : t.getData("URL"); + return oo(s) ? (s.preventDefault(), this.attachFiles(s.clipboardData.files)) : pl(s) ? (s.preventDefault(), e = { type: "text/plain", string: s.clipboardData.getData("text/plain") }, (n = this.delegate) === null || n === void 0 || n.inputControllerWillPaste(e), (r = this.responder) === null || r === void 0 || r.insertString(e.string), this.render(), (o = this.delegate) === null || o === void 0 ? void 0 : o.inputControllerDidPaste(e)) : i ? (s.preventDefault(), e = { type: "text/html", html: this.createLinkHTML(i) }, (a = this.delegate) === null || a === void 0 || a.inputControllerWillPaste(e), (c = this.responder) === null || c === void 0 || c.insertHTML(e.html), this.render(), (h = this.delegate) === null || h === void 0 ? void 0 : h.inputControllerDidPaste(e)) : void 0; + var n, r, o, a, c, h; +}, beforeinput(s) { + const t = this.constructor.inputTypes[s.inputType], e = (i = s, !(!/iPhone|iPad/.test(navigator.userAgent) || i.inputType && i.inputType !== "insertParagraph")); + var i; + t && (this.withEvent(s, t), e || this.scheduleRender()), e && this.render(); +}, input(s) { + Mt.reset(); +}, dragstart(s) { + var t, e; + (t = this.responder) !== null && t !== void 0 && t.selectionContainsAttachments() && (s.dataTransfer.setData("application/x-trix-dragging", !0), this.dragging = { range: (e = this.responder) === null || e === void 0 ? void 0 : e.getSelectedRange(), point: zi(s) }); +}, dragenter(s) { + Wi(s) && s.preventDefault(); +}, dragover(s) { + if (this.dragging) { + s.preventDefault(); + const e = zi(s); + var t; + if (!Yt(e, this.dragging.point)) return this.dragging.point = e, (t = this.responder) === null || t === void 0 ? void 0 : t.setLocationRangeFromPointRange(e); + } else Wi(s) && s.preventDefault(); +}, drop(s) { + var t, e; + if (this.dragging) return s.preventDefault(), (t = this.delegate) === null || t === void 0 || t.inputControllerWillMoveText(), (e = this.responder) === null || e === void 0 || e.moveTextFromRange(this.dragging.range), this.dragging = null, this.scheduleRender(); + if (Wi(s)) { + var i; + s.preventDefault(); + const n = zi(s); + return (i = this.responder) === null || i === void 0 || i.setLocationRangeFromPointRange(n), this.attachFiles(s.dataTransfer.files); + } +}, dragend() { + var s; + this.dragging && ((s = this.responder) === null || s === void 0 || s.setSelectedRange(this.dragging.range), this.dragging = null); +}, compositionend(s) { + this.composing && (this.composing = !1, Ce.recentAndroid || this.scheduleRender()); +} }), V(ve, "keys", { ArrowLeft() { + var s, t; + if ((s = this.responder) !== null && s !== void 0 && s.shouldManageMovingCursorInDirection("backward")) return this.event.preventDefault(), (t = this.responder) === null || t === void 0 ? void 0 : t.moveCursorInDirection("backward"); +}, ArrowRight() { + var s, t; + if ((s = this.responder) !== null && s !== void 0 && s.shouldManageMovingCursorInDirection("forward")) return this.event.preventDefault(), (t = this.responder) === null || t === void 0 ? void 0 : t.moveCursorInDirection("forward"); +}, Backspace() { + var s, t, e; + if ((s = this.responder) !== null && s !== void 0 && s.shouldManageDeletingInDirection("backward")) return this.event.preventDefault(), (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), (e = this.responder) === null || e === void 0 || e.deleteInDirection("backward"), this.render(); +}, Tab() { + var s, t; + if ((s = this.responder) !== null && s !== void 0 && s.canIncreaseNestingLevel()) return this.event.preventDefault(), (t = this.responder) === null || t === void 0 || t.increaseNestingLevel(), this.render(); +}, "Tab+Shift"() { + var s, t; + if ((s = this.responder) !== null && s !== void 0 && s.canDecreaseNestingLevel()) return this.event.preventDefault(), (t = this.responder) === null || t === void 0 || t.decreaseNestingLevel(), this.render(); +} }), V(ve, "inputTypes", { deleteByComposition() { + return this.deleteInDirection("backward", { recordUndoEntry: !1 }); +}, deleteByCut() { + return this.deleteInDirection("backward"); +}, deleteByDrag() { + return this.event.preventDefault(), this.withTargetDOMRange(function() { + var s; + this.deleteByDragRange = (s = this.responder) === null || s === void 0 ? void 0 : s.getSelectedRange(); + }); +}, deleteCompositionText() { + return this.deleteInDirection("backward", { recordUndoEntry: !1 }); +}, deleteContent() { + return this.deleteInDirection("backward"); +}, deleteContentBackward() { + return this.deleteInDirection("backward"); +}, deleteContentForward() { + return this.deleteInDirection("forward"); +}, deleteEntireSoftLine() { + return this.deleteInDirection("forward"); +}, deleteHardLineBackward() { + return this.deleteInDirection("backward"); +}, deleteHardLineForward() { + return this.deleteInDirection("forward"); +}, deleteSoftLineBackward() { + return this.deleteInDirection("backward"); +}, deleteSoftLineForward() { + return this.deleteInDirection("forward"); +}, deleteWordBackward() { + return this.deleteInDirection("backward"); +}, deleteWordForward() { + return this.deleteInDirection("forward"); +}, formatBackColor() { + return this.activateAttributeIfSupported("backgroundColor", this.event.data); +}, formatBold() { + return this.toggleAttributeIfSupported("bold"); +}, formatFontColor() { + return this.activateAttributeIfSupported("color", this.event.data); +}, formatFontName() { + return this.activateAttributeIfSupported("font", this.event.data); +}, formatIndent() { + var s; + if ((s = this.responder) !== null && s !== void 0 && s.canIncreaseNestingLevel()) return this.withTargetDOMRange(function() { + var t; + return (t = this.responder) === null || t === void 0 ? void 0 : t.increaseNestingLevel(); + }); +}, formatItalic() { + return this.toggleAttributeIfSupported("italic"); +}, formatJustifyCenter() { + return this.toggleAttributeIfSupported("justifyCenter"); +}, formatJustifyFull() { + return this.toggleAttributeIfSupported("justifyFull"); +}, formatJustifyLeft() { + return this.toggleAttributeIfSupported("justifyLeft"); +}, formatJustifyRight() { + return this.toggleAttributeIfSupported("justifyRight"); +}, formatOutdent() { + var s; + if ((s = this.responder) !== null && s !== void 0 && s.canDecreaseNestingLevel()) return this.withTargetDOMRange(function() { + var t; + return (t = this.responder) === null || t === void 0 ? void 0 : t.decreaseNestingLevel(); + }); +}, formatRemove() { + this.withTargetDOMRange(function() { + for (const e in (s = this.responder) === null || s === void 0 ? void 0 : s.getCurrentAttributes()) { + var s, t; + (t = this.responder) === null || t === void 0 || t.removeCurrentAttribute(e); + } + }); +}, formatSetBlockTextDirection() { + return this.activateAttributeIfSupported("blockDir", this.event.data); +}, formatSetInlineTextDirection() { + return this.activateAttributeIfSupported("textDir", this.event.data); +}, formatStrikeThrough() { + return this.toggleAttributeIfSupported("strike"); +}, formatSubscript() { + return this.toggleAttributeIfSupported("sub"); +}, formatSuperscript() { + return this.toggleAttributeIfSupported("sup"); +}, formatUnderline() { + return this.toggleAttributeIfSupported("underline"); +}, historyRedo() { + var s; + return (s = this.delegate) === null || s === void 0 ? void 0 : s.inputControllerWillPerformRedo(); +}, historyUndo() { + var s; + return (s = this.delegate) === null || s === void 0 ? void 0 : s.inputControllerWillPerformUndo(); +}, insertCompositionText() { + return this.composing = !0, this.insertString(this.event.data); +}, insertFromComposition() { + return this.composing = !1, this.insertString(this.event.data); +}, insertFromDrop() { + const s = this.deleteByDragRange; + var t; + if (s) return this.deleteByDragRange = null, (t = this.delegate) === null || t === void 0 || t.inputControllerWillMoveText(), this.withTargetDOMRange(function() { + var e; + return (e = this.responder) === null || e === void 0 ? void 0 : e.moveTextFromRange(s); + }); +}, insertFromPaste() { + const { dataTransfer: s } = this.event, t = { dataTransfer: s }, e = s.getData("URL"), i = s.getData("text/html"); + if (e) { + var n; + let c; + this.event.preventDefault(), t.type = "text/html"; + const h = s.getData("public.url-name"); + c = h ? wn(h).trim() : e, t.html = this.createLinkHTML(e, c), (n = this.delegate) === null || n === void 0 || n.inputControllerWillPaste(t), this.withTargetDOMRange(function() { + var d; + return (d = this.responder) === null || d === void 0 ? void 0 : d.insertHTML(t.html); + }), this.afterRender = () => { + var d; + return (d = this.delegate) === null || d === void 0 ? void 0 : d.inputControllerDidPaste(t); + }; + } else if (Cr(s)) { + var r; + t.type = "text/plain", t.string = s.getData("text/plain"), (r = this.delegate) === null || r === void 0 || r.inputControllerWillPaste(t), this.withTargetDOMRange(function() { + var c; + return (c = this.responder) === null || c === void 0 ? void 0 : c.insertString(t.string); + }), this.afterRender = () => { + var c; + return (c = this.delegate) === null || c === void 0 ? void 0 : c.inputControllerDidPaste(t); + }; + } else if (gl(this.event)) { + var o; + t.type = "File", t.file = s.files[0], (o = this.delegate) === null || o === void 0 || o.inputControllerWillPaste(t), this.withTargetDOMRange(function() { + var c; + return (c = this.responder) === null || c === void 0 ? void 0 : c.insertFile(t.file); + }), this.afterRender = () => { + var c; + return (c = this.delegate) === null || c === void 0 ? void 0 : c.inputControllerDidPaste(t); + }; + } else if (i) { + var a; + this.event.preventDefault(), t.type = "text/html", t.html = i, (a = this.delegate) === null || a === void 0 || a.inputControllerWillPaste(t), this.withTargetDOMRange(function() { + var c; + return (c = this.responder) === null || c === void 0 ? void 0 : c.insertHTML(t.html); + }), this.afterRender = () => { + var c; + return (c = this.delegate) === null || c === void 0 ? void 0 : c.inputControllerDidPaste(t); + }; + } +}, insertFromYank() { + return this.insertString(this.event.data); +}, insertLineBreak() { + return this.insertString(` +`); +}, insertLink() { + return this.activateAttributeIfSupported("href", this.event.data); +}, insertOrderedList() { + return this.toggleAttributeIfSupported("number"); +}, insertParagraph() { + var s; + return (s = this.delegate) === null || s === void 0 || s.inputControllerWillPerformTyping(), this.withTargetDOMRange(function() { + var t; + return (t = this.responder) === null || t === void 0 ? void 0 : t.insertLineBreak(); + }); +}, insertReplacementText() { + const s = this.event.dataTransfer.getData("text/plain"), t = this.event.getTargetRanges()[0]; + this.withTargetDOMRange(t, () => { + this.insertString(s, { updatePosition: !1 }); + }); +}, insertText() { + var s; + return this.insertString(this.event.data || ((s = this.event.dataTransfer) === null || s === void 0 ? void 0 : s.getData("text/plain"))); +}, insertTranspose() { + return this.insertString(this.event.data); +}, insertUnorderedList() { + return this.toggleAttributeIfSupported("bullet"); +} }); +const ml = function(s) { + const t = document.createRange(); + return t.setStart(s.startContainer, s.startOffset), t.setEnd(s.endContainer, s.endOffset), t; +}, Wi = (s) => { + var t; + return Array.from(((t = s.dataTransfer) === null || t === void 0 ? void 0 : t.types) || []).includes("Files"); +}, gl = (s) => { + var t; + return ((t = s.dataTransfer.files) === null || t === void 0 ? void 0 : t[0]) && !oo(s) && !((e) => { + let { dataTransfer: i } = e; + return i.types.includes("Files") && i.types.includes("text/html") && i.getData("text/html").includes("urn:schemas-microsoft-com:office:office"); + })(s); +}, oo = function(s) { + const t = s.clipboardData; + if (t) + return Array.from(t.types).filter((e) => e.match(/file/i)).length === t.types.length && t.files.length >= 1; +}, pl = function(s) { + const t = s.clipboardData; + if (t) return t.types.includes("text/plain") && t.types.length === 1; +}, fl = function(s) { + const t = []; + return s.altKey && t.push("alt"), s.shiftKey && t.push("shift"), t.push(s.key), t; +}, zi = (s) => ({ x: s.clientX, y: s.clientY }), vn = "[data-trix-attribute]", _n = "[data-trix-action]", bl = "".concat(vn, ", ").concat(_n), oi = "[data-trix-dialog]", vl = "".concat(oi, "[data-trix-active]"), _l = "".concat(oi, " [data-trix-method]"), Ms = "".concat(oi, " [data-trix-input]"), Bs = (s, t) => (t || (t = Wt(s)), s.querySelector("[data-trix-input][name='".concat(t, "']"))), Ns = (s) => s.getAttribute("data-trix-action"), Wt = (s) => s.getAttribute("data-trix-attribute") || s.getAttribute("data-trix-dialog-attribute"); +class ao extends M { + constructor(t) { + super(t), this.didClickActionButton = this.didClickActionButton.bind(this), this.didClickAttributeButton = this.didClickAttributeButton.bind(this), this.didClickDialogButton = this.didClickDialogButton.bind(this), this.didKeyDownDialogInput = this.didKeyDownDialogInput.bind(this), this.element = t, this.attributes = {}, this.actions = {}, this.resetDialogInputs(), k("mousedown", { onElement: this.element, matchingSelector: _n, withCallback: this.didClickActionButton }), k("mousedown", { onElement: this.element, matchingSelector: vn, withCallback: this.didClickAttributeButton }), k("click", { onElement: this.element, matchingSelector: bl, preventDefault: !0 }), k("click", { onElement: this.element, matchingSelector: _l, withCallback: this.didClickDialogButton }), k("keydown", { onElement: this.element, matchingSelector: Ms, withCallback: this.didKeyDownDialogInput }); + } + didClickActionButton(t, e) { + var i; + (i = this.delegate) === null || i === void 0 || i.toolbarDidClickButton(), t.preventDefault(); + const n = Ns(e); + return this.getDialog(n) ? this.toggleDialog(n) : (r = this.delegate) === null || r === void 0 ? void 0 : r.toolbarDidInvokeAction(n, e); + var r; + } + didClickAttributeButton(t, e) { + var i; + (i = this.delegate) === null || i === void 0 || i.toolbarDidClickButton(), t.preventDefault(); + const n = Wt(e); + var r; + return this.getDialog(n) ? this.toggleDialog(n) : (r = this.delegate) === null || r === void 0 || r.toolbarDidToggleAttribute(n), this.refreshAttributeButtons(); + } + didClickDialogButton(t, e) { + const i = At(e, { matchingSelector: oi }); + return this[e.getAttribute("data-trix-method")].call(this, i); + } + didKeyDownDialogInput(t, e) { + if (t.keyCode === 13) { + t.preventDefault(); + const i = e.getAttribute("name"), n = this.getDialog(i); + this.setAttribute(n); + } + if (t.keyCode === 27) return t.preventDefault(), this.hideDialog(); + } + updateActions(t) { + return this.actions = t, this.refreshActionButtons(); + } + refreshActionButtons() { + return this.eachActionButton((t, e) => { + t.disabled = this.actions[e] === !1; + }); + } + eachActionButton(t) { + return Array.from(this.element.querySelectorAll(_n)).map((e) => t(e, Ns(e))); + } + updateAttributes(t) { + return this.attributes = t, this.refreshAttributeButtons(); + } + refreshAttributeButtons() { + return this.eachAttributeButton((t, e) => (t.disabled = this.attributes[e] === !1, this.attributes[e] || this.dialogIsVisible(e) ? (t.setAttribute("data-trix-active", ""), t.classList.add("trix-active")) : (t.removeAttribute("data-trix-active"), t.classList.remove("trix-active")))); + } + eachAttributeButton(t) { + return Array.from(this.element.querySelectorAll(vn)).map((e) => t(e, Wt(e))); + } + applyKeyboardCommand(t) { + const e = JSON.stringify(t.sort()); + for (const i of Array.from(this.element.querySelectorAll("[data-trix-key]"))) { + const n = i.getAttribute("data-trix-key").split("+"); + if (JSON.stringify(n.sort()) === e) return me("mousedown", { onElement: i }), !0; + } + return !1; + } + dialogIsVisible(t) { + const e = this.getDialog(t); + if (e) return e.hasAttribute("data-trix-active"); + } + toggleDialog(t) { + return this.dialogIsVisible(t) ? this.hideDialog() : this.showDialog(t); + } + showDialog(t) { + var e, i; + this.hideDialog(), (e = this.delegate) === null || e === void 0 || e.toolbarWillShowDialog(); + const n = this.getDialog(t); + n.setAttribute("data-trix-active", ""), n.classList.add("trix-active"), Array.from(n.querySelectorAll("input[disabled]")).forEach((o) => { + o.removeAttribute("disabled"); + }); + const r = Wt(n); + if (r) { + const o = Bs(n, t); + o && (o.value = this.attributes[r] || "", o.select()); + } + return (i = this.delegate) === null || i === void 0 ? void 0 : i.toolbarDidShowDialog(t); + } + setAttribute(t) { + var e; + const i = Wt(t), n = Bs(t, i); + return !n.willValidate || (n.setCustomValidity(""), n.checkValidity() && this.isSafeAttribute(n)) ? ((e = this.delegate) === null || e === void 0 || e.toolbarDidUpdateAttribute(i, n.value), this.hideDialog()) : (n.setCustomValidity("Invalid value"), n.setAttribute("data-trix-validate", ""), n.classList.add("trix-validate"), n.focus()); + } + isSafeAttribute(t) { + return !t.hasAttribute("data-trix-validate-href") || Ee.isValidAttribute("a", "href", t.value); + } + removeAttribute(t) { + var e; + const i = Wt(t); + return (e = this.delegate) === null || e === void 0 || e.toolbarDidRemoveAttribute(i), this.hideDialog(); + } + hideDialog() { + const t = this.element.querySelector(vl); + var e; + if (t) return t.removeAttribute("data-trix-active"), t.classList.remove("trix-active"), this.resetDialogInputs(), (e = this.delegate) === null || e === void 0 ? void 0 : e.toolbarDidHideDialog(((i) => i.getAttribute("data-trix-dialog"))(t)); + } + resetDialogInputs() { + Array.from(this.element.querySelectorAll(Ms)).forEach((t) => { + t.setAttribute("disabled", "disabled"), t.removeAttribute("data-trix-validate"), t.classList.remove("trix-validate"); + }); + } + getDialog(t) { + return this.element.querySelector("[data-trix-dialog=".concat(t, "]")); + } +} +class _e extends eo { + constructor(t) { + let { editorElement: e, document: i, html: n } = t; + super(...arguments), this.editorElement = e, this.selectionManager = new Lt(this.editorElement), this.selectionManager.delegate = this, this.composition = new vt(), this.composition.delegate = this, this.attachmentManager = new Vr(this.composition.getAttachments()), this.attachmentManager.delegate = this, this.inputController = xn.getLevel() === 2 ? new ve(this.editorElement) : new mt(this.editorElement), this.inputController.delegate = this, this.inputController.responder = this.composition, this.compositionController = new to(this.editorElement, this.composition), this.compositionController.delegate = this, this.toolbarController = new ao(this.editorElement.toolbarElement), this.toolbarController.delegate = this, this.editor = new Gr(this.composition, this.selectionManager, this.editorElement), i ? this.editor.loadDocument(i) : this.editor.loadHTML(n); + } + registerSelectionManager() { + return Mt.registerSelectionManager(this.selectionManager); + } + unregisterSelectionManager() { + return Mt.unregisterSelectionManager(this.selectionManager); + } + render() { + return this.compositionController.render(); + } + reparse() { + return this.composition.replaceHTML(this.editorElement.innerHTML); + } + compositionDidChangeDocument(t) { + if (this.notifyEditorElement("document-change"), !this.handlingInput) return this.render(); + } + compositionDidChangeCurrentAttributes(t) { + return this.currentAttributes = t, this.toolbarController.updateAttributes(this.currentAttributes), this.updateCurrentActions(), this.notifyEditorElement("attributes-change", { attributes: this.currentAttributes }); + } + compositionDidPerformInsertionAtRange(t) { + this.pasting && (this.pastedRange = t); + } + compositionShouldAcceptFile(t) { + return this.notifyEditorElement("file-accept", { file: t }); + } + compositionDidAddAttachment(t) { + const e = this.attachmentManager.manageAttachment(t); + return this.notifyEditorElement("attachment-add", { attachment: e }); + } + compositionDidEditAttachment(t) { + this.compositionController.rerenderViewForObject(t); + const e = this.attachmentManager.manageAttachment(t); + return this.notifyEditorElement("attachment-edit", { attachment: e }), this.notifyEditorElement("change"); + } + compositionDidChangeAttachmentPreviewURL(t) { + return this.compositionController.invalidateViewForObject(t), this.notifyEditorElement("change"); + } + compositionDidRemoveAttachment(t) { + const e = this.attachmentManager.unmanageAttachment(t); + return this.notifyEditorElement("attachment-remove", { attachment: e }); + } + compositionDidStartEditingAttachment(t, e) { + return this.attachmentLocationRange = this.composition.document.getLocationRangeOfAttachment(t), this.compositionController.installAttachmentEditorForAttachment(t, e), this.selectionManager.setLocationRange(this.attachmentLocationRange); + } + compositionDidStopEditingAttachment(t) { + this.compositionController.uninstallAttachmentEditor(), this.attachmentLocationRange = null; + } + compositionDidRequestChangingSelectionToLocationRange(t) { + if (!this.loadingSnapshot || this.isFocused()) return this.requestedLocationRange = t, this.compositionRevisionWhenLocationRangeRequested = this.composition.revision, this.handlingInput ? void 0 : this.render(); + } + compositionWillLoadSnapshot() { + this.loadingSnapshot = !0; + } + compositionDidLoadSnapshot() { + this.compositionController.refreshViewCache(), this.render(), this.loadingSnapshot = !1; + } + getSelectionManager() { + return this.selectionManager; + } + attachmentManagerDidRequestRemovalOfAttachment(t) { + return this.removeAttachment(t); + } + compositionControllerWillSyncDocumentView() { + return this.inputController.editorWillSyncDocumentView(), this.selectionManager.lock(), this.selectionManager.clearSelection(); + } + compositionControllerDidSyncDocumentView() { + return this.inputController.editorDidSyncDocumentView(), this.selectionManager.unlock(), this.updateCurrentActions(), this.notifyEditorElement("sync"); + } + compositionControllerDidRender() { + this.requestedLocationRange && (this.compositionRevisionWhenLocationRangeRequested === this.composition.revision && this.selectionManager.setLocationRange(this.requestedLocationRange), this.requestedLocationRange = null, this.compositionRevisionWhenLocationRangeRequested = null), this.renderedCompositionRevision !== this.composition.revision && (this.runEditorFilters(), this.composition.updateCurrentAttributes(), this.notifyEditorElement("render")), this.renderedCompositionRevision = this.composition.revision; + } + compositionControllerDidFocus() { + return this.isFocusedInvisibly() && this.setLocationRange({ index: 0, offset: 0 }), this.toolbarController.hideDialog(), this.notifyEditorElement("focus"); + } + compositionControllerDidBlur() { + return this.notifyEditorElement("blur"); + } + compositionControllerDidSelectAttachment(t, e) { + return this.toolbarController.hideDialog(), this.composition.editAttachment(t, e); + } + compositionControllerDidRequestDeselectingAttachment(t) { + const e = this.attachmentLocationRange || this.composition.document.getLocationRangeOfAttachment(t); + return this.selectionManager.setLocationRange(e[1]); + } + compositionControllerWillUpdateAttachment(t) { + return this.editor.recordUndoEntry("Edit Attachment", { context: t.id, consolidatable: !0 }); + } + compositionControllerDidRequestRemovalOfAttachment(t) { + return this.removeAttachment(t); + } + inputControllerWillHandleInput() { + this.handlingInput = !0, this.requestedRender = !1; + } + inputControllerDidRequestRender() { + this.requestedRender = !0; + } + inputControllerDidHandleInput() { + if (this.handlingInput = !1, this.requestedRender) return this.requestedRender = !1, this.render(); + } + inputControllerDidAllowUnhandledInput() { + return this.notifyEditorElement("change"); + } + inputControllerDidRequestReparse() { + return this.reparse(); + } + inputControllerWillPerformTyping() { + return this.recordTypingUndoEntry(); + } + inputControllerWillPerformFormatting(t) { + return this.recordFormattingUndoEntry(t); + } + inputControllerWillCutText() { + return this.editor.recordUndoEntry("Cut"); + } + inputControllerWillPaste(t) { + return this.editor.recordUndoEntry("Paste"), this.pasting = !0, this.notifyEditorElement("before-paste", { paste: t }); + } + inputControllerDidPaste(t) { + return t.range = this.pastedRange, this.pastedRange = null, this.pasting = null, this.notifyEditorElement("paste", { paste: t }); + } + inputControllerWillMoveText() { + return this.editor.recordUndoEntry("Move"); + } + inputControllerWillAttachFiles() { + return this.editor.recordUndoEntry("Drop Files"); + } + inputControllerWillPerformUndo() { + return this.editor.undo(); + } + inputControllerWillPerformRedo() { + return this.editor.redo(); + } + inputControllerDidReceiveKeyboardCommand(t) { + return this.toolbarController.applyKeyboardCommand(t); + } + inputControllerDidStartDrag() { + this.locationRangeBeforeDrag = this.selectionManager.getLocationRange(); + } + inputControllerDidReceiveDragOverPoint(t) { + return this.selectionManager.setLocationRangeFromPointRange(t); + } + inputControllerDidCancelDrag() { + this.selectionManager.setLocationRange(this.locationRangeBeforeDrag), this.locationRangeBeforeDrag = null; + } + locationRangeDidChange(t) { + return this.composition.updateCurrentAttributes(), this.updateCurrentActions(), this.attachmentLocationRange && !Ye(this.attachmentLocationRange, t) && this.composition.stopEditingAttachment(), this.notifyEditorElement("selection-change"); + } + toolbarDidClickButton() { + if (!this.getLocationRange()) return this.setLocationRange({ index: 0, offset: 0 }); + } + toolbarDidInvokeAction(t, e) { + return this.invokeAction(t, e); + } + toolbarDidToggleAttribute(t) { + if (this.recordFormattingUndoEntry(t), this.composition.toggleCurrentAttribute(t), this.render(), !this.selectionFrozen) return this.editorElement.focus(); + } + toolbarDidUpdateAttribute(t, e) { + if (this.recordFormattingUndoEntry(t), this.composition.setCurrentAttribute(t, e), this.render(), !this.selectionFrozen) return this.editorElement.focus(); + } + toolbarDidRemoveAttribute(t) { + if (this.recordFormattingUndoEntry(t), this.composition.removeCurrentAttribute(t), this.render(), !this.selectionFrozen) return this.editorElement.focus(); + } + toolbarWillShowDialog(t) { + return this.composition.expandSelectionForEditing(), this.freezeSelection(); + } + toolbarDidShowDialog(t) { + return this.notifyEditorElement("toolbar-dialog-show", { dialogName: t }); + } + toolbarDidHideDialog(t) { + return this.thawSelection(), this.editorElement.focus(), this.notifyEditorElement("toolbar-dialog-hide", { dialogName: t }); + } + freezeSelection() { + if (!this.selectionFrozen) return this.selectionManager.lock(), this.composition.freezeSelection(), this.selectionFrozen = !0, this.render(); + } + thawSelection() { + if (this.selectionFrozen) return this.composition.thawSelection(), this.selectionManager.unlock(), this.selectionFrozen = !1, this.render(); + } + canInvokeAction(t) { + return !!this.actionIsExternal(t) || !((e = this.actions[t]) === null || e === void 0 || (e = e.test) === null || e === void 0 || !e.call(this)); + var e; + } + invokeAction(t, e) { + return this.actionIsExternal(t) ? this.notifyEditorElement("action-invoke", { actionName: t, invokingElement: e }) : (i = this.actions[t]) === null || i === void 0 || (i = i.perform) === null || i === void 0 ? void 0 : i.call(this); + var i; + } + actionIsExternal(t) { + return /^x-./.test(t); + } + getCurrentActions() { + const t = {}; + for (const e in this.actions) t[e] = this.canInvokeAction(e); + return t; + } + updateCurrentActions() { + const t = this.getCurrentActions(); + if (!Yt(t, this.currentActions)) return this.currentActions = t, this.toolbarController.updateActions(this.currentActions), this.notifyEditorElement("actions-change", { actions: this.currentActions }); + } + runEditorFilters() { + let t = this.composition.getSnapshot(); + if (Array.from(this.editor.filters).forEach((n) => { + const { document: r, selectedRange: o } = t; + t = n.call(this.editor, t) || {}, t.document || (t.document = r), t.selectedRange || (t.selectedRange = o); + }), e = t, i = this.composition.getSnapshot(), !Ye(e.selectedRange, i.selectedRange) || !e.document.isEqualTo(i.document)) return this.composition.loadSnapshot(t); + var e, i; + } + updateInputElement() { + const t = function(e, i) { + const n = Ga[i]; + if (n) return n(e); + throw new Error("unknown content type: ".concat(i)); + }(this.compositionController.getSerializableElement(), "text/html"); + return this.editorElement.setFormValue(t); + } + notifyEditorElement(t, e) { + switch (t) { + case "document-change": + this.documentChangedSinceLastRender = !0; + break; + case "render": + this.documentChangedSinceLastRender && (this.documentChangedSinceLastRender = !1, this.notifyEditorElement("change")); + break; + case "change": + case "attachment-add": + case "attachment-edit": + case "attachment-remove": + this.updateInputElement(); + } + return this.editorElement.notify(t, e); + } + removeAttachment(t) { + return this.editor.recordUndoEntry("Delete Attachment"), this.composition.removeAttachment(t), this.render(); + } + recordFormattingUndoEntry(t) { + const e = D(t), i = this.selectionManager.getLocationRange(); + if (e || !gt(i)) return this.editor.recordUndoEntry("Formatting", { context: this.getUndoContext(), consolidatable: !0 }); + } + recordTypingUndoEntry() { + return this.editor.recordUndoEntry("Typing", { context: this.getUndoContext(this.currentAttributes), consolidatable: !0 }); + } + getUndoContext() { + for (var t = arguments.length, e = new Array(t), i = 0; i < t; i++) e[i] = arguments[i]; + return [this.getLocationContext(), this.getTimeContext(), ...Array.from(e)]; + } + getLocationContext() { + const t = this.selectionManager.getLocationRange(); + return gt(t) ? t[0].index : t; + } + getTimeContext() { + return an.interval > 0 ? Math.floor((/* @__PURE__ */ new Date()).getTime() / an.interval) : 0; + } + isFocused() { + var t; + return this.editorElement === ((t = this.editorElement.ownerDocument) === null || t === void 0 ? void 0 : t.activeElement); + } + isFocusedInvisibly() { + return this.isFocused() && !this.getLocationRange(); + } + get actions() { + return this.constructor.actions; + } +} +V(_e, "actions", { undo: { test() { + return this.editor.canUndo(); +}, perform() { + return this.editor.undo(); +} }, redo: { test() { + return this.editor.canRedo(); +}, perform() { + return this.editor.redo(); +} }, link: { test() { + return this.editor.canActivateAttribute("href"); +} }, increaseNestingLevel: { test() { + return this.editor.canIncreaseNestingLevel(); +}, perform() { + return this.editor.increaseNestingLevel() && this.render(); +} }, decreaseNestingLevel: { test() { + return this.editor.canDecreaseNestingLevel(); +}, perform() { + return this.editor.decreaseNestingLevel() && this.render(); +} }, attachFiles: { test: () => !0, perform() { + return xn.pickFiles(this.editor.insertFiles); +} } }), _e.proxyMethod("getSelectionManager().setLocationRange"), _e.proxyMethod("getSelectionManager().getLocationRange"); +var Al = Object.freeze({ __proto__: null, AttachmentEditorController: Zr, CompositionController: to, Controller: eo, EditorController: _e, InputController: ri, Level0InputController: mt, Level2InputController: ve, ToolbarController: ao }), yl = Object.freeze({ __proto__: null, MutationObserver: no, SelectionChangeObserver: wr }), El = Object.freeze({ __proto__: null, FileVerificationOperation: so, ImagePreloadOperation: $r }); +xr("trix-toolbar", `%t { + display: block; +} + +%t { + white-space: nowrap; +} + +%t [data-trix-dialog] { + display: none; +} + +%t [data-trix-dialog][data-trix-active] { + display: block; +} + +%t [data-trix-dialog] [data-trix-validate]:invalid { + background-color: #ffdddd; +}`); +class lo extends HTMLElement { + connectedCallback() { + this.innerHTML === "" && (this.innerHTML = Sr.getDefaultHTML()); + } + get editorElements() { + if (this.id) { + var t; + const e = (t = this.ownerDocument) === null || t === void 0 ? void 0 : t.querySelectorAll('trix-editor[toolbar="'.concat(this.id, '"]')); + return Array.from(e); + } + return []; + } + get editorElement() { + const [t] = this.editorElements; + return t; + } +} +let Sl = 0; +const xl = function(s) { + if (!s.hasAttribute("contenteditable")) return s.toggleAttribute("contenteditable", !s.disabled), function(t) { + let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; + return e.times = 1, k(t, e); + }("focus", { onElement: s, withCallback: () => Cl(s) }); +}, Cl = function(s) { + return Ll(s), Tl(); +}, Ll = function(s) { + var t, e; + if ((t = (e = document).queryCommandSupported) !== null && t !== void 0 && t.call(e, "enableObjectResizing")) return document.execCommand("enableObjectResizing", !1, !1), k("mscontrolselect", { onElement: s, preventDefault: !0 }); +}, Tl = function(s) { + var t, e; + if ((t = (e = document).queryCommandSupported) !== null && t !== void 0 && t.call(e, "DefaultParagraphSeparator")) { + const { tagName: i } = G.default; + if (["div", "p"].includes(i)) return document.execCommand("DefaultParagraphSeparator", !1, i); + } +}, Ps = Ce.forcesObjectResizing ? { display: "inline", width: "auto" } : { display: "inline-block", width: "1px" }; +xr("trix-editor", `%t { + display: block; +} + +%t:empty::before { + content: attr(placeholder); + color: graytext; + cursor: text; + pointer-events: none; + white-space: pre-line; +} + +%t a[contenteditable=false] { + cursor: text; +} + +%t img { + max-width: 100%; + height: auto; +} + +%t `.concat(kt, ` figcaption textarea { + resize: none; +} + +%t `).concat(kt, ` figcaption textarea.trix-autoresize-clone { + position: absolute; + left: -9999px; + max-height: 0px; +} + +%t `).concat(kt, ` figcaption[data-trix-placeholder]:empty::before { + content: attr(data-trix-placeholder); + color: graytext; +} + +%t [data-trix-cursor-target] { + display: `).concat(Ps.display, ` !important; + width: `).concat(Ps.width, ` !important; + padding: 0 !important; + margin: 0 !important; + border: none !important; +} + +%t [data-trix-cursor-target=left] { + vertical-align: top !important; + margin-left: -1px !important; +} + +%t [data-trix-cursor-target=right] { + vertical-align: bottom !important; + margin-right: -1px !important; +}`)); +var st = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakMap(), ce = /* @__PURE__ */ new WeakSet(); +class wl { + constructor(t) { + var e, i; + Hr(e = this, i = ce), i.add(e), V(this, "value", ""), Gt(this, st, { writable: !0, value: void 0 }), Gt(this, He, { writable: !0, value: void 0 }), this.element = t, be(this, st, t.attachInternals()), be(this, He, !1); + } + connectedCallback() { + qe(this, ce, $e).call(this); + } + disconnectedCallback() { + } + get form() { + return E(this, st).form; + } + get name() { + return this.element.getAttribute("name"); + } + set name(t) { + this.element.setAttribute("name", t); + } + get labels() { + return E(this, st).labels; + } + get disabled() { + return E(this, He) || this.element.hasAttribute("disabled"); + } + set disabled(t) { + this.element.toggleAttribute("disabled", t); + } + get required() { + return this.element.hasAttribute("required"); + } + set required(t) { + this.element.toggleAttribute("required", t), qe(this, ce, $e).call(this); + } + get validity() { + return E(this, st).validity; + } + get validationMessage() { + return E(this, st).validationMessage; + } + get willValidate() { + return E(this, st).willValidate; + } + formDisabledCallback(t) { + be(this, He, t); + } + setFormValue(t) { + this.value = t, qe(this, ce, $e).call(this), E(this, st).setFormValue(this.element.disabled ? void 0 : this.value); + } + checkValidity() { + return E(this, st).checkValidity(); + } + reportValidity() { + return E(this, st).reportValidity(); + } + setCustomValidity(t) { + qe(this, ce, $e).call(this, t); + } +} +function $e() { + let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; + const { required: t, value: e } = this.element, i = t && !e, n = !!s, r = _("input", { required: t }), o = s || r.validationMessage; + E(this, st).setValidity({ valueMissing: i, customError: n }, o); +} +var Ki = /* @__PURE__ */ new WeakMap(), Gi = /* @__PURE__ */ new WeakMap(), Ji = /* @__PURE__ */ new WeakMap(); +class kl { + constructor(t) { + Gt(this, Ki, { writable: !0, value: void 0 }), Gt(this, Gi, { writable: !0, value: (e) => { + e.defaultPrevented || e.target === this.element.form && this.element.reset(); + } }), Gt(this, Ji, { writable: !0, value: (e) => { + if (e.defaultPrevented || this.element.contains(e.target)) return; + const i = At(e.target, { matchingSelector: "label" }); + i && Array.from(this.labels).includes(i) && this.element.focus(); + } }), this.element = t; + } + connectedCallback() { + be(this, Ki, function(t) { + if (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) return; + const e = function() { + const i = Array.from(t.labels).map((r) => { + if (!r.contains(t)) return r.textContent; + }).filter((r) => r), n = i.join(" "); + return n ? t.setAttribute("aria-label", n) : t.removeAttribute("aria-label"); + }; + return e(), k("focus", { onElement: t, withCallback: e }); + }(this.element)), window.addEventListener("reset", E(this, Gi), !1), window.addEventListener("click", E(this, Ji), !1); + } + disconnectedCallback() { + var t; + (t = E(this, Ki)) === null || t === void 0 || t.destroy(), window.removeEventListener("reset", E(this, Gi), !1), window.removeEventListener("click", E(this, Ji), !1); + } + get labels() { + const t = []; + this.element.id && this.element.ownerDocument && t.push(...Array.from(this.element.ownerDocument.querySelectorAll("label[for='".concat(this.element.id, "']")) || [])); + const e = At(this.element, { matchingSelector: "label" }); + return e && [this.element, null].includes(e.control) && t.push(e), t; + } + get form() { + return console.warn("This browser does not support the .form property for trix-editor elements."), null; + } + get name() { + return console.warn("This browser does not support the .name property for trix-editor elements."), null; + } + set name(t) { + console.warn("This browser does not support the .name property for trix-editor elements."); + } + get disabled() { + return console.warn("This browser does not support the [disabled] attribute for trix-editor elements."), !1; + } + set disabled(t) { + console.warn("This browser does not support the [disabled] attribute for trix-editor elements."); + } + get required() { + return console.warn("This browser does not support the [required] attribute for trix-editor elements."), !1; + } + set required(t) { + console.warn("This browser does not support the [required] attribute for trix-editor elements."); + } + get validity() { + return console.warn("This browser does not support the validity property for trix-editor elements."), null; + } + get validationMessage() { + return console.warn("This browser does not support the validationMessage property for trix-editor elements."), ""; + } + get willValidate() { + return console.warn("This browser does not support the willValidate property for trix-editor elements."), !1; + } + formDisabledCallback(t) { + } + setFormValue(t) { + } + checkValidity() { + return console.warn("This browser does not support checkValidity() for trix-editor elements."), !0; + } + reportValidity() { + return console.warn("This browser does not support reportValidity() for trix-editor elements."), !0; + } + setCustomValidity(t) { + console.warn("This browser does not support setCustomValidity(validationMessage) for trix-editor elements."); + } +} +var R = /* @__PURE__ */ new WeakMap(); +class Ze extends HTMLElement { + constructor() { + super(), Gt(this, R, { writable: !0, value: void 0 }), this.willCreateInput = !0, be(this, R, this.constructor.formAssociated ? new wl(this) : new kl(this)); + } + get trixId() { + return this.hasAttribute("trix-id") ? this.getAttribute("trix-id") : (this.setAttribute("trix-id", ++Sl), this.trixId); + } + get labels() { + return E(this, R).labels; + } + get disabled() { + const { inputElement: t } = this; + return t ? t.disabled : E(this, R).disabled; + } + set disabled(t) { + const { inputElement: e } = this; + e && (e.disabled = t), E(this, R).disabled = t; + } + get required() { + return E(this, R).required; + } + set required(t) { + E(this, R).required = t; + } + get validity() { + return E(this, R).validity; + } + get validationMessage() { + return E(this, R).validationMessage; + } + get willValidate() { + return E(this, R).willValidate; + } + get type() { + return this.localName; + } + get toolbarElement() { + var t; + if (this.hasAttribute("toolbar")) return (t = this.ownerDocument) === null || t === void 0 ? void 0 : t.getElementById(this.getAttribute("toolbar")); + if (this.parentNode) { + const e = "trix-toolbar-".concat(this.trixId); + return this.setAttribute("toolbar", e), this.internalToolbar = _("trix-toolbar", { id: e }), this.parentNode.insertBefore(this.internalToolbar, this), this.internalToolbar; + } + } + get form() { + const { inputElement: t } = this; + return t ? t.form : E(this, R).form; + } + get inputElement() { + var t; + return this.hasAttribute("input") ? (t = this.ownerDocument) === null || t === void 0 ? void 0 : t.getElementById(this.getAttribute("input")) : void 0; + } + get editor() { + var t; + return (t = this.editorController) === null || t === void 0 ? void 0 : t.editor; + } + get name() { + const { inputElement: t } = this; + return t ? t.name : E(this, R).name; + } + set name(t) { + const { inputElement: e } = this; + e ? e.name = t : E(this, R).name = t; + } + get value() { + const { inputElement: t } = this; + return t ? t.value : E(this, R).value; + } + set value(t) { + var e; + this.defaultValue = t, (e = this.editor) === null || e === void 0 || e.loadHTML(this.defaultValue); + } + attributeChangedCallback(t, e, i) { + t === "connected" && this.isConnected && e != null && e !== i && requestAnimationFrame(() => this.reconnect()); + } + notify(t, e) { + if (this.editorController) return me("trix-".concat(t), { onElement: this, attributes: e }); + } + setFormValue(t) { + const { inputElement: e } = this; + e && (e.value = t), E(this, R).setFormValue(t); + } + connectedCallback() { + if (!this.hasAttribute("data-trix-internal")) { + if (xl(this), function(t) { + t.hasAttribute("role") || t.setAttribute("role", "textbox"); + }(this), !this.editorController) { + if (me("trix-before-initialize", { onElement: this }), this.defaultValue = this.inputElement ? this.inputElement.value : this.innerHTML, !this.hasAttribute("input") && this.parentNode && this.willCreateInput) { + const t = "trix-input-".concat(this.trixId); + this.setAttribute("input", t); + const e = _("input", { type: "hidden", id: t }); + this.parentNode.insertBefore(e, this.nextElementSibling); + } + this.editorController = new _e({ editorElement: this, html: this.defaultValue }), requestAnimationFrame(() => me("trix-initialize", { onElement: this })); + } + this.editorController.registerSelectionManager(), E(this, R).connectedCallback(), this.toggleAttribute("connected", !0), function(t) { + !document.querySelector(":focus") && t.hasAttribute("autofocus") && document.querySelector("[autofocus]") === t && t.focus(); + }(this); + } + } + disconnectedCallback() { + var t; + (t = this.editorController) === null || t === void 0 || t.unregisterSelectionManager(), E(this, R).disconnectedCallback(), this.toggleAttribute("connected", !1); + } + reconnect() { + this.removeInternalToolbar(), this.disconnectedCallback(), this.connectedCallback(); + } + removeInternalToolbar() { + var t; + (t = this.internalToolbar) === null || t === void 0 || t.remove(), this.internalToolbar = null; + } + checkValidity() { + return E(this, R).checkValidity(); + } + reportValidity() { + return E(this, R).reportValidity(); + } + setCustomValidity(t) { + E(this, R).setCustomValidity(t); + } + formDisabledCallback(t) { + const { inputElement: e } = this; + e && (e.disabled = t), this.toggleAttribute("contenteditable", !t), E(this, R).formDisabledCallback(t); + } + formResetCallback() { + this.reset(); + } + reset() { + this.value = this.defaultValue; + } +} +V(Ze, "formAssociated", "ElementInternals" in window), V(Ze, "observedAttributes", ["connected"]); +const Fs = { VERSION: Io, config: Le, core: Ja, models: Qr, views: tl, controllers: Al, observers: yl, operations: El, elements: Object.freeze({ __proto__: null, TrixEditorElement: Ze, TrixToolbarElement: lo }), filters: Object.freeze({ __proto__: null, Filter: zr, attachmentGalleryFilter: Kr }) }; +Object.assign(Fs, Qr), window.Trix = Fs, setTimeout(function() { + customElements.get("trix-toolbar") || customElements.define("trix-toolbar", lo), customElements.get("trix-editor") || customElements.define("trix-editor", Ze); +}, 0); +class Il extends HTMLElement { constructor() { super(), this._value = "", this.render(); } @@ -74,13 +5629,13 @@ class ze extends HTMLElement { `; } } -const M = "filter-list-list", Ke = "filter-list-item", We = "filter-list-input", te = "filter-list-searchable"; -var y, R, Z; -class je extends HTMLElement { +const Ue = "filter-list-list", Rl = "filter-list-item", Dl = "filter-list-input", qs = "filter-list-searchable"; +var wt, xe, An; +class Ol extends HTMLElement { constructor() { super(); - I(this, R); - I(this, y, !1); + ie(this, xe); + ie(this, wt, !1); this._items = [], this._url = "", this._filterstart = !1, this._placeholder = "Liste filtern...", this._queryparam = "", this._startparams = null, this.render(); } static get observedAttributes() { @@ -93,23 +5648,23 @@ class je extends HTMLElement { return this._items; } connectedCallback() { - this._url = this.getAttribute("data-url") || "./", this._filterstart = this.getAttribute("data-filterstart") === "true", this._placeholder = this.getAttribute("data-placeholder") || "Liste filtern...", this._queryparam = this.getAttribute("data-queryparam") || "", this._queryparam, this._filterstart && O(this, y, !0), this.addEventListener("input", this.onInput.bind(this)), this.addEventListener("keydown", this.onEnter.bind(this)), this.addEventListener("focusin", this.onGainFocus.bind(this)), this.addEventListener("focusout", this.onLoseFocus.bind(this)); + this._url = this.getAttribute("data-url") || "./", this._filterstart = this.getAttribute("data-filterstart") === "true", this._placeholder = this.getAttribute("data-placeholder") || "Liste filtern...", this._queryparam = this.getAttribute("data-queryparam") || "", this._queryparam, this._filterstart && Me(this, wt, !0), this.addEventListener("input", this.onInput.bind(this)), this.addEventListener("keydown", this.onEnter.bind(this)), this.addEventListener("focusin", this.onGainFocus.bind(this)), this.addEventListener("focusout", this.onLoseFocus.bind(this)); } - attributeChangedCallback(e, i, s) { - e === "data-url" && i !== s && (this._url = s, this.render()), e === "data-filterstart" && i !== s && (this._filterstart = s === "true", this.render()), e === "data-placeholder" && i !== s && (this._placeholder = s, this.render()), e === "data-queryparam" && i !== s && (this._queryparam = s, this.render()); + attributeChangedCallback(e, i, n) { + e === "data-url" && i !== n && (this._url = n, this.render()), e === "data-filterstart" && i !== n && (this._filterstart = n === "true", this.render()), e === "data-placeholder" && i !== n && (this._placeholder = n, this.render()), e === "data-queryparam" && i !== n && (this._queryparam = n, this.render()); } onInput(e) { e.target && e.target.tagName.toLowerCase() === "input" && (this._filter = e.target.value, this.renderList()); } onGainFocus(e) { - e.target && e.target.tagName.toLowerCase() === "input" && (O(this, y, !1), this.renderList()); + e.target && e.target.tagName.toLowerCase() === "input" && (Me(this, wt, !1), this.renderList()); } onLoseFocus(e) { let i = this.querySelector("input"); if (e.target && e.target === i) { if (relatedElement = e.relatedTarget, relatedElement && this.contains(relatedElement)) return; - i.value = "", this._filter = "", this._filterstart && O(this, y, !0), this.renderList(); + i.value = "", this._filter = "", this._filterstart && Me(this, wt, !0), this.renderList(); } } onEnter(e) { @@ -122,10 +5677,10 @@ class je extends HTMLElement { mark() { if (typeof Mark != "function") return; - let e = this.querySelector("#" + M); + let e = this.querySelector("#" + Ue); if (!e) return; - let i = new Mark(e.querySelectorAll("." + te)); + let i = new Mark(e.querySelectorAll("." + qs)); this._filter && i.mark(this._filter, { separateWordSearch: !0 }); @@ -165,17 +5720,17 @@ class je extends HTMLElement { } getLinkText(e) { let i = this.getSearchText(e); - return i === "" ? "" : `${i}`; + return i === "" ? "" : `${i}`; } getURL(e) { if (this._queryparam) { - let i = new URL(window.location), s = new URLSearchParams(i.search); - return s.set(this._queryparam, this.getHREF(e)), s.delete("page"), i.search = s.toString(), i.toString(); + let i = new URL(window.location), n = new URLSearchParams(i.search); + return n.set(this._queryparam, this.getHREF(e)), n.delete("page"), i.search = n.toString(), i.toString(); } return this._url + this.getHREFEncoded(e); } renderList() { - let e = this.querySelector("#" + M); + let e = this.querySelector("#" + Ue); e && (e.outerHTML = this.List()), this.mark(); } render() { @@ -187,7 +5742,7 @@ class je extends HTMLElement { `, htmx && htmx.process(this); } ActiveDot(e) { - return B(this, R, Z).call(this, e), ""; + return Be(this, xe, An).call(this, e), ""; } NoItems(e) { return e.length === 0 ? '
Keine Einträge gefunden
' : ""; @@ -200,7 +5755,7 @@ class je extends HTMLElement { + class="${Dl} w-full placeholder:italic px-2 py-0.5" /> `; @@ -212,20 +5767,20 @@ class je extends HTMLElement { e = this._items.filter((i) => this.getSearchText(i).toLowerCase().startsWith(this._filter.toLowerCase())); else { let i = this._filter.split(" "); - e = this._items.filter((s) => i.every((n) => this.getSearchText(s).toLowerCase().includes(n.toLowerCase()))); + e = this._items.filter((n) => i.every((r) => this.getSearchText(n).toLowerCase().includes(r.toLowerCase()))); } return ` -
+
${e.map( - (i, s) => ` + (i, n) => ` + class="${Rl} block px-2.5 py-0.5 hover:bg-slate-200 no-underline ${n % 2 === 0 ? "bg-stone-100" : "bg-stone-50"}" + ${Be(this, xe, An).call(this, i) ? 'aria-current="page"' : ""}> ${this.ActiveDot(i)} ${this.getLinkText(i)} @@ -236,13 +5791,13 @@ class je extends HTMLElement { `; } } -y = new WeakMap(), R = new WeakSet(), Z = function(e) { +wt = new WeakMap(), xe = new WeakSet(), An = function(e) { if (!e) return !1; let i = this.getHREF(e); return i === "" ? !1 : this._queryparam && (new URLSearchParams(window.location.search).get(this._queryparam) || "") === i ? !0 : !!window.location.href.endsWith(i); }; -class Ge extends HTMLElement { +class Ml extends HTMLElement { constructor() { super(), this.handleScroll = this.handleScroll.bind(this), this.scrollToTop = this.scrollToTop.bind(this); } @@ -278,7 +5833,7 @@ class Ge extends HTMLElement { window.scrollTo({ top: 0, behavior: "smooth" }); } } -class Je extends HTMLElement { +class Bl extends HTMLElement { static get observedAttributes() { return ["position", "timeout"]; } @@ -379,7 +5934,7 @@ class Je extends HTMLElement { } } } -class Qe extends HTMLElement { +class Nl extends HTMLElement { constructor() { super(), this.overlay = null, this._others = null, this._thisindex = -1, this._preview = null, this._description = null, this._imageURL = "", this._hideDLButton = !1; } @@ -439,8 +5994,8 @@ class Qe extends HTMLElement { const e = this.overlay.querySelector("#nextbtn"); e && e.addEventListener("click", this.next.bind(this)); const i = this.overlay.querySelector("#prevbtn"); - i && i.addEventListener("click", this.prev.bind(this)), this.overlay.addEventListener("click", (s) => { - s.target === this.overlay && this.hideOverlay(); + i && i.addEventListener("click", this.prev.bind(this)), this.overlay.addEventListener("click", (n) => { + n.target === this.overlay && this.hideOverlay(); }), document.addEventListener("keydown", this.Keys.bind(this), { once: !0 }), document.body.appendChild(this.overlay); } descriptionImgClass() { @@ -487,7 +6042,7 @@ class Qe extends HTMLElement { this.overlay.parentNode.removeChild(this.overlay), this.overlay = null; } } -class Ye extends HTMLElement { +class Pl extends HTMLElement { static get observedAttributes() { } constructor() { @@ -555,12 +6110,12 @@ class Ye extends HTMLElement { showAll() { this._showall = !0, this.shown = -1, this.disable(), this._contents.forEach((t, e) => { t.classList.remove("hidden"); - let i = this._headings[e], s = i.querySelectorAll(".show-opened"); - for (let a of s) - a.classList.add("hidden"); - let n = i.querySelectorAll(".show-closed"); - for (let a of n) - a.classList.add("hidden"); + let i = this._headings[e], n = i.querySelectorAll(".show-opened"); + for (let o of n) + o.classList.add("hidden"); + let r = i.querySelectorAll(".show-closed"); + for (let o of r) + o.classList.add("hidden"); }); } default() { @@ -577,11 +6132,11 @@ class Ye extends HTMLElement { } _hideAllDep(t, e) { const i = t.querySelectorAll(".show-closed"); - for (let n of i) - e ? n.classList.add("hidden") : n.classList.remove("hidden"); - const s = Array.from(t.querySelectorAll(".show-opened")); - for (let n of s) - e ? n.classList.remove("hidden") : n.classList.add("hidden"); + for (let r of i) + e ? r.classList.add("hidden") : r.classList.remove("hidden"); + const n = Array.from(t.querySelectorAll(".show-opened")); + for (let r of n) + e ? r.classList.remove("hidden") : r.classList.add("hidden"); } handleTabClick(t) { if (!t.target) { @@ -605,7 +6160,7 @@ class Ye extends HTMLElement { return null; } } -class k extends HTMLElement { +class Ae extends HTMLElement { static get observedAttributes() { return ["data-text", "data-abbrevmap"]; } @@ -668,7 +6223,7 @@ class k extends HTMLElement { }; } constructor() { - super(), this._abbrevMap = k.defaultAbbrevMap; + super(), this._abbrevMap = Ae.defaultAbbrevMap; } connectedCallback() { this.render(); @@ -678,13 +6233,13 @@ class k extends HTMLElement { } _parseAndSetAbbrevMap(t) { if (!t) { - this._abbrevMap = k.defaultAbbrevMap; + this._abbrevMap = Ae.defaultAbbrevMap; return; } try { this._abbrevMap = JSON.parse(t); } catch { - this._abbrevMap = k.defaultAbbrevMap; + this._abbrevMap = Ae.defaultAbbrevMap; } } setAbbrevMap(t) { @@ -700,41 +6255,41 @@ class k extends HTMLElement { this.innerHTML = this.transformText(this.text, this._abbrevMap); } transformText(t, e) { - let i = "", s = 0; - for (; s < t.length; ) { - if (s > 0 && !this.isSpaceOrPunct(t[s - 1])) { - i += t[s], s++; + let i = "", n = 0; + for (; n < t.length; ) { + if (n > 0 && !this.isSpaceOrPunct(t[n - 1])) { + i += t[n], n++; continue; } - const n = this.findLongestAbbrevAt(t, s, e); - if (n) { - const { match: a, meaning: l } = n; + const r = this.findLongestAbbrevAt(t, n, e); + if (r) { + const { match: o, meaning: a } = r; i += `
- ${l} + ${a}
- ${a} + ${o}
- `, s += a.length; + `, n += o.length; } else - i += t[s], s++; + i += t[n], n++; } return i; } findLongestAbbrevAt(t, e, i) { - let s = null, n = 0; - for (const a of Object.keys(i)) - t.startsWith(a, e) && a.length > n && (s = a, n = a.length); - return s ? { match: s, meaning: i[s] } : null; + let n = null, r = 0; + for (const o of Object.keys(i)) + t.startsWith(o, e) && o.length > r && (n = o, r = o.length); + return n ? { match: n, meaning: i[n] } : null; } isSpaceOrPunct(t) { return /\s|[.,;:!?]/.test(t); } } -class Xe extends HTMLElement { +class Fl extends HTMLElement { constructor() { super(); } @@ -752,16 +6307,16 @@ class Xe extends HTMLElement { } } } -var P; -class Ze extends HTMLElement { +var ti; +class ql extends HTMLElement { constructor() { super(); - I(this, P, 176); + ie(this, ti, 176); this._images = []; } connectedCallback() { this._images = Array.from(this.querySelectorAll(".primages")), this.calculateShownImages(); - const e = new ResizeObserver((i, s) => { + const e = new ResizeObserver((i, n) => { this.calculateShownImages(); }); this._resizeObserver = e, e.observe(this); @@ -772,17 +6327,17 @@ class Ze extends HTMLElement { calculateShownImages() { const e = this.getBoundingClientRect(); console.log(e); - const i = Math.floor(e.width / (V(this, P) + 10)); - for (let s = 0; s < this._images.length; s++) - s < i - 1 ? this._images[s].classList.remove("hidden") : this._images[s].classList.add("hidden"); + const i = Math.floor(e.width / (Ei(this, ti) + 10)); + for (let n = 0; n < this._images.length; n++) + n < i - 1 ? this._images[n].classList.remove("hidden") : this._images[n].classList.add("hidden"); } } -P = new WeakMap(); -const et = "msr-component-wrapper", ie = "msr-selected-items-container", se = "msr-placeholder-no-selection-text", tt = "msr-selected-item-pill", it = "msr-selected-item-text", st = "msr-item-name", nt = "msr-item-additional-data", at = "msr-selected-item-role", ne = "msr-selected-item-delete-btn", rt = "msr-controls-area", ae = "msr-pre-add-button", re = "msr-input-area-wrapper", $ = "msr-input-area-default-border", U = "msr-input-area-staged", le = "msr-staging-area-container", lt = "msr-staged-item-pill", ot = "msr-staged-item-text", z = "msr-staged-role-select", oe = "msr-staged-cancel-btn", de = "msr-text-input", he = "msr-add-button", ce = "msr-options-list", ue = "msr-option-item", dt = "msr-option-item-name", ht = "msr-option-item-detail", me = "msr-option-item-highlighted", K = "msr-hidden-select", ct = "msr-state-no-selection", ut = "msr-state-has-selection", mt = "msr-state-list-open", _t = "msr-state-item-staged"; -class Be extends HTMLElement { +ti = new WeakMap(); +const Hl = "msr-component-wrapper", Hs = "msr-selected-items-container", $s = "msr-placeholder-no-selection-text", $l = "msr-selected-item-pill", Ul = "msr-selected-item-text", jl = "msr-item-name", Vl = "msr-item-additional-data", Wl = "msr-selected-item-role", Us = "msr-selected-item-delete-btn", zl = "msr-controls-area", js = "msr-pre-add-button", Vs = "msr-input-area-wrapper", je = "msr-input-area-default-border", Yi = "msr-input-area-staged", Ws = "msr-staging-area-container", Kl = "msr-staged-item-pill", Gl = "msr-staged-item-text", Xi = "msr-staged-role-select", zs = "msr-staged-cancel-btn", Ks = "msr-text-input", Gs = "msr-add-button", Js = "msr-options-list", Ys = "msr-option-item", Jl = "msr-option-item-name", Yl = "msr-option-item-detail", Xs = "msr-option-item-highlighted", Qi = "msr-hidden-select", Xl = "msr-state-no-selection", Ql = "msr-state-has-selection", Zl = "msr-state-list-open", tc = "msr-state-item-staged"; +class co extends HTMLElement { constructor() { super(); - C(this, "_blurTimeout", null); + ee(this, "_blurTimeout", null); this.internals_ = this.attachInternals(), this._value = [], this._stagedItem = null, this._showAddButton = !0, this._placeholderNoSelection = "Keine Elemente ausgewählt", this._placeholderSearch = "Elemente suchen...", this._placeholderRoleSelect = "Rolle auswählen...", this._options = [], this._roles = [ "Leitung", "Unterstützung", @@ -831,50 +6386,50 @@ class Be extends HTMLElement { const i = String(e || "Rolle auswählen..."); this._placeholderRoleSelect !== i && (this._placeholderRoleSelect = i, this.setAttribute("placeholder-role-select", i), this._stagedItem && this.stagedItemPillContainer && this._renderStagedPillOrInput()); } - attributeChangedCallback(e, i, s) { - if (i !== s) + attributeChangedCallback(e, i, n) { + if (i !== n) switch (e) { case "disabled": this.disabledCallback(this.hasAttribute("disabled")); break; case "name": - this.hiddenSelect && (this.hiddenSelect.name = s); + this.hiddenSelect && (this.hiddenSelect.name = n); break; case "value": break; case "show-add-button": - this.showAddButton = s; + this.showAddButton = n; break; case "placeholder-no-selection": - this.placeholderNoSelection = s; + this.placeholderNoSelection = n; break; case "placeholder-search": - this.placeholderSearch = s; + this.placeholderSearch = n; break; case "placeholder-role-select": - this.placeholderRoleSelect = s; + this.placeholderRoleSelect = n; break; } } _setupTemplates() { this.optionTemplate = document.createElement("template"), this.optionTemplate.innerHTML = ` -
  • - - +
  • + +
  • `, this.selectedItemTemplate = document.createElement("template"), this.selectedItemTemplate.innerHTML = ` - - - + + + `, this.stagedPlacePillTemplate = document.createElement("template"), this.stagedPlacePillTemplate.innerHTML = ` - - + + `, this.stagedCancelBtnTemplate = document.createElement("template"), this.stagedCancelBtnTemplate.innerHTML = ` - + `, this.stagedRoleSelectTemplate = document.createElement("template"), this.stagedRoleSelectTemplate.innerHTML = ` - `; } @@ -885,22 +6440,22 @@ class Be extends HTMLElement { return this._options.find((i) => i.id === e); } _getAvailableRolesForItem(e) { - const i = this._value.filter((s) => s.itemId === e).map((s) => s.role); - return this._roles.filter((s) => !i.includes(s)); + const i = this._value.filter((n) => n.itemId === e).map((n) => n.role); + return this._roles.filter((n) => !i.includes(n)); } setRoles(e) { if (Array.isArray(e) && e.every((i) => typeof i == "string")) { this._roles = [...e], this._stagedItem && this._stagedItem.item && (this._getAvailableRolesForItem(this._stagedItem.item.id).includes(this._stagedItem.currentRole) || (this._stagedItem.currentRole = ""), this._renderStagedPillOrInput(), this._updateAddButtonState()); - const i = this._value.filter((s) => this._roles.includes(s.role)); - i.length !== this._value.length && (this.value = i.map((s) => `${s.itemId},${s.role}`)); + const i = this._value.filter((n) => this._roles.includes(n.role)); + i.length !== this._value.length && (this.value = i.map((n) => `${n.itemId},${n.role}`)); } else console.error("setRoles expects an array of strings."); } setOptions(e) { if (Array.isArray(e) && e.every((i) => i && typeof i.id == "string" && typeof i.name == "string")) { this._options = [...e]; - const i = this._value.filter((s) => this._getItemById(s.itemId)); - i.length !== this._value.length && (this.value = i.map((s) => `${s.itemId},${s.role}`)), this._stagedItem && this._stagedItem.item && !this._getItemById(this._stagedItem.item.id) && this._handleCancelStagedItem(), this._filteredOptions = [], this._highlightedIndex = -1, this.inputElement && this.inputElement.value ? this._handleInput({ target: this.inputElement }) : this._hideOptionsList(); + const i = this._value.filter((n) => this._getItemById(n.itemId)); + i.length !== this._value.length && (this.value = i.map((n) => `${n.itemId},${n.role}`)), this._stagedItem && this._stagedItem.item && !this._getItemById(this._stagedItem.item.id) && this._handleCancelStagedItem(), this._filteredOptions = [], this._highlightedIndex = -1, this.inputElement && this.inputElement.value ? this._handleInput({ target: this.inputElement }) : this._hideOptionsList(); } else console.error("setOptions expects an array of objects with id and name properties."); } @@ -909,22 +6464,22 @@ class Be extends HTMLElement { } set value(e) { if (Array.isArray(e)) { - const i = e.map((a) => { - if (typeof a == "string") { - const l = a.split(","); - if (l.length === 2) { - const o = l[0].trim(), d = l[1].trim(); - if (this._getItemById(o) && this._roles.includes(d)) - return { itemId: o, role: d, instanceId: crypto.randomUUID() }; + const i = e.map((o) => { + if (typeof o == "string") { + const a = o.split(","); + if (a.length === 2) { + const c = a[0].trim(), h = a[1].trim(); + if (this._getItemById(c) && this._roles.includes(h)) + return { itemId: c, role: h, instanceId: crypto.randomUUID() }; } } return null; - }).filter((a) => a !== null), s = [], n = /* @__PURE__ */ new Set(); - for (const a of i) { - const l = `${a.itemId},${a.role}`; - n.has(l) || (s.push(a), n.add(l)); + }).filter((o) => o !== null), n = [], r = /* @__PURE__ */ new Set(); + for (const o of i) { + const a = `${o.itemId},${o.role}`; + r.has(a) || (n.push(o), r.add(a)); } - this._value = s; + this._value = n; } else this._value = []; this._updateFormValue(), this.selectedItemsContainer && this._renderSelectedItems(), this._updateRootElementStateClasses(); @@ -936,7 +6491,7 @@ class Be extends HTMLElement { this.setAttribute("name", e), this.hiddenSelect && (this.hiddenSelect.name = e); } connectedCallback() { - if (this.placeholderNoSelection = this.getAttribute("placeholder-no-selection") || this._placeholderNoSelection, this.placeholderSearch = this.getAttribute("placeholder-search") || this._placeholderSearch, this.placeholderRoleSelect = this.getAttribute("placeholder-role-select") || this._placeholderRoleSelect, this._render(), this.inputAreaWrapper = this.querySelector(`.${re}`), this.inputElement = this.querySelector(`.${de}`), this.stagedItemPillContainer = this.querySelector(`.${le}`), this.optionsListElement = this.querySelector(`.${ce}`), this.selectedItemsContainer = this.querySelector(`.${ie}`), this.addButtonElement = this.querySelector(`.${he}`), this.preAddButtonElement = this.querySelector(`.${ae}`), this.hiddenSelect = this.querySelector(`.${K}`), this.name && this.hiddenSelect && (this.hiddenSelect.name = this.name), this.hasAttribute("show-add-button") ? this.showAddButton = this.getAttribute("show-add-button") : this.setAttribute("show-add-button", String(this._showAddButton)), this.inputElement && (this.inputElement.placeholder = this.placeholderSearch), this.inputElement.addEventListener("input", this._handleInput), this.inputElement.addEventListener("keydown", this._handleInputKeyDown), this.inputElement.addEventListener("focus", this._handleFocus), this.inputElement.addEventListener("blur", this._handleBlur), this.optionsListElement.addEventListener("mousedown", this._handleOptionMouseDown), this.optionsListElement.addEventListener("click", this._handleOptionClick), this.addButtonElement.addEventListener("click", this._handleAddButtonClick), this.addEventListener("keydown", this._handleKeyDown), this._renderStagedPillOrInput(), this._updateAddButtonState(), this._updatePreAddButtonVisibility(), this._updateRootElementStateClasses(), this.hasAttribute("value")) { + if (this.placeholderNoSelection = this.getAttribute("placeholder-no-selection") || this._placeholderNoSelection, this.placeholderSearch = this.getAttribute("placeholder-search") || this._placeholderSearch, this.placeholderRoleSelect = this.getAttribute("placeholder-role-select") || this._placeholderRoleSelect, this._render(), this.inputAreaWrapper = this.querySelector(`.${Vs}`), this.inputElement = this.querySelector(`.${Ks}`), this.stagedItemPillContainer = this.querySelector(`.${Ws}`), this.optionsListElement = this.querySelector(`.${Js}`), this.selectedItemsContainer = this.querySelector(`.${Hs}`), this.addButtonElement = this.querySelector(`.${Gs}`), this.preAddButtonElement = this.querySelector(`.${js}`), this.hiddenSelect = this.querySelector(`.${Qi}`), this.name && this.hiddenSelect && (this.hiddenSelect.name = this.name), this.hasAttribute("show-add-button") ? this.showAddButton = this.getAttribute("show-add-button") : this.setAttribute("show-add-button", String(this._showAddButton)), this.inputElement && (this.inputElement.placeholder = this.placeholderSearch), this.inputElement.addEventListener("input", this._handleInput), this.inputElement.addEventListener("keydown", this._handleInputKeyDown), this.inputElement.addEventListener("focus", this._handleFocus), this.inputElement.addEventListener("blur", this._handleBlur), this.optionsListElement.addEventListener("mousedown", this._handleOptionMouseDown), this.optionsListElement.addEventListener("click", this._handleOptionClick), this.addButtonElement.addEventListener("click", this._handleAddButtonClick), this.addEventListener("keydown", this._handleKeyDown), this._renderStagedPillOrInput(), this._updateAddButtonState(), this._updatePreAddButtonVisibility(), this._updateRootElementStateClasses(), this.hasAttribute("value")) { const e = this.getAttribute("value"); try { const i = JSON.parse(e); @@ -944,10 +6499,10 @@ class Be extends HTMLElement { } catch (i) { if (console.warn("Failed to parse value attribute as JSON array. Attribute was:", e, i), e.startsWith("[") && e.endsWith("]")) try { - const s = e.slice(1, -1).split(",").map((n) => n.replace(/"/g, "").trim()).filter((n) => n); - this.value = s; - } catch (s) { - console.error("Manual parse of value attribute also failed:", e, s), this.value = []; + const n = e.slice(1, -1).split(",").map((r) => r.replace(/"/g, "").trim()).filter((r) => r); + this.value = n; + } catch (n) { + console.error("Manual parse of value attribute also failed:", e, n), this.value = []; } else e.includes(",") ? this.value = [e] : this.value = []; } @@ -964,102 +6519,102 @@ class Be extends HTMLElement { this.disabledCallback(e); } disabledCallback(e) { - this.inputElement && (this.inputElement.disabled = e), this.classList.toggle("pointer-events-none", e), this.querySelectorAll(`.${ne}`).forEach( - (s) => s.disabled = e + this.inputElement && (this.inputElement.disabled = e), this.classList.toggle("pointer-events-none", e), this.querySelectorAll(`.${Us}`).forEach( + (n) => n.disabled = e ); - const i = this.querySelector(`.${z}`); + const i = this.querySelector(`.${Xi}`); i && (i.disabled = e), this.hiddenSelect && (this.hiddenSelect.disabled = e), this._updateAddButtonState(), this._updatePreAddButtonVisibility(); } formResetCallback() { this.value = [], this._stagedItem = null, this._renderStagedPillOrInput(), this._hideOptionsList(), this.inputElement && (this.inputElement.value = ""), this._updateRootElementStateClasses(); } formStateRestoreCallback(e, i) { - Array.isArray(e) && e.every((s) => typeof s == "string" && s.includes(",")) ? this.value = e : this.value = [], this._updateRootElementStateClasses(), this._updatePreAddButtonVisibility(); + Array.isArray(e) && e.every((n) => typeof n == "string" && n.includes(",")) ? this.value = e : this.value = [], this._updateRootElementStateClasses(), this._updatePreAddButtonVisibility(); } _synchronizeHiddenSelect() { this.hiddenSelect && (this.hiddenSelect.innerHTML = "", this._value.forEach((e) => { - var s; + var n; const i = document.createElement("option"); - i.value = `${e.itemId},${e.role}`, i.textContent = `${((s = this._getItemById(e.itemId)) == null ? void 0 : s.name) || e.itemId} (${e.role})`, i.selected = !0, this.hiddenSelect.appendChild(i); + i.value = `${e.itemId},${e.role}`, i.textContent = `${((n = this._getItemById(e.itemId)) == null ? void 0 : n.name) || e.itemId} (${e.role})`, i.selected = !0, this.hiddenSelect.appendChild(i); })); } _updateFormValue() { this.internals_.setFormValue(null), this._synchronizeHiddenSelect(); } _updateRootElementStateClasses() { - this.classList.toggle(ct, this._value.length === 0), this.classList.toggle(ut, this._value.length > 0), this.classList.toggle(mt, this._isOptionsListVisible), this.classList.toggle(_t, !!this._stagedItem); + this.classList.toggle(Xl, this._value.length === 0), this.classList.toggle(Ql, this._value.length > 0), this.classList.toggle(Zl, this._isOptionsListVisible), this.classList.toggle(tc, !!this._stagedItem); } _render() { const e = this.id || `msr-${crypto.randomUUID().slice(0, 8)}`; this.id || this.setAttribute("id", e), this.innerHTML = ` -
    -
    - ${this._value.length === 0 ? `${this.placeholderNoSelection}` : ""} +
    +
    + ${this._value.length === 0 ? `${this.placeholderNoSelection}` : ""}
    -
    -
    - +
    +
    +
    - +
    - - + +
    `; } _createStagedItemPillElement(e) { - const s = this.stagedPlacePillTemplate.content.cloneNode(!0).firstElementChild; - return s.querySelector('[data-ref="nameEl"]').textContent = e.name, s; + const n = this.stagedPlacePillTemplate.content.cloneNode(!0).firstElementChild; + return n.querySelector('[data-ref="nameEl"]').textContent = e.name, n; } _createStagedRoleSelectElement(e, i) { - const n = this.stagedRoleSelectTemplate.content.cloneNode(!0).firstElementChild; - let a = ``; - return e.length === 0 && !this._roles.includes(i) ? (a += "", n.disabled = !0) : (e.forEach((l) => { - a += ``; - }), n.disabled = e.length === 0 && i === ""), n.innerHTML = a, n.addEventListener("change", this._handleStagedRoleChange), n; + const r = this.stagedRoleSelectTemplate.content.cloneNode(!0).firstElementChild; + let o = ``; + return e.length === 0 && !this._roles.includes(i) ? (o += "", r.disabled = !0) : (e.forEach((a) => { + o += ``; + }), r.disabled = e.length === 0 && i === ""), r.innerHTML = o, r.addEventListener("change", this._handleStagedRoleChange), r; } _createStagedCancelButtonElement(e) { - const s = this.stagedCancelBtnTemplate.content.cloneNode(!0).firstElementChild; - return s.setAttribute("aria-label", `Auswahl von ${e} abbrechen`), s.addEventListener("click", this._handleCancelStagedItem), s; + const n = this.stagedCancelBtnTemplate.content.cloneNode(!0).firstElementChild; + return n.setAttribute("aria-label", `Auswahl von ${e} abbrechen`), n.addEventListener("click", this._handleCancelStagedItem), n; } _renderStagedPillOrInput() { if (!(!this.stagedItemPillContainer || !this.inputElement || !this.inputAreaWrapper)) { if (this.stagedItemPillContainer.innerHTML = "", this._stagedItem && this._stagedItem.item) { - this.inputAreaWrapper.classList.remove($), this.inputAreaWrapper.classList.add(U); + this.inputAreaWrapper.classList.remove(je), this.inputAreaWrapper.classList.add(Yi); const e = this._createStagedItemPillElement(this._stagedItem.item); this.stagedItemPillContainer.appendChild(e); - const i = this._getAvailableRolesForItem(this._stagedItem.item.id), s = this._createStagedRoleSelectElement( + const i = this._getAvailableRolesForItem(this._stagedItem.item.id), n = this._createStagedRoleSelectElement( i, this._stagedItem.currentRole ); - this.stagedItemPillContainer.appendChild(s); - const n = this._createStagedCancelButtonElement(this._stagedItem.item.name); - this.stagedItemPillContainer.appendChild(n), this.inputElement.classList.add("hidden"), this.inputElement.value = "", this.inputElement.removeAttribute("aria-activedescendant"), this.inputElement.setAttribute("aria-expanded", "false"); + this.stagedItemPillContainer.appendChild(n); + const r = this._createStagedCancelButtonElement(this._stagedItem.item.name); + this.stagedItemPillContainer.appendChild(r), this.inputElement.classList.add("hidden"), this.inputElement.value = "", this.inputElement.removeAttribute("aria-activedescendant"), this.inputElement.setAttribute("aria-expanded", "false"); } else - this.inputAreaWrapper.classList.add($), this.inputAreaWrapper.classList.remove(U), this.inputElement.classList.remove("hidden"); + this.inputAreaWrapper.classList.add(je), this.inputAreaWrapper.classList.remove(Yi), this.inputElement.classList.remove("hidden"); this._updateAddButtonState(), this._updatePreAddButtonVisibility(), this._updateRootElementStateClasses(); } } _updatePreAddButtonVisibility() { if (!this.preAddButtonElement) return; - const e = this.hasAttribute("disabled"), i = !this._stagedItem, s = this.showAddButton && i && !e; - this.preAddButtonElement.classList.toggle("hidden", !s), this.preAddButtonElement.disabled = e; + const e = this.hasAttribute("disabled"), i = !this._stagedItem, n = this.showAddButton && i && !e; + this.preAddButtonElement.classList.toggle("hidden", !n), this.preAddButtonElement.disabled = e; } _handleStagedRoleChange(e) { this._stagedItem && (this._stagedItem.currentRole = e.target.value, this._updateAddButtonState()); @@ -1070,41 +6625,41 @@ class Be extends HTMLElement { _createSelectedItemElement(e) { const i = this._getItemById(e.itemId); if (!i) return null; - const n = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, a = n.querySelector('[data-ref="textEl"]'); - let l = `${i.name}`, o = i.additional_data ? ` (${i.additional_data})` : "", d = ` ${e.role}`; - a.innerHTML = `${l}${o}${d}`; - const c = n.querySelector('[data-ref="deleteBtn"]'); - return c.setAttribute("aria-label", `Entferne ${i.name} als ${e.role}`), c.dataset.instanceId = e.instanceId, c.disabled = this.hasAttribute("disabled"), c.addEventListener("click", (h) => { - h.stopPropagation(), this._handleDeleteSelectedItem(e.instanceId); - }), n; + const r = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, o = r.querySelector('[data-ref="textEl"]'); + let a = `${i.name}`, c = i.additional_data ? ` (${i.additional_data})` : "", h = ` ${e.role}`; + o.innerHTML = `${a}${c}${h}`; + const d = r.querySelector('[data-ref="deleteBtn"]'); + return d.setAttribute("aria-label", `Entferne ${i.name} als ${e.role}`), d.dataset.instanceId = e.instanceId, d.disabled = this.hasAttribute("disabled"), d.addEventListener("click", (m) => { + m.stopPropagation(), this._handleDeleteSelectedItem(e.instanceId); + }), r; } _renderSelectedItems() { - this.selectedItemsContainer && (this.selectedItemsContainer.innerHTML = "", this._value.length === 0 ? this.selectedItemsContainer.innerHTML = `${this.placeholderNoSelection}` : this._value.forEach((e) => { + this.selectedItemsContainer && (this.selectedItemsContainer.innerHTML = "", this._value.length === 0 ? this.selectedItemsContainer.innerHTML = `${this.placeholderNoSelection}` : this._value.forEach((e) => { const i = this._createSelectedItemElement(e); i && this.selectedItemsContainer.appendChild(i); }), this._updateRootElementStateClasses()); } _updateAddButtonState() { if (this.addButtonElement) { - const e = this.hasAttribute("disabled"), i = this._stagedItem && this._stagedItem.currentRole && this._roles.includes(this._stagedItem.currentRole), s = !this._stagedItem || !i || e; - this.addButtonElement.classList.toggle("hidden", s), this.addButtonElement.disabled = s; + const e = this.hasAttribute("disabled"), i = this._stagedItem && this._stagedItem.currentRole && this._roles.includes(this._stagedItem.currentRole), n = !this._stagedItem || !i || e; + this.addButtonElement.classList.toggle("hidden", n), this.addButtonElement.disabled = n; } } _createOptionElement(e, i) { - const n = this.optionTemplate.content.cloneNode(!0).firstElementChild; - return n.querySelector('[data-ref="nameEl"]').textContent = e.name, n.querySelector('[data-ref="detailEl"]').textContent = e.additional_data ? `(${e.additional_data})` : "", n.dataset.id = e.id, n.setAttribute("aria-selected", String(i === this._highlightedIndex)), n.id = `${this.id || "msr"}-option-${e.id}`, i === this._highlightedIndex && n.classList.add(me), n; + const r = this.optionTemplate.content.cloneNode(!0).firstElementChild; + return r.querySelector('[data-ref="nameEl"]').textContent = e.name, r.querySelector('[data-ref="detailEl"]').textContent = e.additional_data ? `(${e.additional_data})` : "", r.dataset.id = e.id, r.setAttribute("aria-selected", String(i === this._highlightedIndex)), r.id = `${this.id || "msr"}-option-${e.id}`, i === this._highlightedIndex && r.classList.add(Xs), r; } _renderOptionsList() { if (!(!this.optionsListElement || !this.inputElement)) { if (this.optionsListElement.innerHTML = "", this._filteredOptions.length === 0 || !this._isOptionsListVisible) this.optionsListElement.classList.add("hidden"), this.inputElement.setAttribute("aria-expanded", "false"), this.inputElement.removeAttribute("aria-activedescendant"), this.inputElement.removeAttribute("aria-controls"); else { - this.optionsListElement.classList.remove("hidden"), this.inputElement.setAttribute("aria-expanded", "true"), this.inputElement.setAttribute("aria-controls", this.optionsListElement.id), this._filteredOptions.forEach((i, s) => { - const n = this._createOptionElement(i, s); - this.optionsListElement.appendChild(n); + this.optionsListElement.classList.remove("hidden"), this.inputElement.setAttribute("aria-expanded", "true"), this.inputElement.setAttribute("aria-controls", this.optionsListElement.id), this._filteredOptions.forEach((i, n) => { + const r = this._createOptionElement(i, n); + this.optionsListElement.appendChild(r); }); const e = this.optionsListElement.querySelector( - `.${me}` + `.${Xs}` ); e ? (e.scrollIntoView({ block: "nearest" }), this.inputElement.setAttribute("aria-activedescendant", e.id)) : this.inputElement.removeAttribute("aria-activedescendant"); } @@ -1115,10 +6670,10 @@ class Be extends HTMLElement { if (this._getAvailableRolesForItem(e.id).length === 0) return; this._stagedItem = { item: e, currentRole: "" }, this.inputElement && (this.inputElement.value = "", this.inputElement.setAttribute("aria-expanded", "false"), this.inputElement.removeAttribute("aria-activedescendant")), this._renderStagedPillOrInput(), this._hideOptionsList(); - const s = this.stagedItemPillContainer.querySelector( - `.${z}` + const n = this.stagedItemPillContainer.querySelector( + `.${Xi}` ); - s && !s.disabled ? s.focus() : this.addButtonElement && !this.addButtonElement.disabled && this.addButtonElement.focus(); + n && !n.disabled ? n.focus() : this.addButtonElement && !this.addButtonElement.disabled && this.addButtonElement.focus(); } _handleAddButtonClick() { if (!this.hasAttribute("disabled") && this._stagedItem && this._stagedItem.item && this._stagedItem.currentRole && this._roles.includes(this._stagedItem.currentRole)) { @@ -1128,7 +6683,7 @@ class Be extends HTMLElement { instanceId: crypto.randomUUID() }; if (this._value.find( - (s) => s.itemId === e.itemId && s.role === e.role + (n) => n.itemId === e.itemId && n.role === e.role )) { this._handleCancelStagedItem(); return; @@ -1143,8 +6698,8 @@ class Be extends HTMLElement { if (i.length === 0) this._filteredOptions = [], this._isOptionsListVisible = !1; else { - const s = i.toLowerCase(); - this._filteredOptions = this._options.filter((n) => this._getAvailableRolesForItem(n.id).length === 0 || this._stagedItem && this._stagedItem.item.id === n.id ? !1 : n.name.toLowerCase().includes(s) || n.additional_data && n.additional_data.toLowerCase().includes(s)), this._isOptionsListVisible = this._filteredOptions.length > 0; + const n = i.toLowerCase(); + this._filteredOptions = this._options.filter((r) => this._getAvailableRolesForItem(r.id).length === 0 || this._stagedItem && this._stagedItem.item.id === r.id ? !1 : r.name.toLowerCase().includes(n) || r.additional_data && r.additional_data.toLowerCase().includes(n)), this._isOptionsListVisible = this._filteredOptions.length > 0; } this._highlightedIndex = this._filteredOptions.length > 0 ? 0 : -1, this._renderOptionsList(); } @@ -1152,10 +6707,10 @@ class Be extends HTMLElement { var i; if (!this.hasAttribute("disabled")) { if (e.key === "Enter" && this._stagedItem && this._stagedItem.item) { - const s = document.activeElement, n = (i = this.stagedItemPillContainer) == null ? void 0 : i.querySelector( - `.${oe}` + const n = document.activeElement, r = (i = this.stagedItemPillContainer) == null ? void 0 : i.querySelector( + `.${zs}` ); - if (s === n) { + if (n === r) { e.preventDefault(), this._handleCancelStagedItem(e); return; } else if (this._stagedItem.currentRole && this._roles.includes(this._stagedItem.currentRole)) { @@ -1191,7 +6746,7 @@ class Be extends HTMLElement { } _handleFocus() { if (!(this.hasAttribute("disabled") || this.inputElement && this.inputElement.disabled || this._stagedItem)) { - if (!this._stagedItem && this.inputAreaWrapper && (this.inputAreaWrapper.classList.add($), this.inputAreaWrapper.classList.remove(U)), this.inputElement && this.inputElement.value.length > 0) { + if (!this._stagedItem && this.inputAreaWrapper && (this.inputAreaWrapper.classList.add(je), this.inputAreaWrapper.classList.remove(Yi)), this.inputElement && this.inputElement.value.length > 0) { const e = this.inputElement.value.toLowerCase(); this._filteredOptions = this._options.filter((i) => this._getAvailableRolesForItem(i.id).length === 0 ? !1 : i.name.toLowerCase().includes(e) || i.additional_data && i.additional_data.toLowerCase().includes(e)), this._filteredOptions.length > 0 ? (this._isOptionsListVisible = !0, this._highlightedIndex = 0, this._renderOptionsList()) : this._hideOptionsList(); } else @@ -1210,22 +6765,22 @@ class Be extends HTMLElement { } _handleOptionClick(e) { if (this.hasAttribute("disabled")) return; - const i = e.target.closest(`li[data-id].${ue}`); + const i = e.target.closest(`li[data-id].${Ys}`); if (i) { - const s = i.dataset.id, n = this._filteredOptions.find((a) => a.id === s); - n && this._stageItem(n); + const n = i.dataset.id, r = this._filteredOptions.find((o) => o.id === n); + r && this._stageItem(r); } } _handleDeleteSelectedItem(e) { this.hasAttribute("disabled") || (this._value = this._value.filter((i) => i.instanceId !== e), this._updateFormValue(), this._renderSelectedItems(), this._stagedItem && this._stagedItem.item && this._renderStagedPillOrInput(), this.inputElement && this.inputElement.focus(), this._updatePreAddButtonVisibility()); } } -C(Be, "formAssociated", !0); -const pt = "mss-component-wrapper", _e = "mss-selected-items-container", ft = "mss-selected-item-pill", gt = "mss-selected-item-text", bt = "mss-selected-item-pill-detail", pe = "mss-selected-item-delete-btn", Et = "mss-selected-item-edit-link", fe = "mss-input-controls-container", ge = "mss-input-wrapper", be = "mss-input-wrapper-focused", Ee = "mss-text-input", ve = "mss-create-new-button", Se = "mss-toggle-button", vt = "mss-inline-row", ye = "mss-options-list", St = "mss-option-item", yt = "mss-option-item-name", Lt = "mss-option-item-detail", Le = "mss-option-item-highlighted", W = "mss-hidden-select", j = "mss-no-items-text", xe = "mss-loading", G = 1, J = 10, xt = 250, At = "mss-state-no-selection", Ct = "mss-state-has-selection", It = "mss-state-list-open"; -class Me extends HTMLElement { +ee(co, "formAssociated", !0); +const ec = "mss-component-wrapper", Qs = "mss-selected-items-container", ic = "mss-selected-item-pill", nc = "mss-selected-item-text", sc = "mss-selected-item-pill-detail", Zs = "mss-selected-item-delete-btn", rc = "mss-selected-item-edit-link", tr = "mss-input-controls-container", er = "mss-input-wrapper", ir = "mss-input-wrapper-focused", nr = "mss-text-input", sr = "mss-create-new-button", rr = "mss-toggle-button", oc = "mss-inline-row", or = "mss-options-list", ac = "mss-option-item", lc = "mss-option-item-name", cc = "mss-option-item-detail", ar = "mss-option-item-highlighted", Zi = "mss-hidden-select", tn = "mss-no-items-text", lr = "mss-loading", en = 1, nn = 10, hc = 250, dc = "mss-state-no-selection", uc = "mss-state-has-selection", mc = "mss-state-list-open"; +class ho extends HTMLElement { constructor() { super(); - C(this, "_blurTimeout", null); + ee(this, "_blurTimeout", null); this.internals_ = this.attachInternals(), this._value = [], this._initialValue = [], this._initialOrder = [], this._removedIds = /* @__PURE__ */ new Set(), this._initialCaptured = !1, this._allowInitialCapture = !0, this._options = [ { id: "abk", name: "Abchasisch" }, { id: "aar", name: "Afar" }, @@ -1410,22 +6965,22 @@ class Me extends HTMLElement { { id: "yor", name: "Yoruba" }, { id: "zha", name: "Zhuang" }, { id: "zul", name: "Zulu" } - ], this._filteredOptions = [], this._highlightedIndex = -1, this._isOptionsListVisible = !1, this._remoteEndpoint = null, this._remoteResultKey = "items", this._remoteMinChars = G, this._remoteLimit = J, this._remoteFetchController = null, this._remoteFetchTimeout = null, this._placeholder = this.getAttribute("placeholder") || "Search items...", this._showCreateButton = this.getAttribute("show-create-button") !== "false", this._toggleLabel = this.getAttribute("data-toggle-label") || "", this._toggleInput = this._toggleLabel !== "", this._inputCollapsed = this._toggleInput, this._editBase = this.getAttribute("data-edit-base") || "", this._editSuffix = this.getAttribute("data-edit-suffix") || "/edit", this._setupTemplates(), this._bindEventHandlers(); + ], this._filteredOptions = [], this._highlightedIndex = -1, this._isOptionsListVisible = !1, this._remoteEndpoint = null, this._remoteResultKey = "items", this._remoteMinChars = en, this._remoteLimit = nn, this._remoteFetchController = null, this._remoteFetchTimeout = null, this._placeholder = this.getAttribute("placeholder") || "Search items...", this._showCreateButton = this.getAttribute("show-create-button") !== "false", this._toggleLabel = this.getAttribute("data-toggle-label") || "", this._toggleInput = this._toggleLabel !== "", this._inputCollapsed = this._toggleInput, this._editBase = this.getAttribute("data-edit-base") || "", this._editSuffix = this.getAttribute("data-edit-suffix") || "/edit", this._setupTemplates(), this._bindEventHandlers(); } _setupTemplates() { this.optionTemplate = document.createElement("template"), this.optionTemplate.innerHTML = ` -
  • - - +
  • + +
  • `, this.selectedItemTemplate = document.createElement("template"), this.selectedItemTemplate.innerHTML = ` - - - - - + `; } @@ -1450,11 +7005,11 @@ class Me extends HTMLElement { } setOptions(e) { if (Array.isArray(e) && e.every((i) => i && typeof i.id == "string" && typeof i.name == "string")) { - this._options = e.map((s) => { - const n = { ...s }; - return n.name = this._normalizeText(n.name), n.additional_data = this._normalizeText(n.additional_data), n; + this._options = e.map((n) => { + const r = { ...n }; + return r.name = this._normalizeText(r.name), r.additional_data = this._normalizeText(r.additional_data), r; }); - const i = this._value.filter((s) => this._getItemById(s)); + const i = this._value.filter((n) => this._getItemById(n)); i.length !== this._value.length ? this.value = i : this.selectedItemsContainer && this._renderSelectedItems(), this._filteredOptions = [], this._highlightedIndex = -1, this.inputElement && this.inputElement.value ? this._handleInput({ target: this.inputElement }) : this._hideOptionsList(); } else console.error("setOptions expects an array of objects with id and name properties."); } @@ -1464,15 +7019,15 @@ class Me extends HTMLElement { set value(e) { const i = JSON.stringify(this._value.sort()); if (Array.isArray(e)) - this._value = [...new Set(e.filter((n) => typeof n == "string" && this._getItemById(n)))]; + this._value = [...new Set(e.filter((r) => typeof r == "string" && this._getItemById(r)))]; else if (typeof e == "string" && e.trim() !== "") { - const n = e.trim(); - this._getItemById(n) && !this._value.includes(n) ? this._value = [n] : this._getItemById(n) || (this._value = this._value.filter((a) => a !== n)); + const r = e.trim(); + this._getItemById(r) && !this._value.includes(r) ? this._value = [r] : this._getItemById(r) || (this._value = this._value.filter((o) => o !== r)); } else this._value = []; - const s = JSON.stringify(this._value.sort()); - !this._initialCaptured && this._allowInitialCapture && this._value.length > 0 && (this._initialValue = [...this._value], this._initialOrder = [...this._value], this._initialCaptured = !0), this._value.forEach((n) => { - this._removedIds.has(n) && this._removedIds.delete(n); - }), i !== s && (this._updateFormValue(), this.selectedItemsContainer && this._renderSelectedItems(), this._updateRootElementStateClasses(), this.dispatchEvent(new Event("change", { bubbles: !0 }))); + const n = JSON.stringify(this._value.sort()); + !this._initialCaptured && this._allowInitialCapture && this._value.length > 0 && (this._initialValue = [...this._value], this._initialOrder = [...this._value], this._initialCaptured = !0), this._value.forEach((r) => { + this._removedIds.has(r) && this._removedIds.delete(r); + }), i !== n && (this._updateFormValue(), this.selectedItemsContainer && this._renderSelectedItems(), this._updateRootElementStateClasses(), this.dispatchEvent(new Event("change", { bubbles: !0 }))); } get name() { return this.getAttribute("name"); @@ -1481,14 +7036,14 @@ class Me extends HTMLElement { this.setAttribute("name", e), this.hiddenSelect && (this.hiddenSelect.name = e); } connectedCallback() { - this._render(), this.inputControlsContainer = this.querySelector(`.${fe}`), this.inputWrapper = this.querySelector(`.${ge}`), this.inputElement = this.querySelector(`.${Ee}`), this.createNewButton = this.querySelector(`.${ve}`), this.toggleButton = this.querySelector(`.${Se}`), this.optionsListElement = this.querySelector(`.${ye}`), this.selectedItemsContainer = this.querySelector(`.${_e}`), this.hiddenSelect = this.querySelector(`.${W}`), this.placeholder = this.getAttribute("placeholder") || "Search items...", this.showCreateButton = this.getAttribute("show-create-button") !== "false", this._toggleLabel = this.getAttribute("data-toggle-label") || "", this._toggleInput = this._toggleLabel !== "", this._inputCollapsed = this._toggleInput, this._remoteEndpoint = this.getAttribute("data-endpoint") || null, this._remoteResultKey = this.getAttribute("data-result-key") || "items", this._remoteMinChars = this._parsePositiveInt(this.getAttribute("data-minchars"), G), this._remoteLimit = this._parsePositiveInt(this.getAttribute("data-limit"), J), this.name && this.hiddenSelect && (this.hiddenSelect.name = this.name), this.inputElement.addEventListener("input", this._handleInput), this.inputElement.addEventListener("keydown", this._handleKeyDown), this.inputElement.addEventListener("focus", this._handleFocus), this.inputElement.addEventListener("blur", this._handleBlur), this.optionsListElement.addEventListener("mousedown", this._handleOptionMouseDown), this.optionsListElement.addEventListener("click", this._handleOptionClick), this.createNewButton.addEventListener("click", this._handleCreateNewButtonClick), this.selectedItemsContainer.addEventListener("click", this._handleSelectedItemsContainerClick), this.toggleButton && this.toggleButton.addEventListener("click", this._handleToggleClick); + this._render(), this.inputControlsContainer = this.querySelector(`.${tr}`), this.inputWrapper = this.querySelector(`.${er}`), this.inputElement = this.querySelector(`.${nr}`), this.createNewButton = this.querySelector(`.${sr}`), this.toggleButton = this.querySelector(`.${rr}`), this.optionsListElement = this.querySelector(`.${or}`), this.selectedItemsContainer = this.querySelector(`.${Qs}`), this.hiddenSelect = this.querySelector(`.${Zi}`), this.placeholder = this.getAttribute("placeholder") || "Search items...", this.showCreateButton = this.getAttribute("show-create-button") !== "false", this._toggleLabel = this.getAttribute("data-toggle-label") || "", this._toggleInput = this._toggleLabel !== "", this._inputCollapsed = this._toggleInput, this._remoteEndpoint = this.getAttribute("data-endpoint") || null, this._remoteResultKey = this.getAttribute("data-result-key") || "items", this._remoteMinChars = this._parsePositiveInt(this.getAttribute("data-minchars"), en), this._remoteLimit = this._parsePositiveInt(this.getAttribute("data-limit"), nn), this.name && this.hiddenSelect && (this.hiddenSelect.name = this.name), this.inputElement.addEventListener("input", this._handleInput), this.inputElement.addEventListener("keydown", this._handleKeyDown), this.inputElement.addEventListener("focus", this._handleFocus), this.inputElement.addEventListener("blur", this._handleBlur), this.optionsListElement.addEventListener("mousedown", this._handleOptionMouseDown), this.optionsListElement.addEventListener("click", this._handleOptionClick), this.createNewButton.addEventListener("click", this._handleCreateNewButtonClick), this.selectedItemsContainer.addEventListener("click", this._handleSelectedItemsContainerClick), this.toggleButton && this.toggleButton.addEventListener("click", this._handleToggleClick); const e = this.getAttribute("data-external-toggle-id"); if (e && (this.externalToggleButton = document.getElementById(e), this.externalToggleButton && this.externalToggleButton.addEventListener("click", this._handleToggleClick)), this._updateRootElementStateClasses(), this.hasAttribute("value")) { const i = this.getAttribute("value"); try { this.value = JSON.parse(i); } catch { - this.value = i.split(",").map((n) => n.trim()).filter(Boolean); + this.value = i.split(",").map((r) => r.trim()).filter(Boolean); } } else this._renderSelectedItems(), this._synchronizeHiddenSelect(); @@ -1511,17 +7066,17 @@ class Me extends HTMLElement { "data-toggle-label" ]; } - attributeChangedCallback(e, i, s) { - if (i !== s) + attributeChangedCallback(e, i, n) { + if (i !== n) if (e === "disabled") this.disabledCallback(this.hasAttribute("disabled")); - else if (e === "name" && this.hiddenSelect) this.hiddenSelect.name = s; + else if (e === "name" && this.hiddenSelect) this.hiddenSelect.name = n; else if (e === "value" && this.inputElement) try { - this.value = JSON.parse(s); + this.value = JSON.parse(n); } catch { - this.value = s.split(",").map((a) => a.trim()).filter(Boolean); + this.value = n.split(",").map((o) => o.trim()).filter(Boolean); } - else e === "placeholder" ? this.placeholder = s : e === "show-create-button" ? this.showCreateButton = s : e === "data-endpoint" ? this._remoteEndpoint = s || null : e === "data-result-key" ? this._remoteResultKey = s || "items" : e === "data-minchars" ? this._remoteMinChars = this._parsePositiveInt(s, G) : e === "data-limit" ? this._remoteLimit = this._parsePositiveInt(s, J) : e === "data-toggle-label" && (this._toggleLabel = s || "", this._toggleInput = this._toggleLabel !== ""); + else e === "placeholder" ? this.placeholder = n : e === "show-create-button" ? this.showCreateButton = n : e === "data-endpoint" ? this._remoteEndpoint = n || null : e === "data-result-key" ? this._remoteResultKey = n || "items" : e === "data-minchars" ? this._remoteMinChars = this._parsePositiveInt(n, en) : e === "data-limit" ? this._remoteLimit = this._parsePositiveInt(n, nn) : e === "data-toggle-label" && (this._toggleLabel = n || "", this._toggleInput = this._toggleLabel !== ""); } formAssociatedCallback(e) { } @@ -1541,97 +7096,97 @@ class Me extends HTMLElement { this.hiddenSelect && (this.hiddenSelect.innerHTML = "", this._value.forEach((e) => { const i = document.createElement("option"); i.value = e; - const s = this._getItemById(e); - i.textContent = s ? s.name : e, i.selected = !0, this.hiddenSelect.appendChild(i); + const n = this._getItemById(e); + i.textContent = n ? n.name : e, i.selected = !0, this.hiddenSelect.appendChild(i); })); } _updateFormValue() { this.internals_.setFormValue(null), this._synchronizeHiddenSelect(); } disabledCallback(e) { - this.inputElement && (this.inputElement.disabled = e), this.createNewButton && (this.createNewButton.disabled = e), this.toggleAttribute("disabled", e), this.querySelectorAll(`.${pe}`).forEach((i) => i.disabled = e), this.hiddenSelect && (this.hiddenSelect.disabled = e), e && this._hideOptionsList(); + this.inputElement && (this.inputElement.disabled = e), this.createNewButton && (this.createNewButton.disabled = e), this.toggleAttribute("disabled", e), this.querySelectorAll(`.${Zs}`).forEach((i) => i.disabled = e), this.hiddenSelect && (this.hiddenSelect.disabled = e), e && this._hideOptionsList(); } _updateRootElementStateClasses() { - this.classList.toggle(At, this._value.length === 0), this.classList.toggle(Ct, this._value.length > 0), this.classList.toggle(It, this._isOptionsListVisible); + this.classList.toggle(dc, this._value.length === 0), this.classList.toggle(uc, this._value.length > 0), this.classList.toggle(mc, this._isOptionsListVisible); } _render() { const e = this.id || `mss-${crypto.randomUUID().slice(0, 8)}`; this.id || this.setAttribute("id", e); - const i = this.getAttribute("data-toggle-label") || "", s = i !== "", n = s ? "hidden" : ""; + const i = this.getAttribute("data-toggle-label") || "", n = i !== "", r = n ? "hidden" : ""; this.innerHTML = ` -
    -
    -
    - ${s ? `` : ""} -
    -
    +
    +
    +
    + ${n ? `` : ""} +
    +
    - +
    - - + +
    `; } _createSelectedItemElement(e) { const i = this._getItemById(e); if (!i) return null; - const n = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, a = n.querySelector('[data-ref="textEl"]'), l = n.querySelector('[data-ref="detailEl"]'), o = n.querySelector('[data-ref="editLink"]'), d = n.querySelector('[data-ref="deleteBtn"]'); - a.textContent = this._normalizeText(i.name); - const c = this._normalizeText(i.additional_data); - c ? (l.textContent = `(${c})`, l.classList.remove("hidden")) : (l.textContent = "", l.classList.add("hidden")); - const h = this._removedIds.has(e); + const r = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, o = r.querySelector('[data-ref="textEl"]'), a = r.querySelector('[data-ref="detailEl"]'), c = r.querySelector('[data-ref="editLink"]'), h = r.querySelector('[data-ref="deleteBtn"]'); + o.textContent = this._normalizeText(i.name); + const d = this._normalizeText(i.additional_data); + d ? (a.textContent = `(${d})`, a.classList.remove("hidden")) : (a.textContent = "", a.classList.add("hidden")); + const m = this._removedIds.has(e); if (!this._initialValue.includes(e)) { - const u = document.createElement("span"); - u.className = "ml-1 text-xs text-gray-600", u.textContent = "(Neu)", a.appendChild(u); + const f = document.createElement("span"); + f.className = "ml-1 text-xs text-gray-600", f.textContent = "(Neu)", o.appendChild(f); } - return h && (n.classList.add("bg-red-100"), n.style.position = "relative"), o && (this._editBase && !h ? (o.href = `${this._editBase}${e}${this._editSuffix}`, o.target = "_blank", o.rel = "noreferrer", o.classList.remove("hidden")) : (o.classList.add("hidden"), o.removeAttribute("href"), o.removeAttribute("target"), o.removeAttribute("rel"))), d.setAttribute("aria-label", h ? `Undo remove ${i.name}` : `Remove ${i.name}`), d.dataset.id = e, d.disabled = this.hasAttribute("disabled"), d.innerHTML = h ? '' : "×", d.addEventListener("click", (u) => { - u.stopPropagation(), this._handleDeleteSelectedItem(e); - }), n; + return m && (r.classList.add("bg-red-100"), r.style.position = "relative"), c && (this._editBase && !m ? (c.href = `${this._editBase}${e}${this._editSuffix}`, c.target = "_blank", c.rel = "noreferrer", c.classList.remove("hidden")) : (c.classList.add("hidden"), c.removeAttribute("href"), c.removeAttribute("target"), c.removeAttribute("rel"))), h.setAttribute("aria-label", m ? `Undo remove ${i.name}` : `Remove ${i.name}`), h.dataset.id = e, h.disabled = this.hasAttribute("disabled"), h.innerHTML = m ? '' : "×", h.addEventListener("click", (f) => { + f.stopPropagation(), this._handleDeleteSelectedItem(e); + }), r; } _renderSelectedItems() { if (!this.selectedItemsContainer) return; this.selectedItemsContainer.innerHTML = ""; - const e = this._initialOrder.filter((s) => this._removedIds.has(s) && !this._value.includes(s)), i = [...this._value, ...e]; + const e = this._initialOrder.filter((n) => this._removedIds.has(n) && !this._value.includes(n)), i = [...this._value, ...e]; if (i.length === 0) { - const s = this.getAttribute("data-empty-text") || "Keine Auswahl...", n = this._inputCollapsed ? "" : "hidden"; - this.selectedItemsContainer.innerHTML = `${s}`; + const n = this.getAttribute("data-empty-text") || "Keine Auswahl...", r = this._inputCollapsed ? "" : "hidden"; + this.selectedItemsContainer.innerHTML = `${n}`; } else - i.forEach((s) => { - const n = this._createSelectedItemElement(s); - n && this.selectedItemsContainer.appendChild(n); + i.forEach((n) => { + const r = this._createSelectedItemElement(n); + r && this.selectedItemsContainer.appendChild(r); }); this._updateRootElementStateClasses(); } _createOptionElement(e, i) { - const n = this.optionTemplate.content.cloneNode(!0).firstElementChild, a = n.querySelector('[data-ref="nameEl"]'), l = n.querySelector('[data-ref="detailEl"]'); - a.textContent = this._normalizeText(e.name); - const o = this._normalizeText(e.additional_data); - l.textContent = o ? `(${o})` : "", n.dataset.id = e.id, n.setAttribute("aria-selected", String(i === this._highlightedIndex)); - const d = `option-${this.id || "mss"}-${e.id}`; - return n.id = d, i === this._highlightedIndex && (n.classList.add(Le), this.inputElement && this.inputElement.setAttribute("aria-activedescendant", d)), n; + const r = this.optionTemplate.content.cloneNode(!0).firstElementChild, o = r.querySelector('[data-ref="nameEl"]'), a = r.querySelector('[data-ref="detailEl"]'); + o.textContent = this._normalizeText(e.name); + const c = this._normalizeText(e.additional_data); + a.textContent = c ? `(${c})` : "", r.dataset.id = e.id, r.setAttribute("aria-selected", String(i === this._highlightedIndex)); + const h = `option-${this.id || "mss"}-${e.id}`; + return r.id = h, i === this._highlightedIndex && (r.classList.add(ar), this.inputElement && this.inputElement.setAttribute("aria-activedescendant", h)), r; } _renderOptionsList() { if (!(!this.optionsListElement || !this.inputElement)) { if (this.optionsListElement.innerHTML = "", this.inputElement.removeAttribute("aria-activedescendant"), this._filteredOptions.length === 0 || !this._isOptionsListVisible) this.optionsListElement.classList.add("hidden"), this.inputElement.setAttribute("aria-expanded", "false"); else { - this.optionsListElement.classList.remove("hidden"), this.inputElement.setAttribute("aria-expanded", "true"), this._filteredOptions.forEach((i, s) => { - const n = this._createOptionElement(i, s); - this.optionsListElement.appendChild(n); + this.optionsListElement.classList.remove("hidden"), this.inputElement.setAttribute("aria-expanded", "true"), this._filteredOptions.forEach((i, n) => { + const r = this._createOptionElement(i, n); + this.optionsListElement.appendChild(r); }); - const e = this.optionsListElement.querySelector(`.${Le}`); + const e = this.optionsListElement.querySelector(`.${ar}`); e && (e.scrollIntoView({ block: "nearest" }), this.inputElement.setAttribute("aria-activedescendant", e.id)); } this._updateRootElementStateClasses(); @@ -1660,11 +7215,11 @@ class Me extends HTMLElement { if (i.length === 0) this._filteredOptions = [], this._isOptionsListVisible = !1; else { - const s = i.toLowerCase(); - this._filteredOptions = this._options.filter((n) => { - if (this._value.includes(n.id)) return !1; - const l = this._normalizeText(n.name).toLowerCase().includes(s), o = this._normalizeText(n.additional_data), d = o && o.toLowerCase().includes(s); - return l || d; + const n = i.toLowerCase(); + this._filteredOptions = this._options.filter((r) => { + if (this._value.includes(r.id)) return !1; + const a = this._normalizeText(r.name).toLowerCase().includes(n), c = this._normalizeText(r.additional_data), h = c && c.toLowerCase().includes(n); + return a || h; }), this._isOptionsListVisible = this._filteredOptions.length > 0; } this._highlightedIndex = this._filteredOptions.length > 0 ? 0 : -1, this._renderOptionsList(); @@ -1698,10 +7253,10 @@ class Me extends HTMLElement { this._isOptionsListVisible = !1, this._highlightedIndex = -1, this.optionsListElement && this._renderOptionsList(); } _handleFocus() { - this.inputElement.disabled || (this.inputWrapper && this.inputWrapper.classList.add(be), this.inputElement.value.length > 0 && this._handleInput({ target: this.inputElement }), this._updateRootElementStateClasses()); + this.inputElement.disabled || (this.inputWrapper && this.inputWrapper.classList.add(ir), this.inputElement.value.length > 0 && this._handleInput({ target: this.inputElement }), this._updateRootElementStateClasses()); } _handleBlur() { - this.inputWrapper && this.inputWrapper.classList.remove(be), this._blurTimeout = setTimeout(() => { + this.inputWrapper && this.inputWrapper.classList.remove(ir), this._blurTimeout = setTimeout(() => { this.contains(document.activeElement) || (this._hideOptionsList(), this._toggleInput && (!this.inputElement || this.inputElement.value.trim() === "") && this._hideInputControls()); }, 150); } @@ -1732,7 +7287,7 @@ class Me extends HTMLElement { _showInputControls() { if (this.inputControlsContainer) { if (this.inputControlsContainer.classList.remove("hidden"), this.toggleButton && this.toggleButton.classList.add("hidden"), this._value.length === 0 && this.selectedItemsContainer) { - const e = this.selectedItemsContainer.querySelector(`.${j}`); + const e = this.selectedItemsContainer.querySelector(`.${tn}`); e && e.classList.add("hidden"); } this.inputElement && !this.hasAttribute("disabled") && this.inputElement.focus(), this._inputCollapsed = !1; @@ -1741,7 +7296,7 @@ class Me extends HTMLElement { _hideInputControls() { if (this.inputControlsContainer) { if (this.inputControlsContainer.classList.add("hidden"), this.toggleButton && this.toggleButton.classList.remove("hidden"), this._value.length === 0 && this.selectedItemsContainer) { - const e = this.selectedItemsContainer.querySelector(`.${j}`); + const e = this.selectedItemsContainer.querySelector(`.${tn}`); e && e.classList.remove("hidden"); } this._hideOptionsList(), this._inputCollapsed = !0; @@ -1749,8 +7304,8 @@ class Me extends HTMLElement { } _parsePositiveInt(e, i) { if (!e) return i; - const s = parseInt(e, 10); - return Number.isNaN(s) || s <= 0 ? i : s; + const n = parseInt(e, 10); + return Number.isNaN(n) || n <= 0 ? i : n; } _handleRemoteInput(e) { if (this._remoteFetchTimeout && clearTimeout(this._remoteFetchTimeout), e.length < this._remoteMinChars) { @@ -1759,59 +7314,59 @@ class Me extends HTMLElement { } this._remoteFetchTimeout = setTimeout(() => { this._fetchRemoteOptions(e); - }, xt); + }, hc); } _cancelRemoteFetch() { this._remoteFetchController && (this._remoteFetchController.abort(), this._remoteFetchController = null); } async _fetchRemoteOptions(e) { if (!this._remoteEndpoint) return; - this._cancelRemoteFetch(), this.classList.add(xe); + this._cancelRemoteFetch(), this.classList.add(lr); const i = new AbortController(); this._remoteFetchController = i; try { - const s = new URL(this._remoteEndpoint, window.location.origin); - s.searchParams.set("q", e), this._remoteLimit && s.searchParams.set("limit", String(this._remoteLimit)); - const n = await fetch(s.toString(), { + const n = new URL(this._remoteEndpoint, window.location.origin); + n.searchParams.set("q", e), this._remoteLimit && n.searchParams.set("limit", String(this._remoteLimit)); + const r = await fetch(n.toString(), { headers: { Accept: "application/json" }, signal: i.signal, credentials: "same-origin" }); - if (!n.ok) - throw new Error(`Remote fetch failed with status ${n.status}`); - const a = await n.json(); + if (!r.ok) + throw new Error(`Remote fetch failed with status ${r.status}`); + const o = await r.json(); if (i.signal.aborted) return; - const l = this._extractRemoteOptions(a); - this._applyRemoteResults(l); - } catch (s) { + const a = this._extractRemoteOptions(o); + this._applyRemoteResults(a); + } catch (n) { if (i.signal.aborted) return; - console.error("MultiSelectSimple remote fetch error:", s), this._filteredOptions = [], this._isOptionsListVisible = !1, this._renderOptionsList(); + console.error("MultiSelectSimple remote fetch error:", n), this._filteredOptions = [], this._isOptionsListVisible = !1, this._renderOptionsList(); } finally { - this._remoteFetchController === i && (this._remoteFetchController = null), this.classList.remove(xe); + this._remoteFetchController === i && (this._remoteFetchController = null), this.classList.remove(lr); } } _extractRemoteOptions(e) { if (!e) return []; let i = []; - return Array.isArray(e) ? i = e : this._remoteResultKey && Array.isArray(e[this._remoteResultKey]) ? i = e[this._remoteResultKey] : Array.isArray(e.items) && (i = e.items), i.map((s) => { - if (!s) return null; - const n = s.id ?? s.ID ?? s.value ?? "", a = s.name ?? s.title ?? s.label ?? "", l = s.detail ?? s.additional_data ?? s.annotation ?? "", o = this._normalizeText(a), d = this._normalizeText(l); - return !n || !o ? null : { - id: String(n), - name: o, - additional_data: d + return Array.isArray(e) ? i = e : this._remoteResultKey && Array.isArray(e[this._remoteResultKey]) ? i = e[this._remoteResultKey] : Array.isArray(e.items) && (i = e.items), i.map((n) => { + if (!n) return null; + const r = n.id ?? n.ID ?? n.value ?? "", o = n.name ?? n.title ?? n.label ?? "", a = n.detail ?? n.additional_data ?? n.annotation ?? "", c = this._normalizeText(o), h = this._normalizeText(a); + return !r || !c ? null : { + id: String(r), + name: c, + additional_data: h }; }).filter(Boolean); } _applyRemoteResults(e) { - const i = new Set(this._value), s = /* @__PURE__ */ new Map(); - this._options.forEach((n) => { - n != null && n.id && s.set(n.id, n); - }), e.forEach((n) => { - n != null && n.id && s.set(n.id, n); - }), this._options = Array.from(s.values()), this._filteredOptions = e.filter((n) => n && !i.has(n.id)), this._isOptionsListVisible = this._filteredOptions.length > 0, this._highlightedIndex = this._isOptionsListVisible ? 0 : -1, this._renderOptionsList(); + const i = new Set(this._value), n = /* @__PURE__ */ new Map(); + this._options.forEach((r) => { + r != null && r.id && n.set(r.id, r); + }), e.forEach((r) => { + r != null && r.id && n.set(r.id, r); + }), this._options = Array.from(n.values()), this._filteredOptions = e.filter((r) => r && !i.has(r.id)), this._isOptionsListVisible = this._filteredOptions.length > 0, this._highlightedIndex = this._isOptionsListVisible ? 0 : -1, this._renderOptionsList(); } _normalizeText(e) { if (e == null) @@ -1819,13 +7374,13 @@ class Me extends HTMLElement { let i = String(e).trim(); if (!i) return ""; - const s = i[0], n = i[i.length - 1]; - return (s === '"' && n === '"' || s === "'" && n === "'") && (i = i.slice(1, -1).trim(), !i) ? "" : i; + const n = i[0], r = i[i.length - 1]; + return (n === '"' && r === '"' || n === "'" && r === "'") && (i = i.slice(1, -1).trim(), !i) ? "" : i; } } -C(Me, "formAssociated", !0); -const wt = "rbi-button", Tt = "rbi-icon"; -class kt extends HTMLElement { +ee(ho, "formAssociated", !0); +const gc = "rbi-button", pc = "rbi-icon"; +class fc extends HTMLElement { constructor() { super(), this.initialStates = /* @__PURE__ */ new Map(), this._controlledElements = [], this.button = null, this.lastOverallModifiedState = null, this.handleInputChange = this.handleInputChange.bind(this), this.handleReset = this.handleReset.bind(this); } @@ -1834,10 +7389,10 @@ class kt extends HTMLElement { } connectedCallback() { const t = ` - `; @@ -1862,8 +7417,8 @@ class kt extends HTMLElement { } const e = []; t.forEach((i) => { - const s = document.getElementById(i); - s ? (e.push(s), this.storeInitialState(s), s.addEventListener("input", this.handleInputChange), s.addEventListener("change", this.handleInputChange)) : console.warn(`ResetButtonIndividual: Element with ID "${i}" not found.`); + const n = document.getElementById(i); + n ? (e.push(n), this.storeInitialState(n), n.addEventListener("input", this.handleInputChange), n.addEventListener("change", this.handleInputChange)) : console.warn(`ResetButtonIndividual: Element with ID "${i}" not found.`); }), this._controlledElements = e, this.button && (this.button.disabled = this._controlledElements.length === 0, this.button.setAttribute("aria-controls", this._controlledElements.map((i) => i.id).join(" ")), this.button.disabled ? this.button.setAttribute("aria-disabled", "true") : this.button.removeAttribute("aria-disabled")), this.checkIfModified(); } storeInitialState(t) { @@ -1925,8 +7480,8 @@ class kt extends HTMLElement { case "radio": return t.checked !== e.checked; case "select-multiple": - const i = Array.from(t.options).filter((n) => n.selected).map((n) => n.value), s = e.selectedOptions; - return i.length !== s.length || i.some((n) => !s.includes(n)) || s.some((n) => !i.includes(n)); + const i = Array.from(t.options).filter((r) => r.selected).map((r) => r.value), n = e.selectedOptions; + return i.length !== n.length || i.some((r) => !n.includes(r)) || n.some((r) => !i.includes(r)); case "select-one": default: return t.value !== e.value; @@ -1950,8 +7505,8 @@ class kt extends HTMLElement { if (e) { const i = this.closest(`.${e}`); if (i) { - const s = this.getAttribute("modified-class-suffix") || "modified", n = `${e}-${s}`; - t ? i.classList.add(n) : i.classList.remove(n); + const n = this.getAttribute("modified-class-suffix") || "modified", r = `${e}-${n}`; + t ? i.classList.add(r) : i.classList.remove(r); } } if (this.button && (this.button.disabled = !t || this._controlledElements.length === 0, this.button.disabled ? this.button.setAttribute("aria-disabled", "true") : this.button.removeAttribute("aria-disabled")), this.lastOverallModifiedState !== t) { @@ -1960,7 +7515,7 @@ class kt extends HTMLElement { composed: !0, detail: { modified: t, - controlledElementIds: this._controlledElements.map((s) => s.id), + controlledElementIds: this._controlledElements.map((n) => n.id), instance: this } }); @@ -1973,40 +7528,40 @@ class kt extends HTMLElement { if (!t) { const e = this._controlledElements.map((i) => i.id); if (e.length === 1 && this._controlledElements[0]) { - const i = this._controlledElements[0], s = document.querySelector(`label[for="${i.id}"]`); - let n = i.name || i.id; - s && s.textContent ? n = s.textContent.trim().replace(/[:*]$/, "").trim() : i.getAttribute("aria-label") && (n = i.getAttribute("aria-label")), t = `Reset ${n}`; + const i = this._controlledElements[0], n = document.querySelector(`label[for="${i.id}"]`); + let r = i.name || i.id; + n && n.textContent ? r = n.textContent.trim().replace(/[:*]$/, "").trim() : i.getAttribute("aria-label") && (r = i.getAttribute("aria-label")), t = `Reset ${r}`; } else e.length > 1 ? t = "Reset selected fields" : t = "Reset field"; } this.button.setAttribute("aria-label", t); } } -const g = "hidden", Ae = "dm-stay", N = "dm-title", Ce = "dm-menu-button", Rt = "dm-target", Ot = "data-dm-target", Ie = "dm-menu", we = "dm-menu-item", Bt = "dm-close-button"; -var q, $e; -class Mt extends HTMLElement { +const it = "hidden", cr = "dm-stay", Ve = "dm-title", hr = "dm-menu-button", bc = "dm-target", vc = "data-dm-target", dr = "dm-menu", ur = "dm-menu-item", _c = "dm-close-button"; +var ei, uo; +class Ac extends HTMLElement { constructor() { super(); - I(this, q); - B(this, q, $e).call(this), this.boundHandleClickOutside = this.handleClickOutside.bind(this); + ie(this, ei); + Be(this, ei, uo).call(this), this.boundHandleClickOutside = this.handleClickOutside.bind(this); } connectedCallback() { - if (this._target = document.getElementById(this.getAttribute(Rt)), this._target || (this._target = this), this._cildren = Array.from(this.children).filter((e) => e.nodeType === Node.ELEMENT_NODE && !e.classList.contains(Ce)).map((e) => ({ + if (this._target = document.getElementById(this.getAttribute(bc)), this._target || (this._target = this), this._cildren = Array.from(this.children).filter((e) => e.nodeType === Node.ELEMENT_NODE && !e.classList.contains(hr)).map((e) => ({ node: e, target: () => { - const i = e.getAttribute(Ot); + const i = e.getAttribute(vc); return i ? document.getElementById(i) || this._target : this._target; }, - stay: () => e.hasAttribute(Ae) && e.getAttribute(Ae) == "true", - hidden: () => e.classList.contains(g), + stay: () => e.hasAttribute(cr) && e.getAttribute(cr) == "true", + hidden: () => e.classList.contains(it), name: () => { const i = e.querySelector("label"); - return i ? i.innerHTML : e.hasAttribute(N) ? e.getAttribute(N) : ""; + return i ? i.innerHTML : e.hasAttribute(Ve) ? e.getAttribute(Ve) : ""; }, nameText: () => { const i = e.querySelector("label"); - return i ? i.textContent.trim() : e.hasAttribute(N) ? e.getAttribute(N) : ""; + return i ? i.textContent.trim() : e.hasAttribute(Ve) ? e.getAttribute(Ve) : ""; } - })), this._button = this.querySelector(`.${Ce}`), !this._button) { + })), this._button = this.querySelector(`.${hr}`), !this._button) { console.error("DivManagerMenu needs a button element."); return; } @@ -2015,9 +7570,9 @@ class Mt extends HTMLElement { this.removeChild(e.node); this._button.addEventListener("click", this._toggleMenu.bind(this)), this._button.classList.add("relative"); for (const e of this._cildren) - e.node.querySelectorAll(`.${Bt}`).forEach((s) => { - s.addEventListener("click", (n) => { - this.hideDiv(n, e.node); + e.node.querySelectorAll(`.${_c}`).forEach((n) => { + n.addEventListener("click", (r) => { + this.hideDiv(r, e.node); }); }); this.renderIntoTarget(), this.refresh(), this._observer = new MutationObserver(() => { @@ -2034,23 +7589,23 @@ class Mt extends HTMLElement { } _toggleMenu(e) { e.preventDefault(), e.stopPropagation(); - const i = this._cildren.filter((s) => s.hidden()); + const i = this._cildren.filter((n) => n.hidden()); if (i.length === 1) { - const s = this._cildren.indexOf(i[0]); - this.showDiv(e, s); + const n = this._cildren.indexOf(i[0]); + this.showDiv(e, n); return; } if (i.length === 0) { this.hideMenu(); return; } - this.renderMenu(), this._menu.classList.contains(g) ? (this._menu.classList.remove(g), document.addEventListener("click", this.boundHandleClickOutside)) : (this._menu.classList.add(g), document.removeEventListener("click", this.boundHandleClickOutside)); + this.renderMenu(), this._menu.classList.contains(it) ? (this._menu.classList.remove(it), document.addEventListener("click", this.boundHandleClickOutside)) : (this._menu.classList.add(it), document.removeEventListener("click", this.boundHandleClickOutside)); } handleClickOutside(e) { this._menu && !this._menu.contains(e.target) && !this._button.contains(e.target) && this.hideMenu(); } hideMenu() { - this._menu && (this._menu.classList.add(g), document.removeEventListener("click", this.boundHandleClickOutside)); + this._menu && (this._menu.classList.add(it), document.removeEventListener("click", this.boundHandleClickOutside)); } renderButton() { if (!this._button) @@ -2058,12 +7613,12 @@ class Mt extends HTMLElement { this._originalButtonText || (this._originalButtonText = this._button.innerHTML); const e = this._cildren.filter((i) => i.hidden()); if (e.length === 0) { - this._button.classList.add(g), this._button.parentElement && this._button.parentElement.removeChild(this._button), this._menu = null, this.hideMenu(); + this._button.classList.add(it), this._button.parentElement && this._button.parentElement.removeChild(this._button), this._menu = null, this.hideMenu(); return; } - if (this._button.parentElement || this.appendChild(this._button), this._button.classList.remove(g), e.length === 1) { - const i = this._button.querySelector("i"), s = i ? i.outerHTML : ''; - this._button.innerHTML = `${s} + if (this._button.parentElement || this.appendChild(this._button), this._button.classList.remove(it), e.length === 1) { + const i = this._button.querySelector("i"), n = i ? i.outerHTML : ''; + this._button.innerHTML = `${n} ${e[0].nameText()} hinzufügen`, this._menu = null, this.hideMenu(); } else this._button.innerHTML = this._originalButtonText, this._menu = null; @@ -2073,44 +7628,44 @@ ${e[0].nameText()} hinzufügen`, this._menu = null, this.hideMenu(); console.error("DivManagerMenu: Invalid node provided."); return; } - const s = this._cildren.find((a) => a.node === i); - if (!s) { + const n = this._cildren.find((o) => o.node === i); + if (!n) { console.error("DivManagerMenu: Child not found."); return; } - s.node.classList.add(g); - const n = s.target(); - n && n.contains(s.node) && n.removeChild(s.node), this.renderButton(), this.renderMenu(), this.updateTargetVisibility(); + n.node.classList.add(it); + const r = n.target(); + r && r.contains(n.node) && r.removeChild(n.node), this.renderButton(), this.renderMenu(), this.updateTargetVisibility(); } showDiv(e, i) { if (e && (e.preventDefault(), e.stopPropagation()), i < 0 || i >= this._cildren.length) { console.error("DivManagerMenu: Invalid index."); return; } - const s = this._cildren[i]; - if (s.node.classList.remove(g), this.insertChildInOrder(s), this.renderMenu(), this.renderButton(), this.updateTargetVisibility(), typeof window.TextareaAutoResize == "function") { - const n = s.node.querySelectorAll("textarea"); - n.length > 0 && setTimeout(() => { - n.forEach((a) => { - a.dataset.dmResizeBound !== "true" && (a.dataset.dmResizeBound = "true", a.addEventListener("input", () => { - window.TextareaAutoResize(a); - })), window.TextareaAutoResize(a); + const n = this._cildren[i]; + if (n.node.classList.remove(it), this.insertChildInOrder(n), this.renderMenu(), this.renderButton(), this.updateTargetVisibility(), typeof window.TextareaAutoResize == "function") { + const r = n.node.querySelectorAll("textarea"); + r.length > 0 && setTimeout(() => { + r.forEach((o) => { + o.dataset.dmResizeBound !== "true" && (o.dataset.dmResizeBound = "true", o.addEventListener("input", () => { + window.TextareaAutoResize(o); + })), window.TextareaAutoResize(o); }); }, 10); } } renderMenu() { - const e = this._cildren.filter((s) => s.hidden()); + const e = this._cildren.filter((n) => n.hidden()); if (e.length <= 1) { this.hideMenu(); return; } - (!this._menu || !this._button.contains(this._menu)) && (this._button.insertAdjacentHTML("beforeend", ``), this._menu = this._button.querySelector(`.${Ie}`)), this._menu.innerHTML = `${e.map((s, n) => ` - `).join("")}`, this._menu.querySelectorAll(`.${we}`).forEach((s) => { - s.addEventListener("click", (n) => { - this.showDiv(n, parseInt(s.getAttribute("dm-itemno"))), this.hideMenu(), this.renderButton(); + (!this._menu || !this._button.contains(this._menu)) && (this._button.insertAdjacentHTML("beforeend", ``), this._menu = this._button.querySelector(`.${dr}`)), this._menu.innerHTML = `${e.map((n, r) => ` + `).join("")}`, this._menu.querySelectorAll(`.${ur}`).forEach((n) => { + n.addEventListener("click", (r) => { + this.showDiv(r, parseInt(n.getAttribute("dm-itemno"))), this.hideMenu(), this.renderButton(); }); }); } @@ -2120,30 +7675,30 @@ ${e[0].nameText()} hinzufügen`, this._menu = null, this.hideMenu(); }), this.updateTargetVisibility(); } insertChildInOrder(e) { - const i = e.target(), s = this._cildren.indexOf(e), n = this._cildren.slice(s + 1).filter((a) => a.target() === i).map((a) => a.node).find((a) => i && i.contains(a)); - i && (n ? i.insertBefore(e.node, n) : i.appendChild(e.node)); + const i = e.target(), n = this._cildren.indexOf(e), r = this._cildren.slice(n + 1).filter((o) => o.target() === i).map((o) => o.node).find((o) => i && i.contains(o)); + i && (r ? i.insertBefore(e.node, r) : i.appendChild(e.node)); } updateTargetVisibility() { new Set( this._cildren.map((i) => i.target()).filter((i) => i && i !== this) ).forEach((i) => { - const s = Array.from(i.children).some( - (n) => !n.classList.contains(g) + const n = Array.from(i.children).some( + (r) => !r.classList.contains(it) ); - i.classList.toggle(g, !s); + i.classList.toggle(it, !n); }); } } -q = new WeakSet(), $e = function() { +ei = new WeakSet(), uo = function() { this._cildren = [], this._rendered = [], this._target = null, this._button = null, this._menu = null, this._originalButtonText = null; }; -const b = "items-row", $t = "items-list", Nt = "items-template", Dt = "items-add-button", Pt = "items-cancel-button", D = "items-remove-button", qt = "items-edit-button", Ht = "items-close-button", Ft = "items-summary", Vt = "items-edit-panel", Q = "items_removed[]", w = "data-items-removed"; -class Ut extends HTMLElement { +const nt = "items-row", yc = "items-list", Ec = "items-template", Sc = "items-add-button", xc = "items-cancel-button", We = "items-remove-button", Cc = "items-edit-button", Lc = "items-close-button", Tc = "items-summary", wc = "items-edit-panel", sn = "items_removed[]", he = "data-items-removed"; +class kc extends HTMLElement { constructor() { super(), this._list = null, this._template = null, this._addButton = null, this._idPrefix = `items-editor-${crypto.randomUUID().slice(0, 8)}`, this._handleAdd = this._onAddClick.bind(this); } connectedCallback() { - if (this._list = this.querySelector(`.${$t}`), this._template = this.querySelector(`template.${Nt}`), this._addButton = this.querySelector(`.${Dt}`), !this._list || !this._template || !this._addButton) { + if (this._list = this.querySelector(`.${yc}`), this._template = this.querySelector(`template.${Ec}`), this._addButton = this.querySelector(`.${Sc}`), !this._list || !this._template || !this._addButton) { console.error("ItemsEditor: Missing list, template, or add button."); return; } @@ -2156,7 +7711,7 @@ class Ut extends HTMLElement { t.preventDefault(), this.addItem(); } addItem() { - const t = this._template.content.cloneNode(!0), e = t.querySelector(`.${b}`); + const t = this._template.content.cloneNode(!0), e = t.querySelector(`.${nt}`); if (!e) { console.error("ItemsEditor: Template is missing a row element."); return; @@ -2164,55 +7719,55 @@ class Ut extends HTMLElement { this._list.appendChild(t), this._captureOriginalValues(e), this._wireCancelButtons(e), this._wireRemoveButtons(e), this._wireEditButtons(e), this._assignRowFieldIds(e, this._rowIndex(e)), this._wireSummarySync(e), this._syncSummary(e), this._setRowMode(e, "edit"); } removeItem(t) { - const e = t.closest(`.${b}`); + const e = t.closest(`.${nt}`); if (!e) return; - const i = e.getAttribute(w) === "true"; + const i = e.getAttribute(he) === "true"; this._setRowRemoved(e, !i); } _wireRemoveButtons(t = this) { - t.querySelectorAll(`.${D}`).forEach((e) => { + t.querySelectorAll(`.${We}`).forEach((e) => { e.dataset.itemsBound !== "true" && (e.dataset.itemsBound = "true", e.addEventListener("click", (i) => { i.preventDefault(), this.removeItem(e); }), e.addEventListener("mouseenter", () => { - const i = e.closest(`.${b}`); - if (!i || i.getAttribute(w) !== "true") + const i = e.closest(`.${nt}`); + if (!i || i.getAttribute(he) !== "true") return; - const s = e.querySelector("[data-delete-label]"); - s && (s.textContent = s.getAttribute("data-delete-hover") || "Rückgängig"); - const n = e.querySelector("i"); - n && (n.classList.remove("hidden"), n.classList.add("ri-arrow-go-back-line"), n.classList.remove("ri-delete-bin-line")); + const n = e.querySelector("[data-delete-label]"); + n && (n.textContent = n.getAttribute("data-delete-hover") || "Rückgängig"); + const r = e.querySelector("i"); + r && (r.classList.remove("hidden"), r.classList.add("ri-arrow-go-back-line"), r.classList.remove("ri-delete-bin-line")); }), e.addEventListener("mouseleave", () => { - const i = e.closest(`.${b}`), s = e.querySelector("[data-delete-label]"); - if (!s) + const i = e.closest(`.${nt}`), n = e.querySelector("[data-delete-label]"); + if (!n) return; - i && i.getAttribute(w) === "true" ? s.textContent = s.getAttribute("data-delete-active") || "Wird entfernt" : s.textContent = s.getAttribute("data-delete-default") || "Entfernen"; - const n = e.querySelector("i"); - n && (i && i.getAttribute(w) === "true" ? (n.classList.add("hidden"), n.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (n.classList.remove("hidden"), n.classList.add("ri-delete-bin-line"), n.classList.remove("ri-arrow-go-back-line"))); + i && i.getAttribute(he) === "true" ? n.textContent = n.getAttribute("data-delete-active") || "Wird entfernt" : n.textContent = n.getAttribute("data-delete-default") || "Entfernen"; + const r = e.querySelector("i"); + r && (i && i.getAttribute(he) === "true" ? (r.classList.add("hidden"), r.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (r.classList.remove("hidden"), r.classList.add("ri-delete-bin-line"), r.classList.remove("ri-arrow-go-back-line"))); })); }); } _wireCancelButtons(t = this) { - t.querySelectorAll(`.${Pt}`).forEach((e) => { + t.querySelectorAll(`.${xc}`).forEach((e) => { e.dataset.itemsBound !== "true" && (e.dataset.itemsBound = "true", e.addEventListener("click", (i) => { i.preventDefault(); - const s = e.closest(`.${b}`); - s && this._cancelEdit(s); + const n = e.closest(`.${nt}`); + n && this._cancelEdit(n); })); }); } _wireEditButtons(t = this) { - t.querySelectorAll(`.${qt}`).forEach((e) => { + t.querySelectorAll(`.${Cc}`).forEach((e) => { e.dataset.itemsBound !== "true" && (e.dataset.itemsBound = "true", e.addEventListener("click", (i) => { i.preventDefault(); - const s = e.closest(`.${b}`); - s && this._setRowMode(s, "edit"); + const n = e.closest(`.${nt}`); + n && this._setRowMode(n, "edit"); })); - }), t.querySelectorAll(`.${Ht}`).forEach((e) => { + }), t.querySelectorAll(`.${Lc}`).forEach((e) => { e.dataset.itemsBound !== "true" && (e.dataset.itemsBound = "true", e.addEventListener("click", (i) => { i.preventDefault(); - const s = e.closest(`.${b}`); - s && this._setRowMode(s, "summary"); + const n = e.closest(`.${nt}`); + n && this._setRowMode(n, "summary"); })); }); } @@ -2225,27 +7780,27 @@ class Ut extends HTMLElement { this._resetToOriginal(t), this._setRowMode(t, "summary"); } _setRowRemoved(t, e) { - t.setAttribute(w, e ? "true" : "false"), t.classList.toggle("bg-red-50", e); + t.setAttribute(he, e ? "true" : "false"), t.classList.toggle("bg-red-50", e); const i = t.querySelector(".items-edit-button"); - i && (e ? i.classList.add("hidden") : i.classList.remove("hidden")), t.querySelectorAll("[data-delete-label]").forEach((a) => { - const l = a.closest(`.${D}`), o = l && l.matches(":hover"); - let d; - e && o ? d = a.getAttribute("data-delete-hover") || "Rückgängig" : e ? d = a.getAttribute("data-delete-active") || "Wird entfernt" : d = a.getAttribute("data-delete-default") || "Entfernen", a.textContent = d; - }), t.querySelectorAll(`.${D} i`).forEach((a) => { - const l = a.closest(`.${D}`), o = l && l.matches(":hover"); - e ? o ? (a.classList.remove("hidden"), a.classList.add("ri-arrow-go-back-line"), a.classList.remove("ri-delete-bin-line")) : (a.classList.add("hidden"), a.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (a.classList.remove("hidden"), a.classList.add("ri-delete-bin-line"), a.classList.remove("ri-arrow-go-back-line")); + i && (e ? i.classList.add("hidden") : i.classList.remove("hidden")), t.querySelectorAll("[data-delete-label]").forEach((o) => { + const a = o.closest(`.${We}`), c = a && a.matches(":hover"); + let h; + e && c ? h = o.getAttribute("data-delete-hover") || "Rückgängig" : e ? h = o.getAttribute("data-delete-active") || "Wird entfernt" : h = o.getAttribute("data-delete-default") || "Entfernen", o.textContent = h; + }), t.querySelectorAll(`.${We} i`).forEach((o) => { + const a = o.closest(`.${We}`), c = a && a.matches(":hover"); + e ? c ? (o.classList.remove("hidden"), o.classList.add("ri-arrow-go-back-line"), o.classList.remove("ri-delete-bin-line")) : (o.classList.add("hidden"), o.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (o.classList.remove("hidden"), o.classList.add("ri-delete-bin-line"), o.classList.remove("ri-arrow-go-back-line")); }); - const s = t.querySelector('input[name="items_id[]"]'), n = s ? s.value.trim() : ""; - n && (e ? this._ensureRemovalInput(n) : this._removeRemovalInput(n)), t.querySelectorAll("[data-field]").forEach((a) => { - a.disabled = e; + const n = t.querySelector('input[name="items_id[]"]'), r = n ? n.value.trim() : ""; + r && (e ? this._ensureRemovalInput(r) : this._removeRemovalInput(r)), t.querySelectorAll("[data-field]").forEach((o) => { + o.disabled = e; }); } _setRowMode(t, e) { - const i = t.querySelector(`.${Ft}`), s = t.querySelector(`.${Vt}`); - !i || !s || (e === "edit" ? (i.classList.add("hidden"), s.classList.remove("hidden")) : (i.classList.remove("hidden"), s.classList.add("hidden"), this._syncSummary(t))); + const i = t.querySelector(`.${Tc}`), n = t.querySelector(`.${wc}`); + !i || !n || (e === "edit" ? (i.classList.add("hidden"), n.classList.remove("hidden")) : (i.classList.remove("hidden"), n.classList.add("hidden"), this._syncSummary(t))); } _captureAllOriginals() { - this.querySelectorAll(`.${b}`).forEach((t) => { + this.querySelectorAll(`.${nt}`).forEach((t) => { this._captureOriginalValues(t); }); } @@ -2260,27 +7815,27 @@ class Ut extends HTMLElement { }), this._syncSummary(t); } _refreshRowIds() { - Array.from(this.querySelectorAll(`.${b}`)).forEach((e, i) => { + Array.from(this.querySelectorAll(`.${nt}`)).forEach((e, i) => { this._assignRowFieldIds(e, i); }); } _rowIndex(t) { - return Array.from(this.querySelectorAll(`.${b}`)).indexOf(t); + return Array.from(this.querySelectorAll(`.${nt}`)).indexOf(t); } _assignRowFieldIds(t, e) { e < 0 || t.querySelectorAll("[data-field-label]").forEach((i) => { - const s = i.getAttribute("data-field-label"); - if (!s) - return; - const n = t.querySelector(`[data-field="${s}"]`); + const n = i.getAttribute("data-field-label"); if (!n) return; - const a = `${this._idPrefix}-${e}-${s}`; - n.id = a, i.setAttribute("for", a); + const r = t.querySelector(`[data-field="${n}"]`); + if (!r) + return; + const o = `${this._idPrefix}-${e}-${n}`; + r.id = o, i.setAttribute("for", o); }); } _syncAllSummaries() { - this.querySelectorAll(`.${b}`).forEach((t) => { + this.querySelectorAll(`.${nt}`).forEach((t) => { this._wireSummarySync(t), this._syncSummary(t), this._syncNewBadge(t); }); } @@ -2294,17 +7849,17 @@ class Ut extends HTMLElement { const i = e.getAttribute("data-summary-field"); if (!i) return; - const s = t.querySelector(`[data-field="${i}"]`); - if (!s) + const n = t.querySelector(`[data-field="${i}"]`); + if (!n) return; - const n = this._readFieldValue(s), a = e.getAttribute("data-summary-hide-empty") === "true" ? e.closest("[data-summary-container]") : null; - n ? (this._setSummaryContent(e, n), e.classList.remove("text-gray-400"), a && a.classList.remove("hidden")) : (this._setSummaryContent(e, "—"), e.classList.add("text-gray-400"), a && a.classList.add("hidden")); + const r = this._readFieldValue(n), o = e.getAttribute("data-summary-hide-empty") === "true" ? e.closest("[data-summary-container]") : null; + r ? (this._setSummaryContent(e, r), e.classList.remove("text-gray-400"), o && o.classList.remove("hidden")) : (this._setSummaryContent(e, "—"), e.classList.add("text-gray-400"), o && o.classList.add("hidden")); }), this._syncNewBadge(t); } _syncNewBadge(t) { const e = t.querySelector('input[name="items_id[]"]'), i = e ? e.value.trim() : ""; - t.querySelectorAll("[data-new-badge]").forEach((s) => { - s.classList.toggle("hidden", i !== ""); + t.querySelectorAll("[data-new-badge]").forEach((n) => { + n.classList.toggle("hidden", i !== ""); }); } _setSummaryContent(t, e) { @@ -2321,35 +7876,35 @@ class Ut extends HTMLElement { return t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement ? t.value.trim() : ""; } _ensureRemovalInput(t) { - if (Array.from(this.querySelectorAll(`input[name="${Q}"]`)).some( - (s) => s.value === t + if (Array.from(this.querySelectorAll(`input[name="${sn}"]`)).some( + (n) => n.value === t )) return; const i = document.createElement("input"); - i.type = "hidden", i.name = Q, i.value = t, this.appendChild(i); + i.type = "hidden", i.name = sn, i.value = t, this.appendChild(i); } _removeRemovalInput(t) { - const e = Array.from(this.querySelectorAll(`input[name="${Q}"]`)); + const e = Array.from(this.querySelectorAll(`input[name="${sn}"]`)); for (const i of e) i.value === t && i.remove(); } } -const zt = "ssr-wrapper", Te = "ssr-input", ke = "ssr-list", Kt = "ssr-option", Wt = "ssr-option-name", jt = "ssr-option-detail", Gt = "ssr-option-bio", Re = "ssr-hidden-input", Oe = "ssr-clear-button", Y = 1, X = 10, Jt = 250; -class Qt extends HTMLElement { +const Ic = "ssr-wrapper", mr = "ssr-input", gr = "ssr-list", Rc = "ssr-option", Dc = "ssr-option-name", Oc = "ssr-option-detail", Mc = "ssr-option-bio", pr = "ssr-hidden-input", fr = "ssr-clear-button", rn = 1, on = 10, Bc = 250; +class Nc extends HTMLElement { constructor() { - super(), this._endpoint = "", this._resultKey = "items", this._minChars = Y, this._limit = X, this._placeholder = "Search...", this._options = [], this._selected = null, this._highlightedIndex = -1, this._fetchTimeout = null, this._fetchController = null, this._listVisible = !1, this._boundHandleInput = this._handleInput.bind(this), this._boundHandleFocus = this._handleFocus.bind(this), this._boundHandleKeyDown = this._handleKeyDown.bind(this), this._boundHandleClear = this._handleClear.bind(this), this._boundHandleClickOutside = this._handleClickOutside.bind(this); + super(), this._endpoint = "", this._resultKey = "items", this._minChars = rn, this._limit = on, this._placeholder = "Search...", this._options = [], this._selected = null, this._highlightedIndex = -1, this._fetchTimeout = null, this._fetchController = null, this._listVisible = !1, this._boundHandleInput = this._handleInput.bind(this), this._boundHandleFocus = this._handleFocus.bind(this), this._boundHandleKeyDown = this._handleKeyDown.bind(this), this._boundHandleClear = this._handleClear.bind(this), this._boundHandleClickOutside = this._handleClickOutside.bind(this); } static get observedAttributes() { return ["data-endpoint", "data-result-key", "data-minchars", "data-limit", "placeholder", "name"]; } connectedCallback() { - this._render(), this._input = this.querySelector(`.${Te}`), this._list = this.querySelector(`.${ke}`), this._hiddenInput = this.querySelector(`.${Re}`), this._clearButton = this.querySelector(`.${Oe}`), this._endpoint = this.getAttribute("data-endpoint") || "", this._resultKey = this.getAttribute("data-result-key") || "items", this._minChars = this._parsePositiveInt(this.getAttribute("data-minchars"), Y), this._limit = this._parsePositiveInt(this.getAttribute("data-limit"), X), this._placeholder = this.getAttribute("placeholder") || "Search...", this._input && (this._input.placeholder = this._placeholder, this._input.addEventListener("input", this._boundHandleInput), this._input.addEventListener("focus", this._boundHandleFocus), this._input.addEventListener("keydown", this._boundHandleKeyDown)), this._clearButton && this._clearButton.addEventListener("click", this._boundHandleClear), document.addEventListener("click", this._boundHandleClickOutside); + this._render(), this._input = this.querySelector(`.${mr}`), this._list = this.querySelector(`.${gr}`), this._hiddenInput = this.querySelector(`.${pr}`), this._clearButton = this.querySelector(`.${fr}`), this._endpoint = this.getAttribute("data-endpoint") || "", this._resultKey = this.getAttribute("data-result-key") || "items", this._minChars = this._parsePositiveInt(this.getAttribute("data-minchars"), rn), this._limit = this._parsePositiveInt(this.getAttribute("data-limit"), on), this._placeholder = this.getAttribute("placeholder") || "Search...", this._input && (this._input.placeholder = this._placeholder, this._input.addEventListener("input", this._boundHandleInput), this._input.addEventListener("focus", this._boundHandleFocus), this._input.addEventListener("keydown", this._boundHandleKeyDown)), this._clearButton && this._clearButton.addEventListener("click", this._boundHandleClear), document.addEventListener("click", this._boundHandleClickOutside); } disconnectedCallback() { document.removeEventListener("click", this._boundHandleClickOutside), this._input && (this._input.removeEventListener("input", this._boundHandleInput), this._input.removeEventListener("focus", this._boundHandleFocus), this._input.removeEventListener("keydown", this._boundHandleKeyDown)), this._clearButton && this._clearButton.removeEventListener("click", this._boundHandleClear); } attributeChangedCallback(t, e, i) { - e !== i && (t === "data-endpoint" && (this._endpoint = i || ""), t === "data-result-key" && (this._resultKey = i || "items"), t === "data-minchars" && (this._minChars = this._parsePositiveInt(i, Y)), t === "data-limit" && (this._limit = this._parsePositiveInt(i, X)), t === "placeholder" && (this._placeholder = i || "Search...", this._input && (this._input.placeholder = this._placeholder)), t === "name" && this._hiddenInput && (this._hiddenInput.name = i || "")); + e !== i && (t === "data-endpoint" && (this._endpoint = i || ""), t === "data-result-key" && (this._resultKey = i || "items"), t === "data-minchars" && (this._minChars = this._parsePositiveInt(i, rn)), t === "data-limit" && (this._limit = this._parsePositiveInt(i, on)), t === "placeholder" && (this._placeholder = i || "Search...", this._input && (this._input.placeholder = this._placeholder)), t === "name" && this._hiddenInput && (this._hiddenInput.name = i || "")); } _handleInput(t) { const e = t.target.value.trim(); @@ -2400,7 +7955,7 @@ class Qt extends HTMLElement { _debouncedFetch(t) { this._fetchTimeout && clearTimeout(this._fetchTimeout), this._fetchTimeout = setTimeout(() => { this._fetchOptions(t); - }, Jt); + }, Bc); } async _fetchOptions(t) { if (!this._endpoint) @@ -2412,13 +7967,13 @@ class Qt extends HTMLElement { const i = await fetch(e.toString(), { signal: this._fetchController.signal }); if (!i.ok) return; - const s = await i.json(); - let a = (Array.isArray(s == null ? void 0 : s[this._resultKey]) ? s[this._resultKey] : []).filter((l) => l && l.id && l.name); + const n = await i.json(); + let o = (Array.isArray(n == null ? void 0 : n[this._resultKey]) ? n[this._resultKey] : []).filter((a) => a && a.id && a.name); if (this._excludeIds && Array.isArray(this._excludeIds)) { - const l = new Set(this._excludeIds); - a = a.filter((o) => !l.has(o.id)); + const a = new Set(this._excludeIds); + o = o.filter((c) => !a.has(c.id)); } - this._options = a, this._highlightedIndex = this._options.length > 0 ? 0 : -1, this._renderOptions(), this._options.length > 0 ? this._showList() : this._hideList(); + this._options = o, this._highlightedIndex = this._options.length > 0 ? 0 : -1, this._renderOptions(), this._options.length > 0 ? this._showList() : this._hideList(); } catch (i) { if ((i == null ? void 0 : i.name) === "AbortError") return; @@ -2428,19 +7983,19 @@ class Qt extends HTMLElement { this._list && (this._list.innerHTML = "", this._options.forEach((t) => { const e = document.createElement("button"); e.type = "button", e.setAttribute("data-index", String(this._options.indexOf(t))), e.className = [ - Kt, + Rc, "w-full text-left px-3 py-2 hover:bg-slate-100 transition-colors" ].join(" "); - const s = this._options.indexOf(t) === this._highlightedIndex; - e.classList.toggle("bg-slate-100", s), e.classList.toggle("text-gray-900", s), e.setAttribute("aria-selected", s ? "true" : "false"); - const n = document.createElement("div"); - if (n.className = [Wt, "text-sm font-semibold text-gray-800"].join(" "), n.textContent = t.name, e.appendChild(n), t.detail) { - const a = document.createElement("div"); - a.className = [jt, "text-xs text-gray-600"].join(" "), a.textContent = t.detail, e.appendChild(a); + const n = this._options.indexOf(t) === this._highlightedIndex; + e.classList.toggle("bg-slate-100", n), e.classList.toggle("text-gray-900", n), e.setAttribute("aria-selected", n ? "true" : "false"); + const r = document.createElement("div"); + if (r.className = [Dc, "text-sm font-semibold text-gray-800"].join(" "), r.textContent = t.name, e.appendChild(r), t.detail) { + const o = document.createElement("div"); + o.className = [Oc, "text-xs text-gray-600"].join(" "), o.textContent = t.detail, e.appendChild(o); } if (t.bio) { - const a = document.createElement("div"); - a.className = [Gt, "text-xs text-gray-500"].join(" "), a.textContent = t.bio, e.appendChild(a); + const o = document.createElement("div"); + o.className = [Mc, "text-xs text-gray-500"].join(" "), o.textContent = t.bio, e.appendChild(o); } e.addEventListener("click", () => { this._selectOption(t); @@ -2489,29 +8044,29 @@ class Qt extends HTMLElement { _render() { const t = this.getAttribute("name") || ""; this.innerHTML = ` -
    +
    -
    - - + +
    `; } } -const Yt = "Bevorzugter Reihentitel"; -class Xt extends HTMLElement { +const Pc = "Bevorzugter Reihentitel"; +class Fc extends HTMLElement { constructor() { super(), this._pendingAgent = null, this._form = null, this._saveButton = null, this._resetButton = null, this._deleteButton = null, this._deleteDialog = null, this._deleteConfirmButton = null, this._deleteCancelButton = null, this._statusEl = null, this._saveEndpoint = "", this._deleteEndpoint = "", this._isSaving = !1, this._handleSaveClick = this._handleSaveClick.bind(this), this._handleResetClick = this._handleResetClick.bind(this), this._handleDeleteClick = this._handleDeleteClick.bind(this), this._handleDeleteConfirmClick = this._handleDeleteConfirmClick.bind(this), this._handleDeleteCancelClick = this._handleDeleteCancelClick.bind(this); } @@ -2546,8 +8101,8 @@ class Xt extends HTMLElement { if (!t) return; const e = () => { - const s = this._parseJSONAttr(t, "data-initial-options") || [], n = this._parseJSONAttr(t, "data-initial-values") || []; - s.length > 0 && typeof t.setOptions == "function" && t.setOptions(s), n.length > 0 && (t.value = n, typeof t.captureInitialSelection == "function" && t.captureInitialSelection()); + const n = this._parseJSONAttr(t, "data-initial-options") || [], r = this._parseJSONAttr(t, "data-initial-values") || []; + n.length > 0 && typeof t.setOptions == "function" && t.setOptions(n), r.length > 0 && (t.value = r, typeof t.captureInitialSelection == "function" && t.captureInitialSelection()); }; if (typeof t.setOptions == "function") { e(); @@ -2588,21 +8143,21 @@ class Xt extends HTMLElement { }, body: JSON.stringify(e) }); - let s = null; + let n = null; try { - s = await i.clone().json(); + n = await i.clone().json(); } catch { - s = null; + n = null; } if (!i.ok) { - const n = (s == null ? void 0 : s.error) || `Speichern fehlgeschlagen (${i.status}).`; - throw new Error(n); + const r = (n == null ? void 0 : n.error) || `Speichern fehlgeschlagen (${i.status}).`; + throw new Error(r); } - if (s != null && s.redirect) { - window.location.assign(s.redirect); + if (n != null && n.redirect) { + window.location.assign(n.redirect); return; } - await this._reloadForm((s == null ? void 0 : s.message) || "Änderungen gespeichert."), this._clearStatus(); + await this._reloadForm((n == null ? void 0 : n.message) || "Änderungen gespeichert."), this._clearStatus(); } catch (i) { this._showStatus(i instanceof Error ? i.message : "Speichern fehlgeschlagen.", "error"); } finally { @@ -2632,7 +8187,7 @@ class Xt extends HTMLElement { const e = new FormData(this._form), i = { csrf_token: this._readValue(e, "csrf_token"), last_edited: this._readValue(e, "last_edited") - }, s = await fetch(this._deleteEndpoint, { + }, n = await fetch(this._deleteEndpoint, { method: "POST", headers: { "Content-Type": "application/json", @@ -2640,18 +8195,18 @@ class Xt extends HTMLElement { }, body: JSON.stringify(i) }); - let n = null; + let r = null; try { - n = await s.clone().json(); + r = await n.clone().json(); } catch { - n = null; + r = null; } - if (!s.ok) { - const l = (n == null ? void 0 : n.error) || `Löschen fehlgeschlagen (${s.status}).`; - throw new Error(l); + if (!n.ok) { + const a = (r == null ? void 0 : r.error) || `Löschen fehlgeschlagen (${n.status}).`; + throw new Error(a); } - const a = (n == null ? void 0 : n.redirect) || "/suche/baende"; - window.location.assign(a); + const o = (r == null ? void 0 : r.redirect) || "/suche/baende"; + window.location.assign(o); } catch (e) { this._showStatus(e instanceof Error ? e.message : "Löschen fehlgeschlagen.", "error"); } finally { @@ -2685,110 +8240,110 @@ class Xt extends HTMLElement { const i = this._readValue(t, "year"); if (i === "") throw new Error("Jahr muss angegeben werden (0 ist erlaubt)."); - const s = Number.parseInt(i, 10); - if (Number.isNaN(s)) + const n = Number.parseInt(i, 10); + if (Number.isNaN(n)) throw new Error("Jahr ist ungültig."); - e.year = s; - const n = t.getAll("languages[]").map((p) => p.trim()).filter(Boolean), a = t.getAll("places[]").map((p) => p.trim()).filter(Boolean), { items: l, removedIds: o } = this._collectItems(t), { - relations: d, - deleted: c + e.year = n; + const r = t.getAll("languages[]").map((N) => N.trim()).filter(Boolean), o = t.getAll("places[]").map((N) => N.trim()).filter(Boolean), { items: a, removedIds: c } = this._collectItems(t), { + relations: h, + deleted: d } = this._collectRelations(t, { prefix: "entries_series", targetField: "series" - }), h = this._collectNewRelations("entries_series"), m = [...d, ...h].filter( - (p) => p.type === Yt + }), m = this._collectNewRelations("entries_series"), p = [...h, ...m].filter( + (N) => N.type === Pc ).length; - if (m === 0) + if (p === 0) throw new Error("Mindestens ein bevorzugter Reihentitel muss verknüpft sein."); - if (m > 1) + if (p > 1) throw new Error("Es darf nur ein bevorzugter Reihentitel gesetzt sein."); const { - relations: u, - deleted: _ + relations: f, + deleted: C } = this._collectRelations(t, { prefix: "entries_agents", targetField: "agent" - }), E = this._collectNewRelations("entries_agents"), v = [...d, ...h].map((p) => p.target_id); - if (v.filter((p, H) => v.indexOf(p) !== H).length > 0) + }), L = this._collectNewRelations("entries_agents"), j = [...h, ...m].map((N) => N.target_id); + if (j.filter((N, O) => j.indexOf(N) !== O).length > 0) throw new Error("Doppelte Reihenverknüpfungen sind nicht erlaubt."); return { csrf_token: this._readValue(t, "csrf_token"), last_edited: this._readValue(t, "last_edited"), entry: e, - languages: n, - places: a, - items: l, - deleted_item_ids: o, - series_relations: d, - new_series_relations: h, - deleted_series_relation_ids: c, - agent_relations: u, - new_agent_relations: E, - deleted_agent_relation_ids: _ + languages: r, + places: o, + items: a, + deleted_item_ids: c, + series_relations: h, + new_series_relations: m, + deleted_series_relation_ids: d, + agent_relations: f, + new_agent_relations: L, + deleted_agent_relation_ids: C }; } _collectItems(t) { - const e = t.getAll("items_id[]").map((h) => h.trim()), i = t.getAll("items_owner[]"), s = t.getAll("items_identifier[]"), n = t.getAll("items_location[]"), a = t.getAll("items_media[]"), l = t.getAll("items_annotation[]"), o = t.getAll("items_uri[]"), d = new Set( - t.getAll("items_removed[]").map((h) => h.trim()).filter(Boolean) - ), c = []; - for (let h = 0; h < e.length; h += 1) { - const m = e[h] || ""; - if (m && d.has(m)) + const e = t.getAll("items_id[]").map((m) => m.trim()), i = t.getAll("items_owner[]"), n = t.getAll("items_identifier[]"), r = t.getAll("items_location[]"), o = t.getAll("items_media[]"), a = t.getAll("items_annotation[]"), c = t.getAll("items_uri[]"), h = new Set( + t.getAll("items_removed[]").map((m) => m.trim()).filter(Boolean) + ), d = []; + for (let m = 0; m < e.length; m += 1) { + const p = e[m] || ""; + if (p && h.has(p)) continue; - const u = (i[h] || "").trim(), _ = (s[h] || "").trim(), E = (n[h] || "").trim(), S = (l[h] || "").trim(), v = (o[h] || "").trim(), f = (a[h] || "").trim(); - (m || u || _ || E || S || v || f) && c.push({ - id: m, - owner: u, - identifier: _, - location: E, - annotation: S, - uri: v, - media: f ? [f] : [] + const f = (i[m] || "").trim(), C = (n[m] || "").trim(), L = (r[m] || "").trim(), U = (a[m] || "").trim(), j = (c[m] || "").trim(), q = (o[m] || "").trim(); + (p || f || C || L || U || j || q) && d.push({ + id: p, + owner: f, + identifier: C, + location: L, + annotation: U, + uri: j, + media: q ? [q] : [] }); } return { - items: c, - removedIds: Array.from(d) + items: d, + removedIds: Array.from(h) }; } _collectRelations(t, { prefix: e, targetField: i }) { - const s = [], n = []; - for (const [a, l] of t.entries()) { - if (!a.startsWith(`${e}_id[`)) + const n = [], r = []; + for (const [o, a] of t.entries()) { + if (!o.startsWith(`${e}_id[`)) continue; - const o = a.slice(a.indexOf("[") + 1, -1), d = `${e}_${i}[${o}]`, c = `${e}_type[${o}]`, h = `${e}_delete[${o}]`, m = `${e}_uncertain[${o}]`, u = (l || "").trim(), _ = (t.get(d) || "").trim(); - if (!_ || !u) + const c = o.slice(o.indexOf("[") + 1, -1), h = `${e}_${i}[${c}]`, d = `${e}_type[${c}]`, m = `${e}_delete[${c}]`, p = `${e}_uncertain[${c}]`, f = (a || "").trim(), C = (t.get(h) || "").trim(); + if (!C || !f) continue; - if (t.has(h)) { - n.push(u); + if (t.has(m)) { + r.push(f); continue; } - const E = (t.get(c) || "").trim(); - s.push({ - id: u, - target_id: _, - type: E, - uncertain: t.has(m) + const L = (t.get(d) || "").trim(); + n.push({ + id: f, + target_id: C, + type: L, + uncertain: t.has(p) }); } - return { relations: s, deleted: n }; + return { relations: n, deleted: r }; } _collectNewRelations(t) { const e = this.querySelector(`relations-editor[data-prefix='${t}']`); if (!e) return []; - const i = e.querySelectorAll("[data-role='relation-add-row'] [data-rel-row]"), s = []; - return i.forEach((n) => { - const a = n.querySelector(`input[name='${t}_new_id']`), l = n.querySelector(`select[name='${t}_new_type']`), o = n.querySelector(`input[name='${t}_new_uncertain']`); - if (!a) + const i = e.querySelectorAll("[data-role='relation-add-row'] [data-rel-row]"), n = []; + return i.forEach((r) => { + const o = r.querySelector(`input[name='${t}_new_id']`), a = r.querySelector(`select[name='${t}_new_type']`), c = r.querySelector(`input[name='${t}_new_uncertain']`); + if (!o) return; - const d = a.value.trim(); - d && s.push({ - target_id: d, - type: ((l == null ? void 0 : l.value) || "").trim(), - uncertain: !!(o != null && o.checked) + const h = o.value.trim(); + h && n.push({ + target_id: h, + type: ((a == null ? void 0 : a.value) || "").trim(), + uncertain: !!(c != null && c.checked) }); - }), s; + }), n; } _readValue(t, e) { const i = t.get(e); @@ -2818,22 +8373,22 @@ class Xt extends HTMLElement { }); if (!i.ok) throw new Error("Formular konnte nicht aktualisiert werden."); - const s = await i.text(), a = new DOMParser().parseFromString(s, "text/html"), l = a.querySelector("#changealmanachform"), o = this.querySelector("#changealmanachform"); - if (!l || !o) + const n = await i.text(), o = new DOMParser().parseFromString(n, "text/html"), a = o.querySelector("#changealmanachform"), c = this.querySelector("#changealmanachform"); + if (!a || !c) throw new Error("Formular konnte nicht geladen werden."); - o.replaceWith(l), this._form = l; - const d = a.querySelector("#user-message"), c = this.querySelector("#user-message"); - d && c && c.replaceWith(d); - const h = a.querySelector("#almanach-header-data"), m = this.querySelector("#almanach-header-data"); - h && m && m.replaceWith(h), this._initForm(), this._initPlaces(), this._initSaveHandling(), typeof window.TextareaAutoResize == "function" && setTimeout(() => { - this.querySelectorAll("textarea").forEach((u) => { - window.TextareaAutoResize(u); + c.replaceWith(a), this._form = a; + const h = o.querySelector("#user-message"), d = this.querySelector("#user-message"); + h && d && d.replaceWith(h); + const m = o.querySelector("#almanach-header-data"), p = this.querySelector("#almanach-header-data"); + m && p && p.replaceWith(m), this._initForm(), this._initPlaces(), this._initSaveHandling(), typeof window.TextareaAutoResize == "function" && setTimeout(() => { + this.querySelectorAll("textarea").forEach((f) => { + window.TextareaAutoResize(f); }); }, 100); } } -const Zt = "[data-role='relation-add-toggle']", ei = "[data-role='relation-add-panel']", ti = "[data-role='relation-add-close']", ii = "[data-role='relation-add-apply']", si = "[data-role='relation-add-error']", ni = "[data-role='relation-add-row']", ai = "[data-role='relation-add-select']", ri = "[data-role='relation-type-select']", li = "[data-role='relation-uncertain']", oi = "template[data-role='relation-new-template']", di = "[data-role='relation-new-delete']", T = "[data-rel-row]"; -class hi extends HTMLElement { +const qc = "[data-role='relation-add-toggle']", Hc = "[data-role='relation-add-panel']", $c = "[data-role='relation-add-close']", Uc = "[data-role='relation-add-apply']", jc = "[data-role='relation-add-error']", Vc = "[data-role='relation-add-row']", Wc = "[data-role='relation-add-select']", zc = "[data-role='relation-type-select']", Kc = "[data-role='relation-uncertain']", Gc = "template[data-role='relation-new-template']", Jc = "[data-role='relation-new-delete']", de = "[data-rel-row]"; +class Yc extends HTMLElement { constructor() { super(), this._pendingItem = null, this._pendingApply = !1; } @@ -2843,11 +8398,11 @@ class hi extends HTMLElement { _getExistingIds() { const t = /* @__PURE__ */ new Set(), e = this._prefix === "entries_series" ? "series" : "agent"; return this.querySelectorAll(`input[name^="${this._prefix}_${e}["]`).forEach((i) => { - const s = i.value.trim(); - s && t.add(s); + const n = i.value.trim(); + n && t.add(n); }), this._addRow && this._addRow.querySelectorAll(`input[name="${this._prefix}_new_id"]`).forEach((i) => { - const s = i.value.trim(); - s && t.add(s); + const n = i.value.trim(); + n && t.add(n); }), t; } _updateEmptyTextVisibility() { @@ -2857,11 +8412,11 @@ class hi extends HTMLElement { this._addPanel && !this._addPanel.classList.contains("hidden") || e || i ? this._emptyText.classList.add("hidden") : this._emptyText.classList.remove("hidden"); } _setupAddPanel() { - if (this._addToggle = this.querySelector(Zt), this._addToggleId) { + if (this._addToggle = this.querySelector(qc), this._addToggleId) { const t = document.getElementById(this._addToggleId); t && (this._addToggle = t); } - this._addPanel = this.querySelector(ei), this._addClose = this.querySelector(ti), this._addApply = this.querySelector(ii), this._addError = this.querySelector(si), this._addRow = this.querySelector(ni), this._addSelect = this.querySelector(ai), this._typeSelect = this.querySelector(ri), this._uncertain = this.querySelector(li), this._template = this.querySelector(oi), this._addInput = this._addSelect ? this._addSelect.querySelector(".ssr-input") : null, !(!this._addPanel || !this._addRow || !this._addSelect || !this._typeSelect || !this._uncertain || !this._template) && (this._addSelect && this._prefix === "entries_series" && this._addSelect.addEventListener("ssrbeforefetch", () => { + this._addPanel = this.querySelector(Hc), this._addClose = this.querySelector($c), this._addApply = this.querySelector(Uc), this._addError = this.querySelector(jc), this._addRow = this.querySelector(Vc), this._addSelect = this.querySelector(Wc), this._typeSelect = this.querySelector(zc), this._uncertain = this.querySelector(Kc), this._template = this.querySelector(Gc), this._addInput = this._addSelect ? this._addSelect.querySelector(".ssr-input") : null, !(!this._addPanel || !this._addRow || !this._addSelect || !this._typeSelect || !this._uncertain || !this._template) && (this._addSelect && this._prefix === "entries_series" && this._addSelect.addEventListener("ssrbeforefetch", () => { this._addSelect._excludeIds = Array.from(this._getExistingIds()); }), this._addToggle && this._addToggle.addEventListener("click", () => { const t = this._addPanel.classList.contains("hidden"); @@ -2899,31 +8454,31 @@ class hi extends HTMLElement { this._typeSelect && (this._typeSelect.selectedIndex = 0), this._uncertain && (this._uncertain.checked = !1), this._addError && this._addError.classList.add("hidden"); } _insertNewRow() { - const t = this._template.content.cloneNode(!0), e = t.querySelector(T) || t.firstElementChild; + const t = this._template.content.cloneNode(!0), e = t.querySelector(de) || t.firstElementChild; if (!e) return; const i = t.querySelector("[data-rel-link]"); i && i.setAttribute("href", `${this._linkBase}${this._pendingItem.id}`); - const s = t.querySelector("[data-rel-name]"); - s && (s.textContent = this._pendingItem.name || ""); - const n = t.querySelector("[data-rel-detail]"), a = t.querySelector("[data-rel-detail-container]"), l = this._pendingItem.detail || this._pendingItem.bio || ""; - n && l ? n.textContent = l : a && a.remove(); - const o = t.querySelector("[data-rel-new]"); - o && (o.textContent = this._newLabel); - const d = t.querySelector("[data-rel-input='type']"); - d && this._typeSelect && (d.innerHTML = this._typeSelect.innerHTML, d.value = this._typeSelect.value, d.name = `${this._prefix}_new_type`, d.addEventListener("change", () => this._updatePreferredOptions())); - const c = t.querySelector("[data-rel-input='uncertain']"); - if (c && this._uncertain) { - c.checked = this._uncertain.checked, c.name = `${this._prefix}_new_uncertain`; - const u = `${this._prefix}_new_uncertain_row`; - c.id = u; - const _ = t.querySelector("[data-rel-uncertain-label]"); - _ && _.setAttribute("for", u); + const n = t.querySelector("[data-rel-name]"); + n && (n.textContent = this._pendingItem.name || ""); + const r = t.querySelector("[data-rel-detail]"), o = t.querySelector("[data-rel-detail-container]"), a = this._pendingItem.detail || this._pendingItem.bio || ""; + r && a ? r.textContent = a : o && o.remove(); + const c = t.querySelector("[data-rel-new]"); + c && (c.textContent = this._newLabel); + const h = t.querySelector("[data-rel-input='type']"); + h && this._typeSelect && (h.innerHTML = this._typeSelect.innerHTML, h.value = this._typeSelect.value, h.name = `${this._prefix}_new_type`, h.addEventListener("change", () => this._updatePreferredOptions())); + const d = t.querySelector("[data-rel-input='uncertain']"); + if (d && this._uncertain) { + d.checked = this._uncertain.checked, d.name = `${this._prefix}_new_uncertain`; + const f = `${this._prefix}_new_uncertain_row`; + d.id = f; + const C = t.querySelector("[data-rel-uncertain-label]"); + C && C.setAttribute("for", f); } - const h = t.querySelector("[data-rel-input='id']"); - h && (h.name = `${this._prefix}_new_id`, h.value = this._pendingItem.id); - const m = t.querySelector(di); - m && m.addEventListener("click", () => { + const m = t.querySelector("[data-rel-input='id']"); + m && (m.name = `${this._prefix}_new_id`, m.value = this._pendingItem.id); + const p = t.querySelector(Jc); + p && p.addEventListener("click", () => { e.remove(), this._pendingItem = null, this._clearAddPanel(), this._addPanel && this._addPanel.classList.add("hidden"), this._updateEmptyTextVisibility(); }), this._addRow.appendChild(t), this._pendingItem = null, this._clearAddPanel(), this._addPanel && this._addPanel.classList.add("hidden"), this._updateEmptyTextVisibility(), this._updatePreferredOptions(); } @@ -2934,32 +8489,32 @@ class hi extends HTMLElement { if (!i) return; i.checked = !i.checked; - const s = t.closest(T); - s && (s.classList.toggle("bg-red-50", i.checked), s.querySelectorAll("select, input[type='checkbox']").forEach((o) => { - o !== i && (o.disabled = i.checked); + const n = t.closest(de); + n && (n.classList.toggle("bg-red-50", i.checked), n.querySelectorAll("select, input[type='checkbox']").forEach((c) => { + c !== i && (c.disabled = i.checked); })); - const n = t.matches(":hover"), a = t.querySelector("[data-delete-label]"); - if (a) { - let o; - i.checked && n ? o = a.getAttribute("data-delete-hover") || "Rückgängig" : i.checked ? o = a.getAttribute("data-delete-active") || "Wird entfernt" : o = a.getAttribute("data-delete-default") || "Entfernen", a.textContent = o; + const r = t.matches(":hover"), o = t.querySelector("[data-delete-label]"); + if (o) { + let c; + i.checked && r ? c = o.getAttribute("data-delete-hover") || "Rückgängig" : i.checked ? c = o.getAttribute("data-delete-active") || "Wird entfernt" : c = o.getAttribute("data-delete-default") || "Entfernen", o.textContent = c; } - const l = t.querySelector("i"); - l && (i.checked ? n ? (l.classList.remove("hidden"), l.classList.add("ri-arrow-go-back-line"), l.classList.remove("ri-delete-bin-line")) : (l.classList.add("hidden"), l.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (l.classList.remove("hidden"), l.classList.add("ri-delete-bin-line"), l.classList.remove("ri-arrow-go-back-line"))), this._updatePreferredOptions(); + const a = t.querySelector("i"); + a && (i.checked ? r ? (a.classList.remove("hidden"), a.classList.add("ri-arrow-go-back-line"), a.classList.remove("ri-delete-bin-line")) : (a.classList.add("hidden"), a.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (a.classList.remove("hidden"), a.classList.add("ri-delete-bin-line"), a.classList.remove("ri-arrow-go-back-line"))), this._updatePreferredOptions(); }), t.addEventListener("mouseenter", () => { const e = t.getAttribute("data-delete-toggle"), i = this.querySelector(`#${CSS.escape(e)}`); if (!i || !i.checked) return; - const s = t.querySelector("[data-delete-label]"); - s && (s.textContent = s.getAttribute("data-delete-hover") || "Rückgängig"); - const n = t.querySelector("i"); - n && (n.classList.remove("hidden"), n.classList.add("ri-arrow-go-back-line"), n.classList.remove("ri-delete-bin-line")); + const n = t.querySelector("[data-delete-label]"); + n && (n.textContent = n.getAttribute("data-delete-hover") || "Rückgängig"); + const r = t.querySelector("i"); + r && (r.classList.remove("hidden"), r.classList.add("ri-arrow-go-back-line"), r.classList.remove("ri-delete-bin-line")); }), t.addEventListener("mouseleave", () => { - const e = t.getAttribute("data-delete-toggle"), i = this.querySelector(`#${CSS.escape(e)}`), s = t.querySelector("[data-delete-label]"); - if (!s) + const e = t.getAttribute("data-delete-toggle"), i = this.querySelector(`#${CSS.escape(e)}`), n = t.querySelector("[data-delete-label]"); + if (!n) return; - i && i.checked ? s.textContent = s.getAttribute("data-delete-active") || "Wird entfernt" : s.textContent = s.getAttribute("data-delete-default") || "Entfernen"; - const n = t.querySelector("i"); - n && (i && i.checked ? (n.classList.add("hidden"), n.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (n.classList.remove("hidden"), n.classList.add("ri-delete-bin-line"), n.classList.remove("ri-arrow-go-back-line"))); + i && i.checked ? n.textContent = n.getAttribute("data-delete-active") || "Wird entfernt" : n.textContent = n.getAttribute("data-delete-default") || "Entfernen"; + const r = t.querySelector("i"); + r && (i && i.checked ? (r.classList.add("hidden"), r.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (r.classList.remove("hidden"), r.classList.add("ri-delete-bin-line"), r.classList.remove("ri-arrow-go-back-line"))); }); }); } @@ -2972,39 +8527,39 @@ class hi extends HTMLElement { if (this._prefix !== "entries_series" || !this._preferredLabel) return; const t = this._preferredLabel.trim(), e = []; - this.querySelectorAll(`select[name^="${this._prefix}_type["]`).forEach((s) => { - e.push({ select: s, row: s.closest(T), isAddPanel: !1 }); - }), this._addRow && this._addRow.querySelectorAll(`select[name='${this._prefix}_new_type']`).forEach((s) => { - e.push({ select: s, row: s.closest(T), isAddPanel: !1 }); - }), this._typeSelect && e.push({ select: this._typeSelect, row: this._typeSelect.closest(T), isAddPanel: !0 }); - const i = e.some(({ select: s, row: n, isAddPanel: a }) => { - if (a) + this.querySelectorAll(`select[name^="${this._prefix}_type["]`).forEach((n) => { + e.push({ select: n, row: n.closest(de), isAddPanel: !1 }); + }), this._addRow && this._addRow.querySelectorAll(`select[name='${this._prefix}_new_type']`).forEach((n) => { + e.push({ select: n, row: n.closest(de), isAddPanel: !1 }); + }), this._typeSelect && e.push({ select: this._typeSelect, row: this._typeSelect.closest(de), isAddPanel: !0 }); + const i = e.some(({ select: n, row: r, isAddPanel: o }) => { + if (o) return !1; - const l = ((s == null ? void 0 : s.value) || "").trim(); - if (!s || l !== t) + const a = ((n == null ? void 0 : n.value) || "").trim(); + if (!n || a !== t) return !1; - if (!n) + if (!r) return !0; - const o = n.querySelector(`input[name^="${this._prefix}_delete["]`); - return !(o && o.checked); + const c = r.querySelector(`input[name^="${this._prefix}_delete["]`); + return !(c && c.checked); }); - e.forEach(({ select: s, row: n, isAddPanel: a }) => { - if (!s) + e.forEach(({ select: n, row: r, isAddPanel: o }) => { + if (!n) return; - const l = Array.from(s.options).find((u) => u.value.trim() === t); - if (!l) + const a = Array.from(n.options).find((f) => f.value.trim() === t); + if (!a) return; - const o = n ? n.querySelector(`input[name^="${this._prefix}_delete["]`) : null, d = !!(o && o.checked), c = (s.value || "").trim(), h = !i || c === t && !d; - if (a && i && c === t) { - const u = Array.from(s.options).find((_) => _.value.trim() !== t); - u && (s.value = u.value); + const c = r ? r.querySelector(`input[name^="${this._prefix}_delete["]`) : null, h = !!(c && c.checked), d = (n.value || "").trim(), m = !i || d === t && !h; + if (o && i && d === t) { + const f = Array.from(n.options).find((C) => C.value.trim() !== t); + f && (n.value = f.value); } - const m = !h || a && i; - l.hidden = m, l.disabled = m, l.style.display = m ? "none" : ""; + const p = !m || o && i; + a.hidden = p, a.disabled = p, a.style.display = p ? "none" : ""; }); } } -class ci extends HTMLElement { +class Xc extends HTMLElement { connectedCallback() { setTimeout(() => { const t = this.querySelector("form"); @@ -3018,85 +8573,85 @@ class ci extends HTMLElement { const e = t.getAttribute("data-delete-endpoint"); if (!e) return; - const i = this.querySelector("[data-role='edit-delete-dialog']"), s = this.querySelector("[data-role='edit-delete']"), n = this.querySelector("[data-role='edit-delete-confirm']"), a = this.querySelector("[data-role='edit-delete-cancel']"); - if (!i || !s || !n || !a) + const i = this.querySelector("[data-role='edit-delete-dialog']"), n = this.querySelector("[data-role='edit-delete']"), r = this.querySelector("[data-role='edit-delete-confirm']"), o = this.querySelector("[data-role='edit-delete-cancel']"); + if (!i || !n || !r || !o) return; - s.addEventListener("click", (o) => { - o.preventDefault(), typeof i.showModal == "function" && i.showModal(); + n.addEventListener("click", (c) => { + c.preventDefault(), typeof i.showModal == "function" && i.showModal(); }); - const l = (o) => { - o && o.preventDefault(), i.open && i.close(); + const a = (c) => { + c && c.preventDefault(), i.open && i.close(); }; - a.addEventListener("click", l), i.addEventListener("cancel", l), n.addEventListener("click", async (o) => { - o.preventDefault(), l(); - const d = new FormData(t), c = { - csrf_token: d.get("csrf_token") || "", - last_edited: d.get("last_edited") || "" - }, h = await fetch(e, { + o.addEventListener("click", a), i.addEventListener("cancel", a), r.addEventListener("click", async (c) => { + c.preventDefault(), a(); + const h = new FormData(t), d = { + csrf_token: h.get("csrf_token") || "", + last_edited: h.get("last_edited") || "" + }, m = await fetch(e, { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, - body: JSON.stringify(c) + body: JSON.stringify(d) }); - if (!h.ok) + if (!m.ok) return; - const m = await h.json().catch(() => null), u = (m == null ? void 0 : m.redirect) || "/"; - window.location.assign(u); + const p = await m.json().catch(() => null), f = (p == null ? void 0 : p.redirect) || "/"; + window.location.assign(f); }); } } -class ui extends HTMLElement { +class Qc extends HTMLElement { constructor() { super(), this.state = null, this.handleClick = this.handleClick.bind(this), this.handleClickAway = this.handleClickAway.bind(this); } connectedCallback() { - const t = this.getAttribute("data-user-name") || "Benutzer", e = this.getAttribute("data-user-email") || "", i = this.getAttribute("data-user-id") || "", s = this.getAttribute("data-is-admin-or-editor") === "true", n = this.getAttribute("data-is-admin") === "true", a = this.getAttribute("data-redirect-path") || "", l = window.location.pathname; - let o = !1, d = "", c = !1, h = "", m = !1, u = ""; - const _ = l.match(/^\/reihe\/([^\/]+)\/?$/); - if (_ && _[1] !== "new") { - o = !0, d = _[1]; - const A = document.querySelector('meta[name="entity-updated"]'); - A && A.content; + const t = this.getAttribute("data-user-name") || "Benutzer", e = this.getAttribute("data-user-email") || "", i = this.getAttribute("data-user-id") || "", n = this.getAttribute("data-is-admin-or-editor") === "true", r = this.getAttribute("data-is-admin") === "true", o = this.getAttribute("data-redirect-path") || "", a = window.location.pathname; + let c = !1, h = "", d = !1, m = "", p = !1, f = ""; + const C = a.match(/^\/reihe\/([^\/]+)\/?$/); + if (C && C[1] !== "new") { + c = !0, h = C[1]; + const Et = document.querySelector('meta[name="entity-updated"]'); + Et && Et.content; } - const E = l.match(/^\/person\/([^\/]+)\/?$/); - E && E[1] !== "new" && (c = !0, h = E[1]); - const S = l.match(/^\/almanach\/([^\/]+)\/?$/); - if (S && S[1] !== "new") { - m = !0, u = S[1]; - const A = document.querySelector('meta[name="entity-updated"]'); - A && A.content; + const L = a.match(/^\/person\/([^\/]+)\/?$/); + L && L[1] !== "new" && (d = !0, m = L[1]); + const U = a.match(/^\/almanach\/([^\/]+)\/?$/); + if (U && U[1] !== "new") { + p = !0, f = U[1]; + const Et = document.querySelector('meta[name="entity-updated"]'); + Et && Et.content; } - const v = document.querySelector('input[name="csrf_token"]'); - v && v.value, this.hasContext = o || c || m; - let f = ""; - o ? f = ` + const j = document.querySelector('input[name="csrf_token"]'); + j && j.value, this.hasContext = c || d || p; + let q = ""; + c ? q = `
    Reihe
    - + Bearbeiten - ` : c ? f = ` + ` : d ? q = `
    Person
    - + Bearbeiten - ` : m && (f = ` + ` : p && (q = `
    Almanach
    - + Bearbeiten `); - const p = s ? ` + const N = n ? `
    Erstellen
    @@ -3137,7 +8692,7 @@ class ui extends HTMLElement {
    - ` : "", H = s ? ` + ` : "", O = n ? `
    Listen
    @@ -3169,43 +8724,43 @@ class ui extends HTMLElement {
    - ` : "", qe = n ? ` + ` : "", T = r ? `
    Administration
    - ` : "", He = f || "", Fe = f ? '
    ' : ""; + ` : "", tt = q || "", ct = q ? '
    ' : ""; this.innerHTML = `