@blinkk/root-cms 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +2 -2
- package/dist/ui/ui.js +2 -2
- package/package.json +3 -3
package/dist/ui/ui.js
CHANGED
|
@@ -50,7 +50,7 @@ Content-Type: `+c.contentType+`\r
|
|
|
50
50
|
`).map(u=>({level:u.match(/^\s+/)?.[0]?.length||0,type:"remove",text:u.replace(/^\s+/,"").replace(/,$/g,""),comma:u.endsWith(",")})),n=Xr(r,void 0,1,this.options.maxDepth,this.options.undefinedBehavior).split(`
|
|
51
51
|
`).map(u=>({level:u.match(/^\s+/)?.[0]?.length||0,type:"add",text:u.replace(/^\s+/,"").replace(/,$/g,""),comma:u.endsWith(",")}));let c=o.length,d=n.length;o=Ht(o,Array(d).fill(0).map(()=>({...hy}))),n=Ht(n,Array(c).fill(0).map(()=>({...hy})),!0)}else a==="object"?([o,n]=_y(e,r,1,this.options,this.arrayDiffFunc),o.unshift({...V$}),o.push({...$$}),n.unshift({...V$}),n.push({...$$})):a==="array"?[o,n]=this.arrayDiffFunc(e,r,"","",0,this.options):e!==r?this.options.ignoreCase?typeof e=="string"&&typeof r=="string"&&e.toLowerCase()===r.toLowerCase()&&(o=[{level:0,type:"equal",text:e}],n=[{level:0,type:"equal",text:r}]):this.options.showModifications?(o=[{level:0,type:"modify",text:Xr(e,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}],n=[{level:0,type:"modify",text:Xr(r,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}]):(o=[{level:0,type:"remove",text:Xr(e,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)},{...hy}],n=[{...hy},{level:0,type:"add",text:Xr(r,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}]):(o=[{level:0,type:"equal",text:Xr(e,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}],n=[{level:0,type:"equal",text:Xr(r,void 0,void 0,this.options.maxDepth,this.options.undefinedBehavior)}]);return this.sortResultLines(o,n),this.calculateLineNumbers(o),this.calculateLineNumbers(n),this.calculateCommas(o),this.calculateCommas(n),[o,n]}constructor({detectCircular:e=!0,maxDepth:r=1/0,showModifications:o=!0,arrayDiffMethod:n="normal",ignoreCase:a=!1,ignoreCaseForKey:i=!1,recursiveEqual:s=!1,preserveKeyOrder:l,undefinedBehavior:c="stringify"}={}){this.options={detectCircular:e,maxDepth:r,showModifications:o,arrayDiffMethod:n,ignoreCase:a,ignoreCaseForKey:i,recursiveEqual:s,preserveKeyOrder:l,undefinedBehavior:c},this.arrayDiffFunc=n==="lcs"||n==="unorder-lcs"?xEe:bEe}};H();var ks=t=>"hasLinesBefore"in t||"hasLinesAfter"in t,vEe=(t,e,r)=>ks(t)?r:e*(t.end-t.start+1),oH=(t,e)=>{let r=[],o,n;if(t.length&&e.length)for(t=[...t],e=[...e],o={...t.shift()},n={...e.shift()};;){if(o.start===n.start){let a=Math.min(o.end,n.end);r.push({...o,...n,end:a}),o.start=n.start=a}else if(o.start<n.start){let a=Math.min(o.end,n.start);r.push({...n,...o,end:a}),o.start=a}else{let a=Math.min(o.start,n.end);r.push({...o,...n,end:a}),n.start=a}if(!t.length||!e.length)break;o.start===o.end&&(o={...t.shift()}),n.start===n.end&&(n={...e.shift()})}return t.length||r.push(...e.map(a=>({...a,token:o.token||"plain"}))),e.length||r.push(...t),r},yEe=(t,e,r,o,n,a,i,s,l)=>{if(!e.length)return[0,0];let c=0,d=0,u=t[r];ks(u)?c=e[r]:c=e[r]+(o-u.start)*i;let p=t[n];return ks(p)?d=l-e[n]-s:d=l-e[n]-(a-p.start)*i,[c,d]},IEe=yEe,wEe=(t,e,r,o,n,a)=>{if(!e.length)return[0,0,0,0];let i=0,s=0,l=0,c=0,d=0,u=t.length-1;for(;;){let h=Math.floor((d+u)/2);if(e[h]+vEe(t[h],n,a)<=r?d=h+1:u=h,d===u){i=d;break}}let p=t[i];for(ks(p)?l=p.start:l=p.start+Math.floor((r-e[i])/n),d=0,u=t.length-1;;){let h=Math.floor((d+u+1)/2);if(e[h]>=o?u=h-1:d=h,d===u){s=d;break}}let m=t[s];return ks(m)?c=m.end:c=m.start+Math.ceil((o-e[s])/n),[i,l,s,c]},EEe=wEe,Ta={};Object.defineProperty(Ta,"__esModule",{value:!0});Ta.applyPatch=Ta.calcPatch=WT=Ta.lcs=Ta.diff=Ta.diff_core=void 0;function SEe(t,e){let{b:r,eq:o,stack_base:n}=t,{i:a,N:i,j:s,M:l,Z:c,stack_top:d}=t;for(;;)switch(e){case 0:{e:for(;i>0&&l>0;){r.fill(0,0,2*c);let u=i-l,p=i+l,m=p&1,h=a+i-1,g=s+l-1,_=(p+m)/2,x;t:for(let b=0;b<=_;b++){let v=2*Math.max(0,b-l)-b,I=b-2*Math.max(0,b-i);for(let E=v;E<=I;E+=2){let y=r[E-1-c*Math.floor((E-1)/c)],C=r[E+1-c*Math.floor((E+1)/c)],T=E===-b||E!==b&&y<C?C:y+1,k=T-E,S=T,R=k;for(;S<i&&R<l&&o(a+S,s+R);)S++,R++;if(r[E-c*Math.floor(E/c)]=S,m===1&&(x=u-E)>=1-b&&x<b&&S+r[c+x-c*Math.floor(x/c)]>=i)if(b>1||S!==T){n[d++]=a+S,n[d++]=i-S,n[d++]=s+R,n[d++]=l-R,i=T,l=k,c=2*(Math.min(i,l)+1);continue e}else break t}for(let E=v;E<=I;E+=2){let y=r[c+E-1-c*Math.floor((E-1)/c)],C=r[c+E+1-c*Math.floor((E+1)/c)],T=E===-b||E!==b&&y<C?C:y+1,k=T-E,S=T,R=k;for(;S<i&&R<l&&o(h-S,g-R);)S++,R++;if(r[c+E-c*Math.floor(E/c)]=S,m===0&&(x=u-E)>=-b&&x<=b&&S+r[x-c*Math.floor(x/c)]>=i)if(b>0||S!==T){n[d++]=a+i-T,n[d++]=T,n[d++]=s+l-k,n[d++]=k,i=i-S,l=l-R,c=2*(Math.min(i,l)+1);continue e}else break t}}if(i!==l){l>i?(a+=i,s+=i,l-=i,i=0):(a+=l,s+=l,i-=l,l=0);break}}if(i+l!==0)if(t.pxe===a||t.pye===s)t.pxe=a+i,t.pye=s+l;else{let u=t.pxs;if(t.oxs=t.pxs,t.oxe=t.pxe,t.oys=t.pys,t.oye=t.pye,t.pxs=a,t.pxe=a+i,t.pys=s,t.pye=s+l,u>=0)return t.i=a,t.N=i,t.j=s,t.M=l,t.Z=c,t.stack_top=d,1}}case 1:{if(d===0)return 2;l=n[--d],s=n[--d],i=n[--d],a=n[--d],c=2*(Math.min(i,l)+1),e=0}}}var CEe=class{[Symbol.iterator](){return this}next(){let{state:e,result:r}=this;if(this.c>1)return r.done=!0,r.value=void 0,r;let o=SEe(e,this.c);return this.c=o,o===1?(r.value=[e.oxs,e.oxe,e.oys,e.oye],r):e.pxs>=0?(r.value=[e.pxs,e.pxe,e.pys,e.pye],r):(r.done=!0,r.value=void 0,r)}constructor(e){this.state=e,this.c=0,this.result={value:null,done:!1}}};function cH(t,e,r,o,n){let a=(Math.min(e,o)+1)*2,i=e+o,s=new(i<256?Uint8Array:i<65536?Uint16Array:Uint32Array)(2*a);return new CEe({i:t,N:e,j:r,M:o,Z:a,b:s,eq:n,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}Ta.diff_core=cH;function KT(t,e){let[r,o,n]=[0,t.length,e.length];for(;r<o&&r<n&&t[r]===e[r];)r++;if(r===o&&r===n)return[][Symbol.iterator]();for(;t[--o]===e[--n]&&o>r&&n>r;);let a=(i,s)=>t[i]===e[s];return cH(r,o+1-r,r,n+1-r,a)}Ta.diff=KT;var kEe=class{[Symbol.iterator](){return this}next(){let e=this.diff.next();if(e.done){let{i:l,j:c,N:d}=this;return l<d&&(e.done=!1,e.value=[l,c,d-l],this.i=d),e}let r=e.value,o=r[0],n=r[1],a=r[3],{i,j:s}=this;return i!==o&&(r.length--,r[0]=i,r[1]=s,r[2]=o-i),this.i=n,this.j=a,e}constructor(e,r){this.diff=e,this.N=r,this.i=0,this.j=0}};function TEe(t,e){return new kEe(KT(t,e),t.length)}var WT=Ta.lcs=TEe;function*PEe(t,e){let r=ArrayBuffer.isView(t)?Uint8Array.prototype.subarray:t.slice;for(let o of KT(t,e))o[2]=r.call(e,o[2],o[3]),yield o}Ta.calcPatch=PEe;function*OEe(t,e){let r=0,o=ArrayBuffer.isView(t)?Uint8Array.prototype.subarray:t.slice;for(let[n,a,i]of e)r<n&&(yield o.call(t,r,n)),i.length>0&&(yield i),r=a;r<t.length&&(yield o.call(t,r))}Ta.applyPatch=OEe;var nH=(t,e)=>{let r=[],o=0;for(let n of t)r.push(o),o+=n.length+e;return r.push(o-e),r},Cy=t=>t.filter(e=>e.end>e.start),DEe=(t,e,r)=>{let o=[],n=[],a=0,i=0;if(r.mode==="word"){let l=r.wordSeparator||" ",c=t.split(l),d=e.split(l),u=[...WT(c,d)],p=l.length,m=nH(c,p),h=nH(d,p);for(let[g,_,x]of u)g>a&&o.push({type:"remove",start:m[a],end:m[g]}),_>i&&n.push({type:"add",start:h[i],end:h[_]}),a=g+x,i=_+x,o.push({start:m[g],end:m[a]}),n.push({start:h[_],end:h[i]});return t.length>a&&o.push({type:"remove",start:m[a],end:t.length}),e.length>i&&n.push({type:"add",start:h[i],end:e.length}),o=Cy(o),n=Cy(n),[o,n]}let s=WT(t,e);for(let[l,c,d]of s)l>a&&o.push({type:"remove",start:a,end:l}),c>i&&n.push({type:"add",start:i,end:c}),a=l+d,i=c+d,o.push({start:l,end:a}),n.push({start:c,end:i});return t.length>a&&o.push({type:"remove",start:a,end:t.length}),e.length>i&&n.push({type:"add",start:i,end:e.length}),o=Cy(o),n=Cy(n),[o,n]},AEe=DEe,dH=(t,e,r)=>{if(!t)return[{token:"plain",start:r,end:e.length+r}];if(e==="undefined"||e==="Infinity"||e==="-Infinity"||e==="NaN"||/^\d+n$/i.test(e)||e.startsWith("Symbol(")||e.startsWith("function")||e.startsWith("("))return[{token:"invalid",start:r,end:e.length+r}];if(!Number.isNaN(Number(e)))return[{token:"number",start:r,end:e.length+r}];if(e==="true"||e==="false")return[{token:"boolean",start:r,end:e.length+r}];if(e==="null")return[{token:"null",start:r,end:e.length+r}];if(e.startsWith('"')){if(e.endsWith(": [")||e.endsWith(": {"))return[{token:"key",start:r,end:e.length-3+r},{token:"punctuation",start:e.length-3,end:e.length-2+r},{token:"plain",start:e.length-2,end:e.length-1+r},{token:"punctuation",start:e.length-1,end:e.length+r}];let o=1;for(;o<e.length&&e[o]!=='"';)e[o]==="\\"&&++o,++o;return o===e.length-1?[{token:"string",start:r,end:e.length+r}]:[{token:"key",start:r,end:o+1+r},{token:"punctuation",start:o+1,end:o+2+r},{token:"plain",start:o+2,end:o+3+r},...dH(t,e.substring(o+3),r+o+3)]}return e==="{"||e==="}"||e==="["||e==="]"?[{token:"punctuation",start:r,end:e.length+r}]:[{token:"plain",start:r,end:e.length+r}]},aH=dH,iH={threshold:8,margin:3},NEe=(t,e,r,o)=>{if(!r||o)return[{start:0,end:t.length,isEqual:!1}];let n=[];for(let c=0;c<t.length;c++)t[c].type==="equal"&&e[c].type==="equal"?n.length&&n[n.length-1].isEqual?n[n.length-1].end++:n.push({start:c,end:c+1,isEqual:!0}):n.length&&!n[n.length-1].isEqual?n[n.length-1].end++:n.push({start:c,end:c+1,isEqual:!1});let a=r===!0?iH:{...iH,...r},{threshold:i,margin:s}=a;i<s*2+1&&console.warn(`Threshold (${i}) is no more than 2 margins + 1 "expand" line (${s} * 2 + 1), it's not necessary to hide unchanged areas which have less than ${s*2+1} lines.`);let l=[];for(let c=0;c<n.length;c++){let d=n[c];if(!d.isEqual||d.end-d.start<i||d.end-d.start<=s*2+1){l.push(d);continue}c?c===n.length-1?(l.push({start:d.start,end:d.start+s,isEqual:!0}),l.push({hasLinesBefore:!1,hasLinesAfter:!0,start:d.start+s,end:t.length,isEqual:!0})):(l.push({start:d.start,end:d.start+s,isEqual:!0}),l.push({hasLinesBefore:!0,hasLinesAfter:!0,start:d.start+s,end:d.end-s,isEqual:!0}),l.push({start:d.end-s,end:d.end,isEqual:!0})):(l.push({hasLinesBefore:!0,hasLinesAfter:!1,start:0,end:d.end-s,isEqual:!0}),l.push({start:d.end-s,end:d.end,isEqual:!0}))}return l},sH=NEe,REe=2,lH=20,MEe={noChangeDetected:"No change detected"},ky=t=>{let[e,r]=t.diff,o=ot(()=>e.length===r.length&&e.every(V=>V.type==="equal")&&r.every(V=>V.type==="equal"),[e,r]),n={...MEe,...t.texts},a=t.lineNumbers?`calc(${String(e.length).length}ch + 16px)`:0,i=t.indent??REe,s=i==="tab"?" ":" ",l=i==="tab"?1:i,c={mode:t.inlineDiffOptions?.mode||"char",wordSeparator:t.inlineDiffOptions?.wordSeparator||""},d=t.hideUnchangedLines??!1,{scrollContainer:u="body",itemHeight:p=18,expandLineHeight:m=26}=!t.virtual||t.virtual===!0?{}:t.virtual,h=u==="body"?document.body:document.querySelector(u),g=U(e),_=U(r),x=U(sH(e,r,d,o)),b=U([]),v=U(0),I=U(null),[,E]=P({}),y=()=>{if(b.current=[],t.virtual){let V=0;for(let q of x.current)ks(q)?(b.current.push(V),V+=m):(b.current.push(V),V+=p*(q.end-q.start));v.current=x.current.reduce((q,O)=>ks(O)?q+m:q+(O.end-O.start)*p,0)}E({})};L(()=>{g.current=e,_.current=r,x.current=sH(e,r,d,o),y()},[d,e,r]),L(()=>{if(!t.virtual||!h)return;let V=()=>E({});return h.addEventListener("scroll",V),()=>{h.removeEventListener("scroll",V)}},[t.virtual,h]);let C=V=>q=>{let O=[...x.current],J=O[V];O[V]={...J,end:Math.max(J.end-q,J.start)},V+1<x.current.length-1&&(O[V+1]={...O[V+1],start:Math.max(J.end-q,J.start)}),x.current=O,y()},T=V=>q=>{let O=[...x.current],J=O[V];O[V]={...J,start:Math.min(J.start+q,J.end)},V>1&&(O[V-1]={...O[V-1],end:Math.min(J.start+q,J.end)}),x.current=O,y()},k=V=>()=>{let q=[...x.current],O=q[V];q[V]={...O,start:O.start,end:O.start},V+1<x.current.length-1?q[V+1]={...q[V+1],start:O.start}:q[V-1]={...q[V-1],end:O.end},x.current=q,y()},S=(V,q=[],O=!1,J=!1)=>ee(Oe,null,q.map((oe,D)=>{let le=V.slice(oe.start,oe.end);if(!oe.type&&!oe.token)return le;let we=[oe.type?`inline-diff-${oe.type}`:"",oe.token?`token ${oe.token}`:""].filter(Boolean).join(" ");return ee("span",{key:`${D}-${oe.type}-${le}`,className:we},le)}),O&&(J?ee("span",{className:"token punctuation"},","):",")),R=(V,q)=>{let O=g.current[V],J=_.current[V],[oe,D]=t.highlightInlineDiff&&O.type==="modify"&&J.type==="modify"?AEe(O.text,J.text,c):[[],[]],le=aH(q,O.text,0),we=aH(q,J.text,0),$e=oH(le,oe),Qe=oH(we,D),ke=O.type!=="equal"?t.bgColour?.[O.type]??"":"",_e=J.type!=="equal"?t.bgColour?.[J.type]??"":"";return ee("tr",{key:V},t.lineNumbers&&ee("td",{className:`line-${O.type} line-number`,style:{backgroundColor:ke}},O.lineNumber),ee("td",{className:`line-${O.type}`,style:{backgroundColor:ke}},ee("pre",null,O.text&&s.repeat(O.level*l),S(O.text,$e,O.comma,q))),t.lineNumbers&&ee("td",{className:`line-${J.type} line-number`,style:{backgroundColor:_e}},J.lineNumber),ee("td",{className:`line-${J.type}`,style:{backgroundColor:_e}},ee("pre",null,J.text&&s.repeat(J.level*l),S(J.text,Qe,J.comma,q))))},A=(V,q,O,J)=>ee(Oe,null,V&&ee("button",{onClick:()=>C(J)(O)},"\u2B61 Show ",O," lines before"),ee("button",{onClick:()=>k(J)()},"\u2B65 Show all unchanged lines"),q&&ee("button",{onClick:()=>T(J)(O)},"\u2B63 Show ",O," lines after")),N=(V,q,O,J,oe)=>{let{start:D,end:le}=V;if(D=Math.max(D,O),le=Math.min(le,J),D===le)return null;if(!ks(V))return Array(le-D).fill(0).map((ke,_e)=>R(D+_e,oe));let{hasLinesBefore:we,hasLinesAfter:$e}=V,Qe=typeof d=="boolean"?lH:d.expandMoreLinesLimit||lH;return[ee("tr",{key:`expand-line-${q}`,className:"expand-line"},ee("td",{colSpan:4,className:`${we?"has-lines-before":""} ${$e?"has-lines-after":""}`},typeof d!="boolean"&&d.expandLineRenderer?d.expandLineRenderer({hasLinesBefore:we,hasLinesAfter:$e,onExpandBefore:C(q),onExpandAfter:T(q),onExpandAll:k(q)}):A(we,$e,Qe,q)))]},z=V=>{if(o&&d)return ee("tr",{key:"message-line",className:"message-line"},ee("td",{colSpan:4},n.noChangeDetected));if(!t.virtual)return x.current.map((Xe,tt)=>N(Xe,tt,0,g.current.length,V));let q=h?.clientHeight??0,O=h?.scrollTop??0,J=O+q,oe=I.current,D=oe?.offsetTop??0;for(;oe?.offsetParent&&oe?.offsetParent!==h;)oe=oe.offsetParent,D+=oe.offsetTop;if(D>J||D+v.current<O)return ee("tr",null,ee("td",{colSpan:4,style:{height:`${v.current}px`}}));let le=O-D,we=J-D,[$e,Qe,ke,_e]=EEe(x.current,b.current,le,we,p,m),[et,wt]=IEe(x.current,b.current,$e,Qe,ke,_e,p,m,v.current),He=x.current.slice($e,ke+1);return He.length?ee(Oe,null,ee("tr",null,ee("td",{colSpan:4,style:{height:et,padding:0}})),He.map((Xe,tt)=>N(Xe,tt,Qe,_e,V)),ee("tr",null,ee("td",{colSpan:4,style:{height:wt,padding:0}}))):ee("tr",null,ee("td",{colSpan:4,style:{height:`${v.current}px`}}))},F=()=>ee("colgroup",{className:"measure-line"},t.lineNumbers&&ee("col",{style:{width:a}}),ee("col",null),t.lineNumbers&&ee("col",{style:{width:a}}),ee("col",null)),B=["json-diff-viewer",t.virtual&&"json-diff-viewer-virtual",t.syntaxHighlight&&`json-diff-viewer-theme-${t.syntaxHighlight.theme||"monokai"}`,t.className].filter(Boolean).join(" "),$=!!t.syntaxHighlight;return ee("table",{className:B,style:t.style},F(),ee("tbody",{ref:I},z($)))};ky.displayName="Viewer";H();ye();function Ty(t){let e=t.left,r=t.right,[o,n]=P(!1),[a,i]=P(null),[s,l]=P(null),c=fH(a?.fields||{}),d=fH(s?.fields||{}),p=new GT({}).diff(c,d),m=`/cms/compare?left=${pH(e)}&right=${pH(r)}`;async function h(){n(!0);let[g,_]=await Promise.all([$k(e.docId,e.versionId),$k(r.docId,r.versionId)]);i(g),l(_),n(!1)}return L(()=>{h()},[]),o?f(De,{size:"md",color:"gray"}):f("div",{className:Te(t.className,"DocDiffViewer"),children:[t.showExpandButton&&f("div",{className:"DocDiffViewer__expand",children:f(Y,{component:"a",variant:"default",size:"xs",compact:!0,href:m,target:"_blank",children:"Open in new tab"})}),f("div",{className:"DocDiffViewer__header",children:[f("div",{className:"DocDiffViewer__header__label",children:[t.left.docId,"@",t.left.versionId," - modified"," ",uH(a)]}),f("div",{className:"DocDiffViewer__header__label",children:[t.right.docId,"@",t.right.versionId," - modified"," ",uH(s)]})]}),f(ky,{diff:p,syntaxHighlight:{theme:"root-cms"},lineNumbers:!0,highlightInlineDiff:!0,hideUnchangedLines:!0,inlineDiffOptions:{mode:"word",wordSeparator:" "}})]})}function uH(t){return t?.sys?.modifiedAt?ea(t.sys.modifiedAt.toMillis()):"never"}function fH(t){return Wv(t,{removeArrayKey:!0})}function pH(t){return encodeURIComponent(`${t.docId}@${t.versionId}`).replaceAll("%2F","/").replaceAll("%40","@")}var mH="PublishDocModal";function hH(t){let e=nt(),r=It();return{open:()=>{e.openContextModal(mH,{...r,title:`Publish ${t.docId}`,innerProps:t,size:"850px"})}}}function Py(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(""),[i,s]=P(""),[l,c]=P(!1),d=U(null),u=nt(),p=It(),m=n==="scheduled"?"Schedule":"Publish";async function h(){try{c(!0),await E7(e.docId),c(!1),he({title:"Published!",message:`Succesfully published ${e.docId}.`,autoClose:1e4}),u.closeAll()}catch(b){console.error(b),he({title:"Publish failed",message:`Failed to publish ${e.docId}.`,color:"red",autoClose:!1})}}async function g(){try{c(!0);let b=Math.floor(new Date(i).getTime());await S7(e.docId,b),c(!1),he({title:"Scheduled!",message:`${e.docId} will go live ${i}.`,autoClose:1e4}),u.closeAll()}catch(b){console.error(b),he({title:"Schedule failed",message:`Failed to schedule ${e.docId}.`,color:"red",autoClose:!1})}}function _(){u.openConfirmModal({...p,title:`${m} ${e.docId}`,children:f(Ve,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to publish ",f("code",{children:e.docId}),"? The doc will go live ",n==="now"?"now":`at ${i}`,"."]}),labels:{confirm:m,cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{n==="now"?h():n==="scheduled"&&g()}})}let x=!0;return(n==="now"||n==="scheduled"&&i)&&(x=!1),f("div",{className:"PublishDocModal",children:f("div",{className:"PublishDocModal__content",children:[f("form",{className:"PublishDocModal__form",onSubmit:b=>{b.preventDefault(),_()},children:[f("div",{className:"PublishDocModal__form__publishOptions",children:f("div",{className:"PublishDocModal__form__publishOptions__options",children:[f("label",{className:Te("PublishDocModal__form__publishOptions__option",n==="now"&&"PublishDocModal__form__publishOptions__option--selected",n&&n!=="now"&&"PublishDocModal__form__publishOptions__option--unselected"),children:[f("div",{className:"PublishDocModal__form__publishOptions__option__input",children:[f("input",{type:"radio",name:"publish-option",value:"now",checked:n==="now",onChange:()=>a("now")})," ","Now"]}),f("div",{className:"PublishDocModal__form__publishOptions__option__help",children:"Content will go live immediately."})]}),f("label",{className:Te("PublishDocModal__form__publishOptions__option",n==="scheduled"&&"PublishDocModal__form__publishOptions__option--selected",n&&n!=="scheduled"&&"PublishDocModal__form__publishOptions__option--unselected"),children:[f("div",{className:"PublishDocModal__form__publishOptions__option__input",children:[f("input",{type:"radio",name:"publish-option",value:"scheduled",checked:n==="scheduled",onChange:()=>a("scheduled")}),f("div",{children:"Scheduled"})]}),f("div",{className:"PublishDocModal__form__publishOptions__option__help",children:"Content will go live at the date and time specified below."}),f("div",{className:"PublishDocModal__form__publishOptions__option__input2",children:[f("input",{ref:d,type:"datetime-local",disabled:n!=="scheduled",value:i,min:fu(),onChange:b=>{let v=b.target;s(v.value)}}),f("div",{className:"PublishDocModal__form__publishOptions__option__input2__help",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})]})]})}),f("div",{className:"PublishDocModal__form__buttons",children:[f(Y,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(Y,{variant:"filled",size:"xs",color:"dark",disabled:x,loading:l,type:"submit",children:m})]})]}),f(LEe,{docId:e.docId})]})})}function LEe(t){let e=t.docId,[r,o]=P(!1);function n(){o(!0)}return f("div",{className:"PublishDocModal__ShowChanges",children:f(fd,{iconPosition:"right",onChange:()=>n(),children:f(fd.Item,{label:"Show changes",children:r?f(Ty,{left:{docId:e,versionId:"published"},right:{docId:e,versionId:"draft"},showExpandButton:!0}):f(De,{})})})})}Py.id=mH;ye();var Ts="Releases";async function gH(t,e){if(!t)throw new Error("missing data source id");let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=Ee(o,"Projects",r,Ts,t);await km(o,async a=>{if((await a.get(n)).exists())throw new Error(`release exists: ${t}`);await a.set(n,{...e,id:t,createdAt:$t(),createdBy:window.firebase.user.email})}),st("release.create",{metadata:{releaseId:t}})}async function _H(){let t=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,r=yn(e,"Projects",t,Ts),o=Lr(r,Jn("createdAt","desc")),n=await In(o),a=[];return n.forEach(i=>{a.push(i.data())}),a}async function uc(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=Ee(r,"Projects",e,Ts,t),n=await Pr(o);return n.exists()?n.data():null}async function xH(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=Ee(o,"Projects",r,Ts,t);await cr(n,e),st("release.save",{metadata:{releaseId:t}})}async function bH(t){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,o=Ee(r,"Projects",e,Ts,t);await U8(o),console.log(`deleted release ${t}`),st("release.delete",{metadata:{releaseId:t}})}async function vH(t){let e=await uc(t);if(!e)throw new Error(`release not found: ${t}`);let r=e.docIds||[],o=e.dataSourceIds||[];if(r.length===0&&o.length===0)throw new Error(`no docs or data sources to publish for release: ${t}`);let n=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,i=Ee(a,"Projects",n,Ts,t),s=ln(a);s.update(i,{publishedAt:$t(),publishedBy:window.firebase.user.email,scheduledAt:Yr(),scheduledBy:Yr()}),o.length>0&&await j7(o,{batch:s,commitBatch:!1}),await zk(r,{batch:s,releaseId:t}),console.log(`published release: ${t}`),st("release.publish",{metadata:{releaseId:t,docIds:r,dataSourceIds:o}})}async function yH(t,e){if(!await uc(t))throw new Error(`release not found: ${t}`);typeof e=="number"&&(e=dt.fromMillis(e));let o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,a=Ee(n,"Projects",o,Ts,t);await cr(a,{scheduledAt:e,scheduledBy:window.firebase.user.email}),st("release.publish",{metadata:{releaseId:t,scheduledAt:e.toMillis()}})}async function IH(t){if(!await uc(t))throw new Error(`release not found: ${t}`);let r=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,n=Ee(o,"Projects",r,Ts,t);await cr(n,{scheduledAt:Yr(),scheduledBy:Yr()}),st("release.unschedule",{metadata:{releaseId:t}})}var wH="ScheduleReleaseModal";function EH(t){let e=nt(),r=It();return{open:()=>{e.openContextModal(wH,{...r,title:`Schedule release: ${t.releaseId}`,innerProps:t})}}}function Oy(t){let{innerProps:e,context:r,id:o}=t,[n,a]=P(""),[i,s]=P(!1),l=U(null),c=nt();async function d(){s(!0),await Tt(async()=>{let u=Math.floor(new Date(n).getTime());if(Math.floor(new Date().getTime())>=u)throw new Error("bad datetime, please choose a date in the future");let m=dt.fromMillis(u);await yH(e.releaseId,u),he({title:"Scheduled!",message:`Release ${e.releaseId} will go live ${n}.`,autoClose:1e4}),c.closeAll(),e.onScheduled&&e.onScheduled(m)}),s(!1)}return f("div",{className:"ScheduleReleaseModal",children:f("div",{className:"ScheduleReleaseModal__content",children:f("form",{className:"ScheduleReleaseModal__form",onSubmit:u=>{u.preventDefault(),d()},children:[f("div",{className:"ScheduleReleaseModal__form__description",children:"Content in the release will go live at the datetime specified below."}),f("div",{className:"ScheduleReleaseModal__form__dateInput",children:[f("input",{ref:l,type:"datetime-local",value:n,min:fu(),onChange:u=>{let p=u.target;a(p.value)}}),f("div",{className:"ScheduleReleaseModal__form__dateInput__help",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]}),f("div",{className:"ScheduleReleaseModal__form__buttons",children:[f(Y,{variant:"outline",onClick:()=>r.closeModal(o),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(Y,{variant:"filled",size:"xs",color:"dark",loading:i,type:"submit",children:"Schedule"})]})]})})})}Oy.id=wH;ye();var CH="VersionHistoryModal";function kH(t){let e=nt(),r=It();return{open:()=>{e.openContextModal(CH,{...r,innerProps:t,size:"min(calc(100% - 32px), 720px)"})}}}function Dy(t){let{innerProps:e}=t,r=e.docId,[o,n]=P(!0),[a,i]=P([]),s=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function l(){n(!0);let u=await A7(r);n(!1),i(u)}async function c(u){await N7(r,u),he({title:"Saved!",message:`Restored ${r} to ${s.format(u.sys.modifiedAt.toDate())}.`,autoClose:5e3}),e.onRestore&&e.onRestore({version:u})}function d(u){let p=SH(r,u._versionId),m=SH(r,"draft");return`/cms/compare?left=${p}&right=${m}`}return L(()=>{l()},[]),o?f(De,{}):f("div",{className:"VersionHistoryModal",children:[f(Le,{className:"VersionHistoryModal__title",size:"h2",children:[f(Fm,{strokeWidth:1.5}),f("span",{children:"Version history"})]}),f("div",{className:"VersionHistoryModal__docId",children:f("code",{children:r})}),a.length===0?f(Ve,{className:"VersionHistoryModal__versionsEmpty",size:"body",children:[f("p",{children:"No versions found."}),f("p",{className:"VersionHistoryModal__versionsEmpty__developer",children:"For developers: Configure the Root CMS cron job to populate versions."})]}):f(hr,{className:"VersionHistoryModal__versions",children:[f("thead",{children:f("tr",{children:[f("th",{children:"modified at"}),f("th",{children:"modified by"}),f("th",{children:"actions"})]})}),f("tbody",{children:a.map((u,p)=>f("tr",{children:[f("td",{children:f(Ve,{size:"body-sm",children:s.format(u.sys.modifiedAt.toDate())})}),f("td",{children:f(Ve,{size:"body-sm",children:u.sys.modifiedBy})}),f("td",{children:f("div",{className:"VersionHistoryModal__versions__buttons",children:[f(Y,{variant:"default",size:"xs",compact:!0,onClick:()=>c(u),children:"restore"}),f(Y,{className:"VersionHistoryModal__versions__buttons__compare",component:"a",variant:"default",size:"xs",compact:!0,href:d(u),target:"_blank",rightIcon:f(ws,{size:12}),children:"compare"})]})})]}))})]})]})}function SH(t,e){return encodeURIComponent(`${t}@${e}`).replaceAll("%2F","/").replaceAll("%40","@")}Dy.id=CH;dn();ye();var TH=mt(null);function PH(t){let[e,r]=P(""),o={value:e,set:n=>r(n)};return f(TH.Provider,{value:o,children:t.children})}function OH(){let t=it(TH);if(!t)throw new Error("virtualClipboard is null, make sure to add <VirtualClipboardProvider>");return t}var Bq=Qh(Lq(),1);var cP=Bq.default;var z1e={};function dP(t,e){let r=e||z1e,o=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,n=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return zq(t,o,n)}function zq(t,e,r){if(U1e(t)){if("value"in t)return t.type==="html"&&!r?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return Fq(t.children,e,r)}return Array.isArray(t)?Fq(t,e,r):""}function Fq(t,e,r){let o=[],n=-1;for(;++n<t.length;)o[n]=zq(t[n],e,r);return o.join("")}function U1e(t){return!!(t&&typeof t=="object")}var Uq=document.createElement("i");function Pu(t){let e="&"+t+";";Uq.innerHTML=e;let r=Uq.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===e?!1:r}function Or(t,e,r,o){let n=t.length,a=0,i;if(e<0?e=-e>n?0:n+e:e=e>n?n:e,r=r>0?r:0,o.length<1e4)i=Array.from(o),i.unshift(e,r),t.splice(...i);else for(r&&t.splice(e,r);a<o.length;)i=o.slice(a,a+1e4),i.unshift(e,0),t.splice(...i),a+=1e4,e+=1e4}function Ko(t,e){return t.length>0?(Or(t,t.length,0,e),t):e}var Vq={}.hasOwnProperty;function Hy(t){let e={},r=-1;for(;++r<t.length;)V1e(e,t[r]);return e}function V1e(t,e){let r;for(r in e){let n=(Vq.call(t,r)?t[r]:void 0)||(t[r]={}),a=e[r],i;if(a)for(i in a){Vq.call(n,i)||(n[i]=[]);let s=a[i];$1e(n[i],Array.isArray(s)?s:s?[s]:[])}}}function $1e(t,e){let r=-1,o=[];for(;++r<e.length;)(e[r].add==="after"?t:o).push(e[r]);Or(t,0,0,o)}function jy(t,e){let r=Number.parseInt(t,e);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"\uFFFD":String.fromCodePoint(r)}function ko(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Fr=Os(/[A-Za-z]/),zr=Os(/[\dA-Za-z]/),$q=Os(/[#-'*+\--9=?A-Z^-~]/);function mc(t){return t!==null&&(t<32||t===127)}var Zm=Os(/\d/),Hq=Os(/[\dA-Fa-f]/),jq=Os(/[!-/:-@[-`{-~]/);function ue(t){return t!==null&&t<-2}function lt(t){return t!==null&&(t<0||t===32)}function Be(t){return t===-2||t===-1||t===32}var hc=Os(/\p{P}|\p{S}/u),Ja=Os(/\s/);function Os(t){return e;function e(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function Ne(t,e,r,o){let n=o?o-1:Number.POSITIVE_INFINITY,a=0;return i;function i(l){return Be(l)?(t.enter(r),s(l)):e(l)}function s(l){return Be(l)&&a++<n?(t.consume(l),s):(t.exit(r),e(l))}}var qq={tokenize:H1e};function H1e(t){let e=t.attempt(this.parser.constructs.contentInitial,o,n),r;return e;function o(s){if(s===null){t.consume(s);return}return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),Ne(t,e,"linePrefix")}function n(s){return t.enter("paragraph"),a(s)}function a(s){let l=t.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=l),r=l,i(s)}function i(s){if(s===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(s);return}return ue(s)?(t.consume(s),t.exit("chunkText"),a):(t.consume(s),i)}}var Wq={tokenize:j1e},Gq={tokenize:q1e};function j1e(t){let e=this,r=[],o=0,n,a,i;return s;function s(v){if(o<r.length){let I=r[o];return e.containerState=I[1],t.attempt(I[0].continuation,l,c)(v)}return c(v)}function l(v){if(o++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,n&&b();let I=e.events.length,E=I,y;for(;E--;)if(e.events[E][0]==="exit"&&e.events[E][1].type==="chunkFlow"){y=e.events[E][1].end;break}x(o);let C=I;for(;C<e.events.length;)e.events[C][1].end=Object.assign({},y),C++;return Or(e.events,E+1,0,e.events.slice(I)),e.events.length=C,c(v)}return s(v)}function c(v){if(o===r.length){if(!n)return p(v);if(n.currentConstruct&&n.currentConstruct.concrete)return h(v);e.interrupt=!!(n.currentConstruct&&!n._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(Gq,d,u)(v)}function d(v){return n&&b(),x(o),p(v)}function u(v){return e.parser.lazy[e.now().line]=o!==r.length,i=e.now().offset,h(v)}function p(v){return e.containerState={},t.attempt(Gq,m,h)(v)}function m(v){return o++,r.push([e.currentConstruct,e.containerState]),p(v)}function h(v){if(v===null){n&&b(),x(0),t.consume(v);return}return n=n||e.parser.flow(e.now()),t.enter("chunkFlow",{contentType:"flow",previous:a,_tokenizer:n}),g(v)}function g(v){if(v===null){_(t.exit("chunkFlow"),!0),x(0),t.consume(v);return}return ue(v)?(t.consume(v),_(t.exit("chunkFlow")),o=0,e.interrupt=void 0,s):(t.consume(v),g)}function _(v,I){let E=e.sliceStream(v);if(I&&E.push(null),v.previous=a,a&&(a.next=v),a=v,n.defineSkip(v.start),n.write(E),e.parser.lazy[v.start.line]){let y=n.events.length;for(;y--;)if(n.events[y][1].start.offset<i&&(!n.events[y][1].end||n.events[y][1].end.offset>i))return;let C=e.events.length,T=C,k,S;for(;T--;)if(e.events[T][0]==="exit"&&e.events[T][1].type==="chunkFlow"){if(k){S=e.events[T][1].end;break}k=!0}for(x(o),y=C;y<e.events.length;)e.events[y][1].end=Object.assign({},S),y++;Or(e.events,T+1,0,e.events.slice(C)),e.events.length=y}}function x(v){let I=r.length;for(;I-- >v;){let E=r[I];e.containerState=E[1],E[0].exit.call(e,t)}r.length=v}function b(){n.write([null]),a=void 0,n=void 0,e.containerState._closeFlow=void 0}}function q1e(t,e,r){return Ne(t,t.attempt(this.parser.constructs.document,e,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ou(t){if(t===null||lt(t)||Ja(t))return 1;if(hc(t))return 2}function Ds(t,e,r){let o=[],n=-1;for(;++n<t.length;){let a=t[n].resolveAll;a&&!o.includes(a)&&(e=a(e,r),o.push(a))}return e}var Jm={name:"attention",tokenize:W1e,resolveAll:G1e};function G1e(t,e){let r=-1,o,n,a,i,s,l,c,d;for(;++r<t.length;)if(t[r][0]==="enter"&&t[r][1].type==="attentionSequence"&&t[r][1]._close){for(o=r;o--;)if(t[o][0]==="exit"&&t[o][1].type==="attentionSequence"&&t[o][1]._open&&e.sliceSerialize(t[o][1]).charCodeAt(0)===e.sliceSerialize(t[r][1]).charCodeAt(0)){if((t[o][1]._close||t[r][1]._open)&&(t[r][1].end.offset-t[r][1].start.offset)%3&&!((t[o][1].end.offset-t[o][1].start.offset+t[r][1].end.offset-t[r][1].start.offset)%3))continue;l=t[o][1].end.offset-t[o][1].start.offset>1&&t[r][1].end.offset-t[r][1].start.offset>1?2:1;let u=Object.assign({},t[o][1].end),p=Object.assign({},t[r][1].start);Kq(u,-l),Kq(p,l),i={type:l>1?"strongSequence":"emphasisSequence",start:u,end:Object.assign({},t[o][1].end)},s={type:l>1?"strongSequence":"emphasisSequence",start:Object.assign({},t[r][1].start),end:p},a={type:l>1?"strongText":"emphasisText",start:Object.assign({},t[o][1].end),end:Object.assign({},t[r][1].start)},n={type:l>1?"strong":"emphasis",start:Object.assign({},i.start),end:Object.assign({},s.end)},t[o][1].end=Object.assign({},i.start),t[r][1].start=Object.assign({},s.end),c=[],t[o][1].end.offset-t[o][1].start.offset&&(c=Ko(c,[["enter",t[o][1],e],["exit",t[o][1],e]])),c=Ko(c,[["enter",n,e],["enter",i,e],["exit",i,e],["enter",a,e]]),c=Ko(c,Ds(e.parser.constructs.insideSpan.null,t.slice(o+1,r),e)),c=Ko(c,[["exit",a,e],["enter",s,e],["exit",s,e],["exit",n,e]]),t[r][1].end.offset-t[r][1].start.offset?(d=2,c=Ko(c,[["enter",t[r][1],e],["exit",t[r][1],e]])):d=0,Or(t,o-1,r-o+3,c),r=o+c.length-d-2;break}}for(r=-1;++r<t.length;)t[r][1].type==="attentionSequence"&&(t[r][1].type="data");return t}function W1e(t,e){let r=this.parser.constructs.attentionMarkers.null,o=this.previous,n=Ou(o),a;return i;function i(l){return a=l,t.enter("attentionSequence"),s(l)}function s(l){if(l===a)return t.consume(l),s;let c=t.exit("attentionSequence"),d=Ou(l),u=!d||d===2&&n||r.includes(l),p=!n||n===2&&d||r.includes(o);return c._open=!!(a===42?u:u&&(n||!p)),c._close=!!(a===42?p:p&&(d||!u)),e(l)}}function Kq(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}var uP={name:"autolink",tokenize:K1e};function K1e(t,e,r){let o=0;return n;function n(m){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(m),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),a}function a(m){return Fr(m)?(t.consume(m),i):m===64?r(m):c(m)}function i(m){return m===43||m===45||m===46||zr(m)?(o=1,s(m)):c(m)}function s(m){return m===58?(t.consume(m),o=0,l):(m===43||m===45||m===46||zr(m))&&o++<32?(t.consume(m),s):(o=0,c(m))}function l(m){return m===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(m),t.exit("autolinkMarker"),t.exit("autolink"),e):m===null||m===32||m===60||mc(m)?r(m):(t.consume(m),l)}function c(m){return m===64?(t.consume(m),d):$q(m)?(t.consume(m),c):r(m)}function d(m){return zr(m)?u(m):r(m)}function u(m){return m===46?(t.consume(m),o=0,d):m===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(m),t.exit("autolinkMarker"),t.exit("autolink"),e):p(m)}function p(m){if((m===45||zr(m))&&o++<63){let h=m===45?p:u;return t.consume(m),h}return r(m)}}var ei={tokenize:Y1e,partial:!0};function Y1e(t,e,r){return o;function o(a){return Be(a)?Ne(t,n,"linePrefix")(a):n(a)}function n(a){return a===null||ue(a)?e(a):r(a)}}var qy={name:"blockQuote",tokenize:X1e,continuation:{tokenize:Q1e},exit:Z1e};function X1e(t,e,r){let o=this;return n;function n(i){if(i===62){let s=o.containerState;return s.open||(t.enter("blockQuote",{_container:!0}),s.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(i),t.exit("blockQuoteMarker"),a}return r(i)}function a(i){return Be(i)?(t.enter("blockQuotePrefixWhitespace"),t.consume(i),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(i))}}function Q1e(t,e,r){let o=this;return n;function n(i){return Be(i)?Ne(t,a,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):a(i)}function a(i){return t.attempt(qy,e,r)(i)}}function Z1e(t){t.exit("blockQuote")}var Gy={name:"characterEscape",tokenize:J1e};function J1e(t,e,r){return o;function o(a){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(a),t.exit("escapeMarker"),n}function n(a){return jq(a)?(t.enter("characterEscapeValue"),t.consume(a),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):r(a)}}var Wy={name:"characterReference",tokenize:eCe};function eCe(t,e,r){let o=this,n=0,a,i;return s;function s(u){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(u),t.exit("characterReferenceMarker"),l}function l(u){return u===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(u),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),a=31,i=zr,d(u))}function c(u){return u===88||u===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(u),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),a=6,i=Hq,d):(t.enter("characterReferenceValue"),a=7,i=Zm,d(u))}function d(u){if(u===59&&n){let p=t.exit("characterReferenceValue");return i===zr&&!Pu(o.sliceSerialize(p))?r(u):(t.enter("characterReferenceMarker"),t.consume(u),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return i(u)&&n++<a?(t.consume(u),d):r(u)}}var Yq={tokenize:rCe,partial:!0},Ky={name:"codeFenced",tokenize:tCe,concrete:!0};function tCe(t,e,r){let o=this,n={tokenize:E,partial:!0},a=0,i=0,s;return l;function l(y){return c(y)}function c(y){let C=o.events[o.events.length-1];return a=C&&C[1].type==="linePrefix"?C[2].sliceSerialize(C[1],!0).length:0,s=y,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),d(y)}function d(y){return y===s?(i++,t.consume(y),d):i<3?r(y):(t.exit("codeFencedFenceSequence"),Be(y)?Ne(t,u,"whitespace")(y):u(y))}function u(y){return y===null||ue(y)?(t.exit("codeFencedFence"),o.interrupt?e(y):t.check(Yq,g,I)(y)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===null||ue(y)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),u(y)):Be(y)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Ne(t,m,"whitespace")(y)):y===96&&y===s?r(y):(t.consume(y),p)}function m(y){return y===null||ue(y)?u(y):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===null||ue(y)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),u(y)):y===96&&y===s?r(y):(t.consume(y),h)}function g(y){return t.attempt(n,I,_)(y)}function _(y){return t.enter("lineEnding"),t.consume(y),t.exit("lineEnding"),x}function x(y){return a>0&&Be(y)?Ne(t,b,"linePrefix",a+1)(y):b(y)}function b(y){return y===null||ue(y)?t.check(Yq,g,I)(y):(t.enter("codeFlowValue"),v(y))}function v(y){return y===null||ue(y)?(t.exit("codeFlowValue"),b(y)):(t.consume(y),v)}function I(y){return t.exit("codeFenced"),e(y)}function E(y,C,T){let k=0;return S;function S(F){return y.enter("lineEnding"),y.consume(F),y.exit("lineEnding"),R}function R(F){return y.enter("codeFencedFence"),Be(F)?Ne(y,A,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):A(F)}function A(F){return F===s?(y.enter("codeFencedFenceSequence"),N(F)):T(F)}function N(F){return F===s?(k++,y.consume(F),N):k>=i?(y.exit("codeFencedFenceSequence"),Be(F)?Ne(y,z,"whitespace")(F):z(F)):T(F)}function z(F){return F===null||ue(F)?(y.exit("codeFencedFence"),C(F)):T(F)}}}function rCe(t,e,r){let o=this;return n;function n(i){return i===null?r(i):(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),a)}function a(i){return o.parser.lazy[o.now().line]?r(i):e(i)}}var eh={name:"codeIndented",tokenize:nCe},oCe={tokenize:aCe,partial:!0};function nCe(t,e,r){let o=this;return n;function n(c){return t.enter("codeIndented"),Ne(t,a,"linePrefix",5)(c)}function a(c){let d=o.events[o.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?i(c):r(c)}function i(c){return c===null?l(c):ue(c)?t.attempt(oCe,i,l)(c):(t.enter("codeFlowValue"),s(c))}function s(c){return c===null||ue(c)?(t.exit("codeFlowValue"),i(c)):(t.consume(c),s)}function l(c){return t.exit("codeIndented"),e(c)}}function aCe(t,e,r){let o=this;return n;function n(i){return o.parser.lazy[o.now().line]?r(i):ue(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n):Ne(t,a,"linePrefix",5)(i)}function a(i){let s=o.events[o.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?e(i):ue(i)?n(i):r(i)}}var fP={name:"codeText",tokenize:lCe,resolve:iCe,previous:sCe};function iCe(t){let e=t.length-4,r=3,o,n;if((t[r][1].type==="lineEnding"||t[r][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(o=r;++o<e;)if(t[o][1].type==="codeTextData"){t[r][1].type="codeTextPadding",t[e][1].type="codeTextPadding",r+=2,e-=2;break}}for(o=r-1,e++;++o<=e;)n===void 0?o!==e&&t[o][1].type!=="lineEnding"&&(n=o):(o===e||t[o][1].type==="lineEnding")&&(t[n][1].type="codeTextData",o!==n+2&&(t[n][1].end=t[o-1][1].end,t.splice(n+2,o-n-2),e-=o-n-2,o=n+2),n=void 0);return t}function sCe(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function lCe(t,e,r){let o=this,n=0,a,i;return s;function s(p){return t.enter("codeText"),t.enter("codeTextSequence"),l(p)}function l(p){return p===96?(t.consume(p),n++,l):(t.exit("codeTextSequence"),c(p))}function c(p){return p===null?r(p):p===32?(t.enter("space"),t.consume(p),t.exit("space"),c):p===96?(i=t.enter("codeTextSequence"),a=0,u(p)):ue(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),c):(t.enter("codeTextData"),d(p))}function d(p){return p===null||p===32||p===96||ue(p)?(t.exit("codeTextData"),c(p)):(t.consume(p),d)}function u(p){return p===96?(t.consume(p),a++,u):a===n?(t.exit("codeTextSequence"),t.exit("codeText"),e(p)):(i.type="codeTextData",d(p))}}var Yy=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,r){let o=r??Number.POSITIVE_INFINITY;return o<this.left.length?this.left.slice(e,o):e>this.left.length?this.right.slice(this.right.length-o+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-o+this.left.length).reverse())}splice(e,r,o){let n=r||0;this.setCursor(Math.trunc(e));let a=this.right.splice(this.right.length-n,Number.POSITIVE_INFINITY);return o&&th(this.left,o),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),th(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),th(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let r=this.left.splice(e,Number.POSITIVE_INFINITY);th(this.right,r.reverse())}else{let r=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);th(this.left,r.reverse())}}};function th(t,e){let r=0;if(e.length<1e4)t.push(...e);else for(;r<e.length;)t.push(...e.slice(r,r+1e4)),r+=1e4}function Xy(t){let e={},r=-1,o,n,a,i,s,l,c,d=new Yy(t);for(;++r<d.length;){for(;r in e;)r=e[r];if(o=d.get(r),r&&o[1].type==="chunkFlow"&&d.get(r-1)[1].type==="listItemPrefix"&&(l=o[1]._tokenizer.events,a=0,a<l.length&&l[a][1].type==="lineEndingBlank"&&(a+=2),a<l.length&&l[a][1].type==="content"))for(;++a<l.length&&l[a][1].type!=="content";)l[a][1].type==="chunkText"&&(l[a][1]._isInFirstContentOfListItem=!0,a++);if(o[0]==="enter")o[1].contentType&&(Object.assign(e,cCe(d,r)),r=e[r],c=!0);else if(o[1]._container){for(a=r,n=void 0;a--&&(i=d.get(a),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank");)i[0]==="enter"&&(n&&(d.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=a);n&&(o[1].end=Object.assign({},d.get(n)[1].start),s=d.slice(n,r),s.unshift(o),d.splice(n,r-n+1,s))}}return Or(t,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function cCe(t,e){let r=t.get(e)[1],o=t.get(e)[2],n=e-1,a=[],i=r._tokenizer||o.parser[r.contentType](r.start),s=i.events,l=[],c={},d,u,p=-1,m=r,h=0,g=0,_=[g];for(;m;){for(;t.get(++n)[1]!==m;);a.push(n),m._tokenizer||(d=o.sliceStream(m),m.next||d.push(null),u&&i.defineSkip(m.start),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),u=m,m=m.next}for(m=r;++p<s.length;)s[p][0]==="exit"&&s[p-1][0]==="enter"&&s[p][1].type===s[p-1][1].type&&s[p][1].start.line!==s[p][1].end.line&&(g=p+1,_.push(g),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(i.events=[],m?(m._tokenizer=void 0,m.previous=void 0):_.pop(),p=_.length;p--;){let x=s.slice(_[p],_[p+1]),b=a.pop();l.push([b,b+x.length-1]),t.splice(b,2,x)}for(l.reverse(),p=-1;++p<l.length;)c[h+l[p][0]]=h+l[p][1],h+=l[p][1]-l[p][0]-1;return c}var pP={tokenize:fCe,resolve:uCe},dCe={tokenize:pCe,partial:!0};function uCe(t){return Xy(t),t}function fCe(t,e){let r;return o;function o(s){return t.enter("content"),r=t.enter("chunkContent",{contentType:"content"}),n(s)}function n(s){return s===null?a(s):ue(s)?t.check(dCe,i,a)(s):(t.consume(s),n)}function a(s){return t.exit("chunkContent"),t.exit("content"),e(s)}function i(s){return t.consume(s),t.exit("chunkContent"),r.next=t.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,n}}function pCe(t,e,r){let o=this;return n;function n(i){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),Ne(t,a,"linePrefix")}function a(i){if(i===null||ue(i))return r(i);let s=o.events[o.events.length-1];return!o.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?e(i):t.interrupt(o.parser.constructs.flow,r,e)(i)}}function Qy(t,e,r,o,n,a,i,s,l){let c=l||Number.POSITIVE_INFINITY,d=0;return u;function u(x){return x===60?(t.enter(o),t.enter(n),t.enter(a),t.consume(x),t.exit(a),p):x===null||x===32||x===41||mc(x)?r(x):(t.enter(o),t.enter(i),t.enter(s),t.enter("chunkString",{contentType:"string"}),g(x))}function p(x){return x===62?(t.enter(a),t.consume(x),t.exit(a),t.exit(n),t.exit(o),e):(t.enter(s),t.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===62?(t.exit("chunkString"),t.exit(s),p(x)):x===null||x===60||ue(x)?r(x):(t.consume(x),x===92?h:m)}function h(x){return x===60||x===62||x===92?(t.consume(x),m):m(x)}function g(x){return!d&&(x===null||x===41||lt(x))?(t.exit("chunkString"),t.exit(s),t.exit(i),t.exit(o),e(x)):d<c&&x===40?(t.consume(x),d++,g):x===41?(t.consume(x),d--,g):x===null||x===32||x===40||mc(x)?r(x):(t.consume(x),x===92?_:g)}function _(x){return x===40||x===41||x===92?(t.consume(x),g):g(x)}}function Zy(t,e,r,o,n,a){let i=this,s=0,l;return c;function c(m){return t.enter(o),t.enter(n),t.consume(m),t.exit(n),t.enter(a),d}function d(m){return s>999||m===null||m===91||m===93&&!l||m===94&&!s&&"_hiddenFootnoteSupport"in i.parser.constructs?r(m):m===93?(t.exit(a),t.enter(n),t.consume(m),t.exit(n),t.exit(o),e):ue(m)?(t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),d):(t.enter("chunkString",{contentType:"string"}),u(m))}function u(m){return m===null||m===91||m===93||ue(m)||s++>999?(t.exit("chunkString"),d(m)):(t.consume(m),l||(l=!Be(m)),m===92?p:u)}function p(m){return m===91||m===92||m===93?(t.consume(m),s++,u):u(m)}}function Jy(t,e,r,o,n,a){let i;return s;function s(p){return p===34||p===39||p===40?(t.enter(o),t.enter(n),t.consume(p),t.exit(n),i=p===40?41:p,l):r(p)}function l(p){return p===i?(t.enter(n),t.consume(p),t.exit(n),t.exit(o),e):(t.enter(a),c(p))}function c(p){return p===i?(t.exit(a),l(i)):p===null?r(p):ue(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),Ne(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===i||p===null||ue(p)?(t.exit("chunkString"),c(p)):(t.consume(p),p===92?u:d)}function u(p){return p===i||p===92?(t.consume(p),d):d(p)}}function gc(t,e){let r;return o;function o(n){return ue(n)?(t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),r=!0,o):Be(n)?Ne(t,o,r?"linePrefix":"lineSuffix")(n):e(n)}}var mP={name:"definition",tokenize:hCe},mCe={tokenize:gCe,partial:!0};function hCe(t,e,r){let o=this,n;return a;function a(m){return t.enter("definition"),i(m)}function i(m){return Zy.call(o,t,s,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function s(m){return n=ko(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)),m===58?(t.enter("definitionMarker"),t.consume(m),t.exit("definitionMarker"),l):r(m)}function l(m){return lt(m)?gc(t,c)(m):c(m)}function c(m){return Qy(t,d,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function d(m){return t.attempt(mCe,u,u)(m)}function u(m){return Be(m)?Ne(t,p,"whitespace")(m):p(m)}function p(m){return m===null||ue(m)?(t.exit("definition"),o.parser.defined.push(n),e(m)):r(m)}}function gCe(t,e,r){return o;function o(s){return lt(s)?gc(t,n)(s):r(s)}function n(s){return Jy(t,a,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function a(s){return Be(s)?Ne(t,i,"whitespace")(s):i(s)}function i(s){return s===null||ue(s)?e(s):r(s)}}var hP={name:"hardBreakEscape",tokenize:_Ce};function _Ce(t,e,r){return o;function o(a){return t.enter("hardBreakEscape"),t.consume(a),n}function n(a){return ue(a)?(t.exit("hardBreakEscape"),e(a)):r(a)}}var gP={name:"headingAtx",tokenize:bCe,resolve:xCe};function xCe(t,e){let r=t.length-2,o=3,n,a;return t[o][1].type==="whitespace"&&(o+=2),r-2>o&&t[r][1].type==="whitespace"&&(r-=2),t[r][1].type==="atxHeadingSequence"&&(o===r-1||r-4>o&&t[r-2][1].type==="whitespace")&&(r-=o+1===r?2:4),r>o&&(n={type:"atxHeadingText",start:t[o][1].start,end:t[r][1].end},a={type:"chunkText",start:t[o][1].start,end:t[r][1].end,contentType:"text"},Or(t,o,r-o+1,[["enter",n,e],["enter",a,e],["exit",a,e],["exit",n,e]])),t}function bCe(t,e,r){let o=0;return n;function n(d){return t.enter("atxHeading"),a(d)}function a(d){return t.enter("atxHeadingSequence"),i(d)}function i(d){return d===35&&o++<6?(t.consume(d),i):d===null||lt(d)?(t.exit("atxHeadingSequence"),s(d)):r(d)}function s(d){return d===35?(t.enter("atxHeadingSequence"),l(d)):d===null||ue(d)?(t.exit("atxHeading"),e(d)):Be(d)?Ne(t,s,"whitespace")(d):(t.enter("atxHeadingText"),c(d))}function l(d){return d===35?(t.consume(d),l):(t.exit("atxHeadingSequence"),s(d))}function c(d){return d===null||d===35||lt(d)?(t.exit("atxHeadingText"),s(d)):(t.consume(d),c)}}var Xq=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],_P=["pre","script","style","textarea"];var xP={name:"htmlFlow",tokenize:wCe,resolveTo:ICe,concrete:!0},vCe={tokenize:SCe,partial:!0},yCe={tokenize:ECe,partial:!0};function ICe(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function wCe(t,e,r){let o=this,n,a,i,s,l;return c;function c(D){return d(D)}function d(D){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(D),u}function u(D){return D===33?(t.consume(D),p):D===47?(t.consume(D),a=!0,g):D===63?(t.consume(D),n=3,o.interrupt?e:O):Fr(D)?(t.consume(D),i=String.fromCharCode(D),_):r(D)}function p(D){return D===45?(t.consume(D),n=2,m):D===91?(t.consume(D),n=5,s=0,h):Fr(D)?(t.consume(D),n=4,o.interrupt?e:O):r(D)}function m(D){return D===45?(t.consume(D),o.interrupt?e:O):r(D)}function h(D){let le="CDATA[";return D===le.charCodeAt(s++)?(t.consume(D),s===le.length?o.interrupt?e:A:h):r(D)}function g(D){return Fr(D)?(t.consume(D),i=String.fromCharCode(D),_):r(D)}function _(D){if(D===null||D===47||D===62||lt(D)){let le=D===47,we=i.toLowerCase();return!le&&!a&&_P.includes(we)?(n=1,o.interrupt?e(D):A(D)):Xq.includes(i.toLowerCase())?(n=6,le?(t.consume(D),x):o.interrupt?e(D):A(D)):(n=7,o.interrupt&&!o.parser.lazy[o.now().line]?r(D):a?b(D):v(D))}return D===45||zr(D)?(t.consume(D),i+=String.fromCharCode(D),_):r(D)}function x(D){return D===62?(t.consume(D),o.interrupt?e:A):r(D)}function b(D){return Be(D)?(t.consume(D),b):S(D)}function v(D){return D===47?(t.consume(D),S):D===58||D===95||Fr(D)?(t.consume(D),I):Be(D)?(t.consume(D),v):S(D)}function I(D){return D===45||D===46||D===58||D===95||zr(D)?(t.consume(D),I):E(D)}function E(D){return D===61?(t.consume(D),y):Be(D)?(t.consume(D),E):v(D)}function y(D){return D===null||D===60||D===61||D===62||D===96?r(D):D===34||D===39?(t.consume(D),l=D,C):Be(D)?(t.consume(D),y):T(D)}function C(D){return D===l?(t.consume(D),l=null,k):D===null||ue(D)?r(D):(t.consume(D),C)}function T(D){return D===null||D===34||D===39||D===47||D===60||D===61||D===62||D===96||lt(D)?E(D):(t.consume(D),T)}function k(D){return D===47||D===62||Be(D)?v(D):r(D)}function S(D){return D===62?(t.consume(D),R):r(D)}function R(D){return D===null||ue(D)?A(D):Be(D)?(t.consume(D),R):r(D)}function A(D){return D===45&&n===2?(t.consume(D),B):D===60&&n===1?(t.consume(D),$):D===62&&n===4?(t.consume(D),J):D===63&&n===3?(t.consume(D),O):D===93&&n===5?(t.consume(D),q):ue(D)&&(n===6||n===7)?(t.exit("htmlFlowData"),t.check(vCe,oe,N)(D)):D===null||ue(D)?(t.exit("htmlFlowData"),N(D)):(t.consume(D),A)}function N(D){return t.check(yCe,z,oe)(D)}function z(D){return t.enter("lineEnding"),t.consume(D),t.exit("lineEnding"),F}function F(D){return D===null||ue(D)?N(D):(t.enter("htmlFlowData"),A(D))}function B(D){return D===45?(t.consume(D),O):A(D)}function $(D){return D===47?(t.consume(D),i="",V):A(D)}function V(D){if(D===62){let le=i.toLowerCase();return _P.includes(le)?(t.consume(D),J):A(D)}return Fr(D)&&i.length<8?(t.consume(D),i+=String.fromCharCode(D),V):A(D)}function q(D){return D===93?(t.consume(D),O):A(D)}function O(D){return D===62?(t.consume(D),J):D===45&&n===2?(t.consume(D),O):A(D)}function J(D){return D===null||ue(D)?(t.exit("htmlFlowData"),oe(D)):(t.consume(D),J)}function oe(D){return t.exit("htmlFlow"),e(D)}}function ECe(t,e,r){let o=this;return n;function n(i){return ue(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),a):r(i)}function a(i){return o.parser.lazy[o.now().line]?r(i):e(i)}}function SCe(t,e,r){return o;function o(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),t.attempt(ei,e,r)}}var bP={name:"htmlText",tokenize:CCe};function CCe(t,e,r){let o=this,n,a,i;return s;function s(O){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(O),l}function l(O){return O===33?(t.consume(O),c):O===47?(t.consume(O),E):O===63?(t.consume(O),v):Fr(O)?(t.consume(O),T):r(O)}function c(O){return O===45?(t.consume(O),d):O===91?(t.consume(O),a=0,h):Fr(O)?(t.consume(O),b):r(O)}function d(O){return O===45?(t.consume(O),m):r(O)}function u(O){return O===null?r(O):O===45?(t.consume(O),p):ue(O)?(i=u,$(O)):(t.consume(O),u)}function p(O){return O===45?(t.consume(O),m):u(O)}function m(O){return O===62?B(O):O===45?p(O):u(O)}function h(O){let J="CDATA[";return O===J.charCodeAt(a++)?(t.consume(O),a===J.length?g:h):r(O)}function g(O){return O===null?r(O):O===93?(t.consume(O),_):ue(O)?(i=g,$(O)):(t.consume(O),g)}function _(O){return O===93?(t.consume(O),x):g(O)}function x(O){return O===62?B(O):O===93?(t.consume(O),x):g(O)}function b(O){return O===null||O===62?B(O):ue(O)?(i=b,$(O)):(t.consume(O),b)}function v(O){return O===null?r(O):O===63?(t.consume(O),I):ue(O)?(i=v,$(O)):(t.consume(O),v)}function I(O){return O===62?B(O):v(O)}function E(O){return Fr(O)?(t.consume(O),y):r(O)}function y(O){return O===45||zr(O)?(t.consume(O),y):C(O)}function C(O){return ue(O)?(i=C,$(O)):Be(O)?(t.consume(O),C):B(O)}function T(O){return O===45||zr(O)?(t.consume(O),T):O===47||O===62||lt(O)?k(O):r(O)}function k(O){return O===47?(t.consume(O),B):O===58||O===95||Fr(O)?(t.consume(O),S):ue(O)?(i=k,$(O)):Be(O)?(t.consume(O),k):B(O)}function S(O){return O===45||O===46||O===58||O===95||zr(O)?(t.consume(O),S):R(O)}function R(O){return O===61?(t.consume(O),A):ue(O)?(i=R,$(O)):Be(O)?(t.consume(O),R):k(O)}function A(O){return O===null||O===60||O===61||O===62||O===96?r(O):O===34||O===39?(t.consume(O),n=O,N):ue(O)?(i=A,$(O)):Be(O)?(t.consume(O),A):(t.consume(O),z)}function N(O){return O===n?(t.consume(O),n=void 0,F):O===null?r(O):ue(O)?(i=N,$(O)):(t.consume(O),N)}function z(O){return O===null||O===34||O===39||O===60||O===61||O===96?r(O):O===47||O===62||lt(O)?k(O):(t.consume(O),z)}function F(O){return O===47||O===62||lt(O)?k(O):r(O)}function B(O){return O===62?(t.consume(O),t.exit("htmlTextData"),t.exit("htmlText"),e):r(O)}function $(O){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),V}function V(O){return Be(O)?Ne(t,q,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):q(O)}function q(O){return t.enter("htmlTextData"),i(O)}}var _c={name:"labelEnd",tokenize:ACe,resolveTo:DCe,resolveAll:OCe},kCe={tokenize:NCe},TCe={tokenize:RCe},PCe={tokenize:MCe};function OCe(t){let e=-1;for(;++e<t.length;){let r=t[e][1];(r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd")&&(t.splice(e+1,r.type==="labelImage"?4:2),r.type="data",e++)}return t}function DCe(t,e){let r=t.length,o=0,n,a,i,s;for(;r--;)if(n=t[r][1],a){if(n.type==="link"||n.type==="labelLink"&&n._inactive)break;t[r][0]==="enter"&&n.type==="labelLink"&&(n._inactive=!0)}else if(i){if(t[r][0]==="enter"&&(n.type==="labelImage"||n.type==="labelLink")&&!n._balanced&&(a=r,n.type!=="labelLink")){o=2;break}}else n.type==="labelEnd"&&(i=r);let l={type:t[a][1].type==="labelLink"?"link":"image",start:Object.assign({},t[a][1].start),end:Object.assign({},t[t.length-1][1].end)},c={type:"label",start:Object.assign({},t[a][1].start),end:Object.assign({},t[i][1].end)},d={type:"labelText",start:Object.assign({},t[a+o+2][1].end),end:Object.assign({},t[i-2][1].start)};return s=[["enter",l,e],["enter",c,e]],s=Ko(s,t.slice(a+1,a+o+3)),s=Ko(s,[["enter",d,e]]),s=Ko(s,Ds(e.parser.constructs.insideSpan.null,t.slice(a+o+4,i-3),e)),s=Ko(s,[["exit",d,e],t[i-2],t[i-1],["exit",c,e]]),s=Ko(s,t.slice(i+1)),s=Ko(s,[["exit",l,e]]),Or(t,a,t.length,s),t}function ACe(t,e,r){let o=this,n=o.events.length,a,i;for(;n--;)if((o.events[n][1].type==="labelImage"||o.events[n][1].type==="labelLink")&&!o.events[n][1]._balanced){a=o.events[n][1];break}return s;function s(p){return a?a._inactive?u(p):(i=o.parser.defined.includes(ko(o.sliceSerialize({start:a.end,end:o.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(p),t.exit("labelMarker"),t.exit("labelEnd"),l):r(p)}function l(p){return p===40?t.attempt(kCe,d,i?d:u)(p):p===91?t.attempt(TCe,d,i?c:u)(p):i?d(p):u(p)}function c(p){return t.attempt(PCe,d,u)(p)}function d(p){return e(p)}function u(p){return a._balanced=!0,r(p)}}function NCe(t,e,r){return o;function o(u){return t.enter("resource"),t.enter("resourceMarker"),t.consume(u),t.exit("resourceMarker"),n}function n(u){return lt(u)?gc(t,a)(u):a(u)}function a(u){return u===41?d(u):Qy(t,i,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(u)}function i(u){return lt(u)?gc(t,l)(u):d(u)}function s(u){return r(u)}function l(u){return u===34||u===39||u===40?Jy(t,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(u):d(u)}function c(u){return lt(u)?gc(t,d)(u):d(u)}function d(u){return u===41?(t.enter("resourceMarker"),t.consume(u),t.exit("resourceMarker"),t.exit("resource"),e):r(u)}}function RCe(t,e,r){let o=this;return n;function n(s){return Zy.call(o,t,a,i,"reference","referenceMarker","referenceString")(s)}function a(s){return o.parser.defined.includes(ko(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?e(s):r(s)}function i(s){return r(s)}}function MCe(t,e,r){return o;function o(a){return t.enter("reference"),t.enter("referenceMarker"),t.consume(a),t.exit("referenceMarker"),n}function n(a){return a===93?(t.enter("referenceMarker"),t.consume(a),t.exit("referenceMarker"),t.exit("reference"),e):r(a)}}var vP={name:"labelStartImage",tokenize:LCe,resolveAll:_c.resolveAll};function LCe(t,e,r){let o=this;return n;function n(s){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(s),t.exit("labelImageMarker"),a}function a(s){return s===91?(t.enter("labelMarker"),t.consume(s),t.exit("labelMarker"),t.exit("labelImage"),i):r(s)}function i(s){return s===94&&"_hiddenFootnoteSupport"in o.parser.constructs?r(s):e(s)}}var yP={name:"labelStartLink",tokenize:BCe,resolveAll:_c.resolveAll};function BCe(t,e,r){let o=this;return n;function n(i){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(i),t.exit("labelMarker"),t.exit("labelLink"),a}function a(i){return i===94&&"_hiddenFootnoteSupport"in o.parser.constructs?r(i):e(i)}}var rh={name:"lineEnding",tokenize:FCe};function FCe(t,e){return r;function r(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),Ne(t,e,"linePrefix")}}var xc={name:"thematicBreak",tokenize:zCe};function zCe(t,e,r){let o=0,n;return a;function a(c){return t.enter("thematicBreak"),i(c)}function i(c){return n=c,s(c)}function s(c){return c===n?(t.enter("thematicBreakSequence"),l(c)):o>=3&&(c===null||ue(c))?(t.exit("thematicBreak"),e(c)):r(c)}function l(c){return c===n?(t.consume(c),o++,l):(t.exit("thematicBreakSequence"),Be(c)?Ne(t,s,"whitespace")(c):s(c))}}var To={name:"list",tokenize:$Ce,continuation:{tokenize:HCe},exit:qCe},UCe={tokenize:GCe,partial:!0},VCe={tokenize:jCe,partial:!0};function $Ce(t,e,r){let o=this,n=o.events[o.events.length-1],a=n&&n[1].type==="linePrefix"?n[2].sliceSerialize(n[1],!0).length:0,i=0;return s;function s(m){let h=o.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(h==="listUnordered"?!o.containerState.marker||m===o.containerState.marker:Zm(m)){if(o.containerState.type||(o.containerState.type=h,t.enter(h,{_container:!0})),h==="listUnordered")return t.enter("listItemPrefix"),m===42||m===45?t.check(xc,r,c)(m):c(m);if(!o.interrupt||m===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(m)}return r(m)}function l(m){return Zm(m)&&++i<10?(t.consume(m),l):(!o.interrupt||i<2)&&(o.containerState.marker?m===o.containerState.marker:m===41||m===46)?(t.exit("listItemValue"),c(m)):r(m)}function c(m){return t.enter("listItemMarker"),t.consume(m),t.exit("listItemMarker"),o.containerState.marker=o.containerState.marker||m,t.check(ei,o.interrupt?r:d,t.attempt(UCe,p,u))}function d(m){return o.containerState.initialBlankLine=!0,a++,p(m)}function u(m){return Be(m)?(t.enter("listItemPrefixWhitespace"),t.consume(m),t.exit("listItemPrefixWhitespace"),p):r(m)}function p(m){return o.containerState.size=a+o.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(m)}}function HCe(t,e,r){let o=this;return o.containerState._closeFlow=void 0,t.check(ei,n,a);function n(s){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,Ne(t,e,"listItemIndent",o.containerState.size+1)(s)}function a(s){return o.containerState.furtherBlankLines||!Be(s)?(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,i(s)):(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,t.attempt(VCe,e,i)(s))}function i(s){return o.containerState._closeFlow=!0,o.interrupt=void 0,Ne(t,t.attempt(To,e,r),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function jCe(t,e,r){let o=this;return Ne(t,n,"listItemIndent",o.containerState.size+1);function n(a){let i=o.events[o.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===o.containerState.size?e(a):r(a)}}function qCe(t){t.exit(this.containerState.type)}function GCe(t,e,r){let o=this;return Ne(t,n,"listItemPrefixWhitespace",o.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function n(a){let i=o.events[o.events.length-1];return!Be(a)&&i&&i[1].type==="listItemPrefixWhitespace"?e(a):r(a)}}var eI={name:"setextUnderline",tokenize:KCe,resolveTo:WCe};function WCe(t,e){let r=t.length,o,n,a;for(;r--;)if(t[r][0]==="enter"){if(t[r][1].type==="content"){o=r;break}t[r][1].type==="paragraph"&&(n=r)}else t[r][1].type==="content"&&t.splice(r,1),!a&&t[r][1].type==="definition"&&(a=r);let i={type:"setextHeading",start:Object.assign({},t[n][1].start),end:Object.assign({},t[t.length-1][1].end)};return t[n][1].type="setextHeadingText",a?(t.splice(n,0,["enter",i,e]),t.splice(a+1,0,["exit",t[o][1],e]),t[o][1].end=Object.assign({},t[a][1].end)):t[o][1]=i,t.push(["exit",i,e]),t}function KCe(t,e,r){let o=this,n;return a;function a(c){let d=o.events.length,u;for(;d--;)if(o.events[d][1].type!=="lineEnding"&&o.events[d][1].type!=="linePrefix"&&o.events[d][1].type!=="content"){u=o.events[d][1].type==="paragraph";break}return!o.parser.lazy[o.now().line]&&(o.interrupt||u)?(t.enter("setextHeadingLine"),n=c,i(c)):r(c)}function i(c){return t.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===n?(t.consume(c),s):(t.exit("setextHeadingLineSequence"),Be(c)?Ne(t,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ue(c)?(t.exit("setextHeadingLine"),e(c)):r(c)}}var Qq={tokenize:YCe};function YCe(t){let e=this,r=t.attempt(ei,o,t.attempt(this.parser.constructs.flowInitial,n,Ne(t,t.attempt(this.parser.constructs.flow,n,t.attempt(pP,n)),"linePrefix")));return r;function o(a){if(a===null){t.consume(a);return}return t.enter("lineEndingBlank"),t.consume(a),t.exit("lineEndingBlank"),e.currentConstruct=void 0,r}function n(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),e.currentConstruct=void 0,r}}var Zq={resolveAll:rG()},Jq=tG("string"),eG=tG("text");function tG(t){return{tokenize:e,resolveAll:rG(t==="text"?XCe:void 0)};function e(r){let o=this,n=this.parser.constructs[t],a=r.attempt(n,i,s);return i;function i(d){return c(d)?a(d):s(d)}function s(d){if(d===null){r.consume(d);return}return r.enter("data"),r.consume(d),l}function l(d){return c(d)?(r.exit("data"),a(d)):(r.consume(d),l)}function c(d){if(d===null)return!0;let u=n[d],p=-1;if(u)for(;++p<u.length;){let m=u[p];if(!m.previous||m.previous.call(o,o.previous))return!0}return!1}}}function rG(t){return e;function e(r,o){let n=-1,a;for(;++n<=r.length;)a===void 0?r[n]&&r[n][1].type==="data"&&(a=n,n++):(!r[n]||r[n][1].type!=="data")&&(n!==a+2&&(r[a][1].end=r[n-1][1].end,r.splice(a+2,n-a-2),n=a+2),a=void 0);return t?t(r,o):r}}function XCe(t,e){let r=0;for(;++r<=t.length;)if((r===t.length||t[r][1].type==="lineEnding")&&t[r-1][1].type==="data"){let o=t[r-1][1],n=e.sliceStream(o),a=n.length,i=-1,s=0,l;for(;a--;){let c=n[a];if(typeof c=="string"){for(i=c.length;c.charCodeAt(i-1)===32;)s++,i--;if(i)break;i=-1}else if(c===-2)l=!0,s++;else if(c!==-1){a++;break}}if(s){let c={type:r===t.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{line:o.end.line,column:o.end.column-s,offset:o.end.offset-s,_index:o.start._index+a,_bufferIndex:a?i:o.start._bufferIndex+i},end:Object.assign({},o.end)};o.end=Object.assign({},c.start),o.start.offset===o.end.offset?Object.assign(o,c):(t.splice(r,0,["enter",c,e],["exit",c,e]),r+=2)}r++}return t}function oG(t,e,r){let o=Object.assign(r?Object.assign({},r):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1}),n={},a=[],i=[],s=[],l=!0,c={consume:I,enter:E,exit:y,attempt:k(C),check:k(T),interrupt:k(T,{interrupt:!0})},d={previous:null,code:null,containerState:{},events:[],parser:t,sliceStream:g,sliceSerialize:h,now:_,defineSkip:x,write:m},u=e.tokenize.call(d,c),p;return e.resolveAll&&a.push(e),d;function m(N){return i=Ko(i,N),b(),i[i.length-1]!==null?[]:(S(e,0),d.events=Ds(a,d.events,d),d.events)}function h(N,z){return ZCe(g(N),z)}function g(N){return QCe(i,N)}function _(){let{line:N,column:z,offset:F,_index:B,_bufferIndex:$}=o;return{line:N,column:z,offset:F,_index:B,_bufferIndex:$}}function x(N){n[N.line]=N.column,A()}function b(){let N;for(;o._index<i.length;){let z=i[o._index];if(typeof z=="string")for(N=o._index,o._bufferIndex<0&&(o._bufferIndex=0);o._index===N&&o._bufferIndex<z.length;)v(z.charCodeAt(o._bufferIndex));else v(z)}}function v(N){l=void 0,p=N,u=u(N)}function I(N){ue(N)?(o.line++,o.column=1,o.offset+=N===-3?2:1,A()):N!==-1&&(o.column++,o.offset++),o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===i[o._index].length&&(o._bufferIndex=-1,o._index++)),d.previous=N,l=!0}function E(N,z){let F=z||{};return F.type=N,F.start=_(),d.events.push(["enter",F,d]),s.push(F),F}function y(N){let z=s.pop();return z.end=_(),d.events.push(["exit",z,d]),z}function C(N,z){S(N,z.from)}function T(N,z){z.restore()}function k(N,z){return F;function F(B,$,V){let q,O,J,oe;return Array.isArray(B)?le(B):"tokenize"in B?le([B]):D(B);function D(ke){return _e;function _e(et){let wt=et!==null&&ke[et],He=et!==null&&ke.null,Xe=[...Array.isArray(wt)?wt:wt?[wt]:[],...Array.isArray(He)?He:He?[He]:[]];return le(Xe)(et)}}function le(ke){return q=ke,O=0,ke.length===0?V:we(ke[O])}function we(ke){return _e;function _e(et){return oe=R(),J=ke,ke.partial||(d.currentConstruct=ke),ke.name&&d.parser.constructs.disable.null.includes(ke.name)?Qe(et):ke.tokenize.call(z?Object.assign(Object.create(d),z):d,c,$e,Qe)(et)}}function $e(ke){return l=!0,N(J,oe),$}function Qe(ke){return l=!0,oe.restore(),++O<q.length?we(q[O]):V}}}function S(N,z){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&Or(d.events,z,d.events.length-z,N.resolve(d.events.slice(z),d)),N.resolveTo&&(d.events=N.resolveTo(d.events,d))}function R(){let N=_(),z=d.previous,F=d.currentConstruct,B=d.events.length,$=Array.from(s);return{restore:V,from:B};function V(){o=N,d.previous=z,d.currentConstruct=F,d.events.length=B,s=$,A()}}function A(){o.line in n&&o.column<2&&(o.column=n[o.line],o.offset+=n[o.line]-1)}}function QCe(t,e){let r=e.start._index,o=e.start._bufferIndex,n=e.end._index,a=e.end._bufferIndex,i;if(r===n)i=[t[r].slice(o,a)];else{if(i=t.slice(r,n),o>-1){let s=i[0];typeof s=="string"?i[0]=s.slice(o):i.shift()}a>0&&i.push(t[n].slice(0,a))}return i}function ZCe(t,e){let r=-1,o=[],n;for(;++r<t.length;){let a=t[r],i;if(typeof a=="string")i=a;else switch(a){case-5:{i="\r";break}case-4:{i=`
|
|
52
52
|
`;break}case-3:{i=`\r
|
|
53
|
-
`;break}case-2:{i=e?" ":" ";break}case-1:{if(!e&&n)continue;i=" ";break}default:i=String.fromCharCode(a)}n=a===-2,o.push(i)}return o.join("")}var IP={};dN(IP,{attentionMarkers:()=>ike,contentInitial:()=>eke,disable:()=>ske,document:()=>JCe,flow:()=>rke,flowInitial:()=>tke,insideSpan:()=>ake,string:()=>oke,text:()=>nke});var JCe={42:To,43:To,45:To,48:To,49:To,50:To,51:To,52:To,53:To,54:To,55:To,56:To,57:To,62:qy},eke={91:mP},tke={[-2]:eh,[-1]:eh,32:eh},rke={35:gP,42:xc,45:[eI,xc],60:xP,61:eI,95:xc,96:Ky,126:Ky},oke={38:Wy,92:Gy},nke={[-5]:rh,[-4]:rh,[-3]:rh,33:vP,38:Wy,42:Jm,60:[uP,bP],91:yP,92:[hP,Gy],93:_c,95:Jm,96:fP},ake={null:[Jm,Zq]},ike={null:[42,95]},ske={null:[]};function wP(t){let r=Hy([IP,...(t||{}).extensions||[]]),o={defined:[],lazy:{},constructs:r,content:n(qq),document:n(Wq),flow:n(Qq),string:n(Jq),text:n(eG)};return o;function n(a){return i;function i(s){return oG(o,a,s)}}}function EP(t){for(;!Xy(t););return t}var nG=/[\0\t\n\r]/g;function SP(){let t=1,e="",r=!0,o;return n;function n(a,i,s){let l=[],c,d,u,p,m;for(a=e+(typeof a=="string"?a.toString():new TextDecoder(i||void 0).decode(a)),u=0,e="",r&&(a.charCodeAt(0)===65279&&u++,r=void 0);u<a.length;){if(nG.lastIndex=u,c=nG.exec(a),p=c&&c.index!==void 0?c.index:a.length,m=a.charCodeAt(p),!c){e=a.slice(u);break}if(m===10&&u===p&&o)l.push(-3),o=void 0;else switch(o&&(l.push(-5),o=void 0),u<p&&(l.push(a.slice(u,p)),t+=p-u),m){case 0:{l.push(65533),t++;break}case 9:{for(d=Math.ceil(t/4)*4,l.push(-2);t++<d;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:o=!0,t=1}u=p+1}return s&&(o&&l.push(-5),e&&l.push(e),l.push(null)),l}}var lke=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function aG(t){return t.replace(lke,cke)}function cke(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),a=n===120||n===88;return jy(r.slice(a?2:1),a?16:10)}return Pu(r)||t}function Du(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?iG(t.position):"start"in t||"end"in t?iG(t):"line"in t||"column"in t?CP(t):""}function CP(t){return sG(t&&t.line)+":"+sG(t&&t.column)}function iG(t){return CP(t&&t.start)+"-"+CP(t&&t.end)}function sG(t){return t&&typeof t=="number"?t:1}var cG={}.hasOwnProperty;function kP(t,e,r){return typeof e!="string"&&(r=e,e=void 0),dke(r)(EP(wP(r).document().write(SP()(t,e,!0))))}function dke(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Et),autolinkProtocol:k,autolinkEmail:k,atxHeading:a(Vr),blockQuote:a(et),characterEscape:k,characterReference:k,codeFenced:a(wt),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:a(wt,i),codeText:a(He,i),codeTextData:k,data:k,codeFlowValue:k,definition:a(Xe),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:a(tt),hardBreakEscape:a(ht),hardBreakTrailing:a(ht),htmlFlow:a(ce,i),htmlFlowData:k,htmlText:a(ce,i),htmlTextData:k,image:a(Po),label:i,link:a(Et),listItem:a(Dr),listItemValue:p,listOrdered:a(qe,u),listUnordered:a(qe),paragraph:a(vr),reference:D,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:a(Vr),strong:a(Jr),thematicBreak:a(Q)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:_e,autolinkProtocol:ke,blockQuote:l(),characterEscapeValue:S,characterReferenceMarkerHexadecimal:we,characterReferenceMarkerNumeric:we,characterReferenceValue:$e,characterReference:Qe,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:S,codeIndented:l(x),codeText:l(F),codeTextData:S,data:S,definition:l(),definitionDestinationString:I,definitionLabelString:b,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(N),htmlFlowData:S,htmlText:l(z),htmlTextData:S,image:l($),label:q,labelText:V,lineEnding:R,link:l(B),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:le,resourceDestinationString:O,resourceTitleString:J,resource:oe,setextHeading:l(T),setextHeadingLineSequence:C,setextHeadingText:y,strong:l(),thematicBreak:l()}};dG(e,(t||{}).mdastExtensions||[]);let r={};return o;function o(M){let j={type:"root",children:[]},re={stack:[j],tokenStack:[],config:e,enter:s,exit:c,buffer:i,resume:d,data:r},Se=[],Ze=-1;for(;++Ze<M.length;)if(M[Ze][1].type==="listOrdered"||M[Ze][1].type==="listUnordered")if(M[Ze][0]==="enter")Se.push(Ze);else{let pt=Se.pop();Ze=n(M,pt,Ze)}for(Ze=-1;++Ze<M.length;){let pt=e[M[Ze][0]];cG.call(pt,M[Ze][1].type)&&pt[M[Ze][1].type].call(Object.assign({sliceSerialize:M[Ze][2].sliceSerialize},re),M[Ze][1])}if(re.tokenStack.length>0){let pt=re.tokenStack[re.tokenStack.length-1];(pt[1]||lG).call(re,void 0,pt[0])}for(j.position={start:As(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:As(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},Ze=-1;++Ze<e.transforms.length;)j=e.transforms[Ze](j)||j;return j}function n(M,j,re){let Se=j-1,Ze=-1,pt=!1,Jo,ur,or,An;for(;++Se<=re;){let eo=M[Se];switch(eo[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{eo[0]==="enter"?Ze++:Ze--,An=void 0;break}case"lineEndingBlank":{eo[0]==="enter"&&(Jo&&!An&&!Ze&&!or&&(or=Se),An=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:An=void 0}if(!Ze&&eo[0]==="enter"&&eo[1].type==="listItemPrefix"||Ze===-1&&eo[0]==="exit"&&(eo[1].type==="listUnordered"||eo[1].type==="listOrdered")){if(Jo){let Oo=Se;for(ur=void 0;Oo--;){let Do=M[Oo];if(Do[1].type==="lineEnding"||Do[1].type==="lineEndingBlank"){if(Do[0]==="exit")continue;ur&&(M[ur][1].type="lineEndingBlank",pt=!0),Do[1].type="lineEnding",ur=Oo}else if(!(Do[1].type==="linePrefix"||Do[1].type==="blockQuotePrefix"||Do[1].type==="blockQuotePrefixWhitespace"||Do[1].type==="blockQuoteMarker"||Do[1].type==="listItemIndent"))break}or&&(!ur||or<ur)&&(Jo._spread=!0),Jo.end=Object.assign({},ur?M[ur][1].start:eo[1].end),M.splice(ur||Se,0,["exit",Jo,eo[2]]),Se++,re++}if(eo[1].type==="listItemPrefix"){let Oo={type:"listItem",_spread:!1,start:Object.assign({},eo[1].start),end:void 0};Jo=Oo,M.splice(Se,0,["enter",Oo,eo[2]]),Se++,re++,or=void 0,An=!0}}}return M[j][1]._spread=pt,re}function a(M,j){return re;function re(Se){s.call(this,M(Se),Se),j&&j.call(this,Se)}}function i(){this.stack.push({type:"fragment",children:[]})}function s(M,j,re){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([j,re]),M.position={start:As(j.start),end:void 0}}function l(M){return j;function j(re){M&&M.call(this,re),c.call(this,re)}}function c(M,j){let re=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==M.type&&(j?j.call(this,M,Se[0]):(Se[1]||lG).call(this,M,Se[0]));else throw new Error("Cannot close `"+M.type+"` ("+Du({start:M.start,end:M.end})+"): it\u2019s not open");re.position.end=As(M.end)}function d(){return dP(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function p(M){if(this.data.expectingFirstListItemValue){let j=this.stack[this.stack.length-2];j.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function m(){let M=this.resume(),j=this.stack[this.stack.length-1];j.lang=M}function h(){let M=this.resume(),j=this.stack[this.stack.length-1];j.meta=M}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M.replace(/(\r?\n|\r)$/g,"")}function b(M){let j=this.resume(),re=this.stack[this.stack.length-1];re.label=j,re.identifier=ko(this.sliceSerialize(M)).toLowerCase()}function v(){let M=this.resume(),j=this.stack[this.stack.length-1];j.title=M}function I(){let M=this.resume(),j=this.stack[this.stack.length-1];j.url=M}function E(M){let j=this.stack[this.stack.length-1];if(!j.depth){let re=this.sliceSerialize(M).length;j.depth=re}}function y(){this.data.setextHeadingSlurpLineEnding=!0}function C(M){let j=this.stack[this.stack.length-1];j.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function k(M){let re=this.stack[this.stack.length-1].children,Se=re[re.length-1];(!Se||Se.type!=="text")&&(Se=ve(),Se.position={start:As(M.start),end:void 0},re.push(Se)),this.stack.push(Se)}function S(M){let j=this.stack.pop();j.value+=this.sliceSerialize(M),j.position.end=As(M.end)}function R(M){let j=this.stack[this.stack.length-1];if(this.data.atHardBreak){let re=j.children[j.children.length-1];re.position.end=As(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(j.type)&&(k.call(this,M),S.call(this,M))}function A(){this.data.atHardBreak=!0}function N(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M}function z(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M}function F(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M}function B(){let M=this.stack[this.stack.length-1];if(this.data.inReference){let j=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=j,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function $(){let M=this.stack[this.stack.length-1];if(this.data.inReference){let j=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=j,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function V(M){let j=this.sliceSerialize(M),re=this.stack[this.stack.length-2];re.label=aG(j),re.identifier=ko(j).toLowerCase()}function q(){let M=this.stack[this.stack.length-1],j=this.resume(),re=this.stack[this.stack.length-1];if(this.data.inReference=!0,re.type==="link"){let Se=M.children;re.children=Se}else re.alt=j}function O(){let M=this.resume(),j=this.stack[this.stack.length-1];j.url=M}function J(){let M=this.resume(),j=this.stack[this.stack.length-1];j.title=M}function oe(){this.data.inReference=void 0}function D(){this.data.referenceType="collapsed"}function le(M){let j=this.resume(),re=this.stack[this.stack.length-1];re.label=j,re.identifier=ko(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function we(M){this.data.characterReferenceType=M.type}function $e(M){let j=this.sliceSerialize(M),re=this.data.characterReferenceType,Se;re?(Se=jy(j,re==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=Pu(j);let Ze=this.stack[this.stack.length-1];Ze.value+=Se}function Qe(M){let j=this.stack.pop();j.position.end=As(M.end)}function ke(M){S.call(this,M);let j=this.stack[this.stack.length-1];j.url=this.sliceSerialize(M)}function _e(M){S.call(this,M);let j=this.stack[this.stack.length-1];j.url="mailto:"+this.sliceSerialize(M)}function et(){return{type:"blockquote",children:[]}}function wt(){return{type:"code",lang:null,meta:null,value:""}}function He(){return{type:"inlineCode",value:""}}function Xe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function tt(){return{type:"emphasis",children:[]}}function Vr(){return{type:"heading",depth:0,children:[]}}function ht(){return{type:"break"}}function ce(){return{type:"html",value:""}}function Po(){return{type:"image",title:null,url:"",alt:null}}function Et(){return{type:"link",title:null,url:"",children:[]}}function qe(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Dr(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function vr(){return{type:"paragraph",children:[]}}function Jr(){return{type:"strong",children:[]}}function ve(){return{type:"text",value:""}}function Q(){return{type:"thematicBreak"}}}function As(t){return{line:t.line,column:t.column,offset:t.offset}}function dG(t,e){let r=-1;for(;++r<e.length;){let o=e[r];Array.isArray(o)?dG(t,o):uke(t,o)}}function uke(t,e){let r;for(r in e)if(cG.call(e,r))switch(r){case"canContainEols":{let o=e[r];o&&t[r].push(...o);break}case"transforms":{let o=e[r];o&&t[r].push(...o);break}case"enter":case"exit":{let o=e[r];o&&Object.assign(t[r],o);break}}}function lG(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Du({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Du({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Du({start:e.start,end:e.end})+") is still open")}function TP(t,e){let r=String(t);if(typeof e!="string")throw new TypeError("Expected character");let o=0,n=r.indexOf(e);for(;n!==-1;)o++,n=r.indexOf(e,n+e.length);return o}function PP(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Au=function(t){if(t==null)return hke;if(typeof t=="function")return tI(t);if(typeof t=="object")return Array.isArray(t)?fke(t):pke(t);if(typeof t=="string")return mke(t);throw new Error("Expected function, string, or object as test")};function fke(t){let e=[],r=-1;for(;++r<t.length;)e[r]=Au(t[r]);return tI(o);function o(...n){let a=-1;for(;++a<e.length;)if(e[a].apply(this,n))return!0;return!1}}function pke(t){let e=t;return tI(r);function r(o){let n=o,a;for(a in t)if(n[a]!==e[a])return!1;return!0}}function mke(t){return tI(e);function e(r){return r&&r.type===t}}function tI(t){return e;function e(r,o,n){return!!(gke(r)&&t.call(this,r,typeof o=="number"?o:void 0,n||void 0))}}function hke(){return!0}function gke(t){return t!==null&&typeof t=="object"&&"type"in t}var uG=[],fG=!0,OP=!1,pG="skip";function DP(t,e,r,o){let n;typeof e=="function"&&typeof r!="function"?(o=r,r=e):n=e;let a=Au(n),i=o?-1:1;s(t,void 0,[])();function s(l,c,d){let u=l&&typeof l=="object"?l:{};if(typeof u.type=="string"){let m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=uG,h,g,_;if((!e||a(l,c,d[d.length-1]||void 0))&&(m=_ke(r(l,d)),m[0]===OP))return m;if("children"in l&&l.children){let x=l;if(x.children&&m[0]!==pG)for(g=(o?x.children.length:-1)+i,_=d.concat(x);g>-1&&g<x.children.length;){let b=x.children[g];if(h=s(b,g,_)(),h[0]===OP)return h;g=typeof h[1]=="number"?h[1]:g+i}}return m}}}function _ke(t){return Array.isArray(t)?t:typeof t=="number"?[fG,t]:t==null?uG:[t]}function AP(t,e,r){let n=Au((r||{}).ignore||[]),a=xke(e),i=-1;for(;++i<a.length;)DP(t,"text",s);function s(c,d){let u=-1,p;for(;++u<d.length;){let m=d[u],h=p?p.children:void 0;if(n(m,h?h.indexOf(m):void 0,p))return;p=m}if(p)return l(c,d)}function l(c,d){let u=d[d.length-1],p=a[i][0],m=a[i][1],h=0,_=u.children.indexOf(c),x=!1,b=[];p.lastIndex=0;let v=p.exec(c.value);for(;v;){let I=v.index,E={index:v.index,input:v.input,stack:[...d,c]},y=m(...v,E);if(typeof y=="string"&&(y=y.length>0?{type:"text",value:y}:void 0),y===!1?p.lastIndex=I+1:(h!==I&&b.push({type:"text",value:c.value.slice(h,I)}),Array.isArray(y)?b.push(...y):y&&b.push(y),h=I+v[0].length,x=!0),!p.global)break;v=p.exec(c.value)}return x?(h<c.value.length&&b.push({type:"text",value:c.value.slice(h)}),u.children.splice(_,1,...b)):b=[c],_+b.length}}function xke(t){let e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");let r=!t[0]||Array.isArray(t[0])?t:[t],o=-1;for(;++o<r.length;){let n=r[o];e.push([bke(n[0]),vke(n[1])])}return e}function bke(t){return typeof t=="string"?new RegExp(PP(t),"g"):t}function vke(t){return typeof t=="function"?t:function(){return t}}function RP(){return{transforms:[Cke],enter:{literalAutolink:yke,literalAutolinkEmail:NP,literalAutolinkHttp:NP,literalAutolinkWww:NP},exit:{literalAutolink:Ske,literalAutolinkEmail:Eke,literalAutolinkHttp:Ike,literalAutolinkWww:wke}}}function yke(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function NP(t){this.config.enter.autolinkProtocol.call(this,t)}function Ike(t){this.config.exit.autolinkProtocol.call(this,t)}function wke(t){this.config.exit.data.call(this,t);let e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function Eke(t){this.config.exit.autolinkEmail.call(this,t)}function Ske(t){this.exit(t)}function Cke(t){AP(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,kke],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,Tke]],{ignore:["link","linkReference"]})}function kke(t,e,r,o,n){let a="";if(!mG(n)||(/^w/i.test(e)&&(r=e+r,e="",a="http://"),!Pke(r)))return!1;let i=Oke(r+o);if(!i[0])return!1;let s={type:"link",title:null,url:a+e+i[0],children:[{type:"text",value:e+i[0]}]};return i[1]?[s,{type:"text",value:i[1]}]:s}function Tke(t,e,r,o){return!mG(o,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function Pke(t){let e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function Oke(t){let e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let r=e[0],o=r.indexOf(")"),n=TP(t,"("),a=TP(t,")");for(;o!==-1&&n>a;)t+=r.slice(0,o+1),r=r.slice(o+1),o=r.indexOf(")"),a++;return[t,r]}function mG(t,e){let r=t.input.charCodeAt(t.index-1);return(t.index===0||Ja(r)||hc(r))&&(!e||r!==47)}Uke.peek=Vke;function MP(){return{enter:{gfmFootnoteDefinition:Ake,gfmFootnoteDefinitionLabelString:Nke,gfmFootnoteCall:Lke,gfmFootnoteCallString:Bke},exit:{gfmFootnoteDefinition:Mke,gfmFootnoteDefinitionLabelString:Rke,gfmFootnoteCall:zke,gfmFootnoteCallString:Fke}}}function Ake(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function Nke(){this.buffer()}function Rke(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=ko(this.sliceSerialize(t)).toLowerCase()}function Mke(t){this.exit(t)}function Lke(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function Bke(){this.buffer()}function Fke(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=ko(this.sliceSerialize(t)).toLowerCase()}function zke(t){this.exit(t)}function Uke(t,e,r,o){let n=r.createTracker(o),a=n.move("[^"),i=r.enter("footnoteReference"),s=r.enter("reference");return a+=n.move(r.safe(r.associationId(t),{...n.current(),before:a,after:"]"})),s(),i(),a+=n.move("]"),a}function Vke(){return"["}qke.peek=Gke;function LP(){return{canContainEols:["delete"],enter:{strikethrough:Hke},exit:{strikethrough:jke}}}function Hke(t){this.enter({type:"delete",children:[]},t)}function jke(t){this.exit(t)}function qke(t,e,r,o){let n=r.createTracker(o),a=r.enter("strikethrough"),i=n.move("~~");return i+=r.containerPhrasing(t,{...n.current(),before:i,after:"~"}),i+=n.move("~~"),a(),i}function Gke(){return"~"}function FP(){return{enter:{table:Kke,tableData:hG,tableHeader:hG,tableRow:Xke},exit:{codeText:Qke,table:Yke,tableData:BP,tableHeader:BP,tableRow:BP}}}function Kke(t){let e=t._align;this.enter({type:"table",align:e.map(function(r){return r==="none"?null:r}),children:[]},t),this.data.inTable=!0}function Yke(t){this.exit(t),this.data.inTable=void 0}function Xke(t){this.enter({type:"tableRow",children:[]},t)}function BP(t){this.exit(t)}function hG(t){this.enter({type:"tableCell",children:[]},t)}function Qke(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,Zke));let r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function Zke(t,e){return e==="|"?e:t}function zP(){return{exit:{taskListCheckValueChecked:gG,taskListCheckValueUnchecked:gG,paragraph:eTe}}}function gG(t){let e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function eTe(t){let e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){let r=this.stack[this.stack.length-1];r.type;let o=r.children[0];if(o&&o.type==="text"){let n=e.children,a=-1,i;for(;++a<n.length;){let s=n[a];if(s.type==="paragraph"){i=s;break}}i===r&&(o.value=o.value.slice(1),o.value.length===0?r.children.shift():r.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,r.position.start=Object.assign({},o.position.start)))}}this.exit(t)}function UP(){return[RP(),MP(),LP(),FP(),zP()]}var rTe={tokenize:sTe,partial:!0},_G={tokenize:lTe,partial:!0},xG={tokenize:cTe,partial:!0},bG={tokenize:dTe,partial:!0},oTe={tokenize:uTe,partial:!0},vG={tokenize:aTe,previous:IG},yG={tokenize:iTe,previous:wG},Di={tokenize:nTe,previous:EG},ti={};function $P(){return{text:ti}}var bc=48;for(;bc<123;)ti[bc]=Di,bc++,bc===58?bc=65:bc===91&&(bc=97);ti[43]=Di;ti[45]=Di;ti[46]=Di;ti[95]=Di;ti[72]=[Di,yG];ti[104]=[Di,yG];ti[87]=[Di,vG];ti[119]=[Di,vG];function nTe(t,e,r){let o=this,n,a;return i;function i(u){return!VP(u)||!EG.call(o,o.previous)||HP(o.events)?r(u):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(u))}function s(u){return VP(u)?(t.consume(u),s):u===64?(t.consume(u),l):r(u)}function l(u){return u===46?t.check(oTe,d,c)(u):u===45||u===95||zr(u)?(a=!0,t.consume(u),l):d(u)}function c(u){return t.consume(u),n=!0,l}function d(u){return a&&n&&Fr(o.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(u)):r(u)}}function aTe(t,e,r){let o=this;return n;function n(i){return i!==87&&i!==119||!IG.call(o,o.previous)||HP(o.events)?r(i):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(rTe,t.attempt(_G,t.attempt(xG,a),r),r)(i))}function a(i){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(i)}}function iTe(t,e,r){let o=this,n="",a=!1;return i;function i(u){return(u===72||u===104)&&wG.call(o,o.previous)&&!HP(o.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),n+=String.fromCodePoint(u),t.consume(u),s):r(u)}function s(u){if(Fr(u)&&n.length<5)return n+=String.fromCodePoint(u),t.consume(u),s;if(u===58){let p=n.toLowerCase();if(p==="http"||p==="https")return t.consume(u),l}return r(u)}function l(u){return u===47?(t.consume(u),a?c:(a=!0,l)):r(u)}function c(u){return u===null||mc(u)||lt(u)||Ja(u)||hc(u)?r(u):t.attempt(_G,t.attempt(xG,d),r)(u)}function d(u){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(u)}}function sTe(t,e,r){let o=0;return n;function n(i){return(i===87||i===119)&&o<3?(o++,t.consume(i),n):i===46&&o===3?(t.consume(i),a):r(i)}function a(i){return i===null?r(i):e(i)}}function lTe(t,e,r){let o,n,a;return i;function i(c){return c===46||c===95?t.check(bG,l,s)(c):c===null||lt(c)||Ja(c)||c!==45&&hc(c)?l(c):(a=!0,t.consume(c),i)}function s(c){return c===95?o=!0:(n=o,o=void 0),t.consume(c),i}function l(c){return n||o||!a?r(c):e(c)}}function cTe(t,e){let r=0,o=0;return n;function n(i){return i===40?(r++,t.consume(i),n):i===41&&o<r?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?t.check(bG,e,a)(i):i===null||lt(i)||Ja(i)?e(i):(t.consume(i),n)}function a(i){return i===41&&o++,t.consume(i),n}}function dTe(t,e,r){return o;function o(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(t.consume(s),o):s===38?(t.consume(s),a):s===93?(t.consume(s),n):s===60||s===null||lt(s)||Ja(s)?e(s):r(s)}function n(s){return s===null||s===40||s===91||lt(s)||Ja(s)?e(s):o(s)}function a(s){return Fr(s)?i(s):r(s)}function i(s){return s===59?(t.consume(s),o):Fr(s)?(t.consume(s),i):r(s)}}function uTe(t,e,r){return o;function o(a){return t.consume(a),n}function n(a){return zr(a)?r(a):e(a)}}function IG(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||lt(t)}function wG(t){return!Fr(t)}function EG(t){return!(t===47||VP(t))}function VP(t){return t===43||t===45||t===46||t===95||zr(t)}function HP(t){let e=t.length,r=!1;for(;e--;){let o=t[e][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){r=!0;break}if(o._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}var fTe={tokenize:bTe,partial:!0};function jP(){return{document:{91:{tokenize:gTe,continuation:{tokenize:_Te},exit:xTe}},text:{91:{tokenize:hTe},93:{add:"after",tokenize:pTe,resolveTo:mTe}}}}function pTe(t,e,r){let o=this,n=o.events.length,a=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i;for(;n--;){let l=o.events[n][1];if(l.type==="labelImage"){i=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!i||!i._balanced)return r(l);let c=ko(o.sliceSerialize({start:i.end,end:o.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?r(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function mTe(t,e){let r=t.length,o;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){o=t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";let n={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;let i={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[t[r+1],t[r+2],["enter",n,e],t[r+3],t[r+4],["enter",a,e],["exit",a,e],["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e],t[t.length-2],t[t.length-1],["exit",n,e]];return t.splice(r,t.length-r+1,...l),t}function hTe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a=0,i;return s;function s(u){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),l}function l(u){return u!==94?r(u):(t.enter("gfmFootnoteCallMarker"),t.consume(u),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(u){if(a>999||u===93&&!i||u===null||u===91||lt(u))return r(u);if(u===93){t.exit("chunkString");let p=t.exit("gfmFootnoteCallString");return n.includes(ko(o.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(u)}return lt(u)||(i=!0),a++,t.consume(u),u===92?d:c}function d(u){return u===91||u===92||u===93?(t.consume(u),a++,c):c(u)}}function gTe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a,i=0,s;return l;function l(h){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(h){return h===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",d):r(h)}function d(h){if(i>999||h===93&&!s||h===null||h===91||lt(h))return r(h);if(h===93){t.exit("chunkString");let g=t.exit("gfmFootnoteDefinitionLabelString");return a=ko(o.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return lt(h)||(s=!0),i++,t.consume(h),h===92?u:d}function u(h){return h===91||h===92||h===93?(t.consume(h),i++,d):d(h)}function p(h){return h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),n.includes(a)||n.push(a),Ne(t,m,"gfmFootnoteDefinitionWhitespace")):r(h)}function m(h){return e(h)}}function _Te(t,e,r){return t.check(ei,e,t.attempt(fTe,e,r))}function xTe(t){t.exit("gfmFootnoteDefinition")}function bTe(t,e,r){let o=this;return Ne(t,n,"gfmFootnoteDefinitionIndent",5);function n(a){let i=o.events[o.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?e(a):r(a)}}function qP(t){let r=(t||{}).singleTilde,o={tokenize:a,resolveAll:n};return r==null&&(r=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function n(i,s){let l=-1;for(;++l<i.length;)if(i[l][0]==="enter"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._close){let c=l;for(;c--;)if(i[c][0]==="exit"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._open&&i[l][1].end.offset-i[l][1].start.offset===i[c][1].end.offset-i[c][1].start.offset){i[l][1].type="strikethroughSequence",i[c][1].type="strikethroughSequence";let d={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[l][1].end)},u={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[l][1].start)},p=[["enter",d,s],["enter",i[c][1],s],["exit",i[c][1],s],["enter",u,s]],m=s.parser.constructs.insideSpan.null;m&&Or(p,p.length,0,Ds(m,i.slice(c+1,l),s)),Or(p,p.length,0,[["exit",u,s],["enter",i[l][1],s],["exit",i[l][1],s],["exit",d,s]]),Or(i,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<i.length;)i[l][1].type==="strikethroughSequenceTemporary"&&(i[l][1].type="data");return i}function a(i,s,l){let c=this.previous,d=this.events,u=0;return p;function p(h){return c===126&&d[d.length-1][1].type!=="characterEscape"?l(h):(i.enter("strikethroughSequenceTemporary"),m(h))}function m(h){let g=Ou(c);if(h===126)return u>1?l(h):(i.consume(h),u++,m);if(u<2&&!r)return l(h);let _=i.exit("strikethroughSequenceTemporary"),x=Ou(h);return _._open=!x||x===2&&!!g,_._close=!g||g===2&&!!x,s(h)}}}var rI=class{constructor(){this.map=[]}add(e,r,o){vTe(this,e,r,o)}consume(e){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let r=this.map.length,o=[];for(;r>0;)r-=1,o.push(e.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),e.length=this.map[r][0];o.push([...e]),e.length=0;let n=o.pop();for(;n;)e.push(...n),n=o.pop();this.map.length=0}};function vTe(t,e,r,o){let n=0;if(!(r===0&&o.length===0)){for(;n<t.map.length;){if(t.map[n][0]===e){t.map[n][1]+=r,t.map[n][2].push(...o);return}n+=1}t.map.push([e,r,o])}}function SG(t,e){let r=!1,o=[];for(;e<t.length;){let n=t[e];if(r){if(n[0]==="enter")n[1].type==="tableContent"&&o.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(n[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){let a=o.length-1;o[a]=o[a]==="left"?"center":"right"}}else if(n[1].type==="tableDelimiterRow")break}else n[0]==="enter"&&n[1].type==="tableDelimiterRow"&&(r=!0);e+=1}return o}function GP(){return{flow:{null:{tokenize:yTe,resolveAll:ITe}}}}function yTe(t,e,r){let o=this,n=0,a=0,i;return s;function s(S){let R=o.events.length-1;for(;R>-1;){let z=o.events[R][1].type;if(z==="lineEnding"||z==="linePrefix")R--;else break}let A=R>-1?o.events[R][1].type:null,N=A==="tableHead"||A==="tableRow"?y:l;return N===y&&o.parser.lazy[o.now().line]?r(S):N(S)}function l(S){return t.enter("tableHead"),t.enter("tableRow"),c(S)}function c(S){return S===124||(i=!0,a+=1),d(S)}function d(S){return S===null?r(S):ue(S)?a>1?(a=0,o.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),m):r(S):Be(S)?Ne(t,d,"whitespace")(S):(a+=1,i&&(i=!1,n+=1),S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),i=!0,d):(t.enter("data"),u(S)))}function u(S){return S===null||S===124||lt(S)?(t.exit("data"),d(S)):(t.consume(S),S===92?p:u)}function p(S){return S===92||S===124?(t.consume(S),u):u(S)}function m(S){return o.interrupt=!1,o.parser.lazy[o.now().line]?r(S):(t.enter("tableDelimiterRow"),i=!1,Be(S)?Ne(t,h,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):h(S))}function h(S){return S===45||S===58?_(S):S===124?(i=!0,t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),g):E(S)}function g(S){return Be(S)?Ne(t,_,"whitespace")(S):_(S)}function _(S){return S===58?(a+=1,i=!0,t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),x):S===45?(a+=1,x(S)):S===null||ue(S)?I(S):E(S)}function x(S){return S===45?(t.enter("tableDelimiterFiller"),b(S)):E(S)}function b(S){return S===45?(t.consume(S),b):S===58?(i=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),v):(t.exit("tableDelimiterFiller"),v(S))}function v(S){return Be(S)?Ne(t,I,"whitespace")(S):I(S)}function I(S){return S===124?h(S):S===null||ue(S)?!i||n!==a?E(S):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(S)):E(S)}function E(S){return r(S)}function y(S){return t.enter("tableRow"),C(S)}function C(S){return S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),C):S===null||ue(S)?(t.exit("tableRow"),e(S)):Be(S)?Ne(t,C,"whitespace")(S):(t.enter("data"),T(S))}function T(S){return S===null||S===124||lt(S)?(t.exit("data"),C(S)):(t.consume(S),S===92?k:T)}function k(S){return S===92||S===124?(t.consume(S),T):T(S)}}function ITe(t,e){let r=-1,o=!0,n=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,l=0,c,d,u,p=new rI;for(;++r<t.length;){let m=t[r],h=m[1];m[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(CG(p,e,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(r,0,[["enter",c,e]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(o=!0,u=void 0,a=[0,0,0,0],i=[0,r+1,0,0],s&&(s=!1,d={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(r,0,[["enter",d,e]])),n=h.type==="tableDelimiterRow"?2:d?3:1):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(o=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],u=oI(p,e,a,n,void 0,u),a=[0,0,0,0]),i[2]=r)):h.type==="tableCellDivider"&&(o?o=!1:(a[1]!==0&&(i[0]=i[1],u=oI(p,e,a,n,void 0,u)),a=i,i=[a[1],r,0,0])):h.type==="tableHead"?(s=!0,l=r):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=r,a[1]!==0?(i[0]=i[1],u=oI(p,e,a,n,r,u)):i[1]!==0&&(u=oI(p,e,i,n,r,u)),n=0):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(i[3]=r)}for(l!==0&&CG(p,e,l,c,d),p.consume(e.events),r=-1;++r<e.events.length;){let m=e.events[r];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=SG(e.events,r))}return t}function oI(t,e,r,o,n,a){let i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";r[0]!==0&&(a.end=Object.assign({},Nu(e.events,r[0])),t.add(r[0],0,[["exit",a,e]]));let l=Nu(e.events,r[1]);if(a={type:i,start:Object.assign({},l),end:Object.assign({},l)},t.add(r[1],0,[["enter",a,e]]),r[2]!==0){let c=Nu(e.events,r[2]),d=Nu(e.events,r[3]),u={type:s,start:Object.assign({},c),end:Object.assign({},d)};if(t.add(r[2],0,[["enter",u,e]]),o!==2){let p=e.events[r[2]],m=e.events[r[3]];if(p[1].end=Object.assign({},m[1].end),p[1].type="chunkText",p[1].contentType="text",r[3]>r[2]+1){let h=r[2]+1,g=r[3]-r[2]-1;t.add(h,g,[])}}t.add(r[3]+1,0,[["exit",u,e]])}return n!==void 0&&(a.end=Object.assign({},Nu(e.events,n)),t.add(n,0,[["exit",a,e]]),a=void 0),a}function CG(t,e,r,o,n){let a=[],i=Nu(e.events,r);n&&(n.end=Object.assign({},i),a.push(["exit",n,e])),o.end=Object.assign({},i),a.push(["exit",o,e]),t.add(r+1,0,a)}function Nu(t,e){let r=t[e],o=r[0]==="enter"?"start":"end";return r[1][o]}var wTe={tokenize:ETe};function WP(){return{text:{91:wTe}}}function ETe(t,e,r){let o=this;return n;function n(l){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?r(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),a)}function a(l){return lt(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),i):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),i):r(l)}function i(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),s):r(l)}function s(l){return ue(l)?e(l):Be(l)?t.check({tokenize:STe},e,r)(l):r(l)}}function STe(t,e,r){return Ne(t,o,"whitespace");function o(n){return n===null?r(n):e(n)}}function kG(t){return Hy([$P(),jP(),qP(t),GP(),WP()])}ye();var TG={name:"@blinkk/root-cms",version:"2.0.0",author:"s@blinkk.com",license:"MIT",engines:{node:">=16.0.0"},repository:{type:"git",url:"git+https://github.com/blinkk/rootjs.git",directory:"packages/root-cms"},files:["dist/**/*"],bin:{"root-cms":"./bin/root-cms.js"},type:"module",module:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./client":{types:"./dist/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/richtext.d.ts",import:"./dist/richtext.js"}},scripts:{build:'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',"build:core":"tsup-node --config=./core/tsup.config.ts","//":"NOTE: esbuild is used here because tsup doesn't currently support aliases.","build:ui":"esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui",dev:'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',"dev:core":"pnpm build:core --watch","dev:signin":"pnpm build:signin --watch","dev:ui":"pnpm build:ui --watch",test:"pnpm build && firebase emulators:exec 'vitest run'","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@genkit-ai/ai":"1.15.5","@genkit-ai/core":"1.15.5","@genkit-ai/vertexai":"1.15.5","@hello-pangea/dnd":"18.0.1","body-parser":"1.20.2",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","dts-dom":"3.7.0","fnv-plus":"1.3.1",genkit:"1.15.5",jsonwebtoken:"9.0.2",kleur:"4.1.5",sirv:"2.0.3","tiny-glob":"0.2.9"},"//":"NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",devDependencies:{"@babel/core":"7.17.9","@blinkk/root":"workspace:*","@editorjs/editorjs":"2.30.8","@editorjs/header":"2.8.8","@editorjs/image":"2.10.2","@editorjs/list":"2.0.6","@editorjs/nested-list":"1.4.3","@editorjs/raw":"2.5.1","@editorjs/table":"2.4.4","@editorjs/underline":"1.2.1","@emotion/react":"11.10.5","@firebase/app-compat":"0.2.19","@firebase/app-types":"0.9.0","@firebase/rules-unit-testing":"3.0.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@mantine/spotlight":"4.2.12","@preact/compat":"17.1.2","@tabler/icons-preact":"2.47.0","@types/body-parser":"1.19.3","@types/fnv-plus":"1.3.2","@types/gapi":"0.0.47","@types/gapi.client.drive-v3":"0.0.4","@types/gapi.client.sheets-v4":"0.0.4","@types/google.accounts":"0.0.14","@types/jsonwebtoken":"9.0.1","@types/node":"18.11.8",concurrently:"7.6.0",esbuild:"0.19.9",firebase:"10.5.2","firebase-admin":"11.11.1","firebase-functions":"4.8.0","firebase-tools":"12.9.1","highlight.js":"11.6.0","json-diff-kit":"1.0.29",marked:"9.1.1","mdast-util-from-markdown":"2.0.1","mdast-util-gfm":"3.0.0","micromark-extension-gfm":"3.0.0",preact:"10.19.3","preact-render-to-string":"6.3.1","preact-router":"4.1.2",react:"npm:@preact/compat@^17.1.2","react-dom":"npm:@preact/compat@^17.1.2","react-json-view-compare":"2.0.2",tsup:"8.0.1",typescript:"5.2.2",vite:"5.0.8",vitest:"0.34.6"},peerDependencies:{"@blinkk/root":"2.0.0","firebase-admin":">=11","firebase-functions":">=4",preact:">=10","preact-render-to-string":">=5"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function PG(){return f("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("g",{"clip-path":"url(#clip0_1_318)",children:[f("path",{d:"M7.82998 5.01802C3.12925 5.6479 0.833937 18.1194 2.62578 19.6731C5.64773 22.2934 16.6441 14.1722 15.6786 9.46913C15.3009 6.61371 11.2717 4.28377 7.82998 5.01802Z",fill:"black"}),f("path",{d:"M13.9782 0.720147C12.6553 0.896474 12.0093 4.38767 12.5136 4.8226C13.364 5.55611 16.4587 3.28271 16.187 1.96616C16.0807 1.16683 14.9468 0.514607 13.9782 0.720147Z",fill:"black"}),f("path",{d:"M92.7383 17.6275C90.9681 17.6275 89.3816 17.0263 88.3796 16.0744C87.9955 15.7237 87.8953 15.3396 88.246 14.9555L88.8305 14.2541C89.1645 13.87 89.5486 13.7865 89.9327 14.1205C90.6007 14.6883 91.7029 15.1726 92.5713 15.1726C93.5232 15.1726 94.1244 14.8219 94.1244 14.2875C94.1244 13.5193 93.2059 13.4358 91.9868 13.0684C90.417 12.6008 88.5132 11.7324 88.5132 9.64493C88.5132 7.70773 90.25 6.37173 92.7383 6.37173C94.2413 6.37173 95.5272 6.87273 96.4123 7.57413C96.8131 7.90813 96.9467 8.27553 96.596 8.67633L96.0282 9.37773C95.7109 9.76183 95.3435 9.82863 94.926 9.51133C94.3916 9.09383 93.6568 8.69303 92.7884 8.69303C92.0202 8.69303 91.5192 9.01033 91.5192 9.51133C91.5192 10.1292 92.3041 10.4131 93.1224 10.6636C94.9761 11.2314 97.1304 11.8326 97.1304 14.2708C97.1304 16.4585 95.1264 17.6275 92.7383 17.6275Z",fill:"black"}),f("path",{d:"M87.0008 16.6756C87.0843 17.1766 86.8171 17.4271 86.2994 17.4271H85.097C84.596 17.4271 84.3789 17.1766 84.3121 16.6756L83.7443 11.9161L81.757 16.7424C81.5399 17.2434 81.1892 17.5106 80.6882 17.5106H80.5212C80.0202 17.5106 79.6695 17.2434 79.4524 16.7424L77.4651 11.8994L76.8973 16.6756C76.8472 17.1766 76.6301 17.4271 76.1291 17.4271H74.7263C74.2086 17.4271 73.9414 17.1766 74.0082 16.6756L75.4945 7.24013C75.5613 6.75583 75.8786 6.48863 76.3796 6.48863H76.5466C77.0476 6.48863 77.3315 6.75583 77.5486 7.24013L80.6047 13.8032L83.4938 7.24013C83.7109 6.75583 84.0115 6.48863 84.4958 6.48863H84.6795C85.1638 6.48863 85.4811 6.75583 85.5646 7.24013L87.0008 16.6756Z",fill:"black"}),f("path",{d:"M68.6496 17.6275C65.3096 17.6275 62.7211 15.2227 62.7211 11.9996C62.7211 8.77653 65.3096 6.37173 68.683 6.37173C70.3029 6.37173 71.7558 6.97293 72.7745 7.99163C73.1419 8.34233 73.1419 8.77653 72.7745 9.09383L71.9228 9.81193C71.5554 10.1292 71.2047 10.1125 70.8206 9.79523C70.2361 9.31093 69.5013 9.01033 68.683 9.01033C67.013 9.01033 65.7104 10.2628 65.7104 11.9996C65.7104 13.7364 67.013 14.9889 68.683 14.9889C69.5013 14.9889 70.2528 14.6883 70.8206 14.204C71.2047 13.8867 71.5554 13.87 71.9228 14.1873L72.7745 14.9054C73.1419 15.2227 73.1419 15.6569 72.7745 16.0076C71.7558 17.0263 70.3029 17.6275 68.6496 17.6275Z",fill:"black"}),f("path",{d:"M58.575 16.2915C58.7587 16.6923 58.4581 16.8927 58.241 17.0597C57.7233 17.4271 56.9384 17.6442 56.1201 17.6442C54.4501 17.6442 52.8469 16.6923 52.8469 14.4044V11.0978H52.1121C51.6111 11.0978 51.3439 10.8139 51.3439 10.3296V9.76183C51.3439 9.26083 51.6111 8.99363 52.1121 8.99363H52.8469V7.05643C52.8469 6.57213 53.1308 6.38843 53.6151 6.28823L54.9511 6.05443C55.4521 5.95423 55.7193 6.30493 55.7193 6.80593V8.99363H57.3726C57.8569 8.99363 58.1408 9.26083 58.1408 9.76183V10.3296C58.1408 10.8139 57.8569 11.0978 57.3726 11.0978H55.7193V14.1038C55.7193 14.9221 56.1368 15.1893 56.6545 15.1893C56.905 15.1893 57.1555 15.0724 57.3392 14.9555C57.7567 14.6883 57.9571 14.8887 58.1074 15.206L58.575 16.2915Z",fill:"black"}),f("path",{d:"M46.2592 17.6442C43.5538 17.6442 41.5999 15.7738 41.5999 13.2521C41.5999 10.7304 43.5538 8.86003 46.2592 8.86003C48.9646 8.86003 50.9185 10.7304 50.9185 13.2521C50.9185 15.7738 48.9646 17.6442 46.2592 17.6442ZM46.2592 15.1726C47.3113 15.1726 48.0628 14.3543 48.0628 13.2521C48.0628 12.1499 47.3113 11.3316 46.2592 11.3316C45.2071 11.3316 44.4389 12.1499 44.4389 13.2521C44.4389 14.3543 45.2071 15.1726 46.2592 15.1726Z",fill:"black"}),f("path",{d:"M36.052 17.6442C33.3466 17.6442 31.3927 15.7738 31.3927 13.2521C31.3927 10.7304 33.3466 8.86003 36.052 8.86003C38.7574 8.86003 40.7113 10.7304 40.7113 13.2521C40.7113 15.7738 38.7574 17.6442 36.052 17.6442ZM36.052 15.1726C37.1041 15.1726 37.8556 14.3543 37.8556 13.2521C37.8556 12.1499 37.1041 11.3316 36.052 11.3316C34.9999 11.3316 34.2317 12.1499 34.2317 13.2521C34.2317 14.3543 34.9999 15.1726 36.052 15.1726Z",fill:"black"}),f("path",{d:"M28.7099 13.0851L30.6805 16.6422C30.9644 17.1599 30.6638 17.4271 30.1628 17.4271H28.4594C27.9417 17.4271 27.8081 17.1766 27.5242 16.6589L25.7707 13.4859H24.6351V16.6422C24.6351 17.1432 24.3512 17.4271 23.8502 17.4271H22.4808C21.9798 17.4271 21.6959 17.1432 21.6959 16.6422V7.35703C21.6959 6.85603 21.9798 6.57213 22.4808 6.57213H26.5222C29.3111 6.57213 30.8141 7.92483 30.8141 10.1125C30.8141 11.5654 29.9791 12.5841 28.7099 13.0851ZM24.6351 8.96023V11.5153H26.4721C27.2236 11.5153 27.8248 11.0644 27.8248 10.2628C27.8248 9.44453 27.2236 8.96023 26.4721 8.96023H24.6351Z",fill:"black"})]}),f("defs",{children:f("clipPath",{id:"clip0_1_318",children:f("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}var Ai="1.5";function ge(t){return f("div",{className:"Layout",children:[f(ge.Top,{}),f(ge.Side,{}),f(ge.Main,{...t,children:t.children}),f(ge.Bottom,{})]})}ge.Top=()=>{let t=window.__ROOT_CTX.rootConfig.projectName||window.__ROOT_CTX.rootConfig.projectId;return f("div",{className:"Layout__top",children:[f("a",{className:"Layout__top__logo",href:"/cms",children:f(PG,{})}),f("div",{className:"Layout__top__version",children:["v",TG.version]}),f("div",{className:"Layout__top__project",children:t})]})};ge.Side=()=>{let[t]=g7(),e=t.url.replace(/\/*$/g,""),r=window.firebase.user,o=window.__ROOT_CTX.sidebar?.tools,n=window.__ROOT_CTX.experiments||{};return f("div",{className:"Layout__side",children:[f("div",{className:"Layout__side__buttons",children:[f(ge.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:f(uT,{stroke:Ai})}),f(ge.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:f(nc,{stroke:Ai})}),f(ge.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:f(gu,{stroke:Ai})}),f(ge.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:f(aT,{stroke:Ai})}),f(ge.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:f(gT,{stroke:Ai})}),f(ge.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:f(Es,{stroke:Ai})}),n.ai&&f(ge.SideButton,{label:"Root AI (experimental)",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:f(ic,{stroke:Ai})}),o&&f(Oe,{children:[f("div",{className:"Layout__side__divider"}),Object.entries(o).map(([a,i])=>f(ge.SideButton,{className:"Layout__side__tool",label:i.label||"",url:`/cms/tools/${a}`,active:e.startsWith(`/cms/tools/${a}`),children:i.icon?f("img",{className:"Layout__side__tool__icon",src:i.icon,alt:i.label||""}):f(Jk,{stroke:Ai})})),f("div",{className:"Layout__side__divider"})]}),f(ge.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:f(sc,{stroke:Ai})})]}),f("div",{className:"Layout__side__user",children:f(Ie,{label:r.email,position:"right",withArrow:!0,children:f(qn,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})})})]})};ge.SideButton=t=>f(Ie,{className:Te("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:f("a",{className:Te(t.active&&"active"),href:t.url,children:t.children})});ge.Main=t=>f("div",{className:"Layout__main",children:t.children});ge.Bottom=()=>f("div",{className:"Layout__bottom"});var OG=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],DG=[...OG,"svg"],AG=["mp4","webm"],kTe="https://lh3.googleusercontent.com/";async function Ns(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=await ATe(t),n=Ru(t.name),a=e?.preserveFilename?`${o}/${t.name}`:`${o}.${n}`,i=`${r}/uploads/${a}`,s=f7(window.firebase.storage,i);await d7(s,t),console.log(`uploaded ${i}`);let l={};l.filename=t.name,l.uploadedBy=window.firebase.user.email||"unknown",l.uploadedAt=String(Math.floor(new Date().getTime()));let c=`/${s.bucket}/${s.fullPath}`,d=`https://storage.googleapis.com${c}`;if(DG.includes(n)){let p=await OTe(t);if(l.width=p.width,l.height=p.height,!e?.disableGci&&OG.includes(n)){let m=await PTe(c);m&&(l.gcsPath=c,d=m)}}else if(AG.includes(n)){let p=await DTe(d);l.width=p.width,l.height=p.height,console.log("video dimensions:",p)}let u=e?.cacheControl||"public, max-age=31536000";return await u7(s,{cacheControl:u,customMetadata:NTe(l)}),console.log("updated meta data: ",l),{...l,src:d}}function Ru(t){return TTe(t.split(".").at(-1)||"")}function TTe(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function PTe(t){let e=window.__ROOT_CTX.rootConfig.gci;if(!e)return"";let r=new URLSearchParams({gcs:t}),o=`${e}/_/serving_url?${r.toString()}`,n=await window.fetch(o);if(n.status!==200){let i=await n.text();throw console.error(`failed to get gci url: ${o}`),console.error(i),new Error("failed to get gci url")}return(await n.json()).servingUrl}async function OTe(t){return new Promise((e,r)=>{let o=new FileReader;o.onload=()=>{let n=new Image;n.onload=()=>{e({width:n.width,height:n.height})},n.onerror=r,n.src=String(o.result)},o.onerror=r,o.readAsDataURL(t)})}async function DTe(t){return new Promise((e,r)=>{let o=document.createElement("video");o.addEventListener("loadedmetadata",()=>{let n={width:o.videoWidth,height:o.videoHeight};e(n),document.body.removeChild(o)},!1),o.addEventListener("error",()=>{r(new Error("Failed to load video metadata")),document.body.removeChild(o)},!1),o.className="sr-only",o.src=t,o.preload="metadata",document.body.appendChild(o)})}async function ATe(t){let e=await t.arrayBuffer(),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("")}function NTe(t){let e={};return Object.entries(t).forEach(([r,o])=>{t[r]=String(o).trim()}),e}function KP(t){if(!t)return!1;if(nI(t)||t.startsWith("data:image/"))return!0;let e=Ru(t);return DG.includes(e)}function nI(t){return t?t.startsWith(kTe):!1}function YP(t){if(!t)return!1;let e=Ru(t);return AG.includes(e)}function NG(t){return nI(t)?t.split("=")[0]+"=s0-d":t}function Pa(t){t||(t=6);let e=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=r.length;for(let n=0;n<t;n++)e.push(r.charAt(Math.floor(Math.random()*o)));return e.join("")}function RG(t,e){return Math.random()*(e-t)+t}var RTe=!1,MTe=`Lorem ipsum \u{1F955} dolor sit amet.
|
|
53
|
+
`;break}case-2:{i=e?" ":" ";break}case-1:{if(!e&&n)continue;i=" ";break}default:i=String.fromCharCode(a)}n=a===-2,o.push(i)}return o.join("")}var IP={};dN(IP,{attentionMarkers:()=>ike,contentInitial:()=>eke,disable:()=>ske,document:()=>JCe,flow:()=>rke,flowInitial:()=>tke,insideSpan:()=>ake,string:()=>oke,text:()=>nke});var JCe={42:To,43:To,45:To,48:To,49:To,50:To,51:To,52:To,53:To,54:To,55:To,56:To,57:To,62:qy},eke={91:mP},tke={[-2]:eh,[-1]:eh,32:eh},rke={35:gP,42:xc,45:[eI,xc],60:xP,61:eI,95:xc,96:Ky,126:Ky},oke={38:Wy,92:Gy},nke={[-5]:rh,[-4]:rh,[-3]:rh,33:vP,38:Wy,42:Jm,60:[uP,bP],91:yP,92:[hP,Gy],93:_c,95:Jm,96:fP},ake={null:[Jm,Zq]},ike={null:[42,95]},ske={null:[]};function wP(t){let r=Hy([IP,...(t||{}).extensions||[]]),o={defined:[],lazy:{},constructs:r,content:n(qq),document:n(Wq),flow:n(Qq),string:n(Jq),text:n(eG)};return o;function n(a){return i;function i(s){return oG(o,a,s)}}}function EP(t){for(;!Xy(t););return t}var nG=/[\0\t\n\r]/g;function SP(){let t=1,e="",r=!0,o;return n;function n(a,i,s){let l=[],c,d,u,p,m;for(a=e+(typeof a=="string"?a.toString():new TextDecoder(i||void 0).decode(a)),u=0,e="",r&&(a.charCodeAt(0)===65279&&u++,r=void 0);u<a.length;){if(nG.lastIndex=u,c=nG.exec(a),p=c&&c.index!==void 0?c.index:a.length,m=a.charCodeAt(p),!c){e=a.slice(u);break}if(m===10&&u===p&&o)l.push(-3),o=void 0;else switch(o&&(l.push(-5),o=void 0),u<p&&(l.push(a.slice(u,p)),t+=p-u),m){case 0:{l.push(65533),t++;break}case 9:{for(d=Math.ceil(t/4)*4,l.push(-2);t++<d;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:o=!0,t=1}u=p+1}return s&&(o&&l.push(-5),e&&l.push(e),l.push(null)),l}}var lke=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function aG(t){return t.replace(lke,cke)}function cke(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),a=n===120||n===88;return jy(r.slice(a?2:1),a?16:10)}return Pu(r)||t}function Du(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?iG(t.position):"start"in t||"end"in t?iG(t):"line"in t||"column"in t?CP(t):""}function CP(t){return sG(t&&t.line)+":"+sG(t&&t.column)}function iG(t){return CP(t&&t.start)+"-"+CP(t&&t.end)}function sG(t){return t&&typeof t=="number"?t:1}var cG={}.hasOwnProperty;function kP(t,e,r){return typeof e!="string"&&(r=e,e=void 0),dke(r)(EP(wP(r).document().write(SP()(t,e,!0))))}function dke(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Et),autolinkProtocol:k,autolinkEmail:k,atxHeading:a(Vr),blockQuote:a(et),characterEscape:k,characterReference:k,codeFenced:a(wt),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:a(wt,i),codeText:a(He,i),codeTextData:k,data:k,codeFlowValue:k,definition:a(Xe),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:a(tt),hardBreakEscape:a(ht),hardBreakTrailing:a(ht),htmlFlow:a(ce,i),htmlFlowData:k,htmlText:a(ce,i),htmlTextData:k,image:a(Po),label:i,link:a(Et),listItem:a(Dr),listItemValue:p,listOrdered:a(qe,u),listUnordered:a(qe),paragraph:a(vr),reference:D,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:a(Vr),strong:a(Jr),thematicBreak:a(Q)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:_e,autolinkProtocol:ke,blockQuote:l(),characterEscapeValue:S,characterReferenceMarkerHexadecimal:we,characterReferenceMarkerNumeric:we,characterReferenceValue:$e,characterReference:Qe,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:S,codeIndented:l(x),codeText:l(F),codeTextData:S,data:S,definition:l(),definitionDestinationString:I,definitionLabelString:b,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(N),htmlFlowData:S,htmlText:l(z),htmlTextData:S,image:l($),label:q,labelText:V,lineEnding:R,link:l(B),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:le,resourceDestinationString:O,resourceTitleString:J,resource:oe,setextHeading:l(T),setextHeadingLineSequence:C,setextHeadingText:y,strong:l(),thematicBreak:l()}};dG(e,(t||{}).mdastExtensions||[]);let r={};return o;function o(M){let j={type:"root",children:[]},re={stack:[j],tokenStack:[],config:e,enter:s,exit:c,buffer:i,resume:d,data:r},Se=[],Ze=-1;for(;++Ze<M.length;)if(M[Ze][1].type==="listOrdered"||M[Ze][1].type==="listUnordered")if(M[Ze][0]==="enter")Se.push(Ze);else{let pt=Se.pop();Ze=n(M,pt,Ze)}for(Ze=-1;++Ze<M.length;){let pt=e[M[Ze][0]];cG.call(pt,M[Ze][1].type)&&pt[M[Ze][1].type].call(Object.assign({sliceSerialize:M[Ze][2].sliceSerialize},re),M[Ze][1])}if(re.tokenStack.length>0){let pt=re.tokenStack[re.tokenStack.length-1];(pt[1]||lG).call(re,void 0,pt[0])}for(j.position={start:As(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:As(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},Ze=-1;++Ze<e.transforms.length;)j=e.transforms[Ze](j)||j;return j}function n(M,j,re){let Se=j-1,Ze=-1,pt=!1,Jo,ur,or,An;for(;++Se<=re;){let eo=M[Se];switch(eo[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{eo[0]==="enter"?Ze++:Ze--,An=void 0;break}case"lineEndingBlank":{eo[0]==="enter"&&(Jo&&!An&&!Ze&&!or&&(or=Se),An=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:An=void 0}if(!Ze&&eo[0]==="enter"&&eo[1].type==="listItemPrefix"||Ze===-1&&eo[0]==="exit"&&(eo[1].type==="listUnordered"||eo[1].type==="listOrdered")){if(Jo){let Oo=Se;for(ur=void 0;Oo--;){let Do=M[Oo];if(Do[1].type==="lineEnding"||Do[1].type==="lineEndingBlank"){if(Do[0]==="exit")continue;ur&&(M[ur][1].type="lineEndingBlank",pt=!0),Do[1].type="lineEnding",ur=Oo}else if(!(Do[1].type==="linePrefix"||Do[1].type==="blockQuotePrefix"||Do[1].type==="blockQuotePrefixWhitespace"||Do[1].type==="blockQuoteMarker"||Do[1].type==="listItemIndent"))break}or&&(!ur||or<ur)&&(Jo._spread=!0),Jo.end=Object.assign({},ur?M[ur][1].start:eo[1].end),M.splice(ur||Se,0,["exit",Jo,eo[2]]),Se++,re++}if(eo[1].type==="listItemPrefix"){let Oo={type:"listItem",_spread:!1,start:Object.assign({},eo[1].start),end:void 0};Jo=Oo,M.splice(Se,0,["enter",Oo,eo[2]]),Se++,re++,or=void 0,An=!0}}}return M[j][1]._spread=pt,re}function a(M,j){return re;function re(Se){s.call(this,M(Se),Se),j&&j.call(this,Se)}}function i(){this.stack.push({type:"fragment",children:[]})}function s(M,j,re){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([j,re]),M.position={start:As(j.start),end:void 0}}function l(M){return j;function j(re){M&&M.call(this,re),c.call(this,re)}}function c(M,j){let re=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==M.type&&(j?j.call(this,M,Se[0]):(Se[1]||lG).call(this,M,Se[0]));else throw new Error("Cannot close `"+M.type+"` ("+Du({start:M.start,end:M.end})+"): it\u2019s not open");re.position.end=As(M.end)}function d(){return dP(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function p(M){if(this.data.expectingFirstListItemValue){let j=this.stack[this.stack.length-2];j.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function m(){let M=this.resume(),j=this.stack[this.stack.length-1];j.lang=M}function h(){let M=this.resume(),j=this.stack[this.stack.length-1];j.meta=M}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M.replace(/(\r?\n|\r)$/g,"")}function b(M){let j=this.resume(),re=this.stack[this.stack.length-1];re.label=j,re.identifier=ko(this.sliceSerialize(M)).toLowerCase()}function v(){let M=this.resume(),j=this.stack[this.stack.length-1];j.title=M}function I(){let M=this.resume(),j=this.stack[this.stack.length-1];j.url=M}function E(M){let j=this.stack[this.stack.length-1];if(!j.depth){let re=this.sliceSerialize(M).length;j.depth=re}}function y(){this.data.setextHeadingSlurpLineEnding=!0}function C(M){let j=this.stack[this.stack.length-1];j.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function k(M){let re=this.stack[this.stack.length-1].children,Se=re[re.length-1];(!Se||Se.type!=="text")&&(Se=ve(),Se.position={start:As(M.start),end:void 0},re.push(Se)),this.stack.push(Se)}function S(M){let j=this.stack.pop();j.value+=this.sliceSerialize(M),j.position.end=As(M.end)}function R(M){let j=this.stack[this.stack.length-1];if(this.data.atHardBreak){let re=j.children[j.children.length-1];re.position.end=As(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(j.type)&&(k.call(this,M),S.call(this,M))}function A(){this.data.atHardBreak=!0}function N(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M}function z(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M}function F(){let M=this.resume(),j=this.stack[this.stack.length-1];j.value=M}function B(){let M=this.stack[this.stack.length-1];if(this.data.inReference){let j=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=j,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function $(){let M=this.stack[this.stack.length-1];if(this.data.inReference){let j=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=j,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function V(M){let j=this.sliceSerialize(M),re=this.stack[this.stack.length-2];re.label=aG(j),re.identifier=ko(j).toLowerCase()}function q(){let M=this.stack[this.stack.length-1],j=this.resume(),re=this.stack[this.stack.length-1];if(this.data.inReference=!0,re.type==="link"){let Se=M.children;re.children=Se}else re.alt=j}function O(){let M=this.resume(),j=this.stack[this.stack.length-1];j.url=M}function J(){let M=this.resume(),j=this.stack[this.stack.length-1];j.title=M}function oe(){this.data.inReference=void 0}function D(){this.data.referenceType="collapsed"}function le(M){let j=this.resume(),re=this.stack[this.stack.length-1];re.label=j,re.identifier=ko(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function we(M){this.data.characterReferenceType=M.type}function $e(M){let j=this.sliceSerialize(M),re=this.data.characterReferenceType,Se;re?(Se=jy(j,re==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=Pu(j);let Ze=this.stack[this.stack.length-1];Ze.value+=Se}function Qe(M){let j=this.stack.pop();j.position.end=As(M.end)}function ke(M){S.call(this,M);let j=this.stack[this.stack.length-1];j.url=this.sliceSerialize(M)}function _e(M){S.call(this,M);let j=this.stack[this.stack.length-1];j.url="mailto:"+this.sliceSerialize(M)}function et(){return{type:"blockquote",children:[]}}function wt(){return{type:"code",lang:null,meta:null,value:""}}function He(){return{type:"inlineCode",value:""}}function Xe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function tt(){return{type:"emphasis",children:[]}}function Vr(){return{type:"heading",depth:0,children:[]}}function ht(){return{type:"break"}}function ce(){return{type:"html",value:""}}function Po(){return{type:"image",title:null,url:"",alt:null}}function Et(){return{type:"link",title:null,url:"",children:[]}}function qe(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Dr(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function vr(){return{type:"paragraph",children:[]}}function Jr(){return{type:"strong",children:[]}}function ve(){return{type:"text",value:""}}function Q(){return{type:"thematicBreak"}}}function As(t){return{line:t.line,column:t.column,offset:t.offset}}function dG(t,e){let r=-1;for(;++r<e.length;){let o=e[r];Array.isArray(o)?dG(t,o):uke(t,o)}}function uke(t,e){let r;for(r in e)if(cG.call(e,r))switch(r){case"canContainEols":{let o=e[r];o&&t[r].push(...o);break}case"transforms":{let o=e[r];o&&t[r].push(...o);break}case"enter":case"exit":{let o=e[r];o&&Object.assign(t[r],o);break}}}function lG(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Du({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Du({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Du({start:e.start,end:e.end})+") is still open")}function TP(t,e){let r=String(t);if(typeof e!="string")throw new TypeError("Expected character");let o=0,n=r.indexOf(e);for(;n!==-1;)o++,n=r.indexOf(e,n+e.length);return o}function PP(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Au=function(t){if(t==null)return hke;if(typeof t=="function")return tI(t);if(typeof t=="object")return Array.isArray(t)?fke(t):pke(t);if(typeof t=="string")return mke(t);throw new Error("Expected function, string, or object as test")};function fke(t){let e=[],r=-1;for(;++r<t.length;)e[r]=Au(t[r]);return tI(o);function o(...n){let a=-1;for(;++a<e.length;)if(e[a].apply(this,n))return!0;return!1}}function pke(t){let e=t;return tI(r);function r(o){let n=o,a;for(a in t)if(n[a]!==e[a])return!1;return!0}}function mke(t){return tI(e);function e(r){return r&&r.type===t}}function tI(t){return e;function e(r,o,n){return!!(gke(r)&&t.call(this,r,typeof o=="number"?o:void 0,n||void 0))}}function hke(){return!0}function gke(t){return t!==null&&typeof t=="object"&&"type"in t}var uG=[],fG=!0,OP=!1,pG="skip";function DP(t,e,r,o){let n;typeof e=="function"&&typeof r!="function"?(o=r,r=e):n=e;let a=Au(n),i=o?-1:1;s(t,void 0,[])();function s(l,c,d){let u=l&&typeof l=="object"?l:{};if(typeof u.type=="string"){let m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=uG,h,g,_;if((!e||a(l,c,d[d.length-1]||void 0))&&(m=_ke(r(l,d)),m[0]===OP))return m;if("children"in l&&l.children){let x=l;if(x.children&&m[0]!==pG)for(g=(o?x.children.length:-1)+i,_=d.concat(x);g>-1&&g<x.children.length;){let b=x.children[g];if(h=s(b,g,_)(),h[0]===OP)return h;g=typeof h[1]=="number"?h[1]:g+i}}return m}}}function _ke(t){return Array.isArray(t)?t:typeof t=="number"?[fG,t]:t==null?uG:[t]}function AP(t,e,r){let n=Au((r||{}).ignore||[]),a=xke(e),i=-1;for(;++i<a.length;)DP(t,"text",s);function s(c,d){let u=-1,p;for(;++u<d.length;){let m=d[u],h=p?p.children:void 0;if(n(m,h?h.indexOf(m):void 0,p))return;p=m}if(p)return l(c,d)}function l(c,d){let u=d[d.length-1],p=a[i][0],m=a[i][1],h=0,_=u.children.indexOf(c),x=!1,b=[];p.lastIndex=0;let v=p.exec(c.value);for(;v;){let I=v.index,E={index:v.index,input:v.input,stack:[...d,c]},y=m(...v,E);if(typeof y=="string"&&(y=y.length>0?{type:"text",value:y}:void 0),y===!1?p.lastIndex=I+1:(h!==I&&b.push({type:"text",value:c.value.slice(h,I)}),Array.isArray(y)?b.push(...y):y&&b.push(y),h=I+v[0].length,x=!0),!p.global)break;v=p.exec(c.value)}return x?(h<c.value.length&&b.push({type:"text",value:c.value.slice(h)}),u.children.splice(_,1,...b)):b=[c],_+b.length}}function xke(t){let e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");let r=!t[0]||Array.isArray(t[0])?t:[t],o=-1;for(;++o<r.length;){let n=r[o];e.push([bke(n[0]),vke(n[1])])}return e}function bke(t){return typeof t=="string"?new RegExp(PP(t),"g"):t}function vke(t){return typeof t=="function"?t:function(){return t}}function RP(){return{transforms:[Cke],enter:{literalAutolink:yke,literalAutolinkEmail:NP,literalAutolinkHttp:NP,literalAutolinkWww:NP},exit:{literalAutolink:Ske,literalAutolinkEmail:Eke,literalAutolinkHttp:Ike,literalAutolinkWww:wke}}}function yke(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function NP(t){this.config.enter.autolinkProtocol.call(this,t)}function Ike(t){this.config.exit.autolinkProtocol.call(this,t)}function wke(t){this.config.exit.data.call(this,t);let e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function Eke(t){this.config.exit.autolinkEmail.call(this,t)}function Ske(t){this.exit(t)}function Cke(t){AP(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,kke],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,Tke]],{ignore:["link","linkReference"]})}function kke(t,e,r,o,n){let a="";if(!mG(n)||(/^w/i.test(e)&&(r=e+r,e="",a="http://"),!Pke(r)))return!1;let i=Oke(r+o);if(!i[0])return!1;let s={type:"link",title:null,url:a+e+i[0],children:[{type:"text",value:e+i[0]}]};return i[1]?[s,{type:"text",value:i[1]}]:s}function Tke(t,e,r,o){return!mG(o,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function Pke(t){let e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function Oke(t){let e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let r=e[0],o=r.indexOf(")"),n=TP(t,"("),a=TP(t,")");for(;o!==-1&&n>a;)t+=r.slice(0,o+1),r=r.slice(o+1),o=r.indexOf(")"),a++;return[t,r]}function mG(t,e){let r=t.input.charCodeAt(t.index-1);return(t.index===0||Ja(r)||hc(r))&&(!e||r!==47)}Uke.peek=Vke;function MP(){return{enter:{gfmFootnoteDefinition:Ake,gfmFootnoteDefinitionLabelString:Nke,gfmFootnoteCall:Lke,gfmFootnoteCallString:Bke},exit:{gfmFootnoteDefinition:Mke,gfmFootnoteDefinitionLabelString:Rke,gfmFootnoteCall:zke,gfmFootnoteCallString:Fke}}}function Ake(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function Nke(){this.buffer()}function Rke(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=ko(this.sliceSerialize(t)).toLowerCase()}function Mke(t){this.exit(t)}function Lke(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function Bke(){this.buffer()}function Fke(t){let e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.label=e,r.identifier=ko(this.sliceSerialize(t)).toLowerCase()}function zke(t){this.exit(t)}function Uke(t,e,r,o){let n=r.createTracker(o),a=n.move("[^"),i=r.enter("footnoteReference"),s=r.enter("reference");return a+=n.move(r.safe(r.associationId(t),{...n.current(),before:a,after:"]"})),s(),i(),a+=n.move("]"),a}function Vke(){return"["}qke.peek=Gke;function LP(){return{canContainEols:["delete"],enter:{strikethrough:Hke},exit:{strikethrough:jke}}}function Hke(t){this.enter({type:"delete",children:[]},t)}function jke(t){this.exit(t)}function qke(t,e,r,o){let n=r.createTracker(o),a=r.enter("strikethrough"),i=n.move("~~");return i+=r.containerPhrasing(t,{...n.current(),before:i,after:"~"}),i+=n.move("~~"),a(),i}function Gke(){return"~"}function FP(){return{enter:{table:Kke,tableData:hG,tableHeader:hG,tableRow:Xke},exit:{codeText:Qke,table:Yke,tableData:BP,tableHeader:BP,tableRow:BP}}}function Kke(t){let e=t._align;this.enter({type:"table",align:e.map(function(r){return r==="none"?null:r}),children:[]},t),this.data.inTable=!0}function Yke(t){this.exit(t),this.data.inTable=void 0}function Xke(t){this.enter({type:"tableRow",children:[]},t)}function BP(t){this.exit(t)}function hG(t){this.enter({type:"tableCell",children:[]},t)}function Qke(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,Zke));let r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function Zke(t,e){return e==="|"?e:t}function zP(){return{exit:{taskListCheckValueChecked:gG,taskListCheckValueUnchecked:gG,paragraph:eTe}}}function gG(t){let e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function eTe(t){let e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){let r=this.stack[this.stack.length-1];r.type;let o=r.children[0];if(o&&o.type==="text"){let n=e.children,a=-1,i;for(;++a<n.length;){let s=n[a];if(s.type==="paragraph"){i=s;break}}i===r&&(o.value=o.value.slice(1),o.value.length===0?r.children.shift():r.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,r.position.start=Object.assign({},o.position.start)))}}this.exit(t)}function UP(){return[RP(),MP(),LP(),FP(),zP()]}var rTe={tokenize:sTe,partial:!0},_G={tokenize:lTe,partial:!0},xG={tokenize:cTe,partial:!0},bG={tokenize:dTe,partial:!0},oTe={tokenize:uTe,partial:!0},vG={tokenize:aTe,previous:IG},yG={tokenize:iTe,previous:wG},Di={tokenize:nTe,previous:EG},ti={};function $P(){return{text:ti}}var bc=48;for(;bc<123;)ti[bc]=Di,bc++,bc===58?bc=65:bc===91&&(bc=97);ti[43]=Di;ti[45]=Di;ti[46]=Di;ti[95]=Di;ti[72]=[Di,yG];ti[104]=[Di,yG];ti[87]=[Di,vG];ti[119]=[Di,vG];function nTe(t,e,r){let o=this,n,a;return i;function i(u){return!VP(u)||!EG.call(o,o.previous)||HP(o.events)?r(u):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(u))}function s(u){return VP(u)?(t.consume(u),s):u===64?(t.consume(u),l):r(u)}function l(u){return u===46?t.check(oTe,d,c)(u):u===45||u===95||zr(u)?(a=!0,t.consume(u),l):d(u)}function c(u){return t.consume(u),n=!0,l}function d(u){return a&&n&&Fr(o.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(u)):r(u)}}function aTe(t,e,r){let o=this;return n;function n(i){return i!==87&&i!==119||!IG.call(o,o.previous)||HP(o.events)?r(i):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(rTe,t.attempt(_G,t.attempt(xG,a),r),r)(i))}function a(i){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(i)}}function iTe(t,e,r){let o=this,n="",a=!1;return i;function i(u){return(u===72||u===104)&&wG.call(o,o.previous)&&!HP(o.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),n+=String.fromCodePoint(u),t.consume(u),s):r(u)}function s(u){if(Fr(u)&&n.length<5)return n+=String.fromCodePoint(u),t.consume(u),s;if(u===58){let p=n.toLowerCase();if(p==="http"||p==="https")return t.consume(u),l}return r(u)}function l(u){return u===47?(t.consume(u),a?c:(a=!0,l)):r(u)}function c(u){return u===null||mc(u)||lt(u)||Ja(u)||hc(u)?r(u):t.attempt(_G,t.attempt(xG,d),r)(u)}function d(u){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(u)}}function sTe(t,e,r){let o=0;return n;function n(i){return(i===87||i===119)&&o<3?(o++,t.consume(i),n):i===46&&o===3?(t.consume(i),a):r(i)}function a(i){return i===null?r(i):e(i)}}function lTe(t,e,r){let o,n,a;return i;function i(c){return c===46||c===95?t.check(bG,l,s)(c):c===null||lt(c)||Ja(c)||c!==45&&hc(c)?l(c):(a=!0,t.consume(c),i)}function s(c){return c===95?o=!0:(n=o,o=void 0),t.consume(c),i}function l(c){return n||o||!a?r(c):e(c)}}function cTe(t,e){let r=0,o=0;return n;function n(i){return i===40?(r++,t.consume(i),n):i===41&&o<r?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?t.check(bG,e,a)(i):i===null||lt(i)||Ja(i)?e(i):(t.consume(i),n)}function a(i){return i===41&&o++,t.consume(i),n}}function dTe(t,e,r){return o;function o(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(t.consume(s),o):s===38?(t.consume(s),a):s===93?(t.consume(s),n):s===60||s===null||lt(s)||Ja(s)?e(s):r(s)}function n(s){return s===null||s===40||s===91||lt(s)||Ja(s)?e(s):o(s)}function a(s){return Fr(s)?i(s):r(s)}function i(s){return s===59?(t.consume(s),o):Fr(s)?(t.consume(s),i):r(s)}}function uTe(t,e,r){return o;function o(a){return t.consume(a),n}function n(a){return zr(a)?r(a):e(a)}}function IG(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||lt(t)}function wG(t){return!Fr(t)}function EG(t){return!(t===47||VP(t))}function VP(t){return t===43||t===45||t===46||t===95||zr(t)}function HP(t){let e=t.length,r=!1;for(;e--;){let o=t[e][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){r=!0;break}if(o._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}var fTe={tokenize:bTe,partial:!0};function jP(){return{document:{91:{tokenize:gTe,continuation:{tokenize:_Te},exit:xTe}},text:{91:{tokenize:hTe},93:{add:"after",tokenize:pTe,resolveTo:mTe}}}}function pTe(t,e,r){let o=this,n=o.events.length,a=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i;for(;n--;){let l=o.events[n][1];if(l.type==="labelImage"){i=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!i||!i._balanced)return r(l);let c=ko(o.sliceSerialize({start:i.end,end:o.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?r(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function mTe(t,e){let r=t.length,o;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){o=t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";let n={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;let i={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[t[r+1],t[r+2],["enter",n,e],t[r+3],t[r+4],["enter",a,e],["exit",a,e],["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e],t[t.length-2],t[t.length-1],["exit",n,e]];return t.splice(r,t.length-r+1,...l),t}function hTe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a=0,i;return s;function s(u){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),l}function l(u){return u!==94?r(u):(t.enter("gfmFootnoteCallMarker"),t.consume(u),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(u){if(a>999||u===93&&!i||u===null||u===91||lt(u))return r(u);if(u===93){t.exit("chunkString");let p=t.exit("gfmFootnoteCallString");return n.includes(ko(o.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(u),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(u)}return lt(u)||(i=!0),a++,t.consume(u),u===92?d:c}function d(u){return u===91||u===92||u===93?(t.consume(u),a++,c):c(u)}}function gTe(t,e,r){let o=this,n=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),a,i=0,s;return l;function l(h){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(h){return h===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",d):r(h)}function d(h){if(i>999||h===93&&!s||h===null||h===91||lt(h))return r(h);if(h===93){t.exit("chunkString");let g=t.exit("gfmFootnoteDefinitionLabelString");return a=ko(o.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(h),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return lt(h)||(s=!0),i++,t.consume(h),h===92?u:d}function u(h){return h===91||h===92||h===93?(t.consume(h),i++,d):d(h)}function p(h){return h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),n.includes(a)||n.push(a),Ne(t,m,"gfmFootnoteDefinitionWhitespace")):r(h)}function m(h){return e(h)}}function _Te(t,e,r){return t.check(ei,e,t.attempt(fTe,e,r))}function xTe(t){t.exit("gfmFootnoteDefinition")}function bTe(t,e,r){let o=this;return Ne(t,n,"gfmFootnoteDefinitionIndent",5);function n(a){let i=o.events[o.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?e(a):r(a)}}function qP(t){let r=(t||{}).singleTilde,o={tokenize:a,resolveAll:n};return r==null&&(r=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function n(i,s){let l=-1;for(;++l<i.length;)if(i[l][0]==="enter"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._close){let c=l;for(;c--;)if(i[c][0]==="exit"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._open&&i[l][1].end.offset-i[l][1].start.offset===i[c][1].end.offset-i[c][1].start.offset){i[l][1].type="strikethroughSequence",i[c][1].type="strikethroughSequence";let d={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[l][1].end)},u={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[l][1].start)},p=[["enter",d,s],["enter",i[c][1],s],["exit",i[c][1],s],["enter",u,s]],m=s.parser.constructs.insideSpan.null;m&&Or(p,p.length,0,Ds(m,i.slice(c+1,l),s)),Or(p,p.length,0,[["exit",u,s],["enter",i[l][1],s],["exit",i[l][1],s],["exit",d,s]]),Or(i,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<i.length;)i[l][1].type==="strikethroughSequenceTemporary"&&(i[l][1].type="data");return i}function a(i,s,l){let c=this.previous,d=this.events,u=0;return p;function p(h){return c===126&&d[d.length-1][1].type!=="characterEscape"?l(h):(i.enter("strikethroughSequenceTemporary"),m(h))}function m(h){let g=Ou(c);if(h===126)return u>1?l(h):(i.consume(h),u++,m);if(u<2&&!r)return l(h);let _=i.exit("strikethroughSequenceTemporary"),x=Ou(h);return _._open=!x||x===2&&!!g,_._close=!g||g===2&&!!x,s(h)}}}var rI=class{constructor(){this.map=[]}add(e,r,o){vTe(this,e,r,o)}consume(e){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let r=this.map.length,o=[];for(;r>0;)r-=1,o.push(e.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),e.length=this.map[r][0];o.push([...e]),e.length=0;let n=o.pop();for(;n;)e.push(...n),n=o.pop();this.map.length=0}};function vTe(t,e,r,o){let n=0;if(!(r===0&&o.length===0)){for(;n<t.map.length;){if(t.map[n][0]===e){t.map[n][1]+=r,t.map[n][2].push(...o);return}n+=1}t.map.push([e,r,o])}}function SG(t,e){let r=!1,o=[];for(;e<t.length;){let n=t[e];if(r){if(n[0]==="enter")n[1].type==="tableContent"&&o.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(n[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){let a=o.length-1;o[a]=o[a]==="left"?"center":"right"}}else if(n[1].type==="tableDelimiterRow")break}else n[0]==="enter"&&n[1].type==="tableDelimiterRow"&&(r=!0);e+=1}return o}function GP(){return{flow:{null:{tokenize:yTe,resolveAll:ITe}}}}function yTe(t,e,r){let o=this,n=0,a=0,i;return s;function s(S){let R=o.events.length-1;for(;R>-1;){let z=o.events[R][1].type;if(z==="lineEnding"||z==="linePrefix")R--;else break}let A=R>-1?o.events[R][1].type:null,N=A==="tableHead"||A==="tableRow"?y:l;return N===y&&o.parser.lazy[o.now().line]?r(S):N(S)}function l(S){return t.enter("tableHead"),t.enter("tableRow"),c(S)}function c(S){return S===124||(i=!0,a+=1),d(S)}function d(S){return S===null?r(S):ue(S)?a>1?(a=0,o.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),m):r(S):Be(S)?Ne(t,d,"whitespace")(S):(a+=1,i&&(i=!1,n+=1),S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),i=!0,d):(t.enter("data"),u(S)))}function u(S){return S===null||S===124||lt(S)?(t.exit("data"),d(S)):(t.consume(S),S===92?p:u)}function p(S){return S===92||S===124?(t.consume(S),u):u(S)}function m(S){return o.interrupt=!1,o.parser.lazy[o.now().line]?r(S):(t.enter("tableDelimiterRow"),i=!1,Be(S)?Ne(t,h,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):h(S))}function h(S){return S===45||S===58?_(S):S===124?(i=!0,t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),g):E(S)}function g(S){return Be(S)?Ne(t,_,"whitespace")(S):_(S)}function _(S){return S===58?(a+=1,i=!0,t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),x):S===45?(a+=1,x(S)):S===null||ue(S)?I(S):E(S)}function x(S){return S===45?(t.enter("tableDelimiterFiller"),b(S)):E(S)}function b(S){return S===45?(t.consume(S),b):S===58?(i=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),v):(t.exit("tableDelimiterFiller"),v(S))}function v(S){return Be(S)?Ne(t,I,"whitespace")(S):I(S)}function I(S){return S===124?h(S):S===null||ue(S)?!i||n!==a?E(S):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(S)):E(S)}function E(S){return r(S)}function y(S){return t.enter("tableRow"),C(S)}function C(S){return S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),C):S===null||ue(S)?(t.exit("tableRow"),e(S)):Be(S)?Ne(t,C,"whitespace")(S):(t.enter("data"),T(S))}function T(S){return S===null||S===124||lt(S)?(t.exit("data"),C(S)):(t.consume(S),S===92?k:T)}function k(S){return S===92||S===124?(t.consume(S),T):T(S)}}function ITe(t,e){let r=-1,o=!0,n=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,l=0,c,d,u,p=new rI;for(;++r<t.length;){let m=t[r],h=m[1];m[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(CG(p,e,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(r,0,[["enter",c,e]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(o=!0,u=void 0,a=[0,0,0,0],i=[0,r+1,0,0],s&&(s=!1,d={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(r,0,[["enter",d,e]])),n=h.type==="tableDelimiterRow"?2:d?3:1):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(o=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],u=oI(p,e,a,n,void 0,u),a=[0,0,0,0]),i[2]=r)):h.type==="tableCellDivider"&&(o?o=!1:(a[1]!==0&&(i[0]=i[1],u=oI(p,e,a,n,void 0,u)),a=i,i=[a[1],r,0,0])):h.type==="tableHead"?(s=!0,l=r):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=r,a[1]!==0?(i[0]=i[1],u=oI(p,e,a,n,r,u)):i[1]!==0&&(u=oI(p,e,i,n,r,u)),n=0):n&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(i[3]=r)}for(l!==0&&CG(p,e,l,c,d),p.consume(e.events),r=-1;++r<e.events.length;){let m=e.events[r];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=SG(e.events,r))}return t}function oI(t,e,r,o,n,a){let i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";r[0]!==0&&(a.end=Object.assign({},Nu(e.events,r[0])),t.add(r[0],0,[["exit",a,e]]));let l=Nu(e.events,r[1]);if(a={type:i,start:Object.assign({},l),end:Object.assign({},l)},t.add(r[1],0,[["enter",a,e]]),r[2]!==0){let c=Nu(e.events,r[2]),d=Nu(e.events,r[3]),u={type:s,start:Object.assign({},c),end:Object.assign({},d)};if(t.add(r[2],0,[["enter",u,e]]),o!==2){let p=e.events[r[2]],m=e.events[r[3]];if(p[1].end=Object.assign({},m[1].end),p[1].type="chunkText",p[1].contentType="text",r[3]>r[2]+1){let h=r[2]+1,g=r[3]-r[2]-1;t.add(h,g,[])}}t.add(r[3]+1,0,[["exit",u,e]])}return n!==void 0&&(a.end=Object.assign({},Nu(e.events,n)),t.add(n,0,[["exit",a,e]]),a=void 0),a}function CG(t,e,r,o,n){let a=[],i=Nu(e.events,r);n&&(n.end=Object.assign({},i),a.push(["exit",n,e])),o.end=Object.assign({},i),a.push(["exit",o,e]),t.add(r+1,0,a)}function Nu(t,e){let r=t[e],o=r[0]==="enter"?"start":"end";return r[1][o]}var wTe={tokenize:ETe};function WP(){return{text:{91:wTe}}}function ETe(t,e,r){let o=this;return n;function n(l){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?r(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),a)}function a(l){return lt(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),i):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),i):r(l)}function i(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),s):r(l)}function s(l){return ue(l)?e(l):Be(l)?t.check({tokenize:STe},e,r)(l):r(l)}}function STe(t,e,r){return Ne(t,o,"whitespace");function o(n){return n===null?r(n):e(n)}}function kG(t){return Hy([$P(),jP(),qP(t),GP(),WP()])}ye();var TG={name:"@blinkk/root-cms",version:"2.0.1",author:"s@blinkk.com",license:"MIT",engines:{node:">=16.0.0"},repository:{type:"git",url:"git+https://github.com/blinkk/rootjs.git",directory:"packages/root-cms"},files:["dist/**/*"],bin:{"root-cms":"./bin/root-cms.js"},type:"module",module:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./client":{types:"./dist/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/richtext.d.ts",import:"./dist/richtext.js"}},scripts:{build:'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',"build:core":"tsup-node --config=./core/tsup.config.ts","//":"NOTE: esbuild is used here because tsup doesn't currently support aliases.","build:ui":"esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui",dev:'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',"dev:core":"pnpm build:core --watch","dev:signin":"pnpm build:signin --watch","dev:ui":"pnpm build:ui --watch",test:"pnpm build && firebase emulators:exec 'vitest run'","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@genkit-ai/ai":"1.15.5","@genkit-ai/core":"1.15.5","@genkit-ai/vertexai":"1.15.5","@hello-pangea/dnd":"18.0.1","body-parser":"1.20.2",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","dts-dom":"3.7.0","fnv-plus":"1.3.1",genkit:"1.15.5",jsonwebtoken:"9.0.2",kleur:"4.1.5",sirv:"2.0.3","tiny-glob":"0.2.9"},"//":"NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",devDependencies:{"@babel/core":"7.17.9","@blinkk/root":"workspace:*","@editorjs/editorjs":"2.30.8","@editorjs/header":"2.8.8","@editorjs/image":"2.10.2","@editorjs/list":"2.0.6","@editorjs/nested-list":"1.4.3","@editorjs/raw":"2.5.1","@editorjs/table":"2.4.4","@editorjs/underline":"1.2.1","@emotion/react":"11.10.5","@firebase/app-compat":"0.2.19","@firebase/app-types":"0.9.0","@firebase/rules-unit-testing":"3.0.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@mantine/spotlight":"4.2.12","@preact/compat":"17.1.2","@tabler/icons-preact":"2.47.0","@types/body-parser":"1.19.3","@types/fnv-plus":"1.3.2","@types/gapi":"0.0.47","@types/gapi.client.drive-v3":"0.0.4","@types/gapi.client.sheets-v4":"0.0.4","@types/google.accounts":"0.0.14","@types/jsonwebtoken":"9.0.1","@types/node":"18.11.8",concurrently:"7.6.0",esbuild:"0.19.9",firebase:"10.5.2","firebase-admin":"11.11.1","firebase-functions":"4.8.0","firebase-tools":"12.9.1","highlight.js":"11.6.0","json-diff-kit":"1.0.29",marked:"9.1.1","mdast-util-from-markdown":"2.0.1","mdast-util-gfm":"3.0.0","micromark-extension-gfm":"3.0.0",preact:"10.19.3","preact-render-to-string":"6.3.1","preact-router":"4.1.2",react:"npm:@preact/compat@^17.1.2","react-dom":"npm:@preact/compat@^17.1.2","react-json-view-compare":"2.0.2",tsup:"8.0.1",typescript:"5.2.2",vite:"5.0.8",vitest:"0.34.6"},peerDependencies:{"@blinkk/root":"2.0.1","firebase-admin":">=11","firebase-functions":">=4",preact:">=10","preact-render-to-string":">=5"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function PG(){return f("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f("g",{"clip-path":"url(#clip0_1_318)",children:[f("path",{d:"M7.82998 5.01802C3.12925 5.6479 0.833937 18.1194 2.62578 19.6731C5.64773 22.2934 16.6441 14.1722 15.6786 9.46913C15.3009 6.61371 11.2717 4.28377 7.82998 5.01802Z",fill:"black"}),f("path",{d:"M13.9782 0.720147C12.6553 0.896474 12.0093 4.38767 12.5136 4.8226C13.364 5.55611 16.4587 3.28271 16.187 1.96616C16.0807 1.16683 14.9468 0.514607 13.9782 0.720147Z",fill:"black"}),f("path",{d:"M92.7383 17.6275C90.9681 17.6275 89.3816 17.0263 88.3796 16.0744C87.9955 15.7237 87.8953 15.3396 88.246 14.9555L88.8305 14.2541C89.1645 13.87 89.5486 13.7865 89.9327 14.1205C90.6007 14.6883 91.7029 15.1726 92.5713 15.1726C93.5232 15.1726 94.1244 14.8219 94.1244 14.2875C94.1244 13.5193 93.2059 13.4358 91.9868 13.0684C90.417 12.6008 88.5132 11.7324 88.5132 9.64493C88.5132 7.70773 90.25 6.37173 92.7383 6.37173C94.2413 6.37173 95.5272 6.87273 96.4123 7.57413C96.8131 7.90813 96.9467 8.27553 96.596 8.67633L96.0282 9.37773C95.7109 9.76183 95.3435 9.82863 94.926 9.51133C94.3916 9.09383 93.6568 8.69303 92.7884 8.69303C92.0202 8.69303 91.5192 9.01033 91.5192 9.51133C91.5192 10.1292 92.3041 10.4131 93.1224 10.6636C94.9761 11.2314 97.1304 11.8326 97.1304 14.2708C97.1304 16.4585 95.1264 17.6275 92.7383 17.6275Z",fill:"black"}),f("path",{d:"M87.0008 16.6756C87.0843 17.1766 86.8171 17.4271 86.2994 17.4271H85.097C84.596 17.4271 84.3789 17.1766 84.3121 16.6756L83.7443 11.9161L81.757 16.7424C81.5399 17.2434 81.1892 17.5106 80.6882 17.5106H80.5212C80.0202 17.5106 79.6695 17.2434 79.4524 16.7424L77.4651 11.8994L76.8973 16.6756C76.8472 17.1766 76.6301 17.4271 76.1291 17.4271H74.7263C74.2086 17.4271 73.9414 17.1766 74.0082 16.6756L75.4945 7.24013C75.5613 6.75583 75.8786 6.48863 76.3796 6.48863H76.5466C77.0476 6.48863 77.3315 6.75583 77.5486 7.24013L80.6047 13.8032L83.4938 7.24013C83.7109 6.75583 84.0115 6.48863 84.4958 6.48863H84.6795C85.1638 6.48863 85.4811 6.75583 85.5646 7.24013L87.0008 16.6756Z",fill:"black"}),f("path",{d:"M68.6496 17.6275C65.3096 17.6275 62.7211 15.2227 62.7211 11.9996C62.7211 8.77653 65.3096 6.37173 68.683 6.37173C70.3029 6.37173 71.7558 6.97293 72.7745 7.99163C73.1419 8.34233 73.1419 8.77653 72.7745 9.09383L71.9228 9.81193C71.5554 10.1292 71.2047 10.1125 70.8206 9.79523C70.2361 9.31093 69.5013 9.01033 68.683 9.01033C67.013 9.01033 65.7104 10.2628 65.7104 11.9996C65.7104 13.7364 67.013 14.9889 68.683 14.9889C69.5013 14.9889 70.2528 14.6883 70.8206 14.204C71.2047 13.8867 71.5554 13.87 71.9228 14.1873L72.7745 14.9054C73.1419 15.2227 73.1419 15.6569 72.7745 16.0076C71.7558 17.0263 70.3029 17.6275 68.6496 17.6275Z",fill:"black"}),f("path",{d:"M58.575 16.2915C58.7587 16.6923 58.4581 16.8927 58.241 17.0597C57.7233 17.4271 56.9384 17.6442 56.1201 17.6442C54.4501 17.6442 52.8469 16.6923 52.8469 14.4044V11.0978H52.1121C51.6111 11.0978 51.3439 10.8139 51.3439 10.3296V9.76183C51.3439 9.26083 51.6111 8.99363 52.1121 8.99363H52.8469V7.05643C52.8469 6.57213 53.1308 6.38843 53.6151 6.28823L54.9511 6.05443C55.4521 5.95423 55.7193 6.30493 55.7193 6.80593V8.99363H57.3726C57.8569 8.99363 58.1408 9.26083 58.1408 9.76183V10.3296C58.1408 10.8139 57.8569 11.0978 57.3726 11.0978H55.7193V14.1038C55.7193 14.9221 56.1368 15.1893 56.6545 15.1893C56.905 15.1893 57.1555 15.0724 57.3392 14.9555C57.7567 14.6883 57.9571 14.8887 58.1074 15.206L58.575 16.2915Z",fill:"black"}),f("path",{d:"M46.2592 17.6442C43.5538 17.6442 41.5999 15.7738 41.5999 13.2521C41.5999 10.7304 43.5538 8.86003 46.2592 8.86003C48.9646 8.86003 50.9185 10.7304 50.9185 13.2521C50.9185 15.7738 48.9646 17.6442 46.2592 17.6442ZM46.2592 15.1726C47.3113 15.1726 48.0628 14.3543 48.0628 13.2521C48.0628 12.1499 47.3113 11.3316 46.2592 11.3316C45.2071 11.3316 44.4389 12.1499 44.4389 13.2521C44.4389 14.3543 45.2071 15.1726 46.2592 15.1726Z",fill:"black"}),f("path",{d:"M36.052 17.6442C33.3466 17.6442 31.3927 15.7738 31.3927 13.2521C31.3927 10.7304 33.3466 8.86003 36.052 8.86003C38.7574 8.86003 40.7113 10.7304 40.7113 13.2521C40.7113 15.7738 38.7574 17.6442 36.052 17.6442ZM36.052 15.1726C37.1041 15.1726 37.8556 14.3543 37.8556 13.2521C37.8556 12.1499 37.1041 11.3316 36.052 11.3316C34.9999 11.3316 34.2317 12.1499 34.2317 13.2521C34.2317 14.3543 34.9999 15.1726 36.052 15.1726Z",fill:"black"}),f("path",{d:"M28.7099 13.0851L30.6805 16.6422C30.9644 17.1599 30.6638 17.4271 30.1628 17.4271H28.4594C27.9417 17.4271 27.8081 17.1766 27.5242 16.6589L25.7707 13.4859H24.6351V16.6422C24.6351 17.1432 24.3512 17.4271 23.8502 17.4271H22.4808C21.9798 17.4271 21.6959 17.1432 21.6959 16.6422V7.35703C21.6959 6.85603 21.9798 6.57213 22.4808 6.57213H26.5222C29.3111 6.57213 30.8141 7.92483 30.8141 10.1125C30.8141 11.5654 29.9791 12.5841 28.7099 13.0851ZM24.6351 8.96023V11.5153H26.4721C27.2236 11.5153 27.8248 11.0644 27.8248 10.2628C27.8248 9.44453 27.2236 8.96023 26.4721 8.96023H24.6351Z",fill:"black"})]}),f("defs",{children:f("clipPath",{id:"clip0_1_318",children:f("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}var Ai="1.5";function ge(t){return f("div",{className:"Layout",children:[f(ge.Top,{}),f(ge.Side,{}),f(ge.Main,{...t,children:t.children}),f(ge.Bottom,{})]})}ge.Top=()=>{let t=window.__ROOT_CTX.rootConfig.projectName||window.__ROOT_CTX.rootConfig.projectId;return f("div",{className:"Layout__top",children:[f("a",{className:"Layout__top__logo",href:"/cms",children:f(PG,{})}),f("div",{className:"Layout__top__version",children:["v",TG.version]}),f("div",{className:"Layout__top__project",children:t})]})};ge.Side=()=>{let[t]=g7(),e=t.url.replace(/\/*$/g,""),r=window.firebase.user,o=window.__ROOT_CTX.sidebar?.tools,n=window.__ROOT_CTX.experiments||{};return f("div",{className:"Layout__side",children:[f("div",{className:"Layout__side__buttons",children:[f(ge.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:f(uT,{stroke:Ai})}),f(ge.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:f(nc,{stroke:Ai})}),f(ge.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:f(gu,{stroke:Ai})}),f(ge.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:f(aT,{stroke:Ai})}),f(ge.SideButton,{label:"Assets",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:f(gT,{stroke:Ai})}),f(ge.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:f(Es,{stroke:Ai})}),n.ai&&f(ge.SideButton,{label:"Root AI (experimental)",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:f(ic,{stroke:Ai})}),o&&f(Oe,{children:[f("div",{className:"Layout__side__divider"}),Object.entries(o).map(([a,i])=>f(ge.SideButton,{className:"Layout__side__tool",label:i.label||"",url:`/cms/tools/${a}`,active:e.startsWith(`/cms/tools/${a}`),children:i.icon?f("img",{className:"Layout__side__tool__icon",src:i.icon,alt:i.label||""}):f(Jk,{stroke:Ai})})),f("div",{className:"Layout__side__divider"})]}),f(ge.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:f(sc,{stroke:Ai})})]}),f("div",{className:"Layout__side__user",children:f(Ie,{label:r.email,position:"right",withArrow:!0,children:f(qn,{src:r.photoURL,alt:r.email,size:30,radius:"xl"})})})]})};ge.SideButton=t=>f(Ie,{className:Te("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:f("a",{className:Te(t.active&&"active"),href:t.url,children:t.children})});ge.Main=t=>f("div",{className:"Layout__main",children:t.children});ge.Bottom=()=>f("div",{className:"Layout__bottom"});var OG=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],DG=[...OG,"svg"],AG=["mp4","webm"],kTe="https://lh3.googleusercontent.com/";async function Ns(t,e){let r=window.__ROOT_CTX.rootConfig.projectId,o=await ATe(t),n=Ru(t.name),a=e?.preserveFilename?`${o}/${t.name}`:`${o}.${n}`,i=`${r}/uploads/${a}`,s=f7(window.firebase.storage,i);await d7(s,t),console.log(`uploaded ${i}`);let l={};l.filename=t.name,l.uploadedBy=window.firebase.user.email||"unknown",l.uploadedAt=String(Math.floor(new Date().getTime()));let c=`/${s.bucket}/${s.fullPath}`,d=`https://storage.googleapis.com${c}`;if(DG.includes(n)){let p=await OTe(t);if(l.width=p.width,l.height=p.height,!e?.disableGci&&OG.includes(n)){let m=await PTe(c);m&&(l.gcsPath=c,d=m)}}else if(AG.includes(n)){let p=await DTe(d);l.width=p.width,l.height=p.height,console.log("video dimensions:",p)}let u=e?.cacheControl||"public, max-age=31536000";return await u7(s,{cacheControl:u,customMetadata:NTe(l)}),console.log("updated meta data: ",l),{...l,src:d}}function Ru(t){return TTe(t.split(".").at(-1)||"")}function TTe(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function PTe(t){let e=window.__ROOT_CTX.rootConfig.gci;if(!e)return"";let r=new URLSearchParams({gcs:t}),o=`${e}/_/serving_url?${r.toString()}`,n=await window.fetch(o);if(n.status!==200){let i=await n.text();throw console.error(`failed to get gci url: ${o}`),console.error(i),new Error("failed to get gci url")}return(await n.json()).servingUrl}async function OTe(t){return new Promise((e,r)=>{let o=new FileReader;o.onload=()=>{let n=new Image;n.onload=()=>{e({width:n.width,height:n.height})},n.onerror=r,n.src=String(o.result)},o.onerror=r,o.readAsDataURL(t)})}async function DTe(t){return new Promise((e,r)=>{let o=document.createElement("video");o.addEventListener("loadedmetadata",()=>{let n={width:o.videoWidth,height:o.videoHeight};e(n),document.body.removeChild(o)},!1),o.addEventListener("error",()=>{r(new Error("Failed to load video metadata")),document.body.removeChild(o)},!1),o.className="sr-only",o.src=t,o.preload="metadata",document.body.appendChild(o)})}async function ATe(t){let e=await t.arrayBuffer(),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("")}function NTe(t){let e={};return Object.entries(t).forEach(([r,o])=>{t[r]=String(o).trim()}),e}function KP(t){if(!t)return!1;if(nI(t)||t.startsWith("data:image/"))return!0;let e=Ru(t);return DG.includes(e)}function nI(t){return t?t.startsWith(kTe):!1}function YP(t){if(!t)return!1;let e=Ru(t);return AG.includes(e)}function NG(t){return nI(t)?t.split("=")[0]+"=s0-d":t}function Pa(t){t||(t=6);let e=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=r.length;for(let n=0;n<t;n++)e.push(r.charAt(Math.floor(Math.random()*o)));return e.join("")}function RG(t,e){return Math.random()*(e-t)+t}var RTe=!1,MTe=`Lorem ipsum \u{1F955} dolor sit amet.
|
|
54
54
|
|
|
55
55
|
\`\`\`jsx
|
|
56
56
|
import React, { useState, useEffect } from 'react';
|
|
@@ -224,7 +224,7 @@ ${$e.current.stack}
|
|
|
224
224
|
`)});function C(T,k,S,R){var A=S?"":R.css;if(T.styleSheet)T.styleSheet.cssText=y(k,A);else{var N=document.createTextNode(A),z=T.childNodes;z[k]&&T.removeChild(z[k]),z.length?T.insertBefore(N,z[k]):T.appendChild(N)}}},function(r,o){r.exports=function(n){var a=typeof window<"u"&&window.location;if(!a)throw new Error("fixUrls requires window.location");if(!n||typeof n!="string")return n;var i=a.protocol+"//"+a.host,s=i+a.pathname.replace(/\/[^\/]*$/,"/");return n.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(l,c){var d,u=c.trim().replace(/^"(.*)"$/,function(p,m){return m}).replace(/^'(.*)'$/,function(p,m){return m});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(u)?l:(d=u.indexOf("//")===0?u:u.indexOf("/")===0?i+u:s+u.replace(/^\.\//,""),"url("+JSON.stringify(d)+")")})}},function(r,o,n){var a,i,s,l,c,d,u,p,m;r.exports=(a="cdx-notifies",i="cdx-notify",s="cdx-notify__cross",l="cdx-notify__button--confirm",c="cdx-notify__button--cancel",d="cdx-notify__input",u="cdx-notify__button",p="cdx-notify__btns-wrapper",{alert:m=function(h){var g=document.createElement("DIV"),_=document.createElement("DIV"),x=h.message,b=h.style;return g.classList.add(i),b&&g.classList.add(i+"--"+b),g.innerHTML=x,_.classList.add(s),_.addEventListener("click",g.remove.bind(g)),g.appendChild(_),g},confirm:function(h){var g=m(h),_=document.createElement("div"),x=document.createElement("button"),b=document.createElement("button"),v=g.querySelector("."+s),I=h.cancelHandler,E=h.okHandler;return _.classList.add(p),x.innerHTML=h.okText||"Confirm",b.innerHTML=h.cancelText||"Cancel",x.classList.add(u),b.classList.add(u),x.classList.add(l),b.classList.add(c),I&&typeof I=="function"&&(b.addEventListener("click",I),v.addEventListener("click",I)),E&&typeof E=="function"&&x.addEventListener("click",E),x.addEventListener("click",g.remove.bind(g)),b.addEventListener("click",g.remove.bind(g)),_.appendChild(x),_.appendChild(b),g.appendChild(_),g},prompt:function(h){var g=m(h),_=document.createElement("div"),x=document.createElement("button"),b=document.createElement("input"),v=g.querySelector("."+s),I=h.cancelHandler,E=h.okHandler;return _.classList.add(p),x.innerHTML=h.okText||"Ok",x.classList.add(u),x.classList.add(l),b.classList.add(d),h.placeholder&&b.setAttribute("placeholder",h.placeholder),h.default&&(b.value=h.default),h.inputType&&(b.type=h.inputType),I&&typeof I=="function"&&v.addEventListener("click",I),E&&typeof E=="function"&&x.addEventListener("click",function(){E(b.value)}),x.addEventListener("click",g.remove.bind(g)),_.appendChild(b),_.appendChild(x),g.appendChild(_),g},getWrapper:function(){var h=document.createElement("DIV");return h.classList.add(a),h}})}])})})(AY);var pMe=AY.exports,mMe=QI(pMe),bD=class{show(e){mMe.show(e)}},vD=class extends ft{constructor({config:e,eventsDispatcher:r}){super({config:e,eventsDispatcher:r}),this.notifier=new bD}get methods(){return{show:e=>this.show(e)}}show(e){return this.notifier.show(e)}},yD=class extends ft{get methods(){let e=()=>this.isEnabled;return{toggle:r=>this.toggle(r),get isEnabled(){return e()}}}toggle(e){return this.Editor.ReadOnly.toggle(e)}get isEnabled(){return this.Editor.ReadOnly.isEnabled}},NY={exports:{}};(function(t,e){(function(r,o){t.exports=o()})(Nh,function(){function r(u){var p=u.tags,m=Object.keys(p),h=m.map(function(g){return typeof p[g]}).every(function(g){return g==="object"||g==="boolean"||g==="function"});if(!h)throw new Error("The configuration was invalid");this.config=u}var o=["P","LI","TD","TH","DIV","H1","H2","H3","H4","H5","H6","PRE"];function n(u){return o.indexOf(u.nodeName)!==-1}var a=["A","B","STRONG","I","EM","SUB","SUP","U","STRIKE"];function i(u){return a.indexOf(u.nodeName)!==-1}r.prototype.clean=function(u){let p=document.implementation.createHTMLDocument(),m=p.createElement("div");return m.innerHTML=u,this._sanitize(p,m),m.innerHTML},r.prototype._sanitize=function(u,p){var m=s(u,p),h=m.firstChild();if(h)do{if(h.nodeType===Node.TEXT_NODE)if(h.data.trim()===""&&(h.previousElementSibling&&n(h.previousElementSibling)||h.nextElementSibling&&n(h.nextElementSibling))){p.removeChild(h),this._sanitize(u,p);break}else continue;if(h.nodeType===Node.COMMENT_NODE){p.removeChild(h),this._sanitize(u,p);break}var g=i(h),_;g&&(_=Array.prototype.some.call(h.childNodes,n));var x=!!p.parentNode,b=n(p)&&n(h)&&x,v=h.nodeName.toLowerCase(),I=l(this.config,v,h),E=g&&_;if(E||c(h,I)||!this.config.keepNestedBlockElements&&b){if(!(h.nodeName==="SCRIPT"||h.nodeName==="STYLE"))for(;h.childNodes.length>0;)p.insertBefore(h.childNodes[0],h);p.removeChild(h),this._sanitize(u,p);break}for(var y=0;y<h.attributes.length;y+=1){var C=h.attributes[y];d(C,I,h)&&(h.removeAttribute(C.name),y=y-1)}this._sanitize(u,h)}while(h=m.nextSibling())};function s(u,p){return u.createTreeWalker(p,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT,null,!1)}function l(u,p,m){return typeof u.tags[p]=="function"?u.tags[p](m):u.tags[p]}function c(u,p){return typeof p>"u"?!0:typeof p=="boolean"?!p:!1}function d(u,p,m){var h=u.name.toLowerCase();return p===!0?!1:typeof p[h]=="function"?!p[h](u.value,m):typeof p[h]>"u"||p[h]===!1?!0:typeof p[h]=="string"?p[h]!==u.value:!1}return r})})(NY);var hMe=NY.exports,gMe=QI(hMe);function iA(t,e){return t.map(r=>{let o=rr(e)?e(r.tool):e;return ua(o)||(r.data=sA(r.data,o)),r})}function ri(t,e={}){let r={tags:e};return new gMe(r).clean(t)}function sA(t,e){return Array.isArray(t)?_Me(t,e):bo(t)?xMe(t,e):zi(t)?bMe(t,e):t}function _Me(t,e){return t.map(r=>sA(r,e))}function xMe(t,e){let r={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;let n=t[o],a=vMe(e[o])?e[o]:e;r[o]=sA(n,a)}return r}function bMe(t,e){return bo(e)?ri(t,e):e===!1?ri(t,{}):t}function vMe(t){return bo(t)||KRe(t)||rr(t)}var ID=class extends ft{get methods(){return{clean:(e,r)=>this.clean(e,r)}}clean(e,r){return ri(e,r)}},wD=class extends ft{get methods(){return{save:()=>this.save()}}save(){let e="Editor's content can not be saved in read-only mode";return this.Editor.ReadOnly.isEnabled?(da(e,"warn"),Promise.reject(new Error(e))):this.Editor.Saver.save()}},ED=class extends ft{constructor(){super(...arguments),this.selectionUtils=new ze}get methods(){return{findParentTag:(e,r)=>this.findParentTag(e,r),expandToTag:e=>this.expandToTag(e),save:()=>this.selectionUtils.save(),restore:()=>this.selectionUtils.restore(),setFakeBackground:()=>this.selectionUtils.setFakeBackground(),removeFakeBackground:()=>this.selectionUtils.removeFakeBackground()}}findParentTag(e,r){return this.selectionUtils.findParentTag(e,r)}expandToTag(e){this.selectionUtils.expandToTag(e)}},SD=class extends ft{get methods(){return{getBlockTools:()=>Array.from(this.Editor.Tools.blockTools.values())}}},CD=class extends ft{get classes(){return{block:"cdx-block",inlineToolButton:"ce-inline-tool",inlineToolButtonActive:"ce-inline-tool--active",input:"cdx-input",loader:"cdx-loader",button:"cdx-button",settingsButton:"cdx-settings-button",settingsButtonActive:"cdx-settings-button--active"}}},kD=class extends ft{get methods(){return{close:()=>this.close(),open:()=>this.open(),toggleBlockSettings:e=>this.toggleBlockSettings(e),toggleToolbox:e=>this.toggleToolbox(e)}}open(){this.Editor.Toolbar.moveAndOpen()}close(){this.Editor.Toolbar.close()}toggleBlockSettings(e){if(this.Editor.BlockManager.currentBlockIndex===-1){da("Could't toggle the Toolbar because there is no block selected ","warn");return}e??!this.Editor.BlockSettings.opened?(this.Editor.Toolbar.moveAndOpen(),this.Editor.BlockSettings.open()):this.Editor.BlockSettings.close()}toggleToolbox(e){if(this.Editor.BlockManager.currentBlockIndex===-1){da("Could't toggle the Toolbox because there is no block selected ","warn");return}e??!this.Editor.Toolbar.toolbox.opened?(this.Editor.Toolbar.moveAndOpen(),this.Editor.Toolbar.toolbox.open()):this.Editor.Toolbar.toolbox.close()}},RY={exports:{}};(function(t,e){(function(r,o){t.exports=o()})(window,function(){return function(r){var o={};function n(a){if(o[a])return o[a].exports;var i=o[a]={i:a,l:!1,exports:{}};return r[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=r,n.c=o,n.d=function(a,i,s){n.o(a,i)||Object.defineProperty(a,i,{enumerable:!0,get:s})},n.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},n.t=function(a,i){if(1&i&&(a=n(a)),8&i||4&i&&typeof a=="object"&&a&&a.__esModule)return a;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:a}),2&i&&typeof a!="string")for(var l in a)n.d(s,l,function(c){return a[c]}.bind(null,l));return s},n.n=function(a){var i=a&&a.__esModule?function(){return a.default}:function(){return a};return n.d(i,"a",i),i},n.o=function(a,i){return Object.prototype.hasOwnProperty.call(a,i)},n.p="",n(n.s=0)}([function(r,o,n){r.exports=n(1)},function(r,o,n){n.r(o),n.d(o,"default",function(){return a});class a{constructor(){this.nodes={wrapper:null,content:null},this.showed=!1,this.offsetTop=10,this.offsetLeft=10,this.offsetRight=10,this.hidingDelay=0,this.handleWindowScroll=()=>{this.showed&&this.hide(!0)},this.loadStyles(),this.prepare(),window.addEventListener("scroll",this.handleWindowScroll,{passive:!0})}get CSS(){return{tooltip:"ct",tooltipContent:"ct__content",tooltipShown:"ct--shown",placement:{left:"ct--left",bottom:"ct--bottom",right:"ct--right",top:"ct--top"}}}show(s,l,c){this.nodes.wrapper||this.prepare(),this.hidingTimeout&&clearTimeout(this.hidingTimeout);let d=Object.assign({placement:"bottom",marginTop:0,marginLeft:0,marginRight:0,marginBottom:0,delay:70,hidingDelay:0},c);if(d.hidingDelay&&(this.hidingDelay=d.hidingDelay),this.nodes.content.innerHTML="",typeof l=="string")this.nodes.content.appendChild(document.createTextNode(l));else{if(!(l instanceof Node))throw Error("[CodeX Tooltip] Wrong type of \xABcontent\xBB passed. It should be an instance of Node or String. But "+typeof l+" given.");this.nodes.content.appendChild(l)}switch(this.nodes.wrapper.classList.remove(...Object.values(this.CSS.placement)),d.placement){case"top":this.placeTop(s,d);break;case"left":this.placeLeft(s,d);break;case"right":this.placeRight(s,d);break;case"bottom":default:this.placeBottom(s,d)}d&&d.delay?this.showingTimeout=setTimeout(()=>{this.nodes.wrapper.classList.add(this.CSS.tooltipShown),this.showed=!0},d.delay):(this.nodes.wrapper.classList.add(this.CSS.tooltipShown),this.showed=!0)}hide(s=!1){if(this.hidingDelay&&!s)return this.hidingTimeout&&clearTimeout(this.hidingTimeout),void(this.hidingTimeout=setTimeout(()=>{this.hide(!0)},this.hidingDelay));this.nodes.wrapper.classList.remove(this.CSS.tooltipShown),this.showed=!1,this.showingTimeout&&clearTimeout(this.showingTimeout)}onHover(s,l,c){s.addEventListener("mouseenter",()=>{this.show(s,l,c)}),s.addEventListener("mouseleave",()=>{this.hide()})}destroy(){this.nodes.wrapper.remove(),window.removeEventListener("scroll",this.handleWindowScroll)}prepare(){this.nodes.wrapper=this.make("div",this.CSS.tooltip),this.nodes.content=this.make("div",this.CSS.tooltipContent),this.append(this.nodes.wrapper,this.nodes.content),this.append(document.body,this.nodes.wrapper)}loadStyles(){let s="codex-tooltips-style";if(document.getElementById(s))return;let l=n(2),c=this.make("style",null,{textContent:l.toString(),id:s});this.prepend(document.head,c)}placeBottom(s,l){let c=s.getBoundingClientRect(),d=c.left+s.clientWidth/2-this.nodes.wrapper.offsetWidth/2,u=c.bottom+window.pageYOffset+this.offsetTop+l.marginTop;this.applyPlacement("bottom",d,u)}placeTop(s,l){let c=s.getBoundingClientRect(),d=c.left+s.clientWidth/2-this.nodes.wrapper.offsetWidth/2,u=c.top+window.pageYOffset-this.nodes.wrapper.clientHeight-this.offsetTop;this.applyPlacement("top",d,u)}placeLeft(s,l){let c=s.getBoundingClientRect(),d=c.left-this.nodes.wrapper.offsetWidth-this.offsetLeft-l.marginLeft,u=c.top+window.pageYOffset+s.clientHeight/2-this.nodes.wrapper.offsetHeight/2;this.applyPlacement("left",d,u)}placeRight(s,l){let c=s.getBoundingClientRect(),d=c.right+this.offsetRight+l.marginRight,u=c.top+window.pageYOffset+s.clientHeight/2-this.nodes.wrapper.offsetHeight/2;this.applyPlacement("right",d,u)}applyPlacement(s,l,c){this.nodes.wrapper.classList.add(this.CSS.placement[s]),this.nodes.wrapper.style.left=l+"px",this.nodes.wrapper.style.top=c+"px"}make(s,l=null,c={}){let d=document.createElement(s);Array.isArray(l)?d.classList.add(...l):l&&d.classList.add(l);for(let u in c)c.hasOwnProperty(u)&&(d[u]=c[u]);return d}append(s,l){Array.isArray(l)?l.forEach(c=>s.appendChild(c)):s.appendChild(l)}prepend(s,l){Array.isArray(l)?(l=l.reverse()).forEach(c=>s.prepend(c)):s.prepend(l)}}},function(r,o){r.exports=`.ct{z-index:999;opacity:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;-webkit-transition:opacity 50ms ease-in,-webkit-transform 70ms cubic-bezier(.215,.61,.355,1);transition:opacity 50ms ease-in,-webkit-transform 70ms cubic-bezier(.215,.61,.355,1);transition:opacity 50ms ease-in,transform 70ms cubic-bezier(.215,.61,.355,1);transition:opacity 50ms ease-in,transform 70ms cubic-bezier(.215,.61,.355,1),-webkit-transform 70ms cubic-bezier(.215,.61,.355,1);will-change:opacity,top,left;-webkit-box-shadow:0 8px 12px 0 rgba(29,32,43,.17),0 4px 5px -3px rgba(5,6,12,.49);box-shadow:0 8px 12px 0 rgba(29,32,43,.17),0 4px 5px -3px rgba(5,6,12,.49);border-radius:9px}.ct,.ct:before{position:absolute;top:0;left:0}.ct:before{content:"";bottom:0;right:0;background-color:#1d202b;z-index:-1;border-radius:4px}@supports(-webkit-mask-box-image:url("")){.ct:before{border-radius:0;-webkit-mask-box-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M10.71 0h2.58c3.02 0 4.64.42 6.1 1.2a8.18 8.18 0 013.4 3.4C23.6 6.07 24 7.7 24 10.71v2.58c0 3.02-.42 4.64-1.2 6.1a8.18 8.18 0 01-3.4 3.4c-1.47.8-3.1 1.21-6.11 1.21H10.7c-3.02 0-4.64-.42-6.1-1.2a8.18 8.18 0 01-3.4-3.4C.4 17.93 0 16.3 0 13.29V10.7c0-3.02.42-4.64 1.2-6.1a8.18 8.18 0 013.4-3.4C6.07.4 7.7 0 10.71 0z"/></svg>') 48% 41% 37.9% 53.3%}}@media (--mobile){.ct{display:none}}.ct__content{padding:6px 10px;color:#cdd1e0;font-size:12px;text-align:center;letter-spacing:.02em;line-height:1em}.ct:after{content:"";width:8px;height:8px;position:absolute;background-color:#1d202b;z-index:-1}.ct--bottom{-webkit-transform:translateY(5px);transform:translateY(5px)}.ct--bottom:after{top:-3px;left:50%;-webkit-transform:translateX(-50%) rotate(-45deg);transform:translateX(-50%) rotate(-45deg)}.ct--top{-webkit-transform:translateY(-5px);transform:translateY(-5px)}.ct--top:after{top:auto;bottom:-3px;left:50%;-webkit-transform:translateX(-50%) rotate(-45deg);transform:translateX(-50%) rotate(-45deg)}.ct--left{-webkit-transform:translateX(-5px);transform:translateX(-5px)}.ct--left:after{top:50%;left:auto;right:0;-webkit-transform:translate(41.6%,-50%) rotate(-45deg);transform:translate(41.6%,-50%) rotate(-45deg)}.ct--right{-webkit-transform:translateX(5px);transform:translateX(5px)}.ct--right:after{top:50%;left:0;-webkit-transform:translate(-41.6%,-50%) rotate(-45deg);transform:translate(-41.6%,-50%) rotate(-45deg)}.ct--shown{opacity:1;-webkit-transform:none;transform:none}`}]).default})})(RY);var yMe=RY.exports,IMe=QI(yMe),Da=null;function lA(){Da||(Da=new IMe)}function wMe(t,e,r){lA(),Da?.show(t,e,r)}function BI(t=!1){lA(),Da?.hide(t)}function FI(t,e,r){lA(),Da?.onHover(t,e,r)}function EMe(){Da?.destroy(),Da=null}var TD=class extends ft{constructor({config:e,eventsDispatcher:r}){super({config:e,eventsDispatcher:r})}get methods(){return{show:(e,r,o)=>this.show(e,r,o),hide:()=>this.hide(),onHover:(e,r,o)=>this.onHover(e,r,o)}}show(e,r,o){wMe(e,r,o)}hide(){BI()}onHover(e,r,o){FI(e,r,o)}},PD=class extends ft{get methods(){return{nodes:this.editorNodes}}get editorNodes(){return{wrapper:this.Editor.UI.nodes.wrapper,redactor:this.Editor.UI.nodes.redactor}}};function MY(t,e){let r={};return Object.entries(t).forEach(([o,n])=>{if(bo(n)){let a=e?`${e}.${o}`:o;Object.values(n).every(i=>zi(i))?r[o]=a:r[o]=MY(n,a);return}r[o]=n}),r}var Dn=MY(SY);function SMe(t,e){let r={};return Object.keys(t).forEach(o=>{let n=e[o];n!==void 0?r[n]=t[o]:r[o]=t[o]}),r}var LY=class Oh{constructor(e,r){this.cursor=-1,this.items=[],this.items=e||[],this.focusedCssClass=r}get currentItem(){return this.cursor===-1?null:this.items[this.cursor]}setCursor(e){e<this.items.length&&e>=-1&&(this.dropCursor(),this.cursor=e,this.items[this.cursor].classList.add(this.focusedCssClass))}setItems(e){this.items=e}next(){this.cursor=this.leafNodesAndReturnIndex(Oh.directions.RIGHT)}previous(){this.cursor=this.leafNodesAndReturnIndex(Oh.directions.LEFT)}dropCursor(){this.cursor!==-1&&(this.items[this.cursor].classList.remove(this.focusedCssClass),this.cursor=-1)}leafNodesAndReturnIndex(e){if(this.items.length===0)return this.cursor;let r=this.cursor;return r===-1?r=e===Oh.directions.RIGHT?-1:0:this.items[r].classList.remove(this.focusedCssClass),e===Oh.directions.RIGHT?r=(r+1)%this.items.length:r=(this.items.length+r-1)%this.items.length,K.canSetCaret(this.items[r])&&NI(()=>ze.setCursor(this.items[r]),50)(),this.items[r].classList.add(this.focusedCssClass),r}};LY.directions={RIGHT:"right",LEFT:"left"};var kh=LY,Zu=class t{constructor(e){this.iterator=null,this.activated=!1,this.flipCallbacks=[],this.onKeyDown=r=>{if(this.isEventReadyForHandling(r))switch(t.usedKeys.includes(r.keyCode)&&r.preventDefault(),r.keyCode){case Ye.TAB:this.handleTabPress(r);break;case Ye.LEFT:case Ye.UP:this.flipLeft();break;case Ye.RIGHT:case Ye.DOWN:this.flipRight();break;case Ye.ENTER:this.handleEnterPress(r);break}},this.iterator=new kh(e.items,e.focusedItemClass),this.activateCallback=e.activateCallback,this.allowedKeys=e.allowedKeys||t.usedKeys}get isActivated(){return this.activated}static get usedKeys(){return[Ye.TAB,Ye.LEFT,Ye.RIGHT,Ye.ENTER,Ye.UP,Ye.DOWN]}activate(e,r){this.activated=!0,e&&this.iterator.setItems(e),r!==void 0&&this.iterator.setCursor(r),document.addEventListener("keydown",this.onKeyDown,!0)}deactivate(){this.activated=!1,this.dropCursor(),document.removeEventListener("keydown",this.onKeyDown)}focusFirst(){this.dropCursor(),this.flipRight()}flipLeft(){this.iterator.previous(),this.flipCallback()}flipRight(){this.iterator.next(),this.flipCallback()}hasFocus(){return!!this.iterator.currentItem}onFlip(e){this.flipCallbacks.push(e)}removeOnFlip(e){this.flipCallbacks=this.flipCallbacks.filter(r=>r!==e)}dropCursor(){this.iterator.dropCursor()}isEventReadyForHandling(e){return this.activated&&this.allowedKeys.includes(e.keyCode)}handleTabPress(e){switch(e.shiftKey?kh.directions.LEFT:kh.directions.RIGHT){case kh.directions.RIGHT:this.flipRight();break;case kh.directions.LEFT:this.flipLeft();break}}handleEnterPress(e){this.activated&&(this.iterator.currentItem&&(e.stopPropagation(),e.preventDefault(),this.iterator.currentItem.click()),rr(this.activateCallback)&&this.activateCallback(this.iterator.currentItem))}flipCallback(){this.iterator.currentItem&&this.iterator.currentItem.scrollIntoViewIfNeeded(),this.flipCallbacks.forEach(e=>e())}},CMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9 12L9 7.1C9 7.04477 9.04477 7 9.1 7H10.4C11.5 7 14 7.1 14 9.5C14 9.5 14 12 11 12M9 12V16.8C9 16.9105 9.08954 17 9.2 17H12.5C14 17 15 16 15 14.5C15 11.7046 11 12 11 12M9 12H11"/></svg>',kMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7 10L11.8586 14.8586C11.9367 14.9367 12.0633 14.9367 12.1414 14.8586L17 10"/></svg>',TMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M14.5 17.5L9.64142 12.6414C9.56331 12.5633 9.56331 12.4367 9.64142 12.3586L14.5 7.5"/></svg>',PMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9.58284 17.5L14.4414 12.6414C14.5195 12.5633 14.5195 12.4367 14.4414 12.3586L9.58284 7.5"/></svg>',OMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7 15L11.8586 10.1414C11.9367 10.0633 12.0633 10.0633 12.1414 10.1414L17 15"/></svg>',DMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8 8L12 12M12 12L16 16M12 12L16 8M12 12L8 16"/></svg>',AMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="2"/></svg>',NMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M13.34 10C12.4223 12.7337 11 17 11 17"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M14.21 7H14.2"/></svg>',fY='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7.69998 12.6L7.67896 12.62C6.53993 13.7048 6.52012 15.5155 7.63516 16.625V16.625C8.72293 17.7073 10.4799 17.7102 11.5712 16.6314L13.0263 15.193C14.0703 14.1609 14.2141 12.525 13.3662 11.3266L13.22 11.12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16.22 11.12L16.3564 10.9805C17.2895 10.0265 17.3478 8.5207 16.4914 7.49733V7.49733C15.5691 6.39509 13.9269 6.25143 12.8271 7.17675L11.3901 8.38588C10.0935 9.47674 9.95706 11.4241 11.0888 12.6852L11.12 12.72"/></svg>',RMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M9.40999 7.29999H9.4"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M14.6 7.29999H14.59"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M9.30999 12H9.3"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M14.6 12H14.59"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M9.40999 16.7H9.4"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2.6" d="M14.6 16.7H14.59"/></svg>',MMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M12 7V12M12 17V12M17 12H12M12 12H7"/></svg>',BY='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M11.5 17.5L5 11M5 11V15.5M5 11H9.5"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M12.5 6.5L19 13M19 13V8.5M19 13H14.5"/></svg>',LMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><circle cx="10.5" cy="10.5" r="5.5" stroke="currentColor" stroke-width="2"/><line x1="15.4142" x2="19" y1="15" y2="18.5858" stroke="currentColor" stroke-linecap="round" stroke-width="2"/></svg>',BMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M15.7795 11.5C15.7795 11.5 16.053 11.1962 16.5497 10.6722C17.4442 9.72856 17.4701 8.2475 16.5781 7.30145V7.30145C15.6482 6.31522 14.0873 6.29227 13.1288 7.25073L11.8796 8.49999"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8.24517 12.3883C8.24517 12.3883 7.97171 12.6922 7.47504 13.2161C6.58051 14.1598 6.55467 15.6408 7.44666 16.5869V16.5869C8.37653 17.5731 9.93744 17.5961 10.8959 16.6376L12.1452 15.3883"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M17.7802 15.1032L16.597 14.9422C16.0109 14.8624 15.4841 15.3059 15.4627 15.8969L15.4199 17.0818"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6.39064 9.03238L7.58432 9.06668C8.17551 9.08366 8.6522 8.58665 8.61056 7.99669L8.5271 6.81397"/><line x1="12.1142" x2="11.7" y1="12.2" y2="11.7858" stroke="currentColor" stroke-linecap="round" stroke-width="2"/></svg>',FMe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" stroke="currentColor" stroke-width="2" rx="4"/><line x1="12" x2="12" y1="9" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M12 15.02V15.01"/></svg>',zMe="__",UMe="--";function Us(t){return(e,r)=>[[t,e].filter(o=>!!o).join(zMe),r].filter(o=>!!o).join(UMe)}var Th=Us("ce-hint"),Ph={root:Th(),alignedStart:Th(null,"align-left"),alignedCenter:Th(null,"align-center"),title:Th("title"),description:Th("description")},OD=class{constructor(e){this.nodes={root:K.make("div",[Ph.root,e.alignment==="center"?Ph.alignedCenter:Ph.alignedStart]),title:K.make("div",Ph.title,{textContent:e.title})},this.nodes.root.appendChild(this.nodes.title),e.description!==void 0&&(this.nodes.description=K.make("div",Ph.description,{textContent:e.description}),this.nodes.root.appendChild(this.nodes.description))}getElement(){return this.nodes.root}},Mh=class{constructor(e){this.params=e}get name(){if(this.params!==void 0&&"name"in this.params)return this.params.name}destroy(){BI()}onChildrenOpen(){var e;this.params!==void 0&&"children"in this.params&&typeof((e=this.params.children)==null?void 0:e.onOpen)=="function"&&this.params.children.onOpen()}onChildrenClose(){var e;this.params!==void 0&&"children"in this.params&&typeof((e=this.params.children)==null?void 0:e.onClose)=="function"&&this.params.children.onClose()}handleClick(){var e,r;this.params!==void 0&&"onActivate"in this.params&&((r=(e=this.params).onActivate)==null||r.call(e,this.params))}addHint(e,r){let o=new OD(r);FI(e,o.getElement(),{placement:r.position,hidingDelay:100})}get children(){var e;return this.params!==void 0&&"children"in this.params&&((e=this.params.children)==null?void 0:e.items)!==void 0?this.params.children.items:[]}get hasChildren(){return this.children.length>0}get isChildrenOpen(){var e;return this.params!==void 0&&"children"in this.params&&((e=this.params.children)==null?void 0:e.isOpen)===!0}get isChildrenFlippable(){var e;return!(this.params===void 0||!("children"in this.params)||((e=this.params.children)==null?void 0:e.isFlippable)===!1)}get isChildrenSearchable(){var e;return this.params!==void 0&&"children"in this.params&&((e=this.params.children)==null?void 0:e.searchable)===!0}get closeOnActivate(){return this.params!==void 0&&"closeOnActivate"in this.params&&this.params.closeOnActivate}get isActive(){return this.params===void 0||!("isActive"in this.params)?!1:typeof this.params.isActive=="function"?this.params.isActive():this.params.isActive===!0}},On=Us("ce-popover-item"),dr={container:On(),active:On(null,"active"),disabled:On(null,"disabled"),focused:On(null,"focused"),hidden:On(null,"hidden"),confirmationState:On(null,"confirmation"),noHover:On(null,"no-hover"),noFocus:On(null,"no-focus"),title:On("title"),secondaryTitle:On("secondary-title"),icon:On("icon"),iconTool:On("icon","tool"),iconChevronRight:On("icon","chevron-right"),wobbleAnimation:Us("wobble")()},Fi=class extends Mh{constructor(e,r){super(e),this.params=e,this.nodes={root:null,icon:null},this.confirmationState=null,this.removeSpecialFocusBehavior=()=>{var o;(o=this.nodes.root)==null||o.classList.remove(dr.noFocus)},this.removeSpecialHoverBehavior=()=>{var o;(o=this.nodes.root)==null||o.classList.remove(dr.noHover)},this.onErrorAnimationEnd=()=>{var o,n;(o=this.nodes.icon)==null||o.classList.remove(dr.wobbleAnimation),(n=this.nodes.icon)==null||n.removeEventListener("animationend",this.onErrorAnimationEnd)},this.nodes.root=this.make(e,r)}get isDisabled(){return this.params.isDisabled===!0}get toggle(){return this.params.toggle}get title(){return this.params.title}get isConfirmationStateEnabled(){return this.confirmationState!==null}get isFocused(){return this.nodes.root===null?!1:this.nodes.root.classList.contains(dr.focused)}getElement(){return this.nodes.root}handleClick(){if(this.isConfirmationStateEnabled&&this.confirmationState!==null){this.activateOrEnableConfirmationMode(this.confirmationState);return}this.activateOrEnableConfirmationMode(this.params)}toggleActive(e){var r;(r=this.nodes.root)==null||r.classList.toggle(dr.active,e)}toggleHidden(e){var r;(r=this.nodes.root)==null||r.classList.toggle(dr.hidden,e)}reset(){this.isConfirmationStateEnabled&&this.disableConfirmationMode()}onFocus(){this.disableSpecialHoverAndFocusBehavior()}make(e,r){var o,n;let a=r?.wrapperTag||"div",i=K.make(a,dr.container,{type:a==="button"?"button":void 0});return e.name&&(i.dataset.itemName=e.name),this.nodes.icon=K.make("div",[dr.icon,dr.iconTool],{innerHTML:e.icon||AMe}),i.appendChild(this.nodes.icon),e.title!==void 0&&i.appendChild(K.make("div",dr.title,{innerHTML:e.title||""})),e.secondaryLabel&&i.appendChild(K.make("div",dr.secondaryTitle,{textContent:e.secondaryLabel})),this.hasChildren&&i.appendChild(K.make("div",[dr.icon,dr.iconChevronRight],{innerHTML:PMe})),this.isActive&&i.classList.add(dr.active),e.isDisabled&&i.classList.add(dr.disabled),e.hint!==void 0&&((o=r?.hint)==null?void 0:o.enabled)!==!1&&this.addHint(i,{...e.hint,position:((n=r?.hint)==null?void 0:n.position)||"right"}),i}enableConfirmationMode(e){if(this.nodes.root===null)return;let r={...this.params,...e,confirmation:"confirmation"in e?e.confirmation:void 0},o=this.make(r);this.nodes.root.innerHTML=o.innerHTML,this.nodes.root.classList.add(dr.confirmationState),this.confirmationState=e,this.enableSpecialHoverAndFocusBehavior()}disableConfirmationMode(){if(this.nodes.root===null)return;let e=this.make(this.params);this.nodes.root.innerHTML=e.innerHTML,this.nodes.root.classList.remove(dr.confirmationState),this.confirmationState=null,this.disableSpecialHoverAndFocusBehavior()}enableSpecialHoverAndFocusBehavior(){var e,r,o;(e=this.nodes.root)==null||e.classList.add(dr.noHover),(r=this.nodes.root)==null||r.classList.add(dr.noFocus),(o=this.nodes.root)==null||o.addEventListener("mouseleave",this.removeSpecialHoverBehavior,{once:!0})}disableSpecialHoverAndFocusBehavior(){var e;this.removeSpecialFocusBehavior(),this.removeSpecialHoverBehavior(),(e=this.nodes.root)==null||e.removeEventListener("mouseleave",this.removeSpecialHoverBehavior)}activateOrEnableConfirmationMode(e){var r;if(!("confirmation"in e)||e.confirmation===void 0)try{(r=e.onActivate)==null||r.call(e,e),this.disableConfirmationMode()}catch{this.animateError()}else this.enableConfirmationMode(e.confirmation)}animateError(){var e,r,o;(e=this.nodes.icon)!=null&&e.classList.contains(dr.wobbleAnimation)||((r=this.nodes.icon)==null||r.classList.add(dr.wobbleAnimation),(o=this.nodes.icon)==null||o.addEventListener("animationend",this.onErrorAnimationEnd))}},eD=Us("ce-popover-item-separator"),tD={container:eD(),line:eD("line"),hidden:eD(null,"hidden")},zI=class extends Mh{constructor(){super(),this.nodes={root:K.make("div",tD.container),line:K.make("div",tD.line)},this.nodes.root.appendChild(this.nodes.line)}getElement(){return this.nodes.root}toggleHidden(e){var r;(r=this.nodes.root)==null||r.classList.toggle(tD.hidden,e)}},oi=(t=>(t.Closed="closed",t.ClosedOnActivate="closed-on-activate",t))(oi||{}),Qo=Us("ce-popover"),br={popover:Qo(),popoverContainer:Qo("container"),popoverOpenTop:Qo(null,"open-top"),popoverOpenLeft:Qo(null,"open-left"),popoverOpened:Qo(null,"opened"),search:Qo("search"),nothingFoundMessage:Qo("nothing-found-message"),nothingFoundMessageDisplayed:Qo("nothing-found-message","displayed"),items:Qo("items"),overlay:Qo("overlay"),overlayHidden:Qo("overlay","hidden"),popoverNested:Qo(null,"nested"),getPopoverNestedClass:t=>Qo(null,`nested-level-${t.toString()}`),popoverInline:Qo(null,"inline"),popoverHeader:Qo("header")},Qu=(t=>(t.NestingLevel="--nesting-level",t.PopoverHeight="--popover-height",t.InlinePopoverWidth="--inline-popover-width",t.TriggerItemLeft="--trigger-item-left",t.TriggerItemTop="--trigger-item-top",t))(Qu||{}),pY=Us("ce-popover-item-html"),mY={root:pY(),hidden:pY(null,"hidden")},Ac=class extends Mh{constructor(e,r){var o,n;super(e),this.nodes={root:K.make("div",mY.root)},this.nodes.root.appendChild(e.element),e.name&&(this.nodes.root.dataset.itemName=e.name),e.hint!==void 0&&((o=r?.hint)==null?void 0:o.enabled)!==!1&&this.addHint(this.nodes.root,{...e.hint,position:((n=r?.hint)==null?void 0:n.position)||"right"})}getElement(){return this.nodes.root}toggleHidden(e){var r;(r=this.nodes.root)==null||r.classList.toggle(mY.hidden,e)}getControls(){let e=this.nodes.root.querySelectorAll(`button, ${K.allInputsSelector}`);return Array.from(e)}},UI=class extends Oc{constructor(e,r={}){super(),this.params=e,this.itemsRenderParams=r,this.listeners=new Dc,this.messages={nothingFound:"Nothing found",search:"Search"},this.items=this.buildItems(e.items),e.messages&&(this.messages={...this.messages,...e.messages}),this.nodes={},this.nodes.popoverContainer=K.make("div",[br.popoverContainer]),this.nodes.nothingFoundMessage=K.make("div",[br.nothingFoundMessage],{textContent:this.messages.nothingFound}),this.nodes.popoverContainer.appendChild(this.nodes.nothingFoundMessage),this.nodes.items=K.make("div",[br.items]),this.items.forEach(o=>{let n=o.getElement();n!==null&&this.nodes.items.appendChild(n)}),this.nodes.popoverContainer.appendChild(this.nodes.items),this.listeners.on(this.nodes.popoverContainer,"click",o=>this.handleClick(o)),this.nodes.popover=K.make("div",[br.popover,this.params.class]),this.nodes.popover.appendChild(this.nodes.popoverContainer)}get itemsDefault(){return this.items.filter(e=>e instanceof Fi)}getElement(){return this.nodes.popover}show(){this.nodes.popover.classList.add(br.popoverOpened),this.search!==void 0&&this.search.focus()}hide(){this.nodes.popover.classList.remove(br.popoverOpened),this.nodes.popover.classList.remove(br.popoverOpenTop),this.itemsDefault.forEach(e=>e.reset()),this.search!==void 0&&this.search.clear(),this.emit(oi.Closed)}destroy(){var e;this.items.forEach(r=>r.destroy()),this.nodes.popover.remove(),this.listeners.removeAll(),(e=this.search)==null||e.destroy()}activateItemByName(e){let r=this.items.find(o=>o.name===e);this.handleItemClick(r)}buildItems(e){return e.map(r=>{switch(r.type){case Zt.Separator:return new zI;case Zt.Html:return new Ac(r,this.itemsRenderParams[Zt.Html]);default:return new Fi(r,this.itemsRenderParams[Zt.Default])}})}getTargetItem(e){return this.items.filter(r=>r instanceof Fi||r instanceof Ac).find(r=>{let o=r.getElement();return o===null?!1:e.composedPath().includes(o)})}handleItemClick(e){if(!("isDisabled"in e&&e.isDisabled)){if(e.hasChildren){this.showNestedItems(e),"handleClick"in e&&typeof e.handleClick=="function"&&e.handleClick();return}this.itemsDefault.filter(r=>r!==e).forEach(r=>r.reset()),"handleClick"in e&&typeof e.handleClick=="function"&&e.handleClick(),this.toggleItemActivenessIfNeeded(e),e.closeOnActivate&&(this.hide(),this.emit(oi.ClosedOnActivate))}}handleClick(e){let r=this.getTargetItem(e);r!==void 0&&this.handleItemClick(r)}toggleItemActivenessIfNeeded(e){if(e instanceof Fi&&(e.toggle===!0&&e.toggleActive(),typeof e.toggle=="string")){let r=this.itemsDefault.filter(o=>o.toggle===e.toggle);if(r.length===1){e.toggleActive();return}r.forEach(o=>{o.toggleActive(o===e)})}}},VI=(t=>(t.Search="search",t))(VI||{}),rD=Us("cdx-search-field"),oD={wrapper:rD(),icon:rD("icon"),input:rD("input")},DD=class extends Oc{constructor({items:e,placeholder:r}){super(),this.listeners=new Dc,this.items=e,this.wrapper=K.make("div",oD.wrapper);let o=K.make("div",oD.icon,{innerHTML:LMe});this.input=K.make("input",oD.input,{placeholder:r,tabIndex:-1}),this.wrapper.appendChild(o),this.wrapper.appendChild(this.input),this.listeners.on(this.input,"input",()=>{this.searchQuery=this.input.value,this.emit(VI.Search,{query:this.searchQuery,items:this.foundItems})})}getElement(){return this.wrapper}focus(){this.input.focus()}clear(){this.input.value="",this.searchQuery="",this.emit(VI.Search,{query:"",items:this.foundItems})}destroy(){this.listeners.removeAll()}get foundItems(){return this.items.filter(e=>this.checkItem(e))}checkItem(e){var r,o;let n=((r=e.title)==null?void 0:r.toLowerCase())||"",a=(o=this.searchQuery)==null?void 0:o.toLowerCase();return a!==void 0?n.includes(a):!1}},VMe=Object.defineProperty,$Me=Object.getOwnPropertyDescriptor,HMe=(t,e,r,o)=>{for(var n=o>1?void 0:o?$Me(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=(o?i(e,r,n):i(n))||n);return o&&n&&VMe(e,r,n),n},FY=class zY extends UI{constructor(e,r){super(e,r),this.nestingLevel=0,this.nestedPopoverTriggerItem=null,this.previouslyHoveredItem=null,this.scopeElement=document.body,this.hide=()=>{var o;super.hide(),this.destroyNestedPopoverIfExists(),(o=this.flipper)==null||o.deactivate(),this.previouslyHoveredItem=null},this.onFlip=()=>{let o=this.itemsDefault.find(n=>n.isFocused);o?.onFocus()},this.onSearch=o=>{var n;let a=o.query==="",i=o.items.length===0;this.items.forEach(l=>{let c=!1;l instanceof Fi?c=!o.items.includes(l):(l instanceof zI||l instanceof Ac)&&(c=i||!a),l.toggleHidden(c)}),this.toggleNothingFoundMessage(i);let s=o.query===""?this.flippableElements:o.items.map(l=>l.getElement());(n=this.flipper)!=null&&n.isActivated&&(this.flipper.deactivate(),this.flipper.activate(s))},e.nestingLevel!==void 0&&(this.nestingLevel=e.nestingLevel),this.nestingLevel>0&&this.nodes.popover.classList.add(br.popoverNested),e.scopeElement!==void 0&&(this.scopeElement=e.scopeElement),this.nodes.popoverContainer!==null&&this.listeners.on(this.nodes.popoverContainer,"mouseover",o=>this.handleHover(o)),e.searchable&&this.addSearch(),e.flippable!==!1&&(this.flipper=new Zu({items:this.flippableElements,focusedItemClass:dr.focused,allowedKeys:[Ye.TAB,Ye.UP,Ye.DOWN,Ye.ENTER]}),this.flipper.onFlip(this.onFlip))}hasFocus(){return this.flipper===void 0?!1:this.flipper.hasFocus()}get scrollTop(){return this.nodes.items===null?0:this.nodes.items.scrollTop}get offsetTop(){return this.nodes.popoverContainer===null?0:this.nodes.popoverContainer.offsetTop}show(){var e;this.nodes.popover.style.setProperty(Qu.PopoverHeight,this.size.height+"px"),this.shouldOpenBottom||this.nodes.popover.classList.add(br.popoverOpenTop),this.shouldOpenRight||this.nodes.popover.classList.add(br.popoverOpenLeft),super.show(),(e=this.flipper)==null||e.activate(this.flippableElements)}destroy(){this.hide(),super.destroy()}showNestedItems(e){this.nestedPopover!==null&&this.nestedPopover!==void 0||(this.nestedPopoverTriggerItem=e,this.showNestedPopoverForItem(e))}handleHover(e){let r=this.getTargetItem(e);r!==void 0&&this.previouslyHoveredItem!==r&&(this.destroyNestedPopoverIfExists(),this.previouslyHoveredItem=r,r.hasChildren&&this.showNestedPopoverForItem(r))}setTriggerItemPosition(e,r){let o=r.getElement(),n=(o?o.offsetTop:0)-this.scrollTop,a=this.offsetTop+n;e.style.setProperty(Qu.TriggerItemTop,a+"px")}destroyNestedPopoverIfExists(){var e,r;this.nestedPopover===void 0||this.nestedPopover===null||(this.nestedPopover.off(oi.ClosedOnActivate,this.hide),this.nestedPopover.hide(),this.nestedPopover.destroy(),this.nestedPopover.getElement().remove(),this.nestedPopover=null,(e=this.flipper)==null||e.activate(this.flippableElements),(r=this.nestedPopoverTriggerItem)==null||r.onChildrenClose())}showNestedPopoverForItem(e){var r;this.nestedPopover=new zY({searchable:e.isChildrenSearchable,items:e.children,nestingLevel:this.nestingLevel+1,flippable:e.isChildrenFlippable,messages:this.messages}),e.onChildrenOpen(),this.nestedPopover.on(oi.ClosedOnActivate,this.hide);let o=this.nestedPopover.getElement();return this.nodes.popover.appendChild(o),this.setTriggerItemPosition(o,e),o.style.setProperty(Qu.NestingLevel,this.nestedPopover.nestingLevel.toString()),this.nestedPopover.show(),(r=this.flipper)==null||r.deactivate(),this.nestedPopover}get shouldOpenBottom(){if(this.nodes.popover===void 0||this.nodes.popover===null)return!1;let e=this.nodes.popoverContainer.getBoundingClientRect(),r=this.scopeElement.getBoundingClientRect(),o=this.size.height,n=e.top+o,a=e.top-o,i=Math.min(window.innerHeight,r.bottom);return a<r.top||n<=i}get shouldOpenRight(){if(this.nodes.popover===void 0||this.nodes.popover===null)return!1;let e=this.nodes.popover.getBoundingClientRect(),r=this.scopeElement.getBoundingClientRect(),o=this.size.width,n=e.right+o,a=e.left-o,i=Math.min(window.innerWidth,r.right);return a<r.left||n<=i}get size(){var e;let r={height:0,width:0};if(this.nodes.popover===null)return r;let o=this.nodes.popover.cloneNode(!0);o.style.visibility="hidden",o.style.position="absolute",o.style.top="-1000px",o.classList.add(br.popoverOpened),(e=o.querySelector("."+br.popoverNested))==null||e.remove(),document.body.appendChild(o);let n=o.querySelector("."+br.popoverContainer);return r.height=n.offsetHeight,r.width=n.offsetWidth,o.remove(),r}get flippableElements(){return this.items.map(e=>{if(e instanceof Fi)return e.getElement();if(e instanceof Ac)return e.getControls()}).flat().filter(e=>e!=null)}addSearch(){this.search=new DD({items:this.itemsDefault,placeholder:this.messages.search}),this.search.on(VI.Search,this.onSearch);let e=this.search.getElement();e.classList.add(br.search),this.nodes.popoverContainer.insertBefore(e,this.nodes.popoverContainer.firstChild)}toggleNothingFoundMessage(e){this.nodes.nothingFoundMessage.classList.toggle(br.nothingFoundMessageDisplayed,e)}};HMe([ef],FY.prototype,"size",1);var cA=FY,AD=class extends cA{constructor(e){let r=!tf();super({...e,class:br.popoverInline},{[Zt.Default]:{wrapperTag:"button",hint:{position:"top",alignment:"center",enabled:r}},[Zt.Html]:{hint:{position:"top",alignment:"center",enabled:r}}}),this.items.forEach(o=>{!(o instanceof Fi)&&!(o instanceof Ac)||o.hasChildren&&o.isChildrenOpen&&this.showNestedItems(o)})}get offsetLeft(){return this.nodes.popoverContainer===null?0:this.nodes.popoverContainer.offsetLeft}show(){this.nestingLevel===0&&this.nodes.popover.style.setProperty(Qu.InlinePopoverWidth,this.size.width+"px"),super.show()}handleHover(){}setTriggerItemPosition(e,r){let o=r.getElement(),n=o?o.offsetLeft:0,a=this.offsetLeft+n;e.style.setProperty(Qu.TriggerItemLeft,a+"px")}showNestedItems(e){if(this.nestedPopoverTriggerItem===e){this.destroyNestedPopoverIfExists(),this.nestedPopoverTriggerItem=null;return}super.showNestedItems(e)}showNestedPopoverForItem(e){let r=super.showNestedPopoverForItem(e);return r.getElement().classList.add(br.getPopoverNestedClass(r.nestingLevel)),r}handleItemClick(e){var r;e!==this.nestedPopoverTriggerItem&&((r=this.nestedPopoverTriggerItem)==null||r.handleClick(),super.destroyNestedPopoverIfExists()),super.handleItemClick(e)}},UY=class Dh{constructor(){this.scrollPosition=null}lock(){cD?this.lockHard():document.body.classList.add(Dh.CSS.scrollLocked)}unlock(){cD?this.unlockHard():document.body.classList.remove(Dh.CSS.scrollLocked)}lockHard(){this.scrollPosition=window.pageYOffset,document.documentElement.style.setProperty("--window-scroll-offset",`${this.scrollPosition}px`),document.body.classList.add(Dh.CSS.scrollLockedHard)}unlockHard(){document.body.classList.remove(Dh.CSS.scrollLockedHard),this.scrollPosition!==null&&window.scrollTo(0,this.scrollPosition),this.scrollPosition=null}};UY.CSS={scrollLocked:"ce-scroll-locked",scrollLockedHard:"ce-scroll-locked--hard"};var jMe=UY,nD=Us("ce-popover-header"),aD={root:nD(),text:nD("text"),backButton:nD("back-button")},ND=class{constructor({text:e,onBackButtonClick:r}){this.listeners=new Dc,this.text=e,this.onBackButtonClick=r,this.nodes={root:K.make("div",[aD.root]),backButton:K.make("button",[aD.backButton]),text:K.make("div",[aD.text])},this.nodes.backButton.innerHTML=TMe,this.nodes.root.appendChild(this.nodes.backButton),this.listeners.on(this.nodes.backButton,"click",this.onBackButtonClick),this.nodes.text.innerText=this.text,this.nodes.root.appendChild(this.nodes.text)}getElement(){return this.nodes.root}destroy(){this.nodes.root.remove(),this.listeners.destroy()}},RD=class{constructor(){this.history=[]}push(e){this.history.push(e)}pop(){return this.history.pop()}get currentTitle(){return this.history.length===0?"":this.history[this.history.length-1].title}get currentItems(){return this.history.length===0?[]:this.history[this.history.length-1].items}reset(){for(;this.history.length>1;)this.pop()}},$I=class extends UI{constructor(e){super(e,{[Zt.Default]:{hint:{enabled:!1}},[Zt.Html]:{hint:{enabled:!1}}}),this.scrollLocker=new jMe,this.history=new RD,this.isHidden=!0,this.nodes.overlay=K.make("div",[br.overlay,br.overlayHidden]),this.nodes.popover.insertBefore(this.nodes.overlay,this.nodes.popover.firstChild),this.listeners.on(this.nodes.overlay,"click",()=>{this.hide()}),this.history.push({items:e.items})}show(){this.nodes.overlay.classList.remove(br.overlayHidden),super.show(),this.scrollLocker.lock(),this.isHidden=!1}hide(){this.isHidden||(super.hide(),this.nodes.overlay.classList.add(br.overlayHidden),this.scrollLocker.unlock(),this.history.reset(),this.isHidden=!0)}destroy(){super.destroy(),this.scrollLocker.unlock()}showNestedItems(e){this.updateItemsAndHeader(e.children,e.title),this.history.push({title:e.title,items:e.children})}updateItemsAndHeader(e,r){if(this.header!==null&&this.header!==void 0&&(this.header.destroy(),this.header=null),r!==void 0){this.header=new ND({text:r,onBackButtonClick:()=>{this.history.pop(),this.updateItemsAndHeader(this.history.currentItems,this.history.currentTitle)}});let o=this.header.getElement();o!==null&&this.nodes.popoverContainer.insertBefore(o,this.nodes.popoverContainer.firstChild)}this.items.forEach(o=>{var n;return(n=o.getElement())==null?void 0:n.remove()}),this.items=this.buildItems(e),this.items.forEach(o=>{var n;let a=o.getElement();a!==null&&((n=this.nodes.items)==null||n.appendChild(a))})}},MD=class extends ft{constructor(){super(...arguments),this.opened=!1,this.selection=new ze,this.popover=null,this.close=()=>{this.opened&&(this.opened=!1,ze.isAtEditor||this.selection.restore(),this.selection.clearSaved(),!this.Editor.CrossBlockSelection.isCrossBlockSelectionStarted&&this.Editor.BlockManager.currentBlock&&this.Editor.BlockSelection.unselectBlock(this.Editor.BlockManager.currentBlock),this.eventsDispatcher.emit(this.events.closed),this.popover&&(this.popover.off(oi.Closed,this.onPopoverClose),this.popover.destroy(),this.popover.getElement().remove(),this.popover=null))},this.onPopoverClose=()=>{this.close()}}get events(){return{opened:"block-settings-opened",closed:"block-settings-closed"}}get CSS(){return{settings:"ce-settings"}}get flipper(){var e;if(this.popover!==null)return"flipper"in this.popover?(e=this.popover)==null?void 0:e.flipper:void 0}make(){this.nodes.wrapper=K.make("div",[this.CSS.settings]),this.nodes.wrapper.setAttribute("data-cy","block-tunes"),this.eventsDispatcher.on(Rh,this.close)}destroy(){this.removeAllNodes(),this.listeners.destroy(),this.eventsDispatcher.off(Rh,this.close)}async open(e=this.Editor.BlockManager.currentBlock){var r;this.opened=!0,this.selection.save(),this.Editor.BlockSelection.selectBlock(e),this.Editor.BlockSelection.clearCache();let{toolTunes:o,commonTunes:n}=e.getTunes();this.eventsDispatcher.emit(this.events.opened);let a=tf()?$I:cA;this.popover=new a({searchable:!0,items:await this.getTunesItems(e,n,o),scopeElement:this.Editor.API.methods.ui.nodes.redactor,messages:{nothingFound:Zo.ui(Dn.ui.popover,"Nothing found"),search:Zo.ui(Dn.ui.popover,"Filter")}}),this.popover.on(oi.Closed,this.onPopoverClose),(r=this.nodes.wrapper)==null||r.append(this.popover.getElement()),this.popover.show()}getElement(){return this.nodes.wrapper}async getTunesItems(e,r,o){let n=[];o!==void 0&&o.length>0&&(n.push(...o),n.push({type:Zt.Separator}));let a=Array.from(this.Editor.Tools.blockTools.values()),i=(await DY(e,a)).reduce((s,l)=>(l.toolbox.forEach(c=>{s.push({icon:c.icon,title:Zo.t(Dn.toolNames,c.title),name:l.name,closeOnActivate:!0,onActivate:async()=>{let{BlockManager:d,Caret:u,Toolbar:p}=this.Editor,m=await d.convert(e,l.name,c.data);p.close(),u.setToBlock(m,u.positions.END)}})}),s),[]);return i.length>0&&(n.push({icon:BY,name:"convert-to",title:Zo.ui(Dn.ui.popover,"Convert to"),children:{searchable:!0,items:i}}),n.push({type:Zt.Separator})),n.push(...r),n.map(s=>this.resolveTuneAliases(s))}resolveTuneAliases(e){if(e.type===Zt.Separator||e.type===Zt.Html)return e;let r=SMe(e,{label:"title"});return e.confirmation&&(r.confirmation=this.resolveTuneAliases(e.confirmation)),r}},VY={exports:{}};(function(t,e){(function(r,o){t.exports=o()})(window,function(){return function(r){var o={};function n(a){if(o[a])return o[a].exports;var i=o[a]={i:a,l:!1,exports:{}};return r[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=r,n.c=o,n.d=function(a,i,s){n.o(a,i)||Object.defineProperty(a,i,{enumerable:!0,get:s})},n.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},n.t=function(a,i){if(1&i&&(a=n(a)),8&i||4&i&&typeof a=="object"&&a&&a.__esModule)return a;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:a}),2&i&&typeof a!="string")for(var l in a)n.d(s,l,function(c){return a[c]}.bind(null,l));return s},n.n=function(a){var i=a&&a.__esModule?function(){return a.default}:function(){return a};return n.d(i,"a",i),i},n.o=function(a,i){return Object.prototype.hasOwnProperty.call(a,i)},n.p="",n(n.s=0)}([function(r,o,n){function a(l,c){for(var d=0;d<c.length;d++){var u=c[d];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(l,u.key,u)}}function i(l,c,d){return c&&a(l.prototype,c),d&&a(l,d),l}n.r(o);var s=function(){function l(c){var d=this;(function(u,p){if(!(u instanceof p))throw new TypeError("Cannot call a class as a function")})(this,l),this.commands={},this.keys={},this.name=c.name,this.parseShortcutName(c.name),this.element=c.on,this.callback=c.callback,this.executeShortcut=function(u){d.execute(u)},this.element.addEventListener("keydown",this.executeShortcut,!1)}return i(l,null,[{key:"supportedCommands",get:function(){return{SHIFT:["SHIFT"],CMD:["CMD","CONTROL","COMMAND","WINDOWS","CTRL"],ALT:["ALT","OPTION"]}}},{key:"keyCodes",get:function(){return{0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,BACKSPACE:8,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DELETE:46,".":190}}}]),i(l,[{key:"parseShortcutName",value:function(c){c=c.split("+");for(var d=0;d<c.length;d++){c[d]=c[d].toUpperCase();var u=!1;for(var p in l.supportedCommands)if(l.supportedCommands[p].includes(c[d])){u=this.commands[p]=!0;break}u||(this.keys[c[d]]=!0)}for(var m in l.supportedCommands)this.commands[m]||(this.commands[m]=!1)}},{key:"execute",value:function(c){var d,u={CMD:c.ctrlKey||c.metaKey,SHIFT:c.shiftKey,ALT:c.altKey},p=!0;for(d in this.commands)this.commands[d]!==u[d]&&(p=!1);var m,h=!0;for(m in this.keys)h=h&&c.keyCode===l.keyCodes[m];p&&h&&this.callback(c)}},{key:"remove",value:function(){this.element.removeEventListener("keydown",this.executeShortcut)}}]),l}();o.default=s}]).default})})(VY);var qMe=VY.exports,GMe=QI(qMe),LD=class{constructor(){this.registeredShortcuts=new Map}add(e){if(this.findShortcut(e.on,e.name))throw Error(`Shortcut ${e.name} is already registered for ${e.on}. Please remove it before add a new handler.`);let r=new GMe({name:e.name,on:e.on,callback:e.handler}),o=this.registeredShortcuts.get(e.on)||[];this.registeredShortcuts.set(e.on,[...o,r])}remove(e,r){let o=this.findShortcut(e,r);if(!o)return;o.remove();let n=this.registeredShortcuts.get(e);this.registeredShortcuts.set(e,n.filter(a=>a!==o))}findShortcut(e,r){return(this.registeredShortcuts.get(e)||[]).find(({name:o})=>o===r)}},Ju=new LD,WMe=Object.defineProperty,KMe=Object.getOwnPropertyDescriptor,$Y=(t,e,r,o)=>{for(var n=o>1?void 0:o?KMe(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=(o?i(e,r,n):i(n))||n);return o&&n&&WMe(e,r,n),n},TI=(t=>(t.Opened="toolbox-opened",t.Closed="toolbox-closed",t.BlockAdded="toolbox-block-added",t))(TI||{}),dA=class HY extends Oc{constructor({api:e,tools:r,i18nLabels:o}){super(),this.opened=!1,this.listeners=new Dc,this.popover=null,this.handleMobileLayoutToggle=()=>{this.destroyPopover(),this.initPopover()},this.onPopoverClose=()=>{this.opened=!1,this.emit("toolbox-closed")},this.api=e,this.tools=r,this.i18nLabels=o,this.enableShortcuts(),this.nodes={toolbox:K.make("div",HY.CSS.toolbox)},this.initPopover(),this.nodes.toolbox.setAttribute("data-cy","toolbox"),this.api.events.on(Rh,this.handleMobileLayoutToggle)}get isEmpty(){return this.toolsToBeDisplayed.length===0}static get CSS(){return{toolbox:"ce-toolbox"}}getElement(){return this.nodes.toolbox}hasFocus(){if(this.popover!==null)return"hasFocus"in this.popover?this.popover.hasFocus():void 0}destroy(){var e;super.destroy(),this.nodes&&this.nodes.toolbox&&this.nodes.toolbox.remove(),this.removeAllShortcuts(),(e=this.popover)==null||e.off(oi.Closed,this.onPopoverClose),this.listeners.destroy(),this.api.events.off(Rh,this.handleMobileLayoutToggle)}toolButtonActivated(e,r){this.insertNewBlock(e,r)}open(){var e;this.isEmpty||((e=this.popover)==null||e.show(),this.opened=!0,this.emit("toolbox-opened"))}close(){var e;(e=this.popover)==null||e.hide(),this.opened=!1,this.emit("toolbox-closed")}toggle(){this.opened?this.close():this.open()}initPopover(){var e;let r=tf()?$I:cA;this.popover=new r({scopeElement:this.api.ui.nodes.redactor,searchable:!0,messages:{nothingFound:this.i18nLabels.nothingFound,search:this.i18nLabels.filter},items:this.toolboxItemsToBeDisplayed}),this.popover.on(oi.Closed,this.onPopoverClose),(e=this.nodes.toolbox)==null||e.append(this.popover.getElement())}destroyPopover(){this.popover!==null&&(this.popover.hide(),this.popover.off(oi.Closed,this.onPopoverClose),this.popover.destroy(),this.popover=null),this.nodes.toolbox!==null&&(this.nodes.toolbox.innerHTML="")}get toolsToBeDisplayed(){let e=[];return this.tools.forEach(r=>{r.toolbox&&e.push(r)}),e}get toolboxItemsToBeDisplayed(){let e=(r,o,n=!0)=>({icon:r.icon,title:Zo.t(Dn.toolNames,r.title||RI(o.name)),name:o.name,onActivate:()=>{this.toolButtonActivated(o.name,r.data)},secondaryLabel:o.shortcut&&n?aA(o.shortcut):""});return this.toolsToBeDisplayed.reduce((r,o)=>(Array.isArray(o.toolbox)?o.toolbox.forEach((n,a)=>{r.push(e(n,o,a===0))}):o.toolbox!==void 0&&r.push(e(o.toolbox,o)),r),[])}enableShortcuts(){this.toolsToBeDisplayed.forEach(e=>{let r=e.shortcut;r&&this.enableShortcutForTool(e.name,r)})}enableShortcutForTool(e,r){Ju.add({name:r,on:this.api.ui.nodes.redactor,handler:async o=>{o.preventDefault();let n=this.api.blocks.getCurrentBlockIndex(),a=this.api.blocks.getBlockByIndex(n);if(a)try{let i=await this.api.blocks.convert(a.id,e);this.api.caret.setToBlock(i,"end");return}catch{}this.insertNewBlock(e)}})}removeAllShortcuts(){this.toolsToBeDisplayed.forEach(e=>{let r=e.shortcut;r&&Ju.remove(this.api.ui.nodes.redactor,r)})}async insertNewBlock(e,r){let o=this.api.blocks.getCurrentBlockIndex(),n=this.api.blocks.getBlockByIndex(o);if(!n)return;let a=n.isEmpty?o:o+1,i;if(r){let l=await this.api.blocks.composeBlockData(e);i=Object.assign(l,r)}let s=this.api.blocks.insert(e,i,void 0,a,void 0,n.isEmpty);s.call(Bi.APPEND_CALLBACK),this.api.caret.setToBlock(a),this.emit("toolbox-block-added",{block:s}),this.api.toolbar.close()}};$Y([ef],dA.prototype,"toolsToBeDisplayed",1);$Y([ef],dA.prototype,"toolboxItemsToBeDisplayed",1);var YMe=dA,jY="block hovered";async function XMe(t,e){let r=navigator.keyboard;if(!r)return e;try{return(await r.getLayoutMap()).get(t)||e}catch(o){return console.error(o),e}}var BD=class extends ft{constructor({config:e,eventsDispatcher:r}){super({config:e,eventsDispatcher:r}),this.toolboxInstance=null}get CSS(){return{toolbar:"ce-toolbar",content:"ce-toolbar__content",actions:"ce-toolbar__actions",actionsOpened:"ce-toolbar__actions--opened",toolbarOpened:"ce-toolbar--opened",openedToolboxHolderModifier:"codex-editor--toolbox-opened",plusButton:"ce-toolbar__plus",plusButtonShortcut:"ce-toolbar__plus-shortcut",settingsToggler:"ce-toolbar__settings-btn",settingsTogglerHidden:"ce-toolbar__settings-btn--hidden"}}get opened(){return this.nodes.wrapper.classList.contains(this.CSS.toolbarOpened)}get toolbox(){var e;return{opened:(e=this.toolboxInstance)==null?void 0:e.opened,close:()=>{var r;(r=this.toolboxInstance)==null||r.close()},open:()=>{if(this.toolboxInstance===null){At("toolbox.open() called before initialization is finished","warn");return}this.Editor.BlockManager.currentBlock=this.hoveredBlock,this.toolboxInstance.open()},toggle:()=>{if(this.toolboxInstance===null){At("toolbox.toggle() called before initialization is finished","warn");return}this.toolboxInstance.toggle()},hasFocus:()=>{var r;return(r=this.toolboxInstance)==null?void 0:r.hasFocus()}}}get blockActions(){return{hide:()=>{this.nodes.actions.classList.remove(this.CSS.actionsOpened)},show:()=>{this.nodes.actions.classList.add(this.CSS.actionsOpened)}}}get blockTunesToggler(){return{hide:()=>this.nodes.settingsToggler.classList.add(this.CSS.settingsTogglerHidden),show:()=>this.nodes.settingsToggler.classList.remove(this.CSS.settingsTogglerHidden)}}toggleReadOnly(e){e?(this.destroy(),this.Editor.BlockSettings.destroy(),this.disableModuleBindings()):window.requestIdleCallback(()=>{this.drawUI(),this.enableModuleBindings()},{timeout:2e3})}moveAndOpen(e=this.Editor.BlockManager.currentBlock){if(this.toolboxInstance===null){At("Can't open Toolbar since Editor initialization is not finished yet","warn");return}if(this.toolboxInstance.opened&&this.toolboxInstance.close(),this.Editor.BlockSettings.opened&&this.Editor.BlockSettings.close(),!e)return;this.hoveredBlock=e;let r=e.holder,{isMobile:o}=this.Editor.UI,n,a=20,i=e.firstInput,s=r.getBoundingClientRect(),l=i!==void 0?i.getBoundingClientRect():null,c=l!==null?l.top-s.top:null,d=c!==null?c>a:void 0;if(o)n=r.offsetTop+r.offsetHeight;else if(i===void 0||d){let u=parseInt(window.getComputedStyle(e.pluginsContent).paddingTop);n=r.offsetTop+u}else{let u=aMe(i),p=parseInt(window.getComputedStyle(this.nodes.plusButton).height,10),m=8;n=r.offsetTop+u-p+m+c}this.nodes.wrapper.style.top=`${Math.floor(n)}px`,this.Editor.BlockManager.blocks.length===1&&e.isEmpty?this.blockTunesToggler.hide():this.blockTunesToggler.show(),this.open()}close(){var e,r;this.Editor.ReadOnly.isEnabled||((e=this.nodes.wrapper)==null||e.classList.remove(this.CSS.toolbarOpened),this.blockActions.hide(),(r=this.toolboxInstance)==null||r.close(),this.Editor.BlockSettings.close(),this.reset())}reset(){this.nodes.wrapper.style.top="unset"}open(e=!0){this.nodes.wrapper.classList.add(this.CSS.toolbarOpened),e?this.blockActions.show():this.blockActions.hide()}async make(){this.nodes.wrapper=K.make("div",this.CSS.toolbar),["content","actions"].forEach(a=>{this.nodes[a]=K.make("div",this.CSS[a])}),K.append(this.nodes.wrapper,this.nodes.content),K.append(this.nodes.content,this.nodes.actions),this.nodes.plusButton=K.make("div",this.CSS.plusButton,{innerHTML:MMe}),K.append(this.nodes.actions,this.nodes.plusButton),this.readOnlyMutableListeners.on(this.nodes.plusButton,"click",()=>{BI(!0),this.plusButtonClicked()},!1);let e=K.make("div");e.appendChild(document.createTextNode(Zo.ui(Dn.ui.toolbar.toolbox,"Add"))),e.appendChild(K.make("div",this.CSS.plusButtonShortcut,{textContent:"/"})),FI(this.nodes.plusButton,e,{hidingDelay:400}),this.nodes.settingsToggler=K.make("span",this.CSS.settingsToggler,{innerHTML:RMe}),K.append(this.nodes.actions,this.nodes.settingsToggler);let r=K.make("div"),o=K.text(Zo.ui(Dn.ui.blockTunes.toggler,"Click to tune")),n=await XMe("Slash","/");r.appendChild(o),r.appendChild(K.make("div",this.CSS.plusButtonShortcut,{textContent:aA(`CMD + ${n}`)})),FI(this.nodes.settingsToggler,r,{hidingDelay:400}),K.append(this.nodes.actions,this.makeToolbox()),K.append(this.nodes.actions,this.Editor.BlockSettings.getElement()),K.append(this.Editor.UI.nodes.wrapper,this.nodes.wrapper)}makeToolbox(){return this.toolboxInstance=new YMe({api:this.Editor.API.methods,tools:this.Editor.Tools.blockTools,i18nLabels:{filter:Zo.ui(Dn.ui.popover,"Filter"),nothingFound:Zo.ui(Dn.ui.popover,"Nothing found")}}),this.toolboxInstance.on(TI.Opened,()=>{this.Editor.UI.nodes.wrapper.classList.add(this.CSS.openedToolboxHolderModifier)}),this.toolboxInstance.on(TI.Closed,()=>{this.Editor.UI.nodes.wrapper.classList.remove(this.CSS.openedToolboxHolderModifier)}),this.toolboxInstance.on(TI.BlockAdded,({block:e})=>{let{BlockManager:r,Caret:o}=this.Editor,n=r.getBlockById(e.id);n.inputs.length===0&&(n===r.lastBlock?(r.insertAtEnd(),o.setToBlock(r.lastBlock)):o.setToBlock(r.nextBlock))}),this.toolboxInstance.getElement()}plusButtonClicked(){var e;this.Editor.BlockManager.currentBlock=this.hoveredBlock,(e=this.toolboxInstance)==null||e.toggle()}enableModuleBindings(){this.readOnlyMutableListeners.on(this.nodes.settingsToggler,"mousedown",e=>{var r;e.stopPropagation(),this.settingsTogglerClicked(),(r=this.toolboxInstance)!=null&&r.opened&&this.toolboxInstance.close(),BI(!0)},!0),tf()||this.eventsDispatcher.on(jY,e=>{var r;this.Editor.BlockSettings.opened||(r=this.toolboxInstance)!=null&&r.opened||this.moveAndOpen(e.block)})}disableModuleBindings(){this.readOnlyMutableListeners.clearAll()}settingsTogglerClicked(){this.Editor.BlockManager.currentBlock=this.hoveredBlock,this.Editor.BlockSettings.opened?this.Editor.BlockSettings.close():this.Editor.BlockSettings.open(this.hoveredBlock)}drawUI(){this.Editor.BlockSettings.make(),this.make()}destroy(){this.removeAllNodes(),this.toolboxInstance&&this.toolboxInstance.destroy()}},Tc=(t=>(t[t.Block=0]="Block",t[t.Inline=1]="Inline",t[t.Tune=2]="Tune",t))(Tc||{}),PI=(t=>(t.Shortcut="shortcut",t.Toolbox="toolbox",t.EnabledInlineTools="inlineToolbar",t.EnabledBlockTunes="tunes",t.Config="config",t))(PI||{}),qY=(t=>(t.Shortcut="shortcut",t.SanitizeConfig="sanitize",t))(qY||{}),Xu=(t=>(t.IsEnabledLineBreaks="enableLineBreaks",t.Toolbox="toolbox",t.ConversionConfig="conversionConfig",t.IsReadOnlySupported="isReadOnlySupported",t.PasteConfig="pasteConfig",t))(Xu||{}),HI=(t=>(t.IsInline="isInline",t.Title="title",t.IsReadOnlySupported="isReadOnlySupported",t))(HI||{}),FD=(t=>(t.IsTune="isTune",t))(FD||{}),Lh=class{constructor({name:e,constructable:r,config:o,api:n,isDefault:a,isInternal:i=!1,defaultPlaceholder:s}){this.api=n,this.name=e,this.constructable=r,this.config=o,this.isDefault=a,this.isInternal=i,this.defaultPlaceholder=s}get settings(){let e=this.config.config||{};return this.isDefault&&!("placeholder"in e)&&this.defaultPlaceholder&&(e.placeholder=this.defaultPlaceholder),e}reset(){if(rr(this.constructable.reset))return this.constructable.reset()}prepare(){if(rr(this.constructable.prepare))return this.constructable.prepare({toolName:this.name,config:this.settings})}get shortcut(){let e=this.constructable.shortcut;return this.config.shortcut||e}get sanitizeConfig(){return this.constructable.sanitize||{}}isInline(){return this.type===Tc.Inline}isBlock(){return this.type===Tc.Block}isTune(){return this.type===Tc.Tune}},zD=class extends ft{constructor({config:e,eventsDispatcher:r}){super({config:e,eventsDispatcher:r}),this.CSS={inlineToolbar:"ce-inline-toolbar"},this.opened=!1,this.popover=null,this.toolbarVerticalMargin=tf()?20:6,this.tools=new Map,window.requestIdleCallback(()=>{this.make()},{timeout:2e3})}async tryToShow(e=!1){e&&this.close(),this.allowedToShow()&&(await this.open(),this.Editor.Toolbar.close())}close(){var e,r;if(this.opened){for(let[o,n]of this.tools){let a=this.getToolShortcut(o.name);a!==void 0&&Ju.remove(this.Editor.UI.nodes.redactor,a),rr(n.clear)&&n.clear()}this.tools=new Map,this.reset(),this.opened=!1,(e=this.popover)==null||e.hide(),(r=this.popover)==null||r.destroy(),this.popover=null}}containsNode(e){return this.nodes.wrapper===void 0?!1:this.nodes.wrapper.contains(e)}destroy(){var e;this.removeAllNodes(),(e=this.popover)==null||e.destroy(),this.popover=null}make(){this.nodes.wrapper=K.make("div",[this.CSS.inlineToolbar,...this.isRtl?[this.Editor.UI.CSS.editorRtlFix]:[]]),this.nodes.wrapper.setAttribute("data-cy","inline-toolbar"),K.append(this.Editor.UI.nodes.wrapper,this.nodes.wrapper)}async open(){var e;if(this.opened)return;this.opened=!0,this.popover!==null&&this.popover.destroy(),this.createToolsInstances();let r=await this.getPopoverItems();this.popover=new AD({items:r,scopeElement:this.Editor.API.methods.ui.nodes.redactor,messages:{nothingFound:Zo.ui(Dn.ui.popover,"Nothing found"),search:Zo.ui(Dn.ui.popover,"Filter")}}),this.move(this.popover.size.width),(e=this.nodes.wrapper)==null||e.append(this.popover.getElement()),this.popover.show()}move(e){let r=ze.rect,o=this.Editor.UI.nodes.wrapper.getBoundingClientRect(),n={x:r.x-o.x,y:r.y+r.height-o.top+this.toolbarVerticalMargin};n.x+e+o.x>this.Editor.UI.contentRect.right&&(n.x=this.Editor.UI.contentRect.right-e-o.x),this.nodes.wrapper.style.left=Math.floor(n.x)+"px",this.nodes.wrapper.style.top=Math.floor(n.y)+"px"}reset(){this.nodes.wrapper.style.left="0",this.nodes.wrapper.style.top="0"}allowedToShow(){let e=["IMG","INPUT"],r=ze.get(),o=ze.text;if(!r||!r.anchorNode||r.isCollapsed||o.length<1)return!1;let n=K.isElement(r.anchorNode)?r.anchorNode:r.anchorNode.parentElement;if(n===null||r!==null&&e.includes(n.tagName))return!1;let a=this.Editor.BlockManager.getBlock(r.anchorNode);return!a||this.getTools().some(i=>a.tool.inlineTools.has(i.name))===!1?!1:n.closest("[contenteditable]")!==null}getTools(){let e=this.Editor.BlockManager.currentBlock;return e?Array.from(e.tool.inlineTools.values()).filter(r=>!(this.Editor.ReadOnly.isEnabled&&r.isReadOnlySupported!==!0)):[]}createToolsInstances(){this.tools=new Map,this.getTools().forEach(e=>{let r=e.create();this.tools.set(e,r)})}async getPopoverItems(){let e=[],r=0;for(let[o,n]of this.tools){let a=await n.render(),i=this.getToolShortcut(o.name);if(i!==void 0)try{this.enableShortcuts(o.name,i)}catch{}let s=i!==void 0?aA(i):void 0,l=Zo.t(Dn.toolNames,o.title||RI(o.name));[a].flat().forEach(c=>{var d,u;let p={name:o.name,onActivate:()=>{this.toolClicked(n)},hint:{title:l,description:s}};if(K.isElement(c)){let m={...p,element:c,type:Zt.Html};if(rr(n.renderActions)){let h=n.renderActions();m.children={isOpen:(d=n.checkState)==null?void 0:d.call(n,ze.get()),isFlippable:!1,items:[{type:Zt.Html,element:h}]}}else(u=n.checkState)==null||u.call(n,ze.get());e.push(m)}else if(c.type===Zt.Html)e.push({...p,...c,type:Zt.Html});else if(c.type===Zt.Separator)e.push({type:Zt.Separator});else{let m={...p,...c,type:Zt.Default};"children"in m&&r!==0&&e.push({type:Zt.Separator}),e.push(m),"children"in m&&r<this.tools.size-1&&e.push({type:Zt.Separator})}}),r++}return e}getToolShortcut(e){let{Tools:r}=this.Editor,o=r.inlineTools.get(e),n=r.internal.inlineTools;return Array.from(n.keys()).includes(e)?this.inlineTools[e][qY.Shortcut]:o?.shortcut}enableShortcuts(e,r){Ju.add({name:r,handler:o=>{var n;let{currentBlock:a}=this.Editor.BlockManager;a&&a.tool.enabledInlineTools&&(o.preventDefault(),(n=this.popover)==null||n.activateItemByName(e))},on:document})}toolClicked(e){var r;let o=ze.range;(r=e.surround)==null||r.call(e,o),this.checkToolsState()}checkToolsState(){var e;(e=this.tools)==null||e.forEach(r=>{var o;(o=r.checkState)==null||o.call(r,ze.get())})}get inlineTools(){let e={};return Array.from(this.Editor.Tools.inlineTools.entries()).forEach(([r,o])=>{e[r]=o.create()}),e}};function GY(){let t=window.getSelection();if(t===null)return[null,0];let e=t.focusNode,r=t.focusOffset;return e===null?[null,0]:(e.nodeType!==Node.TEXT_NODE&&e.childNodes.length>0&&(e.childNodes[r]?(e=e.childNodes[r],r=0):(e=e.childNodes[r-1],r=e.textContent.length)),[e,r])}function WY(t,e,r,o){let n=document.createRange();o==="left"?(n.setStart(t,0),n.setEnd(e,r)):(n.setStart(e,r),n.setEnd(t,t.childNodes.length));let a=n.cloneContents(),i=document.createElement("div");i.appendChild(a);let s=i.textContent||"";return nMe(s)}function OI(t){let e=K.getDeepestNode(t);if(e===null||K.isEmpty(t))return!0;if(K.isNativeInput(e))return e.selectionEnd===0;if(K.isEmpty(t))return!0;let[r,o]=GY();return r===null?!1:WY(t,r,o,"left")}function DI(t){let e=K.getDeepestNode(t,!0);if(e===null)return!0;if(K.isNativeInput(e))return e.selectionEnd===e.value.length;let[r,o]=GY();return r===null?!1:WY(t,r,o,"right")}var KY={},uA={},ZI={},Nc={},fA={},pA={};Object.defineProperty(pA,"__esModule",{value:!0});pA.allInputsSelector=QMe;function QMe(){var t=["text","password","email","number","search","tel","url"];return"[contenteditable=true], textarea, input:not([type]), "+t.map(function(e){return'input[type="'.concat(e,'"]')}).join(", ")}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.allInputsSelector=void 0;var e=pA;Object.defineProperty(t,"allInputsSelector",{enumerable:!0,get:function(){return e.allInputsSelector}})})(fA);var Rc={},mA={};Object.defineProperty(mA,"__esModule",{value:!0});mA.isNativeInput=ZMe;function ZMe(t){var e=["INPUT","TEXTAREA"];return t&&t.tagName?e.includes(t.tagName):!1}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isNativeInput=void 0;var e=mA;Object.defineProperty(t,"isNativeInput",{enumerable:!0,get:function(){return e.isNativeInput}})})(Rc);var YY={},hA={};Object.defineProperty(hA,"__esModule",{value:!0});hA.append=JMe;function JMe(t,e){Array.isArray(e)?e.forEach(function(r){t.appendChild(r)}):t.appendChild(e)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.append=void 0;var e=hA;Object.defineProperty(t,"append",{enumerable:!0,get:function(){return e.append}})})(YY);var gA={},_A={};Object.defineProperty(_A,"__esModule",{value:!0});_A.blockElements=e2e;function e2e(){return["address","article","aside","blockquote","canvas","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","noscript","ol","output","p","pre","ruby","section","table","tbody","thead","tr","tfoot","ul","video"]}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.blockElements=void 0;var e=_A;Object.defineProperty(t,"blockElements",{enumerable:!0,get:function(){return e.blockElements}})})(gA);var XY={},xA={};Object.defineProperty(xA,"__esModule",{value:!0});xA.calculateBaseline=t2e;function t2e(t){var e=window.getComputedStyle(t),r=parseFloat(e.fontSize),o=parseFloat(e.lineHeight)||r*1.2,n=parseFloat(e.paddingTop),a=parseFloat(e.borderTopWidth),i=parseFloat(e.marginTop),s=r*.8,l=(o-r)/2,c=i+a+n+l+s;return c}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.calculateBaseline=void 0;var e=xA;Object.defineProperty(t,"calculateBaseline",{enumerable:!0,get:function(){return e.calculateBaseline}})})(XY);var QY={},bA={},vA={},yA={};Object.defineProperty(yA,"__esModule",{value:!0});yA.isContentEditable=r2e;function r2e(t){return t.contentEditable==="true"}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isContentEditable=void 0;var e=yA;Object.defineProperty(t,"isContentEditable",{enumerable:!0,get:function(){return e.isContentEditable}})})(vA);Object.defineProperty(bA,"__esModule",{value:!0});bA.canSetCaret=a2e;var o2e=Rc,n2e=vA;function a2e(t){var e=!0;if((0,o2e.isNativeInput)(t))switch(t.type){case"file":case"checkbox":case"radio":case"hidden":case"submit":case"button":case"image":case"reset":e=!1;break}else e=(0,n2e.isContentEditable)(t);return e}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.canSetCaret=void 0;var e=bA;Object.defineProperty(t,"canSetCaret",{enumerable:!0,get:function(){return e.canSetCaret}})})(QY);var JI={},IA={};function i2e(t,e,r){let o=r.value!==void 0?"value":"get",n=r[o],a=`#${e}Cache`;if(r[o]=function(...i){return this[a]===void 0&&(this[a]=n.apply(this,i)),this[a]},o==="get"&&r.set){let i=r.set;r.set=function(s){delete t[a],i.apply(this,s)}}return r}function ZY(){let t={win:!1,mac:!1,x11:!1,linux:!1},e=Object.keys(t).find(r=>window.navigator.appVersion.toLowerCase().indexOf(r)!==-1);return e!==void 0&&(t[e]=!0),t}function wA(t){return t!=null&&t!==""&&(typeof t!="object"||Object.keys(t).length>0)}function s2e(t){return!wA(t)}var l2e=()=>typeof window<"u"&&window.navigator!==null&&wA(window.navigator.platform)&&(/iP(ad|hone|od)/.test(window.navigator.platform)||window.navigator.platform==="MacIntel"&&window.navigator.maxTouchPoints>1);function c2e(t){let e=ZY();return t=t.replace(/shift/gi,"\u21E7").replace(/backspace/gi,"\u232B").replace(/enter/gi,"\u23CE").replace(/up/gi,"\u2191").replace(/left/gi,"\u2192").replace(/down/gi,"\u2193").replace(/right/gi,"\u2190").replace(/escape/gi,"\u238B").replace(/insert/gi,"Ins").replace(/delete/gi,"\u2421").replace(/\+/gi,"+"),e.mac?t=t.replace(/ctrl|cmd/gi,"\u2318").replace(/alt/gi,"\u2325"):t=t.replace(/cmd/gi,"Ctrl").replace(/windows/gi,"WIN"),t}function d2e(t){return t[0].toUpperCase()+t.slice(1)}function u2e(t){let e=document.createElement("div");e.style.position="absolute",e.style.left="-999px",e.style.bottom="-999px",e.innerHTML=t,document.body.appendChild(e);let r=window.getSelection(),o=document.createRange();if(o.selectNode(e),r===null)throw new Error("Cannot copy text to clipboard");r.removeAllRanges(),r.addRange(o),document.execCommand("copy"),document.body.removeChild(e)}function f2e(t,e,r){let o;return(...n)=>{let a=this,i=()=>{o=void 0,r!==!0&&t.apply(a,n)},s=r===!0&&o!==void 0;window.clearTimeout(o),o=window.setTimeout(i,e),s&&t.apply(a,n)}}function zs(t){return Object.prototype.toString.call(t).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}function p2e(t){return zs(t)==="boolean"}function JY(t){return zs(t)==="function"||zs(t)==="asyncfunction"}function m2e(t){return JY(t)&&/^\s*class\s+/.test(t.toString())}function h2e(t){return zs(t)==="number"}function AI(t){return zs(t)==="object"}function g2e(t){return Promise.resolve(t)===t}function _2e(t){return zs(t)==="string"}function x2e(t){return zs(t)==="undefined"}function UD(t,...e){if(!e.length)return t;let r=e.shift();if(AI(t)&&AI(r))for(let o in r)AI(r[o])?(t[o]===void 0&&Object.assign(t,{[o]:{}}),UD(t[o],r[o])):Object.assign(t,{[o]:r[o]});return UD(t,...e)}function b2e(t,e,r){let o=`\xAB${e}\xBB is deprecated and will be removed in the next major release. Please use the \xAB${r}\xBB instead.`;t&&console.warn(o)}function v2e(t){try{return new URL(t).href}catch{}return t.substring(0,2)==="//"?window.location.protocol+t:window.location.origin+t}function y2e(t){return t>47&&t<58||t===32||t===13||t===229||t>64&&t<91||t>95&&t<112||t>185&&t<193||t>218&&t<223}var I2e={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,LEFT:37,UP:38,DOWN:40,RIGHT:39,DELETE:46,META:91,SLASH:191},w2e={LEFT:0,WHEEL:1,RIGHT:2,BACKWARD:3,FORWARD:4},E2e=class{constructor(){this.completed=Promise.resolve()}add(t){return new Promise((e,r)=>{this.completed=this.completed.then(t).then(e).catch(r)})}};function S2e(t,e,r=void 0){let o,n,a,i=null,s=0;r||(r={});let l=function(){s=r.leading===!1?0:Date.now(),i=null,a=t.apply(o,n),i===null&&(o=n=null)};return function(){let c=Date.now();!s&&r.leading===!1&&(s=c);let d=e-(c-s);return o=this,n=arguments,d<=0||d>e?(i&&(clearTimeout(i),i=null),s=c,a=t.apply(o,n),i===null&&(o=n=null)):!i&&r.trailing!==!1&&(i=setTimeout(l,d)),a}}var C2e=Object.freeze(Object.defineProperty({__proto__:null,PromiseQueue:E2e,beautifyShortcut:c2e,cacheable:i2e,capitalize:d2e,copyTextToClipboard:u2e,debounce:f2e,deepMerge:UD,deprecationAssert:b2e,getUserOS:ZY,getValidUrl:v2e,isBoolean:p2e,isClass:m2e,isEmpty:s2e,isFunction:JY,isIosDevice:l2e,isNumber:h2e,isObject:AI,isPrintableKey:y2e,isPromise:g2e,isString:_2e,isUndefined:x2e,keyCodes:I2e,mouseButtons:w2e,notEmpty:wA,throttle:S2e,typeOf:zs},Symbol.toStringTag,{value:"Module"})),EA=jRe(C2e);Object.defineProperty(IA,"__esModule",{value:!0});IA.containsOnlyInlineElements=P2e;var k2e=EA,T2e=gA;function P2e(t){var e;(0,k2e.isString)(t)?(e=document.createElement("div"),e.innerHTML=t):e=t;var r=function(o){return!(0,T2e.blockElements)().includes(o.tagName.toLowerCase())&&Array.from(o.children).every(r)};return Array.from(e.children).every(r)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.containsOnlyInlineElements=void 0;var e=IA;Object.defineProperty(t,"containsOnlyInlineElements",{enumerable:!0,get:function(){return e.containsOnlyInlineElements}})})(JI);var eX={},SA={},ew={},CA={};Object.defineProperty(CA,"__esModule",{value:!0});CA.make=O2e;function O2e(t,e,r){var o;e===void 0&&(e=null),r===void 0&&(r={});var n=document.createElement(t);if(Array.isArray(e)){var a=e.filter(function(s){return s!==void 0});(o=n.classList).add.apply(o,a)}else e!==null&&n.classList.add(e);for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i]);return n}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.make=void 0;var e=CA;Object.defineProperty(t,"make",{enumerable:!0,get:function(){return e.make}})})(ew);Object.defineProperty(SA,"__esModule",{value:!0});SA.fragmentToString=A2e;var D2e=ew;function A2e(t){var e=(0,D2e.make)("div");return e.appendChild(t),e.innerHTML}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.fragmentToString=void 0;var e=SA;Object.defineProperty(t,"fragmentToString",{enumerable:!0,get:function(){return e.fragmentToString}})})(eX);var tX={},kA={};Object.defineProperty(kA,"__esModule",{value:!0});kA.getContentLength=R2e;var N2e=Rc;function R2e(t){var e,r;return(0,N2e.isNativeInput)(t)?t.value.length:t.nodeType===Node.TEXT_NODE?t.length:(r=(e=t.textContent)===null||e===void 0?void 0:e.length)!==null&&r!==void 0?r:0}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getContentLength=void 0;var e=kA;Object.defineProperty(t,"getContentLength",{enumerable:!0,get:function(){return e.getContentLength}})})(tX);var TA={},PA={},hY=Nh&&Nh.__spreadArray||function(t,e,r){if(r||arguments.length===2)for(var o=0,n=e.length,a;o<n;o++)(a||!(o in e))&&(a||(a=Array.prototype.slice.call(e,0,o)),a[o]=e[o]);return t.concat(a||Array.prototype.slice.call(e))};Object.defineProperty(PA,"__esModule",{value:!0});PA.getDeepestBlockElements=rX;var M2e=JI;function rX(t){return(0,M2e.containsOnlyInlineElements)(t)?[t]:Array.from(t.children).reduce(function(e,r){return hY(hY([],e,!0),rX(r),!0)},[])}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getDeepestBlockElements=void 0;var e=PA;Object.defineProperty(t,"getDeepestBlockElements",{enumerable:!0,get:function(){return e.getDeepestBlockElements}})})(TA);var oX={},OA={},tw={},DA={};Object.defineProperty(DA,"__esModule",{value:!0});DA.isLineBreakTag=L2e;function L2e(t){return["BR","WBR"].includes(t.tagName)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isLineBreakTag=void 0;var e=DA;Object.defineProperty(t,"isLineBreakTag",{enumerable:!0,get:function(){return e.isLineBreakTag}})})(tw);var rw={},AA={};Object.defineProperty(AA,"__esModule",{value:!0});AA.isSingleTag=B2e;function B2e(t){return["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"].includes(t.tagName)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isSingleTag=void 0;var e=AA;Object.defineProperty(t,"isSingleTag",{enumerable:!0,get:function(){return e.isSingleTag}})})(rw);Object.defineProperty(OA,"__esModule",{value:!0});OA.getDeepestNode=nX;var F2e=Rc,z2e=tw,U2e=rw;function nX(t,e){e===void 0&&(e=!1);var r=e?"lastChild":"firstChild",o=e?"previousSibling":"nextSibling";if(t.nodeType===Node.ELEMENT_NODE&&t[r]){var n=t[r];if((0,U2e.isSingleTag)(n)&&!(0,F2e.isNativeInput)(n)&&!(0,z2e.isLineBreakTag)(n))if(n[o])n=n[o];else if(n.parentNode!==null&&n.parentNode[o])n=n.parentNode[o];else return n.parentNode;return nX(n,e)}return t}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getDeepestNode=void 0;var e=OA;Object.defineProperty(t,"getDeepestNode",{enumerable:!0,get:function(){return e.getDeepestNode}})})(oX);var aX={},NA={},CI=Nh&&Nh.__spreadArray||function(t,e,r){if(r||arguments.length===2)for(var o=0,n=e.length,a;o<n;o++)(a||!(o in e))&&(a||(a=Array.prototype.slice.call(e,0,o)),a[o]=e[o]);return t.concat(a||Array.prototype.slice.call(e))};Object.defineProperty(NA,"__esModule",{value:!0});NA.findAllInputs=q2e;var V2e=JI,$2e=TA,H2e=fA,j2e=Rc;function q2e(t){return Array.from(t.querySelectorAll((0,H2e.allInputsSelector)())).reduce(function(e,r){return(0,j2e.isNativeInput)(r)||(0,V2e.containsOnlyInlineElements)(r)?CI(CI([],e,!0),[r],!1):CI(CI([],e,!0),(0,$2e.getDeepestBlockElements)(r),!0)},[])}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.findAllInputs=void 0;var e=NA;Object.defineProperty(t,"findAllInputs",{enumerable:!0,get:function(){return e.findAllInputs}})})(aX);var iX={},RA={};Object.defineProperty(RA,"__esModule",{value:!0});RA.isCollapsedWhitespaces=G2e;function G2e(t){return!/[^\t\n\r ]/.test(t)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isCollapsedWhitespaces=void 0;var e=RA;Object.defineProperty(t,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return e.isCollapsedWhitespaces}})})(iX);var MA={},LA={};Object.defineProperty(LA,"__esModule",{value:!0});LA.isElement=K2e;var W2e=EA;function K2e(t){return(0,W2e.isNumber)(t)?!1:!!t&&!!t.nodeType&&t.nodeType===Node.ELEMENT_NODE}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isElement=void 0;var e=LA;Object.defineProperty(t,"isElement",{enumerable:!0,get:function(){return e.isElement}})})(MA);var sX={},BA={},FA={},zA={};Object.defineProperty(zA,"__esModule",{value:!0});zA.isLeaf=Y2e;function Y2e(t){return t===null?!1:t.childNodes.length===0}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isLeaf=void 0;var e=zA;Object.defineProperty(t,"isLeaf",{enumerable:!0,get:function(){return e.isLeaf}})})(FA);var UA={},VA={};Object.defineProperty(VA,"__esModule",{value:!0});VA.isNodeEmpty=eLe;var X2e=tw,Q2e=MA,Z2e=Rc,J2e=rw;function eLe(t,e){var r="";return(0,J2e.isSingleTag)(t)&&!(0,X2e.isLineBreakTag)(t)?!1:((0,Q2e.isElement)(t)&&(0,Z2e.isNativeInput)(t)?r=t.value:t.textContent!==null&&(r=t.textContent.replace("\u200B","")),e!==void 0&&(r=r.replace(new RegExp(e,"g"),"")),r.trim().length===0)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isNodeEmpty=void 0;var e=VA;Object.defineProperty(t,"isNodeEmpty",{enumerable:!0,get:function(){return e.isNodeEmpty}})})(UA);Object.defineProperty(BA,"__esModule",{value:!0});BA.isEmpty=oLe;var tLe=FA,rLe=UA;function oLe(t,e){t.normalize();for(var r=[t];r.length>0;){var o=r.shift();if(o){if(t=o,(0,tLe.isLeaf)(t)&&!(0,rLe.isNodeEmpty)(t,e))return!1;r.push.apply(r,Array.from(t.childNodes))}}return!0}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isEmpty=void 0;var e=BA;Object.defineProperty(t,"isEmpty",{enumerable:!0,get:function(){return e.isEmpty}})})(sX);var lX={},$A={};Object.defineProperty($A,"__esModule",{value:!0});$A.isFragment=aLe;var nLe=EA;function aLe(t){return(0,nLe.isNumber)(t)?!1:!!t&&!!t.nodeType&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isFragment=void 0;var e=$A;Object.defineProperty(t,"isFragment",{enumerable:!0,get:function(){return e.isFragment}})})(lX);var cX={},HA={};Object.defineProperty(HA,"__esModule",{value:!0});HA.isHTMLString=sLe;var iLe=ew;function sLe(t){var e=(0,iLe.make)("div");return e.innerHTML=t,e.childElementCount>0}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isHTMLString=void 0;var e=HA;Object.defineProperty(t,"isHTMLString",{enumerable:!0,get:function(){return e.isHTMLString}})})(cX);var dX={},jA={};Object.defineProperty(jA,"__esModule",{value:!0});jA.offset=lLe;function lLe(t){var e=t.getBoundingClientRect(),r=window.pageXOffset||document.documentElement.scrollLeft,o=window.pageYOffset||document.documentElement.scrollTop,n=e.top+o,a=e.left+r;return{top:n,left:a,bottom:n+e.height,right:a+e.width}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.offset=void 0;var e=jA;Object.defineProperty(t,"offset",{enumerable:!0,get:function(){return e.offset}})})(dX);var uX={},qA={};Object.defineProperty(qA,"__esModule",{value:!0});qA.prepend=cLe;function cLe(t,e){Array.isArray(e)?(e=e.reverse(),e.forEach(function(r){return t.prepend(r)})):t.prepend(e)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.prepend=void 0;var e=qA;Object.defineProperty(t,"prepend",{enumerable:!0,get:function(){return e.prepend}})})(uX);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.prepend=t.offset=t.make=t.isLineBreakTag=t.isSingleTag=t.isNodeEmpty=t.isLeaf=t.isHTMLString=t.isFragment=t.isEmpty=t.isElement=t.isContentEditable=t.isCollapsedWhitespaces=t.findAllInputs=t.isNativeInput=t.allInputsSelector=t.getDeepestNode=t.getDeepestBlockElements=t.getContentLength=t.fragmentToString=t.containsOnlyInlineElements=t.canSetCaret=t.calculateBaseline=t.blockElements=t.append=void 0;var e=fA;Object.defineProperty(t,"allInputsSelector",{enumerable:!0,get:function(){return e.allInputsSelector}});var r=Rc;Object.defineProperty(t,"isNativeInput",{enumerable:!0,get:function(){return r.isNativeInput}});var o=YY;Object.defineProperty(t,"append",{enumerable:!0,get:function(){return o.append}});var n=gA;Object.defineProperty(t,"blockElements",{enumerable:!0,get:function(){return n.blockElements}});var a=XY;Object.defineProperty(t,"calculateBaseline",{enumerable:!0,get:function(){return a.calculateBaseline}});var i=QY;Object.defineProperty(t,"canSetCaret",{enumerable:!0,get:function(){return i.canSetCaret}});var s=JI;Object.defineProperty(t,"containsOnlyInlineElements",{enumerable:!0,get:function(){return s.containsOnlyInlineElements}});var l=eX;Object.defineProperty(t,"fragmentToString",{enumerable:!0,get:function(){return l.fragmentToString}});var c=tX;Object.defineProperty(t,"getContentLength",{enumerable:!0,get:function(){return c.getContentLength}});var d=TA;Object.defineProperty(t,"getDeepestBlockElements",{enumerable:!0,get:function(){return d.getDeepestBlockElements}});var u=oX;Object.defineProperty(t,"getDeepestNode",{enumerable:!0,get:function(){return u.getDeepestNode}});var p=aX;Object.defineProperty(t,"findAllInputs",{enumerable:!0,get:function(){return p.findAllInputs}});var m=iX;Object.defineProperty(t,"isCollapsedWhitespaces",{enumerable:!0,get:function(){return m.isCollapsedWhitespaces}});var h=vA;Object.defineProperty(t,"isContentEditable",{enumerable:!0,get:function(){return h.isContentEditable}});var g=MA;Object.defineProperty(t,"isElement",{enumerable:!0,get:function(){return g.isElement}});var _=sX;Object.defineProperty(t,"isEmpty",{enumerable:!0,get:function(){return _.isEmpty}});var x=lX;Object.defineProperty(t,"isFragment",{enumerable:!0,get:function(){return x.isFragment}});var b=cX;Object.defineProperty(t,"isHTMLString",{enumerable:!0,get:function(){return b.isHTMLString}});var v=FA;Object.defineProperty(t,"isLeaf",{enumerable:!0,get:function(){return v.isLeaf}});var I=UA;Object.defineProperty(t,"isNodeEmpty",{enumerable:!0,get:function(){return I.isNodeEmpty}});var E=tw;Object.defineProperty(t,"isLineBreakTag",{enumerable:!0,get:function(){return E.isLineBreakTag}});var y=rw;Object.defineProperty(t,"isSingleTag",{enumerable:!0,get:function(){return y.isSingleTag}});var C=ew;Object.defineProperty(t,"make",{enumerable:!0,get:function(){return C.make}});var T=dX;Object.defineProperty(t,"offset",{enumerable:!0,get:function(){return T.offset}});var k=uX;Object.defineProperty(t,"prepend",{enumerable:!0,get:function(){return k.prepend}})})(Nc);var ow={};Object.defineProperty(ow,"__esModule",{value:!0});ow.getContenteditableSlice=uLe;var dLe=Nc;function uLe(t,e,r,o,n){var a;n===void 0&&(n=!1);var i=document.createRange();if(o==="left"?(i.setStart(t,0),i.setEnd(e,r)):(i.setStart(e,r),i.setEnd(t,t.childNodes.length)),n===!0){var s=i.extractContents();return(0,dLe.fragmentToString)(s)}var l=i.cloneContents(),c=document.createElement("div");c.appendChild(l);var d=(a=c.textContent)!==null&&a!==void 0?a:"";return d}Object.defineProperty(ZI,"__esModule",{value:!0});ZI.checkContenteditableSliceForEmptiness=mLe;var fLe=Nc,pLe=ow;function mLe(t,e,r,o){var n=(0,pLe.getContenteditableSlice)(t,e,r,o);return(0,fLe.isCollapsedWhitespaces)(n)}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.checkContenteditableSliceForEmptiness=void 0;var e=ZI;Object.defineProperty(t,"checkContenteditableSliceForEmptiness",{enumerable:!0,get:function(){return e.checkContenteditableSliceForEmptiness}})})(uA);var fX={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getContenteditableSlice=void 0;var e=ow;Object.defineProperty(t,"getContenteditableSlice",{enumerable:!0,get:function(){return e.getContenteditableSlice}})})(fX);var pX={},GA={};Object.defineProperty(GA,"__esModule",{value:!0});GA.focus=gLe;var hLe=Nc;function gLe(t,e){var r,o;if(e===void 0&&(e=!0),(0,hLe.isNativeInput)(t)){t.focus();var n=e?0:t.value.length;t.setSelectionRange(n,n)}else{var a=document.createRange(),i=window.getSelection();if(!i)return;var s=function(p){var m=document.createTextNode("");p.appendChild(m),a.setStart(m,0),a.setEnd(m,0)},l=function(p){return p!=null},c=t.childNodes,d=e?c[0]:c[c.length-1];if(l(d)){for(;l(d)&&d.nodeType!==Node.TEXT_NODE;)d=e?d.firstChild:d.lastChild;if(l(d)&&d.nodeType===Node.TEXT_NODE){var u=(o=(r=d.textContent)===null||r===void 0?void 0:r.length)!==null&&o!==void 0?o:0,n=e?0:u;a.setStart(d,n),a.setEnd(d,n)}else s(t)}else s(t);i.removeAllRanges(),i.addRange(a)}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.focus=void 0;var e=GA;Object.defineProperty(t,"focus",{enumerable:!0,get:function(){return e.focus}})})(pX);var WA={},nw={};Object.defineProperty(nw,"__esModule",{value:!0});nw.getCaretNodeAndOffset=_Le;function _Le(){var t=window.getSelection();if(t===null)return[null,0];var e=t.focusNode,r=t.focusOffset;return e===null?[null,0]:(e.nodeType!==Node.TEXT_NODE&&e.childNodes.length>0&&(e.childNodes[r]!==void 0?(e=e.childNodes[r],r=0):(e=e.childNodes[r-1],e.textContent!==null&&(r=e.textContent.length))),[e,r])}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getCaretNodeAndOffset=void 0;var e=nw;Object.defineProperty(t,"getCaretNodeAndOffset",{enumerable:!0,get:function(){return e.getCaretNodeAndOffset}})})(WA);var mX={},aw={};Object.defineProperty(aw,"__esModule",{value:!0});aw.getRange=xLe;function xLe(){var t=window.getSelection();return t&&t.rangeCount?t.getRangeAt(0):null}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getRange=void 0;var e=aw;Object.defineProperty(t,"getRange",{enumerable:!0,get:function(){return e.getRange}})})(mX);var hX={},KA={};Object.defineProperty(KA,"__esModule",{value:!0});KA.isCaretAtEndOfInput=yLe;var gY=Nc,bLe=WA,vLe=uA;function yLe(t){var e=(0,gY.getDeepestNode)(t,!0);if(e===null)return!0;if((0,gY.isNativeInput)(e))return e.selectionEnd===e.value.length;var r=(0,bLe.getCaretNodeAndOffset)(),o=r[0],n=r[1];return o===null?!1:(0,vLe.checkContenteditableSliceForEmptiness)(t,o,n,"right")}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isCaretAtEndOfInput=void 0;var e=KA;Object.defineProperty(t,"isCaretAtEndOfInput",{enumerable:!0,get:function(){return e.isCaretAtEndOfInput}})})(hX);var gX={},YA={};Object.defineProperty(YA,"__esModule",{value:!0});YA.isCaretAtStartOfInput=ELe;var kI=Nc,ILe=nw,wLe=ZI;function ELe(t){var e=(0,kI.getDeepestNode)(t);if(e===null||(0,kI.isEmpty)(t))return!0;if((0,kI.isNativeInput)(e))return e.selectionEnd===0;if((0,kI.isEmpty)(t))return!0;var r=(0,ILe.getCaretNodeAndOffset)(),o=r[0],n=r[1];return o===null?!1:(0,wLe.checkContenteditableSliceForEmptiness)(t,o,n,"left")}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.isCaretAtStartOfInput=void 0;var e=YA;Object.defineProperty(t,"isCaretAtStartOfInput",{enumerable:!0,get:function(){return e.isCaretAtStartOfInput}})})(gX);var _X={},XA={};Object.defineProperty(XA,"__esModule",{value:!0});XA.save=kLe;var SLe=Nc,CLe=aw;function kLe(){var t=(0,CLe.getRange)(),e=(0,SLe.make)("span");if(e.id="cursor",e.hidden=!0,!!t)return t.insertNode(e),function(){var r=window.getSelection();r&&(t.setStartAfter(e),t.setEndAfter(e),r.removeAllRanges(),r.addRange(t),setTimeout(function(){e.remove()},150))}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.save=void 0;var e=XA;Object.defineProperty(t,"save",{enumerable:!0,get:function(){return e.save}})})(_X);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.save=t.isCaretAtStartOfInput=t.isCaretAtEndOfInput=t.getRange=t.getCaretNodeAndOffset=t.focus=t.getContenteditableSlice=t.checkContenteditableSliceForEmptiness=void 0;var e=uA;Object.defineProperty(t,"checkContenteditableSliceForEmptiness",{enumerable:!0,get:function(){return e.checkContenteditableSliceForEmptiness}});var r=fX;Object.defineProperty(t,"getContenteditableSlice",{enumerable:!0,get:function(){return r.getContenteditableSlice}});var o=pX;Object.defineProperty(t,"focus",{enumerable:!0,get:function(){return o.focus}});var n=WA;Object.defineProperty(t,"getCaretNodeAndOffset",{enumerable:!0,get:function(){return n.getCaretNodeAndOffset}});var a=mX;Object.defineProperty(t,"getRange",{enumerable:!0,get:function(){return a.getRange}});var i=hX;Object.defineProperty(t,"isCaretAtEndOfInput",{enumerable:!0,get:function(){return i.isCaretAtEndOfInput}});var s=gX;Object.defineProperty(t,"isCaretAtStartOfInput",{enumerable:!0,get:function(){return s.isCaretAtStartOfInput}});var l=_X;Object.defineProperty(t,"save",{enumerable:!0,get:function(){return l.save}})})(KY);var VD=class extends ft{keydown(e){switch(this.beforeKeydownProcessing(e),e.keyCode){case Ye.BACKSPACE:this.backspace(e);break;case Ye.DELETE:this.delete(e);break;case Ye.ENTER:this.enter(e);break;case Ye.DOWN:case Ye.RIGHT:this.arrowRightAndDown(e);break;case Ye.UP:case Ye.LEFT:this.arrowLeftAndUp(e);break;case Ye.TAB:this.tabPressed(e);break}e.key==="/"&&!e.ctrlKey&&!e.metaKey&&this.slashPressed(e),e.code==="Slash"&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.commandSlashPressed())}beforeKeydownProcessing(e){this.needToolbarClosing(e)&&yY(e.keyCode)&&(this.Editor.Toolbar.close(),e.ctrlKey||e.metaKey||e.altKey||e.shiftKey||this.Editor.BlockSelection.clearSelection(e))}keyup(e){e.shiftKey||this.Editor.UI.checkEmptiness()}dragOver(e){let r=this.Editor.BlockManager.getBlockByChildNode(e.target);r.dropTarget=!0}dragLeave(e){let r=this.Editor.BlockManager.getBlockByChildNode(e.target);r.dropTarget=!1}handleCommandC(e){let{BlockSelection:r}=this.Editor;r.anyBlockSelected&&r.copySelectedBlocks(e)}handleCommandX(e){let{BlockSelection:r,BlockManager:o,Caret:n}=this.Editor;r.anyBlockSelected&&r.copySelectedBlocks(e).then(()=>{let a=o.removeSelectedBlocks(),i=o.insertDefaultBlockAtIndex(a,!0);n.setToBlock(i,n.positions.START),r.clearSelection(e)})}tabPressed(e){let{InlineToolbar:r,Caret:o}=this.Editor;r.opened||(e.shiftKey?o.navigatePrevious(!0):o.navigateNext(!0))&&e.preventDefault()}commandSlashPressed(){this.Editor.BlockSelection.selectedBlocks.length>1||this.activateBlockSettings()}slashPressed(e){this.Editor.BlockManager.currentBlock.isEmpty&&(e.preventDefault(),this.Editor.Caret.insertContentAtCaretPosition("/"),this.activateToolbox())}enter(e){let{BlockManager:r,UI:o}=this.Editor,n=r.currentBlock;if(n===void 0||n.tool.isLineBreaksEnabled||o.someToolbarOpened&&o.someFlipperButtonFocused||e.shiftKey&&!cD)return;let a=n;n.currentInput!==void 0&&OI(n.currentInput)&&!n.hasMedia?this.Editor.BlockManager.insertDefaultBlockAtIndex(this.Editor.BlockManager.currentBlockIndex):n.currentInput&&DI(n.currentInput)?a=this.Editor.BlockManager.insertDefaultBlockAtIndex(this.Editor.BlockManager.currentBlockIndex+1):a=this.Editor.BlockManager.split(),this.Editor.Caret.setToBlock(a),this.Editor.Toolbar.moveAndOpen(a),e.preventDefault()}backspace(e){let{BlockManager:r,Caret:o}=this.Editor,{currentBlock:n,previousBlock:a}=r;if(!(n===void 0||!ze.isCollapsed||!n.currentInput||!OI(n.currentInput))){if(e.preventDefault(),this.Editor.Toolbar.close(),n.currentInput!==n.firstInput){o.navigatePrevious();return}if(a!==null){if(a.isEmpty){r.removeBlock(a);return}if(n.isEmpty){r.removeBlock(n);let i=r.currentBlock;o.setToBlock(i,o.positions.END);return}dY(a,n)?this.mergeBlocks(a,n):o.setToBlock(a,o.positions.END)}}}delete(e){let{BlockManager:r,Caret:o}=this.Editor,{currentBlock:n,nextBlock:a}=r;if(!(!ze.isCollapsed||!DI(n.currentInput))){if(e.preventDefault(),this.Editor.Toolbar.close(),n.currentInput!==n.lastInput){o.navigateNext();return}if(a!==null){if(a.isEmpty){r.removeBlock(a);return}if(n.isEmpty){r.removeBlock(n),o.setToBlock(a,o.positions.START);return}dY(n,a)?this.mergeBlocks(n,a):o.setToBlock(a,o.positions.START)}}}mergeBlocks(e,r){let{BlockManager:o,Toolbar:n}=this.Editor;e.lastInput!==void 0&&(KY.focus(e.lastInput,!1),o.mergeBlocks(e,r).then(()=>{n.close()}))}arrowRightAndDown(e){let r=Zu.usedKeys.includes(e.keyCode)&&(!e.shiftKey||e.keyCode===Ye.TAB);if(this.Editor.UI.someToolbarOpened&&r)return;this.Editor.Toolbar.close();let{currentBlock:o}=this.Editor.BlockManager,n=(o?.currentInput!==void 0?DI(o.currentInput):void 0)||this.Editor.BlockSelection.anyBlockSelected;if(e.shiftKey&&e.keyCode===Ye.DOWN&&n){this.Editor.CrossBlockSelection.toggleBlockSelectedState();return}if(e.keyCode===Ye.DOWN||e.keyCode===Ye.RIGHT&&!this.isRtl?this.Editor.Caret.navigateNext():this.Editor.Caret.navigatePrevious()){e.preventDefault();return}NI(()=>{this.Editor.BlockManager.currentBlock&&this.Editor.BlockManager.currentBlock.updateCurrentInput()},20)(),this.Editor.BlockSelection.clearSelection(e)}arrowLeftAndUp(e){if(this.Editor.UI.someToolbarOpened){if(Zu.usedKeys.includes(e.keyCode)&&(!e.shiftKey||e.keyCode===Ye.TAB))return;this.Editor.UI.closeAllToolbars()}this.Editor.Toolbar.close();let{currentBlock:r}=this.Editor.BlockManager,o=(r?.currentInput!==void 0?OI(r.currentInput):void 0)||this.Editor.BlockSelection.anyBlockSelected;if(e.shiftKey&&e.keyCode===Ye.UP&&o){this.Editor.CrossBlockSelection.toggleBlockSelectedState(!1);return}if(e.keyCode===Ye.UP||e.keyCode===Ye.LEFT&&!this.isRtl?this.Editor.Caret.navigatePrevious():this.Editor.Caret.navigateNext()){e.preventDefault();return}NI(()=>{this.Editor.BlockManager.currentBlock&&this.Editor.BlockManager.currentBlock.updateCurrentInput()},20)(),this.Editor.BlockSelection.clearSelection(e)}needToolbarClosing(e){let r=e.keyCode===Ye.ENTER&&this.Editor.Toolbar.toolbox.opened,o=e.keyCode===Ye.ENTER&&this.Editor.BlockSettings.opened,n=e.keyCode===Ye.ENTER&&this.Editor.InlineToolbar.opened,a=e.keyCode===Ye.TAB;return!(e.shiftKey||a||r||o||n)}activateToolbox(){this.Editor.Toolbar.opened||this.Editor.Toolbar.moveAndOpen(),this.Editor.Toolbar.toolbox.open()}activateBlockSettings(){this.Editor.Toolbar.opened||this.Editor.Toolbar.moveAndOpen(),this.Editor.BlockSettings.opened||this.Editor.BlockSettings.open()}},Ah=class{constructor(e){this.blocks=[],this.workingArea=e}get length(){return this.blocks.length}get array(){return this.blocks}get nodes(){return IY(this.workingArea.children)}static set(e,r,o){return isNaN(Number(r))?(Reflect.set(e,r,o),!0):(e.insert(+r,o),!0)}static get(e,r){return isNaN(Number(r))?Reflect.get(e,r):e.get(+r)}push(e){this.blocks.push(e),this.insertToDOM(e)}swap(e,r){let o=this.blocks[r];K.swap(this.blocks[e].holder,o.holder),this.blocks[r]=this.blocks[e],this.blocks[e]=o}move(e,r){let o=this.blocks.splice(r,1)[0],n=e-1,a=Math.max(0,n),i=this.blocks[a];e>0?this.insertToDOM(o,"afterend",i):this.insertToDOM(o,"beforebegin",i),this.blocks.splice(e,0,o);let s=this.composeBlockEvent("move",{fromIndex:r,toIndex:e});o.call(Bi.MOVED,s)}insert(e,r,o=!1){if(!this.length){this.push(r);return}e>this.length&&(e=this.length),o&&(this.blocks[e].holder.remove(),this.blocks[e].call(Bi.REMOVED));let n=o?1:0;if(this.blocks.splice(e,n,r),e>0){let a=this.blocks[e-1];this.insertToDOM(r,"afterend",a)}else{let a=this.blocks[e+1];a?this.insertToDOM(r,"beforebegin",a):this.insertToDOM(r)}}replace(e,r){if(this.blocks[e]===void 0)throw Error("Incorrect index");this.blocks[e].holder.replaceWith(r.holder),this.blocks[e]=r}insertMany(e,r){let o=new DocumentFragment;for(let n of e)o.appendChild(n.holder);if(this.length>0){if(r>0){let n=Math.min(r-1,this.length-1);this.blocks[n].holder.after(o)}else r===0&&this.workingArea.prepend(o);this.blocks.splice(r,0,...e)}else this.blocks.push(...e),this.workingArea.appendChild(o);e.forEach(n=>n.call(Bi.RENDERED))}remove(e){isNaN(e)&&(e=this.length-1),this.blocks[e].holder.remove(),this.blocks[e].call(Bi.REMOVED),this.blocks.splice(e,1)}removeAll(){this.workingArea.innerHTML="",this.blocks.forEach(e=>e.call(Bi.REMOVED)),this.blocks.length=0}insertAfter(e,r){let o=this.blocks.indexOf(e);this.insert(o+1,r)}get(e){return this.blocks[e]}indexOf(e){return this.blocks.indexOf(e)}insertToDOM(e,r,o){r?o.holder.insertAdjacentElement(r,e.holder):this.workingArea.appendChild(e.holder),e.call(Bi.RENDERED)}composeBlockEvent(e,r){return new CustomEvent(e,{detail:r})}},_Y="block-removed",xY="block-added",TLe="block-moved",bY="block-changed",$D=class{constructor(){this.completed=Promise.resolve()}add(e){return new Promise((r,o)=>{this.completed=this.completed.then(e).then(r).catch(o)})}},HD=class extends ft{constructor(){super(...arguments),this._currentBlockIndex=-1,this._blocks=null}get currentBlockIndex(){return this._currentBlockIndex}set currentBlockIndex(e){this._currentBlockIndex=e}get firstBlock(){return this._blocks[0]}get lastBlock(){return this._blocks[this._blocks.length-1]}get currentBlock(){return this._blocks[this.currentBlockIndex]}set currentBlock(e){this.currentBlockIndex=this.getBlockIndex(e)}get nextBlock(){return this.currentBlockIndex===this._blocks.length-1?null:this._blocks[this.currentBlockIndex+1]}get nextContentfulBlock(){return this.blocks.slice(this.currentBlockIndex+1).find(e=>!!e.inputs.length)}get previousContentfulBlock(){return this.blocks.slice(0,this.currentBlockIndex).reverse().find(e=>!!e.inputs.length)}get previousBlock(){return this.currentBlockIndex===0?null:this._blocks[this.currentBlockIndex-1]}get blocks(){return this._blocks.array}get isEditorEmpty(){return this.blocks.every(e=>e.isEmpty)}prepare(){let e=new Ah(this.Editor.UI.nodes.redactor);this._blocks=new Proxy(e,{set:Ah.set,get:Ah.get}),this.listeners.on(document,"copy",r=>this.Editor.BlockEvents.handleCommandC(r))}toggleReadOnly(e){e?this.disableModuleBindings():this.enableModuleBindings()}composeBlock({tool:e,data:r={},id:o=void 0,tunes:n={}}){let a=this.Editor.ReadOnly.isEnabled,i=this.Editor.Tools.blockTools.get(e),s=new Oa({id:o,data:r,tool:i,api:this.Editor.API,readOnly:a,tunesData:n},this.eventsDispatcher);return a||window.requestIdleCallback(()=>{this.bindBlockEvents(s)},{timeout:2e3}),s}insert({id:e=void 0,tool:r=this.config.defaultBlock,data:o={},index:n,needToFocus:a=!0,replace:i=!1,tunes:s={}}={}){let l=n;l===void 0&&(l=this.currentBlockIndex+(i?0:1));let c=this.composeBlock({id:e,tool:r,data:o,tunes:s});return i&&this.blockDidMutated(_Y,this.getBlockByIndex(l),{index:l}),this._blocks.insert(l,c,i),this.blockDidMutated(xY,c,{index:l}),a?this.currentBlockIndex=l:l<=this.currentBlockIndex&&this.currentBlockIndex++,c}insertMany(e,r=0){this._blocks.insertMany(e,r)}async update(e,r,o){if(!r&&!o)return e;let n=await e.data,a=this.composeBlock({id:e.id,tool:e.name,data:Object.assign({},n,r??{}),tunes:o??e.tunes}),i=this.getBlockIndex(e);return this._blocks.replace(i,a),this.blockDidMutated(bY,a,{index:i}),a}replace(e,r,o){let n=this.getBlockIndex(e);return this.insert({tool:r,data:o,index:n,replace:!0})}paste(e,r,o=!1){let n=this.insert({tool:e,replace:o});try{window.requestIdleCallback(()=>{n.call(Bi.ON_PASTE,r)})}catch(a){At(`${e}: onPaste callback call is failed`,"error",a)}return n}insertDefaultBlockAtIndex(e,r=!1){let o=this.composeBlock({tool:this.config.defaultBlock});return this._blocks[e]=o,this.blockDidMutated(xY,o,{index:e}),r?this.currentBlockIndex=e:e<=this.currentBlockIndex&&this.currentBlockIndex++,o}insertAtEnd(){return this.currentBlockIndex=this.blocks.length-1,this.insert()}async mergeBlocks(e,r){let o;if(e.name===r.name&&e.mergeable){let n=await r.data;if(ua(n)){console.error("Could not merge Block. Failed to extract original Block data.");return}let[a]=iA([n],e.tool.sanitizeConfig);o=a}else if(e.mergeable&&LI(r,"export")&&LI(e,"import")){let n=await r.exportDataAsString(),a=ri(n,e.tool.sanitizeConfig);o=uY(a,e.tool.conversionConfig)}o!==void 0&&(await e.mergeWith(o),this.removeBlock(r),this.currentBlockIndex=this._blocks.indexOf(e))}removeBlock(e,r=!0){return new Promise(o=>{let n=this._blocks.indexOf(e);if(!this.validateIndex(n))throw new Error("Can't find a Block to remove");e.destroy(),this._blocks.remove(n),this.blockDidMutated(_Y,e,{index:n}),this.currentBlockIndex>=n&&this.currentBlockIndex--,this.blocks.length?n===0&&(this.currentBlockIndex=0):(this.unsetCurrentBlock(),r&&this.insert()),o()})}removeSelectedBlocks(){let e;for(let r=this.blocks.length-1;r>=0;r--)this.blocks[r].selected&&(this.removeBlock(this.blocks[r]),e=r);return e}removeAllBlocks(){for(let e=this.blocks.length-1;e>=0;e--)this._blocks.remove(e);this.unsetCurrentBlock(),this.insert(),this.currentBlock.firstInput.focus()}split(){let e=this.Editor.Caret.extractFragmentFromCaretPosition(),r=K.make("div");r.appendChild(e);let o={text:K.isEmpty(r)?"":r.innerHTML};return this.insert({data:o})}getBlockByIndex(e){return e===-1&&(e=this._blocks.length-1),this._blocks[e]}getBlockIndex(e){return this._blocks.indexOf(e)}getBlockById(e){return this._blocks.array.find(r=>r.id===e)}getBlock(e){K.isElement(e)||(e=e.parentNode);let r=this._blocks.nodes,o=e.closest(`.${Oa.CSS.wrapper}`),n=r.indexOf(o);if(n>=0)return this._blocks[n]}setCurrentBlockByChildNode(e){K.isElement(e)||(e=e.parentNode);let r=e.closest(`.${Oa.CSS.wrapper}`);if(!r)return;let o=r.closest(`.${this.Editor.UI.CSS.editorWrapper}`);if(o!=null&&o.isEqualNode(this.Editor.UI.nodes.wrapper))return this.currentBlockIndex=this._blocks.nodes.indexOf(r),this.currentBlock.updateCurrentInput(),this.currentBlock}getBlockByChildNode(e){if(!e||!(e instanceof Node))return;K.isElement(e)||(e=e.parentNode);let r=e.closest(`.${Oa.CSS.wrapper}`);return this.blocks.find(o=>o.holder===r)}swap(e,r){this._blocks.swap(e,r),this.currentBlockIndex=r}move(e,r=this.currentBlockIndex){if(isNaN(e)||isNaN(r)){At("Warning during 'move' call: incorrect indices provided.","warn");return}if(!this.validateIndex(e)||!this.validateIndex(r)){At("Warning during 'move' call: indices cannot be lower than 0 or greater than the amount of blocks.","warn");return}this._blocks.move(e,r),this.currentBlockIndex=e,this.blockDidMutated(TLe,this.currentBlock,{fromIndex:r,toIndex:e})}async convert(e,r,o){if(!await e.save())throw new Error("Could not convert Block. Failed to extract original Block data.");let n=this.Editor.Tools.blockTools.get(r);if(!n)throw new Error(`Could not convert Block. Tool \xAB${r}\xBB not found.`);let a=await e.exportDataAsString(),i=ri(a,n.sanitizeConfig),s=uY(i,n.conversionConfig,n.settings);return o&&(s=Object.assign(s,o)),this.replace(e,n.name,s)}unsetCurrentBlock(){this.currentBlockIndex=-1}async clear(e=!1){let r=new $D;this.blocks.forEach(o=>{r.add(async()=>{await this.removeBlock(o,!1)})}),await r.completed,this.unsetCurrentBlock(),e&&this.insert(),this.Editor.UI.checkEmptiness()}async destroy(){await Promise.all(this.blocks.map(e=>e.destroy()))}bindBlockEvents(e){let{BlockEvents:r}=this.Editor;this.readOnlyMutableListeners.on(e.holder,"keydown",o=>{r.keydown(o)}),this.readOnlyMutableListeners.on(e.holder,"keyup",o=>{r.keyup(o)}),this.readOnlyMutableListeners.on(e.holder,"dragover",o=>{r.dragOver(o)}),this.readOnlyMutableListeners.on(e.holder,"dragleave",o=>{r.dragLeave(o)}),e.on("didMutated",o=>this.blockDidMutated(bY,o,{index:this.getBlockIndex(o)}))}disableModuleBindings(){this.readOnlyMutableListeners.clearAll()}enableModuleBindings(){this.readOnlyMutableListeners.on(document,"cut",e=>this.Editor.BlockEvents.handleCommandX(e)),this.blocks.forEach(e=>{this.bindBlockEvents(e)})}validateIndex(e){return!(e<0||e>=this._blocks.length)}blockDidMutated(e,r,o){let n=new CustomEvent(e,{detail:{target:new Li(r),...o}});return this.eventsDispatcher.emit(kY,{event:n}),r}},jD=class extends ft{constructor(){super(...arguments),this.anyBlockSelectedCache=null,this.needToSelectAll=!1,this.nativeInputSelected=!1,this.readyToBlockSelection=!1}get sanitizerConfig(){return{p:{},h1:{},h2:{},h3:{},h4:{},h5:{},h6:{},ol:{},ul:{},li:{},br:!0,img:{src:!0,width:!0,height:!0},a:{href:!0},b:{},i:{},u:{}}}get allBlocksSelected(){let{BlockManager:e}=this.Editor;return e.blocks.every(r=>r.selected===!0)}set allBlocksSelected(e){let{BlockManager:r}=this.Editor;r.blocks.forEach(o=>{o.selected=e}),this.clearCache()}get anyBlockSelected(){let{BlockManager:e}=this.Editor;return this.anyBlockSelectedCache===null&&(this.anyBlockSelectedCache=e.blocks.some(r=>r.selected===!0)),this.anyBlockSelectedCache}get selectedBlocks(){return this.Editor.BlockManager.blocks.filter(e=>e.selected)}prepare(){this.selection=new ze,Ju.add({name:"CMD+A",handler:e=>{let{BlockManager:r,ReadOnly:o}=this.Editor;if(o.isEnabled){e.preventDefault(),this.selectAllBlocks();return}r.currentBlock&&this.handleCommandA(e)},on:this.Editor.UI.nodes.redactor})}toggleReadOnly(){ze.get().removeAllRanges(),this.allBlocksSelected=!1}unSelectBlockByIndex(e){let{BlockManager:r}=this.Editor,o;isNaN(e)?o=r.currentBlock:o=r.getBlockByIndex(e),o.selected=!1,this.clearCache()}clearSelection(e,r=!1){let{BlockManager:o,Caret:n,RectangleSelection:a}=this.Editor;this.needToSelectAll=!1,this.nativeInputSelected=!1,this.readyToBlockSelection=!1;let i=e&&e instanceof KeyboardEvent,s=i&&yY(e.keyCode);if(this.anyBlockSelected&&i&&s&&!ze.isSelectionExists){let l=o.removeSelectedBlocks();o.insertDefaultBlockAtIndex(l,!0),n.setToBlock(o.currentBlock),NI(()=>{let c=e.key;n.insertContentAtCaretPosition(c.length>1?"":c)},20)()}if(this.Editor.CrossBlockSelection.clear(e),!this.anyBlockSelected||a.isRectActivated()){this.Editor.RectangleSelection.clearSelection();return}r&&this.selection.restore(),this.allBlocksSelected=!1}copySelectedBlocks(e){e.preventDefault();let r=K.make("div");this.selectedBlocks.forEach(a=>{let i=ri(a.holder.innerHTML,this.sanitizerConfig),s=K.make("p");s.innerHTML=i,r.appendChild(s)});let o=Array.from(r.childNodes).map(a=>a.textContent).join(`
|
|
225
225
|
|
|
226
226
|
`),n=r.innerHTML;return e.clipboardData.setData("text/plain",o),e.clipboardData.setData("text/html",n),Promise.all(this.selectedBlocks.map(a=>a.save())).then(a=>{try{e.clipboardData.setData(this.Editor.Paste.MIME_TYPE,JSON.stringify(a))}catch{}})}selectBlockByIndex(e){let{BlockManager:r}=this.Editor,o=r.getBlockByIndex(e);o!==void 0&&this.selectBlock(o)}selectBlock(e){this.selection.save(),ze.get().removeAllRanges(),e.selected=!0,this.clearCache(),this.Editor.InlineToolbar.close()}unselectBlock(e){e.selected=!1,this.clearCache()}clearCache(){this.anyBlockSelectedCache=null}destroy(){Ju.remove(this.Editor.UI.nodes.redactor,"CMD+A")}handleCommandA(e){if(this.Editor.RectangleSelection.clearSelection(),K.isNativeInput(e.target)&&!this.readyToBlockSelection){this.readyToBlockSelection=!0;return}let r=this.Editor.BlockManager.getBlock(e.target),o=r.inputs;if(o.length>1&&!this.readyToBlockSelection){this.readyToBlockSelection=!0;return}if(o.length===1&&!this.needToSelectAll){this.needToSelectAll=!0;return}this.needToSelectAll?(e.preventDefault(),this.selectAllBlocks(),this.needToSelectAll=!1,this.readyToBlockSelection=!1):this.readyToBlockSelection&&(e.preventDefault(),this.selectBlock(r),this.needToSelectAll=!0)}selectAllBlocks(){this.selection.save(),ze.get().removeAllRanges(),this.allBlocksSelected=!0,this.Editor.InlineToolbar.close()}},qD=class t extends ft{get positions(){return{START:"start",END:"end",DEFAULT:"default"}}static get CSS(){return{shadowCaret:"cdx-shadow-caret"}}setToBlock(e,r=this.positions.DEFAULT,o=0){var n;let{BlockManager:a,BlockSelection:i}=this.Editor;if(i.clearSelection(),!e.focusable){(n=window.getSelection())==null||n.removeAllRanges(),i.selectBlock(e),a.currentBlock=e;return}let s;switch(r){case this.positions.START:s=e.firstInput;break;case this.positions.END:s=e.lastInput;break;default:s=e.currentInput}if(!s)return;let l=K.getDeepestNode(s,r===this.positions.END),c=K.getContentLength(l);switch(!0){case r===this.positions.START:o=0;break;case r===this.positions.END:case o>c:o=c;break}this.set(l,o),a.setCurrentBlockByChildNode(e.holder),a.currentBlock.currentInput=s}setToInput(e,r=this.positions.DEFAULT,o=0){let{currentBlock:n}=this.Editor.BlockManager,a=K.getDeepestNode(e);switch(r){case this.positions.START:this.set(a,0);break;case this.positions.END:this.set(a,K.getContentLength(a));break;default:o&&this.set(a,o)}n.currentInput=e}set(e,r=0){let{top:o,bottom:n}=ze.setCursor(e,r),{innerHeight:a}=window;o<0?window.scrollBy(0,o-30):n>a&&window.scrollBy(0,n-a+30)}setToTheLastBlock(){let e=this.Editor.BlockManager.lastBlock;if(e)if(e.tool.isDefault&&e.isEmpty)this.setToBlock(e);else{let r=this.Editor.BlockManager.insertAtEnd();this.setToBlock(r)}}extractFragmentFromCaretPosition(){let e=ze.get();if(e.rangeCount){let r=e.getRangeAt(0),o=this.Editor.BlockManager.currentBlock.currentInput;if(r.deleteContents(),o)if(K.isNativeInput(o)){let n=o,a=document.createDocumentFragment(),i=n.value.substring(0,n.selectionStart),s=n.value.substring(n.selectionStart);return a.textContent=s,n.value=i,a}else{let n=r.cloneRange();return n.selectNodeContents(o),n.setStart(r.endContainer,r.endOffset),n.extractContents()}}}navigateNext(e=!1){let{BlockManager:r}=this.Editor,{currentBlock:o,nextBlock:n}=r;if(o===void 0)return!1;let{nextInput:a,currentInput:i}=o,s=i!==void 0?DI(i):void 0,l=n,c=e||s||!o.focusable;if(a&&c)return this.setToInput(a,this.positions.START),!0;if(l===null){if(o.tool.isDefault||!c)return!1;l=r.insertAtEnd()}return c?(this.setToBlock(l,this.positions.START),!0):!1}navigatePrevious(e=!1){let{currentBlock:r,previousBlock:o}=this.Editor.BlockManager;if(!r)return!1;let{previousInput:n,currentInput:a}=r,i=a!==void 0?OI(a):void 0,s=e||i||!r.focusable;return n&&s?(this.setToInput(n,this.positions.END),!0):o!==null&&s?(this.setToBlock(o,this.positions.END),!0):!1}createShadow(e){let r=document.createElement("span");r.classList.add(t.CSS.shadowCaret),e.insertAdjacentElement("beforeend",r)}restoreCaret(e){let r=e.querySelector(`.${t.CSS.shadowCaret}`);if(!r)return;new ze().expandToTag(r);let o=document.createRange();o.selectNode(r),o.extractContents()}insertContentAtCaretPosition(e){let r=document.createDocumentFragment(),o=document.createElement("div"),n=ze.get(),a=ze.range;o.innerHTML=e,Array.from(o.childNodes).forEach(c=>r.appendChild(c)),r.childNodes.length===0&&r.appendChild(new Text);let i=r.lastChild;a.deleteContents(),a.insertNode(r);let s=document.createRange(),l=i.nodeType===Node.TEXT_NODE?i:i.firstChild;l!==null&&l.textContent!==null&&s.setStart(l,l.textContent.length),n.removeAllRanges(),n.addRange(s)}},GD=class extends ft{constructor(){super(...arguments),this.onMouseUp=()=>{this.listeners.off(document,"mouseover",this.onMouseOver),this.listeners.off(document,"mouseup",this.onMouseUp)},this.onMouseOver=e=>{let{BlockManager:r,BlockSelection:o}=this.Editor;if(e.relatedTarget===null&&e.target===null)return;let n=r.getBlockByChildNode(e.relatedTarget)||this.lastSelectedBlock,a=r.getBlockByChildNode(e.target);if(!(!n||!a)&&a!==n){if(n===this.firstSelectedBlock){ze.get().removeAllRanges(),n.selected=!0,a.selected=!0,o.clearCache();return}if(a===this.firstSelectedBlock){n.selected=!1,a.selected=!1,o.clearCache();return}this.Editor.InlineToolbar.close(),this.toggleBlocksSelectedState(n,a),this.lastSelectedBlock=a}}}async prepare(){this.listeners.on(document,"mousedown",e=>{this.enableCrossBlockSelection(e)})}watchSelection(e){if(e.button!==GRe.LEFT)return;let{BlockManager:r}=this.Editor;this.firstSelectedBlock=r.getBlock(e.target),this.lastSelectedBlock=this.firstSelectedBlock,this.listeners.on(document,"mouseover",this.onMouseOver),this.listeners.on(document,"mouseup",this.onMouseUp)}get isCrossBlockSelectionStarted(){return!!this.firstSelectedBlock&&!!this.lastSelectedBlock&&this.firstSelectedBlock!==this.lastSelectedBlock}toggleBlockSelectedState(e=!0){let{BlockManager:r,BlockSelection:o}=this.Editor;this.lastSelectedBlock||(this.lastSelectedBlock=this.firstSelectedBlock=r.currentBlock),this.firstSelectedBlock===this.lastSelectedBlock&&(this.firstSelectedBlock.selected=!0,o.clearCache(),ze.get().removeAllRanges());let n=r.blocks.indexOf(this.lastSelectedBlock)+(e?1:-1),a=r.blocks[n];a&&(this.lastSelectedBlock.selected!==a.selected?(a.selected=!0,o.clearCache()):(this.lastSelectedBlock.selected=!1,o.clearCache()),this.lastSelectedBlock=a,this.Editor.InlineToolbar.close(),a.holder.scrollIntoView({block:"nearest"}))}clear(e){let{BlockManager:r,BlockSelection:o,Caret:n}=this.Editor,a=r.blocks.indexOf(this.firstSelectedBlock),i=r.blocks.indexOf(this.lastSelectedBlock);if(o.anyBlockSelected&&a>-1&&i>-1&&e&&e instanceof KeyboardEvent)switch(e.keyCode){case Ye.DOWN:case Ye.RIGHT:n.setToBlock(r.blocks[Math.max(a,i)],n.positions.END);break;case Ye.UP:case Ye.LEFT:n.setToBlock(r.blocks[Math.min(a,i)],n.positions.START);break;default:n.setToBlock(r.blocks[Math.max(a,i)],n.positions.END)}this.firstSelectedBlock=this.lastSelectedBlock=null}enableCrossBlockSelection(e){let{UI:r}=this.Editor;ze.isCollapsed||this.Editor.BlockSelection.clearSelection(e),r.nodes.redactor.contains(e.target)?this.watchSelection(e):this.Editor.BlockSelection.clearSelection(e)}toggleBlocksSelectedState(e,r){let{BlockManager:o,BlockSelection:n}=this.Editor,a=o.blocks.indexOf(e),i=o.blocks.indexOf(r),s=e.selected!==r.selected;for(let l=Math.min(a,i);l<=Math.max(a,i);l++){let c=o.blocks[l];c!==this.firstSelectedBlock&&c!==(s?e:r)&&(o.blocks[l].selected=!o.blocks[l].selected,n.clearCache())}}},WD=class extends ft{constructor(){super(...arguments),this.isStartedAtEditor=!1}toggleReadOnly(e){e?this.disableModuleBindings():this.enableModuleBindings()}enableModuleBindings(){let{UI:e}=this.Editor;this.readOnlyMutableListeners.on(e.nodes.holder,"drop",async r=>{await this.processDrop(r)},!0),this.readOnlyMutableListeners.on(e.nodes.holder,"dragstart",()=>{this.processDragStart()}),this.readOnlyMutableListeners.on(e.nodes.holder,"dragover",r=>{this.processDragOver(r)},!0)}disableModuleBindings(){this.readOnlyMutableListeners.clearAll()}async processDrop(e){let{BlockManager:r,Paste:o,Caret:n}=this.Editor;e.preventDefault(),r.blocks.forEach(i=>{i.dropTarget=!1}),ze.isAtEditor&&!ze.isCollapsed&&this.isStartedAtEditor&&document.execCommand("delete"),this.isStartedAtEditor=!1;let a=r.setCurrentBlockByChildNode(e.target);if(a)this.Editor.Caret.setToBlock(a,n.positions.END);else{let i=r.setCurrentBlockByChildNode(r.lastBlock.holder);this.Editor.Caret.setToBlock(i,n.positions.END)}await o.processDataTransfer(e.dataTransfer,!0)}processDragStart(){ze.isAtEditor&&!ze.isCollapsed&&(this.isStartedAtEditor=!0),this.Editor.InlineToolbar.close()}processDragOver(e){e.preventDefault()}},PLe=180,OLe=400,KD=class extends ft{constructor({config:e,eventsDispatcher:r}){super({config:e,eventsDispatcher:r}),this.disabled=!1,this.batchingTimeout=null,this.batchingOnChangeQueue=new Map,this.batchTime=OLe,this.mutationObserver=new MutationObserver(o=>{this.redactorChanged(o)}),this.eventsDispatcher.on(kY,o=>{this.particularBlockChanged(o.event)}),this.eventsDispatcher.on(TY,()=>{this.disable()}),this.eventsDispatcher.on(PY,()=>{this.enable()})}enable(){this.mutationObserver.observe(this.Editor.UI.nodes.redactor,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),this.disabled=!1}disable(){this.mutationObserver.disconnect(),this.disabled=!0}particularBlockChanged(e){this.disabled||!rr(this.config.onChange)||(this.batchingOnChangeQueue.set(`block:${e.detail.target.id}:event:${e.type}`,e),this.batchingTimeout&&clearTimeout(this.batchingTimeout),this.batchingTimeout=setTimeout(()=>{let r;this.batchingOnChangeQueue.size===1?r=this.batchingOnChangeQueue.values().next().value:r=Array.from(this.batchingOnChangeQueue.values()),this.config.onChange&&this.config.onChange(this.Editor.API.methods,r),this.batchingOnChangeQueue.clear()},this.batchTime))}redactorChanged(e){this.eventsDispatcher.emit(dD,{mutations:e})}},xX=class bX extends ft{constructor(){super(...arguments),this.MIME_TYPE="application/x-editor-js",this.toolsTags={},this.tagsByTool={},this.toolsPatterns=[],this.toolsFiles={},this.exceptionList=[],this.processTool=e=>{try{let r=e.create({},{},!1);if(e.pasteConfig===!1){this.exceptionList.push(e.name);return}if(!rr(r.onPaste))return;this.getTagsConfig(e),this.getFilesConfig(e),this.getPatternsConfig(e)}catch(r){At(`Paste handling for \xAB${e.name}\xBB Tool hasn't been set up because of the error`,"warn",r)}},this.handlePasteEvent=async e=>{let{BlockManager:r,Toolbar:o}=this.Editor,n=r.setCurrentBlockByChildNode(e.target);!n||this.isNativeBehaviour(e.target)&&!e.clipboardData.types.includes("Files")||n&&this.exceptionList.includes(n.name)||(e.preventDefault(),this.processDataTransfer(e.clipboardData),o.close())}}async prepare(){this.processTools()}toggleReadOnly(e){e?this.unsetCallback():this.setCallback()}async processDataTransfer(e,r=!1){let{Tools:o}=this.Editor,n=e.types;if((n.includes?n.includes("Files"):n.contains("Files"))&&!ua(this.toolsFiles)){await this.processFiles(e.files);return}let a=e.getData(this.MIME_TYPE),i=e.getData("text/plain"),s=e.getData("text/html");if(a)try{this.insertEditorJSData(JSON.parse(a));return}catch{}r&&i.trim()&&s.trim()&&(s="<p>"+(s.trim()?s:i)+"</p>");let l=Object.keys(this.toolsTags).reduce((u,p)=>(u[p.toLowerCase()]=this.toolsTags[p].sanitizationConfig??{},u),{}),c=Object.assign({},l,o.getAllInlineToolsSanitizeConfig(),{br:{}}),d=ri(s,c);!d.trim()||d.trim()===i||!K.isHTMLString(d)?await this.processText(i):await this.processText(d,!0)}async processText(e,r=!1){let{Caret:o,BlockManager:n}=this.Editor,a=r?this.processHTML(e):this.processPlain(e);if(!a.length)return;if(a.length===1){a[0].isBlock?this.processSingleBlock(a.pop()):this.processInlinePaste(a.pop());return}let i=n.currentBlock&&n.currentBlock.tool.isDefault&&n.currentBlock.isEmpty;a.map(async(s,l)=>this.insertBlock(s,l===0&&i)),n.currentBlock&&o.setToBlock(n.currentBlock,o.positions.END)}setCallback(){this.listeners.on(this.Editor.UI.nodes.holder,"paste",this.handlePasteEvent)}unsetCallback(){this.listeners.off(this.Editor.UI.nodes.holder,"paste",this.handlePasteEvent)}processTools(){let e=this.Editor.Tools.blockTools;Array.from(e.values()).forEach(this.processTool)}collectTagNames(e){return zi(e)?[e]:bo(e)?Object.keys(e):[]}getTagsConfig(e){if(e.pasteConfig===!1)return;let r=e.pasteConfig.tags||[],o=[];r.forEach(n=>{let a=this.collectTagNames(n);o.push(...a),a.forEach(i=>{if(Object.prototype.hasOwnProperty.call(this.toolsTags,i)){At(`Paste handler for \xAB${e.name}\xBB Tool on \xAB${i}\xBB tag is skipped because it is already used by \xAB${this.toolsTags[i].tool.name}\xBB Tool.`,"warn");return}let s=bo(n)?n[i]:null;this.toolsTags[i.toUpperCase()]={tool:e,sanitizationConfig:s}})}),this.tagsByTool[e.name]=o.map(n=>n.toUpperCase())}getFilesConfig(e){if(e.pasteConfig===!1)return;let{files:r={}}=e.pasteConfig,{extensions:o,mimeTypes:n}=r;!o&&!n||(o&&!Array.isArray(o)&&(At(`\xABextensions\xBB property of the onDrop config for \xAB${e.name}\xBB Tool should be an array`),o=[]),n&&!Array.isArray(n)&&(At(`\xABmimeTypes\xBB property of the onDrop config for \xAB${e.name}\xBB Tool should be an array`),n=[]),n&&(n=n.filter(a=>QRe(a)?!0:(At(`MIME type value \xAB${a}\xBB for the \xAB${e.name}\xBB Tool is not a valid MIME type`,"warn"),!1))),this.toolsFiles[e.name]={extensions:o||[],mimeTypes:n||[]})}getPatternsConfig(e){e.pasteConfig===!1||!e.pasteConfig.patterns||ua(e.pasteConfig.patterns)||Object.entries(e.pasteConfig.patterns).forEach(([r,o])=>{o instanceof RegExp||At(`Pattern ${o} for \xAB${e.name}\xBB Tool is skipped because it should be a Regexp instance.`,"warn"),this.toolsPatterns.push({key:r,pattern:o,tool:e})})}isNativeBehaviour(e){return K.isNativeInput(e)}async processFiles(e){let{BlockManager:r}=this.Editor,o;o=await Promise.all(Array.from(e).map(a=>this.processFile(a))),o=o.filter(a=>!!a);let n=r.currentBlock.tool.isDefault&&r.currentBlock.isEmpty;o.forEach((a,i)=>{r.paste(a.type,a.event,i===0&&n)})}async processFile(e){let r=XRe(e),o=Object.entries(this.toolsFiles).find(([a,{mimeTypes:i,extensions:s}])=>{let[l,c]=e.type.split("/"),d=s.find(p=>p.toLowerCase()===r.toLowerCase()),u=i.find(p=>{let[m,h]=p.split("/");return m===l&&(h===c||h==="*")});return!!d||!!u});if(!o)return;let[n]=o;return{event:this.composePasteEvent("file",{file:e}),type:n}}processHTML(e){let{Tools:r}=this.Editor,o=K.make("DIV");return o.innerHTML=e,this.getNodes(o).map(n=>{let a,i=r.defaultTool,s=!1;switch(n.nodeType){case Node.DOCUMENT_FRAGMENT_NODE:a=K.make("div"),a.appendChild(n);break;case Node.ELEMENT_NODE:a=n,s=!0,this.toolsTags[a.tagName]&&(i=this.toolsTags[a.tagName].tool);break}let{tags:l}=i.pasteConfig||{tags:[]},c=l.reduce((p,m)=>(this.collectTagNames(m).forEach(h=>{let g=bo(m)?m[h]:null;p[h.toLowerCase()]=g||{}}),p),{}),d=Object.assign({},c,i.baseSanitizeConfig);if(a.tagName.toLowerCase()==="table"){let p=ri(a.outerHTML,d);a=K.make("div",void 0,{innerHTML:p}).firstChild}else a.innerHTML=ri(a.innerHTML,d);let u=this.composePasteEvent("tag",{data:a});return{content:a,isBlock:s,tool:i.name,event:u}}).filter(n=>{let a=K.isEmpty(n.content),i=K.isSingleTag(n.content);return!a||i})}processPlain(e){let{defaultBlock:r}=this.config;if(!e)return[];let o=r;return e.split(/\r?\n/).filter(n=>n.trim()).map(n=>{let a=K.make("div");a.textContent=n;let i=this.composePasteEvent("tag",{data:a});return{content:a,tool:o,isBlock:!1,event:i}})}async processSingleBlock(e){let{Caret:r,BlockManager:o}=this.Editor,{currentBlock:n}=o;if(!n||e.tool!==n.name||!K.containsOnlyInlineElements(e.content.innerHTML)){this.insertBlock(e,n?.tool.isDefault&&n.isEmpty);return}r.insertContentAtCaretPosition(e.content.innerHTML)}async processInlinePaste(e){let{BlockManager:r,Caret:o}=this.Editor,{content:n}=e;if(r.currentBlock&&r.currentBlock.tool.isDefault&&n.textContent.length<bX.PATTERN_PROCESSING_MAX_LENGTH){let a=await this.processPattern(n.textContent);if(a){let i=r.currentBlock&&r.currentBlock.tool.isDefault&&r.currentBlock.isEmpty,s=r.paste(a.tool,a.event,i);o.setToBlock(s,o.positions.END);return}}if(r.currentBlock&&r.currentBlock.currentInput){let a=r.currentBlock.tool.baseSanitizeConfig;document.execCommand("insertHTML",!1,ri(n.innerHTML,a))}else this.insertBlock(e)}async processPattern(e){let r=this.toolsPatterns.find(o=>{let n=o.pattern.exec(e);return n?e===n.shift():!1});return r?{event:this.composePasteEvent("pattern",{key:r.key,data:e}),tool:r.tool.name}:void 0}insertBlock(e,r=!1){let{BlockManager:o,Caret:n}=this.Editor,{currentBlock:a}=o,i;if(r&&a&&a.isEmpty){i=o.paste(e.tool,e.event,!0),n.setToBlock(i,n.positions.END);return}i=o.paste(e.tool,e.event),n.setToBlock(i,n.positions.END)}insertEditorJSData(e){let{BlockManager:r,Caret:o,Tools:n}=this.Editor;iA(e,a=>n.blockTools.get(a).sanitizeConfig).forEach(({tool:a,data:i},s)=>{let l=!1;s===0&&(l=r.currentBlock&&r.currentBlock.tool.isDefault&&r.currentBlock.isEmpty);let c=r.insert({tool:a,data:i,replace:l});o.setToBlock(c,o.positions.END)})}processElementNode(e,r,o){let n=Object.keys(this.toolsTags),a=e,{tool:i}=this.toolsTags[a.tagName]||{},s=this.tagsByTool[i?.name]||[],l=n.includes(a.tagName),c=K.blockElements.includes(a.tagName.toLowerCase()),d=Array.from(a.children).some(({tagName:p})=>n.includes(p)&&!s.includes(p)),u=Array.from(a.children).some(({tagName:p})=>K.blockElements.includes(p.toLowerCase()));if(!c&&!l&&!d)return o.appendChild(a),[...r,o];if(l&&!d||c&&!u&&!d)return[...r,o,a]}getNodes(e){let r=Array.from(e.childNodes),o,n=(a,i)=>{if(K.isEmpty(i)&&!K.isSingleTag(i))return a;let s=a[a.length-1],l=new DocumentFragment;switch(s&&K.isFragment(s)&&(l=a.pop()),i.nodeType){case Node.ELEMENT_NODE:if(o=this.processElementNode(i,a,l),o)return o;break;case Node.TEXT_NODE:return l.appendChild(i),[...a,l];default:return[...a,l]}return[...a,...Array.from(i.childNodes).reduce(n,[])]};return r.reduce(n,[])}composePasteEvent(e,r){return new CustomEvent(e,{detail:r})}};xX.PATTERN_PROCESSING_MAX_LENGTH=450;var DLe=xX,YD=class extends ft{constructor(){super(...arguments),this.toolsDontSupportReadOnly=[],this.readOnlyEnabled=!1}get isEnabled(){return this.readOnlyEnabled}async prepare(){let{Tools:e}=this.Editor,{blockTools:r}=e,o=[];Array.from(r.entries()).forEach(([n,a])=>{a.isReadOnlySupported||o.push(n)}),this.toolsDontSupportReadOnly=o,this.config.readOnly&&o.length>0&&this.throwCriticalError(),this.toggle(this.config.readOnly,!0)}async toggle(e=!this.readOnlyEnabled,r=!1){e&&this.toolsDontSupportReadOnly.length>0&&this.throwCriticalError();let o=this.readOnlyEnabled;this.readOnlyEnabled=e;for(let a in this.Editor)this.Editor[a].toggleReadOnly&&this.Editor[a].toggleReadOnly(e);if(o===e)return this.readOnlyEnabled;if(r)return this.readOnlyEnabled;this.Editor.ModificationsObserver.disable();let n=await this.Editor.Saver.save();return await this.Editor.BlockManager.clear(),await this.Editor.Renderer.render(n.blocks),this.Editor.ModificationsObserver.enable(),this.readOnlyEnabled}throwCriticalError(){throw new MI(`To enable read-only mode all connected tools should support it. Tools ${this.toolsDontSupportReadOnly.join(", ")} don't support read-only mode.`)}},XD=class t extends ft{constructor(){super(...arguments),this.isRectSelectionActivated=!1,this.SCROLL_SPEED=3,this.HEIGHT_OF_SCROLL_ZONE=40,this.BOTTOM_SCROLL_ZONE=1,this.TOP_SCROLL_ZONE=2,this.MAIN_MOUSE_BUTTON=0,this.mousedown=!1,this.isScrolling=!1,this.inScrollZone=null,this.startX=0,this.startY=0,this.mouseX=0,this.mouseY=0,this.stackOfSelected=[],this.listenerIds=[]}static get CSS(){return{overlay:"codex-editor-overlay",overlayContainer:"codex-editor-overlay__container",rect:"codex-editor-overlay__rectangle",topScrollZone:"codex-editor-overlay__scroll-zone--top",bottomScrollZone:"codex-editor-overlay__scroll-zone--bottom"}}prepare(){this.enableModuleBindings()}startSelection(e,r){let o=document.elementFromPoint(e-window.pageXOffset,r-window.pageYOffset);o.closest(`.${this.Editor.Toolbar.CSS.toolbar}`)||(this.Editor.BlockSelection.allBlocksSelected=!1,this.clearSelection(),this.stackOfSelected=[]);let n=[`.${Oa.CSS.content}`,`.${this.Editor.Toolbar.CSS.toolbar}`,`.${this.Editor.InlineToolbar.CSS.inlineToolbar}`],a=o.closest("."+this.Editor.UI.CSS.editorWrapper),i=n.some(s=>!!o.closest(s));!a||i||(this.mousedown=!0,this.startX=e,this.startY=r)}endSelection(){this.mousedown=!1,this.startX=0,this.startY=0,this.overlayRectangle.style.display="none"}isRectActivated(){return this.isRectSelectionActivated}clearSelection(){this.isRectSelectionActivated=!1}enableModuleBindings(){let{container:e}=this.genHTML();this.listeners.on(e,"mousedown",r=>{this.processMouseDown(r)},!1),this.listeners.on(document.body,"mousemove",iD(r=>{this.processMouseMove(r)},10),{passive:!0}),this.listeners.on(document.body,"mouseleave",()=>{this.processMouseLeave()}),this.listeners.on(window,"scroll",iD(r=>{this.processScroll(r)},10),{passive:!0}),this.listeners.on(document.body,"mouseup",()=>{this.processMouseUp()},!1)}processMouseDown(e){e.button===this.MAIN_MOUSE_BUTTON&&(e.target.closest(K.allInputsSelector)!==null||this.startSelection(e.pageX,e.pageY))}processMouseMove(e){this.changingRectangle(e),this.scrollByZones(e.clientY)}processMouseLeave(){this.clearSelection(),this.endSelection()}processScroll(e){this.changingRectangle(e)}processMouseUp(){this.clearSelection(),this.endSelection()}scrollByZones(e){if(this.inScrollZone=null,e<=this.HEIGHT_OF_SCROLL_ZONE&&(this.inScrollZone=this.TOP_SCROLL_ZONE),document.documentElement.clientHeight-e<=this.HEIGHT_OF_SCROLL_ZONE&&(this.inScrollZone=this.BOTTOM_SCROLL_ZONE),!this.inScrollZone){this.isScrolling=!1;return}this.isScrolling||(this.scrollVertical(this.inScrollZone===this.TOP_SCROLL_ZONE?-this.SCROLL_SPEED:this.SCROLL_SPEED),this.isScrolling=!0)}genHTML(){let{UI:e}=this.Editor,r=e.nodes.holder.querySelector("."+e.CSS.editorWrapper),o=K.make("div",t.CSS.overlay,{}),n=K.make("div",t.CSS.overlayContainer,{}),a=K.make("div",t.CSS.rect,{});return n.appendChild(a),o.appendChild(n),r.appendChild(o),this.overlayRectangle=a,{container:r,overlay:o}}scrollVertical(e){if(!(this.inScrollZone&&this.mousedown))return;let r=window.pageYOffset;window.scrollBy(0,e),this.mouseY+=window.pageYOffset-r,setTimeout(()=>{this.scrollVertical(e)},0)}changingRectangle(e){if(!this.mousedown)return;e.pageY!==void 0&&(this.mouseX=e.pageX,this.mouseY=e.pageY);let{rightPos:r,leftPos:o,index:n}=this.genInfoForMouseSelection(),a=this.startX>r&&this.mouseX>r,i=this.startX<o&&this.mouseX<o;this.rectCrossesBlocks=!(a||i),this.isRectSelectionActivated||(this.rectCrossesBlocks=!1,this.isRectSelectionActivated=!0,this.shrinkRectangleToPoint(),this.overlayRectangle.style.display="block"),this.updateRectangleSize(),this.Editor.Toolbar.close(),n!==void 0&&(this.trySelectNextBlock(n),this.inverseSelection(),ze.get().removeAllRanges())}shrinkRectangleToPoint(){this.overlayRectangle.style.left=`${this.startX-window.pageXOffset}px`,this.overlayRectangle.style.top=`${this.startY-window.pageYOffset}px`,this.overlayRectangle.style.bottom=`calc(100% - ${this.startY-window.pageYOffset}px`,this.overlayRectangle.style.right=`calc(100% - ${this.startX-window.pageXOffset}px`}inverseSelection(){let e=this.Editor.BlockManager.getBlockByIndex(this.stackOfSelected[0]).selected;if(this.rectCrossesBlocks&&!e)for(let r of this.stackOfSelected)this.Editor.BlockSelection.selectBlockByIndex(r);if(!this.rectCrossesBlocks&&e)for(let r of this.stackOfSelected)this.Editor.BlockSelection.unSelectBlockByIndex(r)}updateRectangleSize(){this.mouseY>=this.startY?(this.overlayRectangle.style.top=`${this.startY-window.pageYOffset}px`,this.overlayRectangle.style.bottom=`calc(100% - ${this.mouseY-window.pageYOffset}px`):(this.overlayRectangle.style.bottom=`calc(100% - ${this.startY-window.pageYOffset}px`,this.overlayRectangle.style.top=`${this.mouseY-window.pageYOffset}px`),this.mouseX>=this.startX?(this.overlayRectangle.style.left=`${this.startX-window.pageXOffset}px`,this.overlayRectangle.style.right=`calc(100% - ${this.mouseX-window.pageXOffset}px`):(this.overlayRectangle.style.right=`calc(100% - ${this.startX-window.pageXOffset}px`,this.overlayRectangle.style.left=`${this.mouseX-window.pageXOffset}px`)}genInfoForMouseSelection(){let e=document.body.offsetWidth/2,r=this.mouseY-window.pageYOffset,o=document.elementFromPoint(e,r),n=this.Editor.BlockManager.getBlockByChildNode(o),a;n!==void 0&&(a=this.Editor.BlockManager.blocks.findIndex(d=>d.holder===n.holder));let i=this.Editor.BlockManager.lastBlock.holder.querySelector("."+Oa.CSS.content),s=Number.parseInt(window.getComputedStyle(i).width,10)/2,l=e-s,c=e+s;return{index:a,leftPos:l,rightPos:c}}addBlockInSelection(e){this.rectCrossesBlocks&&this.Editor.BlockSelection.selectBlockByIndex(e),this.stackOfSelected.push(e)}trySelectNextBlock(e){let r=this.stackOfSelected[this.stackOfSelected.length-1]===e,o=this.stackOfSelected.length,n=1,a=-1,i=0;if(r)return;let s=this.stackOfSelected[o-1]-this.stackOfSelected[o-2]>0,l=i;o>1&&(l=s?n:a);let c=e>this.stackOfSelected[o-1]&&l===n,d=e<this.stackOfSelected[o-1]&&l===a,u=!(c||d||l===i);if(!u&&(e>this.stackOfSelected[o-1]||this.stackOfSelected[o-1]===void 0)){let h=this.stackOfSelected[o-1]+1||e;for(h;h<=e;h++)this.addBlockInSelection(h);return}if(!u&&e<this.stackOfSelected[o-1]){for(let h=this.stackOfSelected[o-1]-1;h>=e;h--)this.addBlockInSelection(h);return}if(!u)return;let p=o-1,m;for(e>this.stackOfSelected[o-1]?m=()=>e>this.stackOfSelected[p]:m=()=>e<this.stackOfSelected[p];m();)this.rectCrossesBlocks&&this.Editor.BlockSelection.unSelectBlockByIndex(this.stackOfSelected[p]),this.stackOfSelected.pop(),p--}},QD=class extends ft{async render(e){return new Promise(r=>{let{Tools:o,BlockManager:n}=this.Editor;if(e.length===0)n.insert();else{let a=e.map(({type:i,data:s,tunes:l,id:c})=>{o.available.has(i)===!1&&(da(`Tool \xAB${i}\xBB is not found. Check 'tools' property at the Editor.js config.`,"warn"),s=this.composeStubDataForTool(i,s,c),i=o.stubTool);let d;try{d=n.composeBlock({id:c,tool:i,data:s,tunes:l})}catch(u){At(`Block \xAB${i}\xBB skipped because of plugins error`,"error",{data:s,error:u}),s=this.composeStubDataForTool(i,s,c),i=o.stubTool,d=n.composeBlock({id:c,tool:i,data:s,tunes:l})}return d});n.insertMany(a)}window.requestIdleCallback(()=>{r()},{timeout:2e3})})}composeStubDataForTool(e,r,o){let{Tools:n}=this.Editor,a=e;if(n.unavailable.has(e)){let i=n.unavailable.get(e).toolbox;i!==void 0&&i[0].title!==void 0&&(a=i[0].title)}return{savedData:{id:o,type:e,data:r},title:a}}},ZD=class extends ft{async save(){let{BlockManager:e,Tools:r}=this.Editor,o=e.blocks,n=[];try{o.forEach(s=>{n.push(this.getSavedData(s))});let a=await Promise.all(n),i=await iA(a,s=>r.blockTools.get(s).sanitizeConfig);return this.makeOutput(i)}catch(a){da("Saving failed due to the Error %o","error",a)}}async getSavedData(e){let r=await e.save(),o=r&&await e.validate(r.data);return{...r,isValid:o}}makeOutput(e){let r=[];return e.forEach(({id:o,tool:n,data:a,tunes:i,isValid:s})=>{if(!s){At(`Block \xAB${n}\xBB skipped because saved data is invalid`);return}if(n===this.Editor.Tools.stubTool){r.push(a);return}let l={id:o,type:n,data:a,...!ua(i)&&{tunes:i}};r.push(l)}),{time:+new Date,blocks:r,version:"2.31.0-rc.7"}}};(function(){try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ce-paragraph{line-height:1.6em;outline:none}.ce-block:only-of-type .ce-paragraph[data-placeholder-active]:empty:before,.ce-block:only-of-type .ce-paragraph[data-placeholder-active][data-empty=true]:before{content:attr(data-placeholder-active)}.ce-paragraph p:first-of-type{margin-top:0}.ce-paragraph p:last-of-type{margin-bottom:0}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var ALe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8 9V7.2C8 7.08954 8.08954 7 8.2 7L12 7M16 9V7.2C16 7.08954 15.9105 7 15.8 7L12 7M12 7L12 17M12 17H10M12 17H14"/></svg>';function NLe(t){let e=document.createElement("div");e.innerHTML=t.trim();let r=document.createDocumentFragment();return r.append(...Array.from(e.childNodes)),r}var JD=class t{static get DEFAULT_PLACEHOLDER(){return""}constructor({data:e,config:r,api:o,readOnly:n}){this.api=o,this.readOnly=n,this._CSS={block:this.api.styles.block,wrapper:"ce-paragraph"},this.readOnly||(this.onKeyUp=this.onKeyUp.bind(this)),this._placeholder=r.placeholder?r.placeholder:t.DEFAULT_PLACEHOLDER,this._data=e??{},this._element=null,this._preserveBlank=r.preserveBlank??!1}onKeyUp(e){if(e.code!=="Backspace"&&e.code!=="Delete"||!this._element)return;let{textContent:r}=this._element;r===""&&(this._element.innerHTML="")}drawView(){let e=document.createElement("DIV");return e.classList.add(this._CSS.wrapper,this._CSS.block),e.contentEditable="false",e.dataset.placeholderActive=this.api.i18n.t(this._placeholder),this._data.text&&(e.innerHTML=this._data.text),this.readOnly||(e.contentEditable="true",e.addEventListener("keyup",this.onKeyUp)),e}render(){return this._element=this.drawView(),this._element}merge(e){if(!this._element)return;this._data.text+=e.text;let r=NLe(e.text);this._element.appendChild(r),this._element.normalize()}validate(e){return!(e.text.trim()===""&&!this._preserveBlank)}save(e){return{text:e.innerHTML}}onPaste(e){let r={text:e.detail.data.innerHTML};this._data=r,window.requestAnimationFrame(()=>{this._element&&(this._element.innerHTML=this._data.text||"")})}static get conversionConfig(){return{export:"text",import:"text"}}static get sanitize(){return{text:{br:!0}}}static get isReadOnlySupported(){return!0}static get pasteConfig(){return{tags:["P"]}}static get toolbox(){return{icon:ALe,title:"Text"}}},Bh=class{constructor(){this.commandName="bold"}static get sanitize(){return{b:{}}}render(){return{icon:CMe,name:"bold",onActivate:()=>{document.execCommand(this.commandName)},isActive:()=>document.queryCommandState(this.commandName)}}get shortcut(){return"CMD+B"}};Bh.isInline=!0;Bh.title="Bold";var Fh=class{constructor(){this.commandName="italic",this.CSS={button:"ce-inline-tool",buttonActive:"ce-inline-tool--active",buttonModifier:"ce-inline-tool--italic"},this.nodes={button:null}}static get sanitize(){return{i:{}}}render(){return this.nodes.button=document.createElement("button"),this.nodes.button.type="button",this.nodes.button.classList.add(this.CSS.button,this.CSS.buttonModifier),this.nodes.button.innerHTML=NMe,this.nodes.button}surround(){document.execCommand(this.commandName)}checkState(){let e=document.queryCommandState(this.commandName);return this.nodes.button.classList.toggle(this.CSS.buttonActive,e),e}get shortcut(){return"CMD+I"}};Fh.isInline=!0;Fh.title="Italic";var zh=class{constructor({api:e}){this.commandLink="createLink",this.commandUnlink="unlink",this.ENTER_KEY=13,this.CSS={button:"ce-inline-tool",buttonActive:"ce-inline-tool--active",buttonModifier:"ce-inline-tool--link",buttonUnlink:"ce-inline-tool--unlink",input:"ce-inline-tool-input",inputShowed:"ce-inline-tool-input--showed"},this.nodes={button:null,input:null},this.inputOpened=!1,this.toolbar=e.toolbar,this.inlineToolbar=e.inlineToolbar,this.notifier=e.notifier,this.i18n=e.i18n,this.selection=new ze}static get sanitize(){return{a:{href:!0,target:"_blank",rel:"nofollow"}}}render(){return this.nodes.button=document.createElement("button"),this.nodes.button.type="button",this.nodes.button.classList.add(this.CSS.button,this.CSS.buttonModifier),this.nodes.button.innerHTML=fY,this.nodes.button}renderActions(){return this.nodes.input=document.createElement("input"),this.nodes.input.placeholder=this.i18n.t("Add a link"),this.nodes.input.enterKeyHint="done",this.nodes.input.classList.add(this.CSS.input),this.nodes.input.addEventListener("keydown",e=>{e.keyCode===this.ENTER_KEY&&this.enterPressed(e)}),this.nodes.input}surround(e){if(e){this.inputOpened?(this.selection.restore(),this.selection.removeFakeBackground()):(this.selection.setFakeBackground(),this.selection.save());let r=this.selection.findParentTag("A");if(r){this.selection.expandToTag(r),this.unlink(),this.closeActions(),this.checkState(),this.toolbar.close();return}}this.toggleActions()}checkState(){let e=this.selection.findParentTag("A");if(e){this.nodes.button.innerHTML=BMe,this.nodes.button.classList.add(this.CSS.buttonUnlink),this.nodes.button.classList.add(this.CSS.buttonActive),this.openActions();let r=e.getAttribute("href");this.nodes.input.value=r!=="null"?r:"",this.selection.save()}else this.nodes.button.innerHTML=fY,this.nodes.button.classList.remove(this.CSS.buttonUnlink),this.nodes.button.classList.remove(this.CSS.buttonActive);return!!e}clear(){this.closeActions()}get shortcut(){return"CMD+K"}toggleActions(){this.inputOpened?this.closeActions(!1):this.openActions(!0)}openActions(e=!1){this.nodes.input.classList.add(this.CSS.inputShowed),e&&this.nodes.input.focus(),this.inputOpened=!0}closeActions(e=!0){if(this.selection.isFakeBackgroundEnabled){let r=new ze;r.save(),this.selection.restore(),this.selection.removeFakeBackground(),r.restore()}this.nodes.input.classList.remove(this.CSS.inputShowed),this.nodes.input.value="",e&&this.selection.clearSaved(),this.inputOpened=!1}enterPressed(e){let r=this.nodes.input.value||"";if(!r.trim()){this.selection.restore(),this.unlink(),e.preventDefault(),this.closeActions();return}if(!this.validateURL(r)){this.notifier.show({message:"Pasted link is not valid.",style:"error"}),At("Incorrect Link pasted","warn",r);return}r=this.prepareLink(r),this.selection.restore(),this.selection.removeFakeBackground(),this.insertLink(r),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.selection.collapseToEnd(),this.inlineToolbar.close()}validateURL(e){return!/\s/.test(e)}prepareLink(e){return e=e.trim(),e=this.addProtocol(e),e}addProtocol(e){if(/^(\w+):(\/\/)?/.test(e))return e;let r=/^\/[^/\s]/.test(e),o=e.substring(0,1)==="#",n=/^\/\/[^/\s]/.test(e);return!r&&!o&&!n&&(e="http://"+e),e}insertLink(e){let r=this.selection.findParentTag("A");r&&this.selection.expandToTag(r),document.execCommand(this.commandLink,!1,e)}unlink(){document.execCommand(this.commandUnlink)}};zh.isInline=!0;zh.title="Link";var jI=class{constructor({api:e}){this.i18nAPI=e.i18n,this.blocksAPI=e.blocks,this.selectionAPI=e.selection,this.toolsAPI=e.tools,this.caretAPI=e.caret}async render(){let e=ze.get(),r=this.blocksAPI.getBlockByElement(e.anchorNode);if(r===void 0)return[];let o=this.toolsAPI.getBlockTools(),n=await DY(r,o);if(n.length===0)return[];let a=n.reduce((c,d)=>{var u;return(u=d.toolbox)==null||u.forEach(p=>{c.push({icon:p.icon,title:Zo.t(Dn.toolNames,p.title),name:d.name,closeOnActivate:!0,onActivate:async()=>{let m=await this.blocksAPI.convert(r.id,d.name,p.data);this.caretAPI.setToBlock(m,"end")}})}),c},[]),i=await r.getActiveToolboxEntry(),s=i!==void 0?i.icon:BY,l=!tf();return{icon:s,name:"convert-to",hint:{title:this.i18nAPI.t("Convert to")},children:{searchable:l,items:a,onOpen:()=>{l&&(this.selectionAPI.setFakeBackground(),this.selectionAPI.save())},onClose:()=>{l&&(this.selectionAPI.restore(),this.selectionAPI.removeFakeBackground())}}}}};jI.isInline=!0;var qI=class{constructor({data:e,api:r}){this.CSS={wrapper:"ce-stub",info:"ce-stub__info",title:"ce-stub__title",subtitle:"ce-stub__subtitle"},this.api=r,this.title=e.title||this.api.i18n.t("Error"),this.subtitle=this.api.i18n.t("The block can not be displayed correctly."),this.savedData=e.savedData,this.wrapper=this.make()}render(){return this.wrapper}save(){return this.savedData}make(){let e=K.make("div",this.CSS.wrapper),r=FMe,o=K.make("div",this.CSS.info),n=K.make("div",this.CSS.title,{textContent:this.title}),a=K.make("div",this.CSS.subtitle,{textContent:this.subtitle});return e.innerHTML=r,o.appendChild(n),o.appendChild(a),e.appendChild(o),e}};qI.isReadOnlySupported=!0;var eA=class extends Lh{constructor(){super(...arguments),this.type=Tc.Inline}get title(){return this.constructable[HI.Title]}create(){return new this.constructable({api:this.api,config:this.settings})}get isReadOnlySupported(){return this.constructable[HI.IsReadOnlySupported]??!1}},tA=class extends Lh{constructor(){super(...arguments),this.type=Tc.Tune}create(e,r){return new this.constructable({api:this.api,config:this.settings,block:r,data:e})}},ca=class t extends Map{get blockTools(){let e=Array.from(this.entries()).filter(([,r])=>r.isBlock());return new t(e)}get inlineTools(){let e=Array.from(this.entries()).filter(([,r])=>r.isInline());return new t(e)}get blockTunes(){let e=Array.from(this.entries()).filter(([,r])=>r.isTune());return new t(e)}get internalTools(){let e=Array.from(this.entries()).filter(([,r])=>r.isInternal);return new t(e)}get externalTools(){let e=Array.from(this.entries()).filter(([,r])=>!r.isInternal);return new t(e)}},RLe=Object.defineProperty,MLe=Object.getOwnPropertyDescriptor,vX=(t,e,r,o)=>{for(var n=o>1?void 0:o?MLe(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=(o?i(e,r,n):i(n))||n);return o&&n&&RLe(e,r,n),n},Uh=class extends Lh{constructor(){super(...arguments),this.type=Tc.Block,this.inlineTools=new ca,this.tunes=new ca}create(e,r,o){return new this.constructable({data:e,block:r,readOnly:o,api:this.api,config:this.settings})}get isReadOnlySupported(){return this.constructable[Xu.IsReadOnlySupported]===!0}get isLineBreaksEnabled(){return this.constructable[Xu.IsEnabledLineBreaks]}get toolbox(){let e=this.constructable[Xu.Toolbox],r=this.config[PI.Toolbox];if(!ua(e)&&r!==!1)return r?Array.isArray(e)?Array.isArray(r)?r.map((o,n)=>{let a=e[n];return a?{...a,...o}:o}):[r]:Array.isArray(r)?r:[{...e,...r}]:Array.isArray(e)?e:[e]}get conversionConfig(){return this.constructable[Xu.ConversionConfig]}get enabledInlineTools(){return this.config[PI.EnabledInlineTools]||!1}get enabledBlockTunes(){return this.config[PI.EnabledBlockTunes]}get pasteConfig(){return this.constructable[Xu.PasteConfig]??{}}get sanitizeConfig(){let e=super.sanitizeConfig,r=this.baseSanitizeConfig;if(ua(e))return r;let o={};for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let a=e[n];bo(a)?o[n]=Object.assign({},r,a):o[n]=a}return o}get baseSanitizeConfig(){let e={};return Array.from(this.inlineTools.values()).forEach(r=>Object.assign(e,r.sanitizeConfig)),Array.from(this.tunes.values()).forEach(r=>Object.assign(e,r.sanitizeConfig)),e}};vX([ef],Uh.prototype,"sanitizeConfig",1);vX([ef],Uh.prototype,"baseSanitizeConfig",1);var rA=class{constructor(e,r,o){this.api=o,this.config=e,this.editorConfig=r}get(e){let{class:r,isInternal:o=!1,...n}=this.config[e],a=this.getConstructor(r),i=r[FD.IsTune];return new a({name:e,constructable:r,config:n,api:this.api.getMethodsForTool(e,i),isDefault:e===this.editorConfig.defaultBlock,defaultPlaceholder:this.editorConfig.placeholder,isInternal:o})}getConstructor(e){switch(!0){case e[HI.IsInline]:return eA;case e[FD.IsTune]:return tA;default:return Uh}}},GI=class{constructor({api:e}){this.CSS={animation:"wobble"},this.api=e}render(){return{icon:kMe,title:this.api.i18n.t("Move down"),onActivate:()=>this.handleClick(),name:"move-down"}}handleClick(){let e=this.api.blocks.getCurrentBlockIndex(),r=this.api.blocks.getBlockByIndex(e+1);if(!r)throw new Error("Unable to move Block down since it is already the last");let o=r.holder,n=o.getBoundingClientRect(),a=Math.abs(window.innerHeight-o.offsetHeight);n.top<window.innerHeight&&(a=window.scrollY+o.offsetHeight),window.scrollTo(0,a),this.api.blocks.move(e+1),this.api.toolbar.toggleBlockSettings(!0)}};GI.isTune=!0;var WI=class{constructor({api:e}){this.api=e}render(){return{icon:DMe,title:this.api.i18n.t("Delete"),name:"delete",confirmation:{title:this.api.i18n.t("Click to delete"),onActivate:()=>this.handleClick()}}}handleClick(){this.api.blocks.delete()}};WI.isTune=!0;var KI=class{constructor({api:e}){this.CSS={animation:"wobble"},this.api=e}render(){return{icon:OMe,title:this.api.i18n.t("Move up"),onActivate:()=>this.handleClick(),name:"move-up"}}handleClick(){let e=this.api.blocks.getCurrentBlockIndex(),r=this.api.blocks.getBlockByIndex(e),o=this.api.blocks.getBlockByIndex(e-1);if(e===0||!r||!o)throw new Error("Unable to move Block up since it is already the first");let n=r.holder,a=o.holder,i=n.getBoundingClientRect(),s=a.getBoundingClientRect(),l;s.top>0?l=Math.abs(i.top)-Math.abs(s.top):l=Math.abs(i.top)+s.height,window.scrollBy(0,-1*l),this.api.blocks.move(e-1),this.api.toolbar.toggleBlockSettings(!0)}};KI.isTune=!0;var LLe=Object.defineProperty,BLe=Object.getOwnPropertyDescriptor,FLe=(t,e,r,o)=>{for(var n=o>1?void 0:o?BLe(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=(o?i(e,r,n):i(n))||n);return o&&n&&LLe(e,r,n),n},YI=class extends ft{constructor(){super(...arguments),this.stubTool="stub",this.toolsAvailable=new ca,this.toolsUnavailable=new ca}get available(){return this.toolsAvailable}get unavailable(){return this.toolsUnavailable}get inlineTools(){return this.available.inlineTools}get blockTools(){return this.available.blockTools}get blockTunes(){return this.available.blockTunes}get defaultTool(){return this.blockTools.get(this.config.defaultBlock)}get internal(){return this.available.internalTools}async prepare(){if(this.validateTools(),this.config.tools=sD({},this.internalTools,this.config.tools),!Object.prototype.hasOwnProperty.call(this.config,"tools")||Object.keys(this.config.tools).length===0)throw Error("Can't start without tools");let e=this.prepareConfig();this.factory=new rA(e,this.config,this.Editor.API);let r=this.getListOfPrepareFunctions(e);if(r.length===0)return Promise.resolve();await YRe(r,o=>{this.toolPrepareMethodSuccess(o)},o=>{this.toolPrepareMethodFallback(o)}),this.prepareBlockTools()}getAllInlineToolsSanitizeConfig(){let e={};return Array.from(this.inlineTools.values()).forEach(r=>{Object.assign(e,r.sanitizeConfig)}),e}destroy(){Object.values(this.available).forEach(async e=>{rr(e.reset)&&await e.reset()})}get internalTools(){return{convertTo:{class:jI,isInternal:!0},link:{class:zh,isInternal:!0},bold:{class:Bh,isInternal:!0},italic:{class:Fh,isInternal:!0},paragraph:{class:JD,inlineToolbar:!0,isInternal:!0},stub:{class:qI,isInternal:!0},moveUp:{class:KI,isInternal:!0},delete:{class:WI,isInternal:!0},moveDown:{class:GI,isInternal:!0}}}toolPrepareMethodSuccess(e){let r=this.factory.get(e.toolName);if(r.isInline()){let o=["render"].filter(n=>!r.create()[n]);if(o.length){At(`Incorrect Inline Tool: ${r.name}. Some of required methods is not implemented %o`,"warn",o),this.toolsUnavailable.set(r.name,r);return}}this.toolsAvailable.set(r.name,r)}toolPrepareMethodFallback(e){this.toolsUnavailable.set(e.toolName,this.factory.get(e.toolName))}getListOfPrepareFunctions(e){let r=[];return Object.entries(e).forEach(([o,n])=>{r.push({function:rr(n.class.prepare)?n.class.prepare:()=>{},data:{toolName:o,config:n.config}})}),r}prepareBlockTools(){Array.from(this.blockTools.values()).forEach(e=>{this.assignInlineToolsToBlockTool(e),this.assignBlockTunesToBlockTool(e)})}assignInlineToolsToBlockTool(e){if(this.config.inlineToolbar!==!1){if(e.enabledInlineTools===!0){e.inlineTools=new ca(Array.isArray(this.config.inlineToolbar)?this.config.inlineToolbar.map(r=>[r,this.inlineTools.get(r)]):Array.from(this.inlineTools.entries()));return}Array.isArray(e.enabledInlineTools)&&(e.inlineTools=new ca(["convertTo",...e.enabledInlineTools].map(r=>[r,this.inlineTools.get(r)])))}}assignBlockTunesToBlockTool(e){if(e.enabledBlockTunes!==!1){if(Array.isArray(e.enabledBlockTunes)){let r=new ca(e.enabledBlockTunes.map(o=>[o,this.blockTunes.get(o)]));e.tunes=new ca([...r,...this.blockTunes.internalTools]);return}if(Array.isArray(this.config.tunes)){let r=new ca(this.config.tunes.map(o=>[o,this.blockTunes.get(o)]));e.tunes=new ca([...r,...this.blockTunes.internalTools]);return}e.tunes=this.blockTunes.internalTools}}validateTools(){for(let e in this.config.tools)if(Object.prototype.hasOwnProperty.call(this.config.tools,e)){if(e in this.internalTools)return;let r=this.config.tools[e];if(!rr(r)&&!rr(r.class))throw Error(`Tool \xAB${e}\xBB must be a constructor function or an object with function in the \xABclass\xBB property`)}}prepareConfig(){let e={};for(let r in this.config.tools)bo(this.config.tools[r])?e[r]=this.config.tools[r]:e[r]={class:this.config.tools[r]};return e}};FLe([ef],YI.prototype,"getAllInlineToolsSanitizeConfig",1);var zLe=`:root{--selectionColor: #e1f2ff;--inlineSelectionColor: #d4ecff;--bg-light: #eff2f5;--grayText: #707684;--color-dark: #1D202B;--color-active-icon: #388AE5;--color-gray-border: rgba(201, 201, 204, .48);--content-width: 650px;--narrow-mode-right-padding: 50px;--toolbox-buttons-size: 26px;--toolbox-buttons-size--mobile: 36px;--icon-size: 20px;--icon-size--mobile: 28px;--block-padding-vertical: .4em;--color-line-gray: #EFF0F1 }.codex-editor{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;z-index:1}.codex-editor .hide{display:none}.codex-editor__redactor [contenteditable]:empty:after{content:"\\feff"}@media (min-width: 651px){.codex-editor--narrow .codex-editor__redactor{margin-right:50px}}@media (min-width: 651px){.codex-editor--narrow.codex-editor--rtl .codex-editor__redactor{margin-left:50px;margin-right:0}}@media (min-width: 651px){.codex-editor--narrow .ce-toolbar__actions{right:-5px}}.codex-editor-copyable{position:absolute;height:1px;width:1px;top:-400%;opacity:.001}.codex-editor-overlay{position:fixed;top:0;left:0;right:0;bottom:0;z-index:999;pointer-events:none;overflow:hidden}.codex-editor-overlay__container{position:relative;pointer-events:auto;z-index:0}.codex-editor-overlay__rectangle{position:absolute;pointer-events:none;background-color:#2eaadc33;border:1px solid transparent}.codex-editor svg{max-height:100%}.codex-editor path{stroke:currentColor}.codex-editor ::-moz-selection{background-color:#d4ecff}.codex-editor ::selection{background-color:#d4ecff}.codex-editor--toolbox-opened [contentEditable=true][data-placeholder]:focus:before{opacity:0!important}.ce-scroll-locked{overflow:hidden}.ce-scroll-locked--hard{overflow:hidden;top:calc(-1 * var(--window-scroll-offset));position:fixed;width:100%}.ce-toolbar{position:absolute;left:0;right:0;top:0;-webkit-transition:opacity .1s ease;transition:opacity .1s ease;will-change:opacity,top;display:none}.ce-toolbar--opened{display:block}.ce-toolbar__content{max-width:650px;margin:0 auto;position:relative}.ce-toolbar__plus{color:#1d202b;cursor:pointer;width:26px;height:26px;border-radius:7px;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-flex-negative:0;flex-shrink:0}@media (max-width: 650px){.ce-toolbar__plus{width:36px;height:36px}}@media (hover: hover){.ce-toolbar__plus:hover{background-color:#eff2f5}}.ce-toolbar__plus--active{background-color:#eff2f5;-webkit-animation:bounceIn .75s 1;animation:bounceIn .75s 1;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards}.ce-toolbar__plus-shortcut{opacity:.6;word-spacing:-2px;margin-top:5px}@media (max-width: 650px){.ce-toolbar__plus{position:absolute;background-color:#fff;border:1px solid #E8E8EB;-webkit-box-shadow:0 3px 15px -3px rgba(13,20,33,.13);box-shadow:0 3px 15px -3px #0d142121;border-radius:6px;z-index:2;position:static}.ce-toolbar__plus--left-oriented:before{left:15px;margin-left:0}.ce-toolbar__plus--right-oriented:before{left:auto;right:15px;margin-left:0}}.ce-toolbar__actions{position:absolute;right:100%;opacity:0;display:-webkit-box;display:-ms-flexbox;display:flex;padding-right:5px}.ce-toolbar__actions--opened{opacity:1}@media (max-width: 650px){.ce-toolbar__actions{right:auto}}.ce-toolbar__settings-btn{color:#1d202b;width:26px;height:26px;border-radius:7px;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;margin-left:3px;cursor:pointer;user-select:none}@media (max-width: 650px){.ce-toolbar__settings-btn{width:36px;height:36px}}@media (hover: hover){.ce-toolbar__settings-btn:hover{background-color:#eff2f5}}.ce-toolbar__settings-btn--active{background-color:#eff2f5;-webkit-animation:bounceIn .75s 1;animation:bounceIn .75s 1;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards}@media (min-width: 651px){.ce-toolbar__settings-btn{width:24px}}.ce-toolbar__settings-btn--hidden{display:none}@media (max-width: 650px){.ce-toolbar__settings-btn{position:absolute;background-color:#fff;border:1px solid #E8E8EB;-webkit-box-shadow:0 3px 15px -3px rgba(13,20,33,.13);box-shadow:0 3px 15px -3px #0d142121;border-radius:6px;z-index:2;position:static}.ce-toolbar__settings-btn--left-oriented:before{left:15px;margin-left:0}.ce-toolbar__settings-btn--right-oriented:before{left:auto;right:15px;margin-left:0}}.ce-toolbar__plus svg,.ce-toolbar__settings-btn svg{width:24px;height:24px}@media (min-width: 651px){.codex-editor--narrow .ce-toolbar__plus{left:5px}}@media (min-width: 651px){.codex-editor--narrow .ce-toolbox .ce-popover{right:0;left:auto;left:initial}}.ce-inline-toolbar{--y-offset: 8px;--color-background-icon-active: rgba(56, 138, 229, .1);--color-text-icon-active: #388AE5;--color-text-primary: black;position:absolute;visibility:hidden;-webkit-transition:opacity .25s ease;transition:opacity .25s ease;will-change:opacity,left,top;top:0;left:0;z-index:3;opacity:1;visibility:visible}.ce-inline-toolbar [hidden]{display:none!important}.ce-inline-toolbar__toggler-and-button-wrapper{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;padding:0 6px}.ce-inline-toolbar__buttons{display:-webkit-box;display:-ms-flexbox;display:flex}.ce-inline-toolbar__dropdown{display:-webkit-box;display:-ms-flexbox;display:flex;padding:6px;margin:0 6px 0 -6px;-webkit-box-align:center;-ms-flex-align:center;align-items:center;cursor:pointer;border-right:1px solid rgba(201,201,204,.48);-webkit-box-sizing:border-box;box-sizing:border-box}@media (hover: hover){.ce-inline-toolbar__dropdown:hover{background:#eff2f5}}.ce-inline-toolbar__dropdown--hidden{display:none}.ce-inline-toolbar__dropdown-content,.ce-inline-toolbar__dropdown-arrow{display:-webkit-box;display:-ms-flexbox;display:flex}.ce-inline-toolbar__dropdown-content svg,.ce-inline-toolbar__dropdown-arrow svg{width:20px;height:20px}.ce-inline-toolbar__shortcut{opacity:.6;word-spacing:-3px;margin-top:3px}.ce-inline-tool{color:var(--color-text-primary);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;border:0;border-radius:4px;line-height:normal;height:100%;padding:0;width:28px;background-color:transparent;cursor:pointer}@media (max-width: 650px){.ce-inline-tool{width:36px;height:36px}}@media (hover: hover){.ce-inline-tool:hover{background-color:#f8f8f8}}.ce-inline-tool svg{display:block;width:20px;height:20px}@media (max-width: 650px){.ce-inline-tool svg{width:28px;height:28px}}.ce-inline-tool--link .icon--unlink,.ce-inline-tool--unlink .icon--link{display:none}.ce-inline-tool--unlink .icon--unlink{display:inline-block;margin-bottom:-1px}.ce-inline-tool-input{background:#F8F8F8;border:1px solid rgba(226,226,229,.2);border-radius:6px;padding:4px 8px;font-size:14px;line-height:22px;outline:none;margin:0;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;display:none;font-weight:500;-webkit-appearance:none;font-family:inherit}@media (max-width: 650px){.ce-inline-tool-input{font-size:15px;font-weight:500}}.ce-inline-tool-input::-webkit-input-placeholder{color:#707684}.ce-inline-tool-input::-moz-placeholder{color:#707684}.ce-inline-tool-input:-ms-input-placeholder{color:#707684}.ce-inline-tool-input::-ms-input-placeholder{color:#707684}.ce-inline-tool-input::placeholder{color:#707684}.ce-inline-tool-input--showed{display:block}.ce-inline-tool--active{background:var(--color-background-icon-active);color:var(--color-text-icon-active)}@-webkit-keyframes fade-in{0%{opacity:0}to{opacity:1}}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.ce-block{-webkit-animation:fade-in .3s ease;animation:fade-in .3s ease;-webkit-animation-fill-mode:none;animation-fill-mode:none;-webkit-animation-fill-mode:initial;animation-fill-mode:initial}.ce-block:first-of-type{margin-top:0}.ce-block--selected .ce-block__content{background:#e1f2ff}.ce-block--selected .ce-block__content [contenteditable]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ce-block--selected .ce-block__content img,.ce-block--selected .ce-block__content .ce-stub{opacity:.55}.ce-block--stretched .ce-block__content{max-width:none}.ce-block__content{position:relative;max-width:650px;margin:0 auto;-webkit-transition:background-color .15s ease;transition:background-color .15s ease}.ce-block--drop-target .ce-block__content:before{content:"";position:absolute;top:100%;left:-20px;margin-top:-1px;height:8px;width:8px;border:solid #388AE5;border-width:1px 1px 0 0;-webkit-transform-origin:right;transform-origin:right;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.ce-block--drop-target .ce-block__content:after{content:"";position:absolute;top:100%;height:1px;width:100%;color:#388ae5;background:repeating-linear-gradient(90deg,#388AE5,#388AE5 1px,#fff 1px,#fff 6px)}.ce-block a{cursor:pointer;-webkit-text-decoration:underline;text-decoration:underline}.ce-block b{font-weight:700}.ce-block i{font-style:italic}@-webkit-keyframes bounceIn{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}20%{-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}60%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@keyframes bounceIn{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}20%{-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}60%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@-webkit-keyframes selectionBounce{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}50%{-webkit-transform:scale3d(1.01,1.01,1.01);transform:scale3d(1.01,1.01,1.01)}70%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@keyframes selectionBounce{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}50%{-webkit-transform:scale3d(1.01,1.01,1.01);transform:scale3d(1.01,1.01,1.01)}70%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@-webkit-keyframes buttonClicked{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{-webkit-transform:scale3d(.95,.95,.95);transform:scale3d(.95,.95,.95)}60%{-webkit-transform:scale3d(1.02,1.02,1.02);transform:scale3d(1.02,1.02,1.02)}80%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}@keyframes buttonClicked{0%,20%,40%,60%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{-webkit-transform:scale3d(.95,.95,.95);transform:scale3d(.95,.95,.95)}60%{-webkit-transform:scale3d(1.02,1.02,1.02);transform:scale3d(1.02,1.02,1.02)}80%{-webkit-transform:scale3d(1,1,1);transform:scaleZ(1)}}.cdx-block{padding:.4em 0}.cdx-block::-webkit-input-placeholder{line-height:normal!important}.cdx-input{border:1px solid rgba(201,201,204,.48);-webkit-box-shadow:inset 0 1px 2px 0 rgba(35,44,72,.06);box-shadow:inset 0 1px 2px #232c480f;border-radius:3px;padding:10px 12px;outline:none;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box}.cdx-input[data-placeholder]:before{position:static!important}.cdx-input[data-placeholder]:before{display:inline-block;width:0;white-space:nowrap;pointer-events:none}.cdx-settings-button{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;border-radius:3px;cursor:pointer;border:0;outline:none;background-color:transparent;vertical-align:bottom;color:inherit;margin:0;min-width:26px;min-height:26px}.cdx-settings-button--focused{background:rgba(34,186,255,.08)!important}.cdx-settings-button--focused{-webkit-box-shadow:inset 0 0 0px 1px rgba(7,161,227,.08);box-shadow:inset 0 0 0 1px #07a1e314}.cdx-settings-button--focused-animated{-webkit-animation-name:buttonClicked;animation-name:buttonClicked;-webkit-animation-duration:.25s;animation-duration:.25s}.cdx-settings-button--active{color:#388ae5}.cdx-settings-button svg{width:auto;height:auto}@media (max-width: 650px){.cdx-settings-button svg{width:28px;height:28px}}@media (max-width: 650px){.cdx-settings-button{width:36px;height:36px;border-radius:8px}}@media (hover: hover){.cdx-settings-button:hover{background-color:#eff2f5}}.cdx-loader{position:relative;border:1px solid rgba(201,201,204,.48)}.cdx-loader:before{content:"";position:absolute;left:50%;top:50%;width:18px;height:18px;margin:-11px 0 0 -11px;border:2px solid rgba(201,201,204,.48);border-left-color:#388ae5;border-radius:50%;-webkit-animation:cdxRotation 1.2s infinite linear;animation:cdxRotation 1.2s infinite linear}@-webkit-keyframes cdxRotation{0%{-webkit-transform:rotate(0deg);transform:rotate(0)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes cdxRotation{0%{-webkit-transform:rotate(0deg);transform:rotate(0)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.cdx-button{padding:13px;border-radius:3px;border:1px solid rgba(201,201,204,.48);font-size:14.9px;background:#fff;-webkit-box-shadow:0 2px 2px 0 rgba(18,30,57,.04);box-shadow:0 2px 2px #121e390a;color:#707684;text-align:center;cursor:pointer}@media (hover: hover){.cdx-button:hover{background:#FBFCFE;-webkit-box-shadow:0 1px 3px 0 rgba(18,30,57,.08);box-shadow:0 1px 3px #121e3914}}.cdx-button svg{height:20px;margin-right:.2em;margin-top:-2px}.ce-stub{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:12px 18px;margin:10px 0;border-radius:10px;background:#eff2f5;border:1px solid #EFF0F1;color:#707684;font-size:14px}.ce-stub svg{width:20px;height:20px}.ce-stub__info{margin-left:14px}.ce-stub__title{font-weight:500;text-transform:capitalize}.codex-editor.codex-editor--rtl{direction:rtl}.codex-editor.codex-editor--rtl .cdx-list{padding-left:0;padding-right:40px}.codex-editor.codex-editor--rtl .ce-toolbar__plus{right:-26px;left:auto}.codex-editor.codex-editor--rtl .ce-toolbar__actions{right:auto;left:-26px}@media (max-width: 650px){.codex-editor.codex-editor--rtl .ce-toolbar__actions{margin-left:0;margin-right:auto;padding-right:0;padding-left:10px}}.codex-editor.codex-editor--rtl .ce-settings{left:5px;right:auto}.codex-editor.codex-editor--rtl .ce-settings:before{right:auto;left:25px}.codex-editor.codex-editor--rtl .ce-settings__button:not(:nth-child(3n+3)){margin-left:3px;margin-right:0}.codex-editor.codex-editor--rtl .ce-conversion-tool__icon{margin-right:0;margin-left:10px}.codex-editor.codex-editor--rtl .ce-inline-toolbar__dropdown{border-right:0px solid transparent;border-left:1px solid rgba(201,201,204,.48);margin:0 -6px 0 6px}.codex-editor.codex-editor--rtl .ce-inline-toolbar__dropdown .icon--toggler-down{margin-left:0;margin-right:4px}@media (min-width: 651px){.codex-editor--narrow.codex-editor--rtl .ce-toolbar__plus{left:0;right:5px}}@media (min-width: 651px){.codex-editor--narrow.codex-editor--rtl .ce-toolbar__actions{left:-5px}}.cdx-search-field{--icon-margin-right: 10px;background:#F8F8F8;border:1px solid rgba(226,226,229,.2);border-radius:6px;padding:2px;display:grid;grid-template-columns:auto auto 1fr;grid-template-rows:auto}.cdx-search-field__icon{width:26px;height:26px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;margin-right:var(--icon-margin-right)}.cdx-search-field__icon svg{width:20px;height:20px;color:#707684}.cdx-search-field__input{font-size:14px;outline:none;font-weight:500;font-family:inherit;border:0;background:transparent;margin:0;padding:0;line-height:22px;min-width:calc(100% - 26px - var(--icon-margin-right))}.cdx-search-field__input::-webkit-input-placeholder{color:#707684;font-weight:500}.cdx-search-field__input::-moz-placeholder{color:#707684;font-weight:500}.cdx-search-field__input:-ms-input-placeholder{color:#707684;font-weight:500}.cdx-search-field__input::-ms-input-placeholder{color:#707684;font-weight:500}.cdx-search-field__input::placeholder{color:#707684;font-weight:500}.ce-popover{--border-radius: 6px;--width: 200px;--max-height: 270px;--padding: 6px;--offset-from-target: 8px;--color-border: #EFF0F1;--color-shadow: rgba(13, 20, 33, .1);--color-background: white;--color-text-primary: black;--color-text-secondary: #707684;--color-border-icon: rgba(201, 201, 204, .48);--color-border-icon-disabled: #EFF0F1;--color-text-icon-active: #388AE5;--color-background-icon-active: rgba(56, 138, 229, .1);--color-background-item-focus: rgba(34, 186, 255, .08);--color-shadow-item-focus: rgba(7, 161, 227, .08);--color-background-item-hover: #F8F8F8;--color-background-item-confirm: #E24A4A;--color-background-item-confirm-hover: #CE4343;--popover-top: calc(100% + var(--offset-from-target));--popover-left: 0;--nested-popover-overlap: 4px;--icon-size: 20px;--item-padding: 3px;--item-height: calc(var(--icon-size) + 2 * var(--item-padding))}.ce-popover__container{min-width:var(--width);width:var(--width);max-height:var(--max-height);border-radius:var(--border-radius);overflow:hidden;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:0px 3px 15px -3px var(--color-shadow);box-shadow:0 3px 15px -3px var(--color-shadow);position:absolute;left:var(--popover-left);top:var(--popover-top);background:var(--color-background);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;z-index:4;opacity:0;max-height:0;pointer-events:none;padding:0;border:none}.ce-popover--opened>.ce-popover__container{opacity:1;padding:var(--padding);max-height:var(--max-height);pointer-events:auto;-webkit-animation:panelShowing .1s ease;animation:panelShowing .1s ease;border:1px solid var(--color-border)}@media (max-width: 650px){.ce-popover--opened>.ce-popover__container{-webkit-animation:panelShowingMobile .25s ease;animation:panelShowingMobile .25s ease}}.ce-popover--open-top .ce-popover__container{--popover-top: calc(-1 * (var(--offset-from-target) + var(--popover-height)))}.ce-popover--open-left .ce-popover__container{--popover-left: calc(-1 * var(--width) + 100%)}.ce-popover__items{overflow-y:auto;-ms-scroll-chaining:none;overscroll-behavior:contain}@media (max-width: 650px){.ce-popover__overlay{position:fixed;top:0;bottom:0;left:0;right:0;background:#1D202B;z-index:3;opacity:.5;-webkit-transition:opacity .12s ease-in;transition:opacity .12s ease-in;will-change:opacity;visibility:visible}}.ce-popover__overlay--hidden{display:none}@media (max-width: 650px){.ce-popover .ce-popover__container{--offset: 5px;position:fixed;max-width:none;min-width:calc(100% - var(--offset) * 2);left:var(--offset);right:var(--offset);bottom:calc(var(--offset) + env(safe-area-inset-bottom));top:auto;border-radius:10px}}.ce-popover__search{margin-bottom:5px}.ce-popover__nothing-found-message{color:#707684;display:none;cursor:default;padding:3px;font-size:14px;line-height:20px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ce-popover__nothing-found-message--displayed{display:block}.ce-popover--nested .ce-popover__container{--popover-left: calc(var(--nesting-level) * (var(--width) - var(--nested-popover-overlap)));top:calc(var(--trigger-item-top) - var(--nested-popover-overlap));position:absolute}.ce-popover--open-top.ce-popover--nested .ce-popover__container{top:calc(var(--trigger-item-top) - var(--popover-height) + var(--item-height) + var(--offset-from-target) + var(--nested-popover-overlap))}.ce-popover--open-left .ce-popover--nested .ce-popover__container{--popover-left: calc(-1 * (var(--nesting-level) + 1) * var(--width) + 100%)}.ce-popover-item-separator{padding:4px 3px}.ce-popover-item-separator--hidden{display:none}.ce-popover-item-separator__line{height:1px;background:var(--color-border);width:100%}.ce-popover-item-html--hidden{display:none}.ce-popover-item{--border-radius: 6px;border-radius:var(--border-radius);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:var(--item-padding);color:var(--color-text-primary);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:none;background:transparent}@media (max-width: 650px){.ce-popover-item{padding:4px}}.ce-popover-item:not(:last-of-type){margin-bottom:1px}.ce-popover-item__icon{width:26px;height:26px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.ce-popover-item__icon svg{width:20px;height:20px}@media (max-width: 650px){.ce-popover-item__icon{width:36px;height:36px;border-radius:8px}.ce-popover-item__icon svg{width:28px;height:28px}}.ce-popover-item__icon--tool{margin-right:4px}.ce-popover-item__title{font-size:14px;line-height:20px;font-weight:500;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-right:auto}@media (max-width: 650px){.ce-popover-item__title{font-size:16px}}.ce-popover-item__secondary-title{color:var(--color-text-secondary);font-size:12px;white-space:nowrap;letter-spacing:-.1em;padding-right:5px;opacity:.6}@media (max-width: 650px){.ce-popover-item__secondary-title{display:none}}.ce-popover-item--active{background:var(--color-background-icon-active);color:var(--color-text-icon-active)}.ce-popover-item--disabled{color:var(--color-text-secondary);cursor:default;pointer-events:none}.ce-popover-item--focused:not(.ce-popover-item--no-focus){background:var(--color-background-item-focus)!important}.ce-popover-item--hidden{display:none}@media (hover: hover){.ce-popover-item:hover{cursor:pointer}.ce-popover-item:hover:not(.ce-popover-item--no-hover){background-color:var(--color-background-item-hover)}}.ce-popover-item--confirmation{background:var(--color-background-item-confirm)}.ce-popover-item--confirmation .ce-popover-item__title,.ce-popover-item--confirmation .ce-popover-item__icon{color:#fff}@media (hover: hover){.ce-popover-item--confirmation:not(.ce-popover-item--no-hover):hover{background:var(--color-background-item-confirm-hover)}}.ce-popover-item--confirmation:not(.ce-popover-item--no-focus).ce-popover-item--focused{background:var(--color-background-item-confirm-hover)!important}@-webkit-keyframes panelShowing{0%{opacity:0;-webkit-transform:translateY(-8px) scale(.9);transform:translateY(-8px) scale(.9)}70%{opacity:1;-webkit-transform:translateY(2px);transform:translateY(2px)}to{-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes panelShowing{0%{opacity:0;-webkit-transform:translateY(-8px) scale(.9);transform:translateY(-8px) scale(.9)}70%{opacity:1;-webkit-transform:translateY(2px);transform:translateY(2px)}to{-webkit-transform:translateY(0);transform:translateY(0)}}@-webkit-keyframes panelShowingMobile{0%{opacity:0;-webkit-transform:translateY(14px) scale(.98);transform:translateY(14px) scale(.98)}70%{opacity:1;-webkit-transform:translateY(-4px);transform:translateY(-4px)}to{-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes panelShowingMobile{0%{opacity:0;-webkit-transform:translateY(14px) scale(.98);transform:translateY(14px) scale(.98)}70%{opacity:1;-webkit-transform:translateY(-4px);transform:translateY(-4px)}to{-webkit-transform:translateY(0);transform:translateY(0)}}.wobble{-webkit-animation-name:wobble;animation-name:wobble;-webkit-animation-duration:.4s;animation-duration:.4s}@-webkit-keyframes wobble{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}15%{-webkit-transform:translate3d(-9%,0,0);transform:translate3d(-9%,0,0)}30%{-webkit-transform:translate3d(9%,0,0);transform:translate3d(9%,0,0)}45%{-webkit-transform:translate3d(-4%,0,0);transform:translate3d(-4%,0,0)}60%{-webkit-transform:translate3d(4%,0,0);transform:translate3d(4%,0,0)}75%{-webkit-transform:translate3d(-1%,0,0);transform:translate3d(-1%,0,0)}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}@keyframes wobble{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}15%{-webkit-transform:translate3d(-9%,0,0);transform:translate3d(-9%,0,0)}30%{-webkit-transform:translate3d(9%,0,0);transform:translate3d(9%,0,0)}45%{-webkit-transform:translate3d(-4%,0,0);transform:translate3d(-4%,0,0)}60%{-webkit-transform:translate3d(4%,0,0);transform:translate3d(4%,0,0)}75%{-webkit-transform:translate3d(-1%,0,0);transform:translate3d(-1%,0,0)}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}.ce-popover-header{margin-bottom:8px;margin-top:4px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.ce-popover-header__text{font-size:18px;font-weight:600}.ce-popover-header__back-button{border:0;background:transparent;width:36px;height:36px;color:var(--color-text-primary)}.ce-popover-header__back-button svg{display:block;width:28px;height:28px}.ce-popover--inline{--height: 38px;--height-mobile: 46px;--container-padding: 4px;position:relative}.ce-popover--inline .ce-popover__custom-content{margin-bottom:0}.ce-popover--inline .ce-popover__items{display:-webkit-box;display:-ms-flexbox;display:flex}.ce-popover--inline .ce-popover__container{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;padding:var(--container-padding);height:var(--height);top:0;min-width:-webkit-max-content;min-width:-moz-max-content;min-width:max-content;width:-webkit-max-content;width:-moz-max-content;width:max-content;-webkit-animation:none;animation:none}@media (max-width: 650px){.ce-popover--inline .ce-popover__container{height:var(--height-mobile);position:absolute}}.ce-popover--inline .ce-popover-item-separator{padding:0 4px}.ce-popover--inline .ce-popover-item-separator__line{height:100%;width:1px}.ce-popover--inline .ce-popover-item{border-radius:4px;padding:4px}.ce-popover--inline .ce-popover-item__icon--tool{-webkit-box-shadow:none;box-shadow:none;background:transparent;margin-right:0}.ce-popover--inline .ce-popover-item__icon{width:auto;width:initial;height:auto;height:initial}.ce-popover--inline .ce-popover-item__icon svg{width:20px;height:20px}@media (max-width: 650px){.ce-popover--inline .ce-popover-item__icon svg{width:28px;height:28px}}.ce-popover--inline .ce-popover-item:not(:last-of-type){margin-bottom:0;margin-bottom:initial}.ce-popover--inline .ce-popover-item-html{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.ce-popover--inline .ce-popover-item__icon--chevron-right{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.ce-popover--inline .ce-popover--nested-level-1 .ce-popover__container{--offset: 3px;left:0;top:calc(var(--height) + var(--offset))}@media (max-width: 650px){.ce-popover--inline .ce-popover--nested-level-1 .ce-popover__container{top:calc(var(--height-mobile) + var(--offset))}}.ce-popover--inline .ce-popover--nested .ce-popover__container{min-width:var(--width);width:var(--width);height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;padding:6px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.ce-popover--inline .ce-popover--nested .ce-popover__items{display:block;width:100%}.ce-popover--inline .ce-popover--nested .ce-popover-item{border-radius:6px;padding:3px}@media (max-width: 650px){.ce-popover--inline .ce-popover--nested .ce-popover-item{padding:4px}}.ce-popover--inline .ce-popover--nested .ce-popover-item__icon--tool{margin-right:4px}.ce-popover--inline .ce-popover--nested .ce-popover-item__icon{width:26px;height:26px}.ce-popover--inline .ce-popover--nested .ce-popover-item-separator{padding:4px 3px}.ce-popover--inline .ce-popover--nested .ce-popover-item-separator__line{width:100%;height:1px}.codex-editor [data-placeholder]:empty:before,.codex-editor [data-placeholder][data-empty=true]:before{pointer-events:none;color:#707684;cursor:text;content:attr(data-placeholder)}.codex-editor [data-placeholder-active]:empty:before,.codex-editor [data-placeholder-active][data-empty=true]:before{pointer-events:none;color:#707684;cursor:text}.codex-editor [data-placeholder-active]:empty:focus:before,.codex-editor [data-placeholder-active][data-empty=true]:focus:before{content:attr(data-placeholder-active)}
|
|
227
|
-
`,oA=class extends ft{constructor(){super(...arguments),this.isMobile=!1,this.contentRectCache=null,this.resizeDebouncer=cY(()=>{this.windowResize()},200),this.selectionChangeDebounced=cY(()=>{this.selectionChanged()},PLe),this.documentTouchedListener=e=>{this.documentTouched(e)}}get CSS(){return{editorWrapper:"codex-editor",editorWrapperNarrow:"codex-editor--narrow",editorZone:"codex-editor__redactor",editorZoneHidden:"codex-editor__redactor--hidden",editorEmpty:"codex-editor--empty",editorRtlFix:"codex-editor--rtl"}}get contentRect(){if(this.contentRectCache!==null)return this.contentRectCache;let e=this.nodes.wrapper.querySelector(`.${Oa.CSS.content}`);return e?(this.contentRectCache=e.getBoundingClientRect(),this.contentRectCache):{width:650,left:0,right:0}}async prepare(){this.setIsMobile(),this.make(),this.loadStyles()}toggleReadOnly(e){e?this.unbindReadOnlySensitiveListeners():window.requestIdleCallback(()=>{this.bindReadOnlySensitiveListeners()},{timeout:2e3})}checkEmptiness(){let{BlockManager:e}=this.Editor;this.nodes.wrapper.classList.toggle(this.CSS.editorEmpty,e.isEditorEmpty)}get someToolbarOpened(){let{Toolbar:e,BlockSettings:r,InlineToolbar:o}=this.Editor;return!!(r.opened||o.opened||e.toolbox.opened)}get someFlipperButtonFocused(){return this.Editor.Toolbar.toolbox.hasFocus()?!0:Object.entries(this.Editor).filter(([e,r])=>r.flipper instanceof Zu).some(([e,r])=>r.flipper.hasFocus())}destroy(){this.nodes.holder.innerHTML="",this.unbindReadOnlyInsensitiveListeners()}closeAllToolbars(){let{Toolbar:e,BlockSettings:r,InlineToolbar:o}=this.Editor;r.close(),o.close(),e.toolbox.close()}setIsMobile(){let e=window.innerWidth<wY;e!==this.isMobile&&this.eventsDispatcher.emit(Rh,{isEnabled:this.isMobile}),this.isMobile=e}make(){this.nodes.holder=K.getHolder(this.config.holder),this.nodes.wrapper=K.make("div",[this.CSS.editorWrapper,...this.isRtl?[this.CSS.editorRtlFix]:[]]),this.nodes.redactor=K.make("div",this.CSS.editorZone),this.nodes.holder.offsetWidth<this.contentRect.width&&this.nodes.wrapper.classList.add(this.CSS.editorWrapperNarrow),this.nodes.redactor.style.paddingBottom=this.config.minHeight+"px",this.nodes.wrapper.appendChild(this.nodes.redactor),this.nodes.holder.appendChild(this.nodes.wrapper),this.bindReadOnlyInsensitiveListeners()}loadStyles(){let e="editor-js-styles";if(K.get(e))return;let r=K.make("style",null,{id:e,textContent:zLe.toString()});this.config.style&&!ua(this.config.style)&&this.config.style.nonce&&r.setAttribute("nonce",this.config.style.nonce),K.prepend(document.head,r)}bindReadOnlyInsensitiveListeners(){this.listeners.on(document,"selectionchange",this.selectionChangeDebounced),this.listeners.on(window,"resize",this.resizeDebouncer,{passive:!0}),this.listeners.on(this.nodes.redactor,"mousedown",this.documentTouchedListener,{capture:!0,passive:!0}),this.listeners.on(this.nodes.redactor,"touchstart",this.documentTouchedListener,{capture:!0,passive:!0})}unbindReadOnlyInsensitiveListeners(){this.listeners.off(document,"selectionchange",this.selectionChangeDebounced),this.listeners.off(window,"resize",this.resizeDebouncer),this.listeners.off(this.nodes.redactor,"mousedown",this.documentTouchedListener),this.listeners.off(this.nodes.redactor,"touchstart",this.documentTouchedListener)}bindReadOnlySensitiveListeners(){this.readOnlyMutableListeners.on(this.nodes.redactor,"click",e=>{this.redactorClicked(e)},!1),this.readOnlyMutableListeners.on(document,"keydown",e=>{this.documentKeydown(e)},!0),this.readOnlyMutableListeners.on(document,"mousedown",e=>{this.documentClicked(e)},!0),this.watchBlockHoveredEvents(),this.enableInputsEmptyMark()}watchBlockHoveredEvents(){let e;this.readOnlyMutableListeners.on(this.nodes.redactor,"mousemove",iD(r=>{let o=r.target.closest(".ce-block");this.Editor.BlockSelection.anyBlockSelected||o&&e!==o&&(e=o,this.eventsDispatcher.emit(jY,{block:this.Editor.BlockManager.getBlockByChildNode(o)}))},20),{passive:!0})}unbindReadOnlySensitiveListeners(){this.readOnlyMutableListeners.clearAll()}windowResize(){this.contentRectCache=null,this.setIsMobile()}documentKeydown(e){switch(e.keyCode){case Ye.ENTER:this.enterPressed(e);break;case Ye.BACKSPACE:case Ye.DELETE:this.backspacePressed(e);break;case Ye.ESC:this.escapePressed(e);break;default:this.defaultBehaviour(e);break}}defaultBehaviour(e){let{currentBlock:r}=this.Editor.BlockManager,o=e.target.closest(`.${this.CSS.editorWrapper}`),n=e.altKey||e.ctrlKey||e.metaKey||e.shiftKey;if(r!==void 0&&o===null){this.Editor.BlockEvents.keydown(e);return}o||r&&n||(this.Editor.BlockManager.unsetCurrentBlock(),this.Editor.Toolbar.close())}backspacePressed(e){let{BlockManager:r,BlockSelection:o,Caret:n}=this.Editor;if(o.anyBlockSelected&&!ze.isSelectionExists){let a=r.removeSelectedBlocks(),i=r.insertDefaultBlockAtIndex(a,!0);n.setToBlock(i,n.positions.START),o.clearSelection(e),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}}escapePressed(e){this.Editor.BlockSelection.clearSelection(e),this.Editor.Toolbar.toolbox.opened?(this.Editor.Toolbar.toolbox.close(),this.Editor.Caret.setToBlock(this.Editor.BlockManager.currentBlock,this.Editor.Caret.positions.END)):this.Editor.BlockSettings.opened?this.Editor.BlockSettings.close():this.Editor.InlineToolbar.opened?this.Editor.InlineToolbar.close():this.Editor.Toolbar.close()}enterPressed(e){let{BlockManager:r,BlockSelection:o}=this.Editor;if(this.someToolbarOpened)return;let n=r.currentBlockIndex>=0;if(o.anyBlockSelected&&!ze.isSelectionExists){o.clearSelection(e),e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation();return}if(!this.someToolbarOpened&&n&&e.target.tagName==="BODY"){let a=this.Editor.BlockManager.insert();e.preventDefault(),this.Editor.Caret.setToBlock(a),this.Editor.Toolbar.moveAndOpen(a)}this.Editor.BlockSelection.clearSelection(e)}documentClicked(e){var r,o;if(!e.isTrusted)return;let n=e.target;this.nodes.holder.contains(n)||ze.isAtEditor||(this.Editor.BlockManager.unsetCurrentBlock(),this.Editor.Toolbar.close());let a=(r=this.Editor.BlockSettings.nodes.wrapper)==null?void 0:r.contains(n),i=(o=this.Editor.Toolbar.nodes.settingsToggler)==null?void 0:o.contains(n),s=a||i;if(this.Editor.BlockSettings.opened&&!s){this.Editor.BlockSettings.close();let l=this.Editor.BlockManager.getBlockByChildNode(n);this.Editor.Toolbar.moveAndOpen(l)}this.Editor.BlockSelection.clearSelection(e)}documentTouched(e){let r=e.target;if(r===this.nodes.redactor){let o=e instanceof MouseEvent?e.clientX:e.touches[0].clientX,n=e instanceof MouseEvent?e.clientY:e.touches[0].clientY;r=document.elementFromPoint(o,n)}try{this.Editor.BlockManager.setCurrentBlockByChildNode(r)}catch{this.Editor.RectangleSelection.isRectActivated()||this.Editor.Caret.setToTheLastBlock()}this.Editor.ReadOnly.isEnabled||this.Editor.Toolbar.moveAndOpen()}redactorClicked(e){if(!ze.isCollapsed)return;let r=e.target,o=e.metaKey||e.ctrlKey;if(K.isAnchor(r)&&o){e.stopImmediatePropagation(),e.stopPropagation();let n=r.getAttribute("href"),a=JRe(n);tMe(a);return}this.processBottomZoneClick(e)}processBottomZoneClick(e){let r=this.Editor.BlockManager.getBlockByIndex(-1),o=K.offset(r.holder).bottom,n=e.pageY,{BlockSelection:a}=this.Editor;if(e.target instanceof Element&&e.target.isEqualNode(this.nodes.redactor)&&!a.anyBlockSelected&&o<n){e.stopImmediatePropagation(),e.stopPropagation();let{BlockManager:i,Caret:s,Toolbar:l}=this.Editor;(!i.lastBlock.tool.isDefault||!i.lastBlock.isEmpty)&&i.insertAtEnd(),s.setToTheLastBlock(),l.moveAndOpen(i.lastBlock)}}selectionChanged(){let{CrossBlockSelection:e,BlockSelection:r}=this.Editor,o=ze.anchorElement;if(e.isCrossBlockSelectionStarted&&r.anyBlockSelected&&ze.get().removeAllRanges(),!o){ze.range||this.Editor.InlineToolbar.close();return}let n=o.closest(`.${Oa.CSS.content}`);(n===null||n.closest(`.${ze.CSS.editorWrapper}`)!==this.nodes.wrapper)&&(this.Editor.InlineToolbar.containsNode(o)||this.Editor.InlineToolbar.close(),o.dataset.inlineToolbar!=="true")||(this.Editor.BlockManager.currentBlock||this.Editor.BlockManager.setCurrentBlockByChildNode(o),this.Editor.InlineToolbar.tryToShow(!0))}enableInputsEmptyMark(){function e(r){let o=r.target;EY(o)}this.readOnlyMutableListeners.on(this.nodes.wrapper,"input",e),this.readOnlyMutableListeners.on(this.nodes.wrapper,"focusin",e),this.readOnlyMutableListeners.on(this.nodes.wrapper,"focusout",e)}},ULe={BlocksAPI:fD,CaretAPI:pD,EventsAPI:mD,I18nAPI:hD,API:gD,InlineToolbarAPI:_D,ListenersAPI:xD,NotifierAPI:vD,ReadOnlyAPI:yD,SanitizerAPI:ID,SaverAPI:wD,SelectionAPI:ED,ToolsAPI:SD,StylesAPI:CD,ToolbarAPI:kD,TooltipAPI:TD,UiAPI:PD,BlockSettings:MD,Toolbar:BD,InlineToolbar:zD,BlockEvents:VD,BlockManager:HD,BlockSelection:jD,Caret:qD,CrossBlockSelection:GD,DragNDrop:WD,ModificationsObserver:KD,Paste:DLe,ReadOnly:YD,RectangleSelection:XD,Renderer:QD,Saver:ZD,Tools:YI,UI:oA},nA=class{constructor(e){this.moduleInstances={},this.eventsDispatcher=new Oc;let r,o;this.isReady=new Promise((n,a)=>{r=n,o=a}),Promise.resolve().then(async()=>{this.configuration=e,this.validate(),this.init(),await this.start(),await this.render();let{BlockManager:n,Caret:a,UI:i,ModificationsObserver:s}=this.moduleInstances;i.checkEmptiness(),s.enable(),this.configuration.autofocus===!0&&this.configuration.readOnly!==!0&&a.setToBlock(n.blocks[0],a.positions.START),r()}).catch(n=>{At(`Editor.js is not ready because of ${n}`,"error"),o(n)})}set configuration(e){var r,o;bo(e)?this.config={...e}:this.config={holder:e},lD(!!this.config.holderId,"config.holderId","config.holder"),this.config.holderId&&!this.config.holder&&(this.config.holder=this.config.holderId,this.config.holderId=null),this.config.holder==null&&(this.config.holder="editorjs"),this.config.logLevel||(this.config.logLevel=vY.VERBOSE),WRe(this.config.logLevel),lD(!!this.config.initialBlock,"config.initialBlock","config.defaultBlock"),this.config.defaultBlock=this.config.defaultBlock||this.config.initialBlock||"paragraph",this.config.minHeight=this.config.minHeight!==void 0?this.config.minHeight:300;let n={type:this.config.defaultBlock,data:{}};this.config.placeholder=this.config.placeholder||!1,this.config.sanitizer=this.config.sanitizer||{p:!0,b:!0,a:!0},this.config.hideToolbar=this.config.hideToolbar?this.config.hideToolbar:!1,this.config.tools=this.config.tools||{},this.config.i18n=this.config.i18n||{},this.config.data=this.config.data||{blocks:[]},this.config.onReady=this.config.onReady||(()=>{}),this.config.onChange=this.config.onChange||(()=>{}),this.config.inlineToolbar=this.config.inlineToolbar!==void 0?this.config.inlineToolbar:!0,(ua(this.config.data)||!this.config.data.blocks||this.config.data.blocks.length===0)&&(this.config.data={blocks:[n]}),this.config.readOnly=this.config.readOnly||!1,(r=this.config.i18n)!=null&&r.messages&&Zo.setDictionary(this.config.i18n.messages),this.config.i18n.direction=((o=this.config.i18n)==null?void 0:o.direction)||"ltr"}get configuration(){return this.config}validate(){let{holderId:e,holder:r}=this.config;if(e&&r)throw Error("\xABholderId\xBB and \xABholder\xBB param can't assign at the same time.");if(zi(r)&&!K.get(r))throw Error(`element with ID \xAB${r}\xBB is missing. Pass correct holder's ID.`);if(r&&bo(r)&&!K.isElement(r))throw Error("\xABholder\xBB value must be an Element node")}init(){this.constructModules(),this.configureModules()}async start(){await["Tools","UI","BlockManager","Paste","BlockSelection","RectangleSelection","CrossBlockSelection","ReadOnly"].reduce((e,r)=>e.then(async()=>{try{await this.moduleInstances[r].prepare()}catch(o){if(o instanceof MI)throw new Error(o.message);At(`Module ${r} was skipped because of %o`,"warn",o)}}),Promise.resolve())}render(){return this.moduleInstances.Renderer.render(this.config.data.blocks)}constructModules(){Object.entries(ULe).forEach(([e,r])=>{try{this.moduleInstances[e]=new r({config:this.configuration,eventsDispatcher:this.eventsDispatcher})}catch(o){At("[constructModules]",`Module ${e} skipped because`,"error",o)}})}configureModules(){for(let e in this.moduleInstances)Object.prototype.hasOwnProperty.call(this.moduleInstances,e)&&(this.moduleInstances[e].state=this.getModulesDiff(e))}getModulesDiff(e){let r={};for(let o in this.moduleInstances)o!==e&&(r[o]=this.moduleInstances[o]);return r}};var XI=class{static get version(){return"2.31.0-rc.7"}constructor(e){let r=()=>{};bo(e)&&rr(e.onReady)&&(r=e.onReady);let o=new nA(e);this.isReady=o.isReady.then(()=>{this.exportAPI(o),r()})}exportAPI(e){let r=["configuration"],o=()=>{Object.values(e.moduleInstances).forEach(n=>{rr(n.destroy)&&n.destroy(),n.listeners.removeAll()}),EMe(),e=null;for(let n in this)Object.prototype.hasOwnProperty.call(this,n)&&delete this[n];Object.setPrototypeOf(this,null)};r.forEach(n=>{this[n]=e[n]}),this.destroy=o,Object.setPrototypeOf(this,e.moduleInstances.API.methods),delete this.exportAPI,Object.entries({blocks:{clear:"clear",render:"render"},caret:{focus:"focus"},events:{on:"on",off:"off",emit:"emit"},saver:{save:"save"}}).forEach(([n,a])=>{Object.entries(a).forEach(([i,s])=>{this[s]=e.moduleInstances.API.methods[n][i]})})}};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ce-header{padding:.6em 0 3px;margin:0;line-height:1.25em;outline:none}.ce-header p,.ce-header div{padding:0!important;margin:0!important}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var VLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M19 17V10.2135C19 10.1287 18.9011 10.0824 18.836 10.1367L16 12.5"/></svg>',$Le='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 11C16 10 19 9.5 19 12C19 13.9771 16.0684 13.9997 16.0012 16.8981C15.9999 16.9533 16.0448 17 16.1 17L19.3 17"/></svg>',HLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 11C16 10.5 16.8323 10 17.6 10C18.3677 10 19.5 10.311 19.5 11.5C19.5 12.5315 18.7474 12.9022 18.548 12.9823C18.5378 12.9864 18.5395 13.0047 18.5503 13.0063C18.8115 13.0456 20 13.3065 20 14.8C20 16 19.5 17 17.8 17C17.8 17 16 17 16 16.3"/></svg>',jLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M18 10L15.2834 14.8511C15.246 14.9178 15.294 15 15.3704 15C16.8489 15 18.7561 15 20.2 15M19 17C19 15.7187 19 14.8813 19 13.6"/></svg>',qLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 15.9C16 15.9 16.3768 17 17.8 17C19.5 17 20 15.6199 20 14.7C20 12.7323 17.6745 12.0486 16.1635 12.9894C16.094 13.0327 16 12.9846 16 12.9027V10.1C16 10.0448 16.0448 10 16.1 10H19.8"/></svg>',GLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M19.5 10C16.5 10.5 16 13.3285 16 15M16 15V15C16 16.1046 16.8954 17 18 17H18.3246C19.3251 17 20.3191 16.3492 20.2522 15.3509C20.0612 12.4958 16 12.6611 16 15Z"/></svg>',WLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9 7L9 12M9 17V12M9 12L15 12M15 7V12M15 17L15 12"/></svg>';var iw=class{constructor({data:e,config:r,api:o,readOnly:n}){this.api=o,this.readOnly=n,this._settings=r,this._data=this.normalizeData(e),this._element=this.getTag()}get _CSS(){return{block:this.api.styles.block,wrapper:"ce-header"}}isHeaderData(e){return e.text!==void 0}normalizeData(e){let r={text:"",level:this.defaultLevel.number};return this.isHeaderData(e)&&(r.text=e.text||"",e.level!==void 0&&!isNaN(parseInt(e.level.toString()))&&(r.level=parseInt(e.level.toString()))),r}render(){return this._element}renderSettings(){return this.levels.map(e=>({icon:e.svg,label:this.api.i18n.t(`Heading ${e.number}`),onActivate:()=>this.setLevel(e.number),closeOnActivate:!0,isActive:this.currentLevel.number===e.number,render:()=>document.createElement("div")}))}setLevel(e){this.data={level:e,text:this.data.text}}merge(e){this._element.insertAdjacentHTML("beforeend",e.text)}validate(e){return e.text.trim()!==""}save(e){return{text:e.innerHTML,level:this.currentLevel.number}}static get conversionConfig(){return{export:"text",import:"text"}}static get sanitize(){return{level:!1,text:{}}}static get isReadOnlySupported(){return!0}get data(){return this._data.text=this._element.innerHTML,this._data.level=this.currentLevel.number,this._data}set data(e){if(this._data=this.normalizeData(e),e.level!==void 0&&this._element.parentNode){let r=this.getTag();r.innerHTML=this._element.innerHTML,this._element.parentNode.replaceChild(r,this._element),this._element=r}e.text!==void 0&&(this._element.innerHTML=this._data.text||"")}getTag(){let e=document.createElement(this.currentLevel.tag);return e.innerHTML=this._data.text||"",e.classList.add(this._CSS.wrapper),e.contentEditable=this.readOnly?"false":"true",e.dataset.placeholder=this.api.i18n.t(this._settings.placeholder||""),e}get currentLevel(){let e=this.levels.find(r=>r.number===this._data.level);return e||(e=this.defaultLevel),e}get defaultLevel(){if(this._settings.defaultLevel){let e=this.levels.find(r=>r.number===this._settings.defaultLevel);if(e)return e;console.warn("(\u0E07'\u0300-'\u0301)\u0E07 Heading Tool: the default level specified was not found in available levels")}return this.levels[1]}get levels(){let e=[{number:1,tag:"H1",svg:VLe},{number:2,tag:"H2",svg:$Le},{number:3,tag:"H3",svg:HLe},{number:4,tag:"H4",svg:jLe},{number:5,tag:"H5",svg:qLe},{number:6,tag:"H6",svg:GLe}];return this._settings.levels?e.filter(r=>this._settings.levels.includes(r.number)):e}onPaste(e){let r=e.detail;if("data"in r){let o=r.data,n=this.defaultLevel.number;switch(o.tagName){case"H1":n=1;break;case"H2":n=2;break;case"H3":n=3;break;case"H4":n=4;break;case"H5":n=5;break;case"H6":n=6;break}this._settings.levels&&(n=this._settings.levels.reduce((a,i)=>Math.abs(i-n)<Math.abs(a-n)?i:a)),this.data={level:n,text:o.innerHTML}}}static get pasteConfig(){return{tags:["H1","H2","H3","H4","H5","H6"]}}static get toolbox(){return{icon:WLe,title:"Heading"}}};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.image-tool{--bg-color: #cdd1e0;--front-color: #388ae5;--border-color: #e8e8eb}.image-tool__image{border-radius:3px;overflow:hidden;margin-bottom:10px;padding-bottom:0}.image-tool__image-picture{max-width:100%;vertical-align:bottom;display:block}.image-tool__image-preloader{width:50px;height:50px;border-radius:50%;background-size:cover;margin:auto;position:relative;background-color:var(--bg-color);background-position:center center}.image-tool__image-preloader:after{content:"";position:absolute;z-index:3;width:60px;height:60px;border-radius:50%;border:2px solid var(--bg-color);border-top-color:var(--front-color);left:50%;top:50%;margin-top:-30px;margin-left:-30px;animation:image-preloader-spin 2s infinite linear;box-sizing:border-box}.image-tool__caption{visibility:hidden;position:absolute;bottom:0;left:0;margin-bottom:10px}.image-tool__caption[contentEditable=true][data-placeholder]:before{position:absolute!important;content:attr(data-placeholder);color:#707684;font-weight:400;display:none}.image-tool__caption[contentEditable=true][data-placeholder]:empty:before{display:block}.image-tool__caption[contentEditable=true][data-placeholder]:empty:focus:before{display:none}.image-tool--empty .image-tool__image,.image-tool--empty .image-tool__image-preloader{display:none}.image-tool--empty .image-tool__caption,.image-tool--uploading .image-tool__caption{visibility:hidden!important}.image-tool .cdx-button{display:flex;align-items:center;justify-content:center}.image-tool .cdx-button svg{height:auto;margin:0 6px 0 0}.image-tool--filled .cdx-button,.image-tool--filled .image-tool__image-preloader{display:none}.image-tool--uploading .image-tool__image{min-height:200px;display:flex;border:1px solid var(--border-color);background-color:#fff}.image-tool--uploading .image-tool__image-picture,.image-tool--uploading .cdx-button{display:none}.image-tool--withBorder .image-tool__image{border:1px solid var(--border-color)}.image-tool--withBackground .image-tool__image{padding:15px;background:var(--bg-color)}.image-tool--withBackground .image-tool__image-picture{max-width:60%;margin:0 auto}.image-tool--stretched .image-tool__image-picture{width:100%}.image-tool--caption .image-tool__caption{visibility:visible}.image-tool--caption{padding-bottom:50px}@keyframes image-preloader-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var KLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 19V19C9.13623 19 8.20435 19 7.46927 18.6955C6.48915 18.2895 5.71046 17.5108 5.30448 16.5307C5 15.7956 5 14.8638 5 13V12C5 9.19108 5 7.78661 5.67412 6.77772C5.96596 6.34096 6.34096 5.96596 6.77772 5.67412C7.78661 5 9.19108 5 12 5H13.5C14.8956 5 15.5933 5 16.1611 5.17224C17.4395 5.56004 18.44 6.56046 18.8278 7.83886C19 8.40666 19 9.10444 19 10.5V10.5"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 13V16M16 19V16M19 16H16M16 16H13"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6.5 17.5L17.5 6.5"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.9919 10.5H19.0015"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.9919 19H11.0015"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13L13 5"/></svg>',YLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.9919 9.5H19.0015"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.5 5H14.5096"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M14.625 5H15C17.2091 5 19 6.79086 19 9V9.375"/><path stroke="currentColor" stroke-width="2" d="M9.375 5L9 5C6.79086 5 5 6.79086 5 9V9.375"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.3725 5H9.38207"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 9.5H5.00957"/><path stroke="currentColor" stroke-width="2" d="M9.375 19H9C6.79086 19 5 17.2091 5 15V14.625"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.3725 19H9.38207"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 14.55H5.00957"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 13V16M16 19V16M19 16H16M16 16H13"/></svg>',yX='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" stroke="currentColor" stroke-width="2" rx="4"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.13968 15.32L8.69058 11.5661C9.02934 11.2036 9.48873 11 9.96774 11C10.4467 11 10.9061 11.2036 11.2449 11.5661L15.3871 16M13.5806 14.0664L15.0132 12.533C15.3519 12.1705 15.8113 11.9668 16.2903 11.9668C16.7693 11.9668 17.2287 12.1705 17.5675 12.533L18.841 13.9634"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.7778 9.33331H13.7867"/></svg>',XLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 9L20 12L17 15"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 12H20"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 9L4 12L7 15"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 12H10"/></svg>',QLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8 9V7.2C8 7.08954 8.08954 7 8.2 7L12 7M16 9V7.2C16 7.08954 15.9105 7 15.8 7L12 7M12 7L12 17M12 17H10M12 17H14"/></svg>';function rf(t,e=null,r={}){let o=document.createElement(t);Array.isArray(e)?o.classList.add(...e):e!==null&&o.classList.add(e);for(let n in r)r.hasOwnProperty(n)&&(o[n]=r[n]);return o}var sw=(t=>(t.Empty="empty",t.Uploading="uploading",t.Filled="filled",t))(sw||{}),ZA=class{constructor({api:e,config:r,onSelectFile:o,readOnly:n}){this.api=e,this.config=r,this.onSelectFile=o,this.readOnly=n,this.nodes={wrapper:rf("div",[this.CSS.baseClass,this.CSS.wrapper]),imageContainer:rf("div",[this.CSS.imageContainer]),fileButton:this.createFileButton(),imageEl:void 0,imagePreloader:rf("div",this.CSS.imagePreloader),caption:rf("div",[this.CSS.input,this.CSS.caption],{contentEditable:!this.readOnly})},this.nodes.caption.dataset.placeholder=this.config.captionPlaceholder,this.nodes.imageContainer.appendChild(this.nodes.imagePreloader),this.nodes.wrapper.appendChild(this.nodes.imageContainer),this.nodes.wrapper.appendChild(this.nodes.caption),this.nodes.wrapper.appendChild(this.nodes.fileButton)}applyTune(e,r){this.nodes.wrapper.classList.toggle(`${this.CSS.wrapper}--${e}`,r)}render(){return this.toggleStatus("empty"),this.nodes.wrapper}showPreloader(e){this.nodes.imagePreloader.style.backgroundImage=`url(${e})`,this.toggleStatus("uploading")}hidePreloader(){this.nodes.imagePreloader.style.backgroundImage="",this.toggleStatus("empty")}fillImage(e){let r=/\.mp4$/.test(e)?"VIDEO":"IMG",o={src:e},n="load";r==="VIDEO"&&(o.autoplay=!0,o.loop=!0,o.muted=!0,o.playsinline=!0,n="loadeddata"),this.nodes.imageEl=rf(r,this.CSS.imageEl,o),this.nodes.imageEl.addEventListener(n,()=>{this.toggleStatus("filled"),this.nodes.imagePreloader!==void 0&&(this.nodes.imagePreloader.style.backgroundImage="")}),this.nodes.imageContainer.appendChild(this.nodes.imageEl)}fillCaption(e){this.nodes.caption!==void 0&&(this.nodes.caption.innerHTML=e)}toggleStatus(e){for(let r in sw)if(Object.prototype.hasOwnProperty.call(sw,r)){let o=sw[r];this.nodes.wrapper.classList.toggle(`${this.CSS.wrapper}--${o}`,o===e)}}get CSS(){return{baseClass:this.api.styles.block,loading:this.api.styles.loader,input:this.api.styles.input,button:this.api.styles.button,wrapper:"image-tool",imageContainer:"image-tool__image",imagePreloader:"image-tool__image-preloader",imageEl:"image-tool__image-picture",caption:"image-tool__caption"}}createFileButton(){let e=rf("div",[this.CSS.button]);return e.innerHTML=this.config.buttonContent??`${yX} ${this.api.i18n.t("Select an Image")}`,e.addEventListener("click",()=>{this.onSelectFile()}),e}};function ZLe(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var IX={exports:{}};(function(t,e){(function(r,o){t.exports=o()})(window,function(){return function(r){var o={};function n(a){if(o[a])return o[a].exports;var i=o[a]={i:a,l:!1,exports:{}};return r[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=r,n.c=o,n.d=function(a,i,s){n.o(a,i)||Object.defineProperty(a,i,{enumerable:!0,get:s})},n.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},n.t=function(a,i){if(1&i&&(a=n(a)),8&i||4&i&&typeof a=="object"&&a&&a.__esModule)return a;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:a}),2&i&&typeof a!="string")for(var l in a)n.d(s,l,function(c){return a[c]}.bind(null,l));return s},n.n=function(a){var i=a&&a.__esModule?function(){return a.default}:function(){return a};return n.d(i,"a",i),i},n.o=function(a,i){return Object.prototype.hasOwnProperty.call(a,i)},n.p="",n(n.s=3)}([function(r,o){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch{typeof window=="object"&&(n=window)}r.exports=n},function(r,o,n){(function(a){var i=n(2),s=setTimeout;function l(){}function c(_){if(!(this instanceof c))throw new TypeError("Promises must be constructed via new");if(typeof _!="function")throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],g(_,this)}function d(_,x){for(;_._state===3;)_=_._value;_._state!==0?(_._handled=!0,c._immediateFn(function(){var b=_._state===1?x.onFulfilled:x.onRejected;if(b!==null){var v;try{v=b(_._value)}catch(I){return void p(x.promise,I)}u(x.promise,v)}else(_._state===1?u:p)(x.promise,_._value)})):_._deferreds.push(x)}function u(_,x){try{if(x===_)throw new TypeError("A promise cannot be resolved with itself.");if(x&&(typeof x=="object"||typeof x=="function")){var b=x.then;if(x instanceof c)return _._state=3,_._value=x,void m(_);if(typeof b=="function")return void g((v=b,I=x,function(){v.apply(I,arguments)}),_)}_._state=1,_._value=x,m(_)}catch(E){p(_,E)}var v,I}function p(_,x){_._state=2,_._value=x,m(_)}function m(_){_._state===2&&_._deferreds.length===0&&c._immediateFn(function(){_._handled||c._unhandledRejectionFn(_._value)});for(var x=0,b=_._deferreds.length;x<b;x++)d(_,_._deferreds[x]);_._deferreds=null}function h(_,x,b){this.onFulfilled=typeof _=="function"?_:null,this.onRejected=typeof x=="function"?x:null,this.promise=b}function g(_,x){var b=!1;try{_(function(v){b||(b=!0,u(x,v))},function(v){b||(b=!0,p(x,v))})}catch(v){if(b)return;b=!0,p(x,v)}}c.prototype.catch=function(_){return this.then(null,_)},c.prototype.then=function(_,x){var b=new this.constructor(l);return d(this,new h(_,x,b)),b},c.prototype.finally=i.a,c.all=function(_){return new c(function(x,b){if(!_||_.length===void 0)throw new TypeError("Promise.all accepts an array");var v=Array.prototype.slice.call(_);if(v.length===0)return x([]);var I=v.length;function E(C,T){try{if(T&&(typeof T=="object"||typeof T=="function")){var k=T.then;if(typeof k=="function")return void k.call(T,function(S){E(C,S)},b)}v[C]=T,--I==0&&x(v)}catch(S){b(S)}}for(var y=0;y<v.length;y++)E(y,v[y])})},c.resolve=function(_){return _&&typeof _=="object"&&_.constructor===c?_:new c(function(x){x(_)})},c.reject=function(_){return new c(function(x,b){b(_)})},c.race=function(_){return new c(function(x,b){for(var v=0,I=_.length;v<I;v++)_[v].then(x,b)})},c._immediateFn=typeof a=="function"&&function(_){a(_)}||function(_){s(_,0)},c._unhandledRejectionFn=function(_){typeof console<"u"&&console&&console.warn("Possible Unhandled Promise Rejection:",_)},o.a=c}).call(this,n(5).setImmediate)},function(r,o,n){o.a=function(a){var i=this.constructor;return this.then(function(s){return i.resolve(a()).then(function(){return s})},function(s){return i.resolve(a()).then(function(){return i.reject(s)})})}},function(r,o,n){function a(g){return(a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _})(g)}n(4);var i,s,l,c,d,u,p,m=n(8),h=(s=function(g){return new Promise(function(_,x){g=c(g),(g=d(g)).beforeSend&&g.beforeSend();var b=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");b.open(g.method,g.url),b.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(g.headers).forEach(function(I){var E=g.headers[I];b.setRequestHeader(I,E)});var v=g.ratio;b.upload.addEventListener("progress",function(I){var E=Math.round(I.loaded/I.total*100),y=Math.ceil(E*v/100);g.progress(Math.min(y,100))},!1),b.addEventListener("progress",function(I){var E=Math.round(I.loaded/I.total*100),y=Math.ceil(E*(100-v)/100)+v;g.progress(Math.min(y,100))},!1),b.onreadystatechange=function(){if(b.readyState===4){var I=b.response;try{I=JSON.parse(I)}catch{}var E=m.parseHeaders(b.getAllResponseHeaders()),y={body:I,code:b.status,headers:E};p(b.status)?_(y):x(y)}},b.send(g.data)})},l=function(g){return g.method="POST",s(g)},c=function(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(g.url&&typeof g.url!="string")throw new Error("Url must be a string");if(g.url=g.url||"",g.method&&typeof g.method!="string")throw new Error("`method` must be a string or null");if(g.method=g.method?g.method.toUpperCase():"GET",g.headers&&a(g.headers)!=="object")throw new Error("`headers` must be an object or null");if(g.headers=g.headers||{},g.type&&(typeof g.type!="string"||!Object.values(i).includes(g.type)))throw new Error("`type` must be taken from module's \xABcontentType\xBB library");if(g.progress&&typeof g.progress!="function")throw new Error("`progress` must be a function or null");if(g.progress=g.progress||function(_){},g.beforeSend=g.beforeSend||function(_){},g.ratio&&typeof g.ratio!="number")throw new Error("`ratio` must be a number");if(g.ratio<0||g.ratio>100)throw new Error("`ratio` must be in a 0-100 interval");if(g.ratio=g.ratio||90,g.accept&&typeof g.accept!="string")throw new Error("`accept` must be a string with a list of allowed mime-types");if(g.accept=g.accept||"*/*",g.multiple&&typeof g.multiple!="boolean")throw new Error("`multiple` must be a true or false");if(g.multiple=g.multiple||!1,g.fieldName&&typeof g.fieldName!="string")throw new Error("`fieldName` must be a string");return g.fieldName=g.fieldName||"files",g},d=function(g){switch(g.method){case"GET":var _=u(g.data,i.URLENCODED);delete g.data,g.url=/\?/.test(g.url)?g.url+"&"+_:g.url+"?"+_;break;case"POST":case"PUT":case"DELETE":case"UPDATE":var x=function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).type||i.JSON}(g);(m.isFormData(g.data)||m.isFormElement(g.data))&&(x=i.FORM),g.data=u(g.data,x),x!==h.contentType.FORM&&(g.headers["content-type"]=x)}return g},u=function(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};switch(arguments.length>1?arguments[1]:void 0){case i.URLENCODED:return m.urlEncode(g);case i.JSON:return m.jsonEncode(g);case i.FORM:return m.formEncode(g);default:return g}},p=function(g){return g>=200&&g<300},{contentType:i={URLENCODED:"application/x-www-form-urlencoded; charset=utf-8",FORM:"multipart/form-data",JSON:"application/json; charset=utf-8"},request:s,get:function(g){return g.method="GET",s(g)},post:l,transport:function(g){return g=c(g),m.selectFiles(g).then(function(_){for(var x=new FormData,b=0;b<_.length;b++)x.append(g.fieldName,_[b],_[b].name);m.isObject(g.data)&&Object.keys(g.data).forEach(function(I){var E=g.data[I];x.append(I,E)});var v=g.beforeSend;return g.beforeSend=function(){return v(_)},g.data=x,l(g)})},selectFiles:function(g){return delete(g=c(g)).beforeSend,m.selectFiles(g)}});r.exports=h},function(r,o,n){n.r(o);var a=n(1);window.Promise=window.Promise||a.a},function(r,o,n){(function(a){var i=a!==void 0&&a||typeof self<"u"&&self||window,s=Function.prototype.apply;function l(c,d){this._id=c,this._clearFn=d}o.setTimeout=function(){return new l(s.call(setTimeout,i,arguments),clearTimeout)},o.setInterval=function(){return new l(s.call(setInterval,i,arguments),clearInterval)},o.clearTimeout=o.clearInterval=function(c){c&&c.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(i,this._id)},o.enroll=function(c,d){clearTimeout(c._idleTimeoutId),c._idleTimeout=d},o.unenroll=function(c){clearTimeout(c._idleTimeoutId),c._idleTimeout=-1},o._unrefActive=o.active=function(c){clearTimeout(c._idleTimeoutId);var d=c._idleTimeout;d>=0&&(c._idleTimeoutId=setTimeout(function(){c._onTimeout&&c._onTimeout()},d))},n(6),o.setImmediate=typeof self<"u"&&self.setImmediate||a!==void 0&&a.setImmediate||this&&this.setImmediate,o.clearImmediate=typeof self<"u"&&self.clearImmediate||a!==void 0&&a.clearImmediate||this&&this.clearImmediate}).call(this,n(0))},function(r,o,n){(function(a,i){(function(s,l){if(!s.setImmediate){var c,d,u,p,m,h=1,g={},_=!1,x=s.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(s);b=b&&b.setTimeout?b:s,{}.toString.call(s.process)==="[object process]"?c=function(E){i.nextTick(function(){I(E)})}:function(){if(s.postMessage&&!s.importScripts){var E=!0,y=s.onmessage;return s.onmessage=function(){E=!1},s.postMessage("","*"),s.onmessage=y,E}}()?(p="setImmediate$"+Math.random()+"$",m=function(E){E.source===s&&typeof E.data=="string"&&E.data.indexOf(p)===0&&I(+E.data.slice(p.length))},s.addEventListener?s.addEventListener("message",m,!1):s.attachEvent("onmessage",m),c=function(E){s.postMessage(p+E,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(E){I(E.data)},c=function(E){u.port2.postMessage(E)}):x&&"onreadystatechange"in x.createElement("script")?(d=x.documentElement,c=function(E){var y=x.createElement("script");y.onreadystatechange=function(){I(E),y.onreadystatechange=null,d.removeChild(y),y=null},d.appendChild(y)}):c=function(E){setTimeout(I,0,E)},b.setImmediate=function(E){typeof E!="function"&&(E=new Function(""+E));for(var y=new Array(arguments.length-1),C=0;C<y.length;C++)y[C]=arguments[C+1];var T={callback:E,args:y};return g[h]=T,c(h),h++},b.clearImmediate=v}function v(E){delete g[E]}function I(E){if(_)setTimeout(I,0,E);else{var y=g[E];if(y){_=!0;try{(function(C){var T=C.callback,k=C.args;switch(k.length){case 0:T();break;case 1:T(k[0]);break;case 2:T(k[0],k[1]);break;case 3:T(k[0],k[1],k[2]);break;default:T.apply(l,k)}})(y)}finally{v(E),_=!1}}}}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,n(0),n(7))},function(r,o){var n,a,i=r.exports={};function s(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function c(b){if(n===setTimeout)return setTimeout(b,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(b,0);try{return n(b,0)}catch{try{return n.call(null,b,0)}catch{return n.call(this,b,0)}}}(function(){try{n=typeof setTimeout=="function"?setTimeout:s}catch{n=s}try{a=typeof clearTimeout=="function"?clearTimeout:l}catch{a=l}})();var d,u=[],p=!1,m=-1;function h(){p&&d&&(p=!1,d.length?u=d.concat(u):m=-1,u.length&&g())}function g(){if(!p){var b=c(h);p=!0;for(var v=u.length;v;){for(d=u,u=[];++m<v;)d&&d[m].run();m=-1,v=u.length}d=null,p=!1,function(I){if(a===clearTimeout)return clearTimeout(I);if((a===l||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(I);try{a(I)}catch{try{return a.call(null,I)}catch{return a.call(this,I)}}}(b)}}function _(b,v){this.fun=b,this.array=v}function x(){}i.nextTick=function(b){var v=new Array(arguments.length-1);if(arguments.length>1)for(var I=1;I<arguments.length;I++)v[I-1]=arguments[I];u.push(new _(b,v)),u.length!==1||p||c(g)},_.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=x,i.addListener=x,i.once=x,i.off=x,i.removeListener=x,i.removeAllListeners=x,i.emit=x,i.prependListener=x,i.prependOnceListener=x,i.listeners=function(b){return[]},i.binding=function(b){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(b){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(r,o,n){function a(s,l){for(var c=0;c<l.length;c++){var d=l[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(s,d.key,d)}}var i=n(9);r.exports=function(){function s(){(function(u,p){if(!(u instanceof p))throw new TypeError("Cannot call a class as a function")})(this,s)}var l,c,d;return l=s,d=[{key:"urlEncode",value:function(u){return i(u)}},{key:"jsonEncode",value:function(u){return JSON.stringify(u)}},{key:"formEncode",value:function(u){if(this.isFormData(u))return u;if(this.isFormElement(u))return new FormData(u);if(this.isObject(u)){var p=new FormData;return Object.keys(u).forEach(function(m){var h=u[m];p.append(m,h)}),p}throw new Error("`data` must be an instance of Object, FormData or <FORM> HTMLElement")}},{key:"isObject",value:function(u){return Object.prototype.toString.call(u)==="[object Object]"}},{key:"isFormData",value:function(u){return u instanceof FormData}},{key:"isFormElement",value:function(u){return u instanceof HTMLFormElement}},{key:"selectFiles",value:function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new Promise(function(p,m){var h=document.createElement("INPUT");h.type="file",u.multiple&&h.setAttribute("multiple","multiple"),u.accept&&h.setAttribute("accept",u.accept),h.style.display="none",document.body.appendChild(h),h.addEventListener("change",function(g){var _=g.target.files;p(_),document.body.removeChild(h)},!1),h.click()})}},{key:"parseHeaders",value:function(u){var p=u.trim().split(/[\r\n]+/),m={};return p.forEach(function(h){var g=h.split(": "),_=g.shift(),x=g.join(": ");_&&(m[_]=x)}),m}}],(c=null)&&a(l.prototype,c),d&&a(l,d),s}()},function(r,o){var n=function(i){return encodeURIComponent(i).replace(/[!'()*]/g,escape).replace(/%20/g,"+")},a=function(i,s,l,c){return s=s||null,l=l||"&",c=c||null,i?function(d){for(var u=new Array,p=0;p<d.length;p++)d[p]&&u.push(d[p]);return u}(Object.keys(i).map(function(d){var u,p,m=d;if(c&&(m=c+"["+m+"]"),typeof i[d]=="object"&&i[d]!==null)u=a(i[d],null,l,m);else{s&&(p=m,m=!isNaN(parseFloat(p))&&isFinite(p)?s+Number(m):m);var h=i[d];h=(h=(h=(h=h===!0?"1":h)===!1?"0":h)===0?"0":h)||"",u=n(m)+"="+n(h)}return u})).join(l).replace(/[!'()*]/g,""):""};r.exports=a}])})})(IX);var JLe=IX.exports,of=ZLe(JLe);function QA(t){return t!==void 0&&typeof t.then=="function"}var JA=class{constructor({config:e,onUpload:r,onError:o}){this.config=e,this.onUpload=r,this.onError=o}uploadSelectedFile({onPreview:e}){let r=function(n){let a=new FileReader;a.readAsDataURL(n),a.onload=i=>{e(i.target.result)}},o;if(this.config.uploader&&typeof this.config.uploader.uploadByFile=="function"){let n=this.config.uploader.uploadByFile;o=of.selectFiles({accept:this.config.types??"image/*"}).then(a=>{r(a[0]);let i=n(a[0]);return QA(i)||console.warn("Custom uploader method uploadByFile should return a Promise"),i})}else o=of.transport({url:this.config.endpoints.byFile,data:this.config.additionalRequestData,accept:this.config.types??"image/*",headers:this.config.additionalRequestHeaders,beforeSend:n=>{r(n[0])},fieldName:this.config.field??"image"}).then(n=>n.body);o.then(n=>{this.onUpload(n)}).catch(n=>{this.onError(n)})}uploadByUrl(e){let r;this.config.uploader&&typeof this.config.uploader.uploadByUrl=="function"?(r=this.config.uploader.uploadByUrl(e),QA(r)||console.warn("Custom uploader method uploadByUrl should return a Promise")):r=of.post({url:this.config.endpoints.byUrl,data:Object.assign({url:e},this.config.additionalRequestData),type:of.contentType.JSON,headers:this.config.additionalRequestHeaders}).then(o=>o.body),r.then(o=>{this.onUpload(o)}).catch(o=>{this.onError(o)})}uploadByFile(e,{onPreview:r}){let o=new FileReader;o.readAsDataURL(e),o.onload=a=>{r(a.target.result)};let n;if(this.config.uploader&&typeof this.config.uploader.uploadByFile=="function")n=this.config.uploader.uploadByFile(e),QA(n)||console.warn("Custom uploader method uploadByFile should return a Promise");else{let a=new FormData;a.append(this.config.field??"image",e),this.config.additionalRequestData&&Object.keys(this.config.additionalRequestData).length&&Object.entries(this.config.additionalRequestData).forEach(([i,s])=>{a.append(i,s)}),n=of.post({url:this.config.endpoints.byFile,data:a,type:of.contentType.JSON,headers:this.config.additionalRequestHeaders}).then(i=>i.body)}n.then(a=>{this.onUpload(a)}).catch(a=>{this.onError(a)})}};var lw=class t{constructor({data:e,config:r,api:o,readOnly:n,block:a}){this.isCaptionEnabled=null,this.api=o,this.block=a,this.config={endpoints:r.endpoints,additionalRequestData:r.additionalRequestData,additionalRequestHeaders:r.additionalRequestHeaders,field:r.field,types:r.types,captionPlaceholder:this.api.i18n.t(r.captionPlaceholder??"Caption"),buttonContent:r.buttonContent,uploader:r.uploader,actions:r.actions,features:r.features||{}},this.uploader=new JA({config:this.config,onUpload:i=>this.onUpload(i),onError:i=>this.uploadingFailed(i)}),this.ui=new ZA({api:o,config:this.config,onSelectFile:()=>{this.uploader.uploadSelectedFile({onPreview:i=>{this.ui.showPreloader(i)}})},readOnly:n}),this._data={caption:"",withBorder:!1,withBackground:!1,stretched:!1,file:{url:""}},this.data=e}static get isReadOnlySupported(){return!0}static get toolbox(){return{icon:yX,title:"Image"}}static get tunes(){return[{name:"withBorder",icon:YLe,title:"With border",toggle:!0},{name:"stretched",icon:XLe,title:"Stretch image",toggle:!0},{name:"withBackground",icon:KLe,title:"With background",toggle:!0}]}render(){var e,r,o;return(((e=this.config.features)==null?void 0:e.caption)===!0||((r=this.config.features)==null?void 0:r.caption)===void 0||((o=this.config.features)==null?void 0:o.caption)==="optional"&&this.data.caption)&&(this.isCaptionEnabled=!0),this.ui.render()}validate(e){return!!e.file.url}save(){let e=this.ui.nodes.caption;return this._data.caption=e.innerHTML,this.data}renderSettings(){var e;let r=t.tunes.concat(this.config.actions||[]),o={border:"withBorder",background:"withBackground",stretch:"stretched",caption:"caption"};((e=this.config.features)==null?void 0:e.caption)==="optional"&&r.push({name:"caption",icon:QLe,title:"With caption",toggle:!0});let n=r.filter(i=>{var s,l;let c=Object.keys(o).find(d=>o[d]===i.name);return c==="caption"?((s=this.config.features)==null?void 0:s.caption)!==!1:c==null||((l=this.config.features)==null?void 0:l[c])!==!1}),a=i=>{let s=this.data[i.name];return i.name==="caption"&&(s=this.isCaptionEnabled??s),s};return n.map(i=>({icon:i.icon,label:this.api.i18n.t(i.title),name:i.name,toggle:i.toggle,isActive:a(i),onActivate:()=>{if(typeof i.action=="function"){i.action(i.name);return}let s=!a(i);i.name==="caption"&&(this.isCaptionEnabled=!(this.isCaptionEnabled??!1),s=this.isCaptionEnabled),this.tuneToggled(i.name,s)}}))}appendCallback(){this.ui.nodes.fileButton.click()}static get pasteConfig(){return{tags:[{img:{src:!0}}],patterns:{image:/https?:\/\/\S+\.(gif|jpe?g|tiff|png|svg|webp)(\?[a-z0-9=]*)?$/i},files:{mimeTypes:["image/*"]}}}async onPaste(e){switch(e.type){case"tag":{let r=e.detail.data;if(/^blob:/.test(r.src)){let o=await(await fetch(r.src)).blob();this.uploadFile(o);break}this.uploadUrl(r.src);break}case"pattern":{let r=e.detail.data;this.uploadUrl(r);break}case"file":{let r=e.detail.file;this.uploadFile(r);break}}}set data(e){this.image=e.file,this._data.caption=e.caption||"",this.ui.fillCaption(this._data.caption),t.tunes.forEach(({name:r})=>{let o=typeof e[r]<"u"?e[r]===!0||e[r]==="true":!1;this.setTune(r,o)}),e.caption&&this.setTune("caption",!0)}get data(){return this._data}set image(e){this._data.file=e||{url:""},e&&e.url&&this.ui.fillImage(e.url)}onUpload(e){e.success&&e.file?this.image=e.file:this.uploadingFailed("incorrect response: "+JSON.stringify(e))}uploadingFailed(e){console.log("Image Tool: uploading failed because of",e),this.api.notifier.show({message:this.api.i18n.t("Couldn\u2019t upload image. Please try another."),style:"error"}),this.ui.hidePreloader()}tuneToggled(e,r){e==="caption"?(this.ui.applyTune(e,r),r==!1&&(this._data.caption="",this.ui.fillCaption(""))):this.setTune(e,r)}setTune(e,r){this._data[e]=r,this.ui.applyTune(e,r),e==="stretched"&&Promise.resolve().then(()=>{this.block.stretched=r}).catch(o=>{console.error(o)})}uploadFile(e){this.uploader.uploadByFile(e,{onPreview:r=>{this.ui.showPreloader(r)}})}uploadUrl(e){this.ui.showPreloader(e),this.uploader.uploadByUrl(e)}};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.cdx-nested-list{margin:0;padding:0;outline:none;counter-reset:item;list-style:none}.cdx-nested-list__item{line-height:1.6em;display:flex;margin:2px 0}.cdx-nested-list__item [contenteditable]{outline:none}.cdx-nested-list__item-body{flex-grow:2}.cdx-nested-list__item-content,.cdx-nested-list__item-children{flex-basis:100%}.cdx-nested-list__item-content{word-break:break-word;white-space:pre-wrap}.cdx-nested-list__item:before{counter-increment:item;margin-right:5px;white-space:nowrap}.cdx-nested-list--ordered>.cdx-nested-list__item:before{content:counters(item,".") ". "}.cdx-nested-list--unordered>.cdx-nested-list__item:before{content:"\u2022"}.cdx-nested-list__settings{display:flex}.cdx-nested-list__settings .cdx-settings-button{width:50%}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();function Ui(t){return t.nodeType===Node.ELEMENT_NODE}function nf(t,e=null,r){let o=document.createElement(t);Array.isArray(e)?o.classList.add(...e):e&&o.classList.add(e);for(let n in r)o[n]=r[n];return o}function wX(t){let e=nf("div");return e.appendChild(t),e.innerHTML}function SX(t){let e;return t.nodeType!==Node.ELEMENT_NODE?e=t.textContent:(e=t.innerHTML,e=e.replaceAll("<br>","")),e?.trim().length===0}var Vs=class t{constructor(){this.savedFakeCaret=void 0}save(){let e=t.range,r=nf("span");r.hidden=!0,e&&(e.insertNode(r),this.savedFakeCaret=r)}restore(){if(!this.savedFakeCaret)return;let e=window.getSelection();if(!e)return;let r=new Range;r.setStartAfter(this.savedFakeCaret),r.setEndAfter(this.savedFakeCaret),e.removeAllRanges(),e.addRange(r),setTimeout(()=>{var o;(o=this.savedFakeCaret)==null||o.remove()},150)}static get range(){let e=window.getSelection();return e&&e.rangeCount?e.getRangeAt(0):null}static extractFragmentFromCaretPositionTillTheEnd(){let e=window.getSelection();if(!e||!e.rangeCount)return;let r=e.getRangeAt(0),o=r.startContainer;if(o.nodeType!==Node.ELEMENT_NODE){if(!o.parentNode)return;o=o.parentNode}if(!Ui(o))return;let n=o.closest("[contenteditable]");if(!n)return;r.deleteContents();let a=r.cloneRange();return a.selectNodeContents(n),a.setStart(r.endContainer,r.endOffset),a.extractContents()}static focus(e,r=!0){let o=document.createRange(),n=window.getSelection();n&&(o.selectNodeContents(e),o.collapse(r),n.removeAllRanges(),n.addRange(o))}static isAtStart(){let e=window.getSelection();if(!e||e.focusOffset>0)return!1;let r=e.focusNode;return!r||!Ui(r)?!1:t.getHigherLevelSiblings(r,"left").every(o=>SX(o))}static getHigherLevelSiblings(e,r="left"){let o=e,n=[];for(;o.parentNode&&o.parentNode.contentEditable!=="true";)o=o.parentNode;let a=r==="left"?"previousSibling":"nextSibling";for(;o[a];)o=o[a],n.push(o);return n}},eBe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="9" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 17H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 12H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 7H4.99002"/></svg>',EX='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="12" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7.79999 14L7.79999 7.2135C7.79999 7.12872 7.7011 7.0824 7.63597 7.13668L4.79999 9.5"/></svg>',$h=class t{static get isReadOnlySupported(){return!0}static get enableLineBreaks(){return!0}static get toolbox(){return{icon:EX,title:"List"}}constructor({data:e,config:r,api:o,readOnly:n}){var a;this.nodes={wrapper:null},this.api=o,this.readOnly=n,this.config=r,this.defaultListStyle=((a=this.config)==null?void 0:a.defaultStyle)==="ordered"?"ordered":"unordered";let i={style:this.defaultListStyle,items:[]};this.data=e&&Object.keys(e).length?e:i,this.caret=new Vs}render(){return this.nodes.wrapper=this.makeListWrapper(this.data.style,[this.CSS.baseBlock]),this.data.items.length?this.appendItems(this.data.items,this.nodes.wrapper):this.appendItems([{content:"",items:[]}],this.nodes.wrapper),this.readOnly||this.nodes.wrapper.addEventListener("keydown",e=>{switch(e.key){case"Enter":this.enterPressed(e);break;case"Backspace":this.backspace(e);break;case"Tab":e.shiftKey?this.shiftTab(e):this.addTab(e);break}},!1),this.nodes.wrapper}renderSettings(){return[{name:"unordered",label:this.api.i18n.t("Unordered"),icon:eBe},{name:"ordered",label:this.api.i18n.t("Ordered"),icon:EX}].map(e=>({name:e.name,icon:e.icon,label:e.label,isActive:this.data.style===e.name,closeOnActivate:!0,onActivate:()=>{this.listStyle=e.name}}))}static get pasteConfig(){return{tags:["OL","UL","LI"]}}onPaste(e){let r=e.detail.data;this.data=this.pasteHandler(r);let o=this.nodes.wrapper;o&&o.parentNode&&o.parentNode.replaceChild(this.render(),o)}pasteHandler(e){let{tagName:r}=e,o="unordered",n;switch(r){case"OL":o="ordered",n="ol";break;case"UL":case"LI":o="unordered",n="ul"}let a={style:o,items:[]},i=s=>Array.from(s.querySelectorAll(":scope > li")).map(l=>{var c;let d=l.querySelector(`:scope > ${n}`),u=d?i(d):[];return{content:((c=l?.firstChild)==null?void 0:c.textContent)||"",items:u}});return a.items=i(e),a}appendItems(e,r){e.forEach(o=>{let n=this.createItem(o.content,o.items);r.appendChild(n)})}createItem(e,r=[]){let o=nf("li",this.CSS.item),n=nf("div",this.CSS.itemBody),a=nf("div",this.CSS.itemContent,{innerHTML:e,contentEditable:(!this.readOnly).toString()});return n.appendChild(a),o.appendChild(n),r&&r.length>0&&this.addChildrenList(o,r),o}save(){let e=r=>Array.from(r.querySelectorAll(`:scope > .${this.CSS.item}`)).map(o=>{let n=o.querySelector(`.${this.CSS.itemChildren}`),a=this.getItemContent(o),i=n?e(n):[];return{content:a,items:i}});return{style:this.data.style,items:this.nodes.wrapper?e(this.nodes.wrapper):[]}}addChildrenList(e,r){let o=e.querySelector(`.${this.CSS.itemBody}`),n=this.makeListWrapper(void 0,[this.CSS.itemChildren]);this.appendItems(r,n),o&&o.appendChild(n)}makeListWrapper(e=this.listStyle,r=[]){let o=e==="ordered"?"ol":"ul",n=e==="ordered"?this.CSS.wrapperOrdered:this.CSS.wrapperUnordered;return r.push(n),nf(o,[this.CSS.wrapper,...r])}get CSS(){return{baseBlock:this.api.styles.block,wrapper:"cdx-nested-list",wrapperOrdered:"cdx-nested-list--ordered",wrapperUnordered:"cdx-nested-list--unordered",item:"cdx-nested-list__item",itemBody:"cdx-nested-list__item-body",itemContent:"cdx-nested-list__item-content",itemChildren:"cdx-nested-list__item-children",settingsWrapper:"cdx-nested-list__settings",settingsButton:this.api.styles.settingsButton,settingsButtonActive:this.api.styles.settingsButtonActive}}get listStyle(){return this.data.style||this.defaultListStyle}set listStyle(e){if(!this.nodes||!this.nodes.wrapper)return;let r=Array.from(this.nodes.wrapper.querySelectorAll(`.${this.CSS.wrapper}`));r.push(this.nodes.wrapper),r.forEach(o=>{o.classList.toggle(this.CSS.wrapperUnordered,e==="unordered"),o.classList.toggle(this.CSS.wrapperOrdered,e==="ordered")}),this.data.style=e}get currentItem(){let e=window.getSelection();if(!e)return null;let r=e.anchorNode;return!r||(Ui(r)||(r=r.parentNode),!r)||!Ui(r)?null:r.closest(`.${this.CSS.item}`)}enterPressed(e){let r=this.currentItem;if(e.stopPropagation(),e.preventDefault(),e.isComposing)return;let o=r?this.getItemContent(r).trim().length===0:!0,n=r?.parentNode===this.nodes.wrapper,a=r?.nextElementSibling===null;if(n&&a&&o){this.getOutOfList();return}else if(a&&o){this.unshiftItem();return}let i=Vs.extractFragmentFromCaretPositionTillTheEnd();if(!i)return;let s=wX(i),l=r?.querySelector(`.${this.CSS.itemChildren}`),c=this.createItem(s,void 0);l&&Array.from(l.querySelectorAll(`.${this.CSS.item}`)).length>0?l.prepend(c):r?.after(c),this.focusItem(c)}unshiftItem(){let e=this.currentItem;if(!e||!e.parentNode||!Ui(e.parentNode))return;let r=e.parentNode.closest(`.${this.CSS.item}`);if(!r)return;this.caret.save(),r.after(e),this.caret.restore();let o=r.querySelector(`.${this.CSS.itemChildren}`);o&&o.children.length===0&&o.remove()}getItemContent(e){let r=e.querySelector(`.${this.CSS.itemContent}`);return!r||SX(r)?"":r.innerHTML}focusItem(e,r=!0){let o=e.querySelector(`.${this.CSS.itemContent}`);o&&Vs.focus(o,r)}getOutOfList(){var e;(e=this.currentItem)==null||e.remove(),this.api.blocks.insert(),this.api.caret.setToBlock(this.api.blocks.getCurrentBlockIndex())}backspace(e){if(!Vs.isAtStart())return;e.preventDefault();let r=this.currentItem;if(!r)return;let o=r.previousSibling;if(!r.parentNode||!Ui(r.parentNode))return;let n=r.parentNode.closest(`.${this.CSS.item}`);if(!o&&!n||o&&!Ui(o))return;e.stopPropagation();let a;if(o){let d=o.querySelectorAll(`.${this.CSS.item}`);a=Array.from(d).pop()||o}else a=n;let i=Vs.extractFragmentFromCaretPositionTillTheEnd();if(!i)return;let s=wX(i);if(!a)return;let l=a.querySelector(`.${this.CSS.itemContent}`);if(!l)return;Vs.focus(l,!1),this.caret.save(),l.insertAdjacentHTML("beforeend",s);let c=r.querySelectorAll(`.${this.CSS.itemChildren} > .${this.CSS.item}`);c=Array.from(c),c=c.filter(d=>!d.parentNode||!Ui(d.parentNode)?!1:d.parentNode.closest(`.${this.CSS.item}`)===r),c.reverse().forEach(d=>{o?a.after(d):r.after(d)}),r.remove(),this.caret.restore()}addTab(e){e.stopPropagation(),e.preventDefault();let r=this.currentItem;if(!r)return;let o=r.previousSibling;if(!o||!Ui(o)||!o)return;let n=o.querySelector(`.${this.CSS.itemChildren}`);if(this.caret.save(),n)n.appendChild(r);else{let a=this.makeListWrapper(void 0,[this.CSS.itemChildren]),i=o.querySelector(`.${this.CSS.itemBody}`);a.appendChild(r),i?.appendChild(a)}this.caret.restore()}shiftTab(e){e.stopPropagation(),e.preventDefault(),this.unshiftItem()}static joinRecursive(e){return e.items.map(r=>`${r.content} ${t.joinRecursive(r)}`).join("")}static get conversionConfig(){return{export:e=>t.joinRecursive(e),import:e=>({items:[{content:e,items:[]}],style:"unordered"})}}};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ce-rawtool__textarea{min-height:200px;resize:vertical;border-radius:8px;border:0;background-color:#1e2128;font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:12px;line-height:1.6;letter-spacing:-.2px;color:#a1a7b6;overscroll-behavior:contain}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var tBe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16.6954 5C17.912 5 18.8468 6.07716 18.6755 7.28165L17.426 16.0659C17.3183 16.8229 16.7885 17.4522 16.061 17.6873L12.6151 18.8012C12.2152 18.9304 11.7848 18.9304 11.3849 18.8012L7.93898 17.6873C7.21148 17.4522 6.6817 16.8229 6.57403 16.0659L5.32454 7.28165C5.15322 6.07716 6.088 5 7.30461 5H16.6954Z"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 8.4H9L9.42857 11.7939H14.5714L14.3571 13.2788L14.1429 14.7636L12 15.4L9.85714 14.7636L9.77143 14.3394"/></svg>';var cw=class t{static get isReadOnlySupported(){return!0}static get displayInToolbox(){return!0}static get enableLineBreaks(){return!0}static get toolbox(){return{icon:tBe,title:"Raw HTML"}}constructor({data:e,config:r,api:o,readOnly:n}){this.api=o,this.readOnly=n,this.placeholder=o.i18n.t(r.placeholder||t.DEFAULT_PLACEHOLDER),this.CSS={baseClass:this.api.styles.block,input:this.api.styles.input,wrapper:"ce-rawtool",textarea:"ce-rawtool__textarea"},this.data={html:e.html||""},this.textarea=null,this.resizeDebounce=null}render(){let e=document.createElement("div"),r=100;return this.textarea=document.createElement("textarea"),e.classList.add(this.CSS.baseClass,this.CSS.wrapper),this.textarea.classList.add(this.CSS.textarea,this.CSS.input),this.textarea.textContent=this.data.html,this.textarea.placeholder=this.placeholder,this.readOnly?this.textarea.disabled=!0:this.textarea.addEventListener("input",()=>{this.onInput()}),e.appendChild(this.textarea),setTimeout(()=>{this.resize()},r),e}save(e){return{html:e.querySelector("textarea").value}}static get DEFAULT_PLACEHOLDER(){return"Enter HTML code"}static get sanitize(){return{html:!0}}onInput(){this.resizeDebounce&&clearTimeout(this.resizeDebounce),this.resizeDebounce=setTimeout(()=>{this.resize()},200)}resize(){this.textarea.style.height="auto",this.textarea.style.height=this.textarea.scrollHeight+"px"}};ye();var eN="S",tN=class t{static get CSS(){return""}static get shortcut(){return"CMD+SHIFT+X"}constructor(e){this.api=e.api,this.button=document.createElement("button"),this.iconClasses={base:this.api.styles.inlineToolButton,active:this.api.styles.inlineToolButtonActive}}static get isInline(){return!0}render(){return this.button?(this.button.type="button",this.button.classList.add(this.iconClasses.base),this.button.innerHTML=this.toolboxIcon,this.button):null}surround(e){if(!e)return;let r=this.api.selection.findParentTag(eN,t.CSS);r?this.unwrap(r):this.wrap(e)}wrap(e){let r=document.createElement(eN);r.appendChild(e.extractContents()),e.insertNode(r),this.api.selection.expandToTag(r)}unwrap(e){this.api.selection.expandToTag(e);let r=window.getSelection(),o=r.getRangeAt(0),n=o.extractContents();e.parentNode.removeChild(e),o.insertNode(n),r.removeAllRanges(),r.addRange(o)}checkState(){let e=this.api.selection.findParentTag(eN,t.CSS);this.button.classList.toggle(this.iconClasses.active,!!e)}get toolboxIcon(){return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="12" height="12"><path d="M17.154 14c.23.516.346 1.09.346 1.72 0 1.342-.524 2.392-1.571 3.147C14.88 19.622 13.433 20 11.586 20c-1.64 0-3.263-.381-4.87-1.144V16.6c1.52.877 3.075 1.316 4.666 1.316 2.551 0 3.83-.732 3.839-2.197a2.21 2.21 0 0 0-.648-1.603l-.12-.117H3v-2h18v2h-3.846zm-4.078-3H7.629a4.086 4.086 0 0 1-.481-.522C6.716 9.92 6.5 9.246 6.5 8.452c0-1.236.466-2.287 1.397-3.153C8.83 4.433 10.271 4 12.222 4c1.471 0 2.879.328 4.222.984v2.152c-1.2-.687-2.515-1.03-3.946-1.03-2.48 0-3.719.782-3.719 2.346 0 .42.218.786.654 1.099.436.313.974.562 1.613.75.62.18 1.297.414 2.03.699z"/></svg>'}static get sanitize(){return{s:{}}}},CX=tN;var rN="SUP",oN=class t{static get CSS(){return""}static get shortcut(){return"CMD+."}constructor(e){this.api=e.api,this.button=document.createElement("button"),this.iconClasses={base:this.api.styles.inlineToolButton,active:this.api.styles.inlineToolButtonActive}}static get isInline(){return!0}render(){return this.button?(this.button.type="button",this.button.classList.add(this.iconClasses.base),this.button.innerHTML=this.toolboxIcon,this.button):null}surround(e){if(!e)return;let r=this.api.selection.findParentTag(rN,t.CSS);r?this.unwrap(r):this.wrap(e)}wrap(e){let r=document.createElement(rN);r.appendChild(e.extractContents()),e.insertNode(r),this.api.selection.expandToTag(r)}unwrap(e){this.api.selection.expandToTag(e);let r=window.getSelection(),o=r.getRangeAt(0),n=o.extractContents();e.parentNode.removeChild(e),o.insertNode(n),r.removeAllRanges(),r.addRange(o)}checkState(){let e=this.api.selection.findParentTag(rN,t.CSS);this.button.classList.toggle(this.iconClasses.active,!!e)}get toolboxIcon(){return'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" stroke-width="2" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" style="stroke: none !important" /><path d="M5 7l8 10m-8 0l8 -10" /><path d="M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2" /></svg>'}static get sanitize(){return{sup:{}}}},kX=oN;var nN="U",aN=class t{static get CSS(){return""}static get shortcut(){return"CMD+U"}constructor(e){this.api=e.api,this.button=document.createElement("button"),this.iconClasses={base:this.api.styles.inlineToolButton,active:this.api.styles.inlineToolButtonActive}}static get isInline(){return!0}render(){return this.button?(this.button.type="button",this.button.classList.add(this.iconClasses.base),this.button.innerHTML=this.toolboxIcon,this.button):null}surround(e){if(!e)return;let r=this.api.selection.findParentTag(nN,t.CSS);r?this.unwrap(r):this.wrap(e)}wrap(e){let r=document.createElement(nN);r.appendChild(e.extractContents()),e.insertNode(r),this.api.selection.expandToTag(r)}unwrap(e){this.api.selection.expandToTag(e);let r=window.getSelection(),o=r.getRangeAt(0),n=o.extractContents();e.parentNode.removeChild(e),o.insertNode(n),r.removeAllRanges(),r.addRange(o)}checkState(){let e=this.api.selection.findParentTag(nN,t.CSS);this.button.classList.toggle(this.iconClasses.active,!!e)}get toolboxIcon(){return'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 7.5V11.5C9 12.2956 9.31607 13.0587 9.87868 13.6213C10.4413 14.1839 11.2044 14.5 12 14.5C12.7956 14.5 13.5587 14.1839 14.1213 13.6213C14.6839 13.0587 15 12.2956 15 11.5V7.5" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M7.71429 18H16.2857" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'}static get sanitize(){return{u:{}}}},TX=aN;function PX(t){let e=U(null),[r,o]=P(null),[n,a]=P({blocks:[{type:"paragraph",data:{}}]}),i=t.placeholder||"Start typing...";return L(()=>{if(!r)return;let s=t.value;if(n?.time!==s?.time){let l=n?.time||0;(s?.time||0)>l&&iN(s)&&((s?.blocks||[]).length>0?r.render(s):r.render({...s,blocks:[{type:"paragraph",data:{text:""}}]}),a(s))}},[r,t.value]),L(()=>{let s=e.current,l=XI,c=new l({holder:s,placeholder:i,inlineToolbar:["bold","italic","underline","strikethrough","superscript","link"],tools:{heading:{class:iw,config:{placeholder:"Enter a header",levels:[2,3,4,5],defaultLevel:2}},strikethrough:{class:CX},superscript:{class:kX},underline:{class:TX},image:{class:lw,config:{uploader:rBe(),captionPlaceholder:"Alt text"}},unorderedList:{class:$h,inlineToolbar:!0,config:{defaultStyle:"unordered"},toolbox:{name:"unorderedList",title:"Bulleted List",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="9" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 17H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 12H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 7H4.99002"/></svg>'}},orderedList:{class:$h,inlineToolbar:!0,config:{defaultStyle:"ordered"},toolbox:{name:"orderedList",title:"Numbered List",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="12" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7.79999 14L7.79999 7.2135C7.79999 7.12872 7.7011 7.0824 7.63597 7.13668L4.79999 9.5"/></svg>'}},html:{class:cw,toolbox:{name:"HTML"}}},onReady:()=>{o(c)},onChange:()=>{c.save().then(d=>{a(d),t.onChange&&t.onChange(d)}).catch(d=>{console.error("richtext error: ",d)})}});return()=>{c&&typeof c.destroy=="function"&&c.destroy()}},[]),f("div",{ref:e,className:Te(t.className,"RichTextEditor")})}function iN(t){return ki(t)&&Array.isArray(t.blocks)&&t.blocks.length>0}function rBe(){return{uploadByFile:async t=>{try{let e=await Ns(t),r=e.src;return oBe(r)&&(r=`${r}=s0-e365`),console.log(e),{success:1,file:{...e,url:r}}}catch(e){return console.error(e),{success:0,error:e}}},uploadByUrl:async t=>({success:0,error:"upload by url not currently supported"})}}function oBe(t){return t.startsWith("https://lh3.googleusercontent.com/")}function Hh(t,e){if(e==null)return!0;switch(t.type){case"string":case"select":case"date":case"datetime":return e==="";case"multiselect":return!Array.isArray(e)||e.length===0;case"number":case"boolean":return e==null;case"image":case"file":return!e||!e.src;case"reference":return!e||!e.id;case"richtext":return!iN(e);case"object":if(!ki(e)||Object.keys(e).length===0)return!0;for(let r of t.fields||[])if(r.id&&!Hh(r,e[r.id]))return!1;return!0;case"array":if(!ki(e)||!Array.isArray(e._array)||e._array.length===0)return!0;for(let r of e._array)if(!Hh(t.of,e[r]))return!1;return!1;case"oneof":{if(!ki(e)||!e._type)return!0;let r=(t.types||[]).find(o=>o.name===e._type);if(!r)return!0;for(let o of r.fields||[])if(o.id&&!Hh(o,e[o.id]))return!1;return!0}default:return!1}}ye();function OX(t,e){let r=!1;return(...o)=>{r||(t(...o),r=!0,setTimeout(()=>{r=!1},e))}}var jh=class extends Fs{constructor(r){super();this.interval=0;this.timeout=0;this.interval=r}start(){this.timeout=window.setTimeout(()=>{this.tick()},this.interval)}tick(){this.dispatch("tick"),this.start()}reset(){this.stop(),this.start()}stop(){this.timeout&&(window.clearTimeout(this.timeout),this.timeout=0)}};var nBe=30*Br.second,DX=5*Br.minute,sN=class extends Fs{constructor(r){super();this.started=!1;this.timer=new jh(nBe);this.idleTimer=new jh(DX);this.onUserInteraction=OX(()=>{this.idleTimer.reset()},5e3);this.id=r;let o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db;this.docRef=Ee(n,"Projects",o,"Viewers",r),this.timer.on("tick",()=>this.onTick()),this.idleTimer.on("tick",()=>this.onIdle()),window.addEventListener("mousemove",this.onUserInteraction),window.addEventListener("keypress",this.onUserInteraction)}async start(){this.started||(this.started=!0,this.dbUnsubscribe=Bv(this.docRef,r=>{let o=r.data();this.onData(o)}),this.onTick(),this.timer.start())}onData(r){let o=window.firebase.user,n=dt.now(),a=Object.values(r).filter(i=>!(i.email===o.email||n.toMillis()-i.lastViewedAt.toMillis()>DX));this.dispatch("change",a)}async onTick(){let r=window.firebase.user;if(!r.email){console.log("no user email:",r);return}console.log(`updating lastViewedAt for ${r.email}`),await cu(this.docRef,{[r.email]:{email:r.email,photoURL:r.photoURL,lastViewedAt:$t()}},{merge:!0})}async onIdle(){this.stop()}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.timer.stop(),this.idleTimer.stop(),this.onDisconnect(),this.started=!1)}async onDisconnect(){let r=window.firebase.user;if(!r.email){console.log("no user email:",r);return}let o=new Wo(r.email,"disconnectedAt");await cr(this.docRef,o,$t())}async dispose(){super.dispose(),this.stop(),this.timer.dispose(),this.idleTimer.dispose()}};function AX(t){let e=xs(t.id),[r,o]=P([]);if(L(()=>{let a=new sN(e);a.on("change",s=>o(s)),a.start();let i=()=>{document.hidden||document.visibilityState!=="visible"?a.stop():a.started||a.start()};return document.addEventListener("visibilitychange",i),()=>{a.dispose(),document.removeEventListener("visibilitychange",i)}},[e]),r.length===0)return null;function n(a){return a.disconnectedAt?a.disconnectedAt>a.lastViewedAt:!1}return f(M_,{className:"Viewers",limit:3,size:30,children:r.map(a=>{if(!a.photoURL){let i=a.email[0].toUpperCase();return f(qn,{alt:a.email,size:24,radius:"xl",children:i})}return f(qn,{className:Te("Viewers__viewer",n(a)&&"Viewers__viewer--disconnected"),src:a.photoURL,alt:a.email,size:24,radius:"xl"},a.email)})})}ye();function NX(t){let r=t.field.checkboxLabel||"Enabled",[o,n]=P(!1);function a(i){n(i),t.draft.updateKey(t.deepKey,i)}return L(()=>t.draft.subscribe(t.deepKey,s=>{n(s)}),[]),f("div",{className:"DocEditor__BooleanField",children:f(wd,{label:r,onChange:i=>{let s=i.currentTarget;a(s.checked)},checked:o,size:"xs"})})}ye();function RX(t){let e=t.field,[r,o]=P(e.default||"");function n(a){a?(t.draft.updateKey(t.deepKey,a),o(a)):(o(""),t.draft.removeKey(t.deepKey)),t.onChange&&t.onChange(a)}return L(()=>t.draft.subscribe(t.deepKey,i=>{o(i||"")}),[]),f("div",{className:"DocEditor__DateField",children:f("input",{type:"date",value:r,onChange:a=>{let i=a.currentTarget;n(i.value)}})})}ye();function MX(t){let[e,r]=P("");function o(a){if(a){let i=Math.floor(new Date(a).getTime()),s=dt.fromMillis(i);r(n(s)),t.draft.updateKey(t.deepKey,s)}else r(""),t.draft.removeKey(t.deepKey)}function n(a){let i=a.toDate();return i.setMinutes(i.getMinutes()-i.getTimezoneOffset()),i.toISOString().slice(0,16)}return L(()=>t.draft.subscribe(t.deepKey,i=>{r(i?n(i):"")}),[]),f("div",{className:"DocEditor__DateTimeField",children:[f("input",{type:"datetime-local",value:e,onChange:a=>{let s=a.target.value;o(s)}}),f("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})}ye();dn();Uc();ye();var aBe=["image/gif","image/jpeg","image/png","image/svg+xml","image/webp"],iBe=["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"],qh=mt(null);function fa(t){let e=Rt(),r=U(null),[o,n]=P(!1),[a,i]=P({uploadedFile:t.file}),s=t.exts??(t.variant==="image"?aBe:[]);L(()=>{i(g=>({...g,uploadedFile:t.file}))},[t.file]);async function l(g){try{i(x=>({...x,state:"uploading",file:g}));let _=await Ns(g,{preserveFilename:t.preserveFilename,cacheControl:t.cacheControl});c(_)}catch(_){console.error("upload failed"),console.error(_),i(x=>({...x,state:"error"})),he({title:"Upload failed",message:"Failed to upload: "+String(_),color:"red",autoClose:!1})}}function c(g){i(_=>({..._,uploadedFile:{..._.uploadedFile,...g}})),t.onFileChange?.(g),i(_=>({..._,uploadedFile:g,state:"finished"}))}function d(g){if(!g)return;let _=Ru(g.name);if(s.length>0&&!s.some(x=>x.endsWith(_)||x===`*/${_}`||x==="*/*"||x===g.type)){he({title:"Invalid file type",message:`File type ${_} is not allowed.`,color:"red",autoClose:!0});return}l(g)}function u(){r.current?.focus()}function p(){if(a.uploadedFile)if(nI(a.uploadedFile.src)){let g=document.createElement("a");g.href=NG(a.uploadedFile.src),a.uploadedFile.filename&&(g.download=a.uploadedFile.filename),document.body.appendChild(g),g.click(),document.body.removeChild(g)}else window.open(a.uploadedFile.src,"_blank")}function m(){let g=document.createElement("input");g.type="file",s.length>0&&(g.accept=s.join(",")),g.onchange=_=>{let x=_.target;x.files&&x.files.length>0&&d(x.files[0])},g.click(),g.remove()}function h(){n(!0)}return f(qh.Provider,{value:{fileUpload:a,variant:t.variant,alt:t.alt,acceptedFileTypes:s,handleFile:d,focusDropZone:u,requestFileUpload:m,requestFileDownload:p,requestPlaceholderModalOpen:h,setFileData:c,setAltText:g=>{i(_=>_.uploadedFile?{..._,uploadedFile:{..._.uploadedFile,alt:g||""}}:_),t.onFileChange?.({...a.uploadedFile,alt:g||""})},removeFile:()=>{i(g=>({...g,uploadedFile:null})),t.onFileChange?.(null)}},children:[f(ts,{size:"sm",opened:o,onClose:()=>n(!1),title:"Placeholder image",centered:!0,overlayColor:e.colorScheme==="dark"?e.colors.dark[9]:e.colors.gray[2],children:f("form",{onSubmit:g=>{g.preventDefault();let _=new FormData(g.currentTarget),x=parseInt(_.get("width"),10),b=parseInt(_.get("height"),10),v=_.get("backgroundColor"),I=_.get("label")||`${x}x${b}`,E=`<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${b}" viewBox="0 0 ${x} ${b}"><rect width="${x}" height="${b}" fill="${v}" />`;if(I){let A=x*.5/(I.length*.6);E+=`<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="sans-serif" font-size="${A}" fill="#fff">${I}</text>`}E+="</svg>";let C=new TextEncoder().encode(E),k={src:`data:image/svg+xml;base64,${btoa(String.fromCharCode(...C))}`,filename:"placeholder.svg",width:x,height:b,alt:""};c(k),n(!1)},children:[f(rs,{gap:"xs",children:[f(Mt,{label:"Width",name:"width",type:"number",defaultValue:1600,"data-autofocus":!0}),f(Mt,{label:"Height",name:"height",type:"number",defaultValue:900}),f(Mt,{name:"label",label:"Label",defaultValue:"",autofocus:!0}),f(Q_,{name:"backgroundColor",label:"Background color",format:"hex",defaultValue:"#868e96",swatches:iBe})]}),f("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"1rem"},children:f(Y,{variant:"filled",type:"submit",children:"Create"})})]})}),f("div",{className:"FileUploadField",children:[f(fa.Dropzone,{ref:r}),a.uploadedFile?.src?f(fa.Preview,{}):f(fa.Empty,{})]})]})}fa.Preview=()=>{let t=it(qh),[e,r]=P(!1),[o,n]=P(!1),a=t?.fileUpload;if(!a||!a.uploadedFile)return null;let i=LX(t?.fileUpload?.uploadedFile?.filename),[s,l]=P(!i),{uploadedFile:c}=a;return f("div",{className:"FileUploadField__Preview",children:[f("div",{className:"FileUploadField__Preview__InfoButton",children:[i&&f(Ie,{label:"Toggle file info",position:"top",withArrow:!0,children:f(Ue,{onClick:()=>l(d=>!d),size:"sm",variant:"outline",className:"FileUploadField__Preview__InfoButton__Icon",children:f(fT,{size:16})})}),f(Ie,{label:"Replace file",position:"top",withArrow:!0,children:f(Ue,{onClick:()=>t.requestFileUpload(),size:"sm",variant:"outline",className:"FileUploadField__Preview__InfoButton__Icon",children:t.variant==="image"?f($m,{size:16}):f(Ca,{size:16})})}),f(Re,{className:"FileUploadField__Preview__Menu",shadow:"sm",withinPortal:!1,closeOnItemClick:!1,control:f(Ue,{variant:"outline",size:"sm",radius:"sm",c:"black",className:"FileUploadField__Preview__InfoButton__Icon",children:f(Ti,{size:16})}),children:[f(Re.Label,{size:"sm",children:"REPLACE"}),f(Re.Item,{icon:t.variant==="image"?f($m,{size:16}):f(Ca,{size:16}),onClick:()=>t.requestFileUpload(),children:["Upload ",t.variant==="image"?"image":"file"]}),BX(t.acceptedFileTypes)&&f(Re.Item,{disabled:!c.src,icon:f(iy,{size:16}),onClick:()=>{t.requestPlaceholderModalOpen()},children:"Placeholder image"}),f(Hn,{}),f(Re.Item,{disabled:c.src.startsWith("data:"),onClick:()=>{t?.requestFileDownload()},icon:f(cT,{size:16}),children:"Download file"}),f(Re.Item,{closeOnItemClick:!1,icon:f(rc,{size:16}),onClick:()=>{n(!1),navigator.clipboard.writeText(c.src).then(()=>n(!0)).finally(()=>setTimeout(()=>{n(!1)},2e3))},children:o?"Copied!":"Copy URL"}),f(Hn,{}),f(Re.Item,{color:"red",onClick:()=>{t?.removeFile()},icon:f(oa,{size:16}),children:"Remove file"})]})]}),f("div",{className:Te("FileUploadField__Canvas",s&&"FileUploadField__Canvas--infoOpened",e&&"FileUploadField__Canvas--dragging"),style:c.width!==void 0&&c.height!==void 0?{"--canvas-aspect-ratio":`${c.width} / ${c.height}`}:{},onDragOver:d=>{d.preventDefault(),r(!0)},onDragLeave:d=>{d.preventDefault(),r(!1)},onDrop:d=>{d.preventDefault(),r(!1);let u=d.dataTransfer?.files[0];u&&t&&t.handleFile(u)},onPaste:d=>{d.preventDefault();let u=d.clipboardData?.files[0];u&&t&&t.handleFile(u)},children:[f(Kn,{visible:t.fileUpload?.state==="uploading"}),s?f("div",{className:"FileUploadField__Canvas__Info",children:[f(Vm,{size:20,className:"FileUploadField__Canvas__Info__Icon"}),f(hr,{className:"FileUploadField__Canvas__InfoTable",verticalSpacing:"xs",fontSize:"xs",children:f("tbody",{children:[c.filename&&f("tr",{children:[f("td",{children:f("b",{children:"Name"})}),f("td",{children:c.filename})]}),c.uploadedAt&&f("tr",{children:[f("td",{children:f("b",{children:"Uploaded"})}),f("td",{children:[new Date(parseInt(c.uploadedAt,10)).toLocaleString(),c.uploadedBy&&f(Oe,{children:[" by ",c.uploadedBy]})]})]}),c.width!==void 0&&c.height!==void 0&&f("tr",{children:[f("td",{children:f("b",{children:"Dimensions"})}),f("td",{children:[c.width,"x",c.height]})]}),f("tr",{children:[f("td",{children:f("b",{children:"URL"})}),f("td",{children:f(Kt,{readOnly:!0,value:c.src,size:"xs",autosize:!0,radius:0})})]})]})})]}):f(Oe,{children:[c.width!==void 0&&c.height!==void 0&&f(ae,{radius:"sm",className:"FileUploadField__Preview__Info",children:[c.width,"x",c.height]}),KP(c.src)&&f("img",{onClick:()=>{t?.focusDropZone()},onDblClick:()=>{t?.requestFileUpload()},src:c.src,alt:c.alt||"Uploaded file preview",className:"FileUploadField__Preview__Image"}),YP(c.src)&&f(Oe,{children:f("video",{className:"FileUploadField__Preview__Image",controls:!0,muted:!0,preload:"metadata",children:f("source",{src:c.src,type:`video/${Ru(c.src)}`})})})]})]}),t.alt!==!1&&(c.alt||LX(c.filename)||t.variant==="image")&&f("div",{className:"DocEditor__ImageField__imagePreview__Image__Alt",children:f(Kt,{radius:0,className:"DocEditor__ImageField__imagePreview__Image__Alt__Textarea",value:c.alt,placeholder:"Alt text",size:"xs",autosize:!0,disabled:t.fileUpload?.state==="uploading",onChange:d=>{t?.setAltText(d.currentTarget.value)}})})]})};fa.UploadButton=G((t,e)=>{let r=it(qh),o=r?.fileUpload?.state==="uploading";return r?f("label",{...t,ref:e,className:"FileUploadField__FileUploadButton",tabIndex:0,children:[f("input",{disabled:o,type:"file",accept:r.acceptedFileTypes.length>0?r.acceptedFileTypes.join(","):void 0,className:"FileUploadField__FileUploadButton__Input",onChange:n=>{let a=n.target;a.files&&r&&r.handleFile(a.files[0])}}),o?f(De,{size:16}):r?.variant==="image"?f($m,{size:16}):f(Ca,{size:16}),f("div",{className:"FileUploadField__FileUploadButton__Title",children:o?"Uploading...":r?.fileUpload?.uploadedFile?.src?"Upload":"Paste, drop, or click to upload"})]}):null});fa.Empty=()=>{let t=it(qh);if(!t)return null;let e=t.acceptedFileTypes.map(r=>r.split("/").pop().split("+")[0].replaceAll(".","")).sort();return f("div",{className:"FileUploadField__Empty",children:[f("div",{className:"FileUploadField__Empty__Label",children:[f("div",{children:f(fa.UploadButton,{})}),BX(t.acceptedFileTypes)&&f("div",{children:f(Ie,{label:"Create placeholder image",children:f(Ue,{className:"FileUploadField__Empty__Label__PlaceholderButton",onClick:()=>{t.requestPlaceholderModalOpen()},title:"Create placeholder image",children:f(iy,{size:16})})})})]}),t.acceptedFileTypes.length>0&&f("div",{children:f("div",{className:"FileUploadField__Empty__AcceptTypes",children:["Allowed file types: ",e.join(", ")]})})]})};fa.Dropzone=G((t,e)=>{let[r,o]=P(!1),n=it(qh);return f("button",{ref:e,className:Te("FileUploadField__Dropzone",r&&"FileUploadField__Dropzone--dragging"),onDblClick:()=>{n?.requestFileUpload()},onCopy:a=>{n?.fileUpload?.uploadedFile&&(a.preventDefault(),a.clipboardData?.setData("text/plain",n.fileUpload.uploadedFile.src),a.clipboardData?.setData("application/json",JSON.stringify(n.fileUpload.uploadedFile)))},onKeyDown:a=>{((a.metaKey||a.ctrlKey)&&a.key==="Backspace"||a.key==="Delete")&&(a.preventDefault(),n?.fileUpload?.uploadedFile&&n?.removeFile())},onDragOver:a=>{a.preventDefault(),o(!0)},onDragLeave:a=>{a.preventDefault(),o(!1)},onDrop:a=>{a.preventDefault(),o(!1);let i=a.dataTransfer?.files[0];i&&n&&n.handleFile(i)},onPaste:a=>{let i=a.clipboardData?.getData("application/json");if(i)try{let l=JSON.parse(i);if(l&&l.src&&l.filename&&n){console.log("Parsed JSON file:",l),n.setFileData(l);return}}catch(l){console.error("error parsing json",l)}a.preventDefault();let s=a.clipboardData?.files[0];s&&n&&n.handleFile(s)},title:"Drop or paste to upload a file"})});function LX(t){return t?KP(t)||YP(t):!1}function BX(t){return t.some(e=>e.startsWith("image/"))||t.length===0}function FX(t){let e=t.field,[r,o]=P(null);return L(()=>{let n=t.draft.subscribe(t.deepKey,a=>{o(a)});return()=>{n()}},[]),f(fa,{file:r,variant:"file",alt:e.alt,exts:e.exts,preserveFilename:e.preserveFilename,cacheControl:e.cacheControl,onFileChange:n=>{n?(t.draft.updateKey(t.deepKey,n),n.alt&&t.draft.updateKey(`${t.deepKey}.alt`,n.alt)):t.draft.removeKey(t.deepKey),t.draft.flush(),o(n)}})}ye();function zX(t){let e=t.field,[r,o]=P(null);return L(()=>{let n=t.draft.subscribe(t.deepKey,a=>{o(a)});return()=>{n()}},[]),f(fa,{file:r,variant:"image",alt:e.alt,exts:e.exts,onFileChange:n=>{n?(t.draft.updateKey(t.deepKey,n),n.alt&&t.draft.updateKey(`${t.deepKey}.alt`,n.alt)):t.draft.removeKey(t.deepKey),t.draft.flush(),o(n)}})}ye();function UX(t){let e=t.field,[r,o]=P([]),n=(e.options||[]).map(i=>typeof i=="string"?{label:i,value:i}:{label:i.label??i.value??"",value:i.value??i.label??""});function a(i){t.draft.updateKey(t.deepKey,i||[]),o(i)}return L(()=>t.draft.subscribe(t.deepKey,s=>{o(s||[])}),[]),f("div",{className:"DocEditor__MultiSelectField",children:f(mx,{data:n,size:"xs",radius:0,placeholder:e.placeholder,value:r,searchable:!0,creatable:e.creatable||!1,getCreateLabel:i=>`+ Add "${i}"`,onChange:i=>a(i),dropdownComponent:"div"})})}ye();function VX(t){let e=t.field,[r,o]=P(e.default||0);function n(a){o(a),t.draft.updateKey(t.deepKey,a)}return L(()=>t.draft.subscribe(t.deepKey,i=>{o(i)}),[]),f(bx,{size:"xs",radius:0,value:r,onChange:a=>n(a),hideControls:!0})}ye();function af(t){let e=t.field,[r,o]=P("");function n(l){if(l){let[c,d]=l.split("/");t.draft.updateKey(t.deepKey,{id:l,collection:c,slug:d})}else t.draft.removeKey(t.deepKey);o(l)}L(()=>t.draft.subscribe(t.deepKey,c=>{o(c?.id||"")}),[]);let a=X7();function i(){let l=r?r.split("/")[0]:e.initialCollection;a.open({collections:e.collections,initialCollection:l,onChange:c=>{n(c),a.close()}})}function s(){n("")}return f("div",{className:"ReferenceField",children:[r?f("div",{className:"ReferenceField__ref",children:[f(af.Preview,{id:r}),f("div",{className:"ReferenceField__remove",children:f(Ie,{label:"Remove",children:f(Ue,{className:"ReferenceField__remove__icon",onClick:()=>s(),children:f(oa,{size:16})})})})]}):f("div",{className:"ReferenceField__none",children:"None selected"}),f(Y,{color:"dark",size:"xs",onClick:()=>i(),children:e.buttonLabel||"Select"})]})}af.Preview=t=>{let[e,r]=P(!0),[o,n]=P(null);async function a(){r(!0),await Tt(async()=>{let i=await qv(t.id);n(i)}),r(!1)}return L(()=>{a()},[t.id]),f("div",{className:"ReferenceField__Preview",children:e?f("div",{className:"ReferenceField__Preview__loading",children:f(De,{color:"gray",size:"sm"})}):o?f(af.DocCard,{doc:o}):f("div",{className:"ReferenceField__Preview__notfound",children:['Doc Not found: "',t.id,'" (was it deleted?). Select a new doc or remove using the trash icon to the right.']})})};af.DocCard=t=>{let e=t.doc,r=e.id||e.sys?.id||"";if(!r)return f("div",{className:"ReferenceField__DocCard ReferenceField__DocCard--error",children:JSON.stringify(e)});let o=r.split("/")[0],n=e.fields||{},a=window.__ROOT_CTX.collections[o];if(!a)throw new Error(`could not find collection: ${o}`);let i=_o(n,a.preview?.title||"meta.title"),s=_o(n,a.preview?.image||"meta.image")||a.preview?.defaultImage;return f("a",{className:"ReferenceField__DocCard",href:`/cms/content/${r}`,target:"_blank",children:[f("div",{className:"ReferenceField__DocCard__image",children:f(Wn,{src:s?.src,width:80,height:60,withPlaceholder:!s?.src})}),f("div",{className:"ReferenceField__DocCard__content",children:[f("div",{className:"ReferenceField__DocCard__content__header",children:f("div",{className:"ReferenceField__DocCard__content__header__docId",children:r})}),f("div",{className:"ReferenceField__DocCard__content__title",children:i||"[UNTITLED]"})]})]})};ye();function $X(t){let e=t.field,[r,o]=P({blocks:[{type:"paragraph",data:{}}]});function n(a){o(i=>(ny({blocks:i?.blocks},{blocks:a?.blocks})||t.draft.updateKey(t.deepKey,a),a))}return L(()=>t.draft.subscribe(t.deepKey,i=>{o(i)}),[]),f(PX,{value:r,placeholder:e.placeholder,onChange:n})}ye();function HX(t){let e=t.field,[r,o]=P(""),n=(e.options||[]).map(i=>typeof i=="string"?{label:i,value:i}:{label:i.label??i.value??"",value:i.value??i.label??""});function a(i){t.draft.updateKey(`${t.deepKey}`,i),o(i||"")}return L(()=>t.draft.subscribe(t.deepKey,s=>{o(s||"")}),[]),f("div",{className:"DocEditor__SelectField",children:f(Vt,{data:n,placeholder:e.placeholder,value:r,onChange:i=>a(i||""),size:"xs",radius:0,searchable:e.searchable??!0,dropdownComponent:"div"})})}ye();function jX(t){let e=t.field,[r,o]=P("");function n(a){o(a),t.draft.updateKey(t.deepKey,a)}return L(()=>t.draft.subscribe(t.deepKey,i=>{o(i)}),[]),e.variant==="textarea"?f(Kt,{size:"xs",radius:0,autosize:!0,minRows:2,maxRows:e.maxRows||12,value:r,onChange:a=>{n(a.currentTarget.value)}}):f(Mt,{size:"xs",radius:0,value:r,onChange:a=>{n(a.currentTarget.value)}})}var qX=mt(null),GX=mt({value:WX(),setValue:()=>{}}),sBe=mt({value:null,setValue:()=>{}});function lBe(){return it(qX)}function dw(){return it(GX)}function WX(){return new URL(window.location.href).searchParams.get("deeplink")||""}function Ur(t){let e=sI(t.collection.id),r=t.draft,{controller:o,saveState:n,data:a}=r,[i,s]=P(null),[l,c]=P(WX()),d=e.loading||r.loading,u=e.schema?.fields||[],p=Gt(()=>{let _=t.docId.split("/")[0];xr(`/cms/content/${_}`)},[t.docId]),m=Gt(_=>{_.action==="delete"&&p()},[p]),h=hH({docId:t.docId}),g=s$({docId:t.docId,draft:o,collection:t.collection});return L(()=>{if(d)return;let x=new URL(window.location.href).searchParams.get("deeplink");x&&c(x)},[d]),f(sBe.Provider,{value:{value:i,setValue:s},children:f(qX.Provider,{value:a,children:f(GX.Provider,{value:{value:l,setValue:c},children:f("div",{className:"DocEditor",children:[f(Kn,{visible:d,loaderProps:{color:"gray",size:"xl"}}),f("div",{className:"DocEditor__statusBar",children:[f("div",{className:"DocEditor__statusBar__viewers",children:f(AX,{id:`doc/${t.docId}`})}),f("div",{className:"DocEditor__statusBar__saveState",children:[n==="SAVED"&&"saved!",n==="SAVING"&&"saving...",n==="UPDATE_PENDING"&&"saving...",n==="ERROR"&&"error saving"]}),!d&&a?.sys&&f("div",{className:"DocEditor__statusBar__statusBadges",children:f(Lu,{doc:a})}),f("div",{className:"DocEditor__statusBar__i18n",children:f(Y,{variant:"default",color:"dark",size:"xs",leftIcon:f(_T,{size:16}),onClick:()=>g.open(),children:"Localization"})}),f("div",{className:"DocEditor__statusBar__publishButton",children:d?f(Y,{color:"dark",size:"xs",onClick:()=>h.open(),loading:!0,disabled:!0,children:"Publish"}):Kv(a)?f(Ie,{label:`Scheduled ${jv(a.sys.scheduledAt)} by ${a.sys.scheduledBy}`,transition:"pop",children:f(Y,{color:"dark",size:"xs",leftIcon:f(gu,{size:16}),disabled:!0,children:"Publish"})}):Jl(a)?f(Ie,{label:`Locked by ${a.sys.publishingLocked.lockedBy}: "${a.sys.publishingLocked.reason}"`,transition:"pop",children:f(Y,{color:"dark",size:"xs",leftIcon:f(ac,{size:16}),disabled:!0,children:"Publish"})}):f(Y,{color:"dark",size:"xs",leftIcon:f(gu,{size:16}),onClick:()=>h.open(),children:"Publish"})}),f("div",{className:"DocEditor__statusBar__actionsMenu",children:f(aI,{docId:t.docId,data:a,onAction:m})})]}),f("div",{className:"DocEditor__fields",children:u.map(_=>f(Ur.Field,{collection:t.collection,field:_,shallowKey:_.id,deepKey:`fields.${_.id}`,draft:o},_.id))})]})})})})}Ur.Field=t=>{let e=t.field,r=t.level??0,n=dw().value===t.deepKey,a=U(null),[i,s]=P(null),[l,c]=P([]),d=!t.hideHeader&&!e.hideLabel;return e.type==="object"&&(e.variant||"drawer")==="drawer"&&(d=!1),L(()=>t.draft.subscribe(t.deepKey,p=>{s(p)}),[t.draft,t.deepKey]),L(()=>{if(!e.translate||!i)return;let p=new Set;fy(p,e,i),c(Array.from(p))},[i]),L(()=>{n&&fBe(a.current)},[n]),e.deprecated&&Hh(e,i)?null:f("div",{className:Te("DocEditor__field",e.deprecated&&"DocEditor__field--deprecated",n&&"deeplink-target"),"data-type":e.type,"data-level":r,id:t.deepKey,ref:a,children:[d&&f(Ur.FieldHeader,{deepKey:t.deepKey,label:e.label||e.id,help:e.help,deprecated:e.deprecated,translate:e.translate,translateStrings:l}),f("div",{className:"DocEditor__field__input",children:e.type==="array"?f(Ur.ArrayField,{...t}):e.type==="boolean"?f(NX,{...t}):e.type==="date"?f(RX,{...t}):e.type==="datetime"?f(MX,{...t}):e.type==="file"?f(FX,{...t}):e.type==="image"?f(zX,{...t}):e.type==="multiselect"?f(UX,{...t}):e.type==="number"?f(VX,{...t}):e.type==="object"?f(Ur.ObjectField,{...t}):e.type==="oneof"?f(Ur.OneOfField,{...t}):e.type==="reference"?f(af,{...t}):e.type==="richtext"?f($X,{...t}):e.type==="select"?f(HX,{...t}):e.type==="string"?f(jX,{...t}):f("div",{className:"DocEditor__field__input__unknown",children:["Unknown field type: ",e.type]})})]})};Ur.FieldHeader=t=>{function e(){let d=new URL(window.location.href);return d.searchParams.set("deeplink",t.deepKey),d.toString()}let r=dw(),o=lBe()||{},n=o.sys?.l10nSheet,i=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"],s=o$(),l=t.translate&&t.translateStrings||[],c=l.length===0;return f("div",{className:Te(t.className,"DocEditor__FieldHeader"),children:[t.deprecated?f("div",{className:"DocEditor__FieldHeader__label",children:["DEPRECATED: ",t.label]}):f("div",{className:"DocEditor__FieldHeader__label",children:[f("span",{children:t.label}),t.deepKey&&f("a",{className:"DocEditor__FieldHeader__label__deeplink",href:e(),title:"Link to field",onClick:d=>{d.preventDefault(),window.history.replaceState({},"",e()),r.setValue(t.deepKey)},children:"#"})]}),t.help&&f("div",{className:"DocEditor__FieldHeader__help",children:t.help}),i.length>1&&t.translate&&f("div",{className:"DocEditor__FieldHeader__translate",children:c?f("div",{className:"DocEditor__FieldHeader__translate__iconDisabled",children:f(Es,{size:16})}):f(Ie,{label:"Show translations",children:f(Ue,{size:"xs",onClick:()=>s.open({docId:o.id,strings:l,l10nSheet:n}),children:f(Es,{size:16})})})})]})};Ur.ObjectField=t=>{let e=t.field,r=e.variant;return r||(t.isArrayChild?r="inline":r="drawer"),r==="drawer"?f(Ur.ObjectFieldDrawer,{...t}):f("div",{className:"DocEditor__ObjectField",children:f("div",{className:"DocEditor__ObjectField__fields",children:e.fields.map(o=>f(Ur.Field,{collection:t.collection,field:o,shallowKey:o.id,deepKey:`${t.deepKey}.${o.id}`,draft:t.draft},o.id))})})};Ur.ObjectFieldDrawer=t=>{let e=t.field,r=e.drawerOptions?.collapsed||!1,o=e.drawerOptions?.inline||!1,n=o?"left":"right",a=dw(),i=!r||a.value.includes(t.deepKey);return f("div",{className:Te("DocEditor__ObjectFieldDrawer",o&&"DocEditor__ObjectFieldDrawer--inline"),children:f("details",{className:"DocEditor__ObjectFieldDrawer__drawer",open:i,children:[f("summary",{className:Te("DocEditor__ObjectFieldDrawer__drawer__toggle",`DocEditor__ObjectFieldDrawer__drawer__toggle--icon-${n}`),children:[f(Ur.FieldHeader,{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__header",deepKey:t.deepKey,label:e.label||e.id,help:e.help}),f("div",{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__icon",children:f(mu,{size:16})})]}),f("div",{className:"DocEditor__ObjectFieldDrawer__drawer__content DocEditor__ObjectFieldDrawer__fields",children:e.fields.map(s=>f(Ur.Field,{collection:t.collection,field:s,shallowKey:s.id,deepKey:`${t.deepKey}.${s.id}`,draft:t.draft},s.id))})]})})};function cBe(t,e){switch(e.type){case"update":{let r=t._new||[];return{...e.newValue,_new:r}}case"updateItem":{let r=t??{},n=[...r._array||[]][e.index],a=e.newValue??{};return e.draft.updateKey(`${e.deepKey}.${n}`,a),{...r,[n]:a}}case"add":{let r=t??{},o=Pa(),n=[...r._array||[],o];e.draft.updateKeys({[`${e.deepKey}._array`]:n,[`${e.deepKey}.${o}`]:{}});let a=t._new||[];return{...r,[o]:{},_array:n,_new:[...a,o]}}case"insertBefore":{let r=t??{},o=[...r._array||[]],n=Pa();o.splice(e.index,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:{}});let a=t._new||[];return{...r,[n]:{},_array:o,_new:[...a,n]}}case"insertAfter":{let r=t??{},o=[...r._array||[]],n=Pa();o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:{}});let a=t._new||[];return{...r,[n]:{},_array:o,_new:[...a,n]}}case"duplicate":{let r=t??{},o=[...r._array||[]],n=o[e.index],a=structuredClone(r[n]),i=Pa();o.splice(e.index+1,0,i),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${i}`]:a});let s=t._new||[];return{...r,[i]:a,_array:o,_new:[...s,i]}}case"moveUp":{if(e.index===0)return t;let r=t??{},o=[...r._array||[]];return lN(o,e.index,e.index-1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:o[e.index-1]}}case"moveDown":{let r=t??{},o=[...r._array||[]];return e.index>=o.length-1?t:(lN(o,e.index,e.index+1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:o[e.index+1]})}case"moveTo":{let r=t??{},o=[...r._array||[]];if(e.fromIndex<0||e.fromIndex>=o.length||e.toIndex<0||e.toIndex>=o.length)return console.error("Invalid moveTo index",e),t;let n=o[e.fromIndex];return lN(o,e.fromIndex,e.toIndex),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:n}}case"removeAt":{let r={...t??{}},n=[...r._array||[]],a=n[e.index];return delete r[a],n.splice(e.index,1),e.draft.updateKeys({[`${e.deepKey}._array`]:n}),e.draft.removeKey(`${e.deepKey}.${a}`),{...r,_array:n}}case"pasteAfter":{let r=t??{},o=[...r._array||[]],n=Pa(),a=e.virtualClipboard.value;o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:a});let i=t._new||[];return{...r,[n]:a,_array:o,_new:[...i,n]}}case"pasteBefore":{let r=t??{},o=[...r._array||[]],n=Pa(),a=e.virtualClipboard.value;o.splice(e.index,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:a});let i=t._new||[];return{...r,[n]:a,_array:o,_new:[...i,n]}}default:return console.error("unknown action",e),t}}Ur.ArrayField=t=>{let e=t.draft,r=t.field,[o,n]=rn(cBe,{_array:[]}),a=dw(),i=OH(),l=(o??{})._array||[],c=o._new||[];L(()=>t.draft.subscribe(t.deepKey,R=>{n({type:"update",newValue:R})}),[t.draft,t.deepKey]),L(()=>{o._moved&&x(t.deepKey,l.indexOf(o._moved))},[o]);let d=()=>{n({type:"add",draft:e,deepKey:t.deepKey})},u=S=>{n({type:"pasteBefore",draft:e,deepKey:t.deepKey,index:S,virtualClipboard:i})},p=S=>{n({type:"pasteAfter",draft:e,deepKey:t.deepKey,index:S,virtualClipboard:i})},m=S=>{n({type:"insertBefore",draft:e,deepKey:t.deepKey,index:S})},h=S=>{n({type:"insertAfter",draft:e,deepKey:t.deepKey,index:S})},g=S=>{n({type:"duplicate",draft:e,deepKey:t.deepKey,index:S})},_=S=>{n({type:"removeAt",draft:e,deepKey:t.deepKey,index:S})},x=(S,R)=>{document.getElementById(`summary-for-${S}.${l[R]}`)?.focus()},b=S=>{S>0&&n({type:"moveUp",draft:e,deepKey:t.deepKey,index:S})},v=S=>{S<l.length-1&&n({type:"moveDown",draft:e,deepKey:t.deepKey,index:S})},I=S=>{let R=l[S],A=o[R];i.set(A)},E=cy(),y=S=>{let R=l[S];E.open({data:o[R],onSave:A=>{console.log("editJson, onSave():",A),n({type:"updateItem",draft:e,index:S,newValue:A,deepKey:t.deepKey}),e.notifySubscribers(),E.close()}})};function C(S){return!!a.value.startsWith(`${t.deepKey}.${S}`)}function T(S,R){S.target&&(S.key==="ArrowUp"?(S.preventDefault(),b(l.indexOf(R))):S.key==="ArrowDown"?(S.preventDefault(),v(l.indexOf(R))):S.key==="ArrowLeft"?S.target.closest("details").open=!1:S.key==="ArrowRight"&&(S.target.closest("details").open=!0))}let k=f("div",{className:"DocEditor__ArrayField__add",children:f(Y,{color:"dark",size:"xs",leftIcon:f(hu,{size:16}),onClick:()=>d(),children:r.buttonLabel||"Add"})});return l.length===0&&!o._new?f("div",{className:"DocEditor__ArrayField",children:[f("div",{className:"DocEditor__ArrayField__items",children:f("div",{className:"DocEditor__ArrayField__items__empty",children:"No items"})}),k]}):f("div",{className:"DocEditor__ArrayField",children:[f(jK,{onDragEnd:S=>{let{source:R,destination:A}=S;A&&n({type:"moveTo",fromIndex:R.index,toIndex:A.index,draft:e,deepKey:t.deepKey})},children:f(tY,{droppableId:"dnd-list",direction:"vertical",children:S=>f("div",{...S.droppableProps,ref:S.innerRef,className:"DocEditor__ArrayField__items",children:[l.map((R,A)=>{let N=dBe(r,o[R]);return f(XK,{index:A,draggableId:R,children:(z,F)=>f("div",{ref:z.innerRef,...z.draggableProps,className:Te("DocEditor__ArrayField__item__wrapper",F.isDragging&&"DocEditor__ArrayField__item__wrapper--dragging"),children:[f("div",{className:"DocEditor__ArrayField__item__handle",...z.dragHandleProps,children:f(dT,{size:18,stroke:"1.5"})}),f("details",{className:"DocEditor__ArrayField__item",open:c.includes(R)||C(R),children:[f("summary",{id:`summary-for-${t.deepKey}.${l[A]}`,className:"DocEditor__ArrayField__item__header",onKeyDown:B=>T(B,R),tabIndex:0,children:[f("div",{className:"DocEditor__ArrayField__item__header__icon",children:f(vT,{size:6})}),f("div",{className:"DocEditor__ArrayField__item__header__preview",children:[N&&f("div",{className:"DocEditor__ArrayField__item__header__preview__image",children:f("img",{src:N,alt:"",className:"DocEditor__ArrayField__item__header__preview__image__img",loading:"lazy"})}),f("div",{className:"DocEditor__ArrayField__item__header__preview__title",children:uBe(r,o[R],A)})]}),f("div",{className:"DocEditor__ArrayField__item__header__controls",children:[f("div",{className:"DocEditor__ArrayField__item__header__controls__arrows",children:[f("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--up",onClick:()=>b(A),children:f(tT,{size:20,strokeWidth:1.75})}),f("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--down",onClick:()=>v(A),children:f(eT,{size:20,strokeWidth:1.75})})]}),f(Re,{className:"DocEditor__ArrayField__item__header__controls__menu",position:"bottom",control:f(Ue,{className:"DocEditor__ArrayField__item__header__controls__dots",children:f(Ti,{size:16})}),children:[f(Re.Label,{children:"INSERT"}),f(Re.Item,{icon:f(ly,{size:20}),onClick:()=>m(A),children:"Add before"}),f(Re.Item,{icon:f(sy,{size:20}),onClick:()=>h(A),children:"Add after"}),f(Re.Item,{icon:f(rc,{size:20}),onClick:()=>g(A),children:"Duplicate"}),f(Re.Label,{children:"CLIPBOARD"}),f(Re.Item,{icon:f(oT,{size:20}),onClick:()=>setTimeout(()=>I(A),500),children:"Copy"}),i.value&&f(Oe,{children:[f(Re.Item,{icon:f(ly,{size:20}),onClick:()=>u(A),children:"Paste before"}),f(Re.Item,{icon:f(sy,{size:20}),onClick:()=>p(A),children:"Paste after"})]}),f(Re.Label,{children:"CODE"}),f(Re.Item,{icon:f(Mm,{size:20}),onClick:()=>y(A),children:"Edit JSON"}),f(Re.Label,{children:"REMOVE"}),f(Re.Item,{icon:f(oa,{size:20}),onClick:()=>_(A),children:"Remove"})]})]})]}),f("div",{className:"DocEditor__ArrayField__item__body",children:f(Ur.Field,{collection:t.collection,field:r.of,shallowKey:r.id,deepKey:`${t.deepKey}.${R}`,draft:t.draft,hideHeader:!0,isArrayChild:!0},`${t.deepKey}.${R}`)})]},R)]})},R)}),S.placeholder]})})}),k]})};Ur.OneOfField=t=>{let e=t.field,[r,o]=P(""),n={},a=[{value:"",label:e.placeholder||"Select type"}];e.types.forEach(c=>{n[c.name]=c,a.push({value:c.name,label:c.name})});let i=n[r||""],s=ot(()=>({}),[]);async function l(c){let d={};if(c){if(c in s){let u=s[c];Object.assign(d,u)}else if(c in n){let u=nh(n[c]);Object.assign(d,u)}}d._type=c,await t.draft.updateKey(t.deepKey,d),o(c)}return L(()=>t.draft.subscribe(t.deepKey,d=>{d?._type&&(o(d._type||""),s[d._type]=d)}),[t.draft,t.deepKey]),f("div",{className:"DocEditor__OneOfField",children:[f("div",{className:"DocEditor__OneOfField__select",children:[f("div",{className:"DocEditor__OneOfField__select__label",children:"Type:"}),f(Vt,{data:a,value:r,placeholder:e.placeholder,onChange:c=>l(c||""),size:"xs",radius:0,searchable:!0,dropdownComponent:"div"})]}),i&&f("div",{className:"DocEditor__OneOfField__fields",children:i.fields.map(c=>f(Ur.Field,{collection:t.collection,field:c,shallowKey:c.id,deepKey:`${t.deepKey}.${c.id}`,draft:t.draft},`${r}::${c.id}`))})]})};function lN(t,e,r){if(t.length<=1)return t;let o=t[e];return t[e]=t[r],t[r]=o,t}function KX(t,e,r="title"){if(t.type==="oneof"){let o=t,n=e?._type;if(n)return o.types.find(i=>i.name===n)?.preview?.[r]||null}return null}function cN(t,e,r){let o=Array.isArray(t)?[...t]:[t],n=Gk(e);for(r!==void 0&&(n._index=String(r),n._index0=String(r),n._index1=String(r+1),n["_index:02"]=n._index.padStart(2,"0"),n["_index:03"]=n._index.padStart(3,"0"));o.length>0;){let a=o.shift(),i=iY(a,n);if(ZO(i).length===0)return i}}function dBe(t,e){let r=KX(t.of,e,"image");if(r)return cN(r,e)}function uBe(t,e,r){let o=KX(t.of,e,"title");if(o){let n=cN(o,e,r);if(n)return n}return t.preview?cN(t.preview,e,r)??`item ${r}`:`item ${r}`}function fBe(t){let e=document.querySelector(".DocumentPage__side");if(e){if(e.scrollTop>0)return;requestAnimationFrame(()=>{let r=t.offsetTop;e.scroll({top:r,behavior:"auto"})})}}function uw(t,e,r=""){let o=Qv({collectionId:t,slug:e}),n=new URLSearchParams(window.location.search);n.set("preview","true");let a=`${n.toString()}${window.location.hash}`;return r?`${Qv({collectionId:t,slug:e,locale:r})}?${a}`:`${o}?${a}`}function fw(t){let e=t.collection,r=t.slug,o=`${e}/${r}`,n=window.__ROOT_CTX.collections[e],a=aY(o),[i,s]=wc(`root::DocumentPage::previewVisible::${e}`,!0);if(!n)return f("div",{children:"Could not find collection."});function l(){let p=uw(e,r),m=window.open(p,"_blank");m&&m.focus()}function c(){a.controller.flush()}let d=cy(),u=()=>{d.open({data:a.data?.fields||{},onSave:p=>{p&&typeof p=="object"&&(a.controller.updateKey("fields",p),a.controller.flush()),d.close()}})};return _0([["mod+S",()=>c()]]),f(ge,{children:f(Mi,{className:"DocumentPage",localStorageId:"DocumentPage",children:[f(Mi.Item,{className:Te("DocumentPage__side",!i&&"DocumentPage__side--expanded"),children:[f("div",{className:"DocumentPage__side__header",children:[f("div",{className:"DocumentPage__side__header__nav",children:[f("a",{href:`/cms/content/${e}`,children:f(Ue,{className:"DocumentPage__side__header__back",children:f(Qk,{size:16})})}),f("div",{className:"DocumentPage__side__header__docId",children:o})]}),f("div",{className:"DocumentPage__side__header__buttons",children:[f(Y,{variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:f(Bm,{size:16}),onClick:()=>c(),children:"Save"}),f(Re,{className:"DocumentPage__side__header__menu",position:"bottom",control:f(Ue,{className:"DocumentPage__side__header__menu__dots",children:f(Ti,{size:16})}),children:f(Re.Item,{icon:f(Mm,{size:20}),onClick:()=>u(),children:"Edit JSON"})}),f(Ie,{label:i?"Hide preview":"Show preview",children:f(Ue,{className:"DocumentPage__side__header__previewToggle",onClick:()=>s(!i),children:i?f(pT,{size:16}):f(mT,{size:16})})}),!i&&f(Ie,{label:"Open preview in new tab",children:f(Ue,{className:"DocumentPage__side__header__openNewTab",onClick:l,children:f(ws,{size:16})})})]})]}),f("div",{className:Te("DocumentPage__side__editor",!i&&"DocumentPage__side__editor--centered"),children:f(Ur,{collection:n,docId:o,draft:a},o)})]}),f(Mi.Item,{className:Te("DocumentPage__main",!i&&"DocumentPage__main--hidden"),fluid:!0,children:i&&f(fw.Preview,{docId:o,draft:a},o)})]})})}var YX={mobile:[360,800],tablet:[768,1024],desktop:[1440,800]};function pBe(t){let e=new Intl.DisplayNames(["en"],{type:"language"}),o=t.split("_")[0];return`${e.of(o)||t} (${t})`}fw.Preview=t=>{let[e,r]=t.docId.split("/"),n=window.__ROOT_CTX.collections[e];if(!n)throw new Error(`collection not found: ${e}`);let a=n.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",i=Hk({collectionId:e,slug:r}),s=Qv({collectionId:e,slug:r}),l=`${a}${i}`,[c,d]=P(l),[u,p]=wc("root::DocumentPage::preview::device",""),[m,h]=P({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[g,_]=P(""),x=U(null),b=t.draft.controller.getLocales(),v=uw(e,r),I=uw(e,r,g),E=[{value:"",label:"Select locale"},...b.map(S=>({value:S,label:pBe(S)}))];function y(){let S=x.current;S.src="about:blank",window.setTimeout(()=>{S.src!==I?S.src=I:S.contentWindow.location.reload()},30)}L(()=>{let S=x.current;function R(){let N=S.contentWindow;if(N&&s===i&&!N.location.href.startsWith("about:blank")){let z=N.location.pathname;console.log(`iframe url change: ${z}`),d(`${a}${z}`)}}S.addEventListener("load",R);let A=t.draft.controller.onFlush(()=>{y()});return()=>{A(),S.removeEventListener("load",R)}},[]),L(()=>{let S=x.current;S.src=I},[g]);function C(S){p(R=>R===S?"":S)}function T(){t.draft.controller.flush().then(()=>y())}function k(){let S=uw(e,r,g),R=window.open(S,"_blank");R&&R.focus()}return L(()=>{if(u===""){h({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"});return}let A=x.current.parentElement.parentElement.getBoundingClientRect(),[N,z]=YX[u],F=20,B=1;(N>A.width-2*F||z>A.height-2*F)&&(B=Math.min((A.width-2*F)/N,(A.height-2*F)/z)),h({"--iframe-width":`${N}px`,"--iframe-height":`${z}px`,"--iframe-scale":String(B)})},[u]),f("div",{className:"DocumentPage__main__preview",children:[f("div",{className:"DocumentPage__main__previewBar",children:[f("div",{className:"DocumentPage__main__previewBar__devices",children:[f(Ie,{label:"Mobile",children:f(Ue,{className:Te("DocumentPage__main__previewBar__device",u==="mobile"&&"active"),onClick:()=>C("mobile"),children:f(lT,{size:16})})}),f(Ie,{label:"Tablet",children:f(Ue,{className:Te("DocumentPage__main__previewBar__device",u==="tablet"&&"active"),onClick:()=>C("tablet"),children:f(sT,{size:16})})}),f(Ie,{label:"Desktop",children:f(Ue,{className:Te("DocumentPage__main__previewBar__device",u==="desktop"&&"active"),onClick:()=>C("desktop"),children:f(iT,{size:16})})})]}),f("div",{className:"DocumentPage__main__previewBar__navbar",children:f("div",{className:"DocumentPage__main__previewBar__navbar__url",children:c})}),f("div",{className:"DocumentPage__main__previewBar__locales",children:f(Vt,{data:E,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:f(yT,{size:16,strokeWidth:1.5}),value:g,onChange:S=>{_(S)}})}),f("div",{className:"DocumentPage__main__previewBar__buttons",children:[f(Ie,{label:"Reload",children:f(Ue,{className:"DocumentPage__main__previewBar__button DocumentPage__main__previewBar__button--reload",onClick:()=>T(),children:f(xT,{size:16})})}),f(Ie,{label:"Open new tab",children:f(Ue,{className:"DocumentPage__main__previewBar__button DocumentPage__main__previewBar__button--openNewTab",onClick:()=>k(),children:f(ws,{size:16})})})]})]}),f("div",{className:"DocumentPage__main__previewFrame","data-device":u||"full",style:m,children:[u&&f("div",{className:"DocumentPage__main__previewFrame__deviceLabel",children:`${u}: ${YX[u].join("x")}`}),f("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:f("iframe",{ref:x,src:v,title:"iframe preview"})})]})]})};ye();var mBe="Enter the URL to make the HTTP request.",hBe="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function pw(t){let e=U(null),r=Ss(),[o,n]=P(!1),[a,i]=P(r.enabled?"gsheet":"http"),[s,l]=P("map"),[c,d]=P("GET"),[u,p]=P(""),[m,h]=P(!!t.dataSourceId),[g,_]=P(null),x="";a==="http"?x=mBe:a==="gsheet"&&(x=hBe);async function b(E){await Tt(async()=>{let y=await tc(E);_(y),i(y?.type||"http"),l(y?.dataFormat||"map")}),h(!1)}L(()=>{t.dataSourceId&&(h(!0),b(t.dataSourceId))},[t.dataSourceId]);async function v(){p("");let E=e.current;function y(S){let R=E.elements[S];return R?R.value.trim():""}let C=t.dataSourceId||y("id");if(!C){p("missing id");return}if(!Qa(C)){p("id is invalid (alphanumeric characters and dashes only)");return}let T=y("url");if(!T){p("missing url");return}let k={id:C,description:y("description"),type:a,url:T,previewUrl:y("previewUrl")};if(a==="http"){if(!gBe(T)){p("invalid url");return}k.httpOptions={method:c};let S=y("httpHeaders");if(S&&(k.httpOptions.headers=_Be(S)),c==="POST"){let R=y("httpBody");R&&(k.httpOptions.body=R)}}else if(a==="gsheet"){if(!vs(T)?.spreadsheetId){p("failed to parse spreadsheet url");return}k.dataFormat=s||"map"}try{_(k),n(!0),t.dataSourceId?(await V7(t.dataSourceId,k),he({title:"Saved data source",message:`Successfully updated ${C}`,autoClose:5e3}),n(!1)):(await U7(C,k),he({title:"Added data source",message:`Successfully added ${C}`,autoClose:5e3}),n(!1),xr(`/cms/data/${C}`))}catch(S){console.error(S),he({title:"Failed to save data source",message:String(S),color:"red",autoClose:!1}),n(!1)}}let I=[{value:"http",label:"HTTP"}];return(r.enabled||a==="gsheet")&&I.push({value:"gsheet",label:"Google Sheet"}),f("form",{className:"DataSourceForm",ref:e,onSubmit:E=>{E.preventDefault(),v()},children:[f(Kn,{visible:m}),f("div",{className:"DataSourceForm__input",children:f(Vt,{name:"type",label:"Type",data:I,value:a,onChange:E=>i(E),size:"xs",radius:0,dropdownComponent:"div"})}),f(Mt,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:t.dataSourceId,disabled:!!t.dataSourceId}),f(Kt,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:g?.description}),f(Mt,{className:"DataSourceForm__input",name:"url",label:"URL",description:x,size:"xs",radius:0,value:g?.url}),a==="http"&&f(Oe,{children:[f("div",{className:"DataSourceForm__input",children:f(Vt,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:c,onChange:E=>d(E),size:"xs",radius:0,dropdownComponent:"div"})}),f(Kt,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:xBe(g?.httpOptions?.headers||{})}),c==="POST"&&f(Kt,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:g?.httpOptions?.body})]}),a==="gsheet"&&f("div",{className:"DataSourceForm__input",children:[f(Vt,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:s,onChange:E=>l(E),size:"xs",radius:0,dropdownComponent:"div"}),s==="array"&&f("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",f("code",{children:"[[header1, header2], [foo, bar]]"})]}),s==="map"&&f("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",f("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),f(Mt,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:g?.previewUrl}),f(Y,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:o,children:t.buttonLabel||"Save"}),u&&f("div",{className:"DataSourceForm__error",children:["Error: ",u]})]})}function gBe(t){let e,r=t.startsWith("/")?"http://localhost":void 0;try{e=new URL(t,r)}catch(o){return console.error(o),!1}return e.protocol==="http:"||e.protocol==="https:"}function _Be(t){let e={};return t.split(`
|
|
227
|
+
`,oA=class extends ft{constructor(){super(...arguments),this.isMobile=!1,this.contentRectCache=null,this.resizeDebouncer=cY(()=>{this.windowResize()},200),this.selectionChangeDebounced=cY(()=>{this.selectionChanged()},PLe),this.documentTouchedListener=e=>{this.documentTouched(e)}}get CSS(){return{editorWrapper:"codex-editor",editorWrapperNarrow:"codex-editor--narrow",editorZone:"codex-editor__redactor",editorZoneHidden:"codex-editor__redactor--hidden",editorEmpty:"codex-editor--empty",editorRtlFix:"codex-editor--rtl"}}get contentRect(){if(this.contentRectCache!==null)return this.contentRectCache;let e=this.nodes.wrapper.querySelector(`.${Oa.CSS.content}`);return e?(this.contentRectCache=e.getBoundingClientRect(),this.contentRectCache):{width:650,left:0,right:0}}async prepare(){this.setIsMobile(),this.make(),this.loadStyles()}toggleReadOnly(e){e?this.unbindReadOnlySensitiveListeners():window.requestIdleCallback(()=>{this.bindReadOnlySensitiveListeners()},{timeout:2e3})}checkEmptiness(){let{BlockManager:e}=this.Editor;this.nodes.wrapper.classList.toggle(this.CSS.editorEmpty,e.isEditorEmpty)}get someToolbarOpened(){let{Toolbar:e,BlockSettings:r,InlineToolbar:o}=this.Editor;return!!(r.opened||o.opened||e.toolbox.opened)}get someFlipperButtonFocused(){return this.Editor.Toolbar.toolbox.hasFocus()?!0:Object.entries(this.Editor).filter(([e,r])=>r.flipper instanceof Zu).some(([e,r])=>r.flipper.hasFocus())}destroy(){this.nodes.holder.innerHTML="",this.unbindReadOnlyInsensitiveListeners()}closeAllToolbars(){let{Toolbar:e,BlockSettings:r,InlineToolbar:o}=this.Editor;r.close(),o.close(),e.toolbox.close()}setIsMobile(){let e=window.innerWidth<wY;e!==this.isMobile&&this.eventsDispatcher.emit(Rh,{isEnabled:this.isMobile}),this.isMobile=e}make(){this.nodes.holder=K.getHolder(this.config.holder),this.nodes.wrapper=K.make("div",[this.CSS.editorWrapper,...this.isRtl?[this.CSS.editorRtlFix]:[]]),this.nodes.redactor=K.make("div",this.CSS.editorZone),this.nodes.holder.offsetWidth<this.contentRect.width&&this.nodes.wrapper.classList.add(this.CSS.editorWrapperNarrow),this.nodes.redactor.style.paddingBottom=this.config.minHeight+"px",this.nodes.wrapper.appendChild(this.nodes.redactor),this.nodes.holder.appendChild(this.nodes.wrapper),this.bindReadOnlyInsensitiveListeners()}loadStyles(){let e="editor-js-styles";if(K.get(e))return;let r=K.make("style",null,{id:e,textContent:zLe.toString()});this.config.style&&!ua(this.config.style)&&this.config.style.nonce&&r.setAttribute("nonce",this.config.style.nonce),K.prepend(document.head,r)}bindReadOnlyInsensitiveListeners(){this.listeners.on(document,"selectionchange",this.selectionChangeDebounced),this.listeners.on(window,"resize",this.resizeDebouncer,{passive:!0}),this.listeners.on(this.nodes.redactor,"mousedown",this.documentTouchedListener,{capture:!0,passive:!0}),this.listeners.on(this.nodes.redactor,"touchstart",this.documentTouchedListener,{capture:!0,passive:!0})}unbindReadOnlyInsensitiveListeners(){this.listeners.off(document,"selectionchange",this.selectionChangeDebounced),this.listeners.off(window,"resize",this.resizeDebouncer),this.listeners.off(this.nodes.redactor,"mousedown",this.documentTouchedListener),this.listeners.off(this.nodes.redactor,"touchstart",this.documentTouchedListener)}bindReadOnlySensitiveListeners(){this.readOnlyMutableListeners.on(this.nodes.redactor,"click",e=>{this.redactorClicked(e)},!1),this.readOnlyMutableListeners.on(document,"keydown",e=>{this.documentKeydown(e)},!0),this.readOnlyMutableListeners.on(document,"mousedown",e=>{this.documentClicked(e)},!0),this.watchBlockHoveredEvents(),this.enableInputsEmptyMark()}watchBlockHoveredEvents(){let e;this.readOnlyMutableListeners.on(this.nodes.redactor,"mousemove",iD(r=>{let o=r.target.closest(".ce-block");this.Editor.BlockSelection.anyBlockSelected||o&&e!==o&&(e=o,this.eventsDispatcher.emit(jY,{block:this.Editor.BlockManager.getBlockByChildNode(o)}))},20),{passive:!0})}unbindReadOnlySensitiveListeners(){this.readOnlyMutableListeners.clearAll()}windowResize(){this.contentRectCache=null,this.setIsMobile()}documentKeydown(e){switch(e.keyCode){case Ye.ENTER:this.enterPressed(e);break;case Ye.BACKSPACE:case Ye.DELETE:this.backspacePressed(e);break;case Ye.ESC:this.escapePressed(e);break;default:this.defaultBehaviour(e);break}}defaultBehaviour(e){let{currentBlock:r}=this.Editor.BlockManager,o=e.target.closest(`.${this.CSS.editorWrapper}`),n=e.altKey||e.ctrlKey||e.metaKey||e.shiftKey;if(r!==void 0&&o===null){this.Editor.BlockEvents.keydown(e);return}o||r&&n||(this.Editor.BlockManager.unsetCurrentBlock(),this.Editor.Toolbar.close())}backspacePressed(e){let{BlockManager:r,BlockSelection:o,Caret:n}=this.Editor;if(o.anyBlockSelected&&!ze.isSelectionExists){let a=r.removeSelectedBlocks(),i=r.insertDefaultBlockAtIndex(a,!0);n.setToBlock(i,n.positions.START),o.clearSelection(e),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}}escapePressed(e){this.Editor.BlockSelection.clearSelection(e),this.Editor.Toolbar.toolbox.opened?(this.Editor.Toolbar.toolbox.close(),this.Editor.Caret.setToBlock(this.Editor.BlockManager.currentBlock,this.Editor.Caret.positions.END)):this.Editor.BlockSettings.opened?this.Editor.BlockSettings.close():this.Editor.InlineToolbar.opened?this.Editor.InlineToolbar.close():this.Editor.Toolbar.close()}enterPressed(e){let{BlockManager:r,BlockSelection:o}=this.Editor;if(this.someToolbarOpened)return;let n=r.currentBlockIndex>=0;if(o.anyBlockSelected&&!ze.isSelectionExists){o.clearSelection(e),e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation();return}if(!this.someToolbarOpened&&n&&e.target.tagName==="BODY"){let a=this.Editor.BlockManager.insert();e.preventDefault(),this.Editor.Caret.setToBlock(a),this.Editor.Toolbar.moveAndOpen(a)}this.Editor.BlockSelection.clearSelection(e)}documentClicked(e){var r,o;if(!e.isTrusted)return;let n=e.target;this.nodes.holder.contains(n)||ze.isAtEditor||(this.Editor.BlockManager.unsetCurrentBlock(),this.Editor.Toolbar.close());let a=(r=this.Editor.BlockSettings.nodes.wrapper)==null?void 0:r.contains(n),i=(o=this.Editor.Toolbar.nodes.settingsToggler)==null?void 0:o.contains(n),s=a||i;if(this.Editor.BlockSettings.opened&&!s){this.Editor.BlockSettings.close();let l=this.Editor.BlockManager.getBlockByChildNode(n);this.Editor.Toolbar.moveAndOpen(l)}this.Editor.BlockSelection.clearSelection(e)}documentTouched(e){let r=e.target;if(r===this.nodes.redactor){let o=e instanceof MouseEvent?e.clientX:e.touches[0].clientX,n=e instanceof MouseEvent?e.clientY:e.touches[0].clientY;r=document.elementFromPoint(o,n)}try{this.Editor.BlockManager.setCurrentBlockByChildNode(r)}catch{this.Editor.RectangleSelection.isRectActivated()||this.Editor.Caret.setToTheLastBlock()}this.Editor.ReadOnly.isEnabled||this.Editor.Toolbar.moveAndOpen()}redactorClicked(e){if(!ze.isCollapsed)return;let r=e.target,o=e.metaKey||e.ctrlKey;if(K.isAnchor(r)&&o){e.stopImmediatePropagation(),e.stopPropagation();let n=r.getAttribute("href"),a=JRe(n);tMe(a);return}this.processBottomZoneClick(e)}processBottomZoneClick(e){let r=this.Editor.BlockManager.getBlockByIndex(-1),o=K.offset(r.holder).bottom,n=e.pageY,{BlockSelection:a}=this.Editor;if(e.target instanceof Element&&e.target.isEqualNode(this.nodes.redactor)&&!a.anyBlockSelected&&o<n){e.stopImmediatePropagation(),e.stopPropagation();let{BlockManager:i,Caret:s,Toolbar:l}=this.Editor;(!i.lastBlock.tool.isDefault||!i.lastBlock.isEmpty)&&i.insertAtEnd(),s.setToTheLastBlock(),l.moveAndOpen(i.lastBlock)}}selectionChanged(){let{CrossBlockSelection:e,BlockSelection:r}=this.Editor,o=ze.anchorElement;if(e.isCrossBlockSelectionStarted&&r.anyBlockSelected&&ze.get().removeAllRanges(),!o){ze.range||this.Editor.InlineToolbar.close();return}let n=o.closest(`.${Oa.CSS.content}`);(n===null||n.closest(`.${ze.CSS.editorWrapper}`)!==this.nodes.wrapper)&&(this.Editor.InlineToolbar.containsNode(o)||this.Editor.InlineToolbar.close(),o.dataset.inlineToolbar!=="true")||(this.Editor.BlockManager.currentBlock||this.Editor.BlockManager.setCurrentBlockByChildNode(o),this.Editor.InlineToolbar.tryToShow(!0))}enableInputsEmptyMark(){function e(r){let o=r.target;EY(o)}this.readOnlyMutableListeners.on(this.nodes.wrapper,"input",e),this.readOnlyMutableListeners.on(this.nodes.wrapper,"focusin",e),this.readOnlyMutableListeners.on(this.nodes.wrapper,"focusout",e)}},ULe={BlocksAPI:fD,CaretAPI:pD,EventsAPI:mD,I18nAPI:hD,API:gD,InlineToolbarAPI:_D,ListenersAPI:xD,NotifierAPI:vD,ReadOnlyAPI:yD,SanitizerAPI:ID,SaverAPI:wD,SelectionAPI:ED,ToolsAPI:SD,StylesAPI:CD,ToolbarAPI:kD,TooltipAPI:TD,UiAPI:PD,BlockSettings:MD,Toolbar:BD,InlineToolbar:zD,BlockEvents:VD,BlockManager:HD,BlockSelection:jD,Caret:qD,CrossBlockSelection:GD,DragNDrop:WD,ModificationsObserver:KD,Paste:DLe,ReadOnly:YD,RectangleSelection:XD,Renderer:QD,Saver:ZD,Tools:YI,UI:oA},nA=class{constructor(e){this.moduleInstances={},this.eventsDispatcher=new Oc;let r,o;this.isReady=new Promise((n,a)=>{r=n,o=a}),Promise.resolve().then(async()=>{this.configuration=e,this.validate(),this.init(),await this.start(),await this.render();let{BlockManager:n,Caret:a,UI:i,ModificationsObserver:s}=this.moduleInstances;i.checkEmptiness(),s.enable(),this.configuration.autofocus===!0&&this.configuration.readOnly!==!0&&a.setToBlock(n.blocks[0],a.positions.START),r()}).catch(n=>{At(`Editor.js is not ready because of ${n}`,"error"),o(n)})}set configuration(e){var r,o;bo(e)?this.config={...e}:this.config={holder:e},lD(!!this.config.holderId,"config.holderId","config.holder"),this.config.holderId&&!this.config.holder&&(this.config.holder=this.config.holderId,this.config.holderId=null),this.config.holder==null&&(this.config.holder="editorjs"),this.config.logLevel||(this.config.logLevel=vY.VERBOSE),WRe(this.config.logLevel),lD(!!this.config.initialBlock,"config.initialBlock","config.defaultBlock"),this.config.defaultBlock=this.config.defaultBlock||this.config.initialBlock||"paragraph",this.config.minHeight=this.config.minHeight!==void 0?this.config.minHeight:300;let n={type:this.config.defaultBlock,data:{}};this.config.placeholder=this.config.placeholder||!1,this.config.sanitizer=this.config.sanitizer||{p:!0,b:!0,a:!0},this.config.hideToolbar=this.config.hideToolbar?this.config.hideToolbar:!1,this.config.tools=this.config.tools||{},this.config.i18n=this.config.i18n||{},this.config.data=this.config.data||{blocks:[]},this.config.onReady=this.config.onReady||(()=>{}),this.config.onChange=this.config.onChange||(()=>{}),this.config.inlineToolbar=this.config.inlineToolbar!==void 0?this.config.inlineToolbar:!0,(ua(this.config.data)||!this.config.data.blocks||this.config.data.blocks.length===0)&&(this.config.data={blocks:[n]}),this.config.readOnly=this.config.readOnly||!1,(r=this.config.i18n)!=null&&r.messages&&Zo.setDictionary(this.config.i18n.messages),this.config.i18n.direction=((o=this.config.i18n)==null?void 0:o.direction)||"ltr"}get configuration(){return this.config}validate(){let{holderId:e,holder:r}=this.config;if(e&&r)throw Error("\xABholderId\xBB and \xABholder\xBB param can't assign at the same time.");if(zi(r)&&!K.get(r))throw Error(`element with ID \xAB${r}\xBB is missing. Pass correct holder's ID.`);if(r&&bo(r)&&!K.isElement(r))throw Error("\xABholder\xBB value must be an Element node")}init(){this.constructModules(),this.configureModules()}async start(){await["Tools","UI","BlockManager","Paste","BlockSelection","RectangleSelection","CrossBlockSelection","ReadOnly"].reduce((e,r)=>e.then(async()=>{try{await this.moduleInstances[r].prepare()}catch(o){if(o instanceof MI)throw new Error(o.message);At(`Module ${r} was skipped because of %o`,"warn",o)}}),Promise.resolve())}render(){return this.moduleInstances.Renderer.render(this.config.data.blocks)}constructModules(){Object.entries(ULe).forEach(([e,r])=>{try{this.moduleInstances[e]=new r({config:this.configuration,eventsDispatcher:this.eventsDispatcher})}catch(o){At("[constructModules]",`Module ${e} skipped because`,"error",o)}})}configureModules(){for(let e in this.moduleInstances)Object.prototype.hasOwnProperty.call(this.moduleInstances,e)&&(this.moduleInstances[e].state=this.getModulesDiff(e))}getModulesDiff(e){let r={};for(let o in this.moduleInstances)o!==e&&(r[o]=this.moduleInstances[o]);return r}};var XI=class{static get version(){return"2.31.0-rc.7"}constructor(e){let r=()=>{};bo(e)&&rr(e.onReady)&&(r=e.onReady);let o=new nA(e);this.isReady=o.isReady.then(()=>{this.exportAPI(o),r()})}exportAPI(e){let r=["configuration"],o=()=>{Object.values(e.moduleInstances).forEach(n=>{rr(n.destroy)&&n.destroy(),n.listeners.removeAll()}),EMe(),e=null;for(let n in this)Object.prototype.hasOwnProperty.call(this,n)&&delete this[n];Object.setPrototypeOf(this,null)};r.forEach(n=>{this[n]=e[n]}),this.destroy=o,Object.setPrototypeOf(this,e.moduleInstances.API.methods),delete this.exportAPI,Object.entries({blocks:{clear:"clear",render:"render"},caret:{focus:"focus"},events:{on:"on",off:"off",emit:"emit"},saver:{save:"save"}}).forEach(([n,a])=>{Object.entries(a).forEach(([i,s])=>{this[s]=e.moduleInstances.API.methods[n][i]})})}};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ce-header{padding:.6em 0 3px;margin:0;line-height:1.25em;outline:none}.ce-header p,.ce-header div{padding:0!important;margin:0!important}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var VLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M19 17V10.2135C19 10.1287 18.9011 10.0824 18.836 10.1367L16 12.5"/></svg>',$Le='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 11C16 10 19 9.5 19 12C19 13.9771 16.0684 13.9997 16.0012 16.8981C15.9999 16.9533 16.0448 17 16.1 17L19.3 17"/></svg>',HLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 11C16 10.5 16.8323 10 17.6 10C18.3677 10 19.5 10.311 19.5 11.5C19.5 12.5315 18.7474 12.9022 18.548 12.9823C18.5378 12.9864 18.5395 13.0047 18.5503 13.0063C18.8115 13.0456 20 13.3065 20 14.8C20 16 19.5 17 17.8 17C17.8 17 16 17 16 16.3"/></svg>',jLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M18 10L15.2834 14.8511C15.246 14.9178 15.294 15 15.3704 15C16.8489 15 18.7561 15 20.2 15M19 17C19 15.7187 19 14.8813 19 13.6"/></svg>',qLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 15.9C16 15.9 16.3768 17 17.8 17C19.5 17 20 15.6199 20 14.7C20 12.7323 17.6745 12.0486 16.1635 12.9894C16.094 13.0327 16 12.9846 16 12.9027V10.1C16 10.0448 16.0448 10 16.1 10H19.8"/></svg>',GLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M19.5 10C16.5 10.5 16 13.3285 16 15M16 15V15C16 16.1046 16.8954 17 18 17H18.3246C19.3251 17 20.3191 16.3492 20.2522 15.3509C20.0612 12.4958 16 12.6611 16 15Z"/></svg>',WLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9 7L9 12M9 17V12M9 12L15 12M15 7V12M15 17L15 12"/></svg>';var iw=class{constructor({data:e,config:r,api:o,readOnly:n}){this.api=o,this.readOnly=n,this._settings=r,this._data=this.normalizeData(e),this._element=this.getTag()}get _CSS(){return{block:this.api.styles.block,wrapper:"ce-header"}}isHeaderData(e){return e.text!==void 0}normalizeData(e){let r={text:"",level:this.defaultLevel.number};return this.isHeaderData(e)&&(r.text=e.text||"",e.level!==void 0&&!isNaN(parseInt(e.level.toString()))&&(r.level=parseInt(e.level.toString()))),r}render(){return this._element}renderSettings(){return this.levels.map(e=>({icon:e.svg,label:this.api.i18n.t(`Heading ${e.number}`),onActivate:()=>this.setLevel(e.number),closeOnActivate:!0,isActive:this.currentLevel.number===e.number,render:()=>document.createElement("div")}))}setLevel(e){this.data={level:e,text:this.data.text}}merge(e){this._element.insertAdjacentHTML("beforeend",e.text)}validate(e){return e.text.trim()!==""}save(e){return{text:e.innerHTML,level:this.currentLevel.number}}static get conversionConfig(){return{export:"text",import:"text"}}static get sanitize(){return{level:!1,text:{}}}static get isReadOnlySupported(){return!0}get data(){return this._data.text=this._element.innerHTML,this._data.level=this.currentLevel.number,this._data}set data(e){if(this._data=this.normalizeData(e),e.level!==void 0&&this._element.parentNode){let r=this.getTag();r.innerHTML=this._element.innerHTML,this._element.parentNode.replaceChild(r,this._element),this._element=r}e.text!==void 0&&(this._element.innerHTML=this._data.text||"")}getTag(){let e=document.createElement(this.currentLevel.tag);return e.innerHTML=this._data.text||"",e.classList.add(this._CSS.wrapper),e.contentEditable=this.readOnly?"false":"true",e.dataset.placeholder=this.api.i18n.t(this._settings.placeholder||""),e}get currentLevel(){let e=this.levels.find(r=>r.number===this._data.level);return e||(e=this.defaultLevel),e}get defaultLevel(){if(this._settings.defaultLevel){let e=this.levels.find(r=>r.number===this._settings.defaultLevel);if(e)return e;console.warn("(\u0E07'\u0300-'\u0301)\u0E07 Heading Tool: the default level specified was not found in available levels")}return this.levels[1]}get levels(){let e=[{number:1,tag:"H1",svg:VLe},{number:2,tag:"H2",svg:$Le},{number:3,tag:"H3",svg:HLe},{number:4,tag:"H4",svg:jLe},{number:5,tag:"H5",svg:qLe},{number:6,tag:"H6",svg:GLe}];return this._settings.levels?e.filter(r=>this._settings.levels.includes(r.number)):e}onPaste(e){let r=e.detail;if("data"in r){let o=r.data,n=this.defaultLevel.number;switch(o.tagName){case"H1":n=1;break;case"H2":n=2;break;case"H3":n=3;break;case"H4":n=4;break;case"H5":n=5;break;case"H6":n=6;break}this._settings.levels&&(n=this._settings.levels.reduce((a,i)=>Math.abs(i-n)<Math.abs(a-n)?i:a)),this.data={level:n,text:o.innerHTML}}}static get pasteConfig(){return{tags:["H1","H2","H3","H4","H5","H6"]}}static get toolbox(){return{icon:WLe,title:"Heading"}}};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.image-tool{--bg-color: #cdd1e0;--front-color: #388ae5;--border-color: #e8e8eb}.image-tool__image{border-radius:3px;overflow:hidden;margin-bottom:10px;padding-bottom:0}.image-tool__image-picture{max-width:100%;vertical-align:bottom;display:block}.image-tool__image-preloader{width:50px;height:50px;border-radius:50%;background-size:cover;margin:auto;position:relative;background-color:var(--bg-color);background-position:center center}.image-tool__image-preloader:after{content:"";position:absolute;z-index:3;width:60px;height:60px;border-radius:50%;border:2px solid var(--bg-color);border-top-color:var(--front-color);left:50%;top:50%;margin-top:-30px;margin-left:-30px;animation:image-preloader-spin 2s infinite linear;box-sizing:border-box}.image-tool__caption{visibility:hidden;position:absolute;bottom:0;left:0;margin-bottom:10px}.image-tool__caption[contentEditable=true][data-placeholder]:before{position:absolute!important;content:attr(data-placeholder);color:#707684;font-weight:400;display:none}.image-tool__caption[contentEditable=true][data-placeholder]:empty:before{display:block}.image-tool__caption[contentEditable=true][data-placeholder]:empty:focus:before{display:none}.image-tool--empty .image-tool__image,.image-tool--empty .image-tool__image-preloader{display:none}.image-tool--empty .image-tool__caption,.image-tool--uploading .image-tool__caption{visibility:hidden!important}.image-tool .cdx-button{display:flex;align-items:center;justify-content:center}.image-tool .cdx-button svg{height:auto;margin:0 6px 0 0}.image-tool--filled .cdx-button,.image-tool--filled .image-tool__image-preloader{display:none}.image-tool--uploading .image-tool__image{min-height:200px;display:flex;border:1px solid var(--border-color);background-color:#fff}.image-tool--uploading .image-tool__image-picture,.image-tool--uploading .cdx-button{display:none}.image-tool--withBorder .image-tool__image{border:1px solid var(--border-color)}.image-tool--withBackground .image-tool__image{padding:15px;background:var(--bg-color)}.image-tool--withBackground .image-tool__image-picture{max-width:60%;margin:0 auto}.image-tool--stretched .image-tool__image-picture{width:100%}.image-tool--caption .image-tool__caption{visibility:visible}.image-tool--caption{padding-bottom:50px}@keyframes image-preloader-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var KLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 19V19C9.13623 19 8.20435 19 7.46927 18.6955C6.48915 18.2895 5.71046 17.5108 5.30448 16.5307C5 15.7956 5 14.8638 5 13V12C5 9.19108 5 7.78661 5.67412 6.77772C5.96596 6.34096 6.34096 5.96596 6.77772 5.67412C7.78661 5 9.19108 5 12 5H13.5C14.8956 5 15.5933 5 16.1611 5.17224C17.4395 5.56004 18.44 6.56046 18.8278 7.83886C19 8.40666 19 9.10444 19 10.5V10.5"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 13V16M16 19V16M19 16H16M16 16H13"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6.5 17.5L17.5 6.5"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.9919 10.5H19.0015"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.9919 19H11.0015"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13L13 5"/></svg>',YLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.9919 9.5H19.0015"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.5 5H14.5096"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M14.625 5H15C17.2091 5 19 6.79086 19 9V9.375"/><path stroke="currentColor" stroke-width="2" d="M9.375 5L9 5C6.79086 5 5 6.79086 5 9V9.375"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.3725 5H9.38207"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 9.5H5.00957"/><path stroke="currentColor" stroke-width="2" d="M9.375 19H9C6.79086 19 5 17.2091 5 15V14.625"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.3725 19H9.38207"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 14.55H5.00957"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 13V16M16 19V16M19 16H16M16 16H13"/></svg>',yX='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" stroke="currentColor" stroke-width="2" rx="4"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.13968 15.32L8.69058 11.5661C9.02934 11.2036 9.48873 11 9.96774 11C10.4467 11 10.9061 11.2036 11.2449 11.5661L15.3871 16M13.5806 14.0664L15.0132 12.533C15.3519 12.1705 15.8113 11.9668 16.2903 11.9668C16.7693 11.9668 17.2287 12.1705 17.5675 12.533L18.841 13.9634"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.7778 9.33331H13.7867"/></svg>',XLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 9L20 12L17 15"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 12H20"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 9L4 12L7 15"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 12H10"/></svg>',QLe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M8 9V7.2C8 7.08954 8.08954 7 8.2 7L12 7M16 9V7.2C16 7.08954 15.9105 7 15.8 7L12 7M12 7L12 17M12 17H10M12 17H14"/></svg>';function rf(t,e=null,r={}){let o=document.createElement(t);Array.isArray(e)?o.classList.add(...e):e!==null&&o.classList.add(e);for(let n in r)r.hasOwnProperty(n)&&(o[n]=r[n]);return o}var sw=(t=>(t.Empty="empty",t.Uploading="uploading",t.Filled="filled",t))(sw||{}),ZA=class{constructor({api:e,config:r,onSelectFile:o,readOnly:n}){this.api=e,this.config=r,this.onSelectFile=o,this.readOnly=n,this.nodes={wrapper:rf("div",[this.CSS.baseClass,this.CSS.wrapper]),imageContainer:rf("div",[this.CSS.imageContainer]),fileButton:this.createFileButton(),imageEl:void 0,imagePreloader:rf("div",this.CSS.imagePreloader),caption:rf("div",[this.CSS.input,this.CSS.caption],{contentEditable:!this.readOnly})},this.nodes.caption.dataset.placeholder=this.config.captionPlaceholder,this.nodes.imageContainer.appendChild(this.nodes.imagePreloader),this.nodes.wrapper.appendChild(this.nodes.imageContainer),this.nodes.wrapper.appendChild(this.nodes.caption),this.nodes.wrapper.appendChild(this.nodes.fileButton)}applyTune(e,r){this.nodes.wrapper.classList.toggle(`${this.CSS.wrapper}--${e}`,r)}render(){return this.toggleStatus("empty"),this.nodes.wrapper}showPreloader(e){this.nodes.imagePreloader.style.backgroundImage=`url(${e})`,this.toggleStatus("uploading")}hidePreloader(){this.nodes.imagePreloader.style.backgroundImage="",this.toggleStatus("empty")}fillImage(e){let r=/\.mp4$/.test(e)?"VIDEO":"IMG",o={src:e},n="load";r==="VIDEO"&&(o.autoplay=!0,o.loop=!0,o.muted=!0,o.playsinline=!0,n="loadeddata"),this.nodes.imageEl=rf(r,this.CSS.imageEl,o),this.nodes.imageEl.addEventListener(n,()=>{this.toggleStatus("filled"),this.nodes.imagePreloader!==void 0&&(this.nodes.imagePreloader.style.backgroundImage="")}),this.nodes.imageContainer.appendChild(this.nodes.imageEl)}fillCaption(e){this.nodes.caption!==void 0&&(this.nodes.caption.innerHTML=e)}toggleStatus(e){for(let r in sw)if(Object.prototype.hasOwnProperty.call(sw,r)){let o=sw[r];this.nodes.wrapper.classList.toggle(`${this.CSS.wrapper}--${o}`,o===e)}}get CSS(){return{baseClass:this.api.styles.block,loading:this.api.styles.loader,input:this.api.styles.input,button:this.api.styles.button,wrapper:"image-tool",imageContainer:"image-tool__image",imagePreloader:"image-tool__image-preloader",imageEl:"image-tool__image-picture",caption:"image-tool__caption"}}createFileButton(){let e=rf("div",[this.CSS.button]);return e.innerHTML=this.config.buttonContent??`${yX} ${this.api.i18n.t("Select an Image")}`,e.addEventListener("click",()=>{this.onSelectFile()}),e}};function ZLe(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var IX={exports:{}};(function(t,e){(function(r,o){t.exports=o()})(window,function(){return function(r){var o={};function n(a){if(o[a])return o[a].exports;var i=o[a]={i:a,l:!1,exports:{}};return r[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=r,n.c=o,n.d=function(a,i,s){n.o(a,i)||Object.defineProperty(a,i,{enumerable:!0,get:s})},n.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},n.t=function(a,i){if(1&i&&(a=n(a)),8&i||4&i&&typeof a=="object"&&a&&a.__esModule)return a;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:a}),2&i&&typeof a!="string")for(var l in a)n.d(s,l,function(c){return a[c]}.bind(null,l));return s},n.n=function(a){var i=a&&a.__esModule?function(){return a.default}:function(){return a};return n.d(i,"a",i),i},n.o=function(a,i){return Object.prototype.hasOwnProperty.call(a,i)},n.p="",n(n.s=3)}([function(r,o){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch{typeof window=="object"&&(n=window)}r.exports=n},function(r,o,n){(function(a){var i=n(2),s=setTimeout;function l(){}function c(_){if(!(this instanceof c))throw new TypeError("Promises must be constructed via new");if(typeof _!="function")throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],g(_,this)}function d(_,x){for(;_._state===3;)_=_._value;_._state!==0?(_._handled=!0,c._immediateFn(function(){var b=_._state===1?x.onFulfilled:x.onRejected;if(b!==null){var v;try{v=b(_._value)}catch(I){return void p(x.promise,I)}u(x.promise,v)}else(_._state===1?u:p)(x.promise,_._value)})):_._deferreds.push(x)}function u(_,x){try{if(x===_)throw new TypeError("A promise cannot be resolved with itself.");if(x&&(typeof x=="object"||typeof x=="function")){var b=x.then;if(x instanceof c)return _._state=3,_._value=x,void m(_);if(typeof b=="function")return void g((v=b,I=x,function(){v.apply(I,arguments)}),_)}_._state=1,_._value=x,m(_)}catch(E){p(_,E)}var v,I}function p(_,x){_._state=2,_._value=x,m(_)}function m(_){_._state===2&&_._deferreds.length===0&&c._immediateFn(function(){_._handled||c._unhandledRejectionFn(_._value)});for(var x=0,b=_._deferreds.length;x<b;x++)d(_,_._deferreds[x]);_._deferreds=null}function h(_,x,b){this.onFulfilled=typeof _=="function"?_:null,this.onRejected=typeof x=="function"?x:null,this.promise=b}function g(_,x){var b=!1;try{_(function(v){b||(b=!0,u(x,v))},function(v){b||(b=!0,p(x,v))})}catch(v){if(b)return;b=!0,p(x,v)}}c.prototype.catch=function(_){return this.then(null,_)},c.prototype.then=function(_,x){var b=new this.constructor(l);return d(this,new h(_,x,b)),b},c.prototype.finally=i.a,c.all=function(_){return new c(function(x,b){if(!_||_.length===void 0)throw new TypeError("Promise.all accepts an array");var v=Array.prototype.slice.call(_);if(v.length===0)return x([]);var I=v.length;function E(C,T){try{if(T&&(typeof T=="object"||typeof T=="function")){var k=T.then;if(typeof k=="function")return void k.call(T,function(S){E(C,S)},b)}v[C]=T,--I==0&&x(v)}catch(S){b(S)}}for(var y=0;y<v.length;y++)E(y,v[y])})},c.resolve=function(_){return _&&typeof _=="object"&&_.constructor===c?_:new c(function(x){x(_)})},c.reject=function(_){return new c(function(x,b){b(_)})},c.race=function(_){return new c(function(x,b){for(var v=0,I=_.length;v<I;v++)_[v].then(x,b)})},c._immediateFn=typeof a=="function"&&function(_){a(_)}||function(_){s(_,0)},c._unhandledRejectionFn=function(_){typeof console<"u"&&console&&console.warn("Possible Unhandled Promise Rejection:",_)},o.a=c}).call(this,n(5).setImmediate)},function(r,o,n){o.a=function(a){var i=this.constructor;return this.then(function(s){return i.resolve(a()).then(function(){return s})},function(s){return i.resolve(a()).then(function(){return i.reject(s)})})}},function(r,o,n){function a(g){return(a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _})(g)}n(4);var i,s,l,c,d,u,p,m=n(8),h=(s=function(g){return new Promise(function(_,x){g=c(g),(g=d(g)).beforeSend&&g.beforeSend();var b=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");b.open(g.method,g.url),b.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(g.headers).forEach(function(I){var E=g.headers[I];b.setRequestHeader(I,E)});var v=g.ratio;b.upload.addEventListener("progress",function(I){var E=Math.round(I.loaded/I.total*100),y=Math.ceil(E*v/100);g.progress(Math.min(y,100))},!1),b.addEventListener("progress",function(I){var E=Math.round(I.loaded/I.total*100),y=Math.ceil(E*(100-v)/100)+v;g.progress(Math.min(y,100))},!1),b.onreadystatechange=function(){if(b.readyState===4){var I=b.response;try{I=JSON.parse(I)}catch{}var E=m.parseHeaders(b.getAllResponseHeaders()),y={body:I,code:b.status,headers:E};p(b.status)?_(y):x(y)}},b.send(g.data)})},l=function(g){return g.method="POST",s(g)},c=function(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(g.url&&typeof g.url!="string")throw new Error("Url must be a string");if(g.url=g.url||"",g.method&&typeof g.method!="string")throw new Error("`method` must be a string or null");if(g.method=g.method?g.method.toUpperCase():"GET",g.headers&&a(g.headers)!=="object")throw new Error("`headers` must be an object or null");if(g.headers=g.headers||{},g.type&&(typeof g.type!="string"||!Object.values(i).includes(g.type)))throw new Error("`type` must be taken from module's \xABcontentType\xBB library");if(g.progress&&typeof g.progress!="function")throw new Error("`progress` must be a function or null");if(g.progress=g.progress||function(_){},g.beforeSend=g.beforeSend||function(_){},g.ratio&&typeof g.ratio!="number")throw new Error("`ratio` must be a number");if(g.ratio<0||g.ratio>100)throw new Error("`ratio` must be in a 0-100 interval");if(g.ratio=g.ratio||90,g.accept&&typeof g.accept!="string")throw new Error("`accept` must be a string with a list of allowed mime-types");if(g.accept=g.accept||"*/*",g.multiple&&typeof g.multiple!="boolean")throw new Error("`multiple` must be a true or false");if(g.multiple=g.multiple||!1,g.fieldName&&typeof g.fieldName!="string")throw new Error("`fieldName` must be a string");return g.fieldName=g.fieldName||"files",g},d=function(g){switch(g.method){case"GET":var _=u(g.data,i.URLENCODED);delete g.data,g.url=/\?/.test(g.url)?g.url+"&"+_:g.url+"?"+_;break;case"POST":case"PUT":case"DELETE":case"UPDATE":var x=function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).type||i.JSON}(g);(m.isFormData(g.data)||m.isFormElement(g.data))&&(x=i.FORM),g.data=u(g.data,x),x!==h.contentType.FORM&&(g.headers["content-type"]=x)}return g},u=function(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};switch(arguments.length>1?arguments[1]:void 0){case i.URLENCODED:return m.urlEncode(g);case i.JSON:return m.jsonEncode(g);case i.FORM:return m.formEncode(g);default:return g}},p=function(g){return g>=200&&g<300},{contentType:i={URLENCODED:"application/x-www-form-urlencoded; charset=utf-8",FORM:"multipart/form-data",JSON:"application/json; charset=utf-8"},request:s,get:function(g){return g.method="GET",s(g)},post:l,transport:function(g){return g=c(g),m.selectFiles(g).then(function(_){for(var x=new FormData,b=0;b<_.length;b++)x.append(g.fieldName,_[b],_[b].name);m.isObject(g.data)&&Object.keys(g.data).forEach(function(I){var E=g.data[I];x.append(I,E)});var v=g.beforeSend;return g.beforeSend=function(){return v(_)},g.data=x,l(g)})},selectFiles:function(g){return delete(g=c(g)).beforeSend,m.selectFiles(g)}});r.exports=h},function(r,o,n){n.r(o);var a=n(1);window.Promise=window.Promise||a.a},function(r,o,n){(function(a){var i=a!==void 0&&a||typeof self<"u"&&self||window,s=Function.prototype.apply;function l(c,d){this._id=c,this._clearFn=d}o.setTimeout=function(){return new l(s.call(setTimeout,i,arguments),clearTimeout)},o.setInterval=function(){return new l(s.call(setInterval,i,arguments),clearInterval)},o.clearTimeout=o.clearInterval=function(c){c&&c.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(i,this._id)},o.enroll=function(c,d){clearTimeout(c._idleTimeoutId),c._idleTimeout=d},o.unenroll=function(c){clearTimeout(c._idleTimeoutId),c._idleTimeout=-1},o._unrefActive=o.active=function(c){clearTimeout(c._idleTimeoutId);var d=c._idleTimeout;d>=0&&(c._idleTimeoutId=setTimeout(function(){c._onTimeout&&c._onTimeout()},d))},n(6),o.setImmediate=typeof self<"u"&&self.setImmediate||a!==void 0&&a.setImmediate||this&&this.setImmediate,o.clearImmediate=typeof self<"u"&&self.clearImmediate||a!==void 0&&a.clearImmediate||this&&this.clearImmediate}).call(this,n(0))},function(r,o,n){(function(a,i){(function(s,l){if(!s.setImmediate){var c,d,u,p,m,h=1,g={},_=!1,x=s.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(s);b=b&&b.setTimeout?b:s,{}.toString.call(s.process)==="[object process]"?c=function(E){i.nextTick(function(){I(E)})}:function(){if(s.postMessage&&!s.importScripts){var E=!0,y=s.onmessage;return s.onmessage=function(){E=!1},s.postMessage("","*"),s.onmessage=y,E}}()?(p="setImmediate$"+Math.random()+"$",m=function(E){E.source===s&&typeof E.data=="string"&&E.data.indexOf(p)===0&&I(+E.data.slice(p.length))},s.addEventListener?s.addEventListener("message",m,!1):s.attachEvent("onmessage",m),c=function(E){s.postMessage(p+E,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(E){I(E.data)},c=function(E){u.port2.postMessage(E)}):x&&"onreadystatechange"in x.createElement("script")?(d=x.documentElement,c=function(E){var y=x.createElement("script");y.onreadystatechange=function(){I(E),y.onreadystatechange=null,d.removeChild(y),y=null},d.appendChild(y)}):c=function(E){setTimeout(I,0,E)},b.setImmediate=function(E){typeof E!="function"&&(E=new Function(""+E));for(var y=new Array(arguments.length-1),C=0;C<y.length;C++)y[C]=arguments[C+1];var T={callback:E,args:y};return g[h]=T,c(h),h++},b.clearImmediate=v}function v(E){delete g[E]}function I(E){if(_)setTimeout(I,0,E);else{var y=g[E];if(y){_=!0;try{(function(C){var T=C.callback,k=C.args;switch(k.length){case 0:T();break;case 1:T(k[0]);break;case 2:T(k[0],k[1]);break;case 3:T(k[0],k[1],k[2]);break;default:T.apply(l,k)}})(y)}finally{v(E),_=!1}}}}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,n(0),n(7))},function(r,o){var n,a,i=r.exports={};function s(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function c(b){if(n===setTimeout)return setTimeout(b,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(b,0);try{return n(b,0)}catch{try{return n.call(null,b,0)}catch{return n.call(this,b,0)}}}(function(){try{n=typeof setTimeout=="function"?setTimeout:s}catch{n=s}try{a=typeof clearTimeout=="function"?clearTimeout:l}catch{a=l}})();var d,u=[],p=!1,m=-1;function h(){p&&d&&(p=!1,d.length?u=d.concat(u):m=-1,u.length&&g())}function g(){if(!p){var b=c(h);p=!0;for(var v=u.length;v;){for(d=u,u=[];++m<v;)d&&d[m].run();m=-1,v=u.length}d=null,p=!1,function(I){if(a===clearTimeout)return clearTimeout(I);if((a===l||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(I);try{a(I)}catch{try{return a.call(null,I)}catch{return a.call(this,I)}}}(b)}}function _(b,v){this.fun=b,this.array=v}function x(){}i.nextTick=function(b){var v=new Array(arguments.length-1);if(arguments.length>1)for(var I=1;I<arguments.length;I++)v[I-1]=arguments[I];u.push(new _(b,v)),u.length!==1||p||c(g)},_.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=x,i.addListener=x,i.once=x,i.off=x,i.removeListener=x,i.removeAllListeners=x,i.emit=x,i.prependListener=x,i.prependOnceListener=x,i.listeners=function(b){return[]},i.binding=function(b){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(b){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(r,o,n){function a(s,l){for(var c=0;c<l.length;c++){var d=l[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(s,d.key,d)}}var i=n(9);r.exports=function(){function s(){(function(u,p){if(!(u instanceof p))throw new TypeError("Cannot call a class as a function")})(this,s)}var l,c,d;return l=s,d=[{key:"urlEncode",value:function(u){return i(u)}},{key:"jsonEncode",value:function(u){return JSON.stringify(u)}},{key:"formEncode",value:function(u){if(this.isFormData(u))return u;if(this.isFormElement(u))return new FormData(u);if(this.isObject(u)){var p=new FormData;return Object.keys(u).forEach(function(m){var h=u[m];p.append(m,h)}),p}throw new Error("`data` must be an instance of Object, FormData or <FORM> HTMLElement")}},{key:"isObject",value:function(u){return Object.prototype.toString.call(u)==="[object Object]"}},{key:"isFormData",value:function(u){return u instanceof FormData}},{key:"isFormElement",value:function(u){return u instanceof HTMLFormElement}},{key:"selectFiles",value:function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new Promise(function(p,m){var h=document.createElement("INPUT");h.type="file",u.multiple&&h.setAttribute("multiple","multiple"),u.accept&&h.setAttribute("accept",u.accept),h.style.display="none",document.body.appendChild(h),h.addEventListener("change",function(g){var _=g.target.files;p(_),document.body.removeChild(h)},!1),h.click()})}},{key:"parseHeaders",value:function(u){var p=u.trim().split(/[\r\n]+/),m={};return p.forEach(function(h){var g=h.split(": "),_=g.shift(),x=g.join(": ");_&&(m[_]=x)}),m}}],(c=null)&&a(l.prototype,c),d&&a(l,d),s}()},function(r,o){var n=function(i){return encodeURIComponent(i).replace(/[!'()*]/g,escape).replace(/%20/g,"+")},a=function(i,s,l,c){return s=s||null,l=l||"&",c=c||null,i?function(d){for(var u=new Array,p=0;p<d.length;p++)d[p]&&u.push(d[p]);return u}(Object.keys(i).map(function(d){var u,p,m=d;if(c&&(m=c+"["+m+"]"),typeof i[d]=="object"&&i[d]!==null)u=a(i[d],null,l,m);else{s&&(p=m,m=!isNaN(parseFloat(p))&&isFinite(p)?s+Number(m):m);var h=i[d];h=(h=(h=(h=h===!0?"1":h)===!1?"0":h)===0?"0":h)||"",u=n(m)+"="+n(h)}return u})).join(l).replace(/[!'()*]/g,""):""};r.exports=a}])})})(IX);var JLe=IX.exports,of=ZLe(JLe);function QA(t){return t!==void 0&&typeof t.then=="function"}var JA=class{constructor({config:e,onUpload:r,onError:o}){this.config=e,this.onUpload=r,this.onError=o}uploadSelectedFile({onPreview:e}){let r=function(n){let a=new FileReader;a.readAsDataURL(n),a.onload=i=>{e(i.target.result)}},o;if(this.config.uploader&&typeof this.config.uploader.uploadByFile=="function"){let n=this.config.uploader.uploadByFile;o=of.selectFiles({accept:this.config.types??"image/*"}).then(a=>{r(a[0]);let i=n(a[0]);return QA(i)||console.warn("Custom uploader method uploadByFile should return a Promise"),i})}else o=of.transport({url:this.config.endpoints.byFile,data:this.config.additionalRequestData,accept:this.config.types??"image/*",headers:this.config.additionalRequestHeaders,beforeSend:n=>{r(n[0])},fieldName:this.config.field??"image"}).then(n=>n.body);o.then(n=>{this.onUpload(n)}).catch(n=>{this.onError(n)})}uploadByUrl(e){let r;this.config.uploader&&typeof this.config.uploader.uploadByUrl=="function"?(r=this.config.uploader.uploadByUrl(e),QA(r)||console.warn("Custom uploader method uploadByUrl should return a Promise")):r=of.post({url:this.config.endpoints.byUrl,data:Object.assign({url:e},this.config.additionalRequestData),type:of.contentType.JSON,headers:this.config.additionalRequestHeaders}).then(o=>o.body),r.then(o=>{this.onUpload(o)}).catch(o=>{this.onError(o)})}uploadByFile(e,{onPreview:r}){let o=new FileReader;o.readAsDataURL(e),o.onload=a=>{r(a.target.result)};let n;if(this.config.uploader&&typeof this.config.uploader.uploadByFile=="function")n=this.config.uploader.uploadByFile(e),QA(n)||console.warn("Custom uploader method uploadByFile should return a Promise");else{let a=new FormData;a.append(this.config.field??"image",e),this.config.additionalRequestData&&Object.keys(this.config.additionalRequestData).length&&Object.entries(this.config.additionalRequestData).forEach(([i,s])=>{a.append(i,s)}),n=of.post({url:this.config.endpoints.byFile,data:a,type:of.contentType.JSON,headers:this.config.additionalRequestHeaders}).then(i=>i.body)}n.then(a=>{this.onUpload(a)}).catch(a=>{this.onError(a)})}};var lw=class t{constructor({data:e,config:r,api:o,readOnly:n,block:a}){this.isCaptionEnabled=null,this.api=o,this.block=a,this.config={endpoints:r.endpoints,additionalRequestData:r.additionalRequestData,additionalRequestHeaders:r.additionalRequestHeaders,field:r.field,types:r.types,captionPlaceholder:this.api.i18n.t(r.captionPlaceholder??"Caption"),buttonContent:r.buttonContent,uploader:r.uploader,actions:r.actions,features:r.features||{}},this.uploader=new JA({config:this.config,onUpload:i=>this.onUpload(i),onError:i=>this.uploadingFailed(i)}),this.ui=new ZA({api:o,config:this.config,onSelectFile:()=>{this.uploader.uploadSelectedFile({onPreview:i=>{this.ui.showPreloader(i)}})},readOnly:n}),this._data={caption:"",withBorder:!1,withBackground:!1,stretched:!1,file:{url:""}},this.data=e}static get isReadOnlySupported(){return!0}static get toolbox(){return{icon:yX,title:"Image"}}static get tunes(){return[{name:"withBorder",icon:YLe,title:"With border",toggle:!0},{name:"stretched",icon:XLe,title:"Stretch image",toggle:!0},{name:"withBackground",icon:KLe,title:"With background",toggle:!0}]}render(){var e,r,o;return(((e=this.config.features)==null?void 0:e.caption)===!0||((r=this.config.features)==null?void 0:r.caption)===void 0||((o=this.config.features)==null?void 0:o.caption)==="optional"&&this.data.caption)&&(this.isCaptionEnabled=!0),this.ui.render()}validate(e){return!!e.file.url}save(){let e=this.ui.nodes.caption;return this._data.caption=e.innerHTML,this.data}renderSettings(){var e;let r=t.tunes.concat(this.config.actions||[]),o={border:"withBorder",background:"withBackground",stretch:"stretched",caption:"caption"};((e=this.config.features)==null?void 0:e.caption)==="optional"&&r.push({name:"caption",icon:QLe,title:"With caption",toggle:!0});let n=r.filter(i=>{var s,l;let c=Object.keys(o).find(d=>o[d]===i.name);return c==="caption"?((s=this.config.features)==null?void 0:s.caption)!==!1:c==null||((l=this.config.features)==null?void 0:l[c])!==!1}),a=i=>{let s=this.data[i.name];return i.name==="caption"&&(s=this.isCaptionEnabled??s),s};return n.map(i=>({icon:i.icon,label:this.api.i18n.t(i.title),name:i.name,toggle:i.toggle,isActive:a(i),onActivate:()=>{if(typeof i.action=="function"){i.action(i.name);return}let s=!a(i);i.name==="caption"&&(this.isCaptionEnabled=!(this.isCaptionEnabled??!1),s=this.isCaptionEnabled),this.tuneToggled(i.name,s)}}))}appendCallback(){this.ui.nodes.fileButton.click()}static get pasteConfig(){return{tags:[{img:{src:!0}}],patterns:{image:/https?:\/\/\S+\.(gif|jpe?g|tiff|png|svg|webp)(\?[a-z0-9=]*)?$/i},files:{mimeTypes:["image/*"]}}}async onPaste(e){switch(e.type){case"tag":{let r=e.detail.data;if(/^blob:/.test(r.src)){let o=await(await fetch(r.src)).blob();this.uploadFile(o);break}this.uploadUrl(r.src);break}case"pattern":{let r=e.detail.data;this.uploadUrl(r);break}case"file":{let r=e.detail.file;this.uploadFile(r);break}}}set data(e){this.image=e.file,this._data.caption=e.caption||"",this.ui.fillCaption(this._data.caption),t.tunes.forEach(({name:r})=>{let o=typeof e[r]<"u"?e[r]===!0||e[r]==="true":!1;this.setTune(r,o)}),e.caption&&this.setTune("caption",!0)}get data(){return this._data}set image(e){this._data.file=e||{url:""},e&&e.url&&this.ui.fillImage(e.url)}onUpload(e){e.success&&e.file?this.image=e.file:this.uploadingFailed("incorrect response: "+JSON.stringify(e))}uploadingFailed(e){console.log("Image Tool: uploading failed because of",e),this.api.notifier.show({message:this.api.i18n.t("Couldn\u2019t upload image. Please try another."),style:"error"}),this.ui.hidePreloader()}tuneToggled(e,r){e==="caption"?(this.ui.applyTune(e,r),r==!1&&(this._data.caption="",this.ui.fillCaption(""))):this.setTune(e,r)}setTune(e,r){this._data[e]=r,this.ui.applyTune(e,r),e==="stretched"&&Promise.resolve().then(()=>{this.block.stretched=r}).catch(o=>{console.error(o)})}uploadFile(e){this.uploader.uploadByFile(e,{onPreview:r=>{this.ui.showPreloader(r)}})}uploadUrl(e){this.ui.showPreloader(e),this.uploader.uploadByUrl(e)}};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.cdx-nested-list{margin:0;padding:0;outline:none;counter-reset:item;list-style:none}.cdx-nested-list__item{line-height:1.6em;display:flex;margin:2px 0}.cdx-nested-list__item [contenteditable]{outline:none}.cdx-nested-list__item-body{flex-grow:2}.cdx-nested-list__item-content,.cdx-nested-list__item-children{flex-basis:100%}.cdx-nested-list__item-content{word-break:break-word;white-space:pre-wrap}.cdx-nested-list__item:before{counter-increment:item;margin-right:5px;white-space:nowrap}.cdx-nested-list--ordered>.cdx-nested-list__item:before{content:counters(item,".") ". "}.cdx-nested-list--unordered>.cdx-nested-list__item:before{content:"\u2022"}.cdx-nested-list__settings{display:flex}.cdx-nested-list__settings .cdx-settings-button{width:50%}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();function Ui(t){return t.nodeType===Node.ELEMENT_NODE}function nf(t,e=null,r){let o=document.createElement(t);Array.isArray(e)?o.classList.add(...e):e&&o.classList.add(e);for(let n in r)o[n]=r[n];return o}function wX(t){let e=nf("div");return e.appendChild(t),e.innerHTML}function SX(t){let e;return t.nodeType!==Node.ELEMENT_NODE?e=t.textContent:(e=t.innerHTML,e=e.replaceAll("<br>","")),e?.trim().length===0}var Vs=class t{constructor(){this.savedFakeCaret=void 0}save(){let e=t.range,r=nf("span");r.hidden=!0,e&&(e.insertNode(r),this.savedFakeCaret=r)}restore(){if(!this.savedFakeCaret)return;let e=window.getSelection();if(!e)return;let r=new Range;r.setStartAfter(this.savedFakeCaret),r.setEndAfter(this.savedFakeCaret),e.removeAllRanges(),e.addRange(r),setTimeout(()=>{var o;(o=this.savedFakeCaret)==null||o.remove()},150)}static get range(){let e=window.getSelection();return e&&e.rangeCount?e.getRangeAt(0):null}static extractFragmentFromCaretPositionTillTheEnd(){let e=window.getSelection();if(!e||!e.rangeCount)return;let r=e.getRangeAt(0),o=r.startContainer;if(o.nodeType!==Node.ELEMENT_NODE){if(!o.parentNode)return;o=o.parentNode}if(!Ui(o))return;let n=o.closest("[contenteditable]");if(!n)return;r.deleteContents();let a=r.cloneRange();return a.selectNodeContents(n),a.setStart(r.endContainer,r.endOffset),a.extractContents()}static focus(e,r=!0){let o=document.createRange(),n=window.getSelection();n&&(o.selectNodeContents(e),o.collapse(r),n.removeAllRanges(),n.addRange(o))}static isAtStart(){let e=window.getSelection();if(!e||e.focusOffset>0)return!1;let r=e.focusNode;return!r||!Ui(r)?!1:t.getHigherLevelSiblings(r,"left").every(o=>SX(o))}static getHigherLevelSiblings(e,r="left"){let o=e,n=[];for(;o.parentNode&&o.parentNode.contentEditable!=="true";)o=o.parentNode;let a=r==="left"?"previousSibling":"nextSibling";for(;o[a];)o=o[a],n.push(o);return n}},eBe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="9" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 17H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 12H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 7H4.99002"/></svg>',EX='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="12" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7.79999 14L7.79999 7.2135C7.79999 7.12872 7.7011 7.0824 7.63597 7.13668L4.79999 9.5"/></svg>',$h=class t{static get isReadOnlySupported(){return!0}static get enableLineBreaks(){return!0}static get toolbox(){return{icon:EX,title:"List"}}constructor({data:e,config:r,api:o,readOnly:n}){var a;this.nodes={wrapper:null},this.api=o,this.readOnly=n,this.config=r,this.defaultListStyle=((a=this.config)==null?void 0:a.defaultStyle)==="ordered"?"ordered":"unordered";let i={style:this.defaultListStyle,items:[]};this.data=e&&Object.keys(e).length?e:i,this.caret=new Vs}render(){return this.nodes.wrapper=this.makeListWrapper(this.data.style,[this.CSS.baseBlock]),this.data.items.length?this.appendItems(this.data.items,this.nodes.wrapper):this.appendItems([{content:"",items:[]}],this.nodes.wrapper),this.readOnly||this.nodes.wrapper.addEventListener("keydown",e=>{switch(e.key){case"Enter":this.enterPressed(e);break;case"Backspace":this.backspace(e);break;case"Tab":e.shiftKey?this.shiftTab(e):this.addTab(e);break}},!1),this.nodes.wrapper}renderSettings(){return[{name:"unordered",label:this.api.i18n.t("Unordered"),icon:eBe},{name:"ordered",label:this.api.i18n.t("Ordered"),icon:EX}].map(e=>({name:e.name,icon:e.icon,label:e.label,isActive:this.data.style===e.name,closeOnActivate:!0,onActivate:()=>{this.listStyle=e.name}}))}static get pasteConfig(){return{tags:["OL","UL","LI"]}}onPaste(e){let r=e.detail.data;this.data=this.pasteHandler(r);let o=this.nodes.wrapper;o&&o.parentNode&&o.parentNode.replaceChild(this.render(),o)}pasteHandler(e){let{tagName:r}=e,o="unordered",n;switch(r){case"OL":o="ordered",n="ol";break;case"UL":case"LI":o="unordered",n="ul"}let a={style:o,items:[]},i=s=>Array.from(s.querySelectorAll(":scope > li")).map(l=>{var c;let d=l.querySelector(`:scope > ${n}`),u=d?i(d):[];return{content:((c=l?.firstChild)==null?void 0:c.textContent)||"",items:u}});return a.items=i(e),a}appendItems(e,r){e.forEach(o=>{let n=this.createItem(o.content,o.items);r.appendChild(n)})}createItem(e,r=[]){let o=nf("li",this.CSS.item),n=nf("div",this.CSS.itemBody),a=nf("div",this.CSS.itemContent,{innerHTML:e,contentEditable:(!this.readOnly).toString()});return n.appendChild(a),o.appendChild(n),r&&r.length>0&&this.addChildrenList(o,r),o}save(){let e=r=>Array.from(r.querySelectorAll(`:scope > .${this.CSS.item}`)).map(o=>{let n=o.querySelector(`.${this.CSS.itemChildren}`),a=this.getItemContent(o),i=n?e(n):[];return{content:a,items:i}});return{style:this.data.style,items:this.nodes.wrapper?e(this.nodes.wrapper):[]}}addChildrenList(e,r){let o=e.querySelector(`.${this.CSS.itemBody}`),n=this.makeListWrapper(void 0,[this.CSS.itemChildren]);this.appendItems(r,n),o&&o.appendChild(n)}makeListWrapper(e=this.listStyle,r=[]){let o=e==="ordered"?"ol":"ul",n=e==="ordered"?this.CSS.wrapperOrdered:this.CSS.wrapperUnordered;return r.push(n),nf(o,[this.CSS.wrapper,...r])}get CSS(){return{baseBlock:this.api.styles.block,wrapper:"cdx-nested-list",wrapperOrdered:"cdx-nested-list--ordered",wrapperUnordered:"cdx-nested-list--unordered",item:"cdx-nested-list__item",itemBody:"cdx-nested-list__item-body",itemContent:"cdx-nested-list__item-content",itemChildren:"cdx-nested-list__item-children",settingsWrapper:"cdx-nested-list__settings",settingsButton:this.api.styles.settingsButton,settingsButtonActive:this.api.styles.settingsButtonActive}}get listStyle(){return this.data.style||this.defaultListStyle}set listStyle(e){if(!this.nodes||!this.nodes.wrapper)return;let r=Array.from(this.nodes.wrapper.querySelectorAll(`.${this.CSS.wrapper}`));r.push(this.nodes.wrapper),r.forEach(o=>{o.classList.toggle(this.CSS.wrapperUnordered,e==="unordered"),o.classList.toggle(this.CSS.wrapperOrdered,e==="ordered")}),this.data.style=e}get currentItem(){let e=window.getSelection();if(!e)return null;let r=e.anchorNode;return!r||(Ui(r)||(r=r.parentNode),!r)||!Ui(r)?null:r.closest(`.${this.CSS.item}`)}enterPressed(e){let r=this.currentItem;if(e.stopPropagation(),e.preventDefault(),e.isComposing)return;let o=r?this.getItemContent(r).trim().length===0:!0,n=r?.parentNode===this.nodes.wrapper,a=r?.nextElementSibling===null;if(n&&a&&o){this.getOutOfList();return}else if(a&&o){this.unshiftItem();return}let i=Vs.extractFragmentFromCaretPositionTillTheEnd();if(!i)return;let s=wX(i),l=r?.querySelector(`.${this.CSS.itemChildren}`),c=this.createItem(s,void 0);l&&Array.from(l.querySelectorAll(`.${this.CSS.item}`)).length>0?l.prepend(c):r?.after(c),this.focusItem(c)}unshiftItem(){let e=this.currentItem;if(!e||!e.parentNode||!Ui(e.parentNode))return;let r=e.parentNode.closest(`.${this.CSS.item}`);if(!r)return;this.caret.save(),r.after(e),this.caret.restore();let o=r.querySelector(`.${this.CSS.itemChildren}`);o&&o.children.length===0&&o.remove()}getItemContent(e){let r=e.querySelector(`.${this.CSS.itemContent}`);return!r||SX(r)?"":r.innerHTML}focusItem(e,r=!0){let o=e.querySelector(`.${this.CSS.itemContent}`);o&&Vs.focus(o,r)}getOutOfList(){var e;(e=this.currentItem)==null||e.remove(),this.api.blocks.insert(),this.api.caret.setToBlock(this.api.blocks.getCurrentBlockIndex())}backspace(e){if(!Vs.isAtStart())return;e.preventDefault();let r=this.currentItem;if(!r)return;let o=r.previousSibling;if(!r.parentNode||!Ui(r.parentNode))return;let n=r.parentNode.closest(`.${this.CSS.item}`);if(!o&&!n||o&&!Ui(o))return;e.stopPropagation();let a;if(o){let d=o.querySelectorAll(`.${this.CSS.item}`);a=Array.from(d).pop()||o}else a=n;let i=Vs.extractFragmentFromCaretPositionTillTheEnd();if(!i)return;let s=wX(i);if(!a)return;let l=a.querySelector(`.${this.CSS.itemContent}`);if(!l)return;Vs.focus(l,!1),this.caret.save(),l.insertAdjacentHTML("beforeend",s);let c=r.querySelectorAll(`.${this.CSS.itemChildren} > .${this.CSS.item}`);c=Array.from(c),c=c.filter(d=>!d.parentNode||!Ui(d.parentNode)?!1:d.parentNode.closest(`.${this.CSS.item}`)===r),c.reverse().forEach(d=>{o?a.after(d):r.after(d)}),r.remove(),this.caret.restore()}addTab(e){e.stopPropagation(),e.preventDefault();let r=this.currentItem;if(!r)return;let o=r.previousSibling;if(!o||!Ui(o)||!o)return;let n=o.querySelector(`.${this.CSS.itemChildren}`);if(this.caret.save(),n)n.appendChild(r);else{let a=this.makeListWrapper(void 0,[this.CSS.itemChildren]),i=o.querySelector(`.${this.CSS.itemBody}`);a.appendChild(r),i?.appendChild(a)}this.caret.restore()}shiftTab(e){e.stopPropagation(),e.preventDefault(),this.unshiftItem()}static joinRecursive(e){return e.items.map(r=>`${r.content} ${t.joinRecursive(r)}`).join("")}static get conversionConfig(){return{export:e=>t.joinRecursive(e),import:e=>({items:[{content:e,items:[]}],style:"unordered"})}}};(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".ce-rawtool__textarea{min-height:200px;resize:vertical;border-radius:8px;border:0;background-color:#1e2128;font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:12px;line-height:1.6;letter-spacing:-.2px;color:#a1a7b6;overscroll-behavior:contain}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var tBe='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16.6954 5C17.912 5 18.8468 6.07716 18.6755 7.28165L17.426 16.0659C17.3183 16.8229 16.7885 17.4522 16.061 17.6873L12.6151 18.8012C12.2152 18.9304 11.7848 18.9304 11.3849 18.8012L7.93898 17.6873C7.21148 17.4522 6.6817 16.8229 6.57403 16.0659L5.32454 7.28165C5.15322 6.07716 6.088 5 7.30461 5H16.6954Z"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 8.4H9L9.42857 11.7939H14.5714L14.3571 13.2788L14.1429 14.7636L12 15.4L9.85714 14.7636L9.77143 14.3394"/></svg>';var cw=class t{static get isReadOnlySupported(){return!0}static get displayInToolbox(){return!0}static get enableLineBreaks(){return!0}static get toolbox(){return{icon:tBe,title:"Raw HTML"}}constructor({data:e,config:r,api:o,readOnly:n}){this.api=o,this.readOnly=n,this.placeholder=o.i18n.t(r.placeholder||t.DEFAULT_PLACEHOLDER),this.CSS={baseClass:this.api.styles.block,input:this.api.styles.input,wrapper:"ce-rawtool",textarea:"ce-rawtool__textarea"},this.data={html:e.html||""},this.textarea=null,this.resizeDebounce=null}render(){let e=document.createElement("div"),r=100;return this.textarea=document.createElement("textarea"),e.classList.add(this.CSS.baseClass,this.CSS.wrapper),this.textarea.classList.add(this.CSS.textarea,this.CSS.input),this.textarea.textContent=this.data.html,this.textarea.placeholder=this.placeholder,this.readOnly?this.textarea.disabled=!0:this.textarea.addEventListener("input",()=>{this.onInput()}),e.appendChild(this.textarea),setTimeout(()=>{this.resize()},r),e}save(e){return{html:e.querySelector("textarea").value}}static get DEFAULT_PLACEHOLDER(){return"Enter HTML code"}static get sanitize(){return{html:!0}}onInput(){this.resizeDebounce&&clearTimeout(this.resizeDebounce),this.resizeDebounce=setTimeout(()=>{this.resize()},200)}resize(){this.textarea.style.height="auto",this.textarea.style.height=this.textarea.scrollHeight+"px"}};ye();var eN="S",tN=class t{static get CSS(){return""}static get shortcut(){return"CMD+SHIFT+X"}constructor(e){this.api=e.api,this.button=document.createElement("button"),this.iconClasses={base:this.api.styles.inlineToolButton,active:this.api.styles.inlineToolButtonActive}}static get isInline(){return!0}render(){return this.button?(this.button.type="button",this.button.classList.add(this.iconClasses.base),this.button.innerHTML=this.toolboxIcon,this.button):null}surround(e){if(!e)return;let r=this.api.selection.findParentTag(eN,t.CSS);r?this.unwrap(r):this.wrap(e)}wrap(e){let r=document.createElement(eN);r.appendChild(e.extractContents()),e.insertNode(r),this.api.selection.expandToTag(r)}unwrap(e){this.api.selection.expandToTag(e);let r=window.getSelection(),o=r.getRangeAt(0),n=o.extractContents();e.parentNode.removeChild(e),o.insertNode(n),r.removeAllRanges(),r.addRange(o)}checkState(){let e=this.api.selection.findParentTag(eN,t.CSS);this.button.classList.toggle(this.iconClasses.active,!!e)}get toolboxIcon(){return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="12" height="12"><path d="M17.154 14c.23.516.346 1.09.346 1.72 0 1.342-.524 2.392-1.571 3.147C14.88 19.622 13.433 20 11.586 20c-1.64 0-3.263-.381-4.87-1.144V16.6c1.52.877 3.075 1.316 4.666 1.316 2.551 0 3.83-.732 3.839-2.197a2.21 2.21 0 0 0-.648-1.603l-.12-.117H3v-2h18v2h-3.846zm-4.078-3H7.629a4.086 4.086 0 0 1-.481-.522C6.716 9.92 6.5 9.246 6.5 8.452c0-1.236.466-2.287 1.397-3.153C8.83 4.433 10.271 4 12.222 4c1.471 0 2.879.328 4.222.984v2.152c-1.2-.687-2.515-1.03-3.946-1.03-2.48 0-3.719.782-3.719 2.346 0 .42.218.786.654 1.099.436.313.974.562 1.613.75.62.18 1.297.414 2.03.699z"/></svg>'}static get sanitize(){return{s:{}}}},CX=tN;var rN="SUP",oN=class t{static get CSS(){return""}static get shortcut(){return"CMD+."}constructor(e){this.api=e.api,this.button=document.createElement("button"),this.iconClasses={base:this.api.styles.inlineToolButton,active:this.api.styles.inlineToolButtonActive}}static get isInline(){return!0}render(){return this.button?(this.button.type="button",this.button.classList.add(this.iconClasses.base),this.button.innerHTML=this.toolboxIcon,this.button):null}surround(e){if(!e)return;let r=this.api.selection.findParentTag(rN,t.CSS);r?this.unwrap(r):this.wrap(e)}wrap(e){let r=document.createElement(rN);r.appendChild(e.extractContents()),e.insertNode(r),this.api.selection.expandToTag(r)}unwrap(e){this.api.selection.expandToTag(e);let r=window.getSelection(),o=r.getRangeAt(0),n=o.extractContents();e.parentNode.removeChild(e),o.insertNode(n),r.removeAllRanges(),r.addRange(o)}checkState(){let e=this.api.selection.findParentTag(rN,t.CSS);this.button.classList.toggle(this.iconClasses.active,!!e)}get toolboxIcon(){return'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" stroke-width="2" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" style="stroke: none !important" /><path d="M5 7l8 10m-8 0l8 -10" /><path d="M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2" /></svg>'}static get sanitize(){return{sup:{}}}},kX=oN;var nN="U",aN=class t{static get CSS(){return""}static get shortcut(){return"CMD+U"}constructor(e){this.api=e.api,this.button=document.createElement("button"),this.iconClasses={base:this.api.styles.inlineToolButton,active:this.api.styles.inlineToolButtonActive}}static get isInline(){return!0}render(){return this.button?(this.button.type="button",this.button.classList.add(this.iconClasses.base),this.button.innerHTML=this.toolboxIcon,this.button):null}surround(e){if(!e)return;let r=this.api.selection.findParentTag(nN,t.CSS);r?this.unwrap(r):this.wrap(e)}wrap(e){let r=document.createElement(nN);r.appendChild(e.extractContents()),e.insertNode(r),this.api.selection.expandToTag(r)}unwrap(e){this.api.selection.expandToTag(e);let r=window.getSelection(),o=r.getRangeAt(0),n=o.extractContents();e.parentNode.removeChild(e),o.insertNode(n),r.removeAllRanges(),r.addRange(o)}checkState(){let e=this.api.selection.findParentTag(nN,t.CSS);this.button.classList.toggle(this.iconClasses.active,!!e)}get toolboxIcon(){return'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 7.5V11.5C9 12.2956 9.31607 13.0587 9.87868 13.6213C10.4413 14.1839 11.2044 14.5 12 14.5C12.7956 14.5 13.5587 14.1839 14.1213 13.6213C14.6839 13.0587 15 12.2956 15 11.5V7.5" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M7.71429 18H16.2857" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'}static get sanitize(){return{u:{}}}},TX=aN;function PX(t){let e=U(null),[r,o]=P(null),[n,a]=P({blocks:[{type:"paragraph",data:{}}]}),i=t.placeholder||"Start typing...";return L(()=>{if(!r)return;let s=t.value;if(n?.time!==s?.time){let l=n?.time||0;(s?.time||0)>l&&iN(s)&&((s?.blocks||[]).length>0?r.render(s):r.render({...s,blocks:[{type:"paragraph",data:{text:""}}]}),a(s))}},[r,t.value]),L(()=>{let s=e.current,l=XI,c=new l({holder:s,placeholder:i,inlineToolbar:["bold","italic","underline","strikethrough","superscript","link"],tools:{heading:{class:iw,config:{placeholder:"Enter a header",levels:[2,3,4,5],defaultLevel:2}},strikethrough:{class:CX},superscript:{class:kX},underline:{class:TX},image:{class:lw,config:{uploader:rBe(),captionPlaceholder:"Alt text"}},unorderedList:{class:$h,inlineToolbar:!0,config:{defaultStyle:"unordered"},toolbox:{name:"unorderedList",title:"Bulleted List",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="9" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="9" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 17H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 12H4.99002"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M5.00001 7H4.99002"/></svg>'}},orderedList:{class:$h,inlineToolbar:!0,config:{defaultStyle:"ordered"},toolbox:{name:"orderedList",title:"Numbered List",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><line x1="12" x2="19" y1="7" y2="7" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="12" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><line x1="12" x2="19" y1="17" y2="17" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7.79999 14L7.79999 7.2135C7.79999 7.12872 7.7011 7.0824 7.63597 7.13668L4.79999 9.5"/></svg>'}},html:{class:cw,toolbox:{name:"HTML"}}},onReady:()=>{o(c)},onChange:()=>{c.save().then(d=>{a(d),t.onChange&&t.onChange(d)}).catch(d=>{console.error("richtext error: ",d)})}});return()=>{c&&typeof c.destroy=="function"&&c.destroy()}},[]),f("div",{ref:e,className:Te(t.className,"RichTextEditor")})}function iN(t){return ki(t)&&Array.isArray(t.blocks)&&t.blocks.length>0}function rBe(){return{uploadByFile:async t=>{try{let e=await Ns(t),r=e.src;return oBe(r)&&(r=`${r}=s0-e365`),console.log(e),{success:1,file:{...e,url:r}}}catch(e){return console.error(e),{success:0,error:e}}},uploadByUrl:async t=>({success:0,error:"upload by url not currently supported"})}}function oBe(t){return t.startsWith("https://lh3.googleusercontent.com/")}function Hh(t,e){if(e==null)return!0;switch(t.type){case"string":case"select":case"date":case"datetime":return e==="";case"multiselect":return!Array.isArray(e)||e.length===0;case"number":case"boolean":return e==null;case"image":case"file":return!e||!e.src;case"reference":return!e||!e.id;case"richtext":return!iN(e);case"object":if(!ki(e)||Object.keys(e).length===0)return!0;for(let r of t.fields||[])if(r.id&&!Hh(r,e[r.id]))return!1;return!0;case"array":if(!ki(e)||!Array.isArray(e._array)||e._array.length===0)return!0;for(let r of e._array)if(!Hh(t.of,e[r]))return!1;return!1;case"oneof":{if(!ki(e)||!e._type)return!0;let r=(t.types||[]).find(o=>o.name===e._type);if(!r)return!0;for(let o of r.fields||[])if(o.id&&!Hh(o,e[o.id]))return!1;return!0}default:return!1}}ye();function OX(t,e){let r=!1;return(...o)=>{r||(t(...o),r=!0,setTimeout(()=>{r=!1},e))}}var jh=class extends Fs{constructor(r){super();this.interval=0;this.timeout=0;this.interval=r}start(){this.timeout=window.setTimeout(()=>{this.tick()},this.interval)}tick(){this.dispatch("tick"),this.start()}reset(){this.stop(),this.start()}stop(){this.timeout&&(window.clearTimeout(this.timeout),this.timeout=0)}};var nBe=30*Br.second,DX=5*Br.minute,sN=class extends Fs{constructor(r){super();this.started=!1;this.timer=new jh(nBe);this.idleTimer=new jh(DX);this.onUserInteraction=OX(()=>{this.idleTimer.reset()},5e3);this.id=r;let o=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db;this.docRef=Ee(n,"Projects",o,"Viewers",r),this.timer.on("tick",()=>this.onTick()),this.idleTimer.on("tick",()=>this.onIdle()),window.addEventListener("mousemove",this.onUserInteraction),window.addEventListener("keypress",this.onUserInteraction)}async start(){this.started||(this.started=!0,this.dbUnsubscribe=Bv(this.docRef,r=>{let o=r.data();this.onData(o)}),this.onTick(),this.timer.start())}onData(r){let o=window.firebase.user,n=dt.now(),a=Object.values(r).filter(i=>!(i.email===o.email||n.toMillis()-i.lastViewedAt.toMillis()>DX));this.dispatch("change",a)}async onTick(){let r=window.firebase.user;if(!r.email){console.log("no user email:",r);return}console.log(`updating lastViewedAt for ${r.email}`),await cu(this.docRef,{[r.email]:{email:r.email,photoURL:r.photoURL,lastViewedAt:$t()}},{merge:!0})}async onIdle(){this.stop()}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.timer.stop(),this.idleTimer.stop(),this.onDisconnect(),this.started=!1)}async onDisconnect(){let r=window.firebase.user;if(!r.email){console.log("no user email:",r);return}let o=new Wo(r.email,"disconnectedAt");await cr(this.docRef,o,$t())}async dispose(){super.dispose(),this.stop(),this.timer.dispose(),this.idleTimer.dispose()}};function AX(t){let e=xs(t.id),[r,o]=P([]);if(L(()=>{let a=new sN(e);a.on("change",s=>o(s)),a.start();let i=()=>{document.hidden||document.visibilityState!=="visible"?a.stop():a.started||a.start()};return document.addEventListener("visibilitychange",i),()=>{a.dispose(),document.removeEventListener("visibilitychange",i)}},[e]),r.length===0)return null;function n(a){return a.disconnectedAt?a.disconnectedAt>a.lastViewedAt:!1}return f(M_,{className:"Viewers",limit:3,size:30,children:r.map(a=>{if(!a.photoURL){let i=a.email[0].toUpperCase();return f(qn,{alt:a.email,size:24,radius:"xl",children:i})}return f(qn,{className:Te("Viewers__viewer",n(a)&&"Viewers__viewer--disconnected"),src:a.photoURL,alt:a.email,size:24,radius:"xl"},a.email)})})}ye();function NX(t){let r=t.field.checkboxLabel||"Enabled",[o,n]=P(!1);function a(i){n(i),t.draft.updateKey(t.deepKey,i)}return L(()=>t.draft.subscribe(t.deepKey,s=>{n(s)}),[]),f("div",{className:"DocEditor__BooleanField",children:f(wd,{label:r,onChange:i=>{let s=i.currentTarget;a(s.checked)},checked:o,size:"xs"})})}ye();function RX(t){let e=t.field,[r,o]=P(e.default||"");function n(a){a?(t.draft.updateKey(t.deepKey,a),o(a)):(o(""),t.draft.removeKey(t.deepKey)),t.onChange&&t.onChange(a)}return L(()=>t.draft.subscribe(t.deepKey,i=>{o(i||"")}),[]),f("div",{className:"DocEditor__DateField",children:f("input",{type:"date",value:r,onChange:a=>{let i=a.currentTarget;n(i.value)}})})}ye();function MX(t){let[e,r]=P("");function o(a){if(a){let i=Math.floor(new Date(a).getTime()),s=dt.fromMillis(i);r(n(s)),t.draft.updateKey(t.deepKey,s)}else r(""),t.draft.removeKey(t.deepKey)}function n(a){let i=a.toDate();return i.setMinutes(i.getMinutes()-i.getTimezoneOffset()),i.toISOString().slice(0,16)}return L(()=>t.draft.subscribe(t.deepKey,i=>{r(i?n(i):"")}),[]),f("div",{className:"DocEditor__DateTimeField",children:[f("input",{type:"datetime-local",value:e,onChange:a=>{let s=a.target.value;o(s)}}),f("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})}ye();dn();Uc();ye();var aBe=["image/gif","image/jpeg","image/png","image/svg+xml","image/webp"],iBe=["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"],qh=mt(null);function fa(t){let e=Rt(),r=U(null),[o,n]=P(!1),[a,i]=P({uploadedFile:t.file}),s=t.exts??(t.variant==="image"?aBe:[]);L(()=>{i(g=>({...g,uploadedFile:t.file}))},[t.file]);async function l(g){try{i(x=>({...x,state:"uploading",file:g}));let _=await Ns(g,{preserveFilename:t.preserveFilename,cacheControl:t.cacheControl});c(_)}catch(_){console.error("upload failed"),console.error(_),i(x=>({...x,state:"error"})),he({title:"Upload failed",message:"Failed to upload: "+String(_),color:"red",autoClose:!1})}}function c(g){i(_=>({..._,uploadedFile:{..._.uploadedFile,...g}})),t.onFileChange?.(g),i(_=>({..._,uploadedFile:g,state:"finished"}))}function d(g){if(!g)return;let _=Ru(g.name);if(s.length>0&&!s.some(x=>x.endsWith(_)||x===`*/${_}`||x==="*/*"||x===g.type)){he({title:"Invalid file type",message:`File type ${_} is not allowed.`,color:"red",autoClose:!0});return}l(g)}function u(){r.current?.focus()}function p(){if(a.uploadedFile)if(nI(a.uploadedFile.src)){let g=document.createElement("a");g.href=NG(a.uploadedFile.src),a.uploadedFile.filename&&(g.download=a.uploadedFile.filename),document.body.appendChild(g),g.click(),document.body.removeChild(g)}else window.open(a.uploadedFile.src,"_blank")}function m(){let g=document.createElement("input");g.type="file",s.length>0&&(g.accept=s.join(",")),g.onchange=_=>{let x=_.target;x.files&&x.files.length>0&&d(x.files[0])},g.click(),g.remove()}function h(){n(!0)}return f(qh.Provider,{value:{fileUpload:a,variant:t.variant,alt:t.alt,acceptedFileTypes:s,handleFile:d,focusDropZone:u,requestFileUpload:m,requestFileDownload:p,requestPlaceholderModalOpen:h,setFileData:c,setAltText:g=>{i(_=>_.uploadedFile?{..._,uploadedFile:{..._.uploadedFile,alt:g||""}}:_),t.onFileChange?.({...a.uploadedFile,alt:g||""})},removeFile:()=>{i(g=>({...g,uploadedFile:null})),t.onFileChange?.(null)}},children:[f(ts,{size:"sm",opened:o,onClose:()=>n(!1),title:"Placeholder image",centered:!0,overlayColor:e.colorScheme==="dark"?e.colors.dark[9]:e.colors.gray[2],children:f("form",{onSubmit:g=>{g.preventDefault();let _=new FormData(g.currentTarget),x=parseInt(_.get("width"),10),b=parseInt(_.get("height"),10),v=_.get("backgroundColor"),I=_.get("label")||`${x}x${b}`,E=`<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${b}" viewBox="0 0 ${x} ${b}"><rect width="${x}" height="${b}" fill="${v}" />`;if(I){let A=x*.5/(I.length*.6);E+=`<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="sans-serif" font-size="${A}" fill="#fff">${I}</text>`}E+="</svg>";let C=new TextEncoder().encode(E),k={src:`data:image/svg+xml;base64,${btoa(String.fromCharCode(...C))}`,filename:"placeholder.svg",width:x,height:b,alt:""};c(k),n(!1)},children:[f(rs,{gap:"xs",children:[f(Mt,{label:"Width",name:"width",type:"number",defaultValue:1600,"data-autofocus":!0}),f(Mt,{label:"Height",name:"height",type:"number",defaultValue:900}),f(Mt,{name:"label",label:"Label",defaultValue:"",autofocus:!0}),f(Q_,{name:"backgroundColor",label:"Background color",format:"hex",defaultValue:"#868e96",swatches:iBe})]}),f("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"1rem"},children:f(Y,{variant:"filled",type:"submit",children:"Create"})})]})}),f("div",{className:"FileUploadField",children:[f(fa.Dropzone,{ref:r}),a.uploadedFile?.src?f(fa.Preview,{}):f(fa.Empty,{})]})]})}fa.Preview=()=>{let t=it(qh),[e,r]=P(!1),[o,n]=P(!1),a=t?.fileUpload;if(!a||!a.uploadedFile)return null;let i=LX(t?.fileUpload?.uploadedFile?.filename),[s,l]=P(!i),{uploadedFile:c}=a;return f("div",{className:"FileUploadField__Preview",children:[f("div",{className:"FileUploadField__Preview__InfoButton",children:[i&&f(Ie,{label:"Toggle file info",position:"top",withArrow:!0,children:f(Ue,{onClick:()=>l(d=>!d),size:"sm",variant:"outline",className:"FileUploadField__Preview__InfoButton__Icon",children:f(fT,{size:16})})}),f(Ie,{label:"Replace file",position:"top",withArrow:!0,children:f(Ue,{onClick:()=>t.requestFileUpload(),size:"sm",variant:"outline",className:"FileUploadField__Preview__InfoButton__Icon",children:t.variant==="image"?f($m,{size:16}):f(Ca,{size:16})})}),f(Re,{className:"FileUploadField__Preview__Menu",shadow:"sm",withinPortal:!1,closeOnItemClick:!1,control:f(Ue,{variant:"outline",size:"sm",radius:"sm",c:"black",className:"FileUploadField__Preview__InfoButton__Icon",children:f(Ti,{size:16})}),children:[f(Re.Label,{size:"sm",children:"REPLACE"}),f(Re.Item,{icon:t.variant==="image"?f($m,{size:16}):f(Ca,{size:16}),onClick:()=>t.requestFileUpload(),children:["Upload ",t.variant==="image"?"image":"file"]}),BX(t.acceptedFileTypes)&&f(Re.Item,{disabled:!c.src,icon:f(iy,{size:16}),onClick:()=>{t.requestPlaceholderModalOpen()},children:"Placeholder image"}),f(Hn,{}),f(Re.Item,{disabled:c.src.startsWith("data:"),onClick:()=>{t?.requestFileDownload()},icon:f(cT,{size:16}),children:"Download file"}),f(Re.Item,{closeOnItemClick:!1,icon:f(rc,{size:16}),onClick:()=>{n(!1),navigator.clipboard.writeText(c.src).then(()=>n(!0)).finally(()=>setTimeout(()=>{n(!1)},2e3))},children:o?"Copied!":"Copy URL"}),f(Hn,{}),f(Re.Item,{color:"red",onClick:()=>{t?.removeFile()},icon:f(oa,{size:16}),children:"Remove file"})]})]}),f("div",{className:Te("FileUploadField__Canvas",s&&"FileUploadField__Canvas--infoOpened",e&&"FileUploadField__Canvas--dragging"),style:c.width!==void 0&&c.height!==void 0?{"--canvas-aspect-ratio":`${c.width} / ${c.height}`}:{},onDragOver:d=>{d.preventDefault(),r(!0)},onDragLeave:d=>{d.preventDefault(),r(!1)},onDrop:d=>{d.preventDefault(),r(!1);let u=d.dataTransfer?.files[0];u&&t&&t.handleFile(u)},onPaste:d=>{d.preventDefault();let u=d.clipboardData?.files[0];u&&t&&t.handleFile(u)},children:[f(Kn,{visible:t.fileUpload?.state==="uploading"}),s?f("div",{className:"FileUploadField__Canvas__Info",children:[f(Vm,{size:20,className:"FileUploadField__Canvas__Info__Icon"}),f(hr,{className:"FileUploadField__Canvas__InfoTable",verticalSpacing:"xs",fontSize:"xs",children:f("tbody",{children:[c.filename&&f("tr",{children:[f("td",{children:f("b",{children:"Name"})}),f("td",{children:c.filename})]}),c.uploadedAt&&f("tr",{children:[f("td",{children:f("b",{children:"Uploaded"})}),f("td",{children:[new Date(parseInt(c.uploadedAt,10)).toLocaleString(),c.uploadedBy&&f(Oe,{children:[" by ",c.uploadedBy]})]})]}),c.width!==void 0&&c.height!==void 0&&f("tr",{children:[f("td",{children:f("b",{children:"Dimensions"})}),f("td",{children:[c.width,"x",c.height]})]}),f("tr",{children:[f("td",{children:f("b",{children:"URL"})}),f("td",{children:f(Kt,{readOnly:!0,value:c.src,size:"xs",autosize:!0,radius:0})})]})]})})]}):f(Oe,{children:[c.width!==void 0&&c.height!==void 0&&f(ae,{radius:"sm",className:"FileUploadField__Preview__Info",children:[c.width,"x",c.height]}),KP(c.src)&&f("img",{onClick:()=>{t?.focusDropZone()},onDblClick:()=>{t?.requestFileUpload()},src:c.src,alt:c.alt||"Uploaded file preview",className:"FileUploadField__Preview__Image"}),YP(c.src)&&f(Oe,{children:f("video",{className:"FileUploadField__Preview__Image",controls:!0,muted:!0,preload:"metadata",children:f("source",{src:c.src,type:`video/${Ru(c.src)}`})})})]})]}),t.alt!==!1&&(c.alt||LX(c.filename)||t.variant==="image")&&f("div",{className:"DocEditor__ImageField__imagePreview__Image__Alt",children:f(Kt,{radius:0,className:"DocEditor__ImageField__imagePreview__Image__Alt__Textarea",value:c.alt,placeholder:"Alt text",size:"xs",autosize:!0,disabled:t.fileUpload?.state==="uploading",onChange:d=>{t?.setAltText(d.currentTarget.value)}})})]})};fa.UploadButton=G((t,e)=>{let r=it(qh),o=r?.fileUpload?.state==="uploading";return r?f("label",{...t,ref:e,className:"FileUploadField__FileUploadButton",tabIndex:0,children:[f("input",{disabled:o,type:"file",accept:r.acceptedFileTypes.length>0?r.acceptedFileTypes.join(","):void 0,className:"FileUploadField__FileUploadButton__Input",onChange:n=>{let a=n.target;a.files&&r&&r.handleFile(a.files[0])}}),o?f(De,{size:16}):r?.variant==="image"?f($m,{size:16}):f(Ca,{size:16}),f("div",{className:"FileUploadField__FileUploadButton__Title",children:o?"Uploading...":r?.fileUpload?.uploadedFile?.src?"Upload":"Paste, drop, or click to upload"})]}):null});fa.Empty=()=>{let t=it(qh);if(!t)return null;let e=t.acceptedFileTypes.map(r=>r.split("/").pop().split("+")[0].replaceAll(".","")).sort();return f("div",{className:"FileUploadField__Empty",children:[f("div",{className:"FileUploadField__Empty__Label",children:[f("div",{children:f(fa.UploadButton,{})}),BX(t.acceptedFileTypes)&&f("div",{children:f(Ie,{label:"Create placeholder image",children:f(Ue,{className:"FileUploadField__Empty__Label__PlaceholderButton",onClick:()=>{t.requestPlaceholderModalOpen()},title:"Create placeholder image",children:f(iy,{size:16})})})})]}),t.acceptedFileTypes.length>0&&f("div",{children:f("div",{className:"FileUploadField__Empty__AcceptTypes",children:["Allowed file types: ",e.join(", ")]})})]})};fa.Dropzone=G((t,e)=>{let[r,o]=P(!1),n=it(qh);return f("button",{ref:e,className:Te("FileUploadField__Dropzone",r&&"FileUploadField__Dropzone--dragging"),onDblClick:()=>{n?.requestFileUpload()},onCopy:a=>{n?.fileUpload?.uploadedFile&&(a.preventDefault(),a.clipboardData?.setData("text/plain",n.fileUpload.uploadedFile.src),a.clipboardData?.setData("application/json",JSON.stringify(n.fileUpload.uploadedFile)))},onKeyDown:a=>{((a.metaKey||a.ctrlKey)&&a.key==="Backspace"||a.key==="Delete")&&(a.preventDefault(),n?.fileUpload?.uploadedFile&&n?.removeFile())},onDragOver:a=>{a.preventDefault(),o(!0)},onDragLeave:a=>{a.preventDefault(),o(!1)},onDrop:a=>{a.preventDefault(),o(!1);let i=a.dataTransfer?.files[0];i&&n&&n.handleFile(i)},onPaste:a=>{let i=a.clipboardData?.getData("application/json");if(i)try{let l=JSON.parse(i);if(l&&l.src&&l.filename&&n){console.log("Parsed JSON file:",l),n.setFileData(l);return}}catch(l){console.error("error parsing json",l)}a.preventDefault();let s=a.clipboardData?.files[0];s&&n&&n.handleFile(s)},title:"Drop or paste to upload a file"})});function LX(t){return t?KP(t)||YP(t):!1}function BX(t){return t.some(e=>e.startsWith("image/"))||t.length===0}function FX(t){let e=t.field,[r,o]=P(null);return L(()=>{let n=t.draft.subscribe(t.deepKey,a=>{o(a)});return()=>{n()}},[]),f(fa,{file:r,variant:"file",alt:e.alt,exts:e.exts,preserveFilename:e.preserveFilename,cacheControl:e.cacheControl,onFileChange:n=>{n?(t.draft.updateKey(t.deepKey,n),n.alt&&t.draft.updateKey(`${t.deepKey}.alt`,n.alt)):t.draft.removeKey(t.deepKey),o(n)}})}ye();function zX(t){let e=t.field,[r,o]=P(null);return L(()=>{let n=t.draft.subscribe(t.deepKey,a=>{o(a)});return()=>{n()}},[]),f(fa,{file:r,variant:"image",alt:e.alt,exts:e.exts,onFileChange:n=>{n?(t.draft.updateKey(t.deepKey,n),n.alt&&t.draft.updateKey(`${t.deepKey}.alt`,n.alt)):t.draft.removeKey(t.deepKey),o(n)}})}ye();function UX(t){let e=t.field,[r,o]=P([]),n=(e.options||[]).map(i=>typeof i=="string"?{label:i,value:i}:{label:i.label??i.value??"",value:i.value??i.label??""});function a(i){t.draft.updateKey(t.deepKey,i||[]),o(i)}return L(()=>t.draft.subscribe(t.deepKey,s=>{o(s||[])}),[]),f("div",{className:"DocEditor__MultiSelectField",children:f(mx,{data:n,size:"xs",radius:0,placeholder:e.placeholder,value:r,searchable:!0,creatable:e.creatable||!1,getCreateLabel:i=>`+ Add "${i}"`,onChange:i=>a(i),dropdownComponent:"div"})})}ye();function VX(t){let e=t.field,[r,o]=P(e.default||0);function n(a){o(a),t.draft.updateKey(t.deepKey,a)}return L(()=>t.draft.subscribe(t.deepKey,i=>{o(i)}),[]),f(bx,{size:"xs",radius:0,value:r,onChange:a=>n(a),hideControls:!0})}ye();function af(t){let e=t.field,[r,o]=P("");function n(l){if(l){let[c,d]=l.split("/");t.draft.updateKey(t.deepKey,{id:l,collection:c,slug:d})}else t.draft.removeKey(t.deepKey);o(l)}L(()=>t.draft.subscribe(t.deepKey,c=>{o(c?.id||"")}),[]);let a=X7();function i(){let l=r?r.split("/")[0]:e.initialCollection;a.open({collections:e.collections,initialCollection:l,onChange:c=>{n(c),a.close()}})}function s(){n("")}return f("div",{className:"ReferenceField",children:[r?f("div",{className:"ReferenceField__ref",children:[f(af.Preview,{id:r}),f("div",{className:"ReferenceField__remove",children:f(Ie,{label:"Remove",children:f(Ue,{className:"ReferenceField__remove__icon",onClick:()=>s(),children:f(oa,{size:16})})})})]}):f("div",{className:"ReferenceField__none",children:"None selected"}),f(Y,{color:"dark",size:"xs",onClick:()=>i(),children:e.buttonLabel||"Select"})]})}af.Preview=t=>{let[e,r]=P(!0),[o,n]=P(null);async function a(){r(!0),await Tt(async()=>{let i=await qv(t.id);n(i)}),r(!1)}return L(()=>{a()},[t.id]),f("div",{className:"ReferenceField__Preview",children:e?f("div",{className:"ReferenceField__Preview__loading",children:f(De,{color:"gray",size:"sm"})}):o?f(af.DocCard,{doc:o}):f("div",{className:"ReferenceField__Preview__notfound",children:['Doc Not found: "',t.id,'" (was it deleted?). Select a new doc or remove using the trash icon to the right.']})})};af.DocCard=t=>{let e=t.doc,r=e.id||e.sys?.id||"";if(!r)return f("div",{className:"ReferenceField__DocCard ReferenceField__DocCard--error",children:JSON.stringify(e)});let o=r.split("/")[0],n=e.fields||{},a=window.__ROOT_CTX.collections[o];if(!a)throw new Error(`could not find collection: ${o}`);let i=_o(n,a.preview?.title||"meta.title"),s=_o(n,a.preview?.image||"meta.image")||a.preview?.defaultImage;return f("a",{className:"ReferenceField__DocCard",href:`/cms/content/${r}`,target:"_blank",children:[f("div",{className:"ReferenceField__DocCard__image",children:f(Wn,{src:s?.src,width:80,height:60,withPlaceholder:!s?.src})}),f("div",{className:"ReferenceField__DocCard__content",children:[f("div",{className:"ReferenceField__DocCard__content__header",children:f("div",{className:"ReferenceField__DocCard__content__header__docId",children:r})}),f("div",{className:"ReferenceField__DocCard__content__title",children:i||"[UNTITLED]"})]})]})};ye();function $X(t){let e=t.field,[r,o]=P({blocks:[{type:"paragraph",data:{}}]});function n(a){o(i=>(ny({blocks:i?.blocks},{blocks:a?.blocks})||t.draft.updateKey(t.deepKey,a),a))}return L(()=>t.draft.subscribe(t.deepKey,i=>{o(i)}),[]),f(PX,{value:r,placeholder:e.placeholder,onChange:n})}ye();function HX(t){let e=t.field,[r,o]=P(""),n=(e.options||[]).map(i=>typeof i=="string"?{label:i,value:i}:{label:i.label??i.value??"",value:i.value??i.label??""});function a(i){t.draft.updateKey(`${t.deepKey}`,i),o(i||"")}return L(()=>t.draft.subscribe(t.deepKey,s=>{o(s||"")}),[]),f("div",{className:"DocEditor__SelectField",children:f(Vt,{data:n,placeholder:e.placeholder,value:r,onChange:i=>a(i||""),size:"xs",radius:0,searchable:e.searchable??!0,dropdownComponent:"div"})})}ye();function jX(t){let e=t.field,[r,o]=P("");function n(a){o(a),t.draft.updateKey(t.deepKey,a)}return L(()=>t.draft.subscribe(t.deepKey,i=>{o(i)}),[]),e.variant==="textarea"?f(Kt,{size:"xs",radius:0,autosize:!0,minRows:2,maxRows:e.maxRows||12,value:r,onChange:a=>{n(a.currentTarget.value)}}):f(Mt,{size:"xs",radius:0,value:r,onChange:a=>{n(a.currentTarget.value)}})}var qX=mt(null),GX=mt({value:WX(),setValue:()=>{}}),sBe=mt({value:null,setValue:()=>{}});function lBe(){return it(qX)}function dw(){return it(GX)}function WX(){return new URL(window.location.href).searchParams.get("deeplink")||""}function Ur(t){let e=sI(t.collection.id),r=t.draft,{controller:o,saveState:n,data:a}=r,[i,s]=P(null),[l,c]=P(WX()),d=e.loading||r.loading,u=e.schema?.fields||[],p=Gt(()=>{let _=t.docId.split("/")[0];xr(`/cms/content/${_}`)},[t.docId]),m=Gt(_=>{_.action==="delete"&&p()},[p]),h=hH({docId:t.docId}),g=s$({docId:t.docId,draft:o,collection:t.collection});return L(()=>{if(d)return;let x=new URL(window.location.href).searchParams.get("deeplink");x&&c(x)},[d]),f(sBe.Provider,{value:{value:i,setValue:s},children:f(qX.Provider,{value:a,children:f(GX.Provider,{value:{value:l,setValue:c},children:f("div",{className:"DocEditor",children:[f(Kn,{visible:d,loaderProps:{color:"gray",size:"xl"}}),f("div",{className:"DocEditor__statusBar",children:[f("div",{className:"DocEditor__statusBar__viewers",children:f(AX,{id:`doc/${t.docId}`})}),f("div",{className:"DocEditor__statusBar__saveState",children:[n==="SAVED"&&"saved!",n==="SAVING"&&"saving...",n==="UPDATE_PENDING"&&"saving...",n==="ERROR"&&"error saving"]}),!d&&a?.sys&&f("div",{className:"DocEditor__statusBar__statusBadges",children:f(Lu,{doc:a})}),f("div",{className:"DocEditor__statusBar__i18n",children:f(Y,{variant:"default",color:"dark",size:"xs",leftIcon:f(_T,{size:16}),onClick:()=>g.open(),children:"Localization"})}),f("div",{className:"DocEditor__statusBar__publishButton",children:d?f(Y,{color:"dark",size:"xs",onClick:()=>h.open(),loading:!0,disabled:!0,children:"Publish"}):Kv(a)?f(Ie,{label:`Scheduled ${jv(a.sys.scheduledAt)} by ${a.sys.scheduledBy}`,transition:"pop",children:f(Y,{color:"dark",size:"xs",leftIcon:f(gu,{size:16}),disabled:!0,children:"Publish"})}):Jl(a)?f(Ie,{label:`Locked by ${a.sys.publishingLocked.lockedBy}: "${a.sys.publishingLocked.reason}"`,transition:"pop",children:f(Y,{color:"dark",size:"xs",leftIcon:f(ac,{size:16}),disabled:!0,children:"Publish"})}):f(Y,{color:"dark",size:"xs",leftIcon:f(gu,{size:16}),onClick:()=>h.open(),children:"Publish"})}),f("div",{className:"DocEditor__statusBar__actionsMenu",children:f(aI,{docId:t.docId,data:a,onAction:m})})]}),f("div",{className:"DocEditor__fields",children:u.map(_=>f(Ur.Field,{collection:t.collection,field:_,shallowKey:_.id,deepKey:`fields.${_.id}`,draft:o},_.id))})]})})})})}Ur.Field=t=>{let e=t.field,r=t.level??0,n=dw().value===t.deepKey,a=U(null),[i,s]=P(null),[l,c]=P([]),d=!t.hideHeader&&!e.hideLabel;return e.type==="object"&&(e.variant||"drawer")==="drawer"&&(d=!1),L(()=>t.draft.subscribe(t.deepKey,p=>{s(p)}),[t.draft,t.deepKey]),L(()=>{if(!e.translate||!i)return;let p=new Set;fy(p,e,i),c(Array.from(p))},[i]),L(()=>{n&&fBe(a.current)},[n]),e.deprecated&&Hh(e,i)?null:f("div",{className:Te("DocEditor__field",e.deprecated&&"DocEditor__field--deprecated",n&&"deeplink-target"),"data-type":e.type,"data-level":r,id:t.deepKey,ref:a,children:[d&&f(Ur.FieldHeader,{deepKey:t.deepKey,label:e.label||e.id,help:e.help,deprecated:e.deprecated,translate:e.translate,translateStrings:l}),f("div",{className:"DocEditor__field__input",children:e.type==="array"?f(Ur.ArrayField,{...t}):e.type==="boolean"?f(NX,{...t}):e.type==="date"?f(RX,{...t}):e.type==="datetime"?f(MX,{...t}):e.type==="file"?f(FX,{...t}):e.type==="image"?f(zX,{...t}):e.type==="multiselect"?f(UX,{...t}):e.type==="number"?f(VX,{...t}):e.type==="object"?f(Ur.ObjectField,{...t}):e.type==="oneof"?f(Ur.OneOfField,{...t}):e.type==="reference"?f(af,{...t}):e.type==="richtext"?f($X,{...t}):e.type==="select"?f(HX,{...t}):e.type==="string"?f(jX,{...t}):f("div",{className:"DocEditor__field__input__unknown",children:["Unknown field type: ",e.type]})})]})};Ur.FieldHeader=t=>{function e(){let d=new URL(window.location.href);return d.searchParams.set("deeplink",t.deepKey),d.toString()}let r=dw(),o=lBe()||{},n=o.sys?.l10nSheet,i=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"],s=o$(),l=t.translate&&t.translateStrings||[],c=l.length===0;return f("div",{className:Te(t.className,"DocEditor__FieldHeader"),children:[t.deprecated?f("div",{className:"DocEditor__FieldHeader__label",children:["DEPRECATED: ",t.label]}):f("div",{className:"DocEditor__FieldHeader__label",children:[f("span",{children:t.label}),t.deepKey&&f("a",{className:"DocEditor__FieldHeader__label__deeplink",href:e(),title:"Link to field",onClick:d=>{d.preventDefault(),window.history.replaceState({},"",e()),r.setValue(t.deepKey)},children:"#"})]}),t.help&&f("div",{className:"DocEditor__FieldHeader__help",children:t.help}),i.length>1&&t.translate&&f("div",{className:"DocEditor__FieldHeader__translate",children:c?f("div",{className:"DocEditor__FieldHeader__translate__iconDisabled",children:f(Es,{size:16})}):f(Ie,{label:"Show translations",children:f(Ue,{size:"xs",onClick:()=>s.open({docId:o.id,strings:l,l10nSheet:n}),children:f(Es,{size:16})})})})]})};Ur.ObjectField=t=>{let e=t.field,r=e.variant;return r||(t.isArrayChild?r="inline":r="drawer"),r==="drawer"?f(Ur.ObjectFieldDrawer,{...t}):f("div",{className:"DocEditor__ObjectField",children:f("div",{className:"DocEditor__ObjectField__fields",children:e.fields.map(o=>f(Ur.Field,{collection:t.collection,field:o,shallowKey:o.id,deepKey:`${t.deepKey}.${o.id}`,draft:t.draft},o.id))})})};Ur.ObjectFieldDrawer=t=>{let e=t.field,r=e.drawerOptions?.collapsed||!1,o=e.drawerOptions?.inline||!1,n=o?"left":"right",a=dw(),i=!r||a.value.includes(t.deepKey);return f("div",{className:Te("DocEditor__ObjectFieldDrawer",o&&"DocEditor__ObjectFieldDrawer--inline"),children:f("details",{className:"DocEditor__ObjectFieldDrawer__drawer",open:i,children:[f("summary",{className:Te("DocEditor__ObjectFieldDrawer__drawer__toggle",`DocEditor__ObjectFieldDrawer__drawer__toggle--icon-${n}`),children:[f(Ur.FieldHeader,{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__header",deepKey:t.deepKey,label:e.label||e.id,help:e.help}),f("div",{className:"DocEditor__ObjectFieldDrawer__drawer__toggle__icon",children:f(mu,{size:16})})]}),f("div",{className:"DocEditor__ObjectFieldDrawer__drawer__content DocEditor__ObjectFieldDrawer__fields",children:e.fields.map(s=>f(Ur.Field,{collection:t.collection,field:s,shallowKey:s.id,deepKey:`${t.deepKey}.${s.id}`,draft:t.draft},s.id))})]})})};function cBe(t,e){switch(e.type){case"update":{let r=t._new||[];return{...e.newValue,_new:r}}case"updateItem":{let r=t??{},n=[...r._array||[]][e.index],a=e.newValue??{};return e.draft.updateKey(`${e.deepKey}.${n}`,a),{...r,[n]:a}}case"add":{let r=t??{},o=Pa(),n=[...r._array||[],o];e.draft.updateKeys({[`${e.deepKey}._array`]:n,[`${e.deepKey}.${o}`]:{}});let a=t._new||[];return{...r,[o]:{},_array:n,_new:[...a,o]}}case"insertBefore":{let r=t??{},o=[...r._array||[]],n=Pa();o.splice(e.index,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:{}});let a=t._new||[];return{...r,[n]:{},_array:o,_new:[...a,n]}}case"insertAfter":{let r=t??{},o=[...r._array||[]],n=Pa();o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:{}});let a=t._new||[];return{...r,[n]:{},_array:o,_new:[...a,n]}}case"duplicate":{let r=t??{},o=[...r._array||[]],n=o[e.index],a=structuredClone(r[n]),i=Pa();o.splice(e.index+1,0,i),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${i}`]:a});let s=t._new||[];return{...r,[i]:a,_array:o,_new:[...s,i]}}case"moveUp":{if(e.index===0)return t;let r=t??{},o=[...r._array||[]];return lN(o,e.index,e.index-1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:o[e.index-1]}}case"moveDown":{let r=t??{},o=[...r._array||[]];return e.index>=o.length-1?t:(lN(o,e.index,e.index+1),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:o[e.index+1]})}case"moveTo":{let r=t??{},o=[...r._array||[]];if(e.fromIndex<0||e.fromIndex>=o.length||e.toIndex<0||e.toIndex>=o.length)return console.error("Invalid moveTo index",e),t;let n=o[e.fromIndex];return lN(o,e.fromIndex,e.toIndex),e.draft.updateKeys({[`${e.deepKey}._array`]:o}),{...r,_array:o,_moved:n}}case"removeAt":{let r={...t??{}},n=[...r._array||[]],a=n[e.index];return delete r[a],n.splice(e.index,1),e.draft.updateKeys({[`${e.deepKey}._array`]:n}),e.draft.removeKey(`${e.deepKey}.${a}`),{...r,_array:n}}case"pasteAfter":{let r=t??{},o=[...r._array||[]],n=Pa(),a=e.virtualClipboard.value;o.splice(e.index+1,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:a});let i=t._new||[];return{...r,[n]:a,_array:o,_new:[...i,n]}}case"pasteBefore":{let r=t??{},o=[...r._array||[]],n=Pa(),a=e.virtualClipboard.value;o.splice(e.index,0,n),e.draft.updateKeys({[`${e.deepKey}._array`]:o,[`${e.deepKey}.${n}`]:a});let i=t._new||[];return{...r,[n]:a,_array:o,_new:[...i,n]}}default:return console.error("unknown action",e),t}}Ur.ArrayField=t=>{let e=t.draft,r=t.field,[o,n]=rn(cBe,{_array:[]}),a=dw(),i=OH(),l=(o??{})._array||[],c=o._new||[];L(()=>t.draft.subscribe(t.deepKey,R=>{n({type:"update",newValue:R})}),[t.draft,t.deepKey]),L(()=>{o._moved&&x(t.deepKey,l.indexOf(o._moved))},[o]);let d=()=>{n({type:"add",draft:e,deepKey:t.deepKey})},u=S=>{n({type:"pasteBefore",draft:e,deepKey:t.deepKey,index:S,virtualClipboard:i})},p=S=>{n({type:"pasteAfter",draft:e,deepKey:t.deepKey,index:S,virtualClipboard:i})},m=S=>{n({type:"insertBefore",draft:e,deepKey:t.deepKey,index:S})},h=S=>{n({type:"insertAfter",draft:e,deepKey:t.deepKey,index:S})},g=S=>{n({type:"duplicate",draft:e,deepKey:t.deepKey,index:S})},_=S=>{n({type:"removeAt",draft:e,deepKey:t.deepKey,index:S})},x=(S,R)=>{document.getElementById(`summary-for-${S}.${l[R]}`)?.focus()},b=S=>{S>0&&n({type:"moveUp",draft:e,deepKey:t.deepKey,index:S})},v=S=>{S<l.length-1&&n({type:"moveDown",draft:e,deepKey:t.deepKey,index:S})},I=S=>{let R=l[S],A=o[R];i.set(A)},E=cy(),y=S=>{let R=l[S];E.open({data:o[R],onSave:A=>{console.log("editJson, onSave():",A),n({type:"updateItem",draft:e,index:S,newValue:A,deepKey:t.deepKey}),e.notifySubscribers(),E.close()}})};function C(S){return!!a.value.startsWith(`${t.deepKey}.${S}`)}function T(S,R){S.target&&(S.key==="ArrowUp"?(S.preventDefault(),b(l.indexOf(R))):S.key==="ArrowDown"?(S.preventDefault(),v(l.indexOf(R))):S.key==="ArrowLeft"?S.target.closest("details").open=!1:S.key==="ArrowRight"&&(S.target.closest("details").open=!0))}let k=f("div",{className:"DocEditor__ArrayField__add",children:f(Y,{color:"dark",size:"xs",leftIcon:f(hu,{size:16}),onClick:()=>d(),children:r.buttonLabel||"Add"})});return l.length===0&&!o._new?f("div",{className:"DocEditor__ArrayField",children:[f("div",{className:"DocEditor__ArrayField__items",children:f("div",{className:"DocEditor__ArrayField__items__empty",children:"No items"})}),k]}):f("div",{className:"DocEditor__ArrayField",children:[f(jK,{onDragEnd:S=>{let{source:R,destination:A}=S;A&&n({type:"moveTo",fromIndex:R.index,toIndex:A.index,draft:e,deepKey:t.deepKey})},children:f(tY,{droppableId:"dnd-list",direction:"vertical",children:S=>f("div",{...S.droppableProps,ref:S.innerRef,className:"DocEditor__ArrayField__items",children:[l.map((R,A)=>{let N=dBe(r,o[R]);return f(XK,{index:A,draggableId:R,children:(z,F)=>f("div",{ref:z.innerRef,...z.draggableProps,className:Te("DocEditor__ArrayField__item__wrapper",F.isDragging&&"DocEditor__ArrayField__item__wrapper--dragging"),children:[f("div",{className:"DocEditor__ArrayField__item__handle",...z.dragHandleProps,children:f(dT,{size:18,stroke:"1.5"})}),f("details",{className:"DocEditor__ArrayField__item",open:c.includes(R)||C(R),children:[f("summary",{id:`summary-for-${t.deepKey}.${l[A]}`,className:"DocEditor__ArrayField__item__header",onKeyDown:B=>T(B,R),tabIndex:0,children:[f("div",{className:"DocEditor__ArrayField__item__header__icon",children:f(vT,{size:6})}),f("div",{className:"DocEditor__ArrayField__item__header__preview",children:[N&&f("div",{className:"DocEditor__ArrayField__item__header__preview__image",children:f("img",{src:N,alt:"",className:"DocEditor__ArrayField__item__header__preview__image__img",loading:"lazy"})}),f("div",{className:"DocEditor__ArrayField__item__header__preview__title",children:uBe(r,o[R],A)})]}),f("div",{className:"DocEditor__ArrayField__item__header__controls",children:[f("div",{className:"DocEditor__ArrayField__item__header__controls__arrows",children:[f("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--up",onClick:()=>b(A),children:f(tT,{size:20,strokeWidth:1.75})}),f("button",{className:"DocEditor__ArrayField__item__header__controls__arrow DocEditor__ArrayField__item__header__controls__arrows--down",onClick:()=>v(A),children:f(eT,{size:20,strokeWidth:1.75})})]}),f(Re,{className:"DocEditor__ArrayField__item__header__controls__menu",position:"bottom",control:f(Ue,{className:"DocEditor__ArrayField__item__header__controls__dots",children:f(Ti,{size:16})}),children:[f(Re.Label,{children:"INSERT"}),f(Re.Item,{icon:f(ly,{size:20}),onClick:()=>m(A),children:"Add before"}),f(Re.Item,{icon:f(sy,{size:20}),onClick:()=>h(A),children:"Add after"}),f(Re.Item,{icon:f(rc,{size:20}),onClick:()=>g(A),children:"Duplicate"}),f(Re.Label,{children:"CLIPBOARD"}),f(Re.Item,{icon:f(oT,{size:20}),onClick:()=>setTimeout(()=>I(A),500),children:"Copy"}),i.value&&f(Oe,{children:[f(Re.Item,{icon:f(ly,{size:20}),onClick:()=>u(A),children:"Paste before"}),f(Re.Item,{icon:f(sy,{size:20}),onClick:()=>p(A),children:"Paste after"})]}),f(Re.Label,{children:"CODE"}),f(Re.Item,{icon:f(Mm,{size:20}),onClick:()=>y(A),children:"Edit JSON"}),f(Re.Label,{children:"REMOVE"}),f(Re.Item,{icon:f(oa,{size:20}),onClick:()=>_(A),children:"Remove"})]})]})]}),f("div",{className:"DocEditor__ArrayField__item__body",children:f(Ur.Field,{collection:t.collection,field:r.of,shallowKey:r.id,deepKey:`${t.deepKey}.${R}`,draft:t.draft,hideHeader:!0,isArrayChild:!0},`${t.deepKey}.${R}`)})]},R)]})},R)}),S.placeholder]})})}),k]})};Ur.OneOfField=t=>{let e=t.field,[r,o]=P(""),n={},a=[{value:"",label:e.placeholder||"Select type"}];e.types.forEach(c=>{n[c.name]=c,a.push({value:c.name,label:c.name})});let i=n[r||""],s=ot(()=>({}),[]);async function l(c){let d={};if(c){if(c in s){let u=s[c];Object.assign(d,u)}else if(c in n){let u=nh(n[c]);Object.assign(d,u)}}d._type=c,await t.draft.updateKey(t.deepKey,d),o(c)}return L(()=>t.draft.subscribe(t.deepKey,d=>{d?._type&&(o(d._type||""),s[d._type]=d)}),[t.draft,t.deepKey]),f("div",{className:"DocEditor__OneOfField",children:[f("div",{className:"DocEditor__OneOfField__select",children:[f("div",{className:"DocEditor__OneOfField__select__label",children:"Type:"}),f(Vt,{data:a,value:r,placeholder:e.placeholder,onChange:c=>l(c||""),size:"xs",radius:0,searchable:!0,dropdownComponent:"div"})]}),i&&f("div",{className:"DocEditor__OneOfField__fields",children:i.fields.map(c=>f(Ur.Field,{collection:t.collection,field:c,shallowKey:c.id,deepKey:`${t.deepKey}.${c.id}`,draft:t.draft},`${r}::${c.id}`))})]})};function lN(t,e,r){if(t.length<=1)return t;let o=t[e];return t[e]=t[r],t[r]=o,t}function KX(t,e,r="title"){if(t.type==="oneof"){let o=t,n=e?._type;if(n)return o.types.find(i=>i.name===n)?.preview?.[r]||null}return null}function cN(t,e,r){let o=Array.isArray(t)?[...t]:[t],n=Gk(e);for(r!==void 0&&(n._index=String(r),n._index0=String(r),n._index1=String(r+1),n["_index:02"]=n._index.padStart(2,"0"),n["_index:03"]=n._index.padStart(3,"0"));o.length>0;){let a=o.shift(),i=iY(a,n);if(ZO(i).length===0)return i}}function dBe(t,e){let r=KX(t.of,e,"image");if(r)return cN(r,e)}function uBe(t,e,r){let o=KX(t.of,e,"title");if(o){let n=cN(o,e,r);if(n)return n}return t.preview?cN(t.preview,e,r)??`item ${r}`:`item ${r}`}function fBe(t){let e=document.querySelector(".DocumentPage__side");if(e){if(e.scrollTop>0)return;requestAnimationFrame(()=>{let r=t.offsetTop;e.scroll({top:r,behavior:"auto"})})}}function uw(t,e,r=""){let o=Qv({collectionId:t,slug:e}),n=new URLSearchParams(window.location.search);n.set("preview","true");let a=`${n.toString()}${window.location.hash}`;return r?`${Qv({collectionId:t,slug:e,locale:r})}?${a}`:`${o}?${a}`}function fw(t){let e=t.collection,r=t.slug,o=`${e}/${r}`,n=window.__ROOT_CTX.collections[e],a=aY(o),[i,s]=wc(`root::DocumentPage::previewVisible::${e}`,!0);if(!n)return f("div",{children:"Could not find collection."});function l(){let p=uw(e,r),m=window.open(p,"_blank");m&&m.focus()}function c(){a.controller.flush()}let d=cy(),u=()=>{d.open({data:a.data?.fields||{},onSave:p=>{p&&typeof p=="object"&&(a.controller.updateKey("fields",p),a.controller.flush()),d.close()}})};return _0([["mod+S",()=>c()]]),f(ge,{children:f(Mi,{className:"DocumentPage",localStorageId:"DocumentPage",children:[f(Mi.Item,{className:Te("DocumentPage__side",!i&&"DocumentPage__side--expanded"),children:[f("div",{className:"DocumentPage__side__header",children:[f("div",{className:"DocumentPage__side__header__nav",children:[f("a",{href:`/cms/content/${e}`,children:f(Ue,{className:"DocumentPage__side__header__back",children:f(Qk,{size:16})})}),f("div",{className:"DocumentPage__side__header__docId",children:o})]}),f("div",{className:"DocumentPage__side__header__buttons",children:[f(Y,{variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:f(Bm,{size:16}),onClick:()=>c(),children:"Save"}),f(Re,{className:"DocumentPage__side__header__menu",position:"bottom",control:f(Ue,{className:"DocumentPage__side__header__menu__dots",children:f(Ti,{size:16})}),children:f(Re.Item,{icon:f(Mm,{size:20}),onClick:()=>u(),children:"Edit JSON"})}),f(Ie,{label:i?"Hide preview":"Show preview",children:f(Ue,{className:"DocumentPage__side__header__previewToggle",onClick:()=>s(!i),children:i?f(pT,{size:16}):f(mT,{size:16})})}),!i&&f(Ie,{label:"Open preview in new tab",children:f(Ue,{className:"DocumentPage__side__header__openNewTab",onClick:l,children:f(ws,{size:16})})})]})]}),f("div",{className:Te("DocumentPage__side__editor",!i&&"DocumentPage__side__editor--centered"),children:f(Ur,{collection:n,docId:o,draft:a},o)})]}),f(Mi.Item,{className:Te("DocumentPage__main",!i&&"DocumentPage__main--hidden"),fluid:!0,children:i&&f(fw.Preview,{docId:o,draft:a},o)})]})})}var YX={mobile:[360,800],tablet:[768,1024],desktop:[1440,800]};function pBe(t){let e=new Intl.DisplayNames(["en"],{type:"language"}),o=t.split("_")[0];return`${e.of(o)||t} (${t})`}fw.Preview=t=>{let[e,r]=t.docId.split("/"),n=window.__ROOT_CTX.collections[e];if(!n)throw new Error(`collection not found: ${e}`);let a=n.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",i=Hk({collectionId:e,slug:r}),s=Qv({collectionId:e,slug:r}),l=`${a}${i}`,[c,d]=P(l),[u,p]=wc("root::DocumentPage::preview::device",""),[m,h]=P({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[g,_]=P(""),x=U(null),b=t.draft.controller.getLocales(),v=uw(e,r),I=uw(e,r,g),E=[{value:"",label:"Select locale"},...b.map(S=>({value:S,label:pBe(S)}))];function y(){let S=x.current;S.src="about:blank",window.setTimeout(()=>{S.src!==I?S.src=I:S.contentWindow.location.reload()},30)}L(()=>{let S=x.current;function R(){let N=S.contentWindow;if(N&&s===i&&!N.location.href.startsWith("about:blank")){let z=N.location.pathname;console.log(`iframe url change: ${z}`),d(`${a}${z}`)}}S.addEventListener("load",R);let A=t.draft.controller.onFlush(()=>{y()});return()=>{A(),S.removeEventListener("load",R)}},[]),L(()=>{let S=x.current;S.src=I},[g]);function C(S){p(R=>R===S?"":S)}function T(){t.draft.controller.flush().then(()=>y())}function k(){let S=uw(e,r,g),R=window.open(S,"_blank");R&&R.focus()}return L(()=>{if(u===""){h({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"});return}let A=x.current.parentElement.parentElement.getBoundingClientRect(),[N,z]=YX[u],F=20,B=1;(N>A.width-2*F||z>A.height-2*F)&&(B=Math.min((A.width-2*F)/N,(A.height-2*F)/z)),h({"--iframe-width":`${N}px`,"--iframe-height":`${z}px`,"--iframe-scale":String(B)})},[u]),f("div",{className:"DocumentPage__main__preview",children:[f("div",{className:"DocumentPage__main__previewBar",children:[f("div",{className:"DocumentPage__main__previewBar__devices",children:[f(Ie,{label:"Mobile",children:f(Ue,{className:Te("DocumentPage__main__previewBar__device",u==="mobile"&&"active"),onClick:()=>C("mobile"),children:f(lT,{size:16})})}),f(Ie,{label:"Tablet",children:f(Ue,{className:Te("DocumentPage__main__previewBar__device",u==="tablet"&&"active"),onClick:()=>C("tablet"),children:f(sT,{size:16})})}),f(Ie,{label:"Desktop",children:f(Ue,{className:Te("DocumentPage__main__previewBar__device",u==="desktop"&&"active"),onClick:()=>C("desktop"),children:f(iT,{size:16})})})]}),f("div",{className:"DocumentPage__main__previewBar__navbar",children:f("div",{className:"DocumentPage__main__previewBar__navbar__url",children:c})}),f("div",{className:"DocumentPage__main__previewBar__locales",children:f(Vt,{data:E,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:f(yT,{size:16,strokeWidth:1.5}),value:g,onChange:S=>{_(S)}})}),f("div",{className:"DocumentPage__main__previewBar__buttons",children:[f(Ie,{label:"Reload",children:f(Ue,{className:"DocumentPage__main__previewBar__button DocumentPage__main__previewBar__button--reload",onClick:()=>T(),children:f(xT,{size:16})})}),f(Ie,{label:"Open new tab",children:f(Ue,{className:"DocumentPage__main__previewBar__button DocumentPage__main__previewBar__button--openNewTab",onClick:()=>k(),children:f(ws,{size:16})})})]})]}),f("div",{className:"DocumentPage__main__previewFrame","data-device":u||"full",style:m,children:[u&&f("div",{className:"DocumentPage__main__previewFrame__deviceLabel",children:`${u}: ${YX[u].join("x")}`}),f("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:f("iframe",{ref:x,src:v,title:"iframe preview"})})]})]})};ye();var mBe="Enter the URL to make the HTTP request.",hBe="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function pw(t){let e=U(null),r=Ss(),[o,n]=P(!1),[a,i]=P(r.enabled?"gsheet":"http"),[s,l]=P("map"),[c,d]=P("GET"),[u,p]=P(""),[m,h]=P(!!t.dataSourceId),[g,_]=P(null),x="";a==="http"?x=mBe:a==="gsheet"&&(x=hBe);async function b(E){await Tt(async()=>{let y=await tc(E);_(y),i(y?.type||"http"),l(y?.dataFormat||"map")}),h(!1)}L(()=>{t.dataSourceId&&(h(!0),b(t.dataSourceId))},[t.dataSourceId]);async function v(){p("");let E=e.current;function y(S){let R=E.elements[S];return R?R.value.trim():""}let C=t.dataSourceId||y("id");if(!C){p("missing id");return}if(!Qa(C)){p("id is invalid (alphanumeric characters and dashes only)");return}let T=y("url");if(!T){p("missing url");return}let k={id:C,description:y("description"),type:a,url:T,previewUrl:y("previewUrl")};if(a==="http"){if(!gBe(T)){p("invalid url");return}k.httpOptions={method:c};let S=y("httpHeaders");if(S&&(k.httpOptions.headers=_Be(S)),c==="POST"){let R=y("httpBody");R&&(k.httpOptions.body=R)}}else if(a==="gsheet"){if(!vs(T)?.spreadsheetId){p("failed to parse spreadsheet url");return}k.dataFormat=s||"map"}try{_(k),n(!0),t.dataSourceId?(await V7(t.dataSourceId,k),he({title:"Saved data source",message:`Successfully updated ${C}`,autoClose:5e3}),n(!1)):(await U7(C,k),he({title:"Added data source",message:`Successfully added ${C}`,autoClose:5e3}),n(!1),xr(`/cms/data/${C}`))}catch(S){console.error(S),he({title:"Failed to save data source",message:String(S),color:"red",autoClose:!1}),n(!1)}}let I=[{value:"http",label:"HTTP"}];return(r.enabled||a==="gsheet")&&I.push({value:"gsheet",label:"Google Sheet"}),f("form",{className:"DataSourceForm",ref:e,onSubmit:E=>{E.preventDefault(),v()},children:[f(Kn,{visible:m}),f("div",{className:"DataSourceForm__input",children:f(Vt,{name:"type",label:"Type",data:I,value:a,onChange:E=>i(E),size:"xs",radius:0,dropdownComponent:"div"})}),f(Mt,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:t.dataSourceId,disabled:!!t.dataSourceId}),f(Kt,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:g?.description}),f(Mt,{className:"DataSourceForm__input",name:"url",label:"URL",description:x,size:"xs",radius:0,value:g?.url}),a==="http"&&f(Oe,{children:[f("div",{className:"DataSourceForm__input",children:f(Vt,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:c,onChange:E=>d(E),size:"xs",radius:0,dropdownComponent:"div"})}),f(Kt,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:xBe(g?.httpOptions?.headers||{})}),c==="POST"&&f(Kt,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:g?.httpOptions?.body})]}),a==="gsheet"&&f("div",{className:"DataSourceForm__input",children:[f(Vt,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:s,onChange:E=>l(E),size:"xs",radius:0,dropdownComponent:"div"}),s==="array"&&f("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",f("code",{children:"[[header1, header2], [foo, bar]]"})]}),s==="map"&&f("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",f("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),f(Mt,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:g?.previewUrl}),f(Y,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:o,children:t.buttonLabel||"Save"}),u&&f("div",{className:"DataSourceForm__error",children:["Error: ",u]})]})}function gBe(t){let e,r=t.startsWith("/")?"http://localhost":void 0;try{e=new URL(t,r)}catch(o){return console.error(o),!1}return e.protocol==="http:"||e.protocol==="https:"}function _Be(t){let e={};return t.split(`
|
|
228
228
|
`).forEach(o=>{let n=o.indexOf(":");if(n===-1)return;let a=o.slice(0,n).trim(),i=o.slice(n+1).trim();a&&i&&(e[a]=i)}),e}function xBe(t){let e=[];for(let r in t){let o=t[r];e.push(`${r}: ${o}`)}return e.join(`
|
|
229
229
|
`)}function XX(t){let e=nt(),r=It();function o(){let n=`delete-data-source-${t.id}`,a=e.openConfirmModal({...r,title:"Delete data source",children:f(Ve,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete data source ",f("code",{children:t.id}),"? All previously synced data will be deleted. There is no undo."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{he({id:n,title:"Deleting data source",message:`Deleting ${t.id} and synced data...`,loading:!0,autoClose:!1}),await q7(t.id),gt({id:n,title:"Deleted data source",message:`Successfully deleted ${t.id}`,loading:!1,autoClose:5e3}),e.closeModal(a),xr("/cms/data")}})}return f(ge,{children:f("div",{className:"EditDataSourcePage",children:[f("div",{className:"EditDataSourcePage__header",children:[f(Sr,{className:"EditDataSourcePage__header__breadcrumbs",children:[f("a",{href:"/cms/data",children:"Data Sources"}),f("a",{href:`/cms/data/${t.id}`,children:t.id}),f("div",{children:"Edit"})]}),f("div",{className:"EditDataSourcePage__header__titleWrap",children:[f(Le,{size:"h1",children:["Edit Data Source: ",t.id]}),f("div",{className:"EditDataSourcePage__header__controls",children:f(Ie,{label:"Delete",children:f(Ue,{onClick:o,children:f(Hm,{size:20,stroke:"1.5"})})})})]})]}),f(pw,{dataSourceId:t.id})]})})}ye();ye();function mw(t){let e=t.docId,[r,o]=P(t.doc),[n,a]=P(!t.doc);async function i(){a(!0),await Tt(async()=>{let h=await qv(e);o(h)}),a(!1)}if(L(()=>{i()},[e]),n)return f("div",{className:Te(t.className,"DocPreviewCard","DocPreviewCard--loading",t.variant&&`DocPreviewCard--${t.variant}`),children:f(De,{color:"gray",size:"sm"})});let[s,l]=e.split("/"),c=r.fields||{},d=window.__ROOT_CTX.collections[s];if(!d)throw new Error(`could not find collection: ${s}`);let u=_o(c,d.preview?.title||"meta.title"),p=_o(c,d.preview?.image||"meta.image")||d.preview?.defaultImage,m=Sa({collectionId:s,slug:l});return f("div",{className:Te(t.className,"DocPreviewCard",t.variant&&`DocPreviewCard--${t.variant}`),children:[f("div",{className:"DocPreviewCard__image",children:f(Wn,{src:p?.src,width:80,height:60,withPlaceholder:!p?.src})}),f("div",{className:"DocPreviewCard__content",children:[f("div",{className:"DocPreviewCard__content__header",children:[f("div",{className:"DocPreviewCard__content__header__docId",children:r.id}),t.statusBadges&&r&&f(Lu,{doc:r})]}),f("div",{className:"DocPreviewCard__content__title",children:u||"[UNTITLED]"}),t.variant!=="compact"&&m&&f("div",{className:"DocPreviewCard__content__url",children:m})]})]})}function $s(t){let e=U(null),[r,o]=P(!1),[n,a]=P(""),[i,s]=P(!!t.releaseId),[l,c]=P(null),[d,u]=P([]),[p,m]=P([]),h=Q7(),g=W7();async function _(y){console.log(y),await Tt(async()=>{let C=await uc(y);c(C),u(C?.docIds||[]),m(C?.dataSourceIds||[])}),s(!1)}L(()=>{t.releaseId&&(s(!0),_(t.releaseId))},[t.releaseId]);async function x(){a("");let y=e.current;function C(S){let R=y.elements[S];return R?R.value.trim():""}let T=t.releaseId||C("id");if(!T){a("missing id");return}if(!Qa(T)){a("id is invalid (alphanumeric characters and dashes only)");return}let k={id:T,description:C("description"),docIds:d,dataSourceIds:p};try{c(k),o(!0),t.releaseId?(await xH(t.releaseId,k),he({title:"Saved release",message:`Updated ${T}`,autoClose:5e3}),o(!1)):(await gH(T,k),he({title:"Added release",message:`Successfully added ${T}`,autoClose:5e3}),o(!1)),xr(`/cms/releases/${T}`)}catch(S){console.error(S),he({title:"Failed to save release",message:String(S),color:"red",autoClose:!1}),o(!1)}}function b(){h.open({selectedDocIds:d,onChange:(y,C)=>{u(T=>{let k=[...T];if(C)k.push(y);else{let S=k.findIndex(R=>R===y);S>-1&&k.splice(S,1)}return console.log(k),k.sort()})}})}function v(){g.open({selectedDataSourceIds:p,onChange:(y,C)=>{m(T=>{let k=[...T];if(C)k.push(y);else{let S=k.indexOf(y);S>-1&&k.splice(S,1)}return k.sort()})}})}function I(y){console.log("onRemoveDoc()",y),u(C=>{let T=[...C],k=T.indexOf(y);return k!==-1&&T.splice(k,1),console.log(T),T})}function E(y){m(C=>{let T=[...C],k=T.indexOf(y);return k!==-1&&T.splice(k,1),T})}return f("form",{className:"ReleaseForm",ref:e,onSubmit:y=>{y.preventDefault(),x()},children:[f(Kn,{visible:i}),f(Mt,{className:"ReleaseForm__input",name:"id",label:"ID",description:"Unique identifier for the release. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:t.releaseId,disabled:!!t.releaseId}),f(Kt,{className:"ReleaseForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:l?.description}),f(co,{className:"ReleaseForm__input",label:"Docs",description:"Select one or more docs to add to the release. Note: you can add or edit this list at a later time, if needed.",size:"xs",children:[d.length>0&&f($s.DocPreviewCards,{docIds:d,onRemoveDoc:I}),f(Y,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>b(),children:"Select"})]}),f(co,{className:"ReleaseForm__input",label:"Data Sources",description:"Optional. Data sources to publish with the release.",size:"xs",children:[p.length>0&&f($s.DataSourceIds,{ids:p,onRemove:E}),f(Y,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>v(),children:"Select"})]}),f("div",{className:"ReleaseForm__submit__buttons",children:f(Y,{className:"ReleaseForm__submit",color:"blue",size:"xs",type:"submit",loading:r,children:t.buttonLabel||"Save"})}),n&&f("div",{className:"ReleaseForm__error",children:["Error: ",n]})]})}$s.DocPreviewCards=t=>f("div",{className:"ReleaseForm__DocPreviewCards",children:t.docIds.map(e=>f("div",{className:"ReleaseForm__DocPreviewCards__card",children:[f(mw,{className:"ReleaseForm__DocPreviewCards__card__preview",docId:e}),f("div",{className:"ReleaseForm__DocPreviewCards__card__controls",children:[f("div",{className:"ReleaseForm__DocPreviewCards__card__controls__remove",children:f(Ie,{label:"Remove",children:f(Ue,{className:"ReleaseForm__DocPreviewCards__card__controls__remove__icon",onClick:()=>t.onRemoveDoc(e),children:f(oa,{size:16})})})}),f("div",{className:"ReleaseForm__DocPreviewCards__card__controls__open",children:f(Ie,{label:"Open",children:f(Ue,{component:"a",className:"ReleaseForm__DocPreviewCards__card__controls__open__icon",href:`/cms/content/${e}`,target:"_blank",children:f(ws,{size:16})})})})]})]},e))});$s.DataSourceIds=t=>f("div",{className:"ReleaseForm__DataSourceIds",children:t.ids.map(e=>f("div",{className:"ReleaseForm__DataSourceIds__item",children:[f("span",{className:"ReleaseForm__DataSourceIds__item__id",children:e}),f(Ue,{className:"ReleaseForm__DataSourceIds__item__remove",onClick:()=>t.onRemove(e),children:f(oa,{size:16})})]},e))});function QX(t){let e=nt(),r=It();function o(){let n=`delete-release-${t.id}`,a=e.openConfirmModal({...r,title:"Delete release",children:f(Ve,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete release ",f("code",{children:t.id}),"? There is no undo. This will only delete the release; the docs in the release will remain unchanged."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{he({id:n,title:"Deleting release",message:`Deleting ${t.id}...`,loading:!0,autoClose:!1}),await bH(t.id),gt({id:n,title:"Deleted release",message:`Successfully deleted ${t.id}`,loading:!1,autoClose:5e3}),e.closeModal(a),xr("/cms/releases")}})}return f(ge,{children:f("div",{className:"EditReleasePage",children:[f("div",{className:"EditReleasePage__header",children:[f(Sr,{className:"EditReleasePage__header__breadcrumbs",children:[f("a",{href:"/cms/releases",children:"Releases"}),f("a",{href:`/cms/releases/${t.id}`,children:t.id}),f("div",{children:"Edit"})]}),f("div",{className:"EditReleasePage__header__titleWrap",children:[f(Le,{size:"h1",children:["Edit Release: ",t.id]}),f("div",{className:"EditReleasePage__header__controls",children:f(Ie,{label:"Delete",children:f(Ue,{onClick:o,children:f(Hm,{size:20,stroke:"1.5"})})})})]})]}),f($s,{releaseId:t.id})]})})}ye();function hw(t){let e=t.limit||40,[r,o]=P(!0),[n,a]=P([]);async function i(){let s=await b7({limit:e});a(s),o(!1)}return L(()=>{i()},[]),r?f("div",{className:"ActionsLog ActionsLog--loading",children:f(De,{color:"gray",size:"xl"})}):f("div",{className:"ActionsLog",children:f(hr,{className:"ActionsLog__table",children:[f("thead",{children:f("tr",{className:"ActionsLogs__table__row ActionsLogs__table__row--header",children:[f("th",{className:"ActionsLogs__table__header",children:"timestamp"}),f("th",{className:"ActionsLogs__table__header",children:"user"}),f("th",{className:"ActionsLogs__table__header",children:"action"}),f("th",{className:"ActionsLogs__table__header",children:"quick links"})]})}),f("tbody",{children:n.map(s=>f("tr",{className:"ActionsLogs__table__row",children:[f("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:bBe(s.timestamp)}),f("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:s.by}),f("td",{className:"ActionsLogs__table__col",children:[s.action," ",vBe(s.metadata)]}),f("td",{className:"ActionsLogs__table__col",children:f("div",{className:"ActionsLogs__table__buttons",children:[s.action!=="doc.delete"&&s.metadata?.docId&&f(Ie,{transition:"pop",label:s.metadata.docId,children:f(Y,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/content/${s.metadata?.docId}`,children:"Open doc"})}),s.action!=="datasource.delete"&&s.metadata?.datasourceId&&f(Ie,{transition:"pop",label:s.metadata.datasourceId,children:f(Y,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/data/${s.metadata?.datasourceId}`,children:"Open release"})}),s.action!=="release.delete"&&s.metadata?.releaseId&&f(Ie,{transition:"pop",label:s.metadata.releaseId,children:f(Y,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${s.metadata?.releaseId}`,children:"Open release"})}),s.metadata?.sheetId&&f(Y,{component:"a",variant:"default",size:"xs",compact:!0,href:ra(s.metadata.sheetId),target:"_blank",children:"Open sheet"}),s.action.startsWith("acls.")&&f(Y,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/settings",children:"Open settings"})]})})]}))})]})})}function bBe(t){return t.toDate().toLocaleString("sv-SE",{dateStyle:"short",timeStyle:"medium"})}function vBe(t){function e(r){return r===null?"null":typeof r>"u"?"undefined":typeof r=="string"?`"${r.replaceAll('"','\\"')}"`:typeof r!="object"?String(r):Array.isArray(r)?`[${r.map(e).join(", ")}]`:`{${Object.entries(r).map(([n,a])=>`${n}: ${e(a)}`).join(", ")}}`}return e(t)}var ZX=250;function JX(){return f(ge,{children:f("div",{className:"LogsPage",children:[f("div",{className:"LogsPage__header",children:[f(Le,{size:"h1",children:"Action Logs"}),f(Ve,{as:"p",children:["The latest ",ZX," actions are displayed here. View all past actions in the"," ",f("a",{href:yBe(),target:"_blank",children:"Firebase Console"}),"."]})]}),f(hw,{limit:ZX})]})})}function yBe(){let t=window.__ROOT_CTX.firebaseConfig,e=t.projectId,r=window.__ROOT_CTX.rootConfig.projectId,o=t.databaseId||"-default-",n=`/Projects/${r}/ActionLogs`.replaceAll("/","~2F");return`https://console.firebase.google.com/project/${e}/firestore/databases/${o}/data/${n}`}function eQ(){return f(ge,{children:f("div",{className:"NewDataSourcePage",children:[f("div",{className:"NewDataSourcePage__header",children:[f(Sr,{className:"NewDataSourcePage__header__breadcrumbs",children:[f("a",{href:"/cms/data",children:"Data Sources"}),f("div",{children:"New"})]}),f(Le,{size:"h1",children:"Add Data Source"})]}),f(pw,{buttonLabel:"Create data source"})]})})}function tQ(){return f(ge,{children:f("div",{className:"NewReleasePage",children:[f("div",{className:"NewReleasePage__header",children:[f(Sr,{className:"NewReleasePage__header__breadcrumbs",children:[f("a",{href:"/cms/releases",children:"Releases"}),f("div",{children:"New"})]}),f(Le,{size:"h1",children:"Add Release"})]}),f($s,{buttonLabel:"Create release"})]})})}function rQ(){return f(ge,{children:f("div",{className:"NotFoundPage",children:[f("div",{className:"NotFoundPage__icon",children:f(Um,{size:60})}),f("h2",{className:"NotFoundPage__title",children:"Not Found"}),f("p",{className:"NotFoundPage__body",children:["Double-check the URL and try again or ",f("a",{href:"/cms",children:"go home"}),"."]})]})})}function gw(){let t=window.__ROOT_CTX.rootConfig.projectName||"Root CMS";return f(ge,{children:f("div",{className:"ProjectPage",children:[f("div",{className:"ProjectPage__headline",children:f(Le,{className:"ProjectPage__title",size:"h1",children:t})}),f("div",{className:"ProjectPage__section",children:[f(Le,{className:"ProjectPage__section__title",size:"h2",children:"Content"}),f(gw.CollectionList,{})]}),f("div",{className:"ProjectPage__section",children:[f(Le,{className:"ProjectPage__section__title ProjectPage__section__title--flex",size:"h2",children:[f("div",{children:"Recent actions"}),f("div",{children:f(Y,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/logs",children:"Show all"})})]}),f(hw,{limit:20})]})]})})}gw.CollectionList=()=>{let t=Object.keys(window.__ROOT_CTX.collections).map(e=>({...window.__ROOT_CTX.collections[e],id:e}));return f("div",{className:"ProjectPage__collectionList",children:[t.map(e=>f("a",{className:"ProjectPage__collectionList__collection",href:`/cms/content/${e.id}`,children:[f("div",{className:"ProjectPage__collectionList__collection__icon",children:f(nc,{size:20,strokeWidth:"1.75"})}),f("div",{className:"ProjectPage__collectionList__collection__name",children:e.name||e.id}),e.description&&f("div",{className:"ProjectPage__collectionList__collection__desc",children:e.description})]},e.id)),t.length===0&&f("div",{className:"ProjectPage__collectionList__collections__empty",children:"No collections match your query."})]})};ye();var oQ={transition:"pop"};function _w(t){let e=t.release;return e.scheduledAt?f(Ie,{...oQ,label:`Scheduled ${wBe(e.scheduledAt)} by ${e.scheduledBy}`,wrapLines:!0,width:240,children:f(xa,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}):e.publishedAt?f(Ie,{...oQ,label:`Published ${IBe(e.publishedAt)} by ${e.publishedBy}`,children:f(xa,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):f(xa,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function IBe(t){return t?ea(t.toMillis()):ea(new Date().getTime())}function wBe(t){return new Date(t.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Hs(t){let[e,r]=P(!0),[o,n]=P(null),[a,i]=P(0),s=t.id;async function l(){r(!0),await Tt(async()=>{let d=await uc(s);n(d),i(Nm())}),r(!1)}L(()=>{l()},[]);function c(d){console.log("onAction()",d),l()}return f(ge,{children:f("div",{className:"ReleasePage",children:[f("div",{className:"ReleasePage__header",children:[f(Sr,{className:"ReleasePage__header__breadcrumbs",children:[f("a",{href:"/cms/releases",children:"Releases"}),f("div",{children:s})]}),f("div",{className:"ReleasePage__header__titleWrap",children:[f(Le,{size:"h1",children:["Release: ",s]}),f("div",{className:"ReleasePage__header__controls",children:f(Ie,{label:"Configure",children:f(Ue,{component:"a",href:`/cms/releases/${t.id}/edit`,children:f(sc,{size:24,stroke:"1.5"})})})})]}),o?.description&&f(Ve,{as:"p",children:o.description})]}),e?f(De,{color:"gray",size:"xl"}):f(Oe,{children:[o&&f(Hs.PublishStatus,{release:o,onAction:c}),o&&o.docIds&&o.docIds.length>0&&f(Hs.DocsList,{release:o},`docs-list-${a}`),o&&o.dataSourceIds&&o.dataSourceIds.length>0&&f(Hs.DataSourcesList,{release:o},`data-sources-${a}`)]})]})})}Hs.PublishStatus=t=>{let e=t.release,[r,o]=P(!1),n=nt(),a=It(),i=EH({releaseId:e.id,onScheduled:()=>{t.onAction("scheduled")}});function s(){let u=e.docIds||[],p=e.dataSourceIds||[],m=u.length+p.length;if(m===0){he({title:"Cannot publish release",message:"Error: nothing in the release to publish.",color:"red",autoClose:!1});return}n.openConfirmModal({...a,title:`Publish release: ${e.id}`,children:f(Ve,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to publish this release? The ",m," items in the release will go live immediately."]}),labels:{confirm:"Publish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{l()}})}async function l(){o(!0),await Tt(async()=>{let u=`publish-release-${e.id}`,p=e.docIds?.length||0,m=e.dataSourceIds?.length||0,h=p+m;he({id:u,title:"Publishing release",message:`Publishing ${h} items...`,loading:!0,autoClose:!1}),await vH(e.id),gt({id:u,title:"Published release!",message:`Successfully published ${h} items!`,loading:!1,autoClose:5e3}),t.onAction&&t.onAction("publish")}),o(!1)}function c(){i.open()}async function d(){await IH(e.id),t.onAction("cancel-schedule")}return f("div",{className:"ReleasePage__PublishStatus",children:[f(Le,{size:"h2",children:"Status"}),f(hr,{verticalSpacing:"xs",striped:!0,fontSize:"xs",children:[f("thead",{children:f("tr",{children:[f("th",{children:"status"}),f("th",{children:"actions"})]})}),f("tbody",{children:f("tr",{children:[f("td",{children:f(_w,{release:e})}),f("td",{children:f("div",{className:"ReleasePage__PublishStatus__actions",children:[!e.scheduledAt&&f(Ie,{label:"Publish the release immediately",position:"bottom",withArrow:!0,children:f(Y,{variant:"default",size:"xs",compact:!0,onClick:()=>s(),loading:r,children:e.publishedAt?"Re-publish":"Publish"})}),e.scheduledAt?f(Ie,{label:"Cancel the scheduled release",position:"bottom",withArrow:!0,children:f(Y,{variant:"default",size:"xs",compact:!0,onClick:()=>d(),children:"Cancel Schedule"})}):f(Ie,{label:"Schedule the release to be published at a future date",position:"bottom",withArrow:!0,wrapLines:!0,width:180,children:f(Y,{variant:"default",size:"xs",compact:!0,onClick:()=>c(),children:"Schedule"})})]})})]})})]})]})};Hs.DocsList=t=>{let e=t.release,r=e.docIds||[];return f("div",{className:"ReleasePage__DocsList",children:[f("div",{className:"ReleasePage__DocsList__header",children:[f(Le,{size:"h2",children:"Docs"}),f(Y,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${e.id}/edit`,children:"Edit"})]}),f("div",{className:"ReleasePage__DocsList__cards",children:r.map(o=>f("div",{className:"ReleasePage__DocsList__card",children:f("a",{href:`/cms/content/${o}`,children:f(mw,{docId:o,statusBadges:!0})})},o))})]})};Hs.DataSourcesList=t=>{let e=t.release,r=e.dataSourceIds||[];return f("div",{className:"ReleasePage__DataSourcesList",children:[f("div",{className:"ReleasePage__DataSourcesList__header",children:[f(Le,{size:"h2",children:"Data Sources"}),f(Y,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${e.id}/edit`,children:"Edit"})]}),f("div",{className:"ReleasePage__DataSourcesList__items",children:r.map(o=>f("div",{className:"ReleasePage__DataSourcesList__item",children:f("a",{href:`/cms/data/${o}`,children:o})},o))})]})};ye();function xw(){return f(ge,{children:f("div",{className:"ReleasesPage",children:[f("div",{className:"ReleasesPage__header",children:[f(Le,{size:"h1",children:"Releases"}),f(Ve,{as:"p",children:"Create a release for publishing content in a batch."}),f("div",{className:"ReleasesPage__header__buttons",children:f(Y,{component:"a",color:"blue",size:"xs",href:"/cms/releases/new",children:"New release"})})]}),f(xw.ReleasesTable,{})]})})}xw.ReleasesTable=()=>{let[t,e]=P(!0),[r,o]=P([]);async function n(){let a=await _H();o(a),e(!1)}return L(()=>{n()},[]),f("div",{className:"ReleasesPage__ReleasesTable",children:[t&&f(De,{color:"gray",size:"xl"}),r.length>0&&f(hr,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[f("thead",{children:f("tr",{children:[f("th",{children:"id"}),f("th",{children:"description"}),f("th",{children:"content"}),f("th",{children:"status"})]})}),f("tbody",{children:r.map(a=>f("tr",{children:[f("td",{children:f("a",{href:`/cms/releases/${a.id}`,children:a.id})}),f("td",{children:a.description||""}),f("td",{children:(a.docIds||[]).map(i=>f("div",{children:f("a",{href:`/cms/content/${i}`,children:i})}))}),f("td",{children:f("div",{className:"ReleasesPage__ReleasesTable__publishStatus",children:f(_w,{release:a})})})]},a.id))})]})]})};ye();function EBe(t){let e=window.firebase.user.email;if(!e)return null;if(e in t)return t[e];let o=`*@${e.split("@").at(-1)}`;return o in t?t[o]:null}function SBe(t){return EBe(t)==="ADMIN"}function bw(t){let[e,r]=P(!0),[o,n]=P({}),[a,i]=P(""),s=window.firebase.db,l=window.__ROOT_CTX.rootConfig.projectId||"default",c=Ee(s,"Projects",l),d=SBe(o);L(()=>{Pr(c).then(h=>{let g=h.data()||{};n(g.roles||{}),r(!1)})},[]);async function u(h,g){r(!0),await Tt(async()=>{g==="REMOVE"?(await cr(c,new Wo("roles",h),Yr()),n(_=>{let x={..._};return delete x[h],x}),st("acls.remove_user",{metadata:{user:h}})):(await cr(c,new Wo("roles",h),g),n(_=>({..._,[h]:g})),st("acls.update_user",{metadata:{user:h,role:g}}))}),r(!1)}async function p(h){i(""),r(!0),await Tt(async()=>{await cr(c,new Wo("roles",h),"EDITOR"),n(g=>({...g,[h]:"VIEWER"}))}),st("acls.add_user",{metadata:{user:h,role:"VIEWER"}}),r(!1)}let m=Y7(Object.keys(o).map(h=>({email:h,role:o[h]})),"email");return f("div",{className:Te(t.className,"ShareBox"),children:[e&&f(Kn,{visible:!0,loaderProps:{color:"gray",size:"xl"}}),f("form",{className:"ShareBox__addUser",onSubmit:h=>{h.preventDefault(),p(a)},children:[f(Mt,{className:"ShareBox__addUser__email",placeholder:"grogu@example.com",type:"email",value:a,onChange:h=>i(h.target.value),radius:0,size:"xs"}),f(Y,{className:"ShareBox__addUser__button",size:"xs",radius:0,color:"dark",type:"submit",disabled:!d,children:"Add user"})]}),f("div",{className:"ShareBox__users",children:m.map(h=>f(bw.User,{...h,currentUserIsAdmin:d,onChange:u},h.email))})]})}bw.User=t=>{let e=t.email===window.firebase.user.email;return f("div",{className:"ShareBox__user",children:[f(Ve,{className:"ShareBox__user__email",size:"body-sm",weight:"semi-bold",color:"gray",children:[t.email,e&&" (you)"]}),f("div",{className:"ShareBox__user__roleSelect",children:f(Vt,{data:[{value:"ADMIN",label:"ADMIN"},{value:"EDITOR",label:"EDITOR"},{value:"VIEWER",label:"VIEWER"},{value:"REMOVE",label:"REMOVE"}],value:t.role,radius:0,size:"xs",disabled:e||!t.currentUserIsAdmin,onChange:r=>{t.onChange(t.email,r)}})})]})};function nQ(){return f(ge,{children:f("div",{className:"SettingsPage",children:f("div",{className:"SettingsPage__section SettingsPage__section__users",children:[f("div",{className:"SettingsPage__section__left",children:[f(Le,{className:"SettingsPage__section__left__title",children:"Share"}),f(Ve,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:[f("p",{children:"Share access to the CMS. To share with everyone in a domain, use *@example.com."}),f("ul",{children:[f("li",{children:"VIEWER: view docs but not edit"}),f("li",{children:"EDITOR: view and edit docs"}),f("li",{children:"ADMIN: all of the above and change sharing settings"})]})]})]}),f("div",{className:"SettingsPage__section__right",children:[f(Le,{className:"SettingsPage__section__right__title",size:"h3",children:"Users"}),f(bw,{className:"SettingsPage__section__users__sharebox"})]})]})})})}function aQ(t){let r=(window.__ROOT_CTX.sidebar?.tools||{})[t.id];return r?r.iframeUrl?f(ge,{children:f("div",{className:"SidebarToolsPage",children:f("iframe",{src:r.iframeUrl})})}):f(ge,{children:f("div",{className:"SidebarToolsPage SidebarToolsPage--error",children:["missing iframeUrl: ",t.id]})}):f(ge,{children:f("div",{className:"SidebarToolsPage SidebarToolsPage--error",children:["not found: ",t.id]})})}Uc();var vw=class{constructor(){this.data={}}setMeta(e){Object.entries(e).forEach(([r,o])=>{r.startsWith("@@")||(r=`@@${r}`),this.data[r]=o})}add(e,r,o){this.data[e]=r,o&&(this.data[`@${e}`]=o)}get(e){let r=this.data[e];return r?{source:r,meta:this.data[`@${e}`]}:null}list(){let e=[];return Object.entries(this.data).forEach(([r])=>{if(r.startsWith("@@"))return;let o=this.data[r],n=this.data[`@${r}`];e.push({key:r,source:o,meta:n})}),e}toJson(){return{...this.data}}toString(){return JSON.stringify(this.toJson(),null,2)}};function sf(){return f(ge,{children:f("div",{className:"TranslationsArbPage",children:[f("div",{className:"TranslationsArbPage__header",children:[f(Sr,{className:"TranslationsArbPage__header__breadcrumbs",children:[f("a",{href:"/cms/translations",children:"Translations"}),f("div",{children:"ARB"})]}),f(Le,{size:"h1",children:"ARB Translations"}),f(Ve,{as:"p",children:"Enter doc ids below (separated by newlines) to include in an ARB file."})]}),f(sf.RequestForm,{})]})})}sf.RequestForm=()=>{let[t,e]=P(""),[r,o]=P(!1),[n,a]=P(""),[i,s]=P(null);async function l(u){let p=await Vk(u),m=new vw,h=window.__ROOT_CTX.rootConfig,g=[h.domain];h.base&&h.base!=="/"&&g.push(h.base);let _=g.join("");m.setMeta({locale:"en",context:_,last_modified:new Date().toISOString()}),console.log(p);for(let x in p){let b=p[x],v=new Set,I=x.split("/")[0],E=await bu(I);jm(v,E.fields,b.fields||{});for(let y of v){let C=await Gv(y),T=m.get(C)?.meta;if(T){let k=T.context.split(", ");k.push(x),k.sort(),T.context=k.join(", ")}else T={context:x};m.add(C,y,T)}}return m}async function c(){try{let u=iQ(t),p=await l(u);s(p)}catch(u){console.error(u),a(`failed to preview arb: ${u}`)}}async function d(){try{o(!0),console.log("download arb");let u=iQ(t),m=(await l(u)).toString(),g=await new Response(m).blob(),_=document.createElement("a");_.href=window.URL.createObjectURL(g),_.download=kBe(u),document.body.appendChild(_),_.click(),document.body.removeChild(_),window.URL.revokeObjectURL(_.href),o(!1)}catch(u){console.error(u),a(`failed to download arb: ${u}`)}}return f("form",{className:"TranslationsArbPage__RequestForm",onSubmit:u=>{u.preventDefault(),d()},children:[f("div",{className:"TranslationsArbPage__RequestForm__textareaWrapper",children:f(Kt,{required:!0,size:"xs",radius:0,autosize:!0,minRows:8,maxRows:20,value:t,placeholder:"Pages/index",onChange:u=>{e(u.currentTarget.value||"")}})}),f("div",{className:"TranslationsArbPage__RequestForm__submit",children:[f(Y,{variant:"default",color:"dark",size:"xs",onClick:c,children:"Preview"}),f(Y,{color:"blue",size:"xs",loading:r,type:"submit",leftIcon:f(oc,{size:16,strokeWidth:1.75}),children:"Download ARB"})]}),n&&f(Ve,{as:"p",className:"TranslationsArbPage__RequestForm__error",children:n}),i&&f(sf.Preview,{arb:i})]})};sf.Preview=t=>{let e=t.arb.list().filter(r=>!!r.meta);return console.log(e),f(hr,{verticalSpacing:"xs",highlightOnHover:!0,fontSize:"xs",children:[f("thead",{children:f("tr",{children:[f("th",{children:"source"}),f("th",{children:"context"})]})}),f("tbody",{children:e.map(r=>f("tr",{class:"TranslationsArbPage__Preview__Table__row",children:[f("td",{children:r.source}),f("td",{children:[r.meta?.context,r.meta?.description&&f(Oe,{children:["/ ",r.meta.description]})]})]},r.source))})]})};function iQ(t){return t.split(`
|
|
230
230
|
`).map(e=>e.trim()).filter(e=>CBe(e))}function CBe(t){return!!t&&t.includes("/")&&t.split("/").length===2}function kBe(t){let e=new Date,r=i=>i.toString().padStart(2,"0"),o=`${e.getFullYear()}${r(e.getMonth()+1)}${r(e.getDate())}t${r(e.getHours())}${r(e.getMinutes())}`,n=window.__ROOT_CTX.rootConfig.projectName||window.__ROOT_CTX.rootConfig.projectId,a=[sQ(n)];return t.length===1&&a.push(sQ(t[0])),a.push(o),`${a.join("_")}.arb`}function sQ(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}ye();function yw(t){let e=t.hash,[r,o]=P(!1),[n,a]=P(!1),[i,s]=P({source:""});async function l(){o(!0);let d=await y7(e);if(o(!1),!d?.source){a(!0);return}s(d)}async function c(d){console.log(d),o(!0),await I7(e,d),s(u=>({...u,...d})),o(!1),he({title:"Saved translations",message:`Updated translations for ${e}.`,autoClose:5e3})}return L(()=>{l()},[t.hash]),f(ge,{children:f("div",{className:"TranslationsEditPage",children:[f("div",{className:"TranslationsEditPage__header",children:[f(Sr,{className:"TranslationsEditPage__header__breadcrumbs",children:[f("a",{href:"/cms/translations",children:"Translations"}),f("div",{children:t.hash})]}),f(Le,{size:"h1",children:"Edit Translations"})]}),r?f(De,{color:"gray",size:"xl"}):n?f("div",{className:"TranslationsEditPage__notFound",children:"Not Found"}):f(yw.Form,{hash:t.hash,translations:i,onChange:c})]})})}yw.Form=t=>{let e=t.translations,o=(window.__ROOT_CTX.rootConfig.i18n.locales||[]).filter(n=>n!=="en");return f("form",{className:"TranslationsEditPage__Form",onSubmit:n=>{n.preventDefault();let a=n.currentTarget,i=["en",...o],s={};i.forEach(l=>{let c=a.elements[l].value;s[l]=Ci(c)}),t.onChange(s)},children:[f(Mt,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:"hash",label:"hash",value:t.hash,disabled:!0}),f(Kt,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:"source",label:"source",value:e.source,disabled:!0}),f(Kt,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:"en",label:"en",value:e.en}),o.map(n=>f(Kt,{className:"TranslationsEditPage__Form__input",size:"xs",radius:0,name:n,label:n,value:e[n]||""},n)),f(Y,{className:"TranslationsEditPage__Form__input__submit",color:"blue",size:"xs",type:"submit",children:"Save"})]})};ye();function Iw(){return f(ge,{children:f("div",{className:"TranslationsPage",children:[f("div",{className:"TranslationsPage__header",children:[f(Le,{size:"h1",children:"Translations"}),f("div",{className:"TranslationsPage__header__buttons",children:f(Y,{component:"a",color:"blue",size:"xs",href:"/cms/translations/arb",children:"Download ARB"})})]}),f(Iw.TranslationsTable,{})]})})}Iw.TranslationsTable=()=>{let[t,e]=P(!0),[r,o]=P([]),a=(window.__ROOT_CTX.rootConfig.i18n?.locales||[]).filter(l=>l!=="en"),i=["hash","source","en",...a,"tags"];async function s(){e(!0),await Tt(async()=>{let l=await bs(),c=[];Object.entries(l).forEach(([d,u])=>{let p=a.map(m=>u[m]||"");c.push([d,u.source,u.en,...p,(u.tags||[]).join(`
|