147 lines
199 KiB
JavaScript
147 lines
199 KiB
JavaScript
var ko="2.1.16";var Rt="[data-trix-attachment]",yi={preview:{presentation:"gallery",caption:{name:!0,size:!0}},file:{caption:{size:!0}}},z={default:{tagName:"div",parse:!1},quote:{tagName:"blockquote",nestable:!0},heading1:{tagName:"h1",terminal:!0,breakOnReturn:!0,group:!1},code:{tagName:"pre",terminal:!0,htmlAttributes:["language"],text:{plaintext:!0}},bulletList:{tagName:"ul",parse:!1},bullet:{tagName:"li",listAttribute:"bulletList",group:!1,nestable:!0,test(i){return $i(i.parentNode)===z[this.listAttribute].tagName}},numberList:{tagName:"ol",parse:!1},number:{tagName:"li",listAttribute:"numberList",group:!1,nestable:!0,test(i){return $i(i.parentNode)===z[this.listAttribute].tagName}},attachmentGallery:{tagName:"div",exclusive:!0,terminal:!0,parse:!1,group:!1}},$i=i=>{var t;return i==null||(t=i.tagName)===null||t===void 0?void 0:t.toLowerCase()},tr=navigator.userAgent.match(/android\s([0-9]+.*Chrome)/i),Ln=tr&&parseInt(tr[1]),Se={composesExistingText:/Android.*Chrome/.test(navigator.userAgent),recentAndroid:Ln&&Ln>12,samsungAndroid:Ln&&navigator.userAgent.match(/Android.*SM-/),forcesObjectResizing:/Trident.*rv:11/.test(navigator.userAgent),supportsInputEvents:typeof InputEvent<"u"&&["data","getTargetRanges","inputType"].every(i=>i in InputEvent.prototype)},Ro={attachment:"attachment",attachmentCaption:"attachment__caption",attachmentCaptionEditor:"attachment__caption-editor",attachmentMetadata:"attachment__metadata",attachmentMetadataContainer:"attachment__metadata-container",attachmentName:"attachment__name",attachmentProgress:"attachment__progress",attachmentSize:"attachment__size",attachmentToolbar:"attachment__toolbar",attachmentGallery:"attachment-gallery"},Nr={ADD_ATTR:["language"],SAFE_FOR_XML:!1,RETURN_DOM:!0},m={attachFiles:"Attach Files",bold:"Bold",bullets:"Bullets",byte:"Byte",bytes:"Bytes",captionPlaceholder:"Add a caption\u2026",code:"Code",heading1:"Heading",indent:"Increase Level",italic:"Italic",link:"Link",numbers:"Numbers",outdent:"Decrease Level",quote:"Quote",redo:"Redo",remove:"Remove",strike:"Strikethrough",undo:"Undo",unlink:"Unlink",url:"URL",urlPlaceholder:"Enter a URL\u2026",GB:"GB",KB:"KB",MB:"MB",PB:"PB",TB:"TB"},Do=[m.bytes,m.KB,m.MB,m.GB,m.TB,m.PB],Br={prefix:"IEC",precision:2,formatter(i){switch(i){case 0:return"0 ".concat(m.bytes);case 1:return"1 ".concat(m.byte);default:let t;this.prefix==="SI"?t=1e3:this.prefix==="IEC"&&(t=1024);let e=Math.floor(Math.log(i)/Math.log(t)),o=(i/Math.pow(t,e)).toFixed(this.precision).replace(/0*$/,"").replace(/\.$/,"");return"".concat(o," ").concat(Do[e])}}},fn="\uFEFF",bt="\xA0",Ai="\uFFFC",_r=function(i){for(let t in i){let e=i[t];this[t]=e}return this},xi=document.documentElement,Lo=xi.matches,C=function(i){let{onElement:t,matchingSelector:e,withCallback:n,inPhase:r,preventDefault:o,times:s}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=t||xi,c=e,d=r==="capturing",g=function(x){s!=null&&--s===0&&g.destroy();let T=vt(x.target,{matchingSelector:c});T!=null&&(n?.call(T,x,T),o&&x.preventDefault())};return g.destroy=()=>l.removeEventListener(i,g,d),l.addEventListener(i,g,d),g},Oo=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t.times=1,C(i,t)},jr=function(i){let{bubbles:t,cancelable:e,attributes:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t=t!==!1,e=e!==!1;let r=document.createEvent("Events");return r.initEvent(i,t,e),n!=null&&_r.call(r,n),r},me=function(i){let{onElement:t,bubbles:e,cancelable:n,attributes:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=t??xi,s=jr(i,{bubbles:e,cancelable:n,attributes:r});return o.dispatchEvent(s)},Wr=function(i,t){if(i?.nodeType===1)return Lo.call(i,t)},vt=function(i){let{matchingSelector:t,untilNode:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};for(;i&&i.nodeType!==Node.ELEMENT_NODE;)i=i.parentNode;if(i!=null)if(t!=null){if(i.closest&&e==null)return i.closest(t);for(;i&&i!==e;){if(Wr(i,t))return i;i=i.parentNode}}else return i},Po=function(i){for(;(t=i)!==null&&t!==void 0&&t.firstElementChild;){var t;i=i.firstElementChild}ret
|
|||
|
|
`},Lt={bold:{tagName:"strong",inheritable:!0,parser(i){let t=window.getComputedStyle(i);return t.fontWeight==="bold"||t.fontWeight>=600}},italic:{tagName:"em",inheritable:!0,parser(i){return window.getComputedStyle(i).fontStyle==="italic"}},href:{groupTagName:"a",parser(i){let t="a:not(".concat(Rt,")"),e=i.closest(t);if(e)return e.getAttribute("href")}},strike:{tagName:"del",inheritable:!0},frozen:{style:{backgroundColor:"highlight"}}},Ur={getDefaultHTML(){return`<div class="trix-button-row">
|
||
|
|
<span class="trix-button-group trix-button-group--text-tools" data-trix-button-group="text-tools">
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-bold" data-trix-attribute="bold" data-trix-key="b" title="`.concat(m.bold,'" tabindex="-1">').concat(m.bold,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-italic" data-trix-attribute="italic" data-trix-key="i" title="`).concat(m.italic,'" tabindex="-1">').concat(m.italic,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-strike" data-trix-attribute="strike" title="`).concat(m.strike,'" tabindex="-1">').concat(m.strike,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-link" data-trix-attribute="href" data-trix-action="link" data-trix-key="k" title="`).concat(m.link,'" tabindex="-1">').concat(m.link,`</button>
|
||
|
|
</span>
|
||
|
|
|
||
|
|
<span class="trix-button-group trix-button-group--block-tools" data-trix-button-group="block-tools">
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-heading-1" data-trix-attribute="heading1" title="`).concat(m.heading1,'" tabindex="-1">').concat(m.heading1,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-quote" data-trix-attribute="quote" title="`).concat(m.quote,'" tabindex="-1">').concat(m.quote,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-code" data-trix-attribute="code" title="`).concat(m.code,'" tabindex="-1">').concat(m.code,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-bullet-list" data-trix-attribute="bullet" title="`).concat(m.bullets,'" tabindex="-1">').concat(m.bullets,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-number-list" data-trix-attribute="number" title="`).concat(m.numbers,'" tabindex="-1">').concat(m.numbers,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-decrease-nesting-level" data-trix-action="decreaseNestingLevel" title="`).concat(m.outdent,'" tabindex="-1">').concat(m.outdent,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-increase-nesting-level" data-trix-action="increaseNestingLevel" title="`).concat(m.indent,'" tabindex="-1">').concat(m.indent,`</button>
|
||
|
|
</span>
|
||
|
|
|
||
|
|
<span class="trix-button-group trix-button-group--file-tools" data-trix-button-group="file-tools">
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-attach" data-trix-action="attachFiles" title="`).concat(m.attachFiles,'" tabindex="-1">').concat(m.attachFiles,`</button>
|
||
|
|
</span>
|
||
|
|
|
||
|
|
<span class="trix-button-group-spacer"></span>
|
||
|
|
|
||
|
|
<span class="trix-button-group trix-button-group--history-tools" data-trix-button-group="history-tools">
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-undo" data-trix-action="undo" data-trix-key="z" title="`).concat(m.undo,'" tabindex="-1">').concat(m.undo,`</button>
|
||
|
|
<button type="button" class="trix-button trix-button--icon trix-button--icon-redo" data-trix-action="redo" data-trix-key="shift+z" title="`).concat(m.redo,'" tabindex="-1">').concat(m.redo,`</button>
|
||
|
|
</span>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="trix-dialogs" data-trix-dialogs>
|
||
|
|
<div class="trix-dialog trix-dialog--link" data-trix-dialog="href" data-trix-dialog-attribute="href">
|
||
|
|
<div class="trix-dialog__link-fields">
|
||
|
|
<input type="url" name="href" class="trix-input trix-input--dialog" placeholder="`).concat(m.urlPlaceholder,'" aria-label="').concat(m.url,`" data-trix-validate-href required data-trix-input>
|
||
|
|
<div class="trix-button-group">
|
||
|
|
<input type="button" class="trix-button trix-button--dialog" value="`).concat(m.link,`" data-trix-method="setAttribute">
|
||
|
|
<input type="button" class="trix-button trix-button--dialog" value="`).concat(m.unlink,`" data-trix-method="removeAttribute">
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>`)}},ii={interval:5e3},Te=Object.freeze({__proto__:null,attachments:yi,blockAttributes:z,browser:Se,css:Ro,dompurify:Nr,fileSize:Br,input:wi,keyNames:Fo,lang:m,parser:ze,textAttributes:Lt,toolbar:Ur,undo:ii}),S=class{static proxyMethod(t){let{name:e,toMethod:n,toProperty:r,optional:o}=No(t);this.prototype[e]=function(){let s,l;if(n)if(o){var c;l=(c=this[n])===null||c===void 0?void 0:c.call(this)}else l=this[n]();else r&&(l=this[r]);if(o){var d;if(s=(d=l)===null||d===void 0?void 0:d[e],s)return nr.call(s,l,arguments)}else return s=l[e],nr.call(s,l,arguments)}}},No=function(i){let t=i.match(Bo);if(!t)throw new Error("can't parse @proxyMethod expression: ".concat(i));let e={name:t[4]};return t[2]!=null?e.toMethod=t[1]:e.toProperty=t[1],t[3]!=null&&(e.optional=!0),e},{apply:nr}=Function.prototype,Bo=new RegExp("^(.+?)(\\(\\))?(\\?)?\\.(.+?)$"),In,Mn,ir,Fn,Ot=class extends S{static box(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return t instanceof this?t:this.fromUCS2String(t?.toString())}static fromUCS2String(t){return new this(t,qe(t))}static fromCodepoints(t){return new this(Ge(t),t)}constructor(t,e){super(...arguments),this.ucs2String=t,this.codepoints=e,this.length=this.codepoints.length,this.ucs2Length=this.ucs2String.length}offsetToUCS2Offset(t){return Ge(this.codepoints.slice(0,Math.max(0,t))).length}offsetFromUCS2Offset(t){return qe(this.ucs2String.slice(0,Math.max(0,t))).length}slice(){return this.constructor.fromCodepoints(this.codepoints.slice(...arguments))}charAt(t){return this.slice(t,t+1)}isEqualTo(t){return this.constructor.box(t).ucs2String===this.ucs2String}toJSON(){return this.ucs2String}getCacheKey(){return this.ucs2String}toString(){return this.ucs2String}},_o=((In=Array.from)===null||In===void 0?void 0:In.call(Array,"\u{1F47C}").length)===1,jo=((Mn=(ir=" ").codePointAt)===null||Mn===void 0?void 0:Mn.call(ir,0))!=null,Wo=((Fn=String.fromCodePoint)===null||Fn===void 0?void 0:Fn.call(String,32,128124))===" \u{1F47C}",qe,Ge;_o&&jo?qe=i=>Array.from(i).map(t=>t.codePointAt(0)):qe=function(i){let t=[],e=0,{length:n}=i;for(;e<n;){let r=i.charCodeAt(e++);if(55296<=r&&r<=56319&&e<n){let o=i.charCodeAt(e++);(o&64512)===56320?r=((r&1023)<<10)+(o&1023)+65536:e--}t.push(r)}return t};Wo?Ge=i=>String.fromCodePoint(...Array.from(i||[])):Ge=function(i){return(()=>{let e=[];return Array.from(i).forEach(n=>{let r="";n>65535&&(n-=65536,r+=String.fromCharCode(n>>>10&1023|55296),n=56320|n&1023),e.push(r+String.fromCharCode(n))}),e})().join("")};var zo=0,dt=class extends S{static fromJSONString(t){return this.fromJSON(JSON.parse(t))}constructor(){super(...arguments),this.id=++zo}hasSameConstructorAs(t){return this.constructor===t?.constructor}isEqualTo(t){return this===t}inspect(){let t=[],e=this.contentsForInspection()||{};for(let n in e){let r=e[n];t.push("".concat(n,"=").concat(r))}return"#<".concat(this.constructor.name,":").concat(this.id).concat(t.length?" ".concat(t.join(", ")):"",">")}contentsForInspection(){}toJSONString(){return JSON.stringify(this)}toUTF16String(){return Ot.box(this)}getCacheKey(){return this.id.toString()}},Pt=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(i.length!==t.length)return!1;for(let e=0;e<i.length;e++)if(i[e]!==t[e])return!1;return!0},Uo=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return Pt(i.slice(0,t.length),t)},Ci=function(i){let t=i.slice(0);for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return t.splice(...n),t},Vo=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],e=[],n=[],r=new Set;i.forEach(s=>{r.add(s)});let o=new Set;return t.forEach(s=>{o.add(s),r.has(s)||e.push(s)}),i.forEach(s=>{o.has(s)||n.push(s)}),{added:e,removed:n}},Ho=/[\u05BE\u05C0\u05C3\u05D0-\u05EA\u05F0-\u05F4\u061B\u061F\u0621-\u063A\u0640-\u064A\u066D\u0671-\u06B7\u06BA-\u06BE\u06C0-\u
|
||
|
|
`),Ti=new RegExp("[^\\S".concat(bt,"]")),ki=i=>i.replace(new RegExp("".concat(Ti.source),"g")," ").replace(/\ {2,}/g," "),ns=function(i,t){let e,n;return i=Ot.box(i),t=Ot.box(t),t.length<i.length?[n,e]=lr(i,t):[e,n]=lr(t,i),{added:e,removed:n}},lr=function(i,t){if(i.isEqualTo(t))return["",""];let e=jn(i,t),{length:n}=e.utf16String,r;if(n){let{offset:o}=e,s=i.codepoints.slice(0,o).concat(i.codepoints.slice(o+n));r=jn(t,Ot.fromCodepoints(s))}else r=jn(t,i);return[e.utf16String.toString(),r.utf16String.toString()]},jn=function(i,t){let e=0,n=i.length,r=t.length;for(;e<n&&i.charAt(e).isEqualTo(t.charAt(e));)e++;for(;n>e+1&&i.charAt(n-1).isEqualTo(t.charAt(r-1));)n--,r--;return{utf16String:i.slice(e,n),offset:e}},U=class extends dt{static fromCommonAttributesOfObjects(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];if(!t.length)return new this;let e=ae(t[0]),n=e.getKeys();return t.slice(1).forEach(r=>{n=e.getKeysCommonToHash(ae(r)),e=e.slice(n)}),e}static box(t){return ae(t)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(...arguments),this.values=Ue(t)}add(t,e){return this.merge(is(t,e))}remove(t){return new U(Ue(this.values,t))}get(t){return this.values[t]}has(t){return t in this.values}merge(t){return new U(rs(this.values,os(t)))}slice(t){let e={};return Array.from(t).forEach(n=>{this.has(n)&&(e[n]=this.values[n])}),new U(e)}getKeys(){return Object.keys(this.values)}getKeysCommonToHash(t){return t=ae(t),this.getKeys().filter(e=>this.values[e]===t.values[e])}isEqualTo(t){return Pt(this.toArray(),ae(t).toArray())}isEmpty(){return this.getKeys().length===0}toArray(){if(!this.array){let t=[];for(let e in this.values){let n=this.values[e];t.push(t.push(e,n))}this.array=t.slice(0)}return this.array}toObject(){return Ue(this.values)}toJSON(){return this.toObject()}contentsForInspection(){return{values:JSON.stringify(this.values)}}},is=function(i,t){let e={};return e[i]=t,e},rs=function(i,t){let e=Ue(i);for(let n in t){let r=t[n];e[n]=r}return e},Ue=function(i,t){let e={};return Object.keys(i).sort().forEach(r=>{r!==t&&(e[r]=i[r])}),e},ae=function(i){return i instanceof U?i:new U(i)},os=function(i){return i instanceof U?i.values:i},Ae=class{static groupObjects(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],{depth:e,asTree:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r;n&&e==null&&(e=0);let o=[];return Array.from(t).forEach(s=>{var l;if(r){var c,d,g;if((c=s.canBeGrouped)!==null&&c!==void 0&&c.call(s,e)&&(d=(g=r[r.length-1]).canBeGroupedWith)!==null&&d!==void 0&&d.call(g,s,e)){r.push(s);return}else o.push(new this(r,{depth:e,asTree:n})),r=null}(l=s.canBeGrouped)!==null&&l!==void 0&&l.call(s,e)?r=[s]:o.push(s)}),r&&o.push(new this(r,{depth:e,asTree:n})),o}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],{depth:e,asTree:n}=arguments.length>1?arguments[1]:void 0;this.objects=t,n&&(this.depth=e,this.objects=this.constructor.groupObjects(this.objects,{asTree:n,depth:this.depth+1}))}getObjects(){return this.objects}getDepth(){return this.depth}getCacheKey(){let t=["objectGroup"];return Array.from(this.getObjects()).forEach(e=>{t.push(e.getCacheKey())}),t.join("/")}},ai=class extends S{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];super(...arguments),this.objects={},Array.from(t).forEach(e=>{let n=JSON.stringify(e);this.objects[n]==null&&(this.objects[n]=e)})}find(t){let e=JSON.stringify(t);return this.objects[e]}},li=class{constructor(t){this.reset(t)}add(t){let e=cr(t);this.elements[e]=t}remove(t){let e=cr(t),n=this.elements[e];if(n)return delete this.elements[e],n}reset(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return this.elements={},Array.from(t).forEach(e=>{this.add(e)}),t}},cr=i=>i.dataset.trixStoreKey,Yt=class extends S{isPerforming(){return this.performing===!0}hasPerformed(){return this.performed===!0}hasSucceeded(){return this.performed&&this.succeeded}hasFailed(){return this.performed&&!this.succeeded}getPromise(){return this.promise||(this.promise=new Pro
|
||
|
|
`+q),_t&&Fe([pn,bn,vn],lt=>{q=ce(q,lt," ")}),y&&De?y.createHTML(q):q},t.setConfig=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};kn(f),xn=!0},t.clearConfig=function(){Vt=null,xn=!1},t.isValidAttribute=function(f,a,u){Vt||kn({});let h=P(f),w=P(a);return Ji(h,w,u)},t.addHook=function(f,a){typeof a=="function"&&le(_[f],a)},t.removeHook=function(f,a){if(a!==void 0){let u=cs(_[f],a);return u===-1?void 0:us(_[f],u,1)[0]}return dr(_[f])},t.removeHooks=function(f){_[f]=[]},t.removeAllHooks=function(){_=br()},t}var xe=$r();xe.addHook("uponSanitizeAttribute",function(i,t){/^data-trix-/.test(t.attrName)&&(t.forceKeepAttr=!0)});var ks="style href src width height language class".split(" "),Rs="javascript:".split(" "),Ds="script iframe form noscript".split(" "),Xt=class extends S{static setHTML(t,e,n){let r=new this(e,n).sanitize(),o=r.getHTML?r.getHTML():r.outerHTML;t.innerHTML=o}static sanitize(t,e){let n=new this(t,e);return n.sanitize(),n}constructor(t){let{allowedAttributes:e,forbiddenProtocols:n,forbiddenElements:r,purifyOptions:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(...arguments),this.allowedAttributes=e||ks,this.forbiddenProtocols=n||Rs,this.forbiddenElements=r||Ds,this.purifyOptions=o||{},this.body=Ls(t)}sanitize(){this.sanitizeElements(),this.normalizeListElementNesting();let t=Object.assign({},Nr,this.purifyOptions);return xe.setConfig(t),this.body=xe.sanitize(this.body),this.body}getHTML(){return this.body.innerHTML}getBody(){return this.body}sanitizeElements(){let t=He(this.body),e=[];for(;t.nextNode();){let n=t.currentNode;switch(n.nodeType){case Node.ELEMENT_NODE:this.elementIsRemovable(n)?e.push(n):this.sanitizeElement(n);break;case Node.COMMENT_NODE:e.push(n);break}}return e.forEach(n=>yt(n)),this.body}sanitizeElement(t){return t.hasAttribute("href")&&this.forbiddenProtocols.includes(t.protocol)&&t.removeAttribute("href"),Array.from(t.attributes).forEach(e=>{let{name:n}=e;!this.allowedAttributes.includes(n)&&n.indexOf("data-trix")!==0&&t.removeAttribute(n)}),t}normalizeListElementNesting(){return Array.from(this.body.querySelectorAll("ul,ol")).forEach(t=>{let e=t.previousElementSibling;e&&W(e)==="li"&&e.appendChild(t)}),this.body}elementIsRemovable(t){if(t?.nodeType===Node.ELEMENT_NODE)return this.elementIsForbidden(t)||this.elementIsntSerializable(t)}elementIsForbidden(t){return this.forbiddenElements.includes(W(t))}elementIsntSerializable(t){return t.getAttribute("data-trix-serialize")==="false"&&!Dt(t)}},Ls=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";i=i.replace(/<\/html[^>]*>[^]*$/i,"</html>");let t=document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=i,Array.from(t.head.querySelectorAll("style")).forEach(e=>{t.body.appendChild(e)}),t.body},{css:pt}=Te,Ee=class extends ht{constructor(){super(...arguments),this.attachment=this.object,this.attachment.uploadProgressDelegate=this,this.attachmentPiece=this.options.piece}createContentNodes(){return[]}createNodes(){let t,e=t=p({tagName:"figure",className:this.getClassName(),data:this.getData(),editable:!1}),n=this.getHref();return n&&(t=p({tagName:"a",editable:!1,attributes:{href:n,tabindex:-1}}),e.appendChild(t)),this.attachment.hasContent()?Xt.setHTML(t,this.attachment.getContent()):this.createContentNodes().forEach(r=>{t.appendChild(r)}),t.appendChild(this.createCaptionElement()),this.attachment.isPending()&&(this.progressElement=p({tagName:"progress",attributes:{class:pt.attachmentProgress,value:this.attachment.getUploadProgress(),max:100},data:{trixMutable:!0,trixStoreKey:["progressElement",this.attachment.id].join("/")}}),e.appendChild(this.progressElement)),[vr("left"),e,vr("right")]}createCaptionElement(){let t=p({tagName:"figcaption",className:pt.attachmentCaption}),e=this.attachmentPiece.getCaption();if(e)t.classList.add("".concat(pt.attachmentCaption,"--edited")),t.textContent=e;else{let n,r,o=this.getCaptionConfig();if(o.name&&(n=this.attachment.getFilename()),o.size&&(r=this.attachment.getFormattedFilesize()),n){let s=p({tagName:"span",classN
|
||
|
|
`);for(let r=0;r<n.length;r++){let o=n[r];if(r>0){let s=p("br");e.push(s)}if(o.length){let s=document.createTextNode(this.preserveSpaces(o));e.push(s)}}return e}}createElement(){let t,e,n,r={};for(e in this.attributes){n=this.attributes[e];let s=oi(e);if(s){if(s.tagName){var o;let l=p(s.tagName);o?(o.appendChild(l),o=l):t=o=l}if(s.styleProperty&&(r[s.styleProperty]=n),s.style)for(e in s.style)n=s.style[e],r[e]=n}}if(Object.keys(r).length){t||(t=p("span"));for(e in r)n=r[e],t.style[e]=n}return t}createContainerElement(){for(let t in this.attributes){let e=this.attributes[t],n=oi(t);if(n&&n.groupTagName){let r={};return r[t]=e,p(n.groupTagName,r)}}}preserveSpaces(t){return this.context.isLast&&(t=t.replace(/\ $/,bt)),t=t.replace(/(\S)\ {3}(\S)/g,"$1 ".concat(bt," $2")).replace(/\ {2}/g,"".concat(bt," ")).replace(/\ {2}/g," ".concat(bt)),(this.context.isFirst||this.context.followsWhitespace)&&(t=t.replace(/^\ /,bt)),t}},Xe=class extends ht{constructor(){super(...arguments),this.text=this.object,this.textConfig=this.options.textConfig}createNodes(){let t=[],e=Ae.groupObjects(this.getPieces()),n=e.length-1;for(let o=0;o<e.length;o++){let s=e[o],l={};o===0&&(l.isFirst=!0),o===n&&(l.isLast=!0),Ps(r)&&(l.followsWhitespace=!0);let c=this.findOrCreateCachedChildView(Ye,s,{textConfig:this.textConfig,context:l});t.push(...Array.from(c.getNodes()||[]));var r=s}return t}getPieces(){return Array.from(this.text.getPieces()).filter(t=>!t.hasAttribute("blockBreak"))}},Ps=i=>/\s$/.test(i?.toString()),{css:yr}=Te,Ze=class extends ht{constructor(){super(...arguments),this.block=this.object,this.attributes=this.block.getAttributes()}createNodes(){let e=[document.createComment("block")];if(this.block.isEmpty())e.push(p("br"));else{var n;let r=(n=D(this.block.getLastAttribute()))===null||n===void 0?void 0:n.text,o=this.findOrCreateCachedChildView(Xe,this.block.text,{textConfig:r});e.push(...Array.from(o.getNodes()||[])),this.shouldAddExtraNewlineElement()&&e.push(p("br"))}if(this.attributes.length)return e;{let r,{tagName:o}=z.default;this.block.isRTL()&&(r={dir:"rtl"});let s=p({tagName:o,attributes:r});return e.forEach(l=>s.appendChild(l)),[s]}}createContainerElement(t){let e={},n,r=this.attributes[t],{tagName:o,htmlAttributes:s=[]}=D(r);if(t===0&&this.block.isRTL()&&Object.assign(e,{dir:"rtl"}),r==="attachmentGallery"){let l=this.block.getBlockBreakPosition();n="".concat(yr.attachmentGallery," ").concat(yr.attachmentGallery,"--").concat(l)}return Object.entries(this.block.htmlAttributes).forEach(l=>{let[c,d]=l;s.includes(c)&&(e[c]=d)}),p({tagName:o,className:n,attributes:e})}shouldAddExtraNewlineElement(){return/\n\n$/.test(this.block.toString())}},Zt=class extends ht{static render(t){let e=p("div"),n=new this(t,{element:e});return n.render(),n.sync(),e}constructor(){super(...arguments),this.element=this.options.element,this.elementStore=new li,this.setDocument(this.object)}setDocument(t){t.isEqualTo(this.document)||(this.document=this.object=t)}render(){if(this.childViews=[],this.shadowElement=p("div"),!this.document.isEmpty()){let t=Ae.groupObjects(this.document.getBlocks(),{asTree:!0});Array.from(t).forEach(e=>{let n=this.findOrCreateCachedChildView(Ze,e);Array.from(n.getNodes()).map(r=>this.shadowElement.appendChild(r))})}}isSynced(){return Is(this.shadowElement,this.element)}sync(){let e=jr("trix-before-render",{cancelable:!1,attributes:{render:(r,o)=>{for(;r.lastChild;)r.removeChild(r.lastChild);r.appendChild(o)}}});this.element.dispatchEvent(e);let n=this.createDocumentFragmentForSync();return e.render(this.element,n),this.didSync()}didSync(){return this.elementStore.reset(Ar(this.element)),Si(()=>this.garbageCollectCachedViews())}createDocumentFragmentForSync(){let t=document.createDocumentFragment();return Array.from(this.shadowElement.childNodes).forEach(e=>{t.appendChild(e.cloneNode(!0))}),Array.from(Ar(t)).forEach(e=>{let n=this.elementStore.remove(e);n&&e.parentNode.replaceChild(n,e)}),t}},Ar=i=>i.querySelectorAll("[data-trix-store-key]"),Is=(i,t)=>xr(i.innerHTML)===xr(t.innerHTML),xr=i=>i.replace(/ /g," ");function Be(i){v
|
||
|
|
`&&this.getAttribute("blockBreak")===!0}toJSON(){let t=super.toJSON(...arguments);return t.string=this.string,t}canBeConsolidatedWith(t){return t&&this.hasSameConstructorAs(t)&&this.hasSameAttributesAsPiece(t)}consolidateWith(t){return new this.constructor(this.toString()+t.toString(),this.attributes)}splitAtOffset(t){let e,n;return t===0?(e=null,n=this):t===this.length?(e=this,n=null):(e=new this.constructor(this.string.slice(0,t),this.attributes),n=new this.constructor(this.string.slice(t),this.attributes)),[e,n]}toConsole(){let{string:t}=this;return t.length>15&&(t=t.slice(0,14)+"\u2026"),JSON.stringify(t.toString())}};ft.registerType("string",we);var Qt=class extends dt{static box(t){return t instanceof this?t:new this(t)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];super(...arguments),this.objects=t.slice(0),this.length=this.objects.length}indexOf(t){return this.objects.indexOf(t)}splice(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new this.constructor(Ci(this.objects,...e))}eachObject(t){return this.objects.map((e,n)=>t(e,n))}insertObjectAtIndex(t,e){return this.splice(e,0,t)}insertSplittableListAtIndex(t,e){return this.splice(e,0,...t.objects)}insertSplittableListAtPosition(t,e){let[n,r]=this.splitObjectAtPosition(e);return new this.constructor(n).insertSplittableListAtIndex(t,r)}editObjectAtIndex(t,e){return this.replaceObjectAtIndex(e(this.objects[t]),t)}replaceObjectAtIndex(t,e){return this.splice(e,1,t)}removeObjectAtIndex(t){return this.splice(t,1)}getObjectAtIndex(t){return this.objects[t]}getSplittableListInRange(t){let[e,n,r]=this.splitObjectsAtRange(t);return new this.constructor(e.slice(n,r+1))}selectSplittableList(t){let e=this.objects.filter(n=>t(n));return new this.constructor(e)}removeObjectsInRange(t){let[e,n,r]=this.splitObjectsAtRange(t);return new this.constructor(e).splice(n,r-n+1)}transformObjectsInRange(t,e){let[n,r,o]=this.splitObjectsAtRange(t),s=n.map((l,c)=>r<=c&&c<=o?e(l):l);return new this.constructor(s)}splitObjectsAtRange(t){let e,[n,r,o]=this.splitObjectAtPosition(zs(t));return[n,e]=new this.constructor(n).splitObjectAtPosition(Us(t)+o),[n,r,e-1]}getObjectAtPosition(t){let{index:e}=this.findIndexAndOffsetAtPosition(t);return this.objects[e]}splitObjectAtPosition(t){let e,n,{index:r,offset:o}=this.findIndexAndOffsetAtPosition(t),s=this.objects.slice(0);if(r!=null)if(o===0)e=r,n=0;else{let l=this.getObjectAtIndex(r),[c,d]=l.splitAtOffset(o);s.splice(r,1,c,d),e=r+1,n=c.getLength()-o}else e=s.length,n=0;return[s,e,n]}consolidate(){let t=[],e=this.objects[0];return this.objects.slice(1).forEach(n=>{var r,o;(r=(o=e).canBeConsolidatedWith)!==null&&r!==void 0&&r.call(o,n)?e=e.consolidateWith(n):(t.push(e),e=n)}),e&&t.push(e),new this.constructor(t)}consolidateFromIndexToIndex(t,e){let r=this.objects.slice(0).slice(t,e+1),o=new this.constructor(r).consolidate().toArray();return this.splice(t,r.length,...o)}findIndexAndOffsetAtPosition(t){let e,n=0;for(e=0;e<this.objects.length;e++){let r=this.objects[e],o=n+r.getLength();if(n<=t&&t<o)return{index:e,offset:t-n};n=o}return{index:null,offset:null}}findPositionAtIndexAndOffset(t,e){let n=0;for(let r=0;r<this.objects.length;r++){let o=this.objects[r];if(r<t)n+=o.getLength();else if(r===t){n+=e;break}}return n}getEndPosition(){return this.endPosition==null&&(this.endPosition=0,this.objects.forEach(t=>this.endPosition+=t.getLength())),this.endPosition}toString(){return this.objects.join("")}toArray(){return this.objects.slice(0)}toJSON(){return this.toArray()}isEqualTo(t){return super.isEqualTo(...arguments)||Ws(this.objects,t?.objects)}contentsForInspection(){return{objects:"[".concat(this.objects.map(t=>t.inspect()).join(", "),"]")}}},Ws=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(i.length!==t.length)return!1;let e=!0;for(let n=0;n<i.length;n++){let r=i[n];e&&!r.isEqualTo(t[n])&&(e=!1)}return e},zs=i=>i[0],Us=i=>i[1],K=class extends dt{static textForAttachmentWithAttributes(t,e){let n=new xt(t,e);return new this([n])}static textForStringWithAttr
|
||
|
|
`,e);break;case"backward":r=n.slice(0,e).lastIndexOf(`
|
||
|
|
`)}if(r!==-1)return r}contentsForInspection(){return{text:this.text.inspect(),attributes:this.attributes}}toString(){return this.text.toString()}toJSON(){return{text:this.text,attributes:this.attributes,htmlAttributes:this.htmlAttributes}}getDirection(){return this.text.getDirection()}isRTL(){return this.text.isRTL()}getLength(){return this.text.getLength()}canBeConsolidatedWith(t){return!this.hasAttributes()&&!t.hasAttributes()&&this.getDirection()===t.getDirection()}consolidateWith(t){let e=K.textForStringWithAttributes(`
|
||
|
|
`),n=this.getTextWithoutBlockBreak().appendText(e);return this.copyWithText(n.appendText(t.text))}splitAtOffset(t){let e,n;return t===0?(e=null,n=this):t===this.getLength()?(e=this,n=null):(e=this.copyWithText(this.text.getTextAtRange([0,t])),n=this.copyWithText(this.text.getTextAtRange([t,this.getLength()]))),[e,n]}getBlockBreakPosition(){return this.text.getLength()-1}getTextWithoutBlockBreak(){return no(this.text)?this.text.getTextAtRange([0,this.getBlockBreakPosition()]):this.text.copy()}canBeGrouped(t){return this.attributes[t]}canBeGroupedWith(t,e){let n=t.getAttributes(),r=n[e],o=this.attributes[e];return o===r&&!(D(o).group===!1&&!Jo().includes(n[e+1]))&&(this.getDirection()===t.getDirection()||t.isEmpty())}},Vs=function(i){return i=Hs(i),i=Gs(i),i},Hs=function(i){let t=!1,e=i.getPieces(),n=e.slice(0,e.length-1),r=e[e.length-1];return r?(n=n.map(o=>o.isBlockBreak()?(t=!0,Ks(o)):o),t?new K([...n,r]):i):i},qs=K.textForStringWithAttributes(`
|
||
|
|
`,{blockBreak:!0}),Gs=function(i){return no(i)?i:i.appendText(qs)},no=function(i){let t=i.getLength();return t===0?!1:i.getTextAtRange([t-1,t]).isBlockBreak()},Ks=i=>i.copyWithoutAttribute("blockBreak"),Er=function(i){let{listAttribute:t}=D(i);return t?[t,i]:[i]},wr=i=>i.slice(-1)[0],Cr=function(i,t){let e=i.lastIndexOf(t);return e===-1?i:Ci(i,e,1)},G=class extends dt{static fromJSON(t){let e=Array.from(t).map(n=>Y.fromJSON(n));return new this(e)}static fromString(t,e){let n=K.textForStringWithAttributes(t,e);return new this([new Y(n)])}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];super(...arguments),t.length===0&&(t=[new Y]),this.blockList=Qt.box(t)}isEmpty(){let t=this.getBlockAtIndex(0);return this.blockList.length===1&&t.isEmpty()&&!t.hasAttributes()}copy(){let e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).consolidateBlocks?this.blockList.consolidate().toArray():this.blockList.toArray();return new this.constructor(e)}copyUsingObjectsFromDocument(t){let e=new ai(t.getObjects());return this.copyUsingObjectMap(e)}copyUsingObjectMap(t){let e=this.getBlocks().map(n=>t.find(n)||n.copyUsingObjectMap(t));return new this.constructor(e)}copyWithBaseBlockAttributes(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=this.getBlocks().map(n=>{let r=t.concat(n.getAttributes());return n.copyWithAttributes(r)});return new this.constructor(e)}replaceBlock(t,e){let n=this.blockList.indexOf(t);return n===-1?this:new this.constructor(this.blockList.replaceObjectAtIndex(e,n))}insertDocumentAtRange(t,e){let{blockList:n}=t;e=A(e);let[r]=e,{index:o,offset:s}=this.locationFromPosition(r),l=this,c=this.getBlockAtPosition(r);return ut(e)&&c.isEmpty()&&!c.hasAttributes()?l=new this.constructor(l.blockList.removeObjectAtIndex(o)):c.getBlockBreakPosition()===s&&r++,l=l.removeTextAtRange(e),new this.constructor(l.blockList.insertSplittableListAtPosition(n,r))}mergeDocumentAtRange(t,e){let n,r;e=A(e);let[o]=e,s=this.locationFromPosition(o),l=this.getBlockAtIndex(s.index).getAttributes(),c=t.getBaseBlockAttributes(),d=l.slice(-c.length);if(Pt(c,d)){let T=l.slice(0,-c.length);n=t.copyWithBaseBlockAttributes(T)}else n=t.copy({consolidateBlocks:!0}).copyWithBaseBlockAttributes(l);let g=n.getBlockCount(),x=n.getBlockAtIndex(0);if(Pt(l,x.getAttributes())){let T=x.getTextWithoutBlockBreak();if(r=this.insertTextAtRange(T,e),g>1){n=new this.constructor(n.getBlocks().slice(1));let Z=o+T.getLength();r=r.insertDocumentAtRange(n,Z)}}else r=this.insertDocumentAtRange(n,e);return r}insertTextAtRange(t,e){e=A(e);let[n]=e,{index:r,offset:o}=this.locationFromPosition(n),s=this.removeTextAtRange(e);return new this.constructor(s.blockList.editObjectAtIndex(r,l=>l.copyWithText(l.text.insertTextAtPosition(t,o))))}removeTextAtRange(t){let e;t=A(t);let[n,r]=t;if(ut(t))return this;let[o,s]=Array.from(this.locationRangeFromRange(t)),l=o.index,c=o.offset,d=this.getBlockAtIndex(l),g=s.index,x=s.offset,T=this.getBlockAtIndex(g);if(r-n===1&&d.getBlockBreakPosition()===c&&T.getBlockBreakPosition()!==x&&T.text.getStringAtPosition(x)===`
|
||
|
|
`)e=this.blockList.editObjectAtIndex(g,F=>F.copyWithText(F.text.removeTextAtRange([x,x+1])));else{let F,Q=d.text.getTextAtRange([0,c]),Et=T.text.getTextAtRange([x,T.getLength()]),mt=Q.appendText(Et);l!==g&&c===0&&d.getAttributeLevel()>=T.getAttributeLevel()?F=T.copyWithText(mt):F=d.copyWithText(mt);let y=g+1-l;e=this.blockList.splice(l,y,F)}return new this.constructor(e)}moveTextFromRangeToPosition(t,e){let n;t=A(t);let[r,o]=t;if(r<=e&&e<=o)return this;let s=this.getDocumentAtRange(t),l=this.removeTextAtRange(t),c=r<e;c&&(e-=s.getLength());let[d,...g]=s.getBlocks();return g.length===0?(n=d.getTextWithoutBlockBreak(),c&&(e+=1)):n=d.text,l=l.insertTextAtRange(n,e),g.length===0?l:(s=new this.constructor(g),e+=n.getLength(),l.insertDocumentAtRange(s,e))}addAttributeAtRange(t,e,n){let{blockList:r}=this;return this.eachBlockAtRange(n,(o,s,l)=>r=r.editObjectAtIndex(l,function(){return D(t)?o.addAttribute(t,e):s[0]===s[1]?o:o.copyWithText(o.text.addAttributeAtRange(t,e,s))})),new this.constructor(r)}addAttribute(t,e){let{blockList:n}=this;return this.eachBlock((r,o)=>n=n.editObjectAtIndex(o,()=>r.addAttribute(t,e))),new this.constructor(n)}removeAttributeAtRange(t,e){let{blockList:n}=this;return this.eachBlockAtRange(e,function(r,o,s){D(t)?n=n.editObjectAtIndex(s,()=>r.removeAttribute(t)):o[0]!==o[1]&&(n=n.editObjectAtIndex(s,()=>r.copyWithText(r.text.removeAttributeAtRange(t,o))))}),new this.constructor(n)}updateAttributesForAttachment(t,e){let n=this.getRangeOfAttachment(e),[r]=Array.from(n),{index:o}=this.locationFromPosition(r),s=this.getTextAtIndex(o);return new this.constructor(this.blockList.editObjectAtIndex(o,l=>l.copyWithText(s.updateAttributesForAttachment(t,e))))}removeAttributeForAttachment(t,e){let n=this.getRangeOfAttachment(e);return this.removeAttributeAtRange(t,n)}setHTMLAttributeAtPosition(t,e,n){let r=this.getBlockAtPosition(t),o=r.addHTMLAttribute(e,n);return this.replaceBlock(r,o)}insertBlockBreakAtRange(t){let e;t=A(t);let[n]=t,{offset:r}=this.locationFromPosition(n),o=this.removeTextAtRange(t);return r===0&&(e=[new Y]),new this.constructor(o.blockList.insertSplittableListAtPosition(new Qt(e),n))}applyBlockAttributeAtRange(t,e,n){let r=this.expandRangeToLineBreaksAndSplitBlocks(n),o=r.document;n=r.range;let s=D(t);if(s.listAttribute){o=o.removeLastListAttributeAtRange(n,{exceptAttributeName:t});let l=o.convertLineBreaksToBlockBreaksInRange(n);o=l.document,n=l.range}else s.exclusive?o=o.removeBlockAttributesAtRange(n):s.terminal?o=o.removeLastTerminalAttributeAtRange(n):o=o.consolidateBlocksAtRange(n);return o.addAttributeAtRange(t,e,n)}removeLastListAttributeAtRange(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{blockList:n}=this;return this.eachBlockAtRange(t,function(r,o,s){let l=r.getLastAttribute();!l||!D(l).listAttribute||l!==e.exceptAttributeName&&(n=n.editObjectAtIndex(s,()=>r.removeAttribute(l)))}),new this.constructor(n)}removeLastTerminalAttributeAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,function(n,r,o){let s=n.getLastAttribute();!s||!D(s).terminal||(e=e.editObjectAtIndex(o,()=>n.removeAttribute(s)))}),new this.constructor(e)}removeBlockAttributesAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,function(n,r,o){n.hasAttributes()&&(e=e.editObjectAtIndex(o,()=>n.copyWithoutAttributes()))}),new this.constructor(e)}expandRangeToLineBreaksAndSplitBlocks(t){let e;t=A(t);let[n,r]=t,o=this.locationFromPosition(n),s=this.locationFromPosition(r),l=this,c=l.getBlockAtIndex(o.index);if(o.offset=c.findLineBreakInDirectionFromPosition("backward",o.offset),o.offset!=null&&(e=l.positionFromLocation(o),l=l.insertBlockBreakAtRange([e,e+1]),s.index+=1,s.offset-=l.getBlockAtIndex(o.index).getLength(),o.index+=1),o.offset=0,s.offset===0&&s.index>o.index)s.index-=1,s.offset=l.getBlockAtIndex(s.index).getBlockBreakPosition();else{let d=l.getBlockAtIndex(s.index);d.text.getStringAtRange([s.offset-1,s.offset])===`
|
||
|
|
`?s.offset-=1:s.offset=d.findLineBreakInDirectionFromPosition("forward",s.offset),s.offset!==d.getBlockBreakPosition()&&(e=l.positionFromLocation(s),l=l.insertBlockBreakAtRange([e,e+1]))}return n=l.positionFromLocation(o),r=l.positionFromLocation(s),t=A([n,r]),{document:l,range:t}}convertLineBreaksToBlockBreaksInRange(t){t=A(t);let[e]=t,n=this.getStringAtRange(t).slice(0,-1),r=this;return n.replace(/.*?\n/g,function(o){e+=o.length,r=r.insertBlockBreakAtRange([e-1,e])}),{document:r,range:t}}consolidateBlocksAtRange(t){t=A(t);let[e,n]=t,r=this.locationFromPosition(e).index,o=this.locationFromPosition(n).index;return new this.constructor(this.blockList.consolidateFromIndexToIndex(r,o))}getDocumentAtRange(t){t=A(t);let e=this.blockList.getSplittableListInRange(t).toArray();return new this.constructor(e)}getStringAtRange(t){let e,n=t=A(t);return n[n.length-1]!==this.getLength()&&(e=-1),this.getDocumentAtRange(t).toString().slice(0,e)}getBlockAtIndex(t){return this.blockList.getObjectAtIndex(t)}getBlockAtPosition(t){let{index:e}=this.locationFromPosition(t);return this.getBlockAtIndex(e)}getTextAtIndex(t){var e;return(e=this.getBlockAtIndex(t))===null||e===void 0?void 0:e.text}getTextAtPosition(t){let{index:e}=this.locationFromPosition(t);return this.getTextAtIndex(e)}getPieceAtPosition(t){let{index:e,offset:n}=this.locationFromPosition(t);return this.getTextAtIndex(e).getPieceAtPosition(n)}getCharacterAtPosition(t){let{index:e,offset:n}=this.locationFromPosition(t);return this.getTextAtIndex(e).getStringAtRange([n,n+1])}getLength(){return this.blockList.getEndPosition()}getBlocks(){return this.blockList.toArray()}getBlockCount(){return this.blockList.length}getEditCount(){return this.editCount}eachBlock(t){return this.blockList.eachObject(t)}eachBlockAtRange(t,e){let n,r;t=A(t);let[o,s]=t,l=this.locationFromPosition(o),c=this.locationFromPosition(s);if(l.index===c.index)return n=this.getBlockAtIndex(l.index),r=[l.offset,c.offset],e(n,r,l.index);for(let d=l.index;d<=c.index;d++)if(n=this.getBlockAtIndex(d),n){switch(d){case l.index:r=[l.offset,n.text.getLength()];break;case c.index:r=[0,c.offset];break;default:r=[0,n.text.getLength()]}e(n,r,d)}}getCommonAttributesAtRange(t){t=A(t);let[e]=t;if(ut(t))return this.getCommonAttributesAtPosition(e);{let n=[],r=[];return this.eachBlockAtRange(t,function(o,s){if(s[0]!==s[1])return n.push(o.text.getCommonAttributesAtRange(s)),r.push(Sr(o))}),U.fromCommonAttributesOfObjects(n).merge(U.fromCommonAttributesOfObjects(r)).toObject()}}getCommonAttributesAtPosition(t){let e,n,{index:r,offset:o}=this.locationFromPosition(t),s=this.getBlockAtIndex(r);if(!s)return{};let l=Sr(s),c=s.text.getAttributesAtPosition(o),d=s.text.getAttributesAtPosition(o-1),g=Object.keys(Lt).filter(x=>Lt[x].inheritable);for(e in d)n=d[e],(n===c[e]||g.includes(e))&&(l[e]=n);return l}getRangeOfCommonAttributeAtPosition(t,e){let{index:n,offset:r}=this.locationFromPosition(e),o=this.getTextAtIndex(n),[s,l]=Array.from(o.getExpandedRangeForAttributeAtOffset(t,r)),c=this.positionFromLocation({index:n,offset:s}),d=this.positionFromLocation({index:n,offset:l});return A([c,d])}getBaseBlockAttributes(){let t=this.getBlockAtIndex(0).getAttributes();for(let e=1;e<this.getBlockCount();e++){let n=this.getBlockAtIndex(e).getAttributes(),r=Math.min(t.length,n.length);t=(()=>{let o=[];for(let s=0;s<r&&n[s]===t[s];s++)o.push(n[s]);return o})()}return t}getAttachmentById(t){for(let e of this.getAttachments())if(e.id===t)return e}getAttachmentPieces(){let t=[];return this.blockList.eachObject(e=>{let{text:n}=e;return t=t.concat(n.getAttachmentPieces())}),t}getAttachments(){return this.getAttachmentPieces().map(t=>t.attachment)}getRangeOfAttachment(t){let e=0,n=this.blockList.toArray();for(let r=0;r<n.length;r++){let{text:o}=n[r],s=o.getRangeOfAttachment(t);if(s)return A([e+s[0],e+s[1]]);e+=o.getLength()}}getLocationRangeOfAttachment(t){let e=this.getRangeOfAttachment(t);return this.locationRangeFromRange(e)}getAttachmentPieceForAttachment(t){for(let e of this.getAttachmentPieces())if(e.attachment===t)return e}findRangesForBlockAttribute(t
|
||
|
|
`);if(e===this.containerElement||this.isBlockElement(e)){var n;let r=this.getBlockAttributes(e),o=this.getBlockHTMLAttributes(e);Pt(r,(n=this.currentBlock)===null||n===void 0?void 0:n.attributes)||(this.currentBlock=this.appendBlockForAttributesWithElement(r,e,o),this.currentBlockElement=e)}}appendBlockForElement(t){let e=this.isBlockElement(t),n=kt(this.currentBlockElement,t);if(e&&!this.isBlockElement(t.firstChild)){if(!this.isInsignificantTextNode(t.firstChild)||!this.isBlockElement(t.firstElementChild)){let r=this.getBlockAttributes(t),o=this.getBlockHTMLAttributes(t);if(t.firstChild)if(!(n&&Pt(r,this.currentBlock.attributes)))this.currentBlock=this.appendBlockForAttributesWithElement(r,t,o),this.currentBlockElement=t;else return this.appendStringWithAttributes(`
|
||
|
|
`)}}else if(this.currentBlockElement&&!n&&!e){let r=this.findParentBlockElement(t);if(r)return this.appendBlockForElement(r);this.currentBlock=this.appendEmptyBlock(),this.currentBlockElement=null}}findParentBlockElement(t){let{parentElement:e}=t;for(;e&&e!==this.containerElement;){if(this.isBlockElement(e)&&this.blockElements.includes(e))return e;e=e.parentElement}return null}processTextNode(t){let e=t.data;if(!kr(t.parentNode)){var n;e=ki(e),io((n=t.previousSibling)===null||n===void 0?void 0:n.textContent)&&(e=$s(e))}return this.appendStringWithAttributes(e,this.getTextAttributes(t.parentNode))}processElement(t){let e;if(Dt(t)){if(e=Tr(t,"attachment"),Object.keys(e).length){let n=this.getTextAttributes(t);this.appendAttachmentWithAttributes(e,n),t.innerHTML=""}return this.processedElements.push(t)}else switch(W(t)){case"br":return!this.isExtraBR(t)&&!this.isBlockElement(t.nextSibling)&&this.appendStringWithAttributes(`
|
||
|
|
`,this.getTextAttributes(t)),this.processedElements.push(t);case"img":e={url:t.getAttribute("src"),contentType:"image"};let n=Xs(t);for(let r in n){let o=n[r];e[r]=o}return this.appendAttachmentWithAttributes(e,this.getTextAttributes(t)),this.processedElements.push(t);case"tr":if(this.needsTableSeparator(t))return this.appendStringWithAttributes(ze.tableRowSeparator);break;case"td":if(this.needsTableSeparator(t))return this.appendStringWithAttributes(ze.tableCellSeparator);break}}appendBlockForAttributesWithElement(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.blockElements.push(e);let r=Ys(t,n);return this.blocks.push(r),r}appendEmptyBlock(){return this.appendBlockForAttributesWithElement([],null)}appendStringWithAttributes(t,e){return this.appendPiece(Gn(t,e))}appendAttachmentWithAttributes(t,e){return this.appendPiece(Js(t,e))}appendPiece(t){return this.blocks.length===0&&this.appendEmptyBlock(),this.blocks[this.blocks.length-1].text.push(t)}appendStringToTextAtIndex(t,e){let{text:n}=this.blocks[e],r=n[n.length-1];if(r?.type==="string")r.string+=t;else return n.push(Gn(t))}prependStringToTextAtIndex(t,e){let{text:n}=this.blocks[e],r=n[0];if(r?.type==="string")r.string=t+r.string;else return n.unshift(Gn(t))}getTextAttributes(t){let e,n={};for(let r in Lt){let o=Lt[r];if(o.tagName&&vt(t,{matchingSelector:o.tagName,untilNode:this.containerElement}))n[r]=!0;else if(o.parser){if(e=o.parser(t),e){let s=!1;for(let l of this.findBlockElementAncestors(t))if(o.parser(l)===e){s=!0;break}s||(n[r]=e)}}else o.styleProperty&&(e=t.style[o.styleProperty],e&&(n[r]=e))}if(Dt(t)){let r=Tr(t,"attributes");for(let o in r)e=r[o],n[o]=e}return n}getBlockAttributes(t){let e=[];for(;t&&t!==this.containerElement;){for(let r in z){let o=z[r];if(o.parse!==!1&&W(t)===o.tagName){var n;((n=o.test)!==null&&n!==void 0&&n.call(o,t)||!o.test)&&(e.push(r),o.listAttribute&&e.push(o.listAttribute))}}t=t.parentNode}return e.reverse()}getBlockHTMLAttributes(t){let e={},n=Object.values(z).find(o=>o.tagName===W(t));return(n?.htmlAttributes||[]).forEach(o=>{t.hasAttribute(o)&&(e[o]=t.getAttribute(o))}),e}findBlockElementAncestors(t){let e=[];for(;t&&t!==this.containerElement;){let n=W(t);pe().includes(n)&&e.push(t),t=t.parentNode}return e}isBlockElement(t){if(t?.nodeType===Node.ELEMENT_NODE&&!Dt(t)&&!vt(t,{matchingSelector:"td",untilNode:this.containerElement}))return pe().includes(W(t))||window.getComputedStyle(t).display==="block"}isInsignificantTextNode(t){if(t?.nodeType!==Node.TEXT_NODE||!ta(t.data))return;let{parentNode:e,previousSibling:n,nextSibling:r}=t;if(!(Zs(e.previousSibling)&&!this.isBlockElement(e.previousSibling))&&!kr(e))return!n||this.isBlockElement(n)||!r||this.isBlockElement(r)}isExtraBR(t){return W(t)==="br"&&this.isBlockElement(t.parentNode)&&t.parentNode.lastChild===t}needsTableSeparator(t){if(ze.removeBlankTableCells){var e;let n=(e=t.previousSibling)===null||e===void 0?void 0:e.textContent;return n&&/\S/.test(n)}else return t.previousSibling}translateBlockElementMarginsToNewlines(){let t=this.getMarginOfDefaultBlockElement();for(let e=0;e<this.blocks.length;e++){let n=this.getMarginOfBlockElementAtIndex(e);n&&(n.top>t.top*2&&this.prependStringToTextAtIndex(`
|
||
|
|
`,e),n.bottom>t.bottom*2&&this.appendStringToTextAtIndex(`
|
||
|
|
`,e))}}getMarginOfBlockElementAtIndex(t){let e=this.blockElements[t];if(e&&e.textContent&&!pe().includes(W(e))&&!this.processedElements.includes(e))return Rr(e)}getMarginOfDefaultBlockElement(){let t=p(z.default.tagName);return this.containerElement.appendChild(t),Rr(t)}},kr=function(i){let{whiteSpace:t}=window.getComputedStyle(i);return["pre","pre-wrap","pre-line"].includes(t)},Zs=i=>i&&!io(i.textContent),Rr=function(i){let t=window.getComputedStyle(i);if(t.display==="block")return{top:parseInt(t.marginTop),bottom:parseInt(t.marginBottom)}},Qs=function(i){return W(i)==="style"?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},$s=i=>i.replace(new RegExp("^".concat(Ti.source,"+")),""),ta=i=>new RegExp("^".concat(Ti.source,"*$")).test(i),io=i=>/\s$/.test(i),ea="[data-trix-serialize=false]",na=["contenteditable","data-trix-id","data-trix-store-key","data-trix-mutable","data-trix-placeholder","tabindex"],hi="data-trix-serialized-attributes",ia="[".concat(hi,"]"),ra=new RegExp("<!--block-->","g"),oa={"application/json":function(i){let t;if(i instanceof G)t=i;else if(i instanceof HTMLElement)t=Mt.parse(i.innerHTML).getDocument();else throw new Error("unserializable object");return t.toSerializableDocument().toJSONString()},"text/html":function(i){let t;if(i instanceof G)t=Zt.render(i);else if(i instanceof HTMLElement)t=i.cloneNode(!0);else throw new Error("unserializable object");return Array.from(t.querySelectorAll(ea)).forEach(e=>{yt(e)}),na.forEach(e=>{Array.from(t.querySelectorAll("[".concat(e,"]"))).forEach(n=>{n.removeAttribute(e)})}),Array.from(t.querySelectorAll(ia)).forEach(e=>{try{let n=JSON.parse(e.getAttribute(hi));e.removeAttribute(hi);for(let r in n){let o=n[r];e.setAttribute(r,o)}}catch{}}),t.innerHTML.replace(ra,"")}};var sa=function(i,t){let e=oa[t];if(e)return e(i);throw new Error("unknown content type: ".concat(t))};var aa=Object.freeze({__proto__:null}),E=class extends S{constructor(t,e){super(...arguments),this.attachmentManager=t,this.attachment=e,this.id=this.attachment.id,this.file=this.attachment.file}remove(){return this.attachmentManager.requestRemovalOfAttachment(this.attachment)}};E.proxyMethod("attachment.getAttribute");E.proxyMethod("attachment.hasAttribute");E.proxyMethod("attachment.setAttribute");E.proxyMethod("attachment.getAttributes");E.proxyMethod("attachment.setAttributes");E.proxyMethod("attachment.isPending");E.proxyMethod("attachment.isPreviewable");E.proxyMethod("attachment.getURL");E.proxyMethod("attachment.getPreviewURL");E.proxyMethod("attachment.setPreviewURL");E.proxyMethod("attachment.getHref");E.proxyMethod("attachment.getFilename");E.proxyMethod("attachment.getFilesize");E.proxyMethod("attachment.getFormattedFilesize");E.proxyMethod("attachment.getExtension");E.proxyMethod("attachment.getContentType");E.proxyMethod("attachment.getFile");E.proxyMethod("attachment.setFile");E.proxyMethod("attachment.releaseFile");E.proxyMethod("attachment.getUploadProgress");E.proxyMethod("attachment.setUploadProgress");var $e=class extends S{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];super(...arguments),this.managedAttachments={},Array.from(t).forEach(e=>{this.manageAttachment(e)})}getAttachments(){let t=[];for(let e in this.managedAttachments){let n=this.managedAttachments[e];t.push(n)}return t}manageAttachment(t){return this.managedAttachments[t.id]||(this.managedAttachments[t.id]=new E(this,t)),this.managedAttachments[t.id]}attachmentIsManaged(t){return t.id in this.managedAttachments}requestRemovalOfAttachment(t){if(this.attachmentIsManaged(t)){var e,n;return(e=this.delegate)===null||e===void 0||(n=e.attachmentManagerDidRequestRemovalOfAttachment)===null||n===void 0?void 0:n.call(e,t)}}unmanageAttachment(t){let e=this.managedAttachments[t.id];return delete this.managedAttachments[t.id],e}},tn=class{constructor(t){this.composition=t,this.document=this.composition.document;let e=this.composition.getSelectedRange();this.startPosition=e[0],this.endPosition=e[1],this.startLocation=this.document.locationFromPosition(this.startPosition),this.endLocation=this.do
|
||
|
|
`}shouldBreakFormattedBlock(){return this.block.hasAttributes()&&!this.block.isListItem()&&(this.breaksOnReturn&&this.nextCharacter===`
|
||
|
|
`||this.previousCharacter===`
|
||
|
|
`)}shouldDecreaseListLevel(){return this.block.hasAttributes()&&this.block.isListItem()&&this.block.isEmpty()}shouldPrependListItem(){return this.block.isListItem()&&this.startLocation.offset===0&&!this.block.isEmpty()}shouldRemoveLastBlockAttribute(){return this.block.hasAttributes()&&!this.block.isListItem()&&this.block.isEmpty()}},Dr=" ",it=class extends S{constructor(){super(...arguments),this.document=new G,this.attachments=[],this.currentAttributes={},this.revision=0}setDocument(t){if(!t.isEqualTo(this.document)){var e,n;return this.document=t,this.refreshAttachments(),this.revision++,(e=this.delegate)===null||e===void 0||(n=e.compositionDidChangeDocument)===null||n===void 0?void 0:n.call(e,t)}}getSnapshot(){return{document:this.document,selectedRange:this.getSelectedRange()}}loadSnapshot(t){var e,n,r,o;let{document:s,selectedRange:l}=t;return(e=this.delegate)===null||e===void 0||(n=e.compositionWillLoadSnapshot)===null||n===void 0||n.call(e),this.setDocument(s??new G),this.setSelection(l??[0,0]),(r=this.delegate)===null||r===void 0||(o=r.compositionDidLoadSnapshot)===null||o===void 0?void 0:o.call(r)}insertText(t){let{updatePosition:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{updatePosition:!0},n=this.getSelectedRange();this.setDocument(this.document.insertTextAtRange(t,n));let r=n[0],o=r+t.getLength();return e&&this.setSelection(o),this.notifyDelegateOfInsertionAtRange([r,o])}insertBlock(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Y,e=new G([t]);return this.insertDocument(e)}insertDocument(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new G,e=this.getSelectedRange();this.setDocument(this.document.insertDocumentAtRange(t,e));let n=e[0],r=n+t.getLength();return this.setSelection(r),this.notifyDelegateOfInsertionAtRange([n,r])}insertString(t,e){let n=this.getCurrentTextAttributes(),r=K.textForStringWithAttributes(t,n);return this.insertText(r,e)}insertBlockBreak(){let t=this.getSelectedRange();this.setDocument(this.document.insertBlockBreakAtRange(t));let e=t[0],n=e+1;return this.setSelection(n),this.notifyDelegateOfInsertionAtRange([e,n])}insertLineBreak(){let t=new tn(this);if(t.shouldDecreaseListLevel())return this.decreaseListLevel(),this.setSelection(t.startPosition);if(t.shouldPrependListItem()){let e=new G([t.block.copyWithoutText()]);return this.insertDocument(e)}else return t.shouldInsertBlockBreak()?this.insertBlockBreak():t.shouldRemoveLastBlockAttribute()?this.removeLastBlockAttribute():t.shouldBreakFormattedBlock()?this.breakFormattedBlock(t):this.insertString(`
|
||
|
|
`)}insertHTML(t){let e=Mt.parse(t,{purifyOptions:{SAFE_FOR_XML:!0}}).getDocument(),n=this.getSelectedRange();this.setDocument(this.document.mergeDocumentAtRange(e,n));let r=n[0],o=r+e.getLength()-1;return this.setSelection(o),this.notifyDelegateOfInsertionAtRange([r,o])}replaceHTML(t){let e=Mt.parse(t).getDocument().copyUsingObjectsFromDocument(this.document),n=this.getLocationRange({strict:!1}),r=this.document.rangeFromLocationRange(n);return this.setDocument(e),this.setSelection(r)}insertFile(t){return this.insertFiles([t])}insertFiles(t){let e=[];return Array.from(t).forEach(n=>{var r;if((r=this.delegate)!==null&&r!==void 0&&r.compositionShouldAcceptFile(n)){let o=At.attachmentForFile(n);e.push(o)}}),this.insertAttachments(e)}insertAttachment(t){return this.insertAttachments([t])}insertAttachments(t){let e=new K;return Array.from(t).forEach(n=>{var r;let o=n.getType(),s=(r=yi[o])===null||r===void 0?void 0:r.presentation,l=this.getCurrentTextAttributes();s&&(l.presentation=s);let c=K.textForAttachmentWithAttributes(n,l);e=e.appendText(c)}),this.insertText(e)}shouldManageDeletingInDirection(t){let e=this.getLocationRange();if(ut(e)){if(t==="backward"&&e[0].offset===0||this.shouldManageMovingCursorInDirection(t))return!0}else if(e[0].index!==e[1].index)return!0;return!1}deleteInDirection(t){let{length:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n,r,o,s=this.getLocationRange(),l=this.getSelectedRange(),c=ut(l);if(c?r=t==="backward"&&s[0].offset===0:o=s[0].index!==s[1].index,r&&this.canDecreaseBlockAttributeLevel()){let d=this.getBlock();if(d.isListItem()?this.decreaseListLevel():this.decreaseBlockAttributeLevel(),this.setSelection(l[0]),d.isEmpty())return!1}if(c&&(l=this.getExpandedRangeInDirection(t,{length:e}),t==="backward"&&(n=this.getAttachmentAtRange(l))),n)return this.editAttachment(n),!1;if(this.setDocument(this.document.removeTextAtRange(l)),this.setSelection(l[0]),r||o)return!1}moveTextFromRange(t){let[e]=Array.from(this.getSelectedRange());return this.setDocument(this.document.moveTextFromRangeToPosition(t,e)),this.setSelection(e)}removeAttachment(t){let e=this.document.getRangeOfAttachment(t);if(e)return this.stopEditingAttachment(),this.setDocument(this.document.removeTextAtRange(e)),this.setSelection(e[0])}removeLastBlockAttribute(){let[t,e]=Array.from(this.getSelectedRange()),n=this.document.getBlockAtPosition(e);return this.removeCurrentAttribute(n.getLastAttribute()),this.setSelection(t)}insertPlaceholder(){return this.placeholderPosition=this.getPosition(),this.insertString(Dr)}selectPlaceholder(){if(this.placeholderPosition!=null)return this.setSelectedRange([this.placeholderPosition,this.placeholderPosition+Dr.length]),this.getSelectedRange()}forgetPlaceholder(){this.placeholderPosition=null}hasCurrentAttribute(t){let e=this.currentAttributes[t];return e!=null&&e!==!1}toggleCurrentAttribute(t){let e=!this.currentAttributes[t];return e?this.setCurrentAttribute(t,e):this.removeCurrentAttribute(t)}canSetCurrentAttribute(t){return D(t)?this.canSetCurrentBlockAttribute(t):this.canSetCurrentTextAttribute(t)}canSetCurrentTextAttribute(t){let e=this.getSelectedDocument();if(!!e){for(let n of Array.from(e.getAttachments()))if(!n.hasContent())return!1;return!0}}canSetCurrentBlockAttribute(t){let e=this.getBlock();if(!!e)return!e.isTerminalBlock()}setCurrentAttribute(t,e){return D(t)?this.setBlockAttribute(t,e):(this.setTextAttribute(t,e),this.currentAttributes[t]=e,this.notifyDelegateOfCurrentAttributesChange())}setHTMLAtributeAtPosition(t,e,n){var r;let o=this.document.getBlockAtPosition(t),s=(r=D(o.getLastAttribute()))===null||r===void 0?void 0:r.htmlAttributes;if(o&&s!==null&&s!==void 0&&s.includes(e)){let l=this.document.setHTMLAttributeAtPosition(t,e,n);this.setDocument(l)}}setTextAttribute(t,e){let n=this.getSelectedRange();if(!n)return;let[r,o]=Array.from(n);if(r===o){if(t==="href"){let s=K.textForStringWithAttributes(e,{href:e});return this.insertText(s)}}else return this.setDocument(this.document.addAttributeAtRange(t,e,n))}setBlockAttribute(t,e){let n=this.getSelectedRange();if(this.c
|
||
|
|
`?r+=1:e=e.removeTextAtRange(o),o=[r,r]):t.nextCharacter===`
|
||
|
|
`?t.previousCharacter===`
|
||
|
|
`?o=[r-1,r+1]:(o=[r,r+1],r+=1):t.startLocation.offset-1!==0&&(r+=1);let s=new G([n.removeLastAttribute().copyWithoutText()]);return this.setDocument(e.insertDocumentAtRange(s,o)),this.setSelection(r)}getPreviousBlock(){let t=this.getLocationRange();if(t){let{index:e}=t[0];if(e>0)return this.document.getBlockAtIndex(e-1)}}getBlock(){let t=this.getLocationRange();if(t)return this.document.getBlockAtIndex(t[0].index)}getAttachmentAtRange(t){let e=this.document.getDocumentAtRange(t);if(e.toString()==="".concat(Ai,`
|
||
|
|
`))return e.getAttachments()[0]}notifyDelegateOfCurrentAttributesChange(){var t,e;return(t=this.delegate)===null||t===void 0||(e=t.compositionDidChangeCurrentAttributes)===null||e===void 0?void 0:e.call(t,this.currentAttributes)}notifyDelegateOfInsertionAtRange(t){var e,n;return(e=this.delegate)===null||e===void 0||(n=e.compositionDidPerformInsertionAtRange)===null||n===void 0?void 0:n.call(e,t)}translateUTF16PositionFromOffset(t,e){let n=this.document.toUTF16String(),r=n.offsetFromUCS2Offset(t);return n.offsetToUCS2Offset(r+e)}};it.proxyMethod("getSelectionManager().getPointRange");it.proxyMethod("getSelectionManager().setLocationRangeFromPointRange");it.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange");it.proxyMethod("getSelectionManager().locationIsCursorTarget");it.proxyMethod("getSelectionManager().selectionIsExpanded");it.proxyMethod("delegate?.getSelectionManager");var Ce=class extends S{constructor(t){super(...arguments),this.composition=t,this.undoEntries=[],this.redoEntries=[]}recordUndoEntry(t){let{context:e,consolidatable:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.undoEntries.slice(-1)[0];if(!n||!la(r,t,e)){let o=this.createEntry({description:t,context:e});this.undoEntries.push(o),this.redoEntries=[]}}undo(){let t=this.undoEntries.pop();if(t){let e=this.createEntry(t);return this.redoEntries.push(e),this.composition.loadSnapshot(t.snapshot)}}redo(){let t=this.redoEntries.pop();if(t){let e=this.createEntry(t);return this.undoEntries.push(e),this.composition.loadSnapshot(t.snapshot)}}canUndo(){return this.undoEntries.length>0}canRedo(){return this.redoEntries.length>0}createEntry(){let{description:t,context:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{description:t?.toString(),context:JSON.stringify(e),snapshot:this.composition.getSnapshot()}}},la=(i,t,e)=>i?.description===t?.toString()&&i?.context===JSON.stringify(e),Kn="attachmentGallery",ca="presentation",ua="gallery",en=class{constructor(t){this.document=t.document,this.selectedRange=t.selectedRange}perform(){return this.removeBlockAttribute(),this.applyBlockAttribute()}getSnapshot(){return{document:this.document,selectedRange:this.selectedRange}}removeBlockAttribute(){return this.findRangesOfBlocks().map(t=>this.document=this.document.removeAttributeAtRange(Kn,t))}applyBlockAttribute(){let t=0;this.findRangesOfPieces().forEach(e=>{e[1]-e[0]>1&&(e[0]+=t,e[1]+=t,this.document.getCharacterAtPosition(e[1])!==`
|
||
|
|
`&&(this.document=this.document.insertBlockBreakAtRange(e[1]),e[1]<this.selectedRange[1]&&this.moveSelectedRangeForward(),e[1]++,t++),e[0]!==0&&this.document.getCharacterAtPosition(e[0]-1)!==`
|
||
|
|
`&&(this.document=this.document.insertBlockBreakAtRange(e[0]),e[0]<this.selectedRange[0]&&this.moveSelectedRangeForward(),e[0]++,t++),this.document=this.document.applyBlockAttributeAtRange(Kn,!0,e))})}findRangesOfBlocks(){return this.document.findRangesForBlockAttribute(Kn)}findRangesOfPieces(){return this.document.findRangesForTextAttribute(ca,{withValue:ua})}moveSelectedRangeForward(){this.selectedRange[0]+=1,this.selectedRange[1]+=1}},ro=function(i){let t=new en(i);return t.perform(),t.getSnapshot()},da=[ro],nn=class{constructor(t,e,n){this.insertFiles=this.insertFiles.bind(this),this.composition=t,this.selectionManager=e,this.element=n,this.undoManager=new Ce(this.composition),this.filters=da.slice(0)}loadDocument(t){return this.loadSnapshot({document:t,selectedRange:[0,0]})}loadHTML(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",e=Mt.parse(t,{referenceElement:this.element}).getDocument();return this.loadDocument(e)}loadJSON(t){let{document:e,selectedRange:n}=t;return e=G.fromJSON(e),this.loadSnapshot({document:e,selectedRange:n})}loadSnapshot(t){return this.undoManager=new Ce(this.composition),this.composition.loadSnapshot(t)}getDocument(){return this.composition.document}getSelectedDocument(){return this.composition.getSelectedDocument()}getSnapshot(){return this.composition.getSnapshot()}toJSON(){return this.getSnapshot()}deleteInDirection(t){return this.composition.deleteInDirection(t)}insertAttachment(t){return this.composition.insertAttachment(t)}insertAttachments(t){return this.composition.insertAttachments(t)}insertDocument(t){return this.composition.insertDocument(t)}insertFile(t){return this.composition.insertFile(t)}insertFiles(t){return this.composition.insertFiles(t)}insertHTML(t){return this.composition.insertHTML(t)}insertString(t){return this.composition.insertString(t)}insertText(t){return this.composition.insertText(t)}insertLineBreak(){return this.composition.insertLineBreak()}getSelectedRange(){return this.composition.getSelectedRange()}getPosition(){return this.composition.getPosition()}getClientRectAtPosition(t){let e=this.getDocument().locationRangeFromRange([t,t+1]);return this.selectionManager.getClientRectAtLocationRange(e)}expandSelectionInDirection(t){return this.composition.expandSelectionInDirection(t)}moveCursorInDirection(t){return this.composition.moveCursorInDirection(t)}setSelectedRange(t){return this.composition.setSelectedRange(t)}activateAttribute(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return this.composition.setCurrentAttribute(t,e)}attributeIsActive(t){return this.composition.hasCurrentAttribute(t)}canActivateAttribute(t){return this.composition.canSetCurrentAttribute(t)}deactivateAttribute(t){return this.composition.removeCurrentAttribute(t)}setHTMLAtributeAtPosition(t,e,n){this.composition.setHTMLAtributeAtPosition(t,e,n)}canDecreaseNestingLevel(){return this.composition.canDecreaseNestingLevel()}canIncreaseNestingLevel(){return this.composition.canIncreaseNestingLevel()}decreaseNestingLevel(){if(this.canDecreaseNestingLevel())return this.composition.decreaseNestingLevel()}increaseNestingLevel(){if(this.canIncreaseNestingLevel())return this.composition.increaseNestingLevel()}canRedo(){return this.undoManager.canRedo()}canUndo(){return this.undoManager.canUndo()}recordUndoEntry(t){let{context:e,consolidatable:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.undoManager.recordUndoEntry(t,{context:e,consolidatable:n})}redo(){if(this.canRedo())return this.undoManager.redo()}undo(){if(this.canUndo())return this.undoManager.undo()}},rn=class{constructor(t){this.element=t}findLocationFromContainerAndOffset(t,e){let{strict:n}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{strict:!0},r=0,o=!1,s={index:0,offset:0},l=this.findAttachmentElementParentForNode(t);l&&(t=l.parentNode,e=On(l));let c=He(this.element,{usingFilter:oo});for(;c.nextNode();){let d=c.currentNode;if(d===t&&be(t)){Kt(d)||(s.offset+=e);break}else{if(d.parentNode===t){if(r++===e)break}else if(!kt(t,d)&&r>0)break;er(d,{strict:n})?(o&&s.index+
|
||
|
|
`]):(t=fi(n),e=fi(r));let s=t.filter((c,d)=>c!==e[d]).map(ge),l=e.filter((c,d)=>c!==t[d]).map(ge);return{additions:s,deletions:l}}getTextChangesFromCharacterData(){let t,e,n=this.getMutationsByType("characterData");if(n.length){let r=n[0],o=n[n.length-1],s=ge(r.oldValue),l=ge(o.target.data),c=ns(s,l);t=c.added,e=c.removed}return{additions:t?[t]:[],deletions:e?[e]:[]}}},fi=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=[];for(let e of Array.from(i))switch(e.nodeType){case Node.TEXT_NODE:t.push(e.data);break;case Node.ELEMENT_NODE:W(e)==="br"?t.push(`
|
||
|
|
`):t.push(...Array.from(fi(e.childNodes)||[]));break}return t},un=class extends Yt{constructor(t){super(...arguments),this.file=t}perform(t){let e=new FileReader;return e.onerror=()=>t(!1),e.onload=()=>{e.onerror=null;try{e.abort()}catch{}return t(!0,this.file)},e.readAsArrayBuffer(this.file)}},gi=class{constructor(t){this.element=t}shouldIgnore(t){return Se.samsungAndroid?(this.previousEvent=this.event,this.event=t,this.checkSamsungKeyboardBuggyModeStart(),this.checkSamsungKeyboardBuggyModeEnd(),this.buggyMode):!1}checkSamsungKeyboardBuggyModeStart(){this.insertingLongTextAfterUnidentifiedChar()&&va(this.element.innerText,this.event.data)&&(this.buggyMode=!0,this.event.preventDefault())}checkSamsungKeyboardBuggyModeEnd(){this.buggyMode&&this.event.inputType!=="insertText"&&(this.buggyMode=!1)}insertingLongTextAfterUnidentifiedChar(){var t;return this.isBeforeInputInsertText()&&this.previousEventWasUnidentifiedKeydown()&&((t=this.event.data)===null||t===void 0?void 0:t.length)>50}isBeforeInputInsertText(){return this.event.type==="beforeinput"&&this.event.inputType==="insertText"}previousEventWasUnidentifiedKeydown(){var t,e;return((t=this.previousEvent)===null||t===void 0?void 0:t.type)==="keydown"&&((e=this.previousEvent)===null||e===void 0?void 0:e.key)==="Unidentified"}},va=(i,t)=>Lr(i)===Lr(t),ya=new RegExp("(".concat(Ai,"|").concat(fn,"|").concat(bt,"|\\s)+"),"g"),Lr=i=>i.replace(ya," ").trim(),$t=class extends S{constructor(t){super(...arguments),this.element=t,this.mutationObserver=new cn(this.element),this.mutationObserver.delegate=this,this.flakyKeyboardDetector=new gi(this.element);for(let e in this.constructor.events)C(e,{onElement:this.element,withCallback:this.handlerFor(e)})}elementDidMutate(t){}editorWillSyncDocumentView(){return this.mutationObserver.stop()}editorDidSyncDocumentView(){return this.mutationObserver.start()}requestRender(){var t,e;return(t=this.delegate)===null||t===void 0||(e=t.inputControllerDidRequestRender)===null||e===void 0?void 0:e.call(t)}requestReparse(){var t,e;return(t=this.delegate)===null||t===void 0||(e=t.inputControllerDidRequestReparse)===null||e===void 0||e.call(t),this.requestRender()}attachFiles(t){let e=Array.from(t).map(n=>new un(n));return Promise.all(e).then(n=>{this.handleInput(function(){var r,o;return(r=this.delegate)===null||r===void 0||r.inputControllerWillAttachFiles(),(o=this.responder)===null||o===void 0||o.insertFiles(n),this.requestRender()})})}handlerFor(t){return e=>{e.defaultPrevented||this.handleInput(()=>{if(!Ei(this.element)){if(this.flakyKeyboardDetector.shouldIgnore(e))return;this.eventName=t,this.constructor.events[t].call(this,e)}})}}handleInput(t){try{var e;(e=this.delegate)===null||e===void 0||e.inputControllerWillHandleInput(),t.call(this)}finally{var n;(n=this.delegate)===null||n===void 0||n.inputControllerDidHandleInput()}}createLinkHTML(t,e){let n=document.createElement("a");return n.href=t,n.textContent=e||t,n.outerHTML}};B($t,"events",{});var Zn,Or,{browser:Aa,keyNames:lo}=Te,xa=0,et=class extends $t{constructor(){super(...arguments),this.resetInputSummary()}setInputSummary(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.inputSummary.eventName=this.eventName;for(let e in t){let n=t[e];this.inputSummary[e]=n}return this.inputSummary}resetInputSummary(){this.inputSummary={}}reset(){return this.resetInputSummary(),It.reset()}elementDidMutate(t){if(this.isComposing()){var e,n;return(e=this.delegate)===null||e===void 0||(n=e.inputControllerDidAllowUnhandledInput)===null||n===void 0?void 0:n.call(e)}else return this.handleInput(function(){return this.mutationIsSignificant(t)&&(this.mutationIsExpected(t)?this.requestRender():this.requestReparse()),this.reset()})}mutationIsExpected(t){let{textAdded:e,textDeleted:n}=t;if(this.inputSummary.preferDocument)return!0;let r=e!=null?e===this.inputSummary.textAdded:!this.inputSummary.textAdded,o=n!=null?this.inputSummary.didDelete:!this.inputSummary.didDelete,s=[`
|
||
|
|
`,`
|
||
|
|
`].includes(e)&&!r,l=n===`
|
||
|
|
`&&!o;if(s&&!l||l&&!s){let g=this.getSelectedRange();if(g){var d;let x=s?e.replace(/\n$/,"").length||-1:e?.length||1;if((d=this.responder)!==null&&d!==void 0&&d.positionIsBlockBreak(g[1]+x))return!0}}return r&&o}mutationIsSignificant(t){var e;let n=Object.keys(t).length>0,r=((e=this.compositionInput)===null||e===void 0?void 0:e.getEndData())==="";return n||!r}getCompositionInput(){if(this.isComposing())return this.compositionInput;this.compositionInput=new rt(this)}isComposing(){return this.compositionInput&&!this.compositionInput.isEnded()}deleteInDirection(t,e){var n;if(((n=this.responder)===null||n===void 0?void 0:n.deleteInDirection(t))===!1){if(e)return e.preventDefault(),this.requestRender()}else return this.setInputSummary({didDelete:!0})}serializeSelectionToDataTransfer(t){var e;if(!Qo(t))return;let n=(e=this.responder)===null||e===void 0?void 0:e.getSelectedDocument().toSerializableDocument();return t.setData("application/x-trix-document",JSON.stringify(n)),t.setData("text/html",Zt.render(n).innerHTML),t.setData("text/plain",n.toString().replace(/\n$/,"")),!0}canAcceptDataTransfer(t){let e={};return Array.from(t?.types||[]).forEach(n=>{e[n]=!0}),e.Files||e["application/x-trix-document"]||e["text/html"]||e["text/plain"]}getPastedHTMLUsingHiddenElement(t){let e=this.getSelectedRange(),n={position:"absolute",left:"".concat(window.pageXOffset,"px"),top:"".concat(window.pageYOffset,"px"),opacity:0},r=p({style:n,tagName:"div",editable:!0});return document.body.appendChild(r),r.focus(),requestAnimationFrame(()=>{let o=r.innerHTML;return yt(r),this.setSelectedRange(e),t(o)})}};B(et,"events",{keydown(i){this.isComposing()||this.resetInputSummary(),this.inputSummary.didInput=!0;let t=lo[i.keyCode];if(t){var e;let r=this.keys;["ctrl","alt","shift","meta"].forEach(o=>{if(i["".concat(o,"Key")]){var s;o==="ctrl"&&(o="control"),r=(s=r)===null||s===void 0?void 0:s[o]}}),((e=r)===null||e===void 0?void 0:e[t])!=null&&(this.setInputSummary({keyName:t}),It.reset(),r[t].call(this,i))}if(qr(i)){let r=String.fromCharCode(i.keyCode).toLowerCase();if(r){var n;let o=["alt","shift"].map(s=>{if(i["".concat(s,"Key")])return s}).filter(s=>s);o.push(r),(n=this.delegate)!==null&&n!==void 0&&n.inputControllerDidReceiveKeyboardCommand(o)&&i.preventDefault()}}},keypress(i){if(this.inputSummary.eventName!=null||i.metaKey||i.ctrlKey&&!i.altKey)return;let t=Ca(i);if(t){var e,n;return(e=this.delegate)===null||e===void 0||e.inputControllerWillPerformTyping(),(n=this.responder)===null||n===void 0||n.insertString(t),this.setInputSummary({textAdded:t,didDelete:this.selectionIsExpanded()})}},textInput(i){let{data:t}=i,{textAdded:e}=this.inputSummary;if(e&&e!==t&&e.toUpperCase()===t){var n;let r=this.getSelectedRange();return this.setSelectedRange([r[0],r[1]+e.length]),(n=this.responder)===null||n===void 0||n.insertString(t),this.setInputSummary({textAdded:t}),this.setSelectedRange(r)}},dragenter(i){i.preventDefault()},dragstart(i){var t,e;return this.serializeSelectionToDataTransfer(i.dataTransfer),this.draggedRange=this.getSelectedRange(),(t=this.delegate)===null||t===void 0||(e=t.inputControllerDidStartDrag)===null||e===void 0?void 0:e.call(t)},dragover(i){if(this.draggedRange||this.canAcceptDataTransfer(i.dataTransfer)){i.preventDefault();let n={x:i.clientX,y:i.clientY};if(!ee(n,this.draggingPoint)){var t,e;return this.draggingPoint=n,(t=this.delegate)===null||t===void 0||(e=t.inputControllerDidReceiveDragOverPoint)===null||e===void 0?void 0:e.call(t,this.draggingPoint)}}},dragend(i){var t,e;(t=this.delegate)===null||t===void 0||(e=t.inputControllerDidCancelDrag)===null||e===void 0||e.call(t),this.draggedRange=null,this.draggingPoint=null},drop(i){var t,e;i.preventDefault();let n=(t=i.dataTransfer)===null||t===void 0?void 0:t.files,r=i.dataTransfer.getData("application/x-trix-document"),o={x:i.clientX,y:i.clientY};if((e=this.responder)===null||e===void 0||e.setLocationRangeFromPointRange(o),n!=null&&n.length)this.attachFiles(n);else if(this.draggedRange){var s,l;(s=this.delegate)===null||s===void 0||s.inputControllerWillMoveText(),(l=this.responder)==
|
||
|
|
`,{updatePosition:!1}),this.requestRender()}},shift:{return(i){var t,e;(t=this.delegate)===null||t===void 0||t.inputControllerWillPerformTyping(),(e=this.responder)===null||e===void 0||e.insertString(`
|
||
|
|
`),this.requestRender(),i.preventDefault()},tab(i){var t;if((t=this.responder)!==null&&t!==void 0&&t.canDecreaseNestingLevel()){var e;(e=this.responder)===null||e===void 0||e.decreaseNestingLevel(),this.requestRender(),i.preventDefault()}},left(i){if(this.selectionIsInCursorTarget())return i.preventDefault(),this.expandSelectionInDirection("backward")},right(i){if(this.selectionIsInCursorTarget())return i.preventDefault(),this.expandSelectionInDirection("forward")}},alt:{backspace(i){var t;return this.setInputSummary({preferDocument:!1}),(t=this.delegate)===null||t===void 0?void 0:t.inputControllerWillPerformTyping()}},meta:{backspace(i){var t;return this.setInputSummary({preferDocument:!1}),(t=this.delegate)===null||t===void 0?void 0:t.inputControllerWillPerformTyping()}}});et.proxyMethod("responder?.getSelectedRange");et.proxyMethod("responder?.setSelectedRange");et.proxyMethod("responder?.expandSelectionInDirection");et.proxyMethod("responder?.selectionIsInCursorTarget");et.proxyMethod("responder?.selectionIsExpanded");var Ea=i=>{var t;return(t=i.type)===null||t===void 0||(t=t.match(/\/(\w+)$/))===null||t===void 0?void 0:t[1]},wa=!!((Zn=(Or=" ").codePointAt)!==null&&Zn!==void 0&&Zn.call(Or,0)),Ca=function(i){if(i.key&&wa&&i.key.codePointAt(0)===i.keyCode)return i.key;{let t;if(i.which===null?t=i.keyCode:i.which!==0&&i.charCode!==0&&(t=i.charCode),t!=null&&lo[t]!=="escape")return Ot.fromCodepoints([t]).toString()}},Sa=function(i){let t=i.clipboardData;if(t)if(t.types.includes("text/html")){for(let e of t.types){let n=/^CorePasteboardFlavorType/.test(e),r=/^dyn\./.test(e)&&t.getData(e);if(n||r)return!0}return!1}else{let e=t.types.includes("com.apple.webarchive"),n=t.types.includes("com.apple.flat-rtfd");return e||n}},rt=class extends S{constructor(t){super(...arguments),this.inputController=t,this.responder=this.inputController.responder,this.delegate=this.inputController.delegate,this.inputSummary=this.inputController.inputSummary,this.data={}}start(t){if(this.data.start=t,this.isSignificant()){var e;if(this.inputSummary.eventName==="keypress"&&this.inputSummary.textAdded){var n;(n=this.responder)===null||n===void 0||n.deleteInDirection("left")}this.selectionIsExpanded()||(this.insertPlaceholder(),this.requestRender()),this.range=(e=this.responder)===null||e===void 0?void 0:e.getSelectedRange()}}update(t){if(this.data.update=t,this.isSignificant()){let e=this.selectPlaceholder();e&&(this.forgetPlaceholder(),this.range=e)}}end(t){if(this.data.end=t,this.isSignificant()){if(this.forgetPlaceholder(),this.canApplyToDocument()){var e,n,r,o;return this.setInputSummary({preferDocument:!0,didInput:!1}),(e=this.delegate)===null||e===void 0||e.inputControllerWillPerformTyping(),(n=this.responder)===null||n===void 0||n.setSelectedRange(this.range),(r=this.responder)===null||r===void 0||r.insertString(this.data.end),(o=this.responder)===null||o===void 0?void 0:o.setSelectedRange(this.range[0]+this.data.end.length)}else if(this.data.start!=null||this.data.update!=null)return this.requestReparse(),this.inputController.reset()}else return this.inputController.reset()}getEndData(){return this.data.end}isEnded(){return this.getEndData()!=null}isSignificant(){return Aa.composesExistingText?this.inputSummary.didInput:!0}canApplyToDocument(){var t,e;return((t=this.data.start)===null||t===void 0?void 0:t.length)===0&&((e=this.data.end)===null||e===void 0?void 0:e.length)>0&&this.range}};rt.proxyMethod("inputController.setInputSummary");rt.proxyMethod("inputController.requestRender");rt.proxyMethod("inputController.requestReparse");rt.proxyMethod("responder?.selectionIsExpanded");rt.proxyMethod("responder?.insertPlaceholder");rt.proxyMethod("responder?.selectPlaceholder");rt.proxyMethod("responder?.forgetPlaceholder");var Ft=class extends $t{constructor(){super(...arguments),this.render=this.render.bind(this)}elementDidMutate(){if(this.scheduledRender){if(this.composing){var t,e;return(t=this.delegate)===null||t===void 0||(e=t.inputControllerDidAllowUnhandledInput)===null||e===void 0?void 0:e.call(t)}}else return this.reparse()}scheduleRen
|
||
|
|
`)},insertLink(){return this.activateAttributeIfSupported("href",this.event.data)},insertOrderedList(){return this.toggleAttributeIfSupported("number")},insertParagraph(){var i;return(i=this.delegate)===null||i===void 0||i.inputControllerWillPerformTyping(),this.withTargetDOMRange(function(){var t;return(t=this.responder)===null||t===void 0?void 0:t.insertLineBreak()})},insertReplacementText(){let i=this.event.dataTransfer.getData("text/plain"),t=this.event.getTargetRanges()[0];this.withTargetDOMRange(t,()=>{this.insertString(i,{updatePosition:!1})})},insertText(){var i;return this.insertString(this.event.data||((i=this.event.dataTransfer)===null||i===void 0?void 0:i.getData("text/plain")))},insertTranspose(){return this.insertString(this.event.data)},insertUnorderedList(){return this.toggleAttributeIfSupported("bullet")}});var Ta=function(i){let t=document.createRange();return t.setStart(i.startContainer,i.startOffset),t.setEnd(i.endContainer,i.endOffset),t},Qn=i=>{var t;return Array.from(((t=i.dataTransfer)===null||t===void 0?void 0:t.types)||[]).includes("Files")},ka=i=>{var t;return((t=i.dataTransfer.files)===null||t===void 0?void 0:t[0])&&!co(i)&&!Zo(i)},co=function(i){let t=i.clipboardData;if(t)return Array.from(t.types).filter(n=>n.match(/file/i)).length===t.types.length&&t.files.length>=1},Ra=function(i){let t=i.clipboardData;if(t)return t.types.includes("text/plain")&&t.types.length===1},Da=function(i){let t=[];return i.altKey&&t.push("alt"),i.shiftKey&&t.push("shift"),t.push(i.key),t},$n=i=>({x:i.clientX,y:i.clientY}),mi="[data-trix-attribute]",pi="[data-trix-action]",La="".concat(mi,", ").concat(pi),mn="[data-trix-dialog]",Oa="".concat(mn,"[data-trix-active]"),Pa="".concat(mn," [data-trix-method]"),Pr="".concat(mn," [data-trix-input]"),Ir=(i,t)=>(t||(t=qt(i)),i.querySelector("[data-trix-input][name='".concat(t,"']"))),Mr=i=>i.getAttribute("data-trix-action"),qt=i=>i.getAttribute("data-trix-attribute")||i.getAttribute("data-trix-dialog-attribute"),Ia=i=>i.getAttribute("data-trix-dialog"),dn=class extends S{constructor(t){super(t),this.didClickActionButton=this.didClickActionButton.bind(this),this.didClickAttributeButton=this.didClickAttributeButton.bind(this),this.didClickDialogButton=this.didClickDialogButton.bind(this),this.didKeyDownDialogInput=this.didKeyDownDialogInput.bind(this),this.element=t,this.attributes={},this.actions={},this.resetDialogInputs(),C("mousedown",{onElement:this.element,matchingSelector:pi,withCallback:this.didClickActionButton}),C("mousedown",{onElement:this.element,matchingSelector:mi,withCallback:this.didClickAttributeButton}),C("click",{onElement:this.element,matchingSelector:La,preventDefault:!0}),C("click",{onElement:this.element,matchingSelector:Pa,withCallback:this.didClickDialogButton}),C("keydown",{onElement:this.element,matchingSelector:Pr,withCallback:this.didKeyDownDialogInput})}didClickActionButton(t,e){var n;(n=this.delegate)===null||n===void 0||n.toolbarDidClickButton(),t.preventDefault();let r=Mr(e);if(this.getDialog(r))return this.toggleDialog(r);var o;return(o=this.delegate)===null||o===void 0?void 0:o.toolbarDidInvokeAction(r,e)}didClickAttributeButton(t,e){var n;(n=this.delegate)===null||n===void 0||n.toolbarDidClickButton(),t.preventDefault();let r=qt(e);if(this.getDialog(r))this.toggleDialog(r);else{var o;(o=this.delegate)===null||o===void 0||o.toolbarDidToggleAttribute(r)}return this.refreshAttributeButtons()}didClickDialogButton(t,e){let n=vt(e,{matchingSelector:mn}),r=e.getAttribute("data-trix-method");return this[r].call(this,n)}didKeyDownDialogInput(t,e){if(t.keyCode===13){t.preventDefault();let n=e.getAttribute("name"),r=this.getDialog(n);this.setAttribute(r)}if(t.keyCode===27)return t.preventDefault(),this.hideDialog()}updateActions(t){return this.actions=t,this.refreshActionButtons()}refreshActionButtons(){return this.eachActionButton((t,e)=>{t.disabled=this.actions[e]===!1})}eachActionButton(t){return Array.from(this.element.querySelectorAll(pi)).map(e=>t(e,Mr(e)))}updateAttributes(t){return this.attributes=t,this.refreshAttributeButtons()}refreshAttrib
|
||
|
|
display: block;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t {
|
||
|
|
white-space: nowrap;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t [data-trix-dialog] {
|
||
|
|
display: none;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t [data-trix-dialog][data-trix-active] {
|
||
|
|
display: block;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t [data-trix-dialog] [data-trix-validate]:invalid {
|
||
|
|
background-color: #ffdddd;
|
||
|
|
}`);var hn=class extends HTMLElement{connectedCallback(){this.innerHTML===""&&(this.innerHTML=Ur.getDefaultHTML())}get editorElements(){if(this.id){var t;let e=(t=this.ownerDocument)===null||t===void 0?void 0:t.querySelectorAll('trix-editor[toolbar="'.concat(this.id,'"]'));return Array.from(e)}else return[]}get editorElement(){let[t]=this.editorElements;return t}},_a=0,ja=function(i){if(!document.querySelector(":focus")&&i.hasAttribute("autofocus")&&document.querySelector("[autofocus]")===i)return i.focus()},Wa=function(i){if(!i.hasAttribute("contenteditable"))return i.toggleAttribute("contenteditable",!i.disabled),Oo("focus",{onElement:i,withCallback(){return za(i)}})},za=function(i){return Ua(i),Va(i)},Ua=function(i){var t,e;if((t=(e=document).queryCommandSupported)!==null&&t!==void 0&&t.call(e,"enableObjectResizing"))return document.execCommand("enableObjectResizing",!1,!1),C("mscontrolselect",{onElement:i,preventDefault:!0})},Va=function(i){var t,e;if((t=(e=document).queryCommandSupported)!==null&&t!==void 0&&t.call(e,"DefaultParagraphSeparator")){let{tagName:n}=z.default;if(["div","p"].includes(n))return document.execCommand("DefaultParagraphSeparator",!1,n)}},Ha=function(i){if(!i.hasAttribute("role"))return i.setAttribute("role","textbox")},qa=function(i){if(i.hasAttribute("aria-label")||i.hasAttribute("aria-labelledby"))return;let t=function(){let n=Array.from(i.labels).map(r=>{if(!r.contains(i))return r.textContent}).filter(r=>r).join(" ");return n?i.setAttribute("aria-label",n):i.removeAttribute("aria-label")};return t(),C("focus",{onElement:i,withCallback:t})},Fr=function(){return Se.forcesObjectResizing?{display:"inline",width:"auto"}:{display:"inline-block",width:"1px"}}();Vr("trix-editor",`%t {
|
||
|
|
display: block;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t:empty::before {
|
||
|
|
content: attr(placeholder);
|
||
|
|
color: graytext;
|
||
|
|
cursor: text;
|
||
|
|
pointer-events: none;
|
||
|
|
white-space: pre-line;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t a[contenteditable=false] {
|
||
|
|
cursor: text;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t img {
|
||
|
|
max-width: 100%;
|
||
|
|
height: auto;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t `.concat(Rt,` figcaption textarea {
|
||
|
|
resize: none;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t `).concat(Rt,` figcaption textarea.trix-autoresize-clone {
|
||
|
|
position: absolute;
|
||
|
|
left: -9999px;
|
||
|
|
max-height: 0px;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t `).concat(Rt,` figcaption[data-trix-placeholder]:empty::before {
|
||
|
|
content: attr(data-trix-placeholder);
|
||
|
|
color: graytext;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t [data-trix-cursor-target] {
|
||
|
|
display: `).concat(Fr.display,` !important;
|
||
|
|
width: `).concat(Fr.width,` !important;
|
||
|
|
padding: 0 !important;
|
||
|
|
margin: 0 !important;
|
||
|
|
border: none !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t [data-trix-cursor-target=left] {
|
||
|
|
vertical-align: top !important;
|
||
|
|
margin-left: -1px !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
%t [data-trix-cursor-target=right] {
|
||
|
|
vertical-align: bottom !important;
|
||
|
|
margin-right: -1px !important;
|
||
|
|
}`));var $=new WeakMap,je=new WeakMap,fe=new WeakSet,bi=class{constructor(t){js(this,fe),B(this,"value",""),Jt(this,$,{writable:!0,value:void 0}),Jt(this,je,{writable:!0,value:void 0}),this.element=t,ye(this,$,t.attachInternals()),ye(this,je,!1)}connectedCallback(){_e(this,fe,We).call(this)}disconnectedCallback(){}get form(){return v(this,$).form}get name(){return this.element.getAttribute("name")}set name(t){this.element.setAttribute("name",t)}get labels(){return v(this,$).labels}get disabled(){return v(this,je)||this.element.hasAttribute("disabled")}set disabled(t){this.element.toggleAttribute("disabled",t)}get required(){return this.element.hasAttribute("required")}set required(t){this.element.toggleAttribute("required",t),_e(this,fe,We).call(this)}get validity(){return v(this,$).validity}get validationMessage(){return v(this,$).validationMessage}get willValidate(){return v(this,$).willValidate}formDisabledCallback(t){ye(this,je,t)}setFormValue(t){this.value=t,_e(this,fe,We).call(this),v(this,$).setFormValue(this.element.disabled?void 0:this.value)}checkValidity(){return v(this,$).checkValidity()}reportValidity(){return v(this,$).reportValidity()}setCustomValidity(t){_e(this,fe,We).call(this,t)}};function We(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",{required:t,value:e}=this.element,n=t&&!e,r=!!i,o=p("input",{required:t}),s=i||o.validationMessage;v(this,$).setValidity({valueMissing:n,customError:r},s)}var ti=new WeakMap,ei=new WeakMap,ni=new WeakMap,vi=class{constructor(t){Jt(this,ti,{writable:!0,value:void 0}),Jt(this,ei,{writable:!0,value:e=>{e.defaultPrevented||e.target===this.element.form&&this.element.reset()}}),Jt(this,ni,{writable:!0,value:e=>{if(e.defaultPrevented||this.element.contains(e.target))return;let n=vt(e.target,{matchingSelector:"label"});!n||!Array.from(this.labels).includes(n)||this.element.focus()}}),this.element=t}connectedCallback(){ye(this,ti,qa(this.element)),window.addEventListener("reset",v(this,ei),!1),window.addEventListener("click",v(this,ni),!1)}disconnectedCallback(){var t;(t=v(this,ti))===null||t===void 0||t.destroy(),window.removeEventListener("reset",v(this,ei),!1),window.removeEventListener("click",v(this,ni),!1)}get labels(){let t=[];this.element.id&&this.element.ownerDocument&&t.push(...Array.from(this.element.ownerDocument.querySelectorAll("label[for='".concat(this.element.id,"']"))||[]));let e=vt(this.element,{matchingSelector:"label"});return e&&[this.element,null].includes(e.control)&&t.push(e),t}get form(){return console.warn("This browser does not support the .form property for trix-editor elements."),null}get name(){return console.warn("This browser does not support the .name property for trix-editor elements."),null}set name(t){console.warn("This browser does not support the .name property for trix-editor elements.")}get disabled(){return console.warn("This browser does not support the [disabled] attribute for trix-editor elements."),!1}set disabled(t){console.warn("This browser does not support the [disabled] attribute for trix-editor elements.")}get required(){return console.warn("This browser does not support the [required] attribute for trix-editor elements."),!1}set required(t){console.warn("This browser does not support the [required] attribute for trix-editor elements.")}get validity(){return console.warn("This browser does not support the validity property for trix-editor elements."),null}get validationMessage(){return console.warn("This browser does not support the validationMessage property for trix-editor elements."),""}get willValidate(){return console.warn("This browser does not support the willValidate property for trix-editor elements."),!1}formDisabledCallback(t){}setFormValue(t){}checkValidity(){return console.warn("This browser does not support checkValidity() for trix-editor elements."),!0}reportValidity(){return console.warn("This browser does not support reportValidity() for trix-editor elements."),!0}setCustomValidity(t){console.warn("This browser does not support setCustomValidity(validationMessage) for trix-editor elements."
|
||
|
|
/*! @license DOMPurify 3.2.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.7/LICENSE */
|