Files
a.montask/public/vendor/rich-text-laravel/trix.esm.js
T
2026-04-23 14:49:46 +03:30

147 lines
199 KiB
JavaScript

var ko="2.1.16";var Rt="[data-trix-attachment]",yi={preview:{presentation:"gallery",caption:{name:!0,size:!0}},file:{caption:{size:!0}}},z={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(i){return $i(i.parentNode)===z[this.listAttribute].tagName}},numberList:{tagName:"ol",parse:!1},number:{tagName:"li",listAttribute:"numberList",group:!1,nestable:!0,test(i){return $i(i.parentNode)===z[this.listAttribute].tagName}},attachmentGallery:{tagName:"div",exclusive:!0,terminal:!0,parse:!1,group:!1}},$i=i=>{var t;return i==null||(t=i.tagName)===null||t===void 0?void 0:t.toLowerCase()},tr=navigator.userAgent.match(/android\s([0-9]+.*Chrome)/i),Ln=tr&&parseInt(tr[1]),Se={composesExistingText:/Android.*Chrome/.test(navigator.userAgent),recentAndroid:Ln&&Ln>12,samsungAndroid:Ln&&navigator.userAgent.match(/Android.*SM-/),forcesObjectResizing:/Trident.*rv:11/.test(navigator.userAgent),supportsInputEvents:typeof InputEvent<"u"&&["data","getTargetRanges","inputType"].every(i=>i in InputEvent.prototype)},Ro={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"},Nr={ADD_ATTR:["language"],SAFE_FOR_XML:!1,RETURN_DOM:!0},m={attachFiles:"Attach Files",bold:"Bold",bullets:"Bullets",byte:"Byte",bytes:"Bytes",captionPlaceholder:"Add a caption\u2026",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\u2026",GB:"GB",KB:"KB",MB:"MB",PB:"PB",TB:"TB"},Do=[m.bytes,m.KB,m.MB,m.GB,m.TB,m.PB],Br={prefix:"IEC",precision:2,formatter(i){switch(i){case 0:return"0 ".concat(m.bytes);case 1:return"1 ".concat(m.byte);default:let t;this.prefix==="SI"?t=1e3:this.prefix==="IEC"&&(t=1024);let e=Math.floor(Math.log(i)/Math.log(t)),o=(i/Math.pow(t,e)).toFixed(this.precision).replace(/0*$/,"").replace(/\.$/,"");return"".concat(o," ").concat(Do[e])}}},fn="\uFEFF",bt="\xA0",Ai="\uFFFC",_r=function(i){for(let t in i){let e=i[t];this[t]=e}return this},xi=document.documentElement,Lo=xi.matches,C=function(i){let{onElement:t,matchingSelector:e,withCallback:n,inPhase:r,preventDefault:o,times:s}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=t||xi,c=e,d=r==="capturing",g=function(x){s!=null&&--s===0&&g.destroy();let T=vt(x.target,{matchingSelector:c});T!=null&&(n?.call(T,x,T),o&&x.preventDefault())};return g.destroy=()=>l.removeEventListener(i,g,d),l.addEventListener(i,g,d),g},Oo=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t.times=1,C(i,t)},jr=function(i){let{bubbles:t,cancelable:e,attributes:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t=t!==!1,e=e!==!1;let r=document.createEvent("Events");return r.initEvent(i,t,e),n!=null&&_r.call(r,n),r},me=function(i){let{onElement:t,bubbles:e,cancelable:n,attributes:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=t??xi,s=jr(i,{bubbles:e,cancelable:n,attributes:r});return o.dispatchEvent(s)},Wr=function(i,t){if(i?.nodeType===1)return Lo.call(i,t)},vt=function(i){let{matchingSelector:t,untilNode:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};for(;i&&i.nodeType!==Node.ELEMENT_NODE;)i=i.parentNode;if(i!=null)if(t!=null){if(i.closest&&e==null)return i.closest(t);for(;i&&i!==e;){if(Wr(i,t))return i;i=i.parentNode}}else return i},Po=function(i){for(;(t=i)!==null&&t!==void 0&&t.firstElementChild;){var t;i=i.firstElementChild}return i},Ei=i=>document.activeElement!==i&&kt(i,document.activeElement),kt=function(i,t){if(!(!i||!t))for(;t;){if(t===i)return!0;t=t.parentNode}};var On=function(i){var t;if(!((t=i)!==null&&t!==void 0&&t.parentNode))return;let e=0;for(i=i.previousSibling;i;)e++,i=i.previousSibling;return e},yt=i=>{var t;return i==null||(t=i.parentNode)===null||t===void 0?void 0:t.removeChild(i)},He=function(i){let{onlyNodesOfType:t,usingFilter:e,expandEntityReferences:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=(()=>{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(i,r,e??null,n===!0)},W=i=>{var t;return i==null||(t=i.tagName)===null||t===void 0?void 0:t.toLowerCase()},p=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e,n;typeof i=="object"?(t=i,i=t.tagName):t={attributes:t};let r=document.createElement(i);if(t.editable!=null&&(t.attributes==null&&(t.attributes={}),t.attributes.contenteditable=t.editable),t.attributes)for(e in t.attributes)n=t.attributes[e],r.setAttribute(e,n);if(t.style)for(e in t.style)n=t.style[e],r.style[e]=n;if(t.data)for(e in t.data)n=t.data[e],r.dataset[e]=n;return t.className&&t.className.split(" ").forEach(o=>{r.classList.add(o)}),t.textContent&&(r.textContent=t.textContent),t.childNodes&&[].concat(t.childNodes).forEach(o=>{r.appendChild(o)}),r},se,pe=function(){if(se!=null)return se;se=[];for(let i in z){let t=z[i];t.tagName&&se.push(t.tagName)}return se},Pn=i=>Gt(i?.firstChild),Io=function(i){return pe().includes(W(i))&&!pe().includes(W(i.firstChild))},er=function(i){let{strict:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{strict:!0};return t?Gt(i):Gt(i)||!Gt(i.firstChild)&&Io(i)},Gt=i=>Mo(i)&&i?.data==="block",Mo=i=>i?.nodeType===Node.COMMENT_NODE,Kt=function(i){let{name:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!!i)if(be(i)){if(i.data===fn)return t?i.parentNode.dataset.trixCursorTarget===t:!0}else return Kt(i.firstChild)},Dt=i=>Wr(i,Rt),zr=i=>be(i)&&i?.data==="",be=i=>i?.nodeType===Node.TEXT_NODE,wi={level2Enabled:!0,getLevel(){return this.level2Enabled&&Se.supportsInputEvents?2:0},pickFiles(i){let t=p("input",{type:"file",multiple:!0,hidden:!0,id:this.fileInputId});t.addEventListener("change",()=>{i(t.files),yt(t)}),yt(document.getElementById(this.fileInputId)),document.body.appendChild(t),t.click()}},Fo={8:"backspace",9:"tab",13:"return",27:"escape",37:"left",39:"right",46:"delete",68:"d",72:"h",79:"o"},ze={removeBlankTableCells:!1,tableCellSeparator:" | ",tableRowSeparator:`
`},Lt={bold:{tagName:"strong",inheritable:!0,parser(i){let t=window.getComputedStyle(i);return t.fontWeight==="bold"||t.fontWeight>=600}},italic:{tagName:"em",inheritable:!0,parser(i){return window.getComputedStyle(i).fontStyle==="italic"}},href:{groupTagName:"a",parser(i){let t="a:not(".concat(Rt,")"),e=i.closest(t);if(e)return e.getAttribute("href")}},strike:{tagName:"del",inheritable:!0},frozen:{style:{backgroundColor:"highlight"}}},Ur={getDefaultHTML(){return`<div class="trix-button-row">
<span class="trix-button-group trix-button-group--text-tools" data-trix-button-group="text-tools">
<button type="button" class="trix-button trix-button--icon trix-button--icon-bold" data-trix-attribute="bold" data-trix-key="b" title="`.concat(m.bold,'" tabindex="-1">').concat(m.bold,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-italic" data-trix-attribute="italic" data-trix-key="i" title="`).concat(m.italic,'" tabindex="-1">').concat(m.italic,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-strike" data-trix-attribute="strike" title="`).concat(m.strike,'" tabindex="-1">').concat(m.strike,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-link" data-trix-attribute="href" data-trix-action="link" data-trix-key="k" title="`).concat(m.link,'" tabindex="-1">').concat(m.link,`</button>
</span>
<span class="trix-button-group trix-button-group--block-tools" data-trix-button-group="block-tools">
<button type="button" class="trix-button trix-button--icon trix-button--icon-heading-1" data-trix-attribute="heading1" title="`).concat(m.heading1,'" tabindex="-1">').concat(m.heading1,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-quote" data-trix-attribute="quote" title="`).concat(m.quote,'" tabindex="-1">').concat(m.quote,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-code" data-trix-attribute="code" title="`).concat(m.code,'" tabindex="-1">').concat(m.code,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-bullet-list" data-trix-attribute="bullet" title="`).concat(m.bullets,'" tabindex="-1">').concat(m.bullets,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-number-list" data-trix-attribute="number" title="`).concat(m.numbers,'" tabindex="-1">').concat(m.numbers,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-decrease-nesting-level" data-trix-action="decreaseNestingLevel" title="`).concat(m.outdent,'" tabindex="-1">').concat(m.outdent,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-increase-nesting-level" data-trix-action="increaseNestingLevel" title="`).concat(m.indent,'" tabindex="-1">').concat(m.indent,`</button>
</span>
<span class="trix-button-group trix-button-group--file-tools" data-trix-button-group="file-tools">
<button type="button" class="trix-button trix-button--icon trix-button--icon-attach" data-trix-action="attachFiles" title="`).concat(m.attachFiles,'" tabindex="-1">').concat(m.attachFiles,`</button>
</span>
<span class="trix-button-group-spacer"></span>
<span class="trix-button-group trix-button-group--history-tools" data-trix-button-group="history-tools">
<button type="button" class="trix-button trix-button--icon trix-button--icon-undo" data-trix-action="undo" data-trix-key="z" title="`).concat(m.undo,'" tabindex="-1">').concat(m.undo,`</button>
<button type="button" class="trix-button trix-button--icon trix-button--icon-redo" data-trix-action="redo" data-trix-key="shift+z" title="`).concat(m.redo,'" tabindex="-1">').concat(m.redo,`</button>
</span>
</div>
<div class="trix-dialogs" data-trix-dialogs>
<div class="trix-dialog trix-dialog--link" data-trix-dialog="href" data-trix-dialog-attribute="href">
<div class="trix-dialog__link-fields">
<input type="url" name="href" class="trix-input trix-input--dialog" placeholder="`).concat(m.urlPlaceholder,'" aria-label="').concat(m.url,`" data-trix-validate-href required data-trix-input>
<div class="trix-button-group">
<input type="button" class="trix-button trix-button--dialog" value="`).concat(m.link,`" data-trix-method="setAttribute">
<input type="button" class="trix-button trix-button--dialog" value="`).concat(m.unlink,`" data-trix-method="removeAttribute">
</div>
</div>
</div>
</div>`)}},ii={interval:5e3},Te=Object.freeze({__proto__:null,attachments:yi,blockAttributes:z,browser:Se,css:Ro,dompurify:Nr,fileSize:Br,input:wi,keyNames:Fo,lang:m,parser:ze,textAttributes:Lt,toolbar:Ur,undo:ii}),S=class{static proxyMethod(t){let{name:e,toMethod:n,toProperty:r,optional:o}=No(t);this.prototype[e]=function(){let s,l;if(n)if(o){var c;l=(c=this[n])===null||c===void 0?void 0:c.call(this)}else l=this[n]();else r&&(l=this[r]);if(o){var d;if(s=(d=l)===null||d===void 0?void 0:d[e],s)return nr.call(s,l,arguments)}else return s=l[e],nr.call(s,l,arguments)}}},No=function(i){let t=i.match(Bo);if(!t)throw new Error("can't parse @proxyMethod expression: ".concat(i));let e={name:t[4]};return t[2]!=null?e.toMethod=t[1]:e.toProperty=t[1],t[3]!=null&&(e.optional=!0),e},{apply:nr}=Function.prototype,Bo=new RegExp("^(.+?)(\\(\\))?(\\?)?\\.(.+?)$"),In,Mn,ir,Fn,Ot=class extends S{static box(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return t instanceof this?t:this.fromUCS2String(t?.toString())}static fromUCS2String(t){return new this(t,qe(t))}static fromCodepoints(t){return new this(Ge(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 Ge(this.codepoints.slice(0,Math.max(0,t))).length}offsetFromUCS2Offset(t){return qe(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}},_o=((In=Array.from)===null||In===void 0?void 0:In.call(Array,"\u{1F47C}").length)===1,jo=((Mn=(ir=" ").codePointAt)===null||Mn===void 0?void 0:Mn.call(ir,0))!=null,Wo=((Fn=String.fromCodePoint)===null||Fn===void 0?void 0:Fn.call(String,32,128124))===" \u{1F47C}",qe,Ge;_o&&jo?qe=i=>Array.from(i).map(t=>t.codePointAt(0)):qe=function(i){let t=[],e=0,{length:n}=i;for(;e<n;){let r=i.charCodeAt(e++);if(55296<=r&&r<=56319&&e<n){let o=i.charCodeAt(e++);(o&64512)===56320?r=((r&1023)<<10)+(o&1023)+65536:e--}t.push(r)}return t};Wo?Ge=i=>String.fromCodePoint(...Array.from(i||[])):Ge=function(i){return(()=>{let e=[];return Array.from(i).forEach(n=>{let r="";n>65535&&(n-=65536,r+=String.fromCharCode(n>>>10&1023|55296),n=56320|n&1023),e.push(r+String.fromCharCode(n))}),e})().join("")};var zo=0,dt=class extends S{static fromJSONString(t){return this.fromJSON(JSON.parse(t))}constructor(){super(...arguments),this.id=++zo}hasSameConstructorAs(t){return this.constructor===t?.constructor}isEqualTo(t){return this===t}inspect(){let t=[],e=this.contentsForInspection()||{};for(let n in e){let r=e[n];t.push("".concat(n,"=").concat(r))}return"#<".concat(this.constructor.name,":").concat(this.id).concat(t.length?" ".concat(t.join(", ")):"",">")}contentsForInspection(){}toJSONString(){return JSON.stringify(this)}toUTF16String(){return Ot.box(this)}getCacheKey(){return this.id.toString()}},Pt=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(i.length!==t.length)return!1;for(let e=0;e<i.length;e++)if(i[e]!==t[e])return!1;return!0},Uo=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return Pt(i.slice(0,t.length),t)},Ci=function(i){let t=i.slice(0);for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return t.splice(...n),t},Vo=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],e=[],n=[],r=new Set;i.forEach(s=>{r.add(s)});let o=new Set;return t.forEach(s=>{o.add(s),r.has(s)||e.push(s)}),i.forEach(s=>{o.has(s)||n.push(s)}),{added:e,removed:n}},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]/,qo=function(){let i=p("input",{dir:"auto",name:"x",dirName:"x.dir"}),t=p("textarea",{dir:"auto",name:"y",dirName:"y.dir"}),e=p("form");e.appendChild(i),e.appendChild(t);let n=function(){try{return new FormData(e).has(t.dirName)}catch{return!1}}(),r=function(){try{return i.matches(":dir(ltr),:dir(rtl)")}catch{return!1}}();return n?function(o){return t.value=o,new FormData(e).get(t.dirName)}:r?function(o){return i.value=o,i.matches(":dir(rtl)")?"rtl":"ltr"}:function(o){let s=o.trim().charAt(0);return Ho.test(s)?"rtl":"ltr"}}(),Nn=null,Bn=null,_n=null,Me=null,ri=()=>(Nn||(Nn=Ko().concat(Go())),Nn),D=i=>z[i],Go=()=>(Bn||(Bn=Object.keys(z)),Bn),oi=i=>Lt[i],Ko=()=>(_n||(_n=Object.keys(Lt)),_n),Jo=()=>{if(!Me){Me=[];for(let i in z){let{listAttribute:t}=z[i];t!=null&&Me.push(t)}}return Me},Vr=function(i,t){let e=Yo(i);e.textContent=t.replace(/%t/g,i)},Yo=function(i){let t=document.createElement("style");t.setAttribute("type","text/css"),t.setAttribute("data-tag-name",i.toLowerCase());let e=Xo();return e&&t.setAttribute("nonce",e),document.head.insertBefore(t,document.head.firstChild),t},Xo=function(){let i=rr("trix-csp-nonce")||rr("csp-nonce");if(i){let{nonce:t,content:e}=i;return t==""?e:t}},rr=i=>document.head.querySelector("meta[name=".concat(i,"]")),or={"application/x-trix-feature-detection":"test"},Hr=function(i){let t=i.getData("text/plain"),e=i.getData("text/html");if(t&&e){let{body:n}=new DOMParser().parseFromString(e,"text/html");if(n.textContent===t)return!n.querySelector("*")}else return t?.length},Zo=i=>{let{dataTransfer:t}=i;return t.types.includes("Files")&&t.types.includes("text/html")&&t.getData("text/html").includes("urn:schemas-microsoft-com:office:office")},Qo=function(i){if(!(i!=null&&i.setData))return!1;for(let t in or){let e=or[t];try{if(i.setData(t,e),!i.getData(t)===e)return!1}catch{return!1}}return!0},qr=function(){return/Mac|^iP/.test(navigator.platform)?i=>i.metaKey:i=>i.ctrlKey}();function $o(i){return/iPhone|iPad/.test(navigator.userAgent)?!i.inputType||i.inputType==="insertParagraph":!1}var Si=i=>setTimeout(i,1),Gr=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={};for(let e in i){let n=i[e];t[e]=n}return t},ee=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Object.keys(i).length!==Object.keys(t).length)return!1;for(let e in i)if(i[e]!==t[e])return!1;return!0},A=function(i){if(i!=null)return Array.isArray(i)||(i=[i,i]),[sr(i[0]),sr(i[1]!=null?i[1]:i[0])]},ut=function(i){if(i==null)return;let[t,e]=A(i);return si(t,e)},gn=function(i,t){if(i==null||t==null)return;let[e,n]=A(i),[r,o]=A(t);return si(e,r)&&si(n,o)},sr=function(i){return typeof i=="number"?i:Gr(i)},si=function(i,t){return typeof i=="number"?i===t:ee(i,t)},Ke=class extends S{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()}},It=new Ke,Kr=function(){let i=window.getSelection();if(i.rangeCount>0)return i},ve=function(){var i;let t=(i=Kr())===null||i===void 0?void 0:i.getRangeAt(0);if(t&&!ts(t))return t},Jr=function(i){let t=window.getSelection();return t.removeAllRanges(),t.addRange(i),It.update()},ts=i=>ar(i.startContainer)||ar(i.endContainer),ar=i=>!Object.getPrototypeOf(i),ge=i=>i.replace(new RegExp("".concat(fn),"g"),"").replace(new RegExp("".concat(bt),"g")," "),es=i=>i.replace(/\r\n?/g,`
`),Ti=new RegExp("[^\\S".concat(bt,"]")),ki=i=>i.replace(new RegExp("".concat(Ti.source),"g")," ").replace(/\ {2,}/g," "),ns=function(i,t){let e,n;return i=Ot.box(i),t=Ot.box(t),t.length<i.length?[n,e]=lr(i,t):[e,n]=lr(t,i),{added:e,removed:n}},lr=function(i,t){if(i.isEqualTo(t))return["",""];let e=jn(i,t),{length:n}=e.utf16String,r;if(n){let{offset:o}=e,s=i.codepoints.slice(0,o).concat(i.codepoints.slice(o+n));r=jn(t,Ot.fromCodepoints(s))}else r=jn(t,i);return[e.utf16String.toString(),r.utf16String.toString()]},jn=function(i,t){let e=0,n=i.length,r=t.length;for(;e<n&&i.charAt(e).isEqualTo(t.charAt(e));)e++;for(;n>e+1&&i.charAt(n-1).isEqualTo(t.charAt(r-1));)n--,r--;return{utf16String:i.slice(e,n),offset:e}},U=class extends dt{static fromCommonAttributesOfObjects(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];if(!t.length)return new this;let e=ae(t[0]),n=e.getKeys();return t.slice(1).forEach(r=>{n=e.getKeysCommonToHash(ae(r)),e=e.slice(n)}),e}static box(t){return ae(t)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(...arguments),this.values=Ue(t)}add(t,e){return this.merge(is(t,e))}remove(t){return new U(Ue(this.values,t))}get(t){return this.values[t]}has(t){return t in this.values}merge(t){return new U(rs(this.values,os(t)))}slice(t){let e={};return Array.from(t).forEach(n=>{this.has(n)&&(e[n]=this.values[n])}),new U(e)}getKeys(){return Object.keys(this.values)}getKeysCommonToHash(t){return t=ae(t),this.getKeys().filter(e=>this.values[e]===t.values[e])}isEqualTo(t){return Pt(this.toArray(),ae(t).toArray())}isEmpty(){return this.getKeys().length===0}toArray(){if(!this.array){let t=[];for(let e in this.values){let n=this.values[e];t.push(t.push(e,n))}this.array=t.slice(0)}return this.array}toObject(){return Ue(this.values)}toJSON(){return this.toObject()}contentsForInspection(){return{values:JSON.stringify(this.values)}}},is=function(i,t){let e={};return e[i]=t,e},rs=function(i,t){let e=Ue(i);for(let n in t){let r=t[n];e[n]=r}return e},Ue=function(i,t){let e={};return Object.keys(i).sort().forEach(r=>{r!==t&&(e[r]=i[r])}),e},ae=function(i){return i instanceof U?i:new U(i)},os=function(i){return i instanceof U?i.values:i},Ae=class{static groupObjects(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],{depth:e,asTree:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r;n&&e==null&&(e=0);let o=[];return Array.from(t).forEach(s=>{var l;if(r){var c,d,g;if((c=s.canBeGrouped)!==null&&c!==void 0&&c.call(s,e)&&(d=(g=r[r.length-1]).canBeGroupedWith)!==null&&d!==void 0&&d.call(g,s,e)){r.push(s);return}else o.push(new this(r,{depth:e,asTree:n})),r=null}(l=s.canBeGrouped)!==null&&l!==void 0&&l.call(s,e)?r=[s]:o.push(s)}),r&&o.push(new this(r,{depth:e,asTree:n})),o}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],{depth:e,asTree:n}=arguments.length>1?arguments[1]:void 0;this.objects=t,n&&(this.depth=e,this.objects=this.constructor.groupObjects(this.objects,{asTree:n,depth:this.depth+1}))}getObjects(){return this.objects}getDepth(){return this.depth}getCacheKey(){let t=["objectGroup"];return Array.from(this.getObjects()).forEach(e=>{t.push(e.getCacheKey())}),t.join("/")}},ai=class extends S{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];super(...arguments),this.objects={},Array.from(t).forEach(e=>{let n=JSON.stringify(e);this.objects[n]==null&&(this.objects[n]=e)})}find(t){let e=JSON.stringify(t);return this.objects[e]}},li=class{constructor(t){this.reset(t)}add(t){let e=cr(t);this.elements[e]=t}remove(t){let e=cr(t),n=this.elements[e];if(n)return delete this.elements[e],n}reset(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return this.elements={},Array.from(t).forEach(e=>{this.add(e)}),t}},cr=i=>i.dataset.trixStoreKey,Yt=class extends S{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((n,r)=>{this.succeeded=n,this.performing=!1,this.performed=!0,this.succeeded?t(r):e(r)})))),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}};Yt.proxyMethod("getPromise().then");Yt.proxyMethod("getPromise().catch");var ht=class extends S{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,n){let r=this.getCachedViewForObject(e);return r?this.recordChildView(r):(r=this.createChildView(...arguments),this.cacheViewForObject(r,e)),r}createChildView(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};e instanceof Ae&&(n.viewClass=t,t=ci);let r=new t(e,n);return this.recordChildView(r)}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){let e=t?.id;if(e)return this.rootView.element.querySelector("[data-trix-id='".concat(e,"']"))}findViewForObject(t){for(let e of this.getAllChildViews())if(e.object===t)return e}getViewCache(){if(this.rootView===this){if(this.isViewCachingEnabled())return this.viewCache||(this.viewCache={}),this.viewCache}else return this.rootView.getViewCache()}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){let n=this.getViewCache();n&&(n[e.getCacheKey()]=t)}garbageCollectCachedViews(){let t=this.getViewCache();if(t){let n=this.getAllChildViews().concat(this).map(r=>r.object.getCacheKey());for(let r in t)n.includes(r)||delete t[r]}}},ci=class extends ht{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(){let t=this.createContainerElement();return this.getChildViews().forEach(e=>{Array.from(e.getNodes()).forEach(n=>{t.appendChild(n)})}),[t]}createContainerElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.objectGroup.getDepth();return this.getChildViews()[0].createContainerElement(t)}};var{entries:Yr,setPrototypeOf:ur,isFrozen:ss,getPrototypeOf:as,getOwnPropertyDescriptor:ls}=Object,{freeze:V,seal:X,create:Xr}=Object,{apply:ui,construct:di}=typeof Reflect<"u"&&Reflect;V||(V=function(t){return t});X||(X=function(t){return t});ui||(ui=function(t,e){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];return t.apply(e,r)});di||(di=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return new t(...n)});var Fe=H(Array.prototype.forEach),cs=H(Array.prototype.lastIndexOf),dr=H(Array.prototype.pop),le=H(Array.prototype.push),us=H(Array.prototype.splice),Ve=H(String.prototype.toLowerCase),Wn=H(String.prototype.toString),zn=H(String.prototype.match),ce=H(String.prototype.replace),ds=H(String.prototype.indexOf),hs=H(String.prototype.trim),tt=H(Object.prototype.hasOwnProperty),j=H(RegExp.prototype.test),ue=fs(TypeError);function H(i){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return ui(i,t,n)}}function fs(i){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return di(i,e)}}function b(i,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ve;ur&&ur(i,null);let n=t.length;for(;n--;){let r=t[n];if(typeof r=="string"){let o=e(r);o!==r&&(ss(t)||(t[n]=o),r=o)}i[r]=!0}return i}function gs(i){for(let t=0;t<i.length;t++)tt(i,t)||(i[t]=null);return i}function ct(i){let t=Xr(null);for(let[e,n]of Yr(i))tt(i,e)&&(Array.isArray(n)?t[e]=gs(n):n&&typeof n=="object"&&n.constructor===Object?t[e]=ct(n):t[e]=n);return t}function de(i,t){for(;i!==null;){let n=ls(i,t);if(n){if(n.get)return H(n.get);if(typeof n.value=="function")return H(n.value)}i=as(i)}function e(){return null}return e}var hr=V(["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"]),Un=V(["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"]),Vn=V(["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"]),ms=V(["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"]),Hn=V(["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"]),ps=V(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),fr=V(["#text"]),gr=V(["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"]),qn=V(["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"]),mr=V(["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"]),Ne=V(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),bs=X(/\{\{[\w\W]*|[\w\W]*\}\}/gm),vs=X(/<%[\w\W]*|[\w\W]*%>/gm),ys=X(/\$\{[\w\W]*/gm),As=X(/^data-[\-\w.\u00B7-\uFFFF]+$/),xs=X(/^aria-[\-\w]+$/),Zr=X(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Es=X(/^(?:\w+script|data):/i),ws=X(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Qr=X(/^html$/i),Cs=X(/^[a-z][.\w]*(-[.\w]+)+$/i),pr=Object.freeze({__proto__:null,ARIA_ATTR:xs,ATTR_WHITESPACE:ws,CUSTOM_ELEMENT:Cs,DATA_ATTR:As,DOCTYPE_NAME:Qr,ERB_EXPR:vs,IS_ALLOWED_URI:Zr,IS_SCRIPT_OR_DATA:Es,MUSTACHE_EXPR:bs,TMPLIT_EXPR:ys}),he={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ss=function(){return typeof window>"u"?null:window},Ts=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null,r="data-tt-policy-suffix";e&&e.hasAttribute(r)&&(n=e.getAttribute(r));let o="dompurify"+(n?"#"+n:"");try{return t.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},br=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function $r(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ss(),t=f=>$r(f);if(t.version="3.2.7",t.removed=[],!i||!i.document||i.document.nodeType!==he.document||!i.Element)return t.isSupported=!1,t;let{document:e}=i,n=e,r=n.currentScript,{DocumentFragment:o,HTMLTemplateElement:s,Node:l,Element:c,NodeFilter:d,NamedNodeMap:g=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:x,DOMParser:T,trustedTypes:Z}=i,F=c.prototype,Q=de(F,"cloneNode"),Et=de(F,"remove"),mt=de(F,"nextSibling"),Bt=de(F,"childNodes"),ot=de(F,"parentNode");if(typeof s=="function"){let f=e.createElement("template");f.content&&f.content.ownerDocument&&(e=f.content.ownerDocument)}let y,J="",{implementation:wt,createNodeIterator:ne,createDocumentFragment:ho,getElementsByTagName:fo}=e,{importNode:go}=n,_=br();t.isSupported=typeof Yr=="function"&&typeof ot=="function"&&wt&&wt.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:pn,ERB_EXPR:bn,TMPLIT_EXPR:vn,DATA_ATTR:mo,ARIA_ATTR:po,IS_SCRIPT_OR_DATA:bo,ATTR_WHITESPACE:Ri,CUSTOM_ELEMENT:vo}=pr,{IS_ALLOWED_URI:Di}=pr,O=null,Li=b({},[...hr,...Un,...Vn,...Hn,...fr]),I=null,Oi=b({},[...gr,...qn,...mr,...Ne]),k=Object.seal(Xr(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}})),ie=null,yn=null,Pi=!0,An=!0,Ii=!1,Mi=!0,_t=!1,ke=!0,Ct=!1,xn=!1,En=!1,jt=!1,Re=!1,De=!1,Fi=!0,Ni=!1,yo="user-content-",wn=!0,re=!1,Wt={},zt=null,Bi=b({},["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"]),_i=null,ji=b({},["audio","video","img","source","image","track"]),Cn=null,Wi=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Le="http://www.w3.org/1998/Math/MathML",Oe="http://www.w3.org/2000/svg",st="http://www.w3.org/1999/xhtml",Ut=st,Sn=!1,Tn=null,Ao=b({},[Le,Oe,st],Wn),Pe=b({},["mi","mo","mn","ms","mtext"]),Ie=b({},["annotation-xml"]),xo=b({},["title","style","font","a","script"]),oe=null,Eo=["application/xhtml+xml","text/html"],wo="text/html",P=null,Vt=null,Co=e.createElement("form"),zi=function(a){return a instanceof RegExp||a instanceof Function},kn=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Vt&&Vt===a)){if((!a||typeof a!="object")&&(a={}),a=ct(a),oe=Eo.indexOf(a.PARSER_MEDIA_TYPE)===-1?wo:a.PARSER_MEDIA_TYPE,P=oe==="application/xhtml+xml"?Wn:Ve,O=tt(a,"ALLOWED_TAGS")?b({},a.ALLOWED_TAGS,P):Li,I=tt(a,"ALLOWED_ATTR")?b({},a.ALLOWED_ATTR,P):Oi,Tn=tt(a,"ALLOWED_NAMESPACES")?b({},a.ALLOWED_NAMESPACES,Wn):Ao,Cn=tt(a,"ADD_URI_SAFE_ATTR")?b(ct(Wi),a.ADD_URI_SAFE_ATTR,P):Wi,_i=tt(a,"ADD_DATA_URI_TAGS")?b(ct(ji),a.ADD_DATA_URI_TAGS,P):ji,zt=tt(a,"FORBID_CONTENTS")?b({},a.FORBID_CONTENTS,P):Bi,ie=tt(a,"FORBID_TAGS")?b({},a.FORBID_TAGS,P):ct({}),yn=tt(a,"FORBID_ATTR")?b({},a.FORBID_ATTR,P):ct({}),Wt=tt(a,"USE_PROFILES")?a.USE_PROFILES:!1,Pi=a.ALLOW_ARIA_ATTR!==!1,An=a.ALLOW_DATA_ATTR!==!1,Ii=a.ALLOW_UNKNOWN_PROTOCOLS||!1,Mi=a.ALLOW_SELF_CLOSE_IN_ATTR!==!1,_t=a.SAFE_FOR_TEMPLATES||!1,ke=a.SAFE_FOR_XML!==!1,Ct=a.WHOLE_DOCUMENT||!1,jt=a.RETURN_DOM||!1,Re=a.RETURN_DOM_FRAGMENT||!1,De=a.RETURN_TRUSTED_TYPE||!1,En=a.FORCE_BODY||!1,Fi=a.SANITIZE_DOM!==!1,Ni=a.SANITIZE_NAMED_PROPS||!1,wn=a.KEEP_CONTENT!==!1,re=a.IN_PLACE||!1,Di=a.ALLOWED_URI_REGEXP||Zr,Ut=a.NAMESPACE||st,Pe=a.MATHML_TEXT_INTEGRATION_POINTS||Pe,Ie=a.HTML_INTEGRATION_POINTS||Ie,k=a.CUSTOM_ELEMENT_HANDLING||{},a.CUSTOM_ELEMENT_HANDLING&&zi(a.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(k.tagNameCheck=a.CUSTOM_ELEMENT_HANDLING.tagNameCheck),a.CUSTOM_ELEMENT_HANDLING&&zi(a.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(k.attributeNameCheck=a.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),a.CUSTOM_ELEMENT_HANDLING&&typeof a.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(k.allowCustomizedBuiltInElements=a.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),_t&&(An=!1),Re&&(jt=!0),Wt&&(O=b({},fr),I=[],Wt.html===!0&&(b(O,hr),b(I,gr)),Wt.svg===!0&&(b(O,Un),b(I,qn),b(I,Ne)),Wt.svgFilters===!0&&(b(O,Vn),b(I,qn),b(I,Ne)),Wt.mathMl===!0&&(b(O,Hn),b(I,mr),b(I,Ne))),a.ADD_TAGS&&(O===Li&&(O=ct(O)),b(O,a.ADD_TAGS,P)),a.ADD_ATTR&&(I===Oi&&(I=ct(I)),b(I,a.ADD_ATTR,P)),a.ADD_URI_SAFE_ATTR&&b(Cn,a.ADD_URI_SAFE_ATTR,P),a.FORBID_CONTENTS&&(zt===Bi&&(zt=ct(zt)),b(zt,a.FORBID_CONTENTS,P)),wn&&(O["#text"]=!0),Ct&&b(O,["html","head","body"]),O.table&&(b(O,["tbody"]),delete ie.tbody),a.TRUSTED_TYPES_POLICY){if(typeof a.TRUSTED_TYPES_POLICY.createHTML!="function")throw ue('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof a.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ue('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');y=a.TRUSTED_TYPES_POLICY,J=y.createHTML("")}else y===void 0&&(y=Ts(Z,r)),y!==null&&typeof J=="string"&&(J=y.createHTML(""));V&&V(a),Vt=a}},Ui=b({},[...Un,...Vn,...ms]),Vi=b({},[...Hn,...ps]),So=function(a){let u=ot(a);(!u||!u.tagName)&&(u={namespaceURI:Ut,tagName:"template"});let h=Ve(a.tagName),w=Ve(u.tagName);return Tn[a.namespaceURI]?a.namespaceURI===Oe?u.namespaceURI===st?h==="svg":u.namespaceURI===Le?h==="svg"&&(w==="annotation-xml"||Pe[w]):Boolean(Ui[h]):a.namespaceURI===Le?u.namespaceURI===st?h==="math":u.namespaceURI===Oe?h==="math"&&Ie[w]:Boolean(Vi[h]):a.namespaceURI===st?u.namespaceURI===Oe&&!Ie[w]||u.namespaceURI===Le&&!Pe[w]?!1:!Vi[h]&&(xo[h]||!Ui[h]):!!(oe==="application/xhtml+xml"&&Tn[a.namespaceURI]):!1},nt=function(a){le(t.removed,{element:a});try{ot(a).removeChild(a)}catch{Et(a)}},St=function(a,u){try{le(t.removed,{attribute:u.getAttributeNode(a),from:u})}catch{le(t.removed,{attribute:null,from:u})}if(u.removeAttribute(a),a==="is")if(jt||Re)try{nt(u)}catch{}else try{u.setAttribute(a,"")}catch{}},Hi=function(a){let u=null,h=null;if(En)a="<remove></remove>"+a;else{let L=zn(a,/^[\r\n\t ]+/);h=L&&L[0]}oe==="application/xhtml+xml"&&Ut===st&&(a='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+a+"</body></html>");let w=y?y.createHTML(a):a;if(Ut===st)try{u=new T().parseFromString(w,oe)}catch{}if(!u||!u.documentElement){u=wt.createDocument(Ut,"template",null);try{u.documentElement.innerHTML=Sn?J:w}catch{}}let N=u.body||u.documentElement;return a&&h&&N.insertBefore(e.createTextNode(h),N.childNodes[0]||null),Ut===st?fo.call(u,Ct?"html":"body")[0]:Ct?u.documentElement:N},qi=function(a){return ne.call(a.ownerDocument||a,a,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Rn=function(a){return a instanceof x&&(typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||!(a.attributes instanceof g)||typeof a.removeAttribute!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function")},Gi=function(a){return typeof l=="function"&&a instanceof l};function at(f,a,u){Fe(f,h=>{h.call(t,a,u,Vt)})}let Ki=function(a){let u=null;if(at(_.beforeSanitizeElements,a,null),Rn(a))return nt(a),!0;let h=P(a.nodeName);if(at(_.uponSanitizeElement,a,{tagName:h,allowedTags:O}),ke&&a.hasChildNodes()&&!Gi(a.firstElementChild)&&j(/<[/\w!]/g,a.innerHTML)&&j(/<[/\w!]/g,a.textContent)||a.nodeType===he.progressingInstruction||ke&&a.nodeType===he.comment&&j(/<[/\w]/g,a.data))return nt(a),!0;if(!O[h]||ie[h]){if(!ie[h]&&Yi(h)&&(k.tagNameCheck instanceof RegExp&&j(k.tagNameCheck,h)||k.tagNameCheck instanceof Function&&k.tagNameCheck(h)))return!1;if(wn&&!zt[h]){let w=ot(a)||a.parentNode,N=Bt(a)||a.childNodes;if(N&&w){let L=N.length;for(let q=L-1;q>=0;--q){let lt=Q(N[q],!0);lt.__removalCount=(a.__removalCount||0)+1,w.insertBefore(lt,mt(a))}}}return nt(a),!0}return a instanceof c&&!So(a)||(h==="noscript"||h==="noembed"||h==="noframes")&&j(/<\/no(script|embed|frames)/i,a.innerHTML)?(nt(a),!0):(_t&&a.nodeType===he.text&&(u=a.textContent,Fe([pn,bn,vn],w=>{u=ce(u,w," ")}),a.textContent!==u&&(le(t.removed,{element:a.cloneNode()}),a.textContent=u)),at(_.afterSanitizeElements,a,null),!1)},Ji=function(a,u,h){if(Fi&&(u==="id"||u==="name")&&(h in e||h in Co))return!1;if(!(An&&!yn[u]&&j(mo,u))){if(!(Pi&&j(po,u))){if(!I[u]||yn[u]){if(!(Yi(a)&&(k.tagNameCheck instanceof RegExp&&j(k.tagNameCheck,a)||k.tagNameCheck instanceof Function&&k.tagNameCheck(a))&&(k.attributeNameCheck instanceof RegExp&&j(k.attributeNameCheck,u)||k.attributeNameCheck instanceof Function&&k.attributeNameCheck(u,a))||u==="is"&&k.allowCustomizedBuiltInElements&&(k.tagNameCheck instanceof RegExp&&j(k.tagNameCheck,h)||k.tagNameCheck instanceof Function&&k.tagNameCheck(h))))return!1}else if(!Cn[u]){if(!j(Di,ce(h,Ri,""))){if(!((u==="src"||u==="xlink:href"||u==="href")&&a!=="script"&&ds(h,"data:")===0&&_i[a])){if(!(Ii&&!j(bo,ce(h,Ri,"")))){if(h)return!1}}}}}}return!0},Yi=function(a){return a!=="annotation-xml"&&zn(a,vo)},Xi=function(a){at(_.beforeSanitizeAttributes,a,null);let{attributes:u}=a;if(!u||Rn(a))return;let h={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:I,forceKeepAttr:void 0},w=u.length;for(;w--;){let N=u[w],{name:L,namespaceURI:q,value:lt}=N,Ht=P(L),Dn=lt,M=L==="value"?Dn:hs(Dn);if(h.attrName=Ht,h.attrValue=M,h.keepAttr=!0,h.forceKeepAttr=void 0,at(_.uponSanitizeAttribute,a,h),M=h.attrValue,Ni&&(Ht==="id"||Ht==="name")&&(St(L,a),M=yo+M),ke&&j(/((--!?|])>)|<\/(style|title|textarea)/i,M)){St(L,a);continue}if(Ht==="attributename"&&zn(M,"href")){St(L,a);continue}if(h.forceKeepAttr)continue;if(!h.keepAttr){St(L,a);continue}if(!Mi&&j(/\/>/i,M)){St(L,a);continue}_t&&Fe([pn,bn,vn],Qi=>{M=ce(M,Qi," ")});let Zi=P(a.nodeName);if(!Ji(Zi,Ht,M)){St(L,a);continue}if(y&&typeof Z=="object"&&typeof Z.getAttributeType=="function"&&!q)switch(Z.getAttributeType(Zi,Ht)){case"TrustedHTML":{M=y.createHTML(M);break}case"TrustedScriptURL":{M=y.createScriptURL(M);break}}if(M!==Dn)try{q?a.setAttributeNS(q,L,M):a.setAttribute(L,M),Rn(a)?nt(a):dr(t.removed)}catch{St(L,a)}}at(_.afterSanitizeAttributes,a,null)},To=function f(a){let u=null,h=qi(a);for(at(_.beforeSanitizeShadowDOM,a,null);u=h.nextNode();)at(_.uponSanitizeShadowNode,u,null),Ki(u),Xi(u),u.content instanceof o&&f(u.content);at(_.afterSanitizeShadowDOM,a,null)};return t.sanitize=function(f){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,h=null,w=null,N=null;if(Sn=!f,Sn&&(f="<!-->"),typeof f!="string"&&!Gi(f))if(typeof f.toString=="function"){if(f=f.toString(),typeof f!="string")throw ue("dirty is not a string, aborting")}else throw ue("toString is not a function");if(!t.isSupported)return f;if(xn||kn(a),t.removed=[],typeof f=="string"&&(re=!1),re){if(f.nodeName){let lt=P(f.nodeName);if(!O[lt]||ie[lt])throw ue("root node is forbidden and cannot be sanitized in-place")}}else if(f instanceof l)u=Hi("<!---->"),h=u.ownerDocument.importNode(f,!0),h.nodeType===he.element&&h.nodeName==="BODY"||h.nodeName==="HTML"?u=h:u.appendChild(h);else{if(!jt&&!_t&&!Ct&&f.indexOf("<")===-1)return y&&De?y.createHTML(f):f;if(u=Hi(f),!u)return jt?null:De?J:""}u&&En&&nt(u.firstChild);let L=qi(re?f:u);for(;w=L.nextNode();)Ki(w),Xi(w),w.content instanceof o&&To(w.content);if(re)return f;if(jt){if(Re)for(N=ho.call(u.ownerDocument);u.firstChild;)N.appendChild(u.firstChild);else N=u;return(I.shadowroot||I.shadowrootmode)&&(N=go.call(n,N,!0)),N}let q=Ct?u.outerHTML:u.innerHTML;return Ct&&O["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&j(Qr,u.ownerDocument.doctype.name)&&(q="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
`+q),_t&&Fe([pn,bn,vn],lt=>{q=ce(q,lt," ")}),y&&De?y.createHTML(q):q},t.setConfig=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};kn(f),xn=!0},t.clearConfig=function(){Vt=null,xn=!1},t.isValidAttribute=function(f,a,u){Vt||kn({});let h=P(f),w=P(a);return Ji(h,w,u)},t.addHook=function(f,a){typeof a=="function"&&le(_[f],a)},t.removeHook=function(f,a){if(a!==void 0){let u=cs(_[f],a);return u===-1?void 0:us(_[f],u,1)[0]}return dr(_[f])},t.removeHooks=function(f){_[f]=[]},t.removeAllHooks=function(){_=br()},t}var xe=$r();xe.addHook("uponSanitizeAttribute",function(i,t){/^data-trix-/.test(t.attrName)&&(t.forceKeepAttr=!0)});var ks="style href src width height language class".split(" "),Rs="javascript:".split(" "),Ds="script iframe form noscript".split(" "),Xt=class extends S{static setHTML(t,e,n){let r=new this(e,n).sanitize(),o=r.getHTML?r.getHTML():r.outerHTML;t.innerHTML=o}static sanitize(t,e){let n=new this(t,e);return n.sanitize(),n}constructor(t){let{allowedAttributes:e,forbiddenProtocols:n,forbiddenElements:r,purifyOptions:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(...arguments),this.allowedAttributes=e||ks,this.forbiddenProtocols=n||Rs,this.forbiddenElements=r||Ds,this.purifyOptions=o||{},this.body=Ls(t)}sanitize(){this.sanitizeElements(),this.normalizeListElementNesting();let t=Object.assign({},Nr,this.purifyOptions);return xe.setConfig(t),this.body=xe.sanitize(this.body),this.body}getHTML(){return this.body.innerHTML}getBody(){return this.body}sanitizeElements(){let t=He(this.body),e=[];for(;t.nextNode();){let n=t.currentNode;switch(n.nodeType){case Node.ELEMENT_NODE:this.elementIsRemovable(n)?e.push(n):this.sanitizeElement(n);break;case Node.COMMENT_NODE:e.push(n);break}}return e.forEach(n=>yt(n)),this.body}sanitizeElement(t){return t.hasAttribute("href")&&this.forbiddenProtocols.includes(t.protocol)&&t.removeAttribute("href"),Array.from(t.attributes).forEach(e=>{let{name:n}=e;!this.allowedAttributes.includes(n)&&n.indexOf("data-trix")!==0&&t.removeAttribute(n)}),t}normalizeListElementNesting(){return Array.from(this.body.querySelectorAll("ul,ol")).forEach(t=>{let e=t.previousElementSibling;e&&W(e)==="li"&&e.appendChild(t)}),this.body}elementIsRemovable(t){if(t?.nodeType===Node.ELEMENT_NODE)return this.elementIsForbidden(t)||this.elementIsntSerializable(t)}elementIsForbidden(t){return this.forbiddenElements.includes(W(t))}elementIsntSerializable(t){return t.getAttribute("data-trix-serialize")==="false"&&!Dt(t)}},Ls=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";i=i.replace(/<\/html[^>]*>[^]*$/i,"</html>");let t=document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=i,Array.from(t.head.querySelectorAll("style")).forEach(e=>{t.body.appendChild(e)}),t.body},{css:pt}=Te,Ee=class extends ht{constructor(){super(...arguments),this.attachment=this.object,this.attachment.uploadProgressDelegate=this,this.attachmentPiece=this.options.piece}createContentNodes(){return[]}createNodes(){let t,e=t=p({tagName:"figure",className:this.getClassName(),data:this.getData(),editable:!1}),n=this.getHref();return n&&(t=p({tagName:"a",editable:!1,attributes:{href:n,tabindex:-1}}),e.appendChild(t)),this.attachment.hasContent()?Xt.setHTML(t,this.attachment.getContent()):this.createContentNodes().forEach(r=>{t.appendChild(r)}),t.appendChild(this.createCaptionElement()),this.attachment.isPending()&&(this.progressElement=p({tagName:"progress",attributes:{class:pt.attachmentProgress,value:this.attachment.getUploadProgress(),max:100},data:{trixMutable:!0,trixStoreKey:["progressElement",this.attachment.id].join("/")}}),e.appendChild(this.progressElement)),[vr("left"),e,vr("right")]}createCaptionElement(){let t=p({tagName:"figcaption",className:pt.attachmentCaption}),e=this.attachmentPiece.getCaption();if(e)t.classList.add("".concat(pt.attachmentCaption,"--edited")),t.textContent=e;else{let n,r,o=this.getCaptionConfig();if(o.name&&(n=this.attachment.getFilename()),o.size&&(r=this.attachment.getFormattedFilesize()),n){let s=p({tagName:"span",className:pt.attachmentName,textContent:n});t.appendChild(s)}if(r){n&&t.appendChild(document.createTextNode(" "));let s=p({tagName:"span",className:pt.attachmentSize,textContent:r});t.appendChild(s)}}return t}getClassName(){let t=[pt.attachment,"".concat(pt.attachment,"--").concat(this.attachment.getType())],e=this.attachment.getExtension();return e&&t.push("".concat(pt.attachment,"--").concat(e)),t.join(" ")}getData(){let 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(!Os(this.attachment.getContent(),"a")){let t=this.attachment.getHref();if(t&&xe.isValidAttribute("a","href",t))return t}}getCaptionConfig(){var t;let e=this.attachment.getType(),n=Gr((t=yi[e])===null||t===void 0?void 0:t.caption);return e==="file"&&(n.name=!0),n}findProgressElement(){var t;return(t=this.findElement())===null||t===void 0?void 0:t.querySelector("progress")}attachmentDidChangeUploadProgress(){let t=this.attachment.getUploadProgress(),e=this.findProgressElement();e&&(e.value=t)}},vr=i=>p({tagName:"span",textContent:fn,data:{trixCursorTarget:i,trixSerialize:!1}}),Os=function(i,t){let e=p("div");return Xt.setHTML(e,i||""),e.querySelector(t)},Je=class extends Ee{constructor(){super(...arguments),this.attachment.previewDelegate=this}createContentNodes(){return this.image=p({tagName:"img",attributes:{src:""},data:{trixMutable:!0}}),this.refresh(this.image),[this.image]}createCaptionElement(){let t=super.createCaptionElement(...arguments);return t.textContent||t.setAttribute("data-trix-placeholder",m.captionPlaceholder),t}refresh(t){if(!t){var e;t=(e=this.findElement())===null||e===void 0?void 0:e.querySelector("img")}if(t)return this.updateAttributesForImage(t)}updateAttributesForImage(t){let e=this.attachment.getURL(),n=this.attachment.getPreviewURL();if(t.src=n||e,n===e)t.removeAttribute("data-trix-serialized-attributes");else{let c=JSON.stringify({src:e});t.setAttribute("data-trix-serialized-attributes",c)}let r=this.attachment.getWidth(),o=this.attachment.getHeight(),s=this.attachment.getAttribute("alt");r!=null&&(t.width=r),o!=null&&(t.height=o),s!=null&&(t.alt=s);let l=["imageElement",this.attachment.id,t.src,t.width,t.height].join("/");t.dataset.trixStoreKey=l}attachmentDidChangeAttributes(){return this.refresh(this.image),this.refresh()}},Ye=class extends ht{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(),e=this.createElement();if(e){let n=Po(e);Array.from(t).forEach(r=>{n.appendChild(r)}),t=[e]}return t}createAttachmentNodes(){let t=this.attachment.isPreviewable()?Je:Ee;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)];{let e=[],n=this.string.split(`
`);for(let r=0;r<n.length;r++){let o=n[r];if(r>0){let s=p("br");e.push(s)}if(o.length){let s=document.createTextNode(this.preserveSpaces(o));e.push(s)}}return e}}createElement(){let t,e,n,r={};for(e in this.attributes){n=this.attributes[e];let s=oi(e);if(s){if(s.tagName){var o;let l=p(s.tagName);o?(o.appendChild(l),o=l):t=o=l}if(s.styleProperty&&(r[s.styleProperty]=n),s.style)for(e in s.style)n=s.style[e],r[e]=n}}if(Object.keys(r).length){t||(t=p("span"));for(e in r)n=r[e],t.style[e]=n}return t}createContainerElement(){for(let t in this.attributes){let e=this.attributes[t],n=oi(t);if(n&&n.groupTagName){let r={};return r[t]=e,p(n.groupTagName,r)}}}preserveSpaces(t){return this.context.isLast&&(t=t.replace(/\ $/,bt)),t=t.replace(/(\S)\ {3}(\S)/g,"$1 ".concat(bt," $2")).replace(/\ {2}/g,"".concat(bt," ")).replace(/\ {2}/g," ".concat(bt)),(this.context.isFirst||this.context.followsWhitespace)&&(t=t.replace(/^\ /,bt)),t}},Xe=class extends ht{constructor(){super(...arguments),this.text=this.object,this.textConfig=this.options.textConfig}createNodes(){let t=[],e=Ae.groupObjects(this.getPieces()),n=e.length-1;for(let o=0;o<e.length;o++){let s=e[o],l={};o===0&&(l.isFirst=!0),o===n&&(l.isLast=!0),Ps(r)&&(l.followsWhitespace=!0);let c=this.findOrCreateCachedChildView(Ye,s,{textConfig:this.textConfig,context:l});t.push(...Array.from(c.getNodes()||[]));var r=s}return t}getPieces(){return Array.from(this.text.getPieces()).filter(t=>!t.hasAttribute("blockBreak"))}},Ps=i=>/\s$/.test(i?.toString()),{css:yr}=Te,Ze=class extends ht{constructor(){super(...arguments),this.block=this.object,this.attributes=this.block.getAttributes()}createNodes(){let e=[document.createComment("block")];if(this.block.isEmpty())e.push(p("br"));else{var n;let r=(n=D(this.block.getLastAttribute()))===null||n===void 0?void 0:n.text,o=this.findOrCreateCachedChildView(Xe,this.block.text,{textConfig:r});e.push(...Array.from(o.getNodes()||[])),this.shouldAddExtraNewlineElement()&&e.push(p("br"))}if(this.attributes.length)return e;{let r,{tagName:o}=z.default;this.block.isRTL()&&(r={dir:"rtl"});let s=p({tagName:o,attributes:r});return e.forEach(l=>s.appendChild(l)),[s]}}createContainerElement(t){let e={},n,r=this.attributes[t],{tagName:o,htmlAttributes:s=[]}=D(r);if(t===0&&this.block.isRTL()&&Object.assign(e,{dir:"rtl"}),r==="attachmentGallery"){let l=this.block.getBlockBreakPosition();n="".concat(yr.attachmentGallery," ").concat(yr.attachmentGallery,"--").concat(l)}return Object.entries(this.block.htmlAttributes).forEach(l=>{let[c,d]=l;s.includes(c)&&(e[c]=d)}),p({tagName:o,className:n,attributes:e})}shouldAddExtraNewlineElement(){return/\n\n$/.test(this.block.toString())}},Zt=class extends ht{static render(t){let e=p("div"),n=new this(t,{element:e});return n.render(),n.sync(),e}constructor(){super(...arguments),this.element=this.options.element,this.elementStore=new li,this.setDocument(this.object)}setDocument(t){t.isEqualTo(this.document)||(this.document=this.object=t)}render(){if(this.childViews=[],this.shadowElement=p("div"),!this.document.isEmpty()){let t=Ae.groupObjects(this.document.getBlocks(),{asTree:!0});Array.from(t).forEach(e=>{let n=this.findOrCreateCachedChildView(Ze,e);Array.from(n.getNodes()).map(r=>this.shadowElement.appendChild(r))})}}isSynced(){return Is(this.shadowElement,this.element)}sync(){let e=jr("trix-before-render",{cancelable:!1,attributes:{render:(r,o)=>{for(;r.lastChild;)r.removeChild(r.lastChild);r.appendChild(o)}}});this.element.dispatchEvent(e);let n=this.createDocumentFragmentForSync();return e.render(this.element,n),this.didSync()}didSync(){return this.elementStore.reset(Ar(this.element)),Si(()=>this.garbageCollectCachedViews())}createDocumentFragmentForSync(){let t=document.createDocumentFragment();return Array.from(this.shadowElement.childNodes).forEach(e=>{t.appendChild(e.cloneNode(!0))}),Array.from(Ar(t)).forEach(e=>{let n=this.elementStore.remove(e);n&&e.parentNode.replaceChild(n,e)}),t}},Ar=i=>i.querySelectorAll("[data-trix-store-key]"),Is=(i,t)=>xr(i.innerHTML)===xr(t.innerHTML),xr=i=>i.replace(/&nbsp;/g," ");function Be(i){var t,e;function n(o,s){try{var l=i[o](s),c=l.value,d=c instanceof Ms;Promise.resolve(d?c.v:c).then(function(g){if(d){var x=o==="return"?"return":"next";if(!c.k||g.done)return n(x,g);g=i[x](g).value}r(l.done?"return":"normal",g)},function(g){n("throw",g)})}catch(g){r("throw",g)}}function r(o,s){switch(o){case"return":t.resolve({value:s,done:!0});break;case"throw":t.reject(s);break;default:t.resolve({value:s,done:!1})}(t=t.next)?n(t.key,t.arg):e=null}this._invoke=function(o,s){return new Promise(function(l,c){var d={key:o,arg:s,resolve:l,reject:c,next:null};e?e=e.next=d:(t=e=d,n(o,s))})},typeof i.return!="function"&&(this.return=void 0)}Be.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Be.prototype.next=function(i){return this._invoke("next",i)},Be.prototype.throw=function(i){return this._invoke("throw",i)},Be.prototype.return=function(i){return this._invoke("return",i)};function Ms(i,t){this.v=i,this.k=t}function Fs(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var n=e.call(i,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function Ns(i){var t=Fs(i,"string");return typeof t=="symbol"?t:String(t)}function B(i,t,e){return t=Ns(t),t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function v(i,t){var e=to(i,t,"get");return Bs(i,e)}function ye(i,t,e){var n=to(i,t,"set");return _s(i,n,e),e}function to(i,t,e){if(!t.has(i))throw new TypeError("attempted to "+e+" private field on non-instance");return t.get(i)}function Bs(i,t){return t.get?t.get.call(i):t.value}function _s(i,t,e){if(t.set)t.set.call(i,e);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=e}}function _e(i,t,e){if(!t.has(i))throw new TypeError("attempted to get private field on non-instance");return e}function eo(i,t){if(t.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Jt(i,t,e){eo(i,t),t.set(i,e)}function js(i,t){eo(i,t),t.add(i)}var ft=class extends dt{static registerType(t,e){e.type=t,this.types[t]=e}static fromJSON(t){let 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=U.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}};B(ft,"types",{});var Qe=class extends Yt{constructor(t){super(...arguments),this.url=t}perform(t){let 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}},At=class extends dt{static attachmentForFile(t){let e=this.attributesForFile(t),n=new this(e);return n.setFile(t),n}static attributesForFile(t){return new U({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=U.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]:{},e=this.attributes.merge(t);if(!this.attributes.isEqualTo(e)){var n,r,o,s;return this.attributes=e,this.didChangeAttributes(),(n=this.previewDelegate)===null||n===void 0||(r=n.attachmentDidChangeAttributes)===null||r===void 0||r.call(n,this),(o=this.delegate)===null||o===void 0||(s=o.attachmentDidChangeAttributes)===null||s===void 0?void 0:s.call(o,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"):At.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(){let t=this.attributes.get("filesize");return typeof t=="number"?Br.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){if(this.uploadProgress!==t){var e,n;return this.uploadProgress=t,(e=this.uploadProgressDelegate)===null||e===void 0||(n=e.attachmentDidChangeUploadProgress)===null||n===void 0?void 0:n.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){if(t!==this.getPreviewURL()){var e,n,r,o;return this.previewURL=t,(e=this.previewDelegate)===null||e===void 0||(n=e.attachmentDidChangeAttributes)===null||n===void 0||n.call(e,this),(r=this.delegate)===null||r===void 0||(o=r.attachmentDidChangePreviewURL)===null||o===void 0?void 0:o.call(r,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 Qe(t).then(r=>{let{width:o,height:s}=r;return(!this.getWidth()||!this.getHeight())&&this.setAttributes({width:o,height:s}),this.preloadingURL=null,this.setPreviewURL(t),e?.()}).catch(()=>(this.preloadingURL=null,e?.()))}};B(At,"previewablePattern",/^image(\/(gif|png|webp|jpe?g)|$)/);var xt=class extends ft{static fromJSON(t){return new this(At.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(){let t=this.attributes.slice(xt.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 Ai}toJSON(){let 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())}};B(xt,"permittedAttributes",["caption","presentation"]);ft.registerType("attachment",xt);var we=class extends ft{static fromJSON(t){return new this(t.string,t.attributes)}constructor(t){super(...arguments),this.string=es(t),this.length=this.string.length}getValue(){return this.string}toString(){return this.string.toString()}isBlockBreak(){return this.toString()===`
`&&this.getAttribute("blockBreak")===!0}toJSON(){let 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,n;return t===0?(e=null,n=this):t===this.length?(e=this,n=null):(e=new this.constructor(this.string.slice(0,t),this.attributes),n=new this.constructor(this.string.slice(t),this.attributes)),[e,n]}toConsole(){let{string:t}=this;return t.length>15&&(t=t.slice(0,14)+"\u2026"),JSON.stringify(t.toString())}};ft.registerType("string",we);var Qt=class extends dt{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),n=0;n<t;n++)e[n]=arguments[n];return new this.constructor(Ci(this.objects,...e))}eachObject(t){return this.objects.map((e,n)=>t(e,n))}insertObjectAtIndex(t,e){return this.splice(e,0,t)}insertSplittableListAtIndex(t,e){return this.splice(e,0,...t.objects)}insertSplittableListAtPosition(t,e){let[n,r]=this.splitObjectAtPosition(e);return new this.constructor(n).insertSplittableListAtIndex(t,r)}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){let[e,n,r]=this.splitObjectsAtRange(t);return new this.constructor(e.slice(n,r+1))}selectSplittableList(t){let e=this.objects.filter(n=>t(n));return new this.constructor(e)}removeObjectsInRange(t){let[e,n,r]=this.splitObjectsAtRange(t);return new this.constructor(e).splice(n,r-n+1)}transformObjectsInRange(t,e){let[n,r,o]=this.splitObjectsAtRange(t),s=n.map((l,c)=>r<=c&&c<=o?e(l):l);return new this.constructor(s)}splitObjectsAtRange(t){let e,[n,r,o]=this.splitObjectAtPosition(zs(t));return[n,e]=new this.constructor(n).splitObjectAtPosition(Us(t)+o),[n,r,e-1]}getObjectAtPosition(t){let{index:e}=this.findIndexAndOffsetAtPosition(t);return this.objects[e]}splitObjectAtPosition(t){let e,n,{index:r,offset:o}=this.findIndexAndOffsetAtPosition(t),s=this.objects.slice(0);if(r!=null)if(o===0)e=r,n=0;else{let l=this.getObjectAtIndex(r),[c,d]=l.splitAtOffset(o);s.splice(r,1,c,d),e=r+1,n=c.getLength()-o}else e=s.length,n=0;return[s,e,n]}consolidate(){let t=[],e=this.objects[0];return this.objects.slice(1).forEach(n=>{var r,o;(r=(o=e).canBeConsolidatedWith)!==null&&r!==void 0&&r.call(o,n)?e=e.consolidateWith(n):(t.push(e),e=n)}),e&&t.push(e),new this.constructor(t)}consolidateFromIndexToIndex(t,e){let r=this.objects.slice(0).slice(t,e+1),o=new this.constructor(r).consolidate().toArray();return this.splice(t,r.length,...o)}findIndexAndOffsetAtPosition(t){let e,n=0;for(e=0;e<this.objects.length;e++){let r=this.objects[e],o=n+r.getLength();if(n<=t&&t<o)return{index:e,offset:t-n};n=o}return{index:null,offset:null}}findPositionAtIndexAndOffset(t,e){let n=0;for(let r=0;r<this.objects.length;r++){let o=this.objects[r];if(r<t)n+=o.getLength();else if(r===t){n+=e;break}}return n}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)||Ws(this.objects,t?.objects)}contentsForInspection(){return{objects:"[".concat(this.objects.map(t=>t.inspect()).join(", "),"]")}}},Ws=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(i.length!==t.length)return!1;let e=!0;for(let n=0;n<i.length;n++){let r=i[n];e&&!r.isEqualTo(t[n])&&(e=!1)}return e},zs=i=>i[0],Us=i=>i[1],K=class extends dt{static textForAttachmentWithAttributes(t,e){let n=new xt(t,e);return new this([n])}static textForStringWithAttributes(t,e){let n=new we(t,e);return new this([n])}static fromJSON(t){let e=Array.from(t).map(n=>ft.fromJSON(n));return new this(e)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];super(...arguments);let e=t.filter(n=>!n.isEmpty());this.pieceList=new Qt(e)}copy(){return this.copyWithPieceList(this.pieceList)}copyWithPieceList(t){return new this.constructor(t.consolidate().toArray())}copyUsingObjectMap(t){let e=this.getPieces().map(n=>t.find(n)||n);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;let n=this.getTextAtRange(t),r=n.getLength();return t[0]<e&&(e-=r),this.removeTextAtRange(t).insertTextAtPosition(n,e)}addAttributeAtRange(t,e,n){let r={};return r[t]=e,this.addAttributesAtRange(r,n)}addAttributesAtRange(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,n=>n.copyWithAdditionalAttributes(t)))}removeAttributeAtRange(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,n=>n.copyWithoutAttribute(t)))}setAttributesAtRange(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,n=>n.copyWithAttributes(t)))}getAttributesAtPosition(t){var e;return((e=this.pieceList.getObjectAtPosition(t))===null||e===void 0?void 0:e.getAttributes())||{}}getCommonAttributes(){let t=Array.from(this.pieceList.toArray()).map(e=>e.getAttributes());return U.fromCommonAttributesOfObjects(t).toObject()}getCommonAttributesAtRange(t){return this.getTextAtRange(t).getCommonAttributes()||{}}getExpandedRangeForAttributeAtOffset(t,e){let n,r=n=e,o=this.getLength();for(;r>0&&this.getCommonAttributesAtRange([r-1,n])[t];)r--;for(;n<o&&this.getCommonAttributesAtRange([e,n+1])[t];)n++;return[r,n]}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){let 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(let r of this.pieceList.toArray()){var n;if(((n=r.attachment)===null||n===void 0?void 0:n.id)===t)return{attachment:r.attachment,position:e};e+=r.length}return{attachment:null,position:null}}getAttachmentById(t){let{attachment:e}=this.getAttachmentAndPositionById(t);return e}getRangeOfAttachment(t){let e=this.getAttachmentAndPositionById(t.id),n=e.position;if(t=e.attachment,t)return[n,n+1]}updateAttributesForAttachment(t,e){let n=this.getRangeOfAttachment(e);return n?this.addAttributesAtRange(t,n):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(){let 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 qo(this.toString())}isRTL(){return this.getDirection()==="rtl"}},Y=class extends dt{static fromJSON(t){let e=K.fromJSON(t.text);return new this(e,t.attributes,t.htmlAttributes)}constructor(t,e,n){super(...arguments),this.text=Vs(t||new K),this.attributes=e||[],this.htmlAttributes=n||{}}isEmpty(){return this.text.isBlockBreak()}isEqualTo(t){return super.isEqualTo(t)?!0:this.text.isEqualTo(t?.text)&&Pt(this.attributes,t?.attributes)&&ee(this.htmlAttributes,t?.htmlAttributes)}copyWithText(t){return new Y(t,this.attributes,this.htmlAttributes)}copyWithoutText(){return this.copyWithText(null)}copyWithAttributes(t){return new Y(this.text,t,this.htmlAttributes)}copyWithoutAttributes(){return this.copyWithAttributes(null)}copyUsingObjectMap(t){let e=t.find(this.text);return e?this.copyWithText(e):this.copyWithText(this.text.copyUsingObjectMap(t))}addAttribute(t){let e=this.attributes.concat(Er(t));return this.copyWithAttributes(e)}addHTMLAttribute(t,e){let n=Object.assign({},this.htmlAttributes,{[t]:e});return new Y(this.text,this.attributes,n)}removeAttribute(t){let{listAttribute:e}=D(t),n=Cr(Cr(this.attributes,t),e);return this.copyWithAttributes(n)}removeLastAttribute(){return this.removeAttribute(this.getLastAttribute())}getLastAttribute(){return wr(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 wr(this.getNestableAttributes())}getNestableAttributes(){return this.attributes.filter(t=>D(t).nestable)}getNestingLevel(){return this.getNestableAttributes().length}decreaseNestingLevel(){let t=this.getLastNestableAttribute();return t?this.removeAttribute(t):this}increaseNestingLevel(){let t=this.getLastNestableAttribute();if(t){let e=this.attributes.lastIndexOf(t),n=Ci(this.attributes,e+1,0,...Er(t));return this.copyWithAttributes(n)}else 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){let n=this.toString(),r;switch(t){case"forward":r=n.indexOf(`
`,e);break;case"backward":r=n.slice(0,e).lastIndexOf(`
`)}if(r!==-1)return r}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){let e=K.textForStringWithAttributes(`
`),n=this.getTextWithoutBlockBreak().appendText(e);return this.copyWithText(n.appendText(t.text))}splitAtOffset(t){let e,n;return t===0?(e=null,n=this):t===this.getLength()?(e=this,n=null):(e=this.copyWithText(this.text.getTextAtRange([0,t])),n=this.copyWithText(this.text.getTextAtRange([t,this.getLength()]))),[e,n]}getBlockBreakPosition(){return this.text.getLength()-1}getTextWithoutBlockBreak(){return no(this.text)?this.text.getTextAtRange([0,this.getBlockBreakPosition()]):this.text.copy()}canBeGrouped(t){return this.attributes[t]}canBeGroupedWith(t,e){let n=t.getAttributes(),r=n[e],o=this.attributes[e];return o===r&&!(D(o).group===!1&&!Jo().includes(n[e+1]))&&(this.getDirection()===t.getDirection()||t.isEmpty())}},Vs=function(i){return i=Hs(i),i=Gs(i),i},Hs=function(i){let t=!1,e=i.getPieces(),n=e.slice(0,e.length-1),r=e[e.length-1];return r?(n=n.map(o=>o.isBlockBreak()?(t=!0,Ks(o)):o),t?new K([...n,r]):i):i},qs=K.textForStringWithAttributes(`
`,{blockBreak:!0}),Gs=function(i){return no(i)?i:i.appendText(qs)},no=function(i){let t=i.getLength();return t===0?!1:i.getTextAtRange([t-1,t]).isBlockBreak()},Ks=i=>i.copyWithoutAttribute("blockBreak"),Er=function(i){let{listAttribute:t}=D(i);return t?[t,i]:[i]},wr=i=>i.slice(-1)[0],Cr=function(i,t){let e=i.lastIndexOf(t);return e===-1?i:Ci(i,e,1)},G=class extends dt{static fromJSON(t){let e=Array.from(t).map(n=>Y.fromJSON(n));return new this(e)}static fromString(t,e){let n=K.textForStringWithAttributes(t,e);return new this([new Y(n)])}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];super(...arguments),t.length===0&&(t=[new Y]),this.blockList=Qt.box(t)}isEmpty(){let t=this.getBlockAtIndex(0);return this.blockList.length===1&&t.isEmpty()&&!t.hasAttributes()}copy(){let e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).consolidateBlocks?this.blockList.consolidate().toArray():this.blockList.toArray();return new this.constructor(e)}copyUsingObjectsFromDocument(t){let e=new ai(t.getObjects());return this.copyUsingObjectMap(e)}copyUsingObjectMap(t){let e=this.getBlocks().map(n=>t.find(n)||n.copyUsingObjectMap(t));return new this.constructor(e)}copyWithBaseBlockAttributes(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=this.getBlocks().map(n=>{let r=t.concat(n.getAttributes());return n.copyWithAttributes(r)});return new this.constructor(e)}replaceBlock(t,e){let n=this.blockList.indexOf(t);return n===-1?this:new this.constructor(this.blockList.replaceObjectAtIndex(e,n))}insertDocumentAtRange(t,e){let{blockList:n}=t;e=A(e);let[r]=e,{index:o,offset:s}=this.locationFromPosition(r),l=this,c=this.getBlockAtPosition(r);return ut(e)&&c.isEmpty()&&!c.hasAttributes()?l=new this.constructor(l.blockList.removeObjectAtIndex(o)):c.getBlockBreakPosition()===s&&r++,l=l.removeTextAtRange(e),new this.constructor(l.blockList.insertSplittableListAtPosition(n,r))}mergeDocumentAtRange(t,e){let n,r;e=A(e);let[o]=e,s=this.locationFromPosition(o),l=this.getBlockAtIndex(s.index).getAttributes(),c=t.getBaseBlockAttributes(),d=l.slice(-c.length);if(Pt(c,d)){let T=l.slice(0,-c.length);n=t.copyWithBaseBlockAttributes(T)}else n=t.copy({consolidateBlocks:!0}).copyWithBaseBlockAttributes(l);let g=n.getBlockCount(),x=n.getBlockAtIndex(0);if(Pt(l,x.getAttributes())){let T=x.getTextWithoutBlockBreak();if(r=this.insertTextAtRange(T,e),g>1){n=new this.constructor(n.getBlocks().slice(1));let Z=o+T.getLength();r=r.insertDocumentAtRange(n,Z)}}else r=this.insertDocumentAtRange(n,e);return r}insertTextAtRange(t,e){e=A(e);let[n]=e,{index:r,offset:o}=this.locationFromPosition(n),s=this.removeTextAtRange(e);return new this.constructor(s.blockList.editObjectAtIndex(r,l=>l.copyWithText(l.text.insertTextAtPosition(t,o))))}removeTextAtRange(t){let e;t=A(t);let[n,r]=t;if(ut(t))return this;let[o,s]=Array.from(this.locationRangeFromRange(t)),l=o.index,c=o.offset,d=this.getBlockAtIndex(l),g=s.index,x=s.offset,T=this.getBlockAtIndex(g);if(r-n===1&&d.getBlockBreakPosition()===c&&T.getBlockBreakPosition()!==x&&T.text.getStringAtPosition(x)===`
`)e=this.blockList.editObjectAtIndex(g,F=>F.copyWithText(F.text.removeTextAtRange([x,x+1])));else{let F,Q=d.text.getTextAtRange([0,c]),Et=T.text.getTextAtRange([x,T.getLength()]),mt=Q.appendText(Et);l!==g&&c===0&&d.getAttributeLevel()>=T.getAttributeLevel()?F=T.copyWithText(mt):F=d.copyWithText(mt);let y=g+1-l;e=this.blockList.splice(l,y,F)}return new this.constructor(e)}moveTextFromRangeToPosition(t,e){let n;t=A(t);let[r,o]=t;if(r<=e&&e<=o)return this;let s=this.getDocumentAtRange(t),l=this.removeTextAtRange(t),c=r<e;c&&(e-=s.getLength());let[d,...g]=s.getBlocks();return g.length===0?(n=d.getTextWithoutBlockBreak(),c&&(e+=1)):n=d.text,l=l.insertTextAtRange(n,e),g.length===0?l:(s=new this.constructor(g),e+=n.getLength(),l.insertDocumentAtRange(s,e))}addAttributeAtRange(t,e,n){let{blockList:r}=this;return this.eachBlockAtRange(n,(o,s,l)=>r=r.editObjectAtIndex(l,function(){return D(t)?o.addAttribute(t,e):s[0]===s[1]?o:o.copyWithText(o.text.addAttributeAtRange(t,e,s))})),new this.constructor(r)}addAttribute(t,e){let{blockList:n}=this;return this.eachBlock((r,o)=>n=n.editObjectAtIndex(o,()=>r.addAttribute(t,e))),new this.constructor(n)}removeAttributeAtRange(t,e){let{blockList:n}=this;return this.eachBlockAtRange(e,function(r,o,s){D(t)?n=n.editObjectAtIndex(s,()=>r.removeAttribute(t)):o[0]!==o[1]&&(n=n.editObjectAtIndex(s,()=>r.copyWithText(r.text.removeAttributeAtRange(t,o))))}),new this.constructor(n)}updateAttributesForAttachment(t,e){let n=this.getRangeOfAttachment(e),[r]=Array.from(n),{index:o}=this.locationFromPosition(r),s=this.getTextAtIndex(o);return new this.constructor(this.blockList.editObjectAtIndex(o,l=>l.copyWithText(s.updateAttributesForAttachment(t,e))))}removeAttributeForAttachment(t,e){let n=this.getRangeOfAttachment(e);return this.removeAttributeAtRange(t,n)}setHTMLAttributeAtPosition(t,e,n){let r=this.getBlockAtPosition(t),o=r.addHTMLAttribute(e,n);return this.replaceBlock(r,o)}insertBlockBreakAtRange(t){let e;t=A(t);let[n]=t,{offset:r}=this.locationFromPosition(n),o=this.removeTextAtRange(t);return r===0&&(e=[new Y]),new this.constructor(o.blockList.insertSplittableListAtPosition(new Qt(e),n))}applyBlockAttributeAtRange(t,e,n){let r=this.expandRangeToLineBreaksAndSplitBlocks(n),o=r.document;n=r.range;let s=D(t);if(s.listAttribute){o=o.removeLastListAttributeAtRange(n,{exceptAttributeName:t});let l=o.convertLineBreaksToBlockBreaksInRange(n);o=l.document,n=l.range}else s.exclusive?o=o.removeBlockAttributesAtRange(n):s.terminal?o=o.removeLastTerminalAttributeAtRange(n):o=o.consolidateBlocksAtRange(n);return o.addAttributeAtRange(t,e,n)}removeLastListAttributeAtRange(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{blockList:n}=this;return this.eachBlockAtRange(t,function(r,o,s){let l=r.getLastAttribute();!l||!D(l).listAttribute||l!==e.exceptAttributeName&&(n=n.editObjectAtIndex(s,()=>r.removeAttribute(l)))}),new this.constructor(n)}removeLastTerminalAttributeAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,function(n,r,o){let s=n.getLastAttribute();!s||!D(s).terminal||(e=e.editObjectAtIndex(o,()=>n.removeAttribute(s)))}),new this.constructor(e)}removeBlockAttributesAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,function(n,r,o){n.hasAttributes()&&(e=e.editObjectAtIndex(o,()=>n.copyWithoutAttributes()))}),new this.constructor(e)}expandRangeToLineBreaksAndSplitBlocks(t){let e;t=A(t);let[n,r]=t,o=this.locationFromPosition(n),s=this.locationFromPosition(r),l=this,c=l.getBlockAtIndex(o.index);if(o.offset=c.findLineBreakInDirectionFromPosition("backward",o.offset),o.offset!=null&&(e=l.positionFromLocation(o),l=l.insertBlockBreakAtRange([e,e+1]),s.index+=1,s.offset-=l.getBlockAtIndex(o.index).getLength(),o.index+=1),o.offset=0,s.offset===0&&s.index>o.index)s.index-=1,s.offset=l.getBlockAtIndex(s.index).getBlockBreakPosition();else{let d=l.getBlockAtIndex(s.index);d.text.getStringAtRange([s.offset-1,s.offset])===`
`?s.offset-=1:s.offset=d.findLineBreakInDirectionFromPosition("forward",s.offset),s.offset!==d.getBlockBreakPosition()&&(e=l.positionFromLocation(s),l=l.insertBlockBreakAtRange([e,e+1]))}return n=l.positionFromLocation(o),r=l.positionFromLocation(s),t=A([n,r]),{document:l,range:t}}convertLineBreaksToBlockBreaksInRange(t){t=A(t);let[e]=t,n=this.getStringAtRange(t).slice(0,-1),r=this;return n.replace(/.*?\n/g,function(o){e+=o.length,r=r.insertBlockBreakAtRange([e-1,e])}),{document:r,range:t}}consolidateBlocksAtRange(t){t=A(t);let[e,n]=t,r=this.locationFromPosition(e).index,o=this.locationFromPosition(n).index;return new this.constructor(this.blockList.consolidateFromIndexToIndex(r,o))}getDocumentAtRange(t){t=A(t);let e=this.blockList.getSplittableListInRange(t).toArray();return new this.constructor(e)}getStringAtRange(t){let e,n=t=A(t);return n[n.length-1]!==this.getLength()&&(e=-1),this.getDocumentAtRange(t).toString().slice(0,e)}getBlockAtIndex(t){return this.blockList.getObjectAtIndex(t)}getBlockAtPosition(t){let{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){let{index:e}=this.locationFromPosition(t);return this.getTextAtIndex(e)}getPieceAtPosition(t){let{index:e,offset:n}=this.locationFromPosition(t);return this.getTextAtIndex(e).getPieceAtPosition(n)}getCharacterAtPosition(t){let{index:e,offset:n}=this.locationFromPosition(t);return this.getTextAtIndex(e).getStringAtRange([n,n+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 n,r;t=A(t);let[o,s]=t,l=this.locationFromPosition(o),c=this.locationFromPosition(s);if(l.index===c.index)return n=this.getBlockAtIndex(l.index),r=[l.offset,c.offset],e(n,r,l.index);for(let d=l.index;d<=c.index;d++)if(n=this.getBlockAtIndex(d),n){switch(d){case l.index:r=[l.offset,n.text.getLength()];break;case c.index:r=[0,c.offset];break;default:r=[0,n.text.getLength()]}e(n,r,d)}}getCommonAttributesAtRange(t){t=A(t);let[e]=t;if(ut(t))return this.getCommonAttributesAtPosition(e);{let n=[],r=[];return this.eachBlockAtRange(t,function(o,s){if(s[0]!==s[1])return n.push(o.text.getCommonAttributesAtRange(s)),r.push(Sr(o))}),U.fromCommonAttributesOfObjects(n).merge(U.fromCommonAttributesOfObjects(r)).toObject()}}getCommonAttributesAtPosition(t){let e,n,{index:r,offset:o}=this.locationFromPosition(t),s=this.getBlockAtIndex(r);if(!s)return{};let l=Sr(s),c=s.text.getAttributesAtPosition(o),d=s.text.getAttributesAtPosition(o-1),g=Object.keys(Lt).filter(x=>Lt[x].inheritable);for(e in d)n=d[e],(n===c[e]||g.includes(e))&&(l[e]=n);return l}getRangeOfCommonAttributeAtPosition(t,e){let{index:n,offset:r}=this.locationFromPosition(e),o=this.getTextAtIndex(n),[s,l]=Array.from(o.getExpandedRangeForAttributeAtOffset(t,r)),c=this.positionFromLocation({index:n,offset:s}),d=this.positionFromLocation({index:n,offset:l});return A([c,d])}getBaseBlockAttributes(){let t=this.getBlockAtIndex(0).getAttributes();for(let e=1;e<this.getBlockCount();e++){let n=this.getBlockAtIndex(e).getAttributes(),r=Math.min(t.length,n.length);t=(()=>{let o=[];for(let s=0;s<r&&n[s]===t[s];s++)o.push(n[s]);return o})()}return t}getAttachmentById(t){for(let e of this.getAttachments())if(e.id===t)return e}getAttachmentPieces(){let t=[];return this.blockList.eachObject(e=>{let{text:n}=e;return t=t.concat(n.getAttachmentPieces())}),t}getAttachments(){return this.getAttachmentPieces().map(t=>t.attachment)}getRangeOfAttachment(t){let e=0,n=this.blockList.toArray();for(let r=0;r<n.length;r++){let{text:o}=n[r],s=o.getRangeOfAttachment(t);if(s)return A([e+s[0],e+s[1]]);e+=o.getLength()}}getLocationRangeOfAttachment(t){let e=this.getRangeOfAttachment(t);return this.locationRangeFromRange(e)}getAttachmentPieceForAttachment(t){for(let e of this.getAttachmentPieces())if(e.attachment===t)return e}findRangesForBlockAttribute(t){let e=0,n=[];return this.getBlocks().forEach(r=>{let o=r.getLength();r.hasAttribute(t)&&n.push([e,e+o]),e+=o}),n}findRangesForTextAttribute(t){let{withValue:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=0,r=[],o=[],s=function(l){return e?l.getAttribute(t)===e:l.hasAttribute(t)};return this.getPieces().forEach(l=>{let c=l.getLength();s(l)&&(r[1]===n?r[1]=n+c:o.push(r=[n,n+c])),n+=c}),o}locationFromPosition(t){let e=this.blockList.findIndexAndOffsetAtPosition(Math.max(0,t));if(e.index!=null)return e;{let n=this.getBlocks();return{index:n.length-1,offset:n[n.length-1].getLength()}}}positionFromLocation(t){return this.blockList.findPositionAtIndexAndOffset(t.index,t.offset)}locationRangeFromPosition(t){return A(this.locationFromPosition(t))}locationRangeFromRange(t){if(t=A(t),!t)return;let[e,n]=Array.from(t),r=this.locationFromPosition(e),o=this.locationFromPosition(n);return A([r,o])}rangeFromLocationRange(t){let e;t=A(t);let n=this.positionFromLocation(t[0]);return ut(t)||(e=this.positionFromLocation(t[1])),A([n,e])}isEqualTo(t){return this.blockList.isEqualTo(t?.blockList)}getTexts(){return this.getBlocks().map(t=>t.text)}getPieces(){let 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(){let 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())))}},Sr=function(i){let t={},e=i.getLastAttribute();return e&&(t[e]=!0),t},Gn=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e="string";return i=ge(i),{string:i,attributes:t,type:e}},Js=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return{attachment:i,attributes:t,type:"attachment"}},Ys=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return{text:[],attributes:i,htmlAttributes:t}},Tr=(i,t)=>{try{return JSON.parse(i.getAttribute("data-trix-".concat(t)))}catch{return{}}},Xs=i=>{let t=i.getAttribute("width"),e=i.getAttribute("height"),n={};return t&&(n.width=parseInt(t,10)),e&&(n.height=parseInt(e,10)),n},Mt=class extends S{static parse(t,e){let n=new this(t,e);return n.parse(),n}constructor(t){let{referenceElement:e,purifyOptions:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(...arguments),this.html=t,this.referenceElement=e,this.purifyOptions=n,this.blocks=[],this.blockElements=[],this.processedElements=[]}getDocument(){return G.fromJSON(this.blocks)}parse(){try{this.createHiddenContainer(),Xt.setHTML(this.containerElement,this.html,{purifyOptions:this.purifyOptions});let t=He(this.containerElement,{usingFilter:Qs});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=p({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){let e=t.parentNode;if(e===this.currentBlockElement&&this.isBlockElement(t.previousSibling))return this.appendStringWithAttributes(`
`);if(e===this.containerElement||this.isBlockElement(e)){var n;let r=this.getBlockAttributes(e),o=this.getBlockHTMLAttributes(e);Pt(r,(n=this.currentBlock)===null||n===void 0?void 0:n.attributes)||(this.currentBlock=this.appendBlockForAttributesWithElement(r,e,o),this.currentBlockElement=e)}}appendBlockForElement(t){let e=this.isBlockElement(t),n=kt(this.currentBlockElement,t);if(e&&!this.isBlockElement(t.firstChild)){if(!this.isInsignificantTextNode(t.firstChild)||!this.isBlockElement(t.firstElementChild)){let r=this.getBlockAttributes(t),o=this.getBlockHTMLAttributes(t);if(t.firstChild)if(!(n&&Pt(r,this.currentBlock.attributes)))this.currentBlock=this.appendBlockForAttributesWithElement(r,t,o),this.currentBlockElement=t;else return this.appendStringWithAttributes(`
`)}}else if(this.currentBlockElement&&!n&&!e){let r=this.findParentBlockElement(t);if(r)return this.appendBlockForElement(r);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;if(!kr(t.parentNode)){var n;e=ki(e),io((n=t.previousSibling)===null||n===void 0?void 0:n.textContent)&&(e=$s(e))}return this.appendStringWithAttributes(e,this.getTextAttributes(t.parentNode))}processElement(t){let e;if(Dt(t)){if(e=Tr(t,"attachment"),Object.keys(e).length){let n=this.getTextAttributes(t);this.appendAttachmentWithAttributes(e,n),t.innerHTML=""}return this.processedElements.push(t)}else switch(W(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"};let n=Xs(t);for(let r in n){let o=n[r];e[r]=o}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);break}}appendBlockForAttributesWithElement(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.blockElements.push(e);let r=Ys(t,n);return this.blocks.push(r),r}appendEmptyBlock(){return this.appendBlockForAttributesWithElement([],null)}appendStringWithAttributes(t,e){return this.appendPiece(Gn(t,e))}appendAttachmentWithAttributes(t,e){return this.appendPiece(Js(t,e))}appendPiece(t){return this.blocks.length===0&&this.appendEmptyBlock(),this.blocks[this.blocks.length-1].text.push(t)}appendStringToTextAtIndex(t,e){let{text:n}=this.blocks[e],r=n[n.length-1];if(r?.type==="string")r.string+=t;else return n.push(Gn(t))}prependStringToTextAtIndex(t,e){let{text:n}=this.blocks[e],r=n[0];if(r?.type==="string")r.string=t+r.string;else return n.unshift(Gn(t))}getTextAttributes(t){let e,n={};for(let r in Lt){let o=Lt[r];if(o.tagName&&vt(t,{matchingSelector:o.tagName,untilNode:this.containerElement}))n[r]=!0;else if(o.parser){if(e=o.parser(t),e){let s=!1;for(let l of this.findBlockElementAncestors(t))if(o.parser(l)===e){s=!0;break}s||(n[r]=e)}}else o.styleProperty&&(e=t.style[o.styleProperty],e&&(n[r]=e))}if(Dt(t)){let r=Tr(t,"attributes");for(let o in r)e=r[o],n[o]=e}return n}getBlockAttributes(t){let e=[];for(;t&&t!==this.containerElement;){for(let r in z){let o=z[r];if(o.parse!==!1&&W(t)===o.tagName){var n;((n=o.test)!==null&&n!==void 0&&n.call(o,t)||!o.test)&&(e.push(r),o.listAttribute&&e.push(o.listAttribute))}}t=t.parentNode}return e.reverse()}getBlockHTMLAttributes(t){let e={},n=Object.values(z).find(o=>o.tagName===W(t));return(n?.htmlAttributes||[]).forEach(o=>{t.hasAttribute(o)&&(e[o]=t.getAttribute(o))}),e}findBlockElementAncestors(t){let e=[];for(;t&&t!==this.containerElement;){let n=W(t);pe().includes(n)&&e.push(t),t=t.parentNode}return e}isBlockElement(t){if(t?.nodeType===Node.ELEMENT_NODE&&!Dt(t)&&!vt(t,{matchingSelector:"td",untilNode:this.containerElement}))return pe().includes(W(t))||window.getComputedStyle(t).display==="block"}isInsignificantTextNode(t){if(t?.nodeType!==Node.TEXT_NODE||!ta(t.data))return;let{parentNode:e,previousSibling:n,nextSibling:r}=t;if(!(Zs(e.previousSibling)&&!this.isBlockElement(e.previousSibling))&&!kr(e))return!n||this.isBlockElement(n)||!r||this.isBlockElement(r)}isExtraBR(t){return W(t)==="br"&&this.isBlockElement(t.parentNode)&&t.parentNode.lastChild===t}needsTableSeparator(t){if(ze.removeBlankTableCells){var e;let n=(e=t.previousSibling)===null||e===void 0?void 0:e.textContent;return n&&/\S/.test(n)}else return t.previousSibling}translateBlockElementMarginsToNewlines(){let t=this.getMarginOfDefaultBlockElement();for(let e=0;e<this.blocks.length;e++){let n=this.getMarginOfBlockElementAtIndex(e);n&&(n.top>t.top*2&&this.prependStringToTextAtIndex(`
`,e),n.bottom>t.bottom*2&&this.appendStringToTextAtIndex(`
`,e))}}getMarginOfBlockElementAtIndex(t){let e=this.blockElements[t];if(e&&e.textContent&&!pe().includes(W(e))&&!this.processedElements.includes(e))return Rr(e)}getMarginOfDefaultBlockElement(){let t=p(z.default.tagName);return this.containerElement.appendChild(t),Rr(t)}},kr=function(i){let{whiteSpace:t}=window.getComputedStyle(i);return["pre","pre-wrap","pre-line"].includes(t)},Zs=i=>i&&!io(i.textContent),Rr=function(i){let t=window.getComputedStyle(i);if(t.display==="block")return{top:parseInt(t.marginTop),bottom:parseInt(t.marginBottom)}},Qs=function(i){return W(i)==="style"?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},$s=i=>i.replace(new RegExp("^".concat(Ti.source,"+")),""),ta=i=>new RegExp("^".concat(Ti.source,"*$")).test(i),io=i=>/\s$/.test(i),ea="[data-trix-serialize=false]",na=["contenteditable","data-trix-id","data-trix-store-key","data-trix-mutable","data-trix-placeholder","tabindex"],hi="data-trix-serialized-attributes",ia="[".concat(hi,"]"),ra=new RegExp("<!--block-->","g"),oa={"application/json":function(i){let t;if(i instanceof G)t=i;else if(i instanceof HTMLElement)t=Mt.parse(i.innerHTML).getDocument();else throw new Error("unserializable object");return t.toSerializableDocument().toJSONString()},"text/html":function(i){let t;if(i instanceof G)t=Zt.render(i);else if(i instanceof HTMLElement)t=i.cloneNode(!0);else throw new Error("unserializable object");return Array.from(t.querySelectorAll(ea)).forEach(e=>{yt(e)}),na.forEach(e=>{Array.from(t.querySelectorAll("[".concat(e,"]"))).forEach(n=>{n.removeAttribute(e)})}),Array.from(t.querySelectorAll(ia)).forEach(e=>{try{let n=JSON.parse(e.getAttribute(hi));e.removeAttribute(hi);for(let r in n){let o=n[r];e.setAttribute(r,o)}}catch{}}),t.innerHTML.replace(ra,"")}};var sa=function(i,t){let e=oa[t];if(e)return e(i);throw new Error("unknown content type: ".concat(t))};var aa=Object.freeze({__proto__:null}),E=class extends S{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)}};E.proxyMethod("attachment.getAttribute");E.proxyMethod("attachment.hasAttribute");E.proxyMethod("attachment.setAttribute");E.proxyMethod("attachment.getAttributes");E.proxyMethod("attachment.setAttributes");E.proxyMethod("attachment.isPending");E.proxyMethod("attachment.isPreviewable");E.proxyMethod("attachment.getURL");E.proxyMethod("attachment.getPreviewURL");E.proxyMethod("attachment.setPreviewURL");E.proxyMethod("attachment.getHref");E.proxyMethod("attachment.getFilename");E.proxyMethod("attachment.getFilesize");E.proxyMethod("attachment.getFormattedFilesize");E.proxyMethod("attachment.getExtension");E.proxyMethod("attachment.getContentType");E.proxyMethod("attachment.getFile");E.proxyMethod("attachment.setFile");E.proxyMethod("attachment.releaseFile");E.proxyMethod("attachment.getUploadProgress");E.proxyMethod("attachment.setUploadProgress");var $e=class extends S{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(){let t=[];for(let e in this.managedAttachments){let n=this.managedAttachments[e];t.push(n)}return t}manageAttachment(t){return this.managedAttachments[t.id]||(this.managedAttachments[t.id]=new E(this,t)),this.managedAttachments[t.id]}attachmentIsManaged(t){return t.id in this.managedAttachments}requestRemovalOfAttachment(t){if(this.attachmentIsManaged(t)){var e,n;return(e=this.delegate)===null||e===void 0||(n=e.attachmentManagerDidRequestRemovalOfAttachment)===null||n===void 0?void 0:n.call(e,t)}}unmanageAttachment(t){let e=this.managedAttachments[t.id];return delete this.managedAttachments[t.id],e}},tn=class{constructor(t){this.composition=t,this.document=this.composition.document;let 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()}},Dr=" ",it=class extends S{constructor(){super(...arguments),this.document=new G,this.attachments=[],this.currentAttributes={},this.revision=0}setDocument(t){if(!t.isEqualTo(this.document)){var e,n;return this.document=t,this.refreshAttachments(),this.revision++,(e=this.delegate)===null||e===void 0||(n=e.compositionDidChangeDocument)===null||n===void 0?void 0:n.call(e,t)}}getSnapshot(){return{document:this.document,selectedRange:this.getSelectedRange()}}loadSnapshot(t){var e,n,r,o;let{document:s,selectedRange:l}=t;return(e=this.delegate)===null||e===void 0||(n=e.compositionWillLoadSnapshot)===null||n===void 0||n.call(e),this.setDocument(s??new G),this.setSelection(l??[0,0]),(r=this.delegate)===null||r===void 0||(o=r.compositionDidLoadSnapshot)===null||o===void 0?void 0:o.call(r)}insertText(t){let{updatePosition:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{updatePosition:!0},n=this.getSelectedRange();this.setDocument(this.document.insertTextAtRange(t,n));let r=n[0],o=r+t.getLength();return e&&this.setSelection(o),this.notifyDelegateOfInsertionAtRange([r,o])}insertBlock(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Y,e=new G([t]);return this.insertDocument(e)}insertDocument(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new G,e=this.getSelectedRange();this.setDocument(this.document.insertDocumentAtRange(t,e));let n=e[0],r=n+t.getLength();return this.setSelection(r),this.notifyDelegateOfInsertionAtRange([n,r])}insertString(t,e){let n=this.getCurrentTextAttributes(),r=K.textForStringWithAttributes(t,n);return this.insertText(r,e)}insertBlockBreak(){let t=this.getSelectedRange();this.setDocument(this.document.insertBlockBreakAtRange(t));let e=t[0],n=e+1;return this.setSelection(n),this.notifyDelegateOfInsertionAtRange([e,n])}insertLineBreak(){let t=new tn(this);if(t.shouldDecreaseListLevel())return this.decreaseListLevel(),this.setSelection(t.startPosition);if(t.shouldPrependListItem()){let e=new G([t.block.copyWithoutText()]);return this.insertDocument(e)}else return t.shouldInsertBlockBreak()?this.insertBlockBreak():t.shouldRemoveLastBlockAttribute()?this.removeLastBlockAttribute():t.shouldBreakFormattedBlock()?this.breakFormattedBlock(t):this.insertString(`
`)}insertHTML(t){let e=Mt.parse(t,{purifyOptions:{SAFE_FOR_XML:!0}}).getDocument(),n=this.getSelectedRange();this.setDocument(this.document.mergeDocumentAtRange(e,n));let r=n[0],o=r+e.getLength()-1;return this.setSelection(o),this.notifyDelegateOfInsertionAtRange([r,o])}replaceHTML(t){let e=Mt.parse(t).getDocument().copyUsingObjectsFromDocument(this.document),n=this.getLocationRange({strict:!1}),r=this.document.rangeFromLocationRange(n);return this.setDocument(e),this.setSelection(r)}insertFile(t){return this.insertFiles([t])}insertFiles(t){let e=[];return Array.from(t).forEach(n=>{var r;if((r=this.delegate)!==null&&r!==void 0&&r.compositionShouldAcceptFile(n)){let o=At.attachmentForFile(n);e.push(o)}}),this.insertAttachments(e)}insertAttachment(t){return this.insertAttachments([t])}insertAttachments(t){let e=new K;return Array.from(t).forEach(n=>{var r;let o=n.getType(),s=(r=yi[o])===null||r===void 0?void 0:r.presentation,l=this.getCurrentTextAttributes();s&&(l.presentation=s);let c=K.textForAttachmentWithAttributes(n,l);e=e.appendText(c)}),this.insertText(e)}shouldManageDeletingInDirection(t){let e=this.getLocationRange();if(ut(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{length:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n,r,o,s=this.getLocationRange(),l=this.getSelectedRange(),c=ut(l);if(c?r=t==="backward"&&s[0].offset===0:o=s[0].index!==s[1].index,r&&this.canDecreaseBlockAttributeLevel()){let d=this.getBlock();if(d.isListItem()?this.decreaseListLevel():this.decreaseBlockAttributeLevel(),this.setSelection(l[0]),d.isEmpty())return!1}if(c&&(l=this.getExpandedRangeInDirection(t,{length:e}),t==="backward"&&(n=this.getAttachmentAtRange(l))),n)return this.editAttachment(n),!1;if(this.setDocument(this.document.removeTextAtRange(l)),this.setSelection(l[0]),r||o)return!1}moveTextFromRange(t){let[e]=Array.from(this.getSelectedRange());return this.setDocument(this.document.moveTextFromRangeToPosition(t,e)),this.setSelection(e)}removeAttachment(t){let e=this.document.getRangeOfAttachment(t);if(e)return this.stopEditingAttachment(),this.setDocument(this.document.removeTextAtRange(e)),this.setSelection(e[0])}removeLastBlockAttribute(){let[t,e]=Array.from(this.getSelectedRange()),n=this.document.getBlockAtPosition(e);return this.removeCurrentAttribute(n.getLastAttribute()),this.setSelection(t)}insertPlaceholder(){return this.placeholderPosition=this.getPosition(),this.insertString(Dr)}selectPlaceholder(){if(this.placeholderPosition!=null)return this.setSelectedRange([this.placeholderPosition,this.placeholderPosition+Dr.length]),this.getSelectedRange()}forgetPlaceholder(){this.placeholderPosition=null}hasCurrentAttribute(t){let e=this.currentAttributes[t];return e!=null&&e!==!1}toggleCurrentAttribute(t){let 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){let e=this.getSelectedDocument();if(!!e){for(let n of Array.from(e.getAttachments()))if(!n.hasContent())return!1;return!0}}canSetCurrentBlockAttribute(t){let 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,n){var r;let o=this.document.getBlockAtPosition(t),s=(r=D(o.getLastAttribute()))===null||r===void 0?void 0:r.htmlAttributes;if(o&&s!==null&&s!==void 0&&s.includes(e)){let l=this.document.setHTMLAttributeAtPosition(t,e,n);this.setDocument(l)}}setTextAttribute(t,e){let n=this.getSelectedRange();if(!n)return;let[r,o]=Array.from(n);if(r===o){if(t==="href"){let s=K.textForStringWithAttributes(e,{href:e});return this.insertText(s)}}else return this.setDocument(this.document.addAttributeAtRange(t,e,n))}setBlockAttribute(t,e){let n=this.getSelectedRange();if(this.canSetCurrentAttribute(t))return this.setDocument(this.document.applyBlockAttributeAtRange(t,e,n)),this.setSelection(n)}removeCurrentAttribute(t){return D(t)?(this.removeBlockAttribute(t),this.updateCurrentAttributes()):(this.removeTextAttribute(t),delete this.currentAttributes[t],this.notifyDelegateOfCurrentAttributesChange())}removeTextAttribute(t){let e=this.getSelectedRange();if(!!e)return this.setDocument(this.document.removeAttributeAtRange(t,e))}removeBlockAttribute(t){let 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;let e=this.getBlock();if(!!e)if((t=D(e.getLastNestableAttribute()))!==null&&t!==void 0&&t.listAttribute){let n=this.getPreviousBlock();if(n)return Uo(n.getListItemAttributes(),e.getListItemAttributes())}else return e.getNestingLevel()>0}decreaseNestingLevel(){let t=this.getBlock();if(!!t)return this.setDocument(this.document.replaceBlock(t,t.decreaseNestingLevel()))}increaseNestingLevel(){let 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;let 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()),{index:e}=this.document.locationFromPosition(t),n=e,r=this.getBlock().getAttributeLevel(),o=this.document.getBlockAtIndex(n+1);for(;o&&!(!o.isListItem()||o.getAttributeLevel()<=r);)n++,o=this.document.getBlockAtIndex(n+1);t=this.document.positionFromLocation({index:e,offset:0});let s=this.document.positionFromLocation({index:n,offset:0});return this.setDocument(this.document.removeLastListAttributeAtRange([t,s]))}updateCurrentAttributes(){let t=this.getSelectedRange({ignoreLock:!0});if(t){let e=this.document.getCommonAttributesAtRange(t);if(Array.from(ri()).forEach(n=>{e[n]||this.canSetCurrentAttribute(n)||(e[n]=!1)}),!ee(e,this.currentAttributes))return this.currentAttributes=e,this.notifyDelegateOfCurrentAttributesChange()}}getCurrentAttributes(){return _r.call({},this.currentAttributes)}getCurrentTextAttributes(){let t={};for(let e in this.currentAttributes){let n=this.currentAttributes[e];n!==!1&&oi(e)&&(t[e]=n)}return t}freezeSelection(){return this.setCurrentAttribute("frozen",!0)}thawSelection(){return this.removeCurrentAttribute("frozen")}hasFrozenSelection(){return this.hasCurrentAttribute("frozen")}setSelection(t){var e;let n=this.document.locationRangeFromRange(t);return(e=this.delegate)===null||e===void 0?void 0:e.compositionDidRequestChangingSelectionToLocationRange(n)}getSelectedRange(){let t=this.getLocationRange();if(t)return this.document.rangeFromLocationRange(t)}setSelectedRange(t){let e=this.document.locationRangeFromRange(t);return this.getSelectionManager().setLocationRange(e)}getPosition(){let t=this.getLocationRange();if(t)return this.document.positionFromLocation(t[0])}getLocationRange(t){return this.targetLocationRange?this.targetLocationRange:this.getSelectionManager().getLocationRange(t)||A({index:0,offset:0})}withTargetLocationRange(t,e){let n;this.targetLocationRange=t;try{n=e()}finally{this.targetLocationRange=null}return n}withTargetRange(t,e){let n=this.document.locationRangeFromRange(t);return this.withTargetLocationRange(n,e)}withTargetDOMRange(t,e){let n=this.createLocationRangeFromDOMRange(t,{strict:!1});return this.withTargetLocationRange(n,e)}getExpandedRangeInDirection(t){let{length:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},[n,r]=Array.from(this.getSelectedRange());return t==="backward"?e?n-=e:n=this.translateUTF16PositionFromOffset(n,-1):e?r+=e:r=this.translateUTF16PositionFromOffset(r,1),A([n,r])}shouldManageMovingCursorInDirection(t){if(this.editingAttachment)return!0;let e=this.getExpandedRangeInDirection(t);return this.getAttachmentAtRange(e)!=null}moveCursorInDirection(t){let e,n;if(this.editingAttachment)n=this.document.getRangeOfAttachment(this.editingAttachment);else{let r=this.getSelectedRange();n=this.getExpandedRangeInDirection(t),e=!gn(r,n)}if(t==="backward"?this.setSelectedRange(n[0]):this.setSelectedRange(n[1]),e){let r=this.getAttachmentAtRange(n);if(r)return this.editAttachment(r)}}expandSelectionInDirection(t){let{length:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.getExpandedRangeInDirection(t,{length:e});return this.setSelectedRange(n)}expandSelectionForEditing(){if(this.hasCurrentAttribute("href"))return this.expandSelectionAroundCommonAttribute("href")}expandSelectionAroundCommonAttribute(t){let e=this.getPosition(),n=this.document.getRangeOfCommonAttributeAtPosition(t,e);return this.setSelectedRange(n)}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){let 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(){let 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(){let t=this.document.getAttachments(),{added:e,removed:n}=Vo(this.attachments,t);return this.attachments=t,Array.from(n).forEach(r=>{var o,s;r.delegate=null,(o=this.delegate)===null||o===void 0||(s=o.compositionDidRemoveAttachment)===null||s===void 0||s.call(o,r)}),(()=>{let r=[];return Array.from(e).forEach(o=>{var s,l;o.delegate=this,r.push((s=this.delegate)===null||s===void 0||(l=s.compositionDidAddAttachment)===null||l===void 0?void 0:l.call(s,o))}),r})()}attachmentDidChangeAttributes(t){var e,n;return this.revision++,(e=this.delegate)===null||e===void 0||(n=e.compositionDidEditAttachment)===null||n===void 0?void 0:n.call(e,t)}attachmentDidChangePreviewURL(t){var e,n;return this.revision++,(e=this.delegate)===null||e===void 0||(n=e.compositionDidChangeAttachmentPreviewURL)===null||n===void 0?void 0:n.call(e,t)}editAttachment(t,e){var n,r;if(t!==this.editingAttachment)return this.stopEditingAttachment(),this.editingAttachment=t,(n=this.delegate)===null||n===void 0||(r=n.compositionDidStartEditingAttachment)===null||r===void 0?void 0:r.call(n,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,{block:n}=t,r=t.startPosition,o=[r-1,r];n.getBlockBreakPosition()===t.startLocation.offset?(n.breaksOnReturn()&&t.nextCharacter===`
`?r+=1:e=e.removeTextAtRange(o),o=[r,r]):t.nextCharacter===`
`?t.previousCharacter===`
`?o=[r-1,r+1]:(o=[r,r+1],r+=1):t.startLocation.offset-1!==0&&(r+=1);let s=new G([n.removeLastAttribute().copyWithoutText()]);return this.setDocument(e.insertDocumentAtRange(s,o)),this.setSelection(r)}getPreviousBlock(){let t=this.getLocationRange();if(t){let{index:e}=t[0];if(e>0)return this.document.getBlockAtIndex(e-1)}}getBlock(){let t=this.getLocationRange();if(t)return this.document.getBlockAtIndex(t[0].index)}getAttachmentAtRange(t){let e=this.document.getDocumentAtRange(t);if(e.toString()==="".concat(Ai,`
`))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,n;return(e=this.delegate)===null||e===void 0||(n=e.compositionDidPerformInsertionAtRange)===null||n===void 0?void 0:n.call(e,t)}translateUTF16PositionFromOffset(t,e){let n=this.document.toUTF16String(),r=n.offsetFromUCS2Offset(t);return n.offsetToUCS2Offset(r+e)}};it.proxyMethod("getSelectionManager().getPointRange");it.proxyMethod("getSelectionManager().setLocationRangeFromPointRange");it.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange");it.proxyMethod("getSelectionManager().locationIsCursorTarget");it.proxyMethod("getSelectionManager().selectionIsExpanded");it.proxyMethod("delegate?.getSelectionManager");var Ce=class extends S{constructor(t){super(...arguments),this.composition=t,this.undoEntries=[],this.redoEntries=[]}recordUndoEntry(t){let{context:e,consolidatable:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.undoEntries.slice(-1)[0];if(!n||!la(r,t,e)){let o=this.createEntry({description:t,context:e});this.undoEntries.push(o),this.redoEntries=[]}}undo(){let t=this.undoEntries.pop();if(t){let e=this.createEntry(t);return this.redoEntries.push(e),this.composition.loadSnapshot(t.snapshot)}}redo(){let t=this.redoEntries.pop();if(t){let 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?.toString(),context:JSON.stringify(e),snapshot:this.composition.getSnapshot()}}},la=(i,t,e)=>i?.description===t?.toString()&&i?.context===JSON.stringify(e),Kn="attachmentGallery",ca="presentation",ua="gallery",en=class{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(Kn,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(Kn,!0,e))})}findRangesOfBlocks(){return this.document.findRangesForBlockAttribute(Kn)}findRangesOfPieces(){return this.document.findRangesForTextAttribute(ca,{withValue:ua})}moveSelectedRangeForward(){this.selectedRange[0]+=1,this.selectedRange[1]+=1}},ro=function(i){let t=new en(i);return t.perform(),t.getSnapshot()},da=[ro],nn=class{constructor(t,e,n){this.insertFiles=this.insertFiles.bind(this),this.composition=t,this.selectionManager=e,this.element=n,this.undoManager=new Ce(this.composition),this.filters=da.slice(0)}loadDocument(t){return this.loadSnapshot({document:t,selectedRange:[0,0]})}loadHTML(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",e=Mt.parse(t,{referenceElement:this.element}).getDocument();return this.loadDocument(e)}loadJSON(t){let{document:e,selectedRange:n}=t;return e=G.fromJSON(e),this.loadSnapshot({document:e,selectedRange:n})}loadSnapshot(t){return this.undoManager=new Ce(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){let 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]:!0;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,n){this.composition.setHTMLAtributeAtPosition(t,e,n)}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:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.undoManager.recordUndoEntry(t,{context:e,consolidatable:n})}redo(){if(this.canRedo())return this.undoManager.redo()}undo(){if(this.canUndo())return this.undoManager.undo()}},rn=class{constructor(t){this.element=t}findLocationFromContainerAndOffset(t,e){let{strict:n}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{strict:!0},r=0,o=!1,s={index:0,offset:0},l=this.findAttachmentElementParentForNode(t);l&&(t=l.parentNode,e=On(l));let c=He(this.element,{usingFilter:oo});for(;c.nextNode();){let d=c.currentNode;if(d===t&&be(t)){Kt(d)||(s.offset+=e);break}else{if(d.parentNode===t){if(r++===e)break}else if(!kt(t,d)&&r>0)break;er(d,{strict:n})?(o&&s.index++,s.offset=0,o=!0):s.offset+=Jn(d)}}return s}findContainerAndOffsetFromLocation(t){let e,n;if(t.index===0&&t.offset===0){for(e=this.element,n=0;e.firstChild;)if(e=e.firstChild,Pn(e)){n=1;break}return[e,n]}let[r,o]=this.findNodeAndOffsetFromLocation(t);if(!!r){if(be(r))Jn(r)===0?(e=r.parentNode.parentNode,n=On(r.parentNode),Kt(r,{name:"right"})&&n++):(e=r,n=t.offset-o);else{if(e=r.parentNode,!er(r.previousSibling)&&!Pn(e))for(;r===e.lastChild&&(r=e,e=e.parentNode,!Pn(e)););n=On(r),t.offset!==0&&n++}return[e,n]}}findNodeAndOffsetFromLocation(t){let e,n,r=0;for(let o of this.getSignificantNodesForIndex(t.index)){let s=Jn(o);if(t.offset<=r+s)if(be(o)){if(e=o,n=r,t.offset===n&&Kt(e))break}else e||(e=o,n=r);if(r+=s,r>t.offset)break}return[e,n]}findAttachmentElementParentForNode(t){for(;t&&t!==this.element;){if(Dt(t))return t;t=t.parentNode}}getSignificantNodesForIndex(t){let e=[],n=He(this.element,{usingFilter:ha}),r=!1;for(;n.nextNode();){let s=n.currentNode;if(Gt(s)){var o;if(o!=null?o++:o=0,o===t)r=!0;else if(r)break}else r&&e.push(s)}return e}},Jn=function(i){return i.nodeType===Node.TEXT_NODE?Kt(i)?0:i.textContent.length:W(i)==="br"||Dt(i)?1:0},ha=function(i){return fa(i)===NodeFilter.FILTER_ACCEPT?oo(i):NodeFilter.FILTER_REJECT},fa=function(i){return zr(i)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},oo=function(i){return Dt(i.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},on=class{createDOMRangeFromPoint(t){let{x:e,y:n}=t,r;if(document.caretPositionFromPoint){let{offsetNode:o,offset:s}=document.caretPositionFromPoint(e,n);return r=document.createRange(),r.setStart(o,s),r}else{if(document.caretRangeFromPoint)return document.caretRangeFromPoint(e,n);if(document.body.createTextRange){let o=ve();try{let s=document.body.createTextRange();s.moveToPoint(e,n),s.select()}catch{}return r=ve(),Jr(o),r}}}getClientRectsForDOMRange(t){let e=Array.from(t.getClientRects()),n=e[0],r=e[e.length-1];return[n,r]}},gt=class extends S{constructor(t){super(...arguments),this.didMouseDown=this.didMouseDown.bind(this),this.selectionDidChange=this.selectionDidChange.bind(this),this.element=t,this.locationMapper=new rn(this.element),this.pointMapper=new on,this.lockCount=0,C("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(ve()):t.ignoreLock?this.currentLocationRange:this.lockedLocationRange?this.lockedLocationRange:this.currentLocationRange}setLocationRange(t){if(this.lockedLocationRange)return;t=A(t);let e=this.createDOMRangeFromLocationRange(t);e&&(Jr(e),this.updateCurrentLocationRange(t))}setLocationRangeFromPointRange(t){t=A(t);let e=this.getLocationAtPoint(t[0]),n=this.getLocationAtPoint(t[1]);this.setLocationRange([e,n])}getClientRectAtLocationRange(t){let e=this.createDOMRangeFromLocationRange(t);if(e)return this.getClientRectsForDOMRange(e)[1]}locationIsCursorTarget(t){let 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){let{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=ve())===null||t===void 0?void 0:t.collapsed)===!0}selectionIsExpanded(){return!this.selectionIsCollapsed()}createLocationRangeFromDOMRange(t,e){if(t==null||!this.domRangeWithinElement(t))return;let n=this.findLocationFromContainerAndOffset(t.startContainer,t.startOffset,e);if(!n)return;let r=t.collapsed?void 0:this.findLocationFromContainerAndOffset(t.endContainer,t.endOffset,e);return A([n,r])}didMouseDown(){return this.pauseTemporarily()}pauseTemporarily(){let t;this.paused=!0;let e=()=>{if(this.paused=!1,clearTimeout(n),Array.from(t).forEach(r=>{r.destroy()}),kt(document,this.element))return this.selectionDidChange()},n=setTimeout(e,200);t=["mousemove","keydown"].map(r=>C(r,{onElement:document,withCallback:e}))}selectionDidChange(){if(!this.paused&&!Ei(this.element))return this.updateCurrentLocationRange()}updateCurrentLocationRange(t){if((t??(t=this.createLocationRangeFromDOMRange(ve())))&&!gn(t,this.currentLocationRange)){var e,n;return this.currentLocationRange=t,(e=this.delegate)===null||e===void 0||(n=e.locationRangeDidChange)===null||n===void 0?void 0:n.call(e,this.currentLocationRange.slice(0))}}createDOMRangeFromLocationRange(t){let e=this.findContainerAndOffsetFromLocation(t[0]),n=ut(t)?e:this.findContainerAndOffsetFromLocation(t[1])||e;if(e!=null&&n!=null){let r=document.createRange();return r.setStart(...Array.from(e||[])),r.setEnd(...Array.from(n||[])),r}}getLocationAtPoint(t){let e=this.createDOMRangeFromPoint(t);if(e){var n;return(n=this.createLocationRangeFromDOMRange(e))===null||n===void 0?void 0:n[0]}}domRangeWithinElement(t){return t.collapsed?kt(this.element,t.startContainer):kt(this.element,t.startContainer)&&kt(this.element,t.endContainer)}};gt.proxyMethod("locationMapper.findLocationFromContainerAndOffset");gt.proxyMethod("locationMapper.findContainerAndOffsetFromLocation");gt.proxyMethod("locationMapper.findNodeAndOffsetFromLocation");gt.proxyMethod("pointMapper.createDOMRangeFromPoint");gt.proxyMethod("pointMapper.getClientRectsForDOMRange");var so=Object.freeze({__proto__:null,Attachment:At,AttachmentManager:$e,AttachmentPiece:xt,Block:Y,Composition:it,Document:G,Editor:nn,HTMLParser:Mt,HTMLSanitizer:Xt,LineBreakInsertion:tn,LocationMapper:rn,ManagedAttachment:E,Piece:ft,PointMapper:on,SelectionManager:gt,SplittableList:Qt,StringPiece:we,Text:K,UndoManager:Ce}),ga=Object.freeze({__proto__:null,ObjectView:ht,AttachmentView:Ee,BlockView:Ze,DocumentView:Zt,PieceView:Ye,PreviewableAttachmentView:Je,TextView:Xe}),{lang:Yn,css:Tt,keyNames:ma}=Te,Xn=function(i){return function(){let t=i.apply(this,arguments);t.do(),this.undos||(this.undos=[]),this.undos.push(t.undo)}},sn=class extends S{constructor(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(...arguments),B(this,"makeElementMutable",Xn(()=>({do:()=>{this.element.dataset.trixMutable=!0},undo:()=>delete this.element.dataset.trixMutable}))),B(this,"addToolbar",Xn(()=>{let o=p({tagName:"div",className:Tt.attachmentToolbar,data:{trixMutable:!0},childNodes:p({tagName:"div",className:"trix-button-row",childNodes:p({tagName:"span",className:"trix-button-group trix-button-group--actions",childNodes:p({tagName:"button",className:"trix-button trix-button--remove",textContent:Yn.remove,attributes:{title:Yn.remove},data:{trixAction:"remove"}})})})});return this.attachment.isPreviewable()&&o.appendChild(p({tagName:"div",className:Tt.attachmentMetadataContainer,childNodes:p({tagName:"span",className:Tt.attachmentMetadata,childNodes:[p({tagName:"span",className:Tt.attachmentName,textContent:this.attachment.getFilename(),attributes:{title:this.attachment.getFilename()}}),p({tagName:"span",className:Tt.attachmentSize,textContent:this.attachment.getFormattedFilesize()})]})})),C("click",{onElement:o,withCallback:this.didClickToolbar}),C("click",{onElement:o,matchingSelector:"[data-trix-action]",withCallback:this.didClickActionButton}),me("trix-attachment-before-toolbar",{onElement:this.element,attributes:{toolbar:o,attachment:this.attachment}}),{do:()=>this.element.appendChild(o),undo:()=>yt(o)}})),B(this,"installCaptionEditor",Xn(()=>{let o=p({tagName:"textarea",className:Tt.attachmentCaptionEditor,attributes:{placeholder:Yn.captionPlaceholder},data:{trixMutable:!0}});o.value=this.attachmentPiece.getCaption();let s=o.cloneNode();s.classList.add("trix-autoresize-clone"),s.tabIndex=-1;let l=function(){s.value=o.value,o.style.height=s.scrollHeight+"px"};C("input",{onElement:o,withCallback:l}),C("input",{onElement:o,withCallback:this.didInputCaption}),C("keydown",{onElement:o,withCallback:this.didKeyDownCaption}),C("change",{onElement:o,withCallback:this.didChangeCaption}),C("blur",{onElement:o,withCallback:this.didBlurCaption});let c=this.element.querySelector("figcaption"),d=c.cloneNode();return{do:()=>{if(c.style.display="none",d.appendChild(o),d.appendChild(s),d.classList.add("".concat(Tt.attachmentCaption,"--editing")),c.parentElement.insertBefore(d,c),l(),this.options.editCaption)return Si(()=>o.focus())},undo(){yt(d),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=n,this.options=r,this.attachment=this.attachmentPiece.attachment,W(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){let o=this.pendingCaption;if(this.pendingCaption=null,o){var t,e;(t=this.delegate)===null||t===void 0||(e=t.attachmentEditorDidRequestUpdatingAttributesForAttachment)===null||e===void 0||e.call(t,{caption:o},this.attachment)}else{var n,r;(n=this.delegate)===null||n===void 0||(r=n.attachmentEditorDidRequestRemovingAttributeForAttachment)===null||r===void 0||r.call(n,"caption",this.attachment)}}}didClickToolbar(t){return t.preventDefault(),t.stopPropagation()}didClickActionButton(t){var e;switch(t.target.getAttribute("data-trix-action")){case"remove":return(e=this.delegate)===null||e===void 0?void 0:e.attachmentEditorDidRequestRemovalOfAttachment(this.attachment)}}didKeyDownCaption(t){if(ma[t.keyCode]==="return"){var e,n;return t.preventDefault(),this.savePendingCaption(),(e=this.delegate)===null||e===void 0||(n=e.attachmentEditorDidRequestDeselectingAttachment)===null||n===void 0?void 0:n.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()}},an=class extends S{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 Zt(this.composition.document,{element:this.element}),C("focus",{onElement:this.element,withCallback:this.didFocus}),C("blur",{onElement:this.element,withCallback:this.didBlur}),C("click",{onElement:this.element,matchingSelector:"a[contenteditable=false]",preventDefault:!0}),C("mousedown",{onElement:this.element,matchingSelector:Rt,withCallback:this.didClickAttachment}),C("click",{onElement:this.element,matchingSelector:"a".concat(Rt),preventDefault:!0})}didFocus(t){var e;let n=()=>{if(!this.focused){var r,o;return this.focused=!0,(r=this.delegate)===null||r===void 0||(o=r.compositionControllerDidFocus)===null||o===void 0?void 0:o.call(r)}};return((e=this.blurPromise)===null||e===void 0?void 0:e.then(n))||n()}didBlur(t){this.blurPromise=new Promise(e=>Si(()=>{if(!Ei(this.element)){var n,r;this.focused=null,(n=this.delegate)===null||n===void 0||(r=n.compositionControllerDidBlur)===null||r===void 0||r.call(n)}return this.blurPromise=null,e()}))}didClickAttachment(t,e){var n,r;let o=this.findAttachmentForElement(e),s=!!vt(t.target,{matchingSelector:"figcaption"});return(n=this.delegate)===null||n===void 0||(r=n.compositionControllerDidSelectAttachment)===null||r===void 0?void 0:r.call(n,o,{editCaption:s})}getSerializableElement(){return this.isEditingAttachment()?this.documentView.shadowElement:this.element}render(){var t,e;if(this.revision!==this.composition.revision&&(this.documentView.setDocument(this.composition.document),this.documentView.render(),this.revision=this.composition.revision),this.canSyncDocumentView()&&!this.documentView.isSynced()){var n,r,o,s;(n=this.delegate)===null||n===void 0||(r=n.compositionControllerWillSyncDocumentView)===null||r===void 0||r.call(n),this.documentView.sync(),(o=this.delegate)===null||o===void 0||(s=o.compositionControllerDidSyncDocumentView)===null||s===void 0||s.call(o)}return(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 n;if(((n=this.attachmentEditor)===null||n===void 0?void 0:n.attachment)===t)return;let r=this.documentView.findElementForObject(t);if(!r)return;this.uninstallAttachmentEditor();let o=this.composition.document.getAttachmentPieceForAttachment(t);this.attachmentEditor=new sn(o,r,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 n,r;return(n=this.delegate)===null||n===void 0||(r=n.compositionControllerWillUpdateAttachment)===null||r===void 0||r.call(n,e),this.composition.updateAttributesForAttachment(t,e)}attachmentEditorDidRequestRemovingAttributeForAttachment(t,e){var n,r;return(n=this.delegate)===null||n===void 0||(r=n.compositionControllerWillUpdateAttachment)===null||r===void 0||r.call(n,e),this.composition.removeAttributeForAttachment(t,e)}attachmentEditorDidRequestRemovalOfAttachment(t){var e,n;return(e=this.delegate)===null||e===void 0||(n=e.compositionControllerDidRequestRemovalOfAttachment)===null||n===void 0?void 0:n.call(e,t)}attachmentEditorDidRequestDeselectingAttachment(t){var e,n;return(e=this.delegate)===null||e===void 0||(n=e.compositionControllerDidRequestDeselectingAttachment)===null||n===void 0?void 0:n.call(e,t)}canSyncDocumentView(){return!this.isEditingAttachment()}findAttachmentForElement(t){return this.composition.document.getAttachmentById(parseInt(t.dataset.trixId,10))}},ln=class extends S{},ao="data-trix-mutable",pa="[".concat(ao,"]"),ba={attributes:!0,childList:!0,characterData:!0,characterDataOldValue:!0,subtree:!0},cn=class extends S{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,ba)}stop(){return this.observer.disconnect()}didMutate(t){if(this.mutations.push(...Array.from(this.findSignificantMutations(t)||[])),this.mutations.length){var e,n;return(e=this.delegate)===null||e===void 0||(n=e.elementDidMutate)===null||n===void 0||n.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(let e of Array.from(this.nodesModifiedByMutation(t)))if(this.nodeIsSignificant(e))return!0;return!1}nodeIsSignificant(t){return t!==this.element&&!this.nodeIsMutable(t)&&!zr(t)}nodeIsMutable(t){return vt(t,{matchingSelector:pa})}nodesModifiedByMutation(t){let e=[];switch(t.type){case"attributes":t.attributeName!==ao&&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||[]));break}return e}getMutationSummary(){return this.getTextMutationSummary()}getTextMutationSummary(){let{additions:t,deletions:e}=this.getTextChangesFromCharacterData(),n=this.getTextChangesFromChildList();Array.from(n.additions).forEach(l=>{Array.from(t).includes(l)||t.push(l)}),e.push(...Array.from(n.deletions||[]));let r={},o=t.join("");o&&(r.textAdded=o);let s=e.join("");return s&&(r.textDeleted=s),r}getMutationsByType(t){return Array.from(this.mutations).filter(e=>e.type===t)}getTextChangesFromChildList(){let t,e,n=[],r=[];Array.from(this.getMutationsByType("childList")).forEach(c=>{n.push(...Array.from(c.addedNodes||[])),r.push(...Array.from(c.removedNodes||[]))}),n.length===0&&r.length===1&&Gt(r[0])?(t=[],e=[`
`]):(t=fi(n),e=fi(r));let s=t.filter((c,d)=>c!==e[d]).map(ge),l=e.filter((c,d)=>c!==t[d]).map(ge);return{additions:s,deletions:l}}getTextChangesFromCharacterData(){let t,e,n=this.getMutationsByType("characterData");if(n.length){let r=n[0],o=n[n.length-1],s=ge(r.oldValue),l=ge(o.target.data),c=ns(s,l);t=c.added,e=c.removed}return{additions:t?[t]:[],deletions:e?[e]:[]}}},fi=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=[];for(let e of Array.from(i))switch(e.nodeType){case Node.TEXT_NODE:t.push(e.data);break;case Node.ELEMENT_NODE:W(e)==="br"?t.push(`
`):t.push(...Array.from(fi(e.childNodes)||[]));break}return t},un=class extends Yt{constructor(t){super(...arguments),this.file=t}perform(t){let 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)}},gi=class{constructor(t){this.element=t}shouldIgnore(t){return Se.samsungAndroid?(this.previousEvent=this.event,this.event=t,this.checkSamsungKeyboardBuggyModeStart(),this.checkSamsungKeyboardBuggyModeEnd(),this.buggyMode):!1}checkSamsungKeyboardBuggyModeStart(){this.insertingLongTextAfterUnidentifiedChar()&&va(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"}},va=(i,t)=>Lr(i)===Lr(t),ya=new RegExp("(".concat(Ai,"|").concat(fn,"|").concat(bt,"|\\s)+"),"g"),Lr=i=>i.replace(ya," ").trim(),$t=class extends S{constructor(t){super(...arguments),this.element=t,this.mutationObserver=new cn(this.element),this.mutationObserver.delegate=this,this.flakyKeyboardDetector=new gi(this.element);for(let e in this.constructor.events)C(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){let e=Array.from(t).map(n=>new un(n));return Promise.all(e).then(n=>{this.handleInput(function(){var r,o;return(r=this.delegate)===null||r===void 0||r.inputControllerWillAttachFiles(),(o=this.responder)===null||o===void 0||o.insertFiles(n),this.requestRender()})})}handlerFor(t){return e=>{e.defaultPrevented||this.handleInput(()=>{if(!Ei(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 n;(n=this.delegate)===null||n===void 0||n.inputControllerDidHandleInput()}}createLinkHTML(t,e){let n=document.createElement("a");return n.href=t,n.textContent=e||t,n.outerHTML}};B($t,"events",{});var Zn,Or,{browser:Aa,keyNames:lo}=Te,xa=0,et=class extends $t{constructor(){super(...arguments),this.resetInputSummary()}setInputSummary(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.inputSummary.eventName=this.eventName;for(let e in t){let n=t[e];this.inputSummary[e]=n}return this.inputSummary}resetInputSummary(){this.inputSummary={}}reset(){return this.resetInputSummary(),It.reset()}elementDidMutate(t){if(this.isComposing()){var e,n;return(e=this.delegate)===null||e===void 0||(n=e.inputControllerDidAllowUnhandledInput)===null||n===void 0?void 0:n.call(e)}else return this.handleInput(function(){return this.mutationIsSignificant(t)&&(this.mutationIsExpected(t)?this.requestRender():this.requestReparse()),this.reset()})}mutationIsExpected(t){let{textAdded:e,textDeleted:n}=t;if(this.inputSummary.preferDocument)return!0;let r=e!=null?e===this.inputSummary.textAdded:!this.inputSummary.textAdded,o=n!=null?this.inputSummary.didDelete:!this.inputSummary.didDelete,s=[`
`,`
`].includes(e)&&!r,l=n===`
`&&!o;if(s&&!l||l&&!s){let g=this.getSelectedRange();if(g){var d;let x=s?e.replace(/\n$/,"").length||-1:e?.length||1;if((d=this.responder)!==null&&d!==void 0&&d.positionIsBlockBreak(g[1]+x))return!0}}return r&&o}mutationIsSignificant(t){var e;let n=Object.keys(t).length>0,r=((e=this.compositionInput)===null||e===void 0?void 0:e.getEndData())==="";return n||!r}getCompositionInput(){if(this.isComposing())return this.compositionInput;this.compositionInput=new rt(this)}isComposing(){return this.compositionInput&&!this.compositionInput.isEnded()}deleteInDirection(t,e){var n;if(((n=this.responder)===null||n===void 0?void 0:n.deleteInDirection(t))===!1){if(e)return e.preventDefault(),this.requestRender()}else return this.setInputSummary({didDelete:!0})}serializeSelectionToDataTransfer(t){var e;if(!Qo(t))return;let n=(e=this.responder)===null||e===void 0?void 0:e.getSelectedDocument().toSerializableDocument();return t.setData("application/x-trix-document",JSON.stringify(n)),t.setData("text/html",Zt.render(n).innerHTML),t.setData("text/plain",n.toString().replace(/\n$/,"")),!0}canAcceptDataTransfer(t){let e={};return Array.from(t?.types||[]).forEach(n=>{e[n]=!0}),e.Files||e["application/x-trix-document"]||e["text/html"]||e["text/plain"]}getPastedHTMLUsingHiddenElement(t){let e=this.getSelectedRange(),n={position:"absolute",left:"".concat(window.pageXOffset,"px"),top:"".concat(window.pageYOffset,"px"),opacity:0},r=p({style:n,tagName:"div",editable:!0});return document.body.appendChild(r),r.focus(),requestAnimationFrame(()=>{let o=r.innerHTML;return yt(r),this.setSelectedRange(e),t(o)})}};B(et,"events",{keydown(i){this.isComposing()||this.resetInputSummary(),this.inputSummary.didInput=!0;let t=lo[i.keyCode];if(t){var e;let r=this.keys;["ctrl","alt","shift","meta"].forEach(o=>{if(i["".concat(o,"Key")]){var s;o==="ctrl"&&(o="control"),r=(s=r)===null||s===void 0?void 0:s[o]}}),((e=r)===null||e===void 0?void 0:e[t])!=null&&(this.setInputSummary({keyName:t}),It.reset(),r[t].call(this,i))}if(qr(i)){let r=String.fromCharCode(i.keyCode).toLowerCase();if(r){var n;let o=["alt","shift"].map(s=>{if(i["".concat(s,"Key")])return s}).filter(s=>s);o.push(r),(n=this.delegate)!==null&&n!==void 0&&n.inputControllerDidReceiveKeyboardCommand(o)&&i.preventDefault()}}},keypress(i){if(this.inputSummary.eventName!=null||i.metaKey||i.ctrlKey&&!i.altKey)return;let t=Ca(i);if(t){var e,n;return(e=this.delegate)===null||e===void 0||e.inputControllerWillPerformTyping(),(n=this.responder)===null||n===void 0||n.insertString(t),this.setInputSummary({textAdded:t,didDelete:this.selectionIsExpanded()})}},textInput(i){let{data:t}=i,{textAdded:e}=this.inputSummary;if(e&&e!==t&&e.toUpperCase()===t){var n;let r=this.getSelectedRange();return this.setSelectedRange([r[0],r[1]+e.length]),(n=this.responder)===null||n===void 0||n.insertString(t),this.setInputSummary({textAdded:t}),this.setSelectedRange(r)}},dragenter(i){i.preventDefault()},dragstart(i){var t,e;return this.serializeSelectionToDataTransfer(i.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(i){if(this.draggedRange||this.canAcceptDataTransfer(i.dataTransfer)){i.preventDefault();let n={x:i.clientX,y:i.clientY};if(!ee(n,this.draggingPoint)){var t,e;return this.draggingPoint=n,(t=this.delegate)===null||t===void 0||(e=t.inputControllerDidReceiveDragOverPoint)===null||e===void 0?void 0:e.call(t,this.draggingPoint)}}},dragend(i){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(i){var t,e;i.preventDefault();let n=(t=i.dataTransfer)===null||t===void 0?void 0:t.files,r=i.dataTransfer.getData("application/x-trix-document"),o={x:i.clientX,y:i.clientY};if((e=this.responder)===null||e===void 0||e.setLocationRangeFromPointRange(o),n!=null&&n.length)this.attachFiles(n);else if(this.draggedRange){var s,l;(s=this.delegate)===null||s===void 0||s.inputControllerWillMoveText(),(l=this.responder)===null||l===void 0||l.moveTextFromRange(this.draggedRange),this.draggedRange=null,this.requestRender()}else if(r){var c;let d=G.fromJSONString(r);(c=this.responder)===null||c===void 0||c.insertDocument(d),this.requestRender()}this.draggedRange=null,this.draggingPoint=null},cut(i){var t;if((t=this.responder)!==null&&t!==void 0&&t.selectionIsExpanded()){var e;if(this.serializeSelectionToDataTransfer(i.clipboardData)&&i.preventDefault(),(e=this.delegate)===null||e===void 0||e.inputControllerWillCutText(),this.deleteInDirection("backward"),i.defaultPrevented)return this.requestRender()}},copy(i){var t;(t=this.responder)!==null&&t!==void 0&&t.selectionIsExpanded()&&this.serializeSelectionToDataTransfer(i.clipboardData)&&i.preventDefault()},paste(i){let t=i.clipboardData||i.testClipboardData,e={clipboard:t};if(!t||Sa(i)){this.getPastedHTMLUsingHiddenElement(y=>{var J,wt,ne;return e.type="text/html",e.html=y,(J=this.delegate)===null||J===void 0||J.inputControllerWillPaste(e),(wt=this.responder)===null||wt===void 0||wt.insertHTML(e.html),this.requestRender(),(ne=this.delegate)===null||ne===void 0?void 0:ne.inputControllerDidPaste(e)});return}let n=t.getData("URL"),r=t.getData("text/html"),o=t.getData("public.url-name");if(n){var s,l,c;let y;e.type="text/html",o?y=ki(o).trim():y=n,e.html=this.createLinkHTML(n,y),(s=this.delegate)===null||s===void 0||s.inputControllerWillPaste(e),this.setInputSummary({textAdded:y,didDelete:this.selectionIsExpanded()}),(l=this.responder)===null||l===void 0||l.insertHTML(e.html),this.requestRender(),(c=this.delegate)===null||c===void 0||c.inputControllerDidPaste(e)}else if(Hr(t)){var d,g,x;e.type="text/plain",e.string=t.getData("text/plain"),(d=this.delegate)===null||d===void 0||d.inputControllerWillPaste(e),this.setInputSummary({textAdded:e.string,didDelete:this.selectionIsExpanded()}),(g=this.responder)===null||g===void 0||g.insertString(e.string),this.requestRender(),(x=this.delegate)===null||x===void 0||x.inputControllerDidPaste(e)}else if(r){var T,Z,F;e.type="text/html",e.html=r,(T=this.delegate)===null||T===void 0||T.inputControllerWillPaste(e),(Z=this.responder)===null||Z===void 0||Z.insertHTML(e.html),this.requestRender(),(F=this.delegate)===null||F===void 0||F.inputControllerDidPaste(e)}else if(Array.from(t.types).includes("Files")){var Q,Et;let y=(Q=t.items)===null||Q===void 0||(Q=Q[0])===null||Q===void 0||(Et=Q.getAsFile)===null||Et===void 0?void 0:Et.call(Q);if(y){var mt,Bt,ot;let J=Ea(y);!y.name&&J&&(y.name="pasted-file-".concat(++xa,".").concat(J)),e.type="File",e.file=y,(mt=this.delegate)===null||mt===void 0||mt.inputControllerWillAttachFiles(),(Bt=this.responder)===null||Bt===void 0||Bt.insertFile(e.file),this.requestRender(),(ot=this.delegate)===null||ot===void 0||ot.inputControllerDidPaste(e)}}i.preventDefault()},compositionstart(i){return this.getCompositionInput().start(i.data)},compositionupdate(i){return this.getCompositionInput().update(i.data)},compositionend(i){return this.getCompositionInput().end(i.data)},beforeinput(i){this.inputSummary.didInput=!0},input(i){return this.inputSummary.didInput=!0,i.stopPropagation()}});B(et,"keys",{backspace(i){var t;return(t=this.delegate)===null||t===void 0||t.inputControllerWillPerformTyping(),this.deleteInDirection("backward",i)},delete(i){var t;return(t=this.delegate)===null||t===void 0||t.inputControllerWillPerformTyping(),this.deleteInDirection("forward",i)},return(i){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(i){var t;if((t=this.responder)!==null&&t!==void 0&&t.canIncreaseNestingLevel()){var e;(e=this.responder)===null||e===void 0||e.increaseNestingLevel(),this.requestRender(),i.preventDefault()}},left(i){if(this.selectionIsInCursorTarget()){var t;return i.preventDefault(),(t=this.responder)===null||t===void 0?void 0:t.moveCursorInDirection("backward")}},right(i){if(this.selectionIsInCursorTarget()){var t;return i.preventDefault(),(t=this.responder)===null||t===void 0?void 0:t.moveCursorInDirection("forward")}},control:{d(i){var t;return(t=this.delegate)===null||t===void 0||t.inputControllerWillPerformTyping(),this.deleteInDirection("forward",i)},h(i){var t;return(t=this.delegate)===null||t===void 0||t.inputControllerWillPerformTyping(),this.deleteInDirection("backward",i)},o(i){var t,e;return i.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(i){var t,e;(t=this.delegate)===null||t===void 0||t.inputControllerWillPerformTyping(),(e=this.responder)===null||e===void 0||e.insertString(`
`),this.requestRender(),i.preventDefault()},tab(i){var t;if((t=this.responder)!==null&&t!==void 0&&t.canDecreaseNestingLevel()){var e;(e=this.responder)===null||e===void 0||e.decreaseNestingLevel(),this.requestRender(),i.preventDefault()}},left(i){if(this.selectionIsInCursorTarget())return i.preventDefault(),this.expandSelectionInDirection("backward")},right(i){if(this.selectionIsInCursorTarget())return i.preventDefault(),this.expandSelectionInDirection("forward")}},alt:{backspace(i){var t;return this.setInputSummary({preferDocument:!1}),(t=this.delegate)===null||t===void 0?void 0:t.inputControllerWillPerformTyping()}},meta:{backspace(i){var t;return this.setInputSummary({preferDocument:!1}),(t=this.delegate)===null||t===void 0?void 0:t.inputControllerWillPerformTyping()}}});et.proxyMethod("responder?.getSelectedRange");et.proxyMethod("responder?.setSelectedRange");et.proxyMethod("responder?.expandSelectionInDirection");et.proxyMethod("responder?.selectionIsInCursorTarget");et.proxyMethod("responder?.selectionIsExpanded");var Ea=i=>{var t;return(t=i.type)===null||t===void 0||(t=t.match(/\/(\w+)$/))===null||t===void 0?void 0:t[1]},wa=!!((Zn=(Or=" ").codePointAt)!==null&&Zn!==void 0&&Zn.call(Or,0)),Ca=function(i){if(i.key&&wa&&i.key.codePointAt(0)===i.keyCode)return i.key;{let t;if(i.which===null?t=i.keyCode:i.which!==0&&i.charCode!==0&&(t=i.charCode),t!=null&&lo[t]!=="escape")return Ot.fromCodepoints([t]).toString()}},Sa=function(i){let t=i.clipboardData;if(t)if(t.types.includes("text/html")){for(let e of t.types){let n=/^CorePasteboardFlavorType/.test(e),r=/^dyn\./.test(e)&&t.getData(e);if(n||r)return!0}return!1}else{let e=t.types.includes("com.apple.webarchive"),n=t.types.includes("com.apple.flat-rtfd");return e||n}},rt=class extends S{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;if(this.inputSummary.eventName==="keypress"&&this.inputSummary.textAdded){var n;(n=this.responder)===null||n===void 0||n.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()){let e=this.selectPlaceholder();e&&(this.forgetPlaceholder(),this.range=e)}}end(t){if(this.data.end=t,this.isSignificant()){if(this.forgetPlaceholder(),this.canApplyToDocument()){var e,n,r,o;return this.setInputSummary({preferDocument:!0,didInput:!1}),(e=this.delegate)===null||e===void 0||e.inputControllerWillPerformTyping(),(n=this.responder)===null||n===void 0||n.setSelectedRange(this.range),(r=this.responder)===null||r===void 0||r.insertString(this.data.end),(o=this.responder)===null||o===void 0?void 0:o.setSelectedRange(this.range[0]+this.data.end.length)}else if(this.data.start!=null||this.data.update!=null)return this.requestReparse(),this.inputController.reset()}else return this.inputController.reset()}getEndData(){return this.data.end}isEnded(){return this.getEndData()!=null}isSignificant(){return Aa.composesExistingText?this.inputSummary.didInput:!0}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}};rt.proxyMethod("inputController.setInputSummary");rt.proxyMethod("inputController.requestRender");rt.proxyMethod("inputController.requestReparse");rt.proxyMethod("responder?.selectionIsExpanded");rt.proxyMethod("responder?.insertPlaceholder");rt.proxyMethod("responder?.selectPlaceholder");rt.proxyMethod("responder?.forgetPlaceholder");var Ft=class extends $t{constructor(){super(...arguments),this.render=this.render.bind(this)}elementDidMutate(){if(this.scheduledRender){if(this.composing){var t,e;return(t=this.delegate)===null||t===void 0||(e=t.inputControllerDidAllowUnhandledInput)===null||e===void 0?void 0:e.call(t)}}else return this.reparse()}scheduleRender(){return this.scheduledRender?this.scheduledRender:this.scheduledRender=requestAnimationFrame(this.render)}render(){var t;if(cancelAnimationFrame(this.scheduledRender),this.scheduledRender=null,!this.composing){var e;(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]:"",n=arguments.length>1?arguments[1]:void 0;return(t=this.delegate)===null||t===void 0||t.inputControllerWillPerformTyping(),this.withTargetDOMRange(function(){var r;return(r=this.responder)===null||r===void 0?void 0:r.insertString(e,n)})}toggleAttributeIfSupported(t){if(ri().includes(t)){var e;return(e=this.delegate)===null||e===void 0||e.inputControllerWillPerformFormatting(t),this.withTargetDOMRange(function(){var n;return(n=this.responder)===null||n===void 0?void 0:n.toggleCurrentAttribute(t)})}}activateAttributeIfSupported(t,e){if(ri().includes(t)){var n;return(n=this.delegate)===null||n===void 0||n.inputControllerWillPerformFormatting(t),this.withTargetDOMRange(function(){var r;return(r=this.responder)===null||r===void 0?void 0:r.setCurrentAttribute(t,e)})}}deleteInDirection(t){let{recordUndoEntry:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{recordUndoEntry:!0};if(e){var n;(n=this.delegate)===null||n===void 0||n.inputControllerWillPerformTyping()}let r=()=>{var s;return(s=this.responder)===null||s===void 0?void 0:s.deleteInDirection(t)},o=this.getTargetDOMRange({minLength:this.composing?1:2});return o?this.withTargetDOMRange(o,r):r()}withTargetDOMRange(t,e){if(typeof t=="function"&&(e=t,t=this.getTargetDOMRange()),t){var n;return(n=this.responder)===null||n===void 0?void 0:n.withTargetDOMRange(t,e.bind(this))}else return It.reset(),e.call(this)}getTargetDOMRange(){var t,e;let{minLength:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{minLength:0},r=(t=(e=this.event).getTargetRanges)===null||t===void 0?void 0:t.call(e);if(r&&r.length){let o=Ta(r[0]);if(n===0||o.toString().length>=n)return o}}withEvent(t,e){let n;this.event=t;try{n=e.call(this)}finally{this.event=null}return n}};B(Ft,"events",{keydown(i){if(qr(i)){var t;let e=Da(i);(t=this.delegate)!==null&&t!==void 0&&t.inputControllerDidReceiveKeyboardCommand(e)&&i.preventDefault()}else{let e=i.key;i.altKey&&(e+="+Alt"),i.shiftKey&&(e+="+Shift");let n=this.constructor.keys[e];if(n)return this.withEvent(i,n)}},paste(i){var t;let e,n=(t=i.clipboardData)===null||t===void 0?void 0:t.getData("URL");if(co(i))return i.preventDefault(),this.attachFiles(i.clipboardData.files);if(Ra(i)){var r,o,s;return i.preventDefault(),e={type:"text/plain",string:i.clipboardData.getData("text/plain")},(r=this.delegate)===null||r===void 0||r.inputControllerWillPaste(e),(o=this.responder)===null||o===void 0||o.insertString(e.string),this.render(),(s=this.delegate)===null||s===void 0?void 0:s.inputControllerDidPaste(e)}else if(n){var l,c,d;return i.preventDefault(),e={type:"text/html",html:this.createLinkHTML(n)},(l=this.delegate)===null||l===void 0||l.inputControllerWillPaste(e),(c=this.responder)===null||c===void 0||c.insertHTML(e.html),this.render(),(d=this.delegate)===null||d===void 0?void 0:d.inputControllerDidPaste(e)}},beforeinput(i){let t=this.constructor.inputTypes[i.inputType],e=$o(i);t&&(this.withEvent(i,t),e||this.scheduleRender()),e&&this.render()},input(i){It.reset()},dragstart(i){var t;if((t=this.responder)!==null&&t!==void 0&&t.selectionContainsAttachments()){var e;i.dataTransfer.setData("application/x-trix-dragging",!0),this.dragging={range:(e=this.responder)===null||e===void 0?void 0:e.getSelectedRange(),point:$n(i)}}},dragenter(i){Qn(i)&&i.preventDefault()},dragover(i){if(this.dragging){i.preventDefault();let e=$n(i);if(!ee(e,this.dragging.point)){var t;return this.dragging.point=e,(t=this.responder)===null||t===void 0?void 0:t.setLocationRangeFromPointRange(e)}}else Qn(i)&&i.preventDefault()},drop(i){if(this.dragging){var t,e;return i.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()}else if(Qn(i)){var n;i.preventDefault();let r=$n(i);return(n=this.responder)===null||n===void 0||n.setLocationRangeFromPointRange(r),this.attachFiles(i.dataTransfer.files)}},dragend(){if(this.dragging){var i;(i=this.responder)===null||i===void 0||i.setSelectedRange(this.dragging.range),this.dragging=null}},compositionend(i){this.composing&&(this.composing=!1,Se.recentAndroid||this.scheduleRender())}});B(Ft,"keys",{ArrowLeft(){var i;if((i=this.responder)!==null&&i!==void 0&&i.shouldManageMovingCursorInDirection("backward")){var t;return this.event.preventDefault(),(t=this.responder)===null||t===void 0?void 0:t.moveCursorInDirection("backward")}},ArrowRight(){var i;if((i=this.responder)!==null&&i!==void 0&&i.shouldManageMovingCursorInDirection("forward")){var t;return this.event.preventDefault(),(t=this.responder)===null||t===void 0?void 0:t.moveCursorInDirection("forward")}},Backspace(){var i;if((i=this.responder)!==null&&i!==void 0&&i.shouldManageDeletingInDirection("backward")){var t,e;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 i;if((i=this.responder)!==null&&i!==void 0&&i.canIncreaseNestingLevel()){var t;return this.event.preventDefault(),(t=this.responder)===null||t===void 0||t.increaseNestingLevel(),this.render()}},"Tab+Shift"(){var i;if((i=this.responder)!==null&&i!==void 0&&i.canDecreaseNestingLevel()){var t;return this.event.preventDefault(),(t=this.responder)===null||t===void 0||t.decreaseNestingLevel(),this.render()}}});B(Ft,"inputTypes",{deleteByComposition(){return this.deleteInDirection("backward",{recordUndoEntry:!1})},deleteByCut(){return this.deleteInDirection("backward")},deleteByDrag(){return this.event.preventDefault(),this.withTargetDOMRange(function(){var i;this.deleteByDragRange=(i=this.responder)===null||i===void 0?void 0:i.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 i;if((i=this.responder)!==null&&i!==void 0&&i.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 i;if((i=this.responder)!==null&&i!==void 0&&i.canDecreaseNestingLevel())return this.withTargetDOMRange(function(){var t;return(t=this.responder)===null||t===void 0?void 0:t.decreaseNestingLevel()})},formatRemove(){this.withTargetDOMRange(function(){for(let e in(i=this.responder)===null||i===void 0?void 0:i.getCurrentAttributes()){var i,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 i;return(i=this.delegate)===null||i===void 0?void 0:i.inputControllerWillPerformRedo()},historyUndo(){var i;return(i=this.delegate)===null||i===void 0?void 0:i.inputControllerWillPerformUndo()},insertCompositionText(){return this.composing=!0,this.insertString(this.event.data)},insertFromComposition(){return this.composing=!1,this.insertString(this.event.data)},insertFromDrop(){let i=this.deleteByDragRange;if(i){var t;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(i)})}},insertFromPaste(){let{dataTransfer:i}=this.event,t={dataTransfer:i},e=i.getData("URL"),n=i.getData("text/html");if(e){var r;let c;this.event.preventDefault(),t.type="text/html";let d=i.getData("public.url-name");d?c=ki(d).trim():c=e,t.html=this.createLinkHTML(e,c),(r=this.delegate)===null||r===void 0||r.inputControllerWillPaste(t),this.withTargetDOMRange(function(){var g;return(g=this.responder)===null||g===void 0?void 0:g.insertHTML(t.html)}),this.afterRender=()=>{var g;return(g=this.delegate)===null||g===void 0?void 0:g.inputControllerDidPaste(t)}}else if(Hr(i)){var o;t.type="text/plain",t.string=i.getData("text/plain"),(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.insertString(t.string)}),this.afterRender=()=>{var c;return(c=this.delegate)===null||c===void 0?void 0:c.inputControllerDidPaste(t)}}else if(ka(this.event)){var s;t.type="File",t.file=i.files[0],(s=this.delegate)===null||s===void 0||s.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(n){var l;this.event.preventDefault(),t.type="text/html",t.html=n,(l=this.delegate)===null||l===void 0||l.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 i;return(i=this.delegate)===null||i===void 0||i.inputControllerWillPerformTyping(),this.withTargetDOMRange(function(){var t;return(t=this.responder)===null||t===void 0?void 0:t.insertLineBreak()})},insertReplacementText(){let i=this.event.dataTransfer.getData("text/plain"),t=this.event.getTargetRanges()[0];this.withTargetDOMRange(t,()=>{this.insertString(i,{updatePosition:!1})})},insertText(){var i;return this.insertString(this.event.data||((i=this.event.dataTransfer)===null||i===void 0?void 0:i.getData("text/plain")))},insertTranspose(){return this.insertString(this.event.data)},insertUnorderedList(){return this.toggleAttributeIfSupported("bullet")}});var Ta=function(i){let t=document.createRange();return t.setStart(i.startContainer,i.startOffset),t.setEnd(i.endContainer,i.endOffset),t},Qn=i=>{var t;return Array.from(((t=i.dataTransfer)===null||t===void 0?void 0:t.types)||[]).includes("Files")},ka=i=>{var t;return((t=i.dataTransfer.files)===null||t===void 0?void 0:t[0])&&!co(i)&&!Zo(i)},co=function(i){let t=i.clipboardData;if(t)return Array.from(t.types).filter(n=>n.match(/file/i)).length===t.types.length&&t.files.length>=1},Ra=function(i){let t=i.clipboardData;if(t)return t.types.includes("text/plain")&&t.types.length===1},Da=function(i){let t=[];return i.altKey&&t.push("alt"),i.shiftKey&&t.push("shift"),t.push(i.key),t},$n=i=>({x:i.clientX,y:i.clientY}),mi="[data-trix-attribute]",pi="[data-trix-action]",La="".concat(mi,", ").concat(pi),mn="[data-trix-dialog]",Oa="".concat(mn,"[data-trix-active]"),Pa="".concat(mn," [data-trix-method]"),Pr="".concat(mn," [data-trix-input]"),Ir=(i,t)=>(t||(t=qt(i)),i.querySelector("[data-trix-input][name='".concat(t,"']"))),Mr=i=>i.getAttribute("data-trix-action"),qt=i=>i.getAttribute("data-trix-attribute")||i.getAttribute("data-trix-dialog-attribute"),Ia=i=>i.getAttribute("data-trix-dialog"),dn=class extends S{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(),C("mousedown",{onElement:this.element,matchingSelector:pi,withCallback:this.didClickActionButton}),C("mousedown",{onElement:this.element,matchingSelector:mi,withCallback:this.didClickAttributeButton}),C("click",{onElement:this.element,matchingSelector:La,preventDefault:!0}),C("click",{onElement:this.element,matchingSelector:Pa,withCallback:this.didClickDialogButton}),C("keydown",{onElement:this.element,matchingSelector:Pr,withCallback:this.didKeyDownDialogInput})}didClickActionButton(t,e){var n;(n=this.delegate)===null||n===void 0||n.toolbarDidClickButton(),t.preventDefault();let r=Mr(e);if(this.getDialog(r))return this.toggleDialog(r);var o;return(o=this.delegate)===null||o===void 0?void 0:o.toolbarDidInvokeAction(r,e)}didClickAttributeButton(t,e){var n;(n=this.delegate)===null||n===void 0||n.toolbarDidClickButton(),t.preventDefault();let r=qt(e);if(this.getDialog(r))this.toggleDialog(r);else{var o;(o=this.delegate)===null||o===void 0||o.toolbarDidToggleAttribute(r)}return this.refreshAttributeButtons()}didClickDialogButton(t,e){let n=vt(e,{matchingSelector:mn}),r=e.getAttribute("data-trix-method");return this[r].call(this,n)}didKeyDownDialogInput(t,e){if(t.keyCode===13){t.preventDefault();let n=e.getAttribute("name"),r=this.getDialog(n);this.setAttribute(r)}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(pi)).map(e=>t(e,Mr(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(mi)).map(e=>t(e,qt(e)))}applyKeyboardCommand(t){let e=JSON.stringify(t.sort());for(let n of Array.from(this.element.querySelectorAll("[data-trix-key]"))){let r=n.getAttribute("data-trix-key").split("+");if(JSON.stringify(r.sort())===e)return me("mousedown",{onElement:n}),!0}return!1}dialogIsVisible(t){let 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,n;this.hideDialog(),(e=this.delegate)===null||e===void 0||e.toolbarWillShowDialog();let r=this.getDialog(t);r.setAttribute("data-trix-active",""),r.classList.add("trix-active"),Array.from(r.querySelectorAll("input[disabled]")).forEach(s=>{s.removeAttribute("disabled")});let o=qt(r);if(o){let s=Ir(r,t);s&&(s.value=this.attributes[o]||"",s.select())}return(n=this.delegate)===null||n===void 0?void 0:n.toolbarDidShowDialog(t)}setAttribute(t){var e;let n=qt(t),r=Ir(t,n);return r.willValidate&&(r.setCustomValidity(""),!r.checkValidity()||!this.isSafeAttribute(r))?(r.setCustomValidity("Invalid value"),r.setAttribute("data-trix-validate",""),r.classList.add("trix-validate"),r.focus()):((e=this.delegate)===null||e===void 0||e.toolbarDidUpdateAttribute(n,r.value),this.hideDialog())}isSafeAttribute(t){return t.hasAttribute("data-trix-validate-href")?xe.isValidAttribute("a","href",t.value):!0}removeAttribute(t){var e;let n=qt(t);return(e=this.delegate)===null||e===void 0||e.toolbarDidRemoveAttribute(n),this.hideDialog()}hideDialog(){let t=this.element.querySelector(Oa);if(t){var e;return t.removeAttribute("data-trix-active"),t.classList.remove("trix-active"),this.resetDialogInputs(),(e=this.delegate)===null||e===void 0?void 0:e.toolbarDidHideDialog(Ia(t))}}resetDialogInputs(){Array.from(this.element.querySelectorAll(Pr)).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,"]"))}},Ma=(i,t)=>gn(i.selectedRange,t.selectedRange)&&i.document.isEqualTo(t.document),Nt=class extends ln{constructor(t){let{editorElement:e,document:n,html:r}=t;super(...arguments),this.editorElement=e,this.selectionManager=new gt(this.editorElement),this.selectionManager.delegate=this,this.composition=new it,this.composition.delegate=this,this.attachmentManager=new $e(this.composition.getAttachments()),this.attachmentManager.delegate=this,this.inputController=wi.getLevel()===2?new Ft(this.editorElement):new et(this.editorElement),this.inputController.delegate=this,this.inputController.responder=this.composition,this.compositionController=new an(this.editorElement,this.composition),this.compositionController.delegate=this,this.toolbarController=new dn(this.editorElement.toolbarElement),this.toolbarController.delegate=this,this.editor=new nn(this.composition,this.selectionManager,this.editorElement),n?this.editor.loadDocument(n):this.editor.loadHTML(r)}registerSelectionManager(){return It.registerSelectionManager(this.selectionManager)}unregisterSelectionManager(){return It.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){let e=this.attachmentManager.manageAttachment(t);return this.notifyEditorElement("attachment-add",{attachment:e})}compositionDidEditAttachment(t){this.compositionController.rerenderViewForObject(t);let 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){let 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())&&(this.requestedLocationRange=t,this.compositionRevisionWhenLocationRangeRequested=this.composition.revision,!this.handlingInput))return 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){let 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&&!gn(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){if(this.actionIsExternal(t))return!0;var e;return!!((e=this.actions[t])!==null&&e!==void 0&&(e=e.test)!==null&&e!==void 0&&e.call(this))}invokeAction(t,e){if(this.actionIsExternal(t))return this.notifyEditorElement("action-invoke",{actionName:t,invokingElement:e});var n;return(n=this.actions[t])===null||n===void 0||(n=n.perform)===null||n===void 0?void 0:n.call(this)}actionIsExternal(t){return/^x-./.test(t)}getCurrentActions(){let t={};for(let e in this.actions)t[e]=this.canInvokeAction(e);return t}updateCurrentActions(){let t=this.getCurrentActions();if(!ee(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(e=>{let{document:n,selectedRange:r}=t;t=e.call(this.editor,t)||{},t.document||(t.document=n),t.selectedRange||(t.selectedRange=r)}),!Ma(t,this.composition.getSnapshot()))return this.composition.loadSnapshot(t)}updateInputElement(){let t=this.compositionController.getSerializableElement(),e=sa(t,"text/html");return this.editorElement.setFormValue(e)}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();break}return this.editorElement.notify(t,e)}removeAttachment(t){return this.editor.recordUndoEntry("Delete Attachment"),this.composition.removeAttachment(t),this.render()}recordFormattingUndoEntry(t){let e=D(t),n=this.selectionManager.getLocationRange();if(e||!ut(n))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),n=0;n<t;n++)e[n]=arguments[n];return[this.getLocationContext(),this.getTimeContext(),...Array.from(e)]}getLocationContext(){let t=this.selectionManager.getLocationRange();return ut(t)?t[0].index:t}getTimeContext(){return ii.interval>0?Math.floor(new Date().getTime()/ii.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}};B(Nt,"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(){return!0},perform(){return wi.pickFiles(this.editor.insertFiles)}}});Nt.proxyMethod("getSelectionManager().setLocationRange");Nt.proxyMethod("getSelectionManager().getLocationRange");var Fa=Object.freeze({__proto__:null,AttachmentEditorController:sn,CompositionController:an,Controller:ln,EditorController:Nt,InputController:$t,Level0InputController:et,Level2InputController:Ft,ToolbarController:dn}),Na=Object.freeze({__proto__:null,MutationObserver:cn,SelectionChangeObserver:Ke}),Ba=Object.freeze({__proto__:null,FileVerificationOperation:un,ImagePreloadOperation:Qe});Vr("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;
}`);var hn=class extends HTMLElement{connectedCallback(){this.innerHTML===""&&(this.innerHTML=Ur.getDefaultHTML())}get editorElements(){if(this.id){var t;let e=(t=this.ownerDocument)===null||t===void 0?void 0:t.querySelectorAll('trix-editor[toolbar="'.concat(this.id,'"]'));return Array.from(e)}else return[]}get editorElement(){let[t]=this.editorElements;return t}},_a=0,ja=function(i){if(!document.querySelector(":focus")&&i.hasAttribute("autofocus")&&document.querySelector("[autofocus]")===i)return i.focus()},Wa=function(i){if(!i.hasAttribute("contenteditable"))return i.toggleAttribute("contenteditable",!i.disabled),Oo("focus",{onElement:i,withCallback(){return za(i)}})},za=function(i){return Ua(i),Va(i)},Ua=function(i){var t,e;if((t=(e=document).queryCommandSupported)!==null&&t!==void 0&&t.call(e,"enableObjectResizing"))return document.execCommand("enableObjectResizing",!1,!1),C("mscontrolselect",{onElement:i,preventDefault:!0})},Va=function(i){var t,e;if((t=(e=document).queryCommandSupported)!==null&&t!==void 0&&t.call(e,"DefaultParagraphSeparator")){let{tagName:n}=z.default;if(["div","p"].includes(n))return document.execCommand("DefaultParagraphSeparator",!1,n)}},Ha=function(i){if(!i.hasAttribute("role"))return i.setAttribute("role","textbox")},qa=function(i){if(i.hasAttribute("aria-label")||i.hasAttribute("aria-labelledby"))return;let t=function(){let n=Array.from(i.labels).map(r=>{if(!r.contains(i))return r.textContent}).filter(r=>r).join(" ");return n?i.setAttribute("aria-label",n):i.removeAttribute("aria-label")};return t(),C("focus",{onElement:i,withCallback:t})},Fr=function(){return Se.forcesObjectResizing?{display:"inline",width:"auto"}:{display:"inline-block",width:"1px"}}();Vr("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(Rt,` figcaption textarea {
resize: none;
}
%t `).concat(Rt,` figcaption textarea.trix-autoresize-clone {
position: absolute;
left: -9999px;
max-height: 0px;
}
%t `).concat(Rt,` figcaption[data-trix-placeholder]:empty::before {
content: attr(data-trix-placeholder);
color: graytext;
}
%t [data-trix-cursor-target] {
display: `).concat(Fr.display,` !important;
width: `).concat(Fr.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 $=new WeakMap,je=new WeakMap,fe=new WeakSet,bi=class{constructor(t){js(this,fe),B(this,"value",""),Jt(this,$,{writable:!0,value:void 0}),Jt(this,je,{writable:!0,value:void 0}),this.element=t,ye(this,$,t.attachInternals()),ye(this,je,!1)}connectedCallback(){_e(this,fe,We).call(this)}disconnectedCallback(){}get form(){return v(this,$).form}get name(){return this.element.getAttribute("name")}set name(t){this.element.setAttribute("name",t)}get labels(){return v(this,$).labels}get disabled(){return v(this,je)||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),_e(this,fe,We).call(this)}get validity(){return v(this,$).validity}get validationMessage(){return v(this,$).validationMessage}get willValidate(){return v(this,$).willValidate}formDisabledCallback(t){ye(this,je,t)}setFormValue(t){this.value=t,_e(this,fe,We).call(this),v(this,$).setFormValue(this.element.disabled?void 0:this.value)}checkValidity(){return v(this,$).checkValidity()}reportValidity(){return v(this,$).reportValidity()}setCustomValidity(t){_e(this,fe,We).call(this,t)}};function We(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",{required:t,value:e}=this.element,n=t&&!e,r=!!i,o=p("input",{required:t}),s=i||o.validationMessage;v(this,$).setValidity({valueMissing:n,customError:r},s)}var ti=new WeakMap,ei=new WeakMap,ni=new WeakMap,vi=class{constructor(t){Jt(this,ti,{writable:!0,value:void 0}),Jt(this,ei,{writable:!0,value:e=>{e.defaultPrevented||e.target===this.element.form&&this.element.reset()}}),Jt(this,ni,{writable:!0,value:e=>{if(e.defaultPrevented||this.element.contains(e.target))return;let n=vt(e.target,{matchingSelector:"label"});!n||!Array.from(this.labels).includes(n)||this.element.focus()}}),this.element=t}connectedCallback(){ye(this,ti,qa(this.element)),window.addEventListener("reset",v(this,ei),!1),window.addEventListener("click",v(this,ni),!1)}disconnectedCallback(){var t;(t=v(this,ti))===null||t===void 0||t.destroy(),window.removeEventListener("reset",v(this,ei),!1),window.removeEventListener("click",v(this,ni),!1)}get labels(){let t=[];this.element.id&&this.element.ownerDocument&&t.push(...Array.from(this.element.ownerDocument.querySelectorAll("label[for='".concat(this.element.id,"']"))||[]));let e=vt(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.")}},R=new WeakMap,te=class extends HTMLElement{constructor(){super(),Jt(this,R,{writable:!0,value:void 0}),this.willCreateInput=!0,ye(this,R,this.constructor.formAssociated?new bi(this):new vi(this))}get trixId(){return this.hasAttribute("trix-id")?this.getAttribute("trix-id"):(this.setAttribute("trix-id",++_a),this.trixId)}get labels(){return v(this,R).labels}get disabled(){let{inputElement:t}=this;return t?t.disabled:v(this,R).disabled}set disabled(t){let{inputElement:e}=this;e&&(e.disabled=t),v(this,R).disabled=t}get required(){return v(this,R).required}set required(t){v(this,R).required=t}get validity(){return v(this,R).validity}get validationMessage(){return v(this,R).validationMessage}get willValidate(){return v(this,R).willValidate}get type(){return this.localName}get toolbarElement(){if(this.hasAttribute("toolbar")){var t;return(t=this.ownerDocument)===null||t===void 0?void 0:t.getElementById(this.getAttribute("toolbar"))}else if(this.parentNode){let e="trix-toolbar-".concat(this.trixId);return this.setAttribute("toolbar",e),this.internalToolbar=p("trix-toolbar",{id:e}),this.parentNode.insertBefore(this.internalToolbar,this),this.internalToolbar}else return}get form(){let{inputElement:t}=this;return t?t.form:v(this,R).form}get inputElement(){if(this.hasAttribute("input")){var t;return(t=this.ownerDocument)===null||t===void 0?void 0:t.getElementById(this.getAttribute("input"))}else return}get editor(){var t;return(t=this.editorController)===null||t===void 0?void 0:t.editor}get name(){let{inputElement:t}=this;return t?t.name:v(this,R).name}set name(t){let{inputElement:e}=this;e?e.name=t:v(this,R).name=t}get value(){let{inputElement:t}=this;return t?t.value:v(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,n){t==="connected"&&this.isConnected&&e!=null&&e!==n&&requestAnimationFrame(()=>this.reconnect())}notify(t,e){if(this.editorController)return me("trix-".concat(t),{onElement:this,attributes:e})}setFormValue(t){let{inputElement:e}=this;e&&(e.value=t),v(this,R).setFormValue(t)}connectedCallback(){if(!this.hasAttribute("data-trix-internal")){if(Wa(this),Ha(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){let t="trix-input-".concat(this.trixId);this.setAttribute("input",t);let e=p("input",{type:"hidden",id:t});this.parentNode.insertBefore(e,this.nextElementSibling)}this.editorController=new Nt({editorElement:this,html:this.defaultValue}),requestAnimationFrame(()=>me("trix-initialize",{onElement:this}))}this.editorController.registerSelectionManager(),v(this,R).connectedCallback(),this.toggleAttribute("connected",!0),ja(this)}}disconnectedCallback(){var t;(t=this.editorController)===null||t===void 0||t.unregisterSelectionManager(),v(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 v(this,R).checkValidity()}reportValidity(){return v(this,R).reportValidity()}setCustomValidity(t){v(this,R).setCustomValidity(t)}formDisabledCallback(t){let{inputElement:e}=this;e&&(e.disabled=t),this.toggleAttribute("contenteditable",!t),v(this,R).formDisabledCallback(t)}formResetCallback(){this.reset()}reset(){this.value=this.defaultValue}};B(te,"formAssociated","ElementInternals"in window);B(te,"observedAttributes",["connected"]);var Ga=Object.freeze({__proto__:null,TrixEditorElement:te,TrixToolbarElement:hn}),Ka=Object.freeze({__proto__:null,Filter:en,attachmentGalleryFilter:ro}),uo={VERSION:ko,config:Te,core:aa,models:so,views:ga,controllers:Fa,observers:Na,operations:Ba,elements:Ga,filters:Ka};Object.assign(uo,so);function Ja(){customElements.get("trix-toolbar")||customElements.define("trix-toolbar",hn),customElements.get("trix-editor")||customElements.define("trix-editor",te)}window.Trix=uo;setTimeout(Ja,0);export{uo as default};
/*! @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 */