var ko="2.1.19",It="[data-trix-attachment]",Ri={preview:{presentation:"gallery",caption:{name:!0,size:!0}},file:{caption:{size:!0}}},J={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 ir(i.parentNode)===J[this.listAttribute].tagName}},numberList:{tagName:"ol",parse:!1},number:{tagName:"li",listAttribute:"numberList",group:!1,nestable:!0,test(i){return ir(i.parentNode)===J[this.listAttribute].tagName}},attachmentGallery:{tagName:"div",exclusive:!0,terminal:!0,parse:!1,group:!1}},ir=i=>{var t;return i==null||(t=i.tagName)===null||t===void 0?void 0:t.toLowerCase()},rr=navigator.userAgent.match(/android\s([0-9]+.*Chrome)/i),Fn=rr&&parseInt(rr[1]),Ne={composesExistingText:/Android.*Chrome/.test(navigator.userAgent),recentAndroid:Fn&&Fn>12,samsungAndroid:Fn&&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))},Wr={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"},To=[m.bytes,m.KB,m.MB,m.GB,m.TB,m.PB],Ur={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)),n=(i/Math.pow(t,e)).toFixed(this.precision).replace(/0*$/,"").replace(/\.$/,"");return"".concat(n," ").concat(To[e])}}},An="\uFEFF",xt="\xA0",Vr=function(i){for(let t in i){let e=i[t];this[t]=e}return this},ki=document.documentElement,wo=ki.matches,R=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||ki,c=e,u=r==="capturing",g=function(S){s!=null&&--s==0&&g.destroy();let D=Et(S.target,{matchingSelector:c});D!=null&&(n?.call(D,S,D),o&&S.preventDefault())};return g.destroy=()=>l.removeEventListener(i,g,u),l.addEventListener(i,g,u),g},zr=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&&Vr.call(r,n),r},Ce=function(i){let{onElement:t,bubbles:e,cancelable:n,attributes:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=t??ki,s=zr(i,{bubbles:e,cancelable:n,attributes:r});return o.dispatchEvent(s)},Hr=function(i,t){if(i?.nodeType===1)return wo.call(i,t)},Et=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)return i;if(i.closest&&e==null)return i.closest(t);for(;i&&i!==e;){if(Hr(i,t))return i;i=i.parentNode}}},Ti=i=>document.activeElement!==i&&Nt(i,document.activeElement),Nt=function(i,t){if(i&&t)for(;t;){if(t===i)return!0;t=t.parentNode}},Pn=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},St=i=>{var t;return i==null||(t=i.parentNode)===null||t===void 0?void 0:t.removeChild(i)},Xe=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)},q=i=>{var t;return i==null||(t=i.tagName)===null||t===void 0?void 0:t.toLowerCase()},b=function(i){let t,e,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof i=="object"?(n=i,i=n.tagName):n={attributes:n};let r=document.createElement(i);if(n.editable!=null&&(n.attributes==null&&(n.attributes={}),n.attributes.contenteditable=n.editable),n.attributes)for(t in n.attributes)e=n.attributes[t],r.setAttribute(t,e);if(n.style)for(t in n.style)e=n.style[t],r.style[t]=e;if(n.data)for(t in n.data)e=n.data[t],r.dataset[t]=e;return n.className&&n.className.split(" ").forEach((o=>{r.classList.add(o)})),n.textContent&&(r.textContent=n.textContent),n.childNodes&&[].concat(n.childNodes).forEach((o=>{r.appendChild(o)})),r},pe,Ee=function(){if(pe!=null)return pe;pe=[];for(let i in J){let t=J[i];t.tagName&&pe.push(t.tagName)}return pe},Bn=i=>Yt(i?.firstChild),Mn=function(i){let{strict:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{strict:!0};return t?Yt(i):Yt(i)||!Yt(i.firstChild)&&(function(e){return Ee().includes(q(e))&&!Ee().includes(q(e.firstChild))})(i)},Yt=i=>Do(i)&&i?.data==="block",Do=i=>i?.nodeType===Node.COMMENT_NODE,Xt=function(i){let{name:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(i)return Se(i)?i.data===An?!t||i.parentNode.dataset.trixCursorTarget===t:void 0:Xt(i.firstChild)},Ot=i=>Hr(i,It),qr=i=>Se(i)&&i?.data==="",Se=i=>i?.nodeType===Node.TEXT_NODE,wi={level2Enabled:!0,getLevel(){return this.level2Enabled&&Ne.supportsInputEvents?2:0},pickFiles(i){let t=b("input",{type:"file",multiple:!0,hidden:!0,id:this.fileInputId});t.addEventListener("change",(()=>{i(t.files),St(t)})),St(document.getElementById(this.fileInputId)),document.body.appendChild(t),t.click()}},$e={removeBlankTableCells:!1,tableCellSeparator:" | ",tableRowSeparator:` `},Bt={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=>window.getComputedStyle(i).fontStyle==="italic"},href:{groupTagName:"a",parser(i){let t="a:not(".concat(It,")"),e=i.closest(t);if(e)return e.getAttribute("href")}},strike:{tagName:"del",inheritable:!0},frozen:{style:{backgroundColor:"highlight"}}},Jr={getDefaultHTML:()=>`
`)},ai={interval:5e3},Ie=Object.freeze({__proto__:null,attachments:Ri,blockAttributes:J,browser:Ne,css:{attachment:"attachment",attachmentCaption:"attachment__caption",attachmentCaptionEditor:"attachment__caption-editor",attachmentMetadata:"attachment__metadata",attachmentMetadataContainer:"attachment__metadata-container",attachmentName:"attachment__name",attachmentProgress:"attachment__progress",attachmentSize:"attachment__size",attachmentToolbar:"attachment__toolbar",attachmentGallery:"attachment-gallery"},dompurify:Wr,fileSize:Ur,input:wi,keyNames:{8:"backspace",9:"tab",13:"return",27:"escape",37:"left",39:"right",46:"delete",68:"d",72:"h",79:"o"},lang:m,parser:$e,textAttributes:Bt,toolbar:Jr,undo:ai}),w=class{static proxyMethod(t){let{name:e,toMethod:n,toProperty:r,optional:o}=Lo(t);this.prototype[e]=function(){let s,l;var c,u;return n?l=o?(c=this[n])===null||c===void 0?void 0:c.call(this):this[n]():r&&(l=this[r]),o?(s=(u=l)===null||u===void 0?void 0:u[e],s?or.call(s,l,arguments):void 0):(s=l[e],or.call(s,l,arguments))}}},Lo=function(i){let t=i.match(No);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:or}=Function.prototype,No=new RegExp("^(.+?)(\\(\\))?(\\?)?\\.(.+?)$"),_n,jn,Wn,Mt=class extends w{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,li(t))}static fromCodepoints(t){return new this(ci(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 ci(this.codepoints.slice(0,Math.max(0,t))).length}offsetFromUCS2Offset(t){return li(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}},Io=((_n=Array.from)===null||_n===void 0?void 0:_n.call(Array,"\u{1F47C}").length)===1,Oo=((jn=" ".codePointAt)===null||jn===void 0?void 0:jn.call(" ",0))!=null,Fo=((Wn=String.fromCodePoint)===null||Wn===void 0?void 0:Wn.call(String,32,128124))===" \u{1F47C}",li,ci;li=Io&&Oo?i=>Array.from(i).map((t=>t.codePointAt(0))):function(i){let t=[],e=0,{length:n}=i;for(;eString.fromCodePoint(...Array.from(i||[])):function(i){return(()=>{let t=[];return Array.from(i).forEach((e=>{let n="";e>65535&&(e-=65536,n+=String.fromCharCode(e>>>10&1023|55296),e=56320|1023&e),t.push(n+String.fromCharCode(e))})),t})().join("")};var Po=0,pt=class extends w{static fromJSONString(t){return this.fromJSON(JSON.parse(t))}constructor(){super(...arguments),this.id=++Po}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 Mt.box(this)}getCacheKey(){return this.id.toString()}},_t=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;e1?e-1:0),r=1;r(Un||(Un=jo().concat(_o())),Un),O=i=>J[i],_o=()=>(Vn||(Vn=Object.keys(J)),Vn),hi=i=>Bt[i],jo=()=>(zn||(zn=Object.keys(Bt)),zn),Kr=function(i,t){Wo(i).textContent=t.replace(/%t/g,i)},Wo=function(i){let t=document.createElement("style");t.setAttribute("type","text/css"),t.setAttribute("data-tag-name",i.toLowerCase());let e=Uo();return e&&t.setAttribute("nonce",e),document.head.insertBefore(t,document.head.firstChild),t},Uo=function(){let i=sr("trix-csp-nonce")||sr("csp-nonce");if(i){let{nonce:t,content:e}=i;return t==""?e:t}},sr=i=>document.head.querySelector("meta[name=".concat(i,"]")),ar={"application/x-trix-feature-detection":"test"},Gr=function(i){let t=i.getData("text/plain"),e=i.getData("text/html");if(!t||!e)return t?.length;{let{body:n}=new DOMParser().parseFromString(e,"text/html");if(n.textContent===t)return!n.querySelector("*")}},$r=/Mac|^iP/.test(navigator.platform)?i=>i.metaKey:i=>i.ctrlKey,Li=i=>setTimeout(i,1),Yr=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},le=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},x=function(i){if(i!=null)return Array.isArray(i)||(i=[i,i]),[lr(i[0]),lr(i[1]!=null?i[1]:i[0])]},mt=function(i){if(i==null)return;let[t,e]=x(i);return di(t,e)},Qe=function(i,t){if(i==null||t==null)return;let[e,n]=x(i),[r,o]=x(t);return di(e,r)&&di(n,o)},lr=function(i){return typeof i=="number"?i:Yr(i)},di=function(i,t){return typeof i=="number"?i===t:le(i,t)},Ze=class extends w{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()}},jt=new Ze,Xr=function(){let i=window.getSelection();if(i.rangeCount>0)return i},Re=function(){var i;let t=(i=Xr())===null||i===void 0?void 0:i.getRangeAt(0);if(t&&!Vo(t))return t},Qr=function(i){let t=window.getSelection();return t.removeAllRanges(),t.addRange(i),jt.update()},Vo=i=>cr(i.startContainer)||cr(i.endContainer),cr=i=>!Object.getPrototypeOf(i),ye=i=>i.replace(new RegExp("".concat(An),"g"),"").replace(new RegExp("".concat(xt),"g")," "),Ni=new RegExp("[^\\S".concat(xt,"]")),Ii=i=>i.replace(new RegExp("".concat(Ni.source),"g")," ").replace(/\ {2,}/g," "),ur=function(i,t){if(i.isEqualTo(t))return["",""];let e=Hn(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=Hn(t,Mt.fromCodepoints(s))}else r=Hn(t,i);return[e.utf16String.toString(),r.utf16String.toString()]},Hn=function(i,t){let e=0,n=i.length,r=t.length;for(;ee+1&&i.charAt(n-1).isEqualTo(t.charAt(r-1));)n--,r--;return{utf16String:i.slice(e,n),offset:e}},rt=class i extends pt{static fromCommonAttributesOfObjects(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];if(!t.length)return new this;let e=fe(t[0]),n=e.getKeys();return t.slice(1).forEach((r=>{n=e.getKeysCommonToHash(fe(r)),e=e.slice(n)})),e}static box(t){return fe(t)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(...arguments),this.values=Ye(t)}add(t,e){return this.merge(zo(t,e))}remove(t){return new i(Ye(this.values,t))}get(t){return this.values[t]}has(t){return t in this.values}merge(t){return new i(Ho(this.values,qo(t)))}slice(t){let e={};return Array.from(t).forEach((n=>{this.has(n)&&(e[n]=this.values[n])})),new i(e)}getKeys(){return Object.keys(this.values)}getKeysCommonToHash(t){return t=fe(t),this.getKeys().filter((e=>this.values[e]===t.values[e]))}isEqualTo(t){return _t(this.toArray(),fe(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 Ye(this.values)}toJSON(){return this.toObject()}contentsForInspection(){return{values:JSON.stringify(this.values)}}},zo=function(i,t){let e={};return e[i]=t,e},Ho=function(i,t){let e=Ye(i);for(let n in t){let r=t[n];e[n]=r}return e},Ye=function(i,t){let e={};return Object.keys(i).sort().forEach((n=>{n!==t&&(e[n]=i[n])})),e},fe=function(i){return i instanceof rt?i:new rt(i)},qo=function(i){return i instanceof rt?i.values:i},Te=class{static groupObjects(){let t,e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],{depth:n,asTree:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};r&&n==null&&(n=0);let o=[];return Array.from(e).forEach((s=>{var l;if(t){var c,u,g;if((c=s.canBeGrouped)!==null&&c!==void 0&&c.call(s,n)&&(u=(g=t[t.length-1]).canBeGroupedWith)!==null&&u!==void 0&&u.call(g,s,n))return void t.push(s);o.push(new this(t,{depth:n,asTree:r})),t=null}(l=s.canBeGrouped)!==null&&l!==void 0&&l.call(s,n)?t=[s]:o.push(s)})),t&&o.push(new this(t,{depth:n,asTree:r})),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("/")}},gi=class extends w{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]}},mi=class{constructor(t){this.reset(t)}add(t){let e=hr(t);this.elements[e]=t}remove(t){let e=hr(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}},hr=i=>i.dataset.trixStoreKey,Zt=class extends w{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}};Zt.proxyMethod("getPromise().then"),Zt.proxyMethod("getPromise().catch");var ft=class extends w{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 Te&&(n.viewClass=t,t=pi);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(){return this.rootView!==this?this.rootView.getViewCache():this.isViewCachingEnabled()?(this.viewCache||(this.viewCache={}),this.viewCache):void 0}isViewCachingEnabled(){return this.shouldCacheViews!==!1}enableViewCaching(){this.shouldCacheViews=!0}disableViewCaching(){this.shouldCacheViews=!1}getCachedViewForObject(t){var e;return(e=this.getViewCache())===null||e===void 0?void 0:e[t.getCacheKey()]}cacheViewForObject(t,e){let n=this.getViewCache();n&&(n[e.getCacheKey()]=t)}garbageCollectCachedViews(){let t=this.getViewCache();if(t){let e=this.getAllChildViews().concat(this).map((n=>n.object.getCacheKey()));for(let n in t)e.includes(n)||delete t[n]}}},pi=class extends ft{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:Zr,setPrototypeOf:dr,isFrozen:Jo,getPrototypeOf:Ko,getOwnPropertyDescriptor:Go}=Object,{freeze:K,seal:Z,create:Gt}=Object,{apply:fi,construct:bi}=typeof Reflect<"u"&&Reflect;K||(K=function(i){return i}),Z||(Z=function(i){return i}),fi||(fi=function(i,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),r=2;r1?t-1:0),n=1;n"u"?null:F(BigInt.prototype.toString),br=typeof Symbol>"u"?null:F(Symbol.prototype.toString),T=F(Object.prototype.hasOwnProperty),Ve=F(Object.prototype.toString),_=F(RegExp.prototype.test),ze=(vr=TypeError,function(){for(var i=arguments.length,t=new Array(i),e=0;e1?e-1:0),r=1;r2&&arguments[2]!==void 0?arguments[2]:xe;if(dr&&dr(i,null),!H(t))return i;let n=t.length;for(;n--;){let r=t[n];if(typeof r=="string"){let o=e(r);o!==r&&(Jo(t)||(t[n]=o),r=o)}i[r]=!0}return i}function ts(i){for(let t=0;t/gm),os=Z(/\$\{[\w\W]*/gm),ss=Z(/^data-[\-\w.\u00B7-\uFFFF]+$/),as=Z(/^aria-[\-\w]+$/),to=Z(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ls=Z(/^(?:\w+script|data):/i),cs=Z(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),eo=Z(/^html$/i),us=Z(/^[a-z][.\w]*(-[.\w]+)+$/i),Er=Object.freeze({__proto__:null,ARIA_ATTR:as,ATTR_WHITESPACE:cs,CUSTOM_ELEMENT:us,DATA_ATTR:ss,DOCTYPE_NAME:eo,ERB_EXPR:rs,IS_ALLOWED_URI:to,IS_SCRIPT_OR_DATA:ls,MUSTACHE_EXPR:is,TMPLIT_EXPR:os}),hs=1,ds=3,gs=7,ms=8,ps=9,fs=function(){return typeof window>"u"?null:window},te=(function i(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fs(),e=a=>i(a);if(e.version="3.4.2",e.removed=[],!t||!t.document||t.document.nodeType!==ps||!t.Element)return e.isSupported=!1,e;let{document:n}=t,r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:l,Node:c,Element:u,NodeFilter:g,NamedNodeMap:S=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:D,DOMParser:Y,trustedTypes:st}=t,V=u.prototype,vt=Kt(V,"cloneNode"),Rt=Kt(V,"remove"),ce=Kt(V,"nextSibling"),ue=Kt(V,"childNodes"),j=Kt(V,"parentNode");if(typeof l=="function"){let a=n.createElement("template");a.content&&a.content.ownerDocument&&(n=a.content.ownerDocument)}let k,ht="",{implementation:kt,createNodeIterator:go,createDocumentFragment:mo,getElementsByTagName:po}=n,{importNode:fo}=r,z={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};e.isSupported=typeof Zr=="function"&&typeof j=="function"&&kt&&kt.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:Oe,ERB_EXPR:Fe,TMPLIT_EXPR:Pe,DATA_ATTR:bo,ARIA_ATTR:vo,IS_SCRIPT_OR_DATA:Ao,ATTR_WHITESPACE:Oi,CUSTOM_ELEMENT:yo}=Er,{IS_ALLOWED_URI:Fi}=Er,B=null,Pi=p({},[...Ar,...Jn,...Kn,...Gn,...yr]),M=null,Bi=p({},[...xr,...$n,...Cr,...He]),L=Object.seal(Gt(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}})),he=null,Be=null,At=Object.seal(Gt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Mi=!0,xn=!0,_i=!1,ji=!0,Tt=!1,de=!0,wt=!1,Cn=!1,En=!1,Ut=!1,Me=!1,_e=!1,Wi=!0,Ui=!1,Vi="user-content-",Sn=!0,ge=!1,Vt={},at=null,Rn=p({},["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"]),zi=null,Hi=p({},["audio","video","img","source","image","track"]),kn=null,qi=p({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),je="http://www.w3.org/1998/Math/MathML",We="http://www.w3.org/2000/svg",lt="http://www.w3.org/1999/xhtml",zt=lt,Tn=!1,wn=null,xo=p({},[je,We,lt],qn),Dn=p({},["mi","mo","mn","ms","mtext"]),Ln=p({},["annotation-xml"]),Co=p({},["title","style","font","a","script"]),me=null,Eo=["application/xhtml+xml","text/html"],P=null,Ht=null,So=n.createElement("form"),Ji=function(a){return a instanceof RegExp||a instanceof Function},Nn=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ht&&Ht===a)return;a&&typeof a=="object"||(a={}),a=G(a),me=Eo.indexOf(a.PARSER_MEDIA_TYPE)===-1?"text/html":a.PARSER_MEDIA_TYPE,P=me==="application/xhtml+xml"?qn:xe,B=T(a,"ALLOWED_TAGS")&&H(a.ALLOWED_TAGS)?p({},a.ALLOWED_TAGS,P):Pi,M=T(a,"ALLOWED_ATTR")&&H(a.ALLOWED_ATTR)?p({},a.ALLOWED_ATTR,P):Bi,wn=T(a,"ALLOWED_NAMESPACES")&&H(a.ALLOWED_NAMESPACES)?p({},a.ALLOWED_NAMESPACES,qn):xo,kn=T(a,"ADD_URI_SAFE_ATTR")&&H(a.ADD_URI_SAFE_ATTR)?p(G(qi),a.ADD_URI_SAFE_ATTR,P):qi,zi=T(a,"ADD_DATA_URI_TAGS")&&H(a.ADD_DATA_URI_TAGS)?p(G(Hi),a.ADD_DATA_URI_TAGS,P):Hi,at=T(a,"FORBID_CONTENTS")&&H(a.FORBID_CONTENTS)?p({},a.FORBID_CONTENTS,P):Rn,he=T(a,"FORBID_TAGS")&&H(a.FORBID_TAGS)?p({},a.FORBID_TAGS,P):G({}),Be=T(a,"FORBID_ATTR")&&H(a.FORBID_ATTR)?p({},a.FORBID_ATTR,P):G({}),Vt=!!T(a,"USE_PROFILES")&&(a.USE_PROFILES&&typeof a.USE_PROFILES=="object"?G(a.USE_PROFILES):a.USE_PROFILES),Mi=a.ALLOW_ARIA_ATTR!==!1,xn=a.ALLOW_DATA_ATTR!==!1,_i=a.ALLOW_UNKNOWN_PROTOCOLS||!1,ji=a.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Tt=a.SAFE_FOR_TEMPLATES||!1,de=a.SAFE_FOR_XML!==!1,wt=a.WHOLE_DOCUMENT||!1,Ut=a.RETURN_DOM||!1,Me=a.RETURN_DOM_FRAGMENT||!1,_e=a.RETURN_TRUSTED_TYPE||!1,En=a.FORCE_BODY||!1,Wi=a.SANITIZE_DOM!==!1,Ui=a.SANITIZE_NAMED_PROPS||!1,Sn=a.KEEP_CONTENT!==!1,ge=a.IN_PLACE||!1,Fi=(function(h){try{return _(h,""),!0}catch{return!1}})(a.ALLOWED_URI_REGEXP)?a.ALLOWED_URI_REGEXP:to,zt=typeof a.NAMESPACE=="string"?a.NAMESPACE:lt,Dn=T(a,"MATHML_TEXT_INTEGRATION_POINTS")&&a.MATHML_TEXT_INTEGRATION_POINTS&&typeof a.MATHML_TEXT_INTEGRATION_POINTS=="object"?G(a.MATHML_TEXT_INTEGRATION_POINTS):p({},["mi","mo","mn","ms","mtext"]),Ln=T(a,"HTML_INTEGRATION_POINTS")&&a.HTML_INTEGRATION_POINTS&&typeof a.HTML_INTEGRATION_POINTS=="object"?G(a.HTML_INTEGRATION_POINTS):p({},["annotation-xml"]);let d=T(a,"CUSTOM_ELEMENT_HANDLING")&&a.CUSTOM_ELEMENT_HANDLING&&typeof a.CUSTOM_ELEMENT_HANDLING=="object"?G(a.CUSTOM_ELEMENT_HANDLING):Gt(null);if(L=Gt(null),T(d,"tagNameCheck")&&Ji(d.tagNameCheck)&&(L.tagNameCheck=d.tagNameCheck),T(d,"attributeNameCheck")&&Ji(d.attributeNameCheck)&&(L.attributeNameCheck=d.attributeNameCheck),T(d,"allowCustomizedBuiltInElements")&&typeof d.allowCustomizedBuiltInElements=="boolean"&&(L.allowCustomizedBuiltInElements=d.allowCustomizedBuiltInElements),Tt&&(xn=!1),Me&&(Ut=!0),Vt&&(B=p({},yr),M=Gt(null),Vt.html===!0&&(p(B,Ar),p(M,xr)),Vt.svg===!0&&(p(B,Jn),p(M,$n),p(M,He)),Vt.svgFilters===!0&&(p(B,Kn),p(M,$n),p(M,He)),Vt.mathMl===!0&&(p(B,Gn),p(M,Cr),p(M,He))),At.tagCheck=null,At.attributeCheck=null,T(a,"ADD_TAGS")&&(typeof a.ADD_TAGS=="function"?At.tagCheck=a.ADD_TAGS:H(a.ADD_TAGS)&&(B===Pi&&(B=G(B)),p(B,a.ADD_TAGS,P))),T(a,"ADD_ATTR")&&(typeof a.ADD_ATTR=="function"?At.attributeCheck=a.ADD_ATTR:H(a.ADD_ATTR)&&(M===Bi&&(M=G(M)),p(M,a.ADD_ATTR,P))),T(a,"ADD_URI_SAFE_ATTR")&&H(a.ADD_URI_SAFE_ATTR)&&p(kn,a.ADD_URI_SAFE_ATTR,P),T(a,"FORBID_CONTENTS")&&H(a.FORBID_CONTENTS)&&(at===Rn&&(at=G(at)),p(at,a.FORBID_CONTENTS,P)),T(a,"ADD_FORBID_CONTENTS")&&H(a.ADD_FORBID_CONTENTS)&&(at===Rn&&(at=G(at)),p(at,a.ADD_FORBID_CONTENTS,P)),Sn&&(B["#text"]=!0),wt&&p(B,["html","head","body"]),B.table&&(p(B,["tbody"]),delete he.tbody),a.TRUSTED_TYPES_POLICY){if(typeof a.TRUSTED_TYPES_POLICY.createHTML!="function")throw ze('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof a.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ze('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');k=a.TRUSTED_TYPES_POLICY,ht=k.createHTML("")}else k===void 0&&(k=(function(h,v){if(typeof h!="object"||typeof h.createPolicy!="function")return null;let y=null,f="data-tt-policy-suffix";v&&v.hasAttribute(f)&&(y=v.getAttribute(f));let W="dompurify"+(y?"#"+y:"");try{return h.createPolicy(W,{createHTML:X=>X,createScriptURL:X=>X})}catch{return console.warn("TrustedTypes policy "+W+" could not be created."),null}})(st,o)),k!==null&&typeof ht=="string"&&(ht=k.createHTML(""));K&&K(a),Ht=a},Ki=p({},[...Jn,...Kn,...es]),Gi=p({},[...Gn,...ns]),tt=function(a){ve(e.removed,{element:a});try{j(a).removeChild(a)}catch{Rt(a)}},Dt=function(a,d){try{ve(e.removed,{attribute:d.getAttributeNode(a),from:d})}catch{ve(e.removed,{attribute:null,from:d})}if(d.removeAttribute(a),a==="is")if(Ut||Me)try{tt(d)}catch{}else try{d.setAttribute(a,"")}catch{}},$i=function(a){let d=null,h=null;if(En)a=""+a;else{let f=mr(a,/^[\r\n\t ]+/);h=f&&f[0]}me==="application/xhtml+xml"&&zt===lt&&(a=''+a+"");let v=k?k.createHTML(a):a;if(zt===lt)try{d=new Y().parseFromString(v,me)}catch{}if(!d||!d.documentElement){d=kt.createDocument(zt,"template",null);try{d.documentElement.innerHTML=Tn?ht:v}catch{}}let y=d.body||d.documentElement;return a&&h&&y.insertBefore(n.createTextNode(h),y.childNodes[0]||null),zt===lt?po.call(d,wt?"html":"body")[0]:wt?d.documentElement:y},Yi=function(a){return go.call(a.ownerDocument||a,a,g.SHOW_ELEMENT|g.SHOW_COMMENT|g.SHOW_TEXT|g.SHOW_PROCESSING_INSTRUCTION|g.SHOW_CDATA_SECTION,null)},In=function(a){return a instanceof D&&(typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||!(a.attributes instanceof S)||typeof a.removeAttribute!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function")},On=function(a){return typeof c=="function"&&a instanceof c};function dt(a,d,h){be(a,(v=>{v.call(e,d,h,Ht)}))}let Xi=function(a){let d=null;if(dt(z.beforeSanitizeElements,a,null),In(a))return tt(a),!0;let h=P(a.nodeName);if(dt(z.uponSanitizeElement,a,{tagName:h,allowedTags:B}),de&&a.hasChildNodes()&&!On(a.firstElementChild)&&_(/<[/\w!]/g,a.innerHTML)&&_(/<[/\w!]/g,a.textContent)||de&&a.namespaceURI===lt&&h==="style"&&On(a.firstElementChild)||a.nodeType===gs||de&&a.nodeType===ms&&_(/<[/\w]/g,a.data))return tt(a),!0;if(he[h]||!(At.tagCheck instanceof Function&&At.tagCheck(h))&&!B[h]){if(!he[h]&&Zi(h)&&(L.tagNameCheck instanceof RegExp&&_(L.tagNameCheck,h)||L.tagNameCheck instanceof Function&&L.tagNameCheck(h)))return!1;if(Sn&&!at[h]){let v=j(a)||a.parentNode,y=ue(a)||a.childNodes;if(y&&v)for(let f=y.length-1;f>=0;--f){let W=vt(y[f],!0);v.insertBefore(W,ce(a))}}return tt(a),!0}return a instanceof u&&!(function(v){let y=j(v);y&&y.tagName||(y={namespaceURI:zt,tagName:"template"});let f=xe(v.tagName),W=xe(y.tagName);return!!wn[v.namespaceURI]&&(v.namespaceURI===We?y.namespaceURI===lt?f==="svg":y.namespaceURI===je?f==="svg"&&(W==="annotation-xml"||Dn[W]):!!Ki[f]:v.namespaceURI===je?y.namespaceURI===lt?f==="math":y.namespaceURI===We?f==="math"&&Ln[W]:!!Gi[f]:v.namespaceURI===lt?!(y.namespaceURI===We&&!Ln[W])&&!(y.namespaceURI===je&&!Dn[W])&&!Gi[f]&&(Co[f]||!Ki[f]):!(me!=="application/xhtml+xml"||!wn[v.namespaceURI]))})(a)?(tt(a),!0):h!=="noscript"&&h!=="noembed"&&h!=="noframes"||!_(/<\/no(script|embed|frames)/i,a.innerHTML)?(Tt&&a.nodeType===ds&&(d=a.textContent,be([Oe,Fe,Pe],(v=>{d=Jt(d,v," ")})),a.textContent!==d&&(ve(e.removed,{element:a.cloneNode()}),a.textContent=d)),dt(z.afterSanitizeElements,a,null),!1):(tt(a),!0)},Qi=function(a,d,h){if(Be[d]||Wi&&(d==="id"||d==="name")&&(h in n||h in So))return!1;let v=M[d]||At.attributeCheck instanceof Function&&At.attributeCheck(d,a);if(!(xn&&!Be[d]&&_(bo,d))){if(!(Mi&&_(vo,d))){if(!v||Be[d]){if(!(Zi(a)&&(L.tagNameCheck instanceof RegExp&&_(L.tagNameCheck,a)||L.tagNameCheck instanceof Function&&L.tagNameCheck(a))&&(L.attributeNameCheck instanceof RegExp&&_(L.attributeNameCheck,d)||L.attributeNameCheck instanceof Function&&L.attributeNameCheck(d,a))||d==="is"&&L.allowCustomizedBuiltInElements&&(L.tagNameCheck instanceof RegExp&&_(L.tagNameCheck,h)||L.tagNameCheck instanceof Function&&L.tagNameCheck(h))))return!1}else if(!kn[d]){if(!_(Fi,Jt(h,Oi,""))){if((d!=="src"&&d!=="xlink:href"&&d!=="href"||a==="script"||pr(h,"data:")!==0||!zi[a])&&!(_i&&!_(Ao,Jt(h,Oi,"")))){if(h)return!1}}}}}return!0},Ro=p({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Zi=function(a){return!Ro[xe(a)]&&_(yo,a)},tr=function(a){dt(z.beforeSanitizeAttributes,a,null);let{attributes:d}=a;if(!d||In(a))return;let h={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:M,forceKeepAttr:void 0},v=d.length;for(;v--;){let y=d[v],{name:f,namespaceURI:W,value:X}=y,C=P(f),et=X,N=f==="value"?et:Xo(et);if(h.attrName=C,h.attrValue=N,h.keepAttr=!0,h.forceKeepAttr=void 0,dt(z.uponSanitizeAttribute,a,h),N=h.attrValue,!Ui||C!=="id"&&C!=="name"||pr(N,Vi)===0||(Dt(f,a),N=Vi+N),de&&_(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,N)){Dt(f,a);continue}if(C==="attributename"&&mr(N,"href")){Dt(f,a);continue}if(h.forceKeepAttr)continue;if(!h.keepAttr){Dt(f,a);continue}if(!ji&&_(/\/>/i,N)){Dt(f,a);continue}Tt&&be([Oe,Fe,Pe],(nr=>{N=Jt(N,nr," ")}));let qt=P(a.nodeName);if(Qi(qt,C,N)){if(k&&typeof st=="object"&&typeof st.getAttributeType=="function"&&!W)switch(st.getAttributeType(qt,C)){case"TrustedHTML":N=k.createHTML(N);break;case"TrustedScriptURL":N=k.createScriptURL(N)}if(N!==et)try{W?a.setAttributeNS(W,f,N):a.setAttribute(f,N),In(a)?tt(a):gr(e.removed)}catch{Dt(f,a)}}else Dt(f,a)}dt(z.afterSanitizeAttributes,a,null)},er=function(a){let d=null,h=Yi(a);for(dt(z.beforeSanitizeShadowDOM,a,null);d=h.nextNode();)dt(z.uponSanitizeShadowNode,d,null),Xi(d),tr(d),d.content instanceof s&&er(d.content);dt(z.afterSanitizeShadowDOM,a,null)};return e.sanitize=function(a){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=null,v=null,y=null,f=null;if(Tn=!a,Tn&&(a=""),typeof a!="string"&&!On(a)&&typeof(a=(function(C){switch(typeof C){case"string":return C;case"number":return Qo(C);case"boolean":return Zo(C);case"bigint":return fr?fr(C):"0";case"symbol":return br?br(C):"Symbol()";case"undefined":default:return Ve(C);case"function":case"object":{if(C===null)return Ve(C);let et=C,N=Kt(et,"toString");if(typeof N=="function"){let qt=N(et);return typeof qt=="string"?qt:Ve(qt)}return Ve(C)}}})(a))!="string")throw ze("dirty is not a string, aborting");if(!e.isSupported)return a;if(Cn||Nn(d),e.removed=[],typeof a=="string"&&(ge=!1),ge){let C=a.nodeName;if(typeof C=="string"){let et=P(C);if(!B[et]||he[et])throw ze("root node is forbidden and cannot be sanitized in-place")}}else if(a instanceof c)h=$i(""),v=h.ownerDocument.importNode(a,!0),v.nodeType===hs&&v.nodeName==="BODY"||v.nodeName==="HTML"?h=v:h.appendChild(v);else{if(!Ut&&!Tt&&!wt&&a.indexOf("<")===-1)return k&&_e?k.createHTML(a):a;if(h=$i(a),!h)return Ut?null:_e?ht:""}h&&En&&tt(h.firstChild);let W=Yi(ge?a:h);for(;y=W.nextNode();)Xi(y),tr(y),y.content instanceof s&&er(y.content);if(ge)return a;if(Ut){if(Tt){h.normalize();let C=h.innerHTML;be([Oe,Fe,Pe],(et=>{C=Jt(C,et," ")})),h.innerHTML=C}if(Me)for(f=mo.call(h.ownerDocument);h.firstChild;)f.appendChild(h.firstChild);else f=h;return(M.shadowroot||M.shadowrootmode)&&(f=fo.call(r,f,!0)),f}let X=wt?h.outerHTML:h.innerHTML;return wt&&B["!doctype"]&&h.ownerDocument&&h.ownerDocument.doctype&&h.ownerDocument.doctype.name&&_(eo,h.ownerDocument.doctype.name)&&(X=" `+X),Tt&&be([Oe,Fe,Pe],(C=>{X=Jt(X,C," ")})),k&&_e?k.createHTML(X):X},e.setConfig=function(){Nn(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),Cn=!0},e.clearConfig=function(){Ht=null,Cn=!1},e.isValidAttribute=function(a,d,h){Ht||Nn({});let v=P(a),y=P(d);return Qi(v,y,h)},e.addHook=function(a,d){typeof d=="function"&&ve(z[a],d)},e.removeHook=function(a,d){if(d!==void 0){let h=$o(z[a],d);return h===-1?void 0:Yo(z[a],h,1)[0]}return gr(z[a])},e.removeHooks=function(a){z[a]=[]},e.removeAllHooks=function(){z={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},e})();te.addHook("uponSanitizeAttribute",(function(i,t){if(t.attrName==="data-trix-serialized-attributes")return void(t.keepAttr=!1);/^data-trix-/.test(t.attrName)&&(t.forceKeepAttr=!0)}));var bs="style href src width height language class".split(" "),vs="javascript:".split(" "),As="script iframe form noscript".split(" "),ee=class extends w{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||bs,this.forbiddenProtocols=n||vs,this.forbiddenElements=r||As,this.purifyOptions=o||{},this.body=ys(t)}sanitize(){this.sanitizeElements(),this.normalizeListElementNesting();let t=Object.assign({},Wr,this.purifyOptions);return te.setConfig(t),this.body=te.sanitize(this.body),this.body}getHTML(){return this.body.innerHTML}getBody(){return this.body}sanitizeElements(){let t=Xe(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)}}return e.forEach((n=>St(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&&q(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(q(t))}elementIsntSerializable(t){return t.getAttribute("data-trix-serialize")==="false"&&!Ot(t)}},ys=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";i=i.replace(/<\/html[^>]*>[^]*$/i,"");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:yt}=Ie,we=class extends ft{constructor(){super(...arguments),this.attachment=this.object,this.attachment.uploadProgressDelegate=this,this.attachmentPiece=this.options.piece}createContentNodes(){return[]}createNodes(){let t,e=t=b({tagName:"figure",className:this.getClassName(),data:this.getData(),editable:!1}),n=this.getHref();return n&&(t=b({tagName:"a",editable:!1,attributes:{href:n,tabindex:-1}}),e.appendChild(t)),this.attachment.hasContent()?ee.setHTML(t,this.attachment.getContent()):this.createContentNodes().forEach((r=>{t.appendChild(r)})),t.appendChild(this.createCaptionElement()),this.attachment.isPending()&&(this.progressElement=b({tagName:"progress",attributes:{class:yt.attachmentProgress,value:this.attachment.getUploadProgress(),max:100},data:{trixMutable:!0,trixStoreKey:["progressElement",this.attachment.id].join("/")}}),e.appendChild(this.progressElement)),[Sr("left"),e,Sr("right")]}createCaptionElement(){let t=b({tagName:"figcaption",className:yt.attachmentCaption}),e=this.attachmentPiece.getCaption();if(e)t.classList.add("".concat(yt.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=b({tagName:"span",className:yt.attachmentName,textContent:n});t.appendChild(s)}if(r){n&&t.appendChild(document.createTextNode(" "));let s=b({tagName:"span",className:yt.attachmentSize,textContent:r});t.appendChild(s)}}return t}getClassName(){let t=[yt.attachment,"".concat(yt.attachment,"--").concat(this.attachment.getType())],e=this.attachment.getExtension();return e&&t.push("".concat(yt.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(!xs(this.attachment.getContent(),"a")){let t=this.attachment.getHref();if(t&&te.isValidAttribute("a","href",t))return t}}getCaptionConfig(){var t;let e=this.attachment.getType(),n=Yr((t=Ri[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)}},Sr=i=>b({tagName:"span",textContent:An,data:{trixCursorTarget:i,trixSerialize:!1}}),xs=function(i,t){let e=b("div");return ee.setHTML(e,i||""),e.querySelector(t)},tn=class extends we{constructor(){super(...arguments),this.attachment.previewDelegate=this}createContentNodes(){return this.image=b({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){var e;if(t||(t=(e=this.findElement())===null||e===void 0?void 0:e.querySelector("img")),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()}},en=class extends ft{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=(function(r){for(;(o=r)!==null&&o!==void 0&&o.firstElementChild;){var o;r=r.firstElementChild}return r})(e);Array.from(t).forEach((r=>{n.appendChild(r)})),t=[e]}return t}createAttachmentNodes(){let t=this.attachment.isPreviewable()?tn:we;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;r0){let s=b("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=hi(e);if(s){if(s.tagName){var o;let l=b(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)for(e in t||(t=b("span")),r)n=r[e],t.style[e]=n;return t}createContainerElement(){for(let t in this.attributes){let e=this.attributes[t],n=hi(t);if(n&&n.groupTagName){let r={};return r[t]=e,b(n.groupTagName,r)}}}preserveSpaces(t){return this.context.isLast&&(t=t.replace(/\ $/,xt)),t=t.replace(/(\S)\ {3}(\S)/g,"$1 ".concat(xt," $2")).replace(/\ {2}/g,"".concat(xt," ")).replace(/\ {2}/g," ".concat(xt)),(this.context.isFirst||this.context.followsWhitespace)&&(t=t.replace(/^\ /,xt)),t}},nn=class extends ft{constructor(){super(...arguments),this.text=this.object,this.textConfig=this.options.textConfig}createNodes(){let t=[],e=Te.groupObjects(this.getPieces()),n=e.length-1;for(let o=0;o!t.hasAttribute("blockBreak")))}},Cs=i=>/\s$/.test(i?.toString()),{css:Rr}=Ie,rn=class extends ft{constructor(){super(...arguments),this.block=this.object,this.attributes=this.block.getAttributes()}createNodes(){let t=[document.createComment("block")];if(this.block.isEmpty())t.push(b("br"));else{var e;let n=(e=O(this.block.getLastAttribute()))===null||e===void 0?void 0:e.text,r=this.findOrCreateCachedChildView(nn,this.block.text,{textConfig:n});t.push(...Array.from(r.getNodes()||[])),this.shouldAddExtraNewlineElement()&&t.push(b("br"))}if(this.attributes.length)return t;{let n,{tagName:r}=J.default;this.block.isRTL()&&(n={dir:"rtl"});let o=b({tagName:r,attributes:n});return t.forEach((s=>o.appendChild(s))),[o]}}createContainerElement(t){let e={},n,r=this.attributes[t],{tagName:o,htmlAttributes:s=[]}=O(r);if(t===0&&this.block.isRTL()&&Object.assign(e,{dir:"rtl"}),r==="attachmentGallery"){let l=this.block.getBlockBreakPosition();n="".concat(Rr.attachmentGallery," ").concat(Rr.attachmentGallery,"--").concat(l)}return Object.entries(this.block.htmlAttributes).forEach((l=>{let[c,u]=l;s.includes(c)&&(e[c]=u)})),b({tagName:o,className:n,attributes:e})}shouldAddExtraNewlineElement(){return/\n\n$/.test(this.block.toString())}},ne=class extends ft{static render(t){let e=b("div"),n=new this(t,{element:e});return n.render(),n.sync(),e}constructor(){super(...arguments),this.element=this.options.element,this.elementStore=new mi,this.setDocument(this.object)}setDocument(t){t.isEqualTo(this.document)||(this.document=this.object=t)}render(){if(this.childViews=[],this.shadowElement=b("div"),!this.document.isEmpty()){let t=Te.groupObjects(this.document.getBlocks(),{asTree:!0});Array.from(t).forEach((e=>{let n=this.findOrCreateCachedChildView(rn,e);Array.from(n.getNodes()).map((r=>this.shadowElement.appendChild(r)))}))}}isSynced(){return Es(this.shadowElement,this.element)}sync(){let t=zr("trix-before-render",{cancelable:!1,attributes:{render:(n,r)=>{for(;n.lastChild;)n.removeChild(n.lastChild);n.appendChild(r)}}});this.element.dispatchEvent(t);let e=this.createDocumentFragmentForSync();return t.render(this.element,e),this.didSync()}didSync(){return this.elementStore.reset(kr(this.element)),Li((()=>this.garbageCollectCachedViews()))}createDocumentFragmentForSync(){let t=document.createDocumentFragment();return Array.from(this.shadowElement.childNodes).forEach((e=>{t.appendChild(e.cloneNode(!0))})),Array.from(kr(t)).forEach((e=>{let n=this.elementStore.remove(e);n&&e.parentNode.replaceChild(n,e)})),t}},kr=i=>i.querySelectorAll("[data-trix-store-key]"),Es=(i,t)=>Tr(i.innerHTML)===Tr(t.innerHTML),Tr=i=>i.replace(/ /g," ");function qe(i){var t,e;function n(o,s){try{var l=i[o](s),c=l.value,u=c instanceof Ss;Promise.resolve(u?c.v:c).then((function(g){if(u){var S=o==="return"?"return":"next";if(!c.k||g.done)return n(S,g);g=i[S](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 u={key:o,arg:s,resolve:l,reject:c,next:null};e?e=e.next=u:(t=e=u,n(o,s))}))},typeof i.return!="function"&&(this.return=void 0)}function Ss(i,t){this.v=i,this.k=t}function Rs(i){var t=(function(e,n){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,n||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)})(i,"string");return typeof t=="symbol"?t:String(t)}function U(i,t,e){return(t=Rs(t))in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}qe.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},qe.prototype.next=function(i){return this._invoke("next",i)},qe.prototype.throw=function(i){return this._invoke("throw",i)},qe.prototype.return=function(i){return this._invoke("return",i)};function A(i,t){return ks(i,no(i,t,"get"))}function ke(i,t,e){return Ts(i,no(i,t,"set"),e),e}function no(i,t,e){if(!t.has(i))throw new TypeError("attempted to "+e+" private field on non-instance");return t.get(i)}function ks(i,t){return t.get?t.get.call(i):t.value}function Ts(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 Je(i,t,e){if(!t.has(i))throw new TypeError("attempted to get private field on non-instance");return e}function io(i,t){if(t.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Qt(i,t,e){io(i,t),t.set(i,e)}var bt=class extends pt{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=rt.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}};U(bt,"types",{});var on=class extends Zt{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}},ie=class i extends pt{static attachmentForFile(t){let e=new this(this.attributesForFile(t));return e.setFile(t),e}static attributesForFile(t){return new rt({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=rt.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);var n,r,o,s;if(!this.attributes.isEqualTo(e))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"):i.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"?Ur.formatter(t):""}getExtension(){var t;return(t=this.getFilename().match(/\.(\w+)$/))===null||t===void 0?void 0:t[1].toLowerCase()}getContentType(){return this.attributes.get("contentType")}hasContent(){return this.attributes.has("content")}getContent(){return this.attributes.get("content")}getWidth(){return this.attributes.get("width")}getHeight(){return this.attributes.get("height")}getFile(){return this.file}setFile(t){if(this.file=t,this.isPreviewable())return this.preloadFile()}releaseFile(){this.releasePreloadedFile(),this.file=null}getUploadProgress(){return this.uploadProgress!=null?this.uploadProgress:0}setUploadProgress(t){var e,n;if(this.uploadProgress!==t)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){var e,n,r,o;if(t!==this.getPreviewURL())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 on(t).then((n=>{let{width:r,height:o}=n;return this.getWidth()&&this.getHeight()||this.setAttributes({width:r,height:o}),this.preloadingURL=null,this.setPreviewURL(t),e?.()})).catch((()=>(this.preloadingURL=null,e?.())))}};U(ie,"previewablePattern",/^image(\/(gif|png|webp|jpe?g)|$)/);var re=class i extends bt{static fromJSON(t){return new this(ie.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(i.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"\uFFFC"}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())}};U(re,"permittedAttributes",["caption","presentation"]),bt.registerType("attachment",re);var De=class extends bt{static fromJSON(t){let e={...t.attributes};return e.href&&!te.isValidAttribute("a","href",e.href)&&delete e.href,new this(t.string,e)}constructor(t){super(...arguments),this.string=(e=>e.replace(/\r\n?/g,` `))(t),this.length=this.string.length}getValue(){return this.string}toString(){return this.string.toString()}isBlockBreak(){return this.toString()===` `&&this.getAttribute("blockBreak")===!0}toJSON(){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())}};bt.registerType("string",De);var oe=class extends pt{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;nt(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(Ds(t));return[n,e]=new this.constructor(n).splitObjectAtPosition(Ls(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,u]=l.splitAtOffset(o);s.splice(r,1,c,u),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 n=this.objects.slice(0).slice(t,e+1),r=new this.constructor(n).consolidate().toArray();return this.splice(t,n.length,...r)}findIndexAndOffsetAtPosition(t){let e,n=0;for(e=0;ethis.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;ni[0],Ls=i=>i[1],Q=class extends pt{static textForAttachmentWithAttributes(t,e){return new this([new re(t,e)])}static textForStringWithAttributes(t,e){return new this([new De(t,e)])}static fromJSON(t){return new this(Array.from(t).map((e=>bt.fromJSON(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 oe(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]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 rt.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!!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)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 Mo(this.toString())}isRTL(){return this.getDirection()==="rtl"}},Ct=class i extends pt{static fromJSON(t){return new this(Q.fromJSON(t.text),t.attributes,t.htmlAttributes)}constructor(t,e,n){super(...arguments),this.text=Ns(t||new Q),this.attributes=e||[],this.htmlAttributes=n||{}}isEmpty(){return this.text.isBlockBreak()}isEqualTo(t){return!!super.isEqualTo(t)||this.text.isEqualTo(t?.text)&&_t(this.attributes,t?.attributes)&&le(this.htmlAttributes,t?.htmlAttributes)}copyWithText(t){return new i(t,this.attributes,this.htmlAttributes)}copyWithoutText(){return this.copyWithText(null)}copyWithAttributes(t){return new i(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(wr(t));return this.copyWithAttributes(e)}addHTMLAttribute(t,e){let n=Object.assign({},this.htmlAttributes,{[t]:e});return new i(this.text,this.attributes,n)}removeAttribute(t){let{listAttribute:e}=O(t),n=Lr(Lr(this.attributes,t),e);return this.copyWithAttributes(n)}removeLastAttribute(){return this.removeAttribute(this.getLastAttribute())}getLastAttribute(){return Dr(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 Dr(this.getNestableAttributes())}getNestableAttributes(){return this.attributes.filter((t=>O(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=Di(this.attributes,e+1,0,...wr(t));return this.copyWithAttributes(n)}return this}getListItemAttributes(){return this.attributes.filter((t=>O(t).listAttribute))}isListItem(){var t;return(t=O(this.getLastAttribute()))===null||t===void 0?void 0:t.listAttribute}isTerminalBlock(){var t;return(t=O(this.getLastAttribute()))===null||t===void 0?void 0:t.terminal}breaksOnReturn(){var t;return(t=O(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=Q.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 ro(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&&!(O(o).group===!1&&!(()=>{if(!Ue){Ue=[];for(let s in J){let{listAttribute:l}=J[s];l!=null&&Ue.push(l)}}return Ue})().includes(n[e+1]))&&(this.getDirection()===t.getDirection()||t.isEmpty())}},Ns=function(i){return i=Is(i),i=Fs(i)},Is=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,Ps(o)):o)),t?new Q([...n,r]):i):i},Os=Q.textForStringWithAttributes(` `,{blockBreak:!0}),Fs=function(i){return ro(i)?i:i.appendText(Os)},ro=function(i){let t=i.getLength();return t===0?!1:i.getTextAtRange([t-1,t]).isBlockBreak()},Ps=i=>i.copyWithoutAttribute("blockBreak"),wr=function(i){let{listAttribute:t}=O(i);return t?[t,i]:[i]},Dr=i=>i.slice(-1)[0],Lr=function(i,t){let e=i.lastIndexOf(t);return e===-1?i:Di(i,e,1)},$=class extends pt{static fromJSON(t){return new this(Array.from(t).map((e=>Ct.fromJSON(e))))}static fromString(t,e){let n=Q.textForStringWithAttributes(t,e);return new this([new Ct(n)])}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];super(...arguments),t.length===0&&(t=[new Ct]),this.blockList=oe.box(t)}isEmpty(){let t=this.getBlockAtIndex(0);return this.blockList.length===1&&t.isEmpty()&&!t.hasAttributes()}copy(){let t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).consolidateBlocks?this.blockList.consolidate().toArray():this.blockList.toArray();return new this.constructor(t)}copyUsingObjectsFromDocument(t){let e=new gi(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=x(e);let[r]=e,{index:o,offset:s}=this.locationFromPosition(r),l=this,c=this.getBlockAtPosition(r);return mt(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=x(e);let[o]=e,s=this.locationFromPosition(o),l=this.getBlockAtIndex(s.index).getAttributes(),c=t.getBaseBlockAttributes(),u=l.slice(-c.length);if(_t(c,u)){let D=l.slice(0,-c.length);n=t.copyWithBaseBlockAttributes(D)}else n=t.copy({consolidateBlocks:!0}).copyWithBaseBlockAttributes(l);let g=n.getBlockCount(),S=n.getBlockAtIndex(0);if(_t(l,S.getAttributes())){let D=S.getTextWithoutBlockBreak();if(r=this.insertTextAtRange(D,e),g>1){n=new this.constructor(n.getBlocks().slice(1));let Y=o+D.getLength();r=r.insertDocumentAtRange(n,Y)}}else r=this.insertDocumentAtRange(n,e);return r}insertTextAtRange(t,e){e=x(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=x(t);let[n,r]=t;if(mt(t))return this;let[o,s]=Array.from(this.locationRangeFromRange(t)),l=o.index,c=o.offset,u=this.getBlockAtIndex(l),g=s.index,S=s.offset,D=this.getBlockAtIndex(g);if(r-n==1&&u.getBlockBreakPosition()===c&&D.getBlockBreakPosition()!==S&&D.text.getStringAtPosition(S)===` `)e=this.blockList.editObjectAtIndex(g,(Y=>Y.copyWithText(Y.text.removeTextAtRange([S,S+1]))));else{let Y,st=u.text.getTextAtRange([0,c]),V=D.text.getTextAtRange([S,D.getLength()]),vt=st.appendText(V);Y=l!==g&&c===0&&u.getAttributeLevel()>=D.getAttributeLevel()?D.copyWithText(vt):u.copyWithText(vt);let Rt=g+1-l;e=this.blockList.splice(l,Rt,Y)}return new this.constructor(e)}moveTextFromRangeToPosition(t,e){let n;t=x(t);let[r,o]=t;if(r<=e&&e<=o)return this;let s=this.getDocumentAtRange(t),l=this.removeTextAtRange(t),c=rr=r.editObjectAtIndex(l,(function(){return O(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){O(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=x(t);let[n]=t,{offset:r}=this.locationFromPosition(n),o=this.removeTextAtRange(t);return r===0&&(e=[new Ct]),new this.constructor(o.blockList.insertSplittableListAtPosition(new oe(e),n))}applyBlockAttributeAtRange(t,e,n){let r=this.expandRangeToLineBreaksAndSplitBlocks(n),o=r.document;n=r.range;let s=O(t);if(s.listAttribute){o=o.removeLastListAttributeAtRange(n,{exceptAttributeName:t});let l=o.convertLineBreaksToBlockBreaksInRange(n);o=l.document,n=l.range}else o=s.exclusive?o.removeBlockAttributesAtRange(n):s.terminal?o.removeLastTerminalAttributeAtRange(n):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&&O(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&&O(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=x(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 u=l.getBlockAtIndex(s.index);u.text.getStringAtRange([s.offset-1,s.offset])===` `?s.offset-=1:s.offset=u.findLineBreakInDirectionFromPosition("forward",s.offset),s.offset!==u.getBlockBreakPosition()&&(e=l.positionFromLocation(s),l=l.insertBlockBreakAtRange([e,e+1]))}return n=l.positionFromLocation(o),r=l.positionFromLocation(s),{document:l,range:t=x([n,r])}}convertLineBreaksToBlockBreaksInRange(t){t=x(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=x(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=x(t);let e=this.blockList.getSplittableListInRange(t).toArray();return new this.constructor(e)}getStringAtRange(t){let e,n=t=x(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=x(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 u=l.index;u<=c.index;u++)if(n=this.getBlockAtIndex(u),n){switch(u){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,u)}}getCommonAttributesAtRange(t){t=x(t);let[e]=t;if(mt(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(Nr(o))})),rt.fromCommonAttributesOfObjects(n).merge(rt.fromCommonAttributesOfObjects(r)).toObject()}}getCommonAttributesAtPosition(t){let e,n,{index:r,offset:o}=this.locationFromPosition(t),s=this.getBlockAtIndex(r);if(!s)return{};let l=Nr(s),c=s.text.getAttributesAtPosition(o),u=s.text.getAttributesAtPosition(o-1),g=Object.keys(Bt).filter((S=>Bt[S].inheritable));for(e in u)n=u[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}),u=this.positionFromLocation({index:n,offset:l});return x([c,u])}getBaseBlockAttributes(){let t=this.getBlockAtIndex(0).getAttributes();for(let e=1;e{let o=[];for(let s=0;s{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{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=[];return this.getPieces().forEach((s=>{let l=s.getLength();(function(c){return e?c.getAttribute(t)===e:c.hasAttribute(t)})(s)&&(r[1]===n?r[1]=n+l:o.push(r=[n,n+l])),n+=l})),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 x(this.locationFromPosition(t))}locationRangeFromRange(t){if(!(t=x(t)))return;let[e,n]=Array.from(t),r=this.locationFromPosition(e),o=this.locationFromPosition(n);return x([r,o])}rangeFromLocationRange(t){let e;t=x(t);let n=this.positionFromLocation(t[0]);return mt(t)||(e=this.positionFromLocation(t[1])),x([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()))))}},Nr=function(i){let t={},e=i.getLastAttribute();return e&&(t[e]=!0),t},Yn=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return{string:i=ye(i),attributes:t,type:"string"}},Ir=(i,t)=>{try{return JSON.parse(i.getAttribute("data-trix-".concat(t)))}catch{return{}}},Wt=class extends w{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 $.fromJSON(this.blocks)}parse(){try{this.createHiddenContainer(),ee.setHTML(this.containerElement,this.html,{purifyOptions:this.purifyOptions});let t=Xe(this.containerElement,{usingFilter:Ms});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=b({tagName:"div",style:{display:"none"}}),document.body.appendChild(this.containerElement))}removeHiddenContainer(){return St(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);_t(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=Nt(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&&_t(r,this.currentBlock.attributes))return this.appendStringWithAttributes(` `);this.currentBlock=this.appendBlockForAttributesWithElement(r,t,o),this.currentBlockElement=t}}}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;var n;return Or(t.parentNode)||(e=Ii(e),oo((n=t.previousSibling)===null||n===void 0?void 0:n.textContent)&&(e=_s(e))),this.appendStringWithAttributes(e,this.getTextAttributes(t.parentNode))}processElement(t){let e;if(Ot(t)){if(e=Ir(t,"attachment"),Object.keys(e).length){let n=this.getTextAttributes(t);this.appendAttachmentWithAttributes(e,n),t.innerHTML=""}return this.processedElements.push(t)}switch(q(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=(r=>{let o=r.getAttribute("width"),s=r.getAttribute("height"),l={};return o&&(l.width=parseInt(o,10)),s&&(l.height=parseInt(s,10)),l})(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($e.tableRowSeparator);break;case"td":if(this.needsTableSeparator(t))return this.appendStringWithAttributes($e.tableCellSeparator)}}appendBlockForAttributesWithElement(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.blockElements.push(e);let r=(function(){return{text:[],attributes:arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},htmlAttributes:arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}}})(t,n);return this.blocks.push(r),r}appendEmptyBlock(){return this.appendBlockForAttributesWithElement([],null)}appendStringWithAttributes(t,e){return this.appendPiece(Yn(t,e))}appendAttachmentWithAttributes(t,e){return this.appendPiece((function(n){return{attachment:n,attributes:arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},type:"attachment"}})(t,e))}appendPiece(t){return this.blocks.length===0&&this.appendEmptyBlock(),this.blocks[this.blocks.length-1].text.push(t)}appendStringToTextAtIndex(t,e){let{text:n}=this.blocks[e],r=n[n.length-1];if(r?.type!=="string")return n.push(Yn(t));r.string+=t}prependStringToTextAtIndex(t,e){let{text:n}=this.blocks[e],r=n[0];if(r?.type!=="string")return n.unshift(Yn(t));r.string=t+r.string}getTextAttributes(t){let e,n={};for(let r in Bt){let o=Bt[r];if(o.tagName&&Et(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(Ot(t)){let r=Ir(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 J){let o=J[r];var n;o.parse!==!1&&q(t)===o.tagName&&((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(J).find((r=>r.tagName===q(t)));return(n?.htmlAttributes||[]).forEach((r=>{t.hasAttribute(r)&&(e[r]=t.getAttribute(r))})),e}findBlockElementAncestors(t){let e=[];for(;t&&t!==this.containerElement;){let n=q(t);Ee().includes(n)&&e.push(t),t=t.parentNode}return e}isBlockElement(t){if(t?.nodeType===Node.ELEMENT_NODE&&!Ot(t)&&!Et(t,{matchingSelector:"td",untilNode:this.containerElement}))return Ee().includes(q(t))||window.getComputedStyle(t).display==="block"}isInsignificantTextNode(t){if(t?.nodeType!==Node.TEXT_NODE||!js(t.data))return;let{parentNode:e,previousSibling:n,nextSibling:r}=t;return Bs(e.previousSibling)&&!this.isBlockElement(e.previousSibling)||Or(e)?void 0:!n||this.isBlockElement(n)||!r||this.isBlockElement(r)}isExtraBR(t){return q(t)==="br"&&this.isBlockElement(t.parentNode)&&t.parentNode.lastChild===t}needsTableSeparator(t){if($e.removeBlankTableCells){var e;let n=(e=t.previousSibling)===null||e===void 0?void 0:e.textContent;return n&&/\S/.test(n)}return t.previousSibling}translateBlockElementMarginsToNewlines(){let t=this.getMarginOfDefaultBlockElement();for(let e=0;e2*t.top&&this.prependStringToTextAtIndex(` `,e),n.bottom>2*t.bottom&&this.appendStringToTextAtIndex(` `,e))}}getMarginOfBlockElementAtIndex(t){let e=this.blockElements[t];if(e&&e.textContent&&!Ee().includes(q(e))&&!this.processedElements.includes(e))return Fr(e)}getMarginOfDefaultBlockElement(){let t=b(J.default.tagName);return this.containerElement.appendChild(t),Fr(t)}},Or=function(i){let{whiteSpace:t}=window.getComputedStyle(i);return["pre","pre-wrap","pre-line"].includes(t)},Bs=i=>i&&!oo(i.textContent),Fr=function(i){let t=window.getComputedStyle(i);if(t.display==="block")return{top:parseInt(t.marginTop),bottom:parseInt(t.marginBottom)}},Ms=function(i){return q(i)==="style"?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},_s=i=>i.replace(new RegExp("^".concat(Ni.source,"+")),""),js=i=>new RegExp("^".concat(Ni.source,"*$")).test(i),oo=i=>/\s$/.test(i),Ws=["contenteditable","data-trix-id","data-trix-store-key","data-trix-mutable","data-trix-placeholder","tabindex"],vi="data-trix-serialized-attributes",Us="[".concat(vi,"]"),Vs=new RegExp("","g"),zs={"application/json":function(i){let t;if(i instanceof $)t=i;else{if(!(i instanceof HTMLElement))throw new Error("unserializable object");t=Wt.parse(i.innerHTML).getDocument()}return t.toSerializableDocument().toJSONString()},"text/html":function(i){let t;if(i instanceof $)t=ne.render(i);else{if(!(i instanceof HTMLElement))throw new Error("unserializable object");t=i.cloneNode(!0)}return Array.from(t.querySelectorAll("[data-trix-serialize=false]")).forEach((e=>{St(e)})),Ws.forEach((e=>{Array.from(t.querySelectorAll("[".concat(e,"]"))).forEach((n=>{n.removeAttribute(e)}))})),Array.from(t.querySelectorAll(Us)).forEach((e=>{try{let n=JSON.parse(e.getAttribute(vi));e.removeAttribute(vi);for(let r in n){let o=n[r];e.setAttribute(r,o)}}catch{}})),t.innerHTML.replace(Vs,"")}},Hs=Object.freeze({__proto__:null}),E=class extends w{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 sn=class extends w{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){var e,n;if(this.attachmentIsManaged(t))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}},an=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()}},ut=class extends w{constructor(){super(...arguments),this.document=new $,this.attachments=[],this.currentAttributes={},this.revision=0}setDocument(t){var e,n;if(!t.isEqualTo(this.document))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 $),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 Ct,e=new $([t]);return this.insertDocument(e)}insertDocument(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new $,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=Q.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 an(this);if(t.shouldDecreaseListLevel())return this.decreaseListLevel(),this.setSelection(t.startPosition);if(t.shouldPrependListItem()){let e=new $([t.block.copyWithoutText()]);return this.insertDocument(e)}return t.shouldInsertBlockBreak()?this.insertBlockBreak():t.shouldRemoveLastBlockAttribute()?this.removeLastBlockAttribute():t.shouldBreakFormattedBlock()?this.breakFormattedBlock(t):this.insertString(` `)}insertHTML(t){let e=Wt.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=Wt.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=ie.attachmentForFile(n);e.push(o)}})),this.insertAttachments(e)}insertAttachment(t){return this.insertAttachments([t])}insertAttachments(t){let e=new Q;return Array.from(t).forEach((n=>{var r;let o=n.getType(),s=(r=Ri[o])===null||r===void 0?void 0:r.presentation,l=this.getCurrentTextAttributes();s&&(l.presentation=s);let c=Q.textForAttachmentWithAttributes(n,l);e=e.appendText(c)})),this.insertText(e)}shouldManageDeletingInDirection(t){let e=this.getLocationRange();if(mt(e)){if(t==="backward"&&e[0].offset===0||this.shouldManageMovingCursorInDirection(t))return!0}else if(e[0].index!==e[1].index)return!0;return!1}deleteInDirection(t){let e,n,r,{length:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=this.getLocationRange(),l=this.getSelectedRange(),c=mt(l);if(c?n=t==="backward"&&s[0].offset===0:r=s[0].index!==s[1].index,n&&this.canDecreaseBlockAttributeLevel()){let u=this.getBlock();if(u.isListItem()?this.decreaseListLevel():this.decreaseBlockAttributeLevel(),this.setSelection(l[0]),u.isEmpty())return!1}return c&&(l=this.getExpandedRangeInDirection(t,{length:o}),t==="backward"&&(e=this.getAttachmentAtRange(l))),e?(this.editAttachment(e),!1):(this.setDocument(this.document.removeTextAtRange(l)),this.setSelection(l[0]),!n&&!r&&void 0)}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(" ")}selectPlaceholder(){if(this.placeholderPosition!=null)return this.setSelectedRange([this.placeholderPosition,this.placeholderPosition+1]),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 O(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 O(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=O(o.getLastAttribute()))===null||r===void 0?void 0:r.htmlAttributes;if(o&&s!=null&&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)return this.setDocument(this.document.addAttributeAtRange(t,e,n));if(t==="href"){let s=Q.textForStringWithAttributes(e,{href:e});return this.insertText(s)}}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 O(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=O(e.getLastNestableAttribute()))===null||t===void 0||!t.listAttribute)return e.getNestingLevel()>0;{let n=this.getPreviousBlock();if(n)return(function(){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return _t((arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).slice(0,r.length),r)})(n.getListItemAttributes(),e.getListItemAttributes())}}}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(ui()).forEach((n=>{e[n]||this.canSetCurrentAttribute(n)||(e[n]=!1)})),!le(e,this.currentAttributes))return this.currentAttributes=e,this.notifyDelegateOfCurrentAttributesChange()}}getCurrentAttributes(){return Vr.call({},this.currentAttributes)}getCurrentTextAttributes(){let t={};for(let e in this.currentAttributes){let n=this.currentAttributes[e];n!==!1&&hi(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)||x({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),x([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=!Qe(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}=(function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],s=[],l=[],c=new Set;r.forEach((g=>{c.add(g)}));let u=new Set;return o.forEach((g=>{u.add(g),c.has(g)||s.push(g)})),r.forEach((g=>{u.has(g)||l.push(g)})),{added:s,removed:l}})(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 $([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("\uFFFC",` `))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)}};ut.proxyMethod("getSelectionManager().getPointRange"),ut.proxyMethod("getSelectionManager().setLocationRangeFromPointRange"),ut.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange"),ut.proxyMethod("getSelectionManager().locationIsCursorTarget"),ut.proxyMethod("getSelectionManager().selectionIsExpanded"),ut.proxyMethod("delegate?.getSelectionManager");var Le=class extends w{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||!qs(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()}}},qs=(i,t,e)=>i?.description===t?.toString()&&i?.context===JSON.stringify(e),Xn="attachmentGallery",ln=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(Xn,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]0&&arguments[0]!==void 0?arguments[0]:"",e=Wt.parse(t,{referenceElement:this.element}).getDocument();return this.loadDocument(e)}loadJSON(t){let{document:e,selectedRange:n}=t;return e=$.fromJSON(e),this.loadSnapshot({document:e,selectedRange:n})}loadSnapshot(t){return this.undoManager=new Le(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];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()}},un=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=Pn(l));let c=Xe(this.element,{usingFilter:ao});for(;c.nextNode();){let u=c.currentNode;if(u===t&&Se(t)){Xt(u)||(s.offset+=e);break}if(u.parentNode===t){if(r++===e){!n&&Mn(u,{strict:n})&&(o&&s.index++,s.offset=0,o=!0);break}}else if(!Nt(t,u)&&r>0)break;Mn(u,{strict:n})?(o&&s.index++,s.offset=0,o=!0):s.offset+=Qn(u)}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,Bn(e)){n=1;break}return[e,n]}let[r,o]=this.findNodeAndOffsetFromLocation(t);if(r){if(Se(r))Qn(r)===0?(e=r.parentNode.parentNode,n=Pn(r.parentNode),Xt(r,{name:"right"})&&n++):(e=r,n=t.offset-o);else{if(e=r.parentNode,!Mn(r.previousSibling)&&!Bn(e))for(;r===e.lastChild&&(r=e,e=e.parentNode,!Bn(e)););n=Pn(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=Qn(o);if(t.offset<=r+s)if(Se(o)){if(e=o,n=r,t.offset===n&&Xt(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(Ot(t))return t;t=t.parentNode}}getSignificantNodesForIndex(t){let e=[],n=Xe(this.element,{usingFilter:Ks}),r=!1;for(;n.nextNode();){let s=n.currentNode;var o;if(Yt(s)){if(o!=null?o++:o=0,o===t)r=!0;else if(r)break}else r&&e.push(s)}return e}},Qn=function(i){return i.nodeType===Node.TEXT_NODE?Xt(i)?0:i.textContent.length:q(i)==="br"||Ot(i)?1:0},Ks=function(i){return Gs(i)===NodeFilter.FILTER_ACCEPT?ao(i):NodeFilter.FILTER_REJECT},Gs=function(i){return qr(i)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},ao=function(i){return Ot(i.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},hn=class{createDOMRangeFromPoint(t){let e,{x:n,y:r}=t;if(document.caretPositionFromPoint){let{offsetNode:o,offset:s}=document.caretPositionFromPoint(n,r);return e=document.createRange(),e.setStart(o,s),e}if(document.caretRangeFromPoint)return document.caretRangeFromPoint(n,r);if(document.body.createTextRange){let o=Re();try{let s=document.body.createTextRange();s.moveToPoint(n,r),s.select()}catch{}return e=Re(),Qr(o),e}}getClientRectsForDOMRange(t){let e=Array.from(t.getClientRects());return[e[0],e[e.length-1]]}},gt=class extends w{constructor(t){super(...arguments),this.didMouseDown=this.didMouseDown.bind(this),this.selectionDidChange=this.selectionDidChange.bind(this),this.element=t,this.locationMapper=new un(this.element),this.pointMapper=new hn,this.lockCount=0,R("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(Re()):t.ignoreLock?this.currentLocationRange:this.lockedLocationRange?this.lockedLocationRange:this.currentLocationRange}setLocationRange(t){if(this.lockedLocationRange)return;t=x(t);let e=this.createDOMRangeFromLocationRange(t);e&&(Qr(e),this.updateCurrentLocationRange(t))}setLocationRangeFromPointRange(t){t=x(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 Xt(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=Xr())===null||t===void 0?void 0:t.removeAllRanges()}selectionIsCollapsed(){var t;return((t=Re())===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 x([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()})),Nt(document,this.element))return this.selectionDidChange()},n=setTimeout(e,200);t=["mousemove","keydown"].map((r=>R(r,{onElement:document,withCallback:e})))}selectionDidChange(){if(!this.paused&&!Ti(this.element))return this.updateCurrentLocationRange()}updateCurrentLocationRange(t){var e,n;if((t??(t=this.createLocationRangeFromDOMRange(Re())))&&!Qe(t,this.currentLocationRange))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=mt(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);var n;if(e)return(n=this.createLocationRangeFromDOMRange(e))===null||n===void 0?void 0:n[0]}domRangeWithinElement(t){return t.collapsed?Nt(this.element,t.startContainer):Nt(this.element,t.startContainer)&&Nt(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 lo=Object.freeze({__proto__:null,Attachment:ie,AttachmentManager:sn,AttachmentPiece:re,Block:Ct,Composition:ut,Document:$,Editor:cn,HTMLParser:Wt,HTMLSanitizer:ee,LineBreakInsertion:an,LocationMapper:un,ManagedAttachment:E,Piece:bt,PointMapper:hn,SelectionManager:gt,SplittableList:oe,StringPiece:De,Text:Q,UndoManager:Le}),$s=Object.freeze({__proto__:null,ObjectView:ft,AttachmentView:we,BlockView:rn,DocumentView:ne,PieceView:en,PreviewableAttachmentView:tn,TextView:nn}),{lang:Zn,css:Lt,keyNames:Ys}=Ie,ti=function(i){return function(){let t=i.apply(this,arguments);t.do(),this.undos||(this.undos=[]),this.undos.push(t.undo)}},dn=class extends w{constructor(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(...arguments),U(this,"makeElementMutable",ti((()=>({do:()=>{this.element.dataset.trixMutable=!0},undo:()=>delete this.element.dataset.trixMutable})))),U(this,"addToolbar",ti((()=>{let o=b({tagName:"div",className:Lt.attachmentToolbar,data:{trixMutable:!0},childNodes:b({tagName:"div",className:"trix-button-row",childNodes:b({tagName:"span",className:"trix-button-group trix-button-group--actions",childNodes:b({tagName:"button",className:"trix-button trix-button--remove",textContent:Zn.remove,attributes:{title:Zn.remove},data:{trixAction:"remove"}})})})});return this.attachment.isPreviewable()&&o.appendChild(b({tagName:"div",className:Lt.attachmentMetadataContainer,childNodes:b({tagName:"span",className:Lt.attachmentMetadata,childNodes:[b({tagName:"span",className:Lt.attachmentName,textContent:this.attachment.getFilename(),attributes:{title:this.attachment.getFilename()}}),b({tagName:"span",className:Lt.attachmentSize,textContent:this.attachment.getFormattedFilesize()})]})})),R("click",{onElement:o,withCallback:this.didClickToolbar}),R("click",{onElement:o,matchingSelector:"[data-trix-action]",withCallback:this.didClickActionButton}),Ce("trix-attachment-before-toolbar",{onElement:this.element,attributes:{toolbar:o,attachment:this.attachment}}),{do:()=>this.element.appendChild(o),undo:()=>St(o)}}))),U(this,"installCaptionEditor",ti((()=>{let o=b({tagName:"textarea",className:Lt.attachmentCaptionEditor,attributes:{placeholder:Zn.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"};R("input",{onElement:o,withCallback:l}),R("input",{onElement:o,withCallback:this.didInputCaption}),R("keydown",{onElement:o,withCallback:this.didKeyDownCaption}),R("change",{onElement:o,withCallback:this.didChangeCaption}),R("blur",{onElement:o,withCallback:this.didBlurCaption});let c=this.element.querySelector("figcaption"),u=c.cloneNode();return{do:()=>{if(c.style.display="none",u.appendChild(o),u.appendChild(s),u.classList.add("".concat(Lt.attachmentCaption,"--editing")),c.parentElement.insertBefore(u,c),l(),this.options.editCaption)return Li((()=>o.focus()))},undo(){St(u),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,q(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;var t,e,n,r;this.pendingCaption=null,o?(t=this.delegate)===null||t===void 0||(e=t.attachmentEditorDidRequestUpdatingAttributesForAttachment)===null||e===void 0||e.call(t,{caption:o},this.attachment):(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;if(t.target.getAttribute("data-trix-action")==="remove")return(e=this.delegate)===null||e===void 0?void 0:e.attachmentEditorDidRequestRemovalOfAttachment(this.attachment)}didKeyDownCaption(t){var e,n;if(Ys[t.keyCode]==="return")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()}},gn=class extends w{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 ne(this.composition.document,{element:this.element}),R("focus",{onElement:this.element,withCallback:this.didFocus}),R("blur",{onElement:this.element,withCallback:this.didBlur}),R("click",{onElement:this.element,matchingSelector:"a[contenteditable=false]",preventDefault:!0}),R("mousedown",{onElement:this.element,matchingSelector:It,withCallback:this.didClickAttachment}),R("click",{onElement:this.element,matchingSelector:"a".concat(It),preventDefault:!0})}didFocus(t){var e;let n=()=>{var r,o;if(!this.focused)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=>Li((()=>{var n,r;return Ti(this.element)||(this.focused=null,(n=this.delegate)===null||n===void 0||(r=n.compositionControllerDidBlur)===null||r===void 0||r.call(n)),this.blurPromise=null,e()}))))}didClickAttachment(t,e){var n,r;let o=this.findAttachmentForElement(e),s=!!Et(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,n,r,o,s;return this.revision!==this.composition.revision&&(this.documentView.setDocument(this.composition.document),this.documentView.render(),this.revision=this.composition.revision),this.canSyncDocumentView()&&!this.documentView.isSynced()&&((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)),(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 dn(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))}},mn=class extends w{},co="data-trix-mutable",Xs="[".concat(co,"]"),Qs={attributes:!0,childList:!0,characterData:!0,characterDataOldValue:!0,subtree:!0},pn=class extends w{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,Qs)}stop(){return this.observer.disconnect()}didMutate(t){var e,n;if(this.mutations.push(...Array.from(this.findSignificantMutations(t)||[])),this.mutations.length)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)&&!qr(t)}nodeIsMutable(t){return Et(t,{matchingSelector:Xs})}nodesModifiedByMutation(t){let e=[];switch(t.type){case"attributes":t.attributeName!==co&&e.push(t.target);break;case"characterData":e.push(t.target.parentNode),e.push(t.target);break;case"childList":e.push(...Array.from(t.addedNodes||[])),e.push(...Array.from(t.removedNodes||[]))}return e}getMutationSummary(){return this.getTextMutationSummary()}getTextMutationSummary(){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((l=>{n.push(...Array.from(l.addedNodes||[])),r.push(...Array.from(l.removedNodes||[]))})),n.length===0&&r.length===1&&Yt(r[0])?(t=[],e=[` `]):(t=Ai(n),e=Ai(r));let o=t.filter(((l,c)=>l!==e[c])).map(ye),s=e.filter(((l,c)=>l!==t[c])).map(ye);return{additions:o,deletions:s}}getTextChangesFromCharacterData(){let t,e,n=this.getMutationsByType("characterData");if(n.length){let r=n[0],o=n[n.length-1],s=(function(l,c){let u,g;return l=Mt.box(l),(c=Mt.box(c)).length0&&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:q(e)==="br"?t.push(` `):t.push(...Array.from(Ai(e.childNodes)||[]))}return t},fn=class extends Zt{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)}},yi=class{constructor(t){this.element=t}shouldIgnore(t){return!!Ne.samsungAndroid&&(this.previousEvent=this.event,this.event=t,this.checkSamsungKeyboardBuggyModeStart(),this.checkSamsungKeyboardBuggyModeEnd(),this.buggyMode)}checkSamsungKeyboardBuggyModeStart(){this.insertingLongTextAfterUnidentifiedChar()&&Zs(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"}},Zs=(i,t)=>Pr(i)===Pr(t),ta=new RegExp("(".concat("\uFFFC","|").concat(An,"|").concat(xt,"|\\s)+"),"g"),Pr=i=>i.replace(ta," ").trim(),se=class extends w{constructor(t){super(...arguments),this.element=t,this.mutationObserver=new pn(this.element),this.mutationObserver.delegate=this,this.flakyKeyboardDetector=new yi(this.element);for(let e in this.constructor.events)R(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 fn(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(!Ti(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}},ei;U(se,"events",{});var{browser:ea,keyNames:uo}=Ie,na=0,it=class extends se{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(),jt.reset()}elementDidMutate(t){var e,n;return this.isComposing()?(e=this.delegate)===null||e===void 0||(n=e.inputControllerDidAllowUnhandledInput)===null||n===void 0?void 0:n.call(e):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 u=this.getSelectedRange();if(u){var c;let g=s?e.replace(/\n$/,"").length||-1:e?.length||1;if((c=this.responder)!==null&&c!==void 0&&c.positionIsBlockBreak(u[1]+g))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 ct(this)}isComposing(){return this.compositionInput&&!this.compositionInput.isEnded()}deleteInDirection(t,e){var n;return((n=this.responder)===null||n===void 0?void 0:n.deleteInDirection(t))!==!1?this.setInputSummary({didDelete:!0}):e?(e.preventDefault(),this.requestRender()):void 0}serializeSelectionToDataTransfer(t){var e;if(!(function(r){if(r==null||!r.setData)return!1;for(let o in ar){let s=ar[o];try{if(r.setData(o,s),!r.getData(o)===s)return!1}catch{return!1}}return!0})(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",ne.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=b({style:n,tagName:"div",editable:!0});return document.body.appendChild(r),r.focus(),requestAnimationFrame((()=>{let o=r.innerHTML;return St(r),this.setSelectedRange(e),t(o)}))}};U(it,"events",{keydown(i){this.isComposing()||this.resetInputSummary(),this.inputSummary.didInput=!0;let t=uo[i.keyCode];if(t){var e;let r=this.keys;["ctrl","alt","shift","meta"].forEach((o=>{var s;i["".concat(o,"Key")]&&(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}),jt.reset(),r[t].call(this,i))}if($r(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=oa(i);var e,n;return t?((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()})):void 0},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};var t,e;if(!le(n,this.draggingPoint))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 u=$.fromJSONString(r);(c=this.responder)===null||c===void 0||c.insertDocument(u),this.requestRender()}this.draggedRange=null,this.draggingPoint=null},cut(i){var t,e;if((t=this.responder)!==null&&t!==void 0&&t.selectionIsExpanded()&&(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))return void this.getPastedHTMLUsingHiddenElement((j=>{var k,ht,kt;return e.type="text/html",e.html=j,(k=this.delegate)===null||k===void 0||k.inputControllerWillPaste(e),(ht=this.responder)===null||ht===void 0||ht.insertHTML(e.html),this.requestRender(),(kt=this.delegate)===null||kt===void 0?void 0:kt.inputControllerDidPaste(e)}));let n=t.getData("URL"),r=t.getData("text/html"),o=t.getData("public.url-name");if(n){var s,l,c;let j;e.type="text/html",j=o?Ii(o).trim():n,e.html=this.createLinkHTML(n,j),(s=this.delegate)===null||s===void 0||s.inputControllerWillPaste(e),this.setInputSummary({textAdded:j,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(Gr(t)){var u,g,S;e.type="text/plain",e.string=t.getData("text/plain"),(u=this.delegate)===null||u===void 0||u.inputControllerWillPaste(e),this.setInputSummary({textAdded:e.string,didDelete:this.selectionIsExpanded()}),(g=this.responder)===null||g===void 0||g.insertString(e.string),this.requestRender(),(S=this.delegate)===null||S===void 0||S.inputControllerDidPaste(e)}else if(r){var D,Y,st;e.type="text/html",e.html=r,(D=this.delegate)===null||D===void 0||D.inputControllerWillPaste(e),(Y=this.responder)===null||Y===void 0||Y.insertHTML(e.html),this.requestRender(),(st=this.delegate)===null||st===void 0||st.inputControllerDidPaste(e)}else if(Array.from(t.types).includes("Files")){var V,vt;let j=(V=t.items)===null||V===void 0||(V=V[0])===null||V===void 0||(vt=V.getAsFile)===null||vt===void 0?void 0:vt.call(V);if(j){var Rt,ce,ue;let k=ia(j);!j.name&&k&&(j.name="pasted-file-".concat(++na,".").concat(k)),e.type="File",e.file=j,(Rt=this.delegate)===null||Rt===void 0||Rt.inputControllerWillAttachFiles(),(ce=this.responder)===null||ce===void 0||ce.insertFile(e.file),this.requestRender(),(ue=this.delegate)===null||ue===void 0||ue.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()}}),U(it,"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,e;(t=this.responder)!==null&&t!==void 0&&t.canIncreaseNestingLevel()&&((e=this.responder)===null||e===void 0||e.increaseNestingLevel(),this.requestRender(),i.preventDefault())},left(i){var t;if(this.selectionIsInCursorTarget())return i.preventDefault(),(t=this.responder)===null||t===void 0?void 0:t.moveCursorInDirection("backward")},right(i){var t;if(this.selectionIsInCursorTarget())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,e;(t=this.responder)!==null&&t!==void 0&&t.canDecreaseNestingLevel()&&((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()}}}),it.proxyMethod("responder?.getSelectedRange"),it.proxyMethod("responder?.setSelectedRange"),it.proxyMethod("responder?.expandSelectionInDirection"),it.proxyMethod("responder?.selectionIsInCursorTarget"),it.proxyMethod("responder?.selectionIsExpanded");var ia=i=>{var t;return(t=i.type)===null||t===void 0||(t=t.match(/\/(\w+)$/))===null||t===void 0?void 0:t[1]},ra=!((ei=" ".codePointAt)===null||ei===void 0||!ei.call(" ",0)),oa=function(i){if(i.key&&ra&&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&&uo[t]!=="escape")return Mt.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}{let e=t.types.includes("com.apple.webarchive"),n=t.types.includes("com.apple.flat-rtfd");return e||n}}},ct=class extends w{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,n;this.inputSummary.eventName==="keypress"&&this.inputSummary.textAdded&&((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){return this.data.end=t,this.isSignificant()?(this.forgetPlaceholder(),this.canApplyToDocument()?(this.setInputSummary({preferDocument:!0,didInput:!1}),(e=this.delegate)===null||e===void 0||e.inputControllerWillPerformTyping(),(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)):this.data.start!=null||this.data.update!=null?(this.requestReparse(),this.inputController.reset()):void 0):this.inputController.reset();var e,n,r,o}getEndData(){return this.data.end}isEnded(){return this.getEndData()!=null}isSignificant(){return!ea.composesExistingText||this.inputSummary.didInput}canApplyToDocument(){var t,e;return((t=this.data.start)===null||t===void 0?void 0:t.length)===0&&((e=this.data.end)===null||e===void 0?void 0:e.length)>0&&this.range}};ct.proxyMethod("inputController.setInputSummary"),ct.proxyMethod("inputController.requestRender"),ct.proxyMethod("inputController.requestReparse"),ct.proxyMethod("responder?.selectionIsExpanded"),ct.proxyMethod("responder?.insertPlaceholder"),ct.proxyMethod("responder?.selectPlaceholder"),ct.proxyMethod("responder?.forgetPlaceholder");var Ft=class extends se{constructor(){super(...arguments),this.render=this.render.bind(this)}elementDidMutate(){return this.scheduledRender?this.composing?(t=this.delegate)===null||t===void 0||(e=t.inputControllerDidAllowUnhandledInput)===null||e===void 0?void 0:e.call(t):void 0:this.reparse();var t,e}scheduleRender(){return this.scheduledRender?this.scheduledRender:this.scheduledRender=requestAnimationFrame(this.render)}render(){var t,e;cancelAnimationFrame(this.scheduledRender),this.scheduledRender=null,this.composing||(e=this.delegate)===null||e===void 0||e.render(),(t=this.afterRender)===null||t===void 0||t.call(this),this.afterRender=null}reparse(){var t;return(t=this.delegate)===null||t===void 0?void 0:t.reparse()}insertString(){var t;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",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){var e;if(ui().includes(t))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){var n;if(ui().includes(t))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};var n;e&&((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){var n;return typeof t=="function"&&(e=t,t=this.getTargetDOMRange()),t?(n=this.responder)===null||n===void 0?void 0:n.withTargetDOMRange(t,e.bind(this)):(jt.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=aa(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}};U(Ft,"events",{keydown(i){if($r(i)){var t;let e=ua(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");return ho(i)?(i.preventDefault(),this.attachFiles(i.clipboardData.files)):ca(i)?(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)):n?(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(),(u=this.delegate)===null||u===void 0?void 0:u.inputControllerDidPaste(e)):void 0;var r,o,s,l,c,u},beforeinput(i){let t=this.constructor.inputTypes[i.inputType],e=(n=i,!(!/iPhone|iPad/.test(navigator.userAgent)||n.inputType&&n.inputType!=="insertParagraph"));var n;t&&(this.withEvent(i,t),e||this.scheduleRender()),e&&this.render()},input(i){jt.reset()},dragstart(i){var t,e;(t=this.responder)!==null&&t!==void 0&&t.selectionContainsAttachments()&&(i.dataTransfer.setData("application/x-trix-dragging",!0),this.dragging={range:(e=this.responder)===null||e===void 0?void 0:e.getSelectedRange(),point:ii(i)})},dragenter(i){ni(i)&&i.preventDefault()},dragover(i){if(this.dragging){i.preventDefault();let e=ii(i);var t;if(!le(e,this.dragging.point))return this.dragging.point=e,(t=this.responder)===null||t===void 0?void 0:t.setLocationRangeFromPointRange(e)}else ni(i)&&i.preventDefault()},drop(i){var t,e;if(this.dragging)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();if(ni(i)){var n;i.preventDefault();let r=ii(i);return(n=this.responder)===null||n===void 0||n.setLocationRangeFromPointRange(r),this.attachFiles(i.dataTransfer.files)}},dragend(){var i;this.dragging&&((i=this.responder)===null||i===void 0||i.setSelectedRange(this.dragging.range),this.dragging=null)},compositionend(i){this.composing&&(this.composing=!1,Ne.recentAndroid||this.scheduleRender())}}),U(Ft,"keys",{ArrowLeft(){var i,t;if((i=this.responder)!==null&&i!==void 0&&i.shouldManageMovingCursorInDirection("backward"))return this.event.preventDefault(),(t=this.responder)===null||t===void 0?void 0:t.moveCursorInDirection("backward")},ArrowRight(){var i,t;if((i=this.responder)!==null&&i!==void 0&&i.shouldManageMovingCursorInDirection("forward"))return this.event.preventDefault(),(t=this.responder)===null||t===void 0?void 0:t.moveCursorInDirection("forward")},Backspace(){var i,t,e;if((i=this.responder)!==null&&i!==void 0&&i.shouldManageDeletingInDirection("backward"))return this.event.preventDefault(),(t=this.delegate)===null||t===void 0||t.inputControllerWillPerformTyping(),(e=this.responder)===null||e===void 0||e.deleteInDirection("backward"),this.render()},Tab(){var i,t;if((i=this.responder)!==null&&i!==void 0&&i.canIncreaseNestingLevel())return this.event.preventDefault(),(t=this.responder)===null||t===void 0||t.increaseNestingLevel(),this.render()},"Tab+Shift"(){var i,t;if((i=this.responder)!==null&&i!==void 0&&i.canDecreaseNestingLevel())return this.event.preventDefault(),(t=this.responder)===null||t===void 0||t.decreaseNestingLevel(),this.render()}}),U(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;var t;if(i)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 u=i.getData("public.url-name");c=u?Ii(u).trim():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(Gr(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(la(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 aa=function(i){let t=document.createRange();return t.setStart(i.startContainer,i.startOffset),t.setEnd(i.endContainer,i.endOffset),t},ni=i=>{var t;return Array.from(((t=i.dataTransfer)===null||t===void 0?void 0:t.types)||[]).includes("Files")},la=i=>{var t;return((t=i.dataTransfer.files)===null||t===void 0?void 0:t[0])&&!ho(i)&&!(e=>{let{dataTransfer:n}=e;return n.types.includes("Files")&&n.types.includes("text/html")&&n.getData("text/html").includes("urn:schemas-microsoft-com:office:office")})(i)},ho=function(i){let t=i.clipboardData;if(t)return Array.from(t.types).filter((e=>e.match(/file/i))).length===t.types.length&&t.files.length>=1},ca=function(i){let t=i.clipboardData;if(t)return t.types.includes("text/plain")&&t.types.length===1},ua=function(i){let t=[];return i.altKey&&t.push("alt"),i.shiftKey&&t.push("shift"),t.push(i.key),t},ii=i=>({x:i.clientX,y:i.clientY}),xi="[data-trix-attribute]",Ci="[data-trix-action]",ha="".concat(xi,", ").concat(Ci),yn="[data-trix-dialog]",da="".concat(yn,"[data-trix-active]"),ga="".concat(yn," [data-trix-method]"),Br="".concat(yn," [data-trix-input]"),Mr=(i,t)=>(t||(t=$t(i)),i.querySelector("[data-trix-input][name='".concat(t,"']"))),_r=i=>i.getAttribute("data-trix-action"),$t=i=>i.getAttribute("data-trix-attribute")||i.getAttribute("data-trix-dialog-attribute"),bn=class extends w{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(),R("mousedown",{onElement:this.element,matchingSelector:Ci,withCallback:this.didClickActionButton}),R("mousedown",{onElement:this.element,matchingSelector:xi,withCallback:this.didClickAttributeButton}),R("click",{onElement:this.element,matchingSelector:ha,preventDefault:!0}),R("click",{onElement:this.element,matchingSelector:ga,withCallback:this.didClickDialogButton}),R("keydown",{onElement:this.element,matchingSelector:Br,withCallback:this.didKeyDownDialogInput})}didClickActionButton(t,e){var n;(n=this.delegate)===null||n===void 0||n.toolbarDidClickButton(),t.preventDefault();let r=_r(e);return this.getDialog(r)?this.toggleDialog(r):(o=this.delegate)===null||o===void 0?void 0:o.toolbarDidInvokeAction(r,e);var o}didClickAttributeButton(t,e){var n;(n=this.delegate)===null||n===void 0||n.toolbarDidClickButton(),t.preventDefault();let r=$t(e);var o;return this.getDialog(r)?this.toggleDialog(r):(o=this.delegate)===null||o===void 0||o.toolbarDidToggleAttribute(r),this.refreshAttributeButtons()}didClickDialogButton(t,e){let n=Et(e,{matchingSelector:yn});return this[e.getAttribute("data-trix-method")].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(Ci)).map((e=>t(e,_r(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(xi)).map((e=>t(e,$t(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 Ce("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=$t(r);if(o){let s=Mr(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=$t(t),r=Mr(t,n);return!r.willValidate||(r.setCustomValidity(""),r.checkValidity()&&this.isSafeAttribute(r))?((e=this.delegate)===null||e===void 0||e.toolbarDidUpdateAttribute(n,r.value),this.hideDialog()):(r.setCustomValidity("Invalid value"),r.setAttribute("data-trix-validate",""),r.classList.add("trix-validate"),r.focus())}isSafeAttribute(t){return!t.hasAttribute("data-trix-validate-href")||te.isValidAttribute("a","href",t.value)}removeAttribute(t){var e;let n=$t(t);return(e=this.delegate)===null||e===void 0||e.toolbarDidRemoveAttribute(n),this.hideDialog()}hideDialog(){let t=this.element.querySelector(da);var e;if(t)return t.removeAttribute("data-trix-active"),t.classList.remove("trix-active"),this.resetDialogInputs(),(e=this.delegate)===null||e===void 0?void 0:e.toolbarDidHideDialog((n=>n.getAttribute("data-trix-dialog"))(t))}resetDialogInputs(){Array.from(this.element.querySelectorAll(Br)).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,"]"))}},Pt=class extends mn{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 ut,this.composition.delegate=this,this.attachmentManager=new sn(this.composition.getAttachments()),this.attachmentManager.delegate=this,this.inputController=wi.getLevel()===2?new Ft(this.editorElement):new it(this.editorElement),this.inputController.delegate=this,this.inputController.responder=this.composition,this.compositionController=new gn(this.editorElement,this.composition),this.compositionController.delegate=this,this.toolbarController=new bn(this.editorElement.toolbarElement),this.toolbarController.delegate=this,this.editor=new cn(this.composition,this.selectionManager,this.editorElement),n?this.editor.loadDocument(n):this.editor.loadHTML(r)}registerSelectionManager(){return jt.registerSelectionManager(this.selectionManager)}unregisterSelectionManager(){return jt.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())return this.requestedLocationRange=t,this.compositionRevisionWhenLocationRangeRequested=this.composition.revision,this.handlingInput?void 0:this.render()}compositionWillLoadSnapshot(){this.loadingSnapshot=!0}compositionDidLoadSnapshot(){this.compositionController.refreshViewCache(),this.render(),this.loadingSnapshot=!1}getSelectionManager(){return this.selectionManager}attachmentManagerDidRequestRemovalOfAttachment(t){return this.removeAttachment(t)}compositionControllerWillSyncDocumentView(){return this.inputController.editorWillSyncDocumentView(),this.selectionManager.lock(),this.selectionManager.clearSelection()}compositionControllerDidSyncDocumentView(){return this.inputController.editorDidSyncDocumentView(),this.selectionManager.unlock(),this.updateCurrentActions(),this.notifyEditorElement("sync")}compositionControllerDidRender(){this.requestedLocationRange&&(this.compositionRevisionWhenLocationRangeRequested===this.composition.revision&&this.selectionManager.setLocationRange(this.requestedLocationRange),this.requestedLocationRange=null,this.compositionRevisionWhenLocationRangeRequested=null),this.renderedCompositionRevision!==this.composition.revision&&(this.runEditorFilters(),this.composition.updateCurrentAttributes(),this.notifyEditorElement("render")),this.renderedCompositionRevision=this.composition.revision}compositionControllerDidFocus(){return this.isFocusedInvisibly()&&this.setLocationRange({index:0,offset:0}),this.toolbarController.hideDialog(),this.notifyEditorElement("focus")}compositionControllerDidBlur(){return this.notifyEditorElement("blur")}compositionControllerDidSelectAttachment(t,e){return this.toolbarController.hideDialog(),this.composition.editAttachment(t,e)}compositionControllerDidRequestDeselectingAttachment(t){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&&!Qe(this.attachmentLocationRange,t)&&this.composition.stopEditingAttachment(),this.notifyEditorElement("selection-change")}toolbarDidClickButton(){if(!this.getLocationRange())return this.setLocationRange({index:0,offset:0})}toolbarDidInvokeAction(t,e){return this.invokeAction(t,e)}toolbarDidToggleAttribute(t){if(this.recordFormattingUndoEntry(t),this.composition.toggleCurrentAttribute(t),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarDidUpdateAttribute(t,e){if(this.recordFormattingUndoEntry(t),this.composition.setCurrentAttribute(t,e),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarDidRemoveAttribute(t){if(this.recordFormattingUndoEntry(t),this.composition.removeCurrentAttribute(t),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarWillShowDialog(t){return this.composition.expandSelectionForEditing(),this.freezeSelection()}toolbarDidShowDialog(t){return this.notifyEditorElement("toolbar-dialog-show",{dialogName:t})}toolbarDidHideDialog(t){return this.thawSelection(),this.editorElement.focus(),this.notifyEditorElement("toolbar-dialog-hide",{dialogName:t})}freezeSelection(){if(!this.selectionFrozen)return this.selectionManager.lock(),this.composition.freezeSelection(),this.selectionFrozen=!0,this.render()}thawSelection(){if(this.selectionFrozen)return this.composition.thawSelection(),this.selectionManager.unlock(),this.selectionFrozen=!1,this.render()}canInvokeAction(t){return!!this.actionIsExternal(t)||!((e=this.actions[t])===null||e===void 0||(e=e.test)===null||e===void 0||!e.call(this));var e}invokeAction(t,e){return this.actionIsExternal(t)?this.notifyEditorElement("action-invoke",{actionName:t,invokingElement:e}):(n=this.actions[t])===null||n===void 0||(n=n.perform)===null||n===void 0?void 0:n.call(this);var n}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(!le(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((r=>{let{document:o,selectedRange:s}=t;t=r.call(this.editor,t)||{},t.document||(t.document=o),t.selectedRange||(t.selectedRange=s)})),e=t,n=this.composition.getSnapshot(),!Qe(e.selectedRange,n.selectedRange)||!e.document.isEqualTo(n.document))return this.composition.loadSnapshot(t);var e,n}updateInputElement(){let t=(function(e,n){let r=zs[n];if(r)return r(e);throw new Error("unknown content type: ".concat(n))})(this.compositionController.getSerializableElement(),"text/html");return this.editorElement.setFormValue(t)}notifyEditorElement(t,e){switch(t){case"document-change":this.documentChangedSinceLastRender=!0;break;case"render":this.documentChangedSinceLastRender&&(this.documentChangedSinceLastRender=!1,this.notifyEditorElement("change"));break;case"change":case"attachment-add":case"attachment-edit":case"attachment-remove":this.updateInputElement()}return this.editorElement.notify(t,e)}removeAttachment(t){return this.editor.recordUndoEntry("Delete Attachment"),this.composition.removeAttachment(t),this.render()}recordFormattingUndoEntry(t){let e=O(t),n=this.selectionManager.getLocationRange();if(e||!mt(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;n0?Math.floor(new Date().getTime()/ai.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}};U(Pt,"actions",{undo:{test(){return this.editor.canUndo()},perform(){return this.editor.undo()}},redo:{test(){return this.editor.canRedo()},perform(){return this.editor.redo()}},link:{test(){return this.editor.canActivateAttribute("href")}},increaseNestingLevel:{test(){return this.editor.canIncreaseNestingLevel()},perform(){return this.editor.increaseNestingLevel()&&this.render()}},decreaseNestingLevel:{test(){return this.editor.canDecreaseNestingLevel()},perform(){return this.editor.decreaseNestingLevel()&&this.render()}},attachFiles:{test:()=>!0,perform(){return wi.pickFiles(this.editor.insertFiles)}}}),Pt.proxyMethod("getSelectionManager().setLocationRange"),Pt.proxyMethod("getSelectionManager().getLocationRange");var ma=Object.freeze({__proto__:null,AttachmentEditorController:dn,CompositionController:gn,Controller:mn,EditorController:Pt,InputController:se,Level0InputController:it,Level2InputController:Ft,ToolbarController:bn}),pa=Object.freeze({__proto__:null,MutationObserver:pn,SelectionChangeObserver:Ze}),fa=Object.freeze({__proto__:null,FileVerificationOperation:fn,ImagePreloadOperation:on});Kr("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 vn=class extends HTMLElement{connectedCallback(){this.innerHTML===""&&(this.innerHTML=Jr.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)}return[]}get editorElement(){let[t]=this.editorElements;return t}},ba=0,va=function(i){if(!i.hasAttribute("contenteditable"))return i.toggleAttribute("contenteditable",!i.disabled),(function(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.times=1,R(t,e)})("focus",{onElement:i,withCallback:()=>Aa(i)})},Aa=function(i){return ya(i),xa(i)},ya=function(i){var t,e;if((t=(e=document).queryCommandSupported)!==null&&t!==void 0&&t.call(e,"enableObjectResizing"))return document.execCommand("enableObjectResizing",!1,!1),R("mscontrolselect",{onElement:i,preventDefault:!0})},xa=function(i){var t,e;if((t=(e=document).queryCommandSupported)!==null&&t!==void 0&&t.call(e,"DefaultParagraphSeparator")){let{tagName:n}=J.default;if(["div","p"].includes(n))return document.execCommand("DefaultParagraphSeparator",!1,n)}},jr=Ne.forcesObjectResizing?{display:"inline",width:"auto"}:{display:"inline-block",width:"1px"};Kr("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(It,` figcaption textarea { resize: none; } %t `).concat(It,` figcaption textarea.trix-autoresize-clone { position: absolute; left: -9999px; max-height: 0px; } %t `).concat(It,` figcaption[data-trix-placeholder]:empty::before { content: attr(data-trix-placeholder); color: graytext; } %t [data-trix-cursor-target] { display: `).concat(jr.display,` !important; width: `).concat(jr.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 nt=new WeakMap,Ke=new WeakMap,Ae=new WeakSet,Ei=class{constructor(t){var e,n;io(e=this,n=Ae),n.add(e),U(this,"value",""),Qt(this,nt,{writable:!0,value:void 0}),Qt(this,Ke,{writable:!0,value:void 0}),this.element=t,ke(this,nt,t.attachInternals()),ke(this,Ke,!1)}connectedCallback(){Je(this,Ae,Ge).call(this)}disconnectedCallback(){}get form(){return A(this,nt).form}get name(){return this.element.getAttribute("name")}set name(t){this.element.setAttribute("name",t)}get labels(){return A(this,nt).labels}get disabled(){return A(this,Ke)||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),Je(this,Ae,Ge).call(this)}get validity(){return A(this,nt).validity}get validationMessage(){return A(this,nt).validationMessage}get willValidate(){return A(this,nt).willValidate}formDisabledCallback(t){ke(this,Ke,t)}setFormValue(t){this.value=t,Je(this,Ae,Ge).call(this),A(this,nt).setFormValue(this.element.disabled?void 0:this.value)}checkValidity(){return A(this,nt).checkValidity()}reportValidity(){return A(this,nt).reportValidity()}setCustomValidity(t){Je(this,Ae,Ge).call(this,t)}};function Ge(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",{required:t,value:e}=this.element,n=t&&!e,r=!!i,o=b("input",{required:t}),s=i||o.validationMessage;A(this,nt).setValidity({valueMissing:n,customError:r},s)}var ri=new WeakMap,oi=new WeakMap,si=new WeakMap,Si=class{constructor(t){Qt(this,ri,{writable:!0,value:void 0}),Qt(this,oi,{writable:!0,value:e=>{e.defaultPrevented||e.target===this.element.form&&this.element.reset()}}),Qt(this,si,{writable:!0,value:e=>{if(e.defaultPrevented||this.element.contains(e.target))return;let n=Et(e.target,{matchingSelector:"label"});n&&Array.from(this.labels).includes(n)&&this.element.focus()}}),this.element=t}connectedCallback(){ke(this,ri,(function(t){if(t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby"))return;let e=function(){let n=Array.from(t.labels).map((o=>{if(!o.contains(t))return o.textContent})).filter((o=>o)),r=n.join(" ");return r?t.setAttribute("aria-label",r):t.removeAttribute("aria-label")};return e(),R("focus",{onElement:t,withCallback:e})})(this.element)),window.addEventListener("reset",A(this,oi),!1),window.addEventListener("click",A(this,si),!1)}disconnectedCallback(){var t;(t=A(this,ri))===null||t===void 0||t.destroy(),window.removeEventListener("reset",A(this,oi),!1),window.removeEventListener("click",A(this,si),!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=Et(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.")}},I=new WeakMap,ae=class extends HTMLElement{constructor(){super(),Qt(this,I,{writable:!0,value:void 0}),this.willCreateInput=!0,ke(this,I,this.constructor.formAssociated?new Ei(this):new Si(this))}get trixId(){return this.hasAttribute("trix-id")?this.getAttribute("trix-id"):(this.setAttribute("trix-id",++ba),this.trixId)}get labels(){return A(this,I).labels}get disabled(){let{inputElement:t}=this;return t?t.disabled:A(this,I).disabled}set disabled(t){let{inputElement:e}=this;e&&(e.disabled=t),A(this,I).disabled=t}get required(){return A(this,I).required}set required(t){A(this,I).required=t}get validity(){return A(this,I).validity}get validationMessage(){return A(this,I).validationMessage}get willValidate(){return A(this,I).willValidate}get type(){return this.localName}get toolbarElement(){var t;if(this.hasAttribute("toolbar"))return(t=this.ownerDocument)===null||t===void 0?void 0:t.getElementById(this.getAttribute("toolbar"));if(this.parentNode){let e="trix-toolbar-".concat(this.trixId);return this.setAttribute("toolbar",e),this.internalToolbar=b("trix-toolbar",{id:e}),this.parentNode.insertBefore(this.internalToolbar,this),this.internalToolbar}}get form(){let{inputElement:t}=this;return t?t.form:A(this,I).form}get inputElement(){var t;return this.hasAttribute("input")?(t=this.ownerDocument)===null||t===void 0?void 0:t.getElementById(this.getAttribute("input")):void 0}get editor(){var t;return(t=this.editorController)===null||t===void 0?void 0:t.editor}get name(){let{inputElement:t}=this;return t?t.name:A(this,I).name}set name(t){let{inputElement:e}=this;e?e.name=t:A(this,I).name=t}get value(){let{inputElement:t}=this;return t?t.value:A(this,I).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 Ce("trix-".concat(t),{onElement:this,attributes:e})}setFormValue(t){let{inputElement:e}=this;e&&(e.value=t),A(this,I).setFormValue(t)}connectedCallback(){if(!this.hasAttribute("data-trix-internal")){if(va(this),(function(t){t.hasAttribute("role")||t.setAttribute("role","textbox")})(this),!this.editorController){if(Ce("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=b("input",{type:"hidden",id:t});this.parentNode.insertBefore(e,this.nextElementSibling)}this.editorController=new Pt({editorElement:this,html:this.defaultValue}),requestAnimationFrame((()=>Ce("trix-initialize",{onElement:this})))}this.editorController.registerSelectionManager(),A(this,I).connectedCallback(),this.toggleAttribute("connected",!0),(function(t){!document.querySelector(":focus")&&t.hasAttribute("autofocus")&&document.querySelector("[autofocus]")===t&&t.focus()})(this)}}disconnectedCallback(){var t;(t=this.editorController)===null||t===void 0||t.unregisterSelectionManager(),A(this,I).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 A(this,I).checkValidity()}reportValidity(){return A(this,I).reportValidity()}setCustomValidity(t){A(this,I).setCustomValidity(t)}formDisabledCallback(t){let{inputElement:e}=this;e&&(e.disabled=t),this.toggleAttribute("contenteditable",!t),A(this,I).formDisabledCallback(t)}formResetCallback(){this.reset()}reset(){this.value=this.defaultValue}};U(ae,"formAssociated","ElementInternals"in window),U(ae,"observedAttributes",["connected"]);var ot={VERSION:ko,config:Ie,core:Hs,models:lo,views:$s,controllers:ma,observers:pa,operations:fa,elements:Object.freeze({__proto__:null,TrixEditorElement:ae,TrixToolbarElement:vn}),filters:Object.freeze({__proto__:null,Filter:ln,attachmentGalleryFilter:so})};Object.assign(ot,lo),window.Trix=ot,setTimeout((function(){customElements.get("trix-toolbar")||customElements.define("trix-toolbar",vn),customElements.get("trix-editor")||customElements.define("trix-editor",ae)}),0);ot.config.blockAttributes.default.tagName="p";ot.config.blockAttributes.default.breakOnReturn=!0;ot.config.blockAttributes.heading={tagName:"h2",terminal:!0,breakOnReturn:!0,group:!1};ot.config.blockAttributes.subHeading={tagName:"h3",terminal:!0,breakOnReturn:!0,group:!1};ot.config.textAttributes.underline={style:{textDecoration:"underline"},inheritable:!0,parser:i=>window.getComputedStyle(i).textDecoration.includes("underline")};ot.Block.prototype.breaksOnReturn=function(){let i=this.getLastAttribute();return ot.config.blockAttributes[i||"default"]?.breakOnReturn??!1};ot.LineBreakInsertion.prototype.shouldInsertBlockBreak=function(){return this.block.hasAttributes()&&this.block.isListItem()&&!this.block.isEmpty()?this.startLocation.offset>0:this.shouldBreakFormattedBlock()?!1:this.breaksOnReturn};function Ca({state:i}){return{state:i,init:function(){this.$refs.trixValue.value=this.state,this.$refs.trix.editor?.loadHTML(this.state??""),this.$watch("state",()=>{document.activeElement!==this.$refs.trix&&(this.$refs.trixValue.value=this.state,this.$refs.trix.editor?.loadHTML(this.state??""))})}}}export{Ca as default}; /*! Bundled license information: trix/dist/trix.esm.min.js: (*! @license DOMPurify 3.4.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.2/LICENSE *) */