@harbour-enterprises/superdoc 1.34.0-next.6 → 1.34.0-next.7
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/chunks/{SuperConverter-U_rfPwId.cjs → SuperConverter-BKnqJHWC.cjs} +1 -1
- package/dist/chunks/{SuperConverter-DlOiYED-.es.js → SuperConverter-D5KgOHBk.es.js} +1 -1
- package/dist/chunks/{SuperDoc-DcSO8d09.cjs → SuperDoc-Bn5axnsN.cjs} +4 -4
- package/dist/chunks/{SuperDoc-DQrNru46.es.js → SuperDoc-DQkxTdgf.es.js} +4 -4
- package/dist/chunks/{create-headless-toolbar-BdzJngfo.cjs → create-headless-toolbar-DmghsEWw.cjs} +1 -1
- package/dist/chunks/{create-headless-toolbar-CfFPHr_F.es.js → create-headless-toolbar-Dp7h3xO7.es.js} +1 -1
- package/dist/chunks/{create-super-doc-ui-CmbXWNKP.es.js → create-super-doc-ui-B2qKbAPC.es.js} +2 -2
- package/dist/chunks/{create-super-doc-ui-Cq_Uaq3r.cjs → create-super-doc-ui-Bg3hP7Gd.cjs} +2 -2
- package/dist/chunks/{src-CbxGnEMy.cjs → src-DDYXrERU.cjs} +5 -5
- package/dist/chunks/{src-CWmo466-.es.js → src-aOq_mhII.es.js} +5 -5
- package/dist/headless-toolbar-react.cjs +2 -2
- package/dist/headless-toolbar-react.es.js +2 -2
- package/dist/headless-toolbar-vue.cjs +2 -2
- package/dist/headless-toolbar-vue.es.js +2 -2
- package/dist/headless-toolbar.cjs +4 -4
- package/dist/headless-toolbar.es.js +4 -4
- package/dist/public/legacy/headless-toolbar.cjs +18 -0
- package/dist/public/legacy/headless-toolbar.es.js +14 -0
- package/dist/public.cjs +5 -5
- package/dist/public.es.js +5 -5
- package/dist/super-editor/converter.cjs +1 -1
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor.cjs +4 -4
- package/dist/super-editor.es.js +4 -4
- package/dist/superdoc/src/public/legacy/headless-toolbar.d.cts +30 -0
- package/dist/superdoc/src/public/legacy/headless-toolbar.d.ts +39 -0
- package/dist/superdoc/src/public/legacy/headless-toolbar.d.ts.map +1 -0
- package/dist/superdoc.cjs +5 -5
- package/dist/superdoc.es.js +5 -5
- package/dist/superdoc.min.js +5 -5
- package/dist/ui-react.cjs +3 -3
- package/dist/ui-react.es.js +3 -3
- package/dist/ui.cjs +3 -3
- package/dist/ui.es.js +3 -3
- package/package.json +2 -2
package/dist/superdoc.min.js
CHANGED
|
@@ -2,7 +2,7 @@ var SuperDoc=(function(){var zWe=Object.create,p_=Object.defineProperty,UWe=Obje
|
|
|
2
2
|
`)}},f8=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[RT]?Nre(e,t):Q0(e)?jB(e,n=>qB(t,r=>f8(n,r))):_qe(e)?Ov(e,(n,r)=>f8(n,t[r])):!1,Vl=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),f8(t,n)}equals(e){return this.constructor===e.constructor&&Fv(this.shape,e.shape)}[cYe](){return!0}[RT](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Mu()}get nullable(){return Bv(this,f1)}get optional(){return new Xre(this)}cast(e){return cie(e,this),e}expect(e){return cie(e,this),e}},h8=class extends Vl{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){const n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}};const qs=(e,t=null)=>new h8(e,t),FXn=qs(h8);var p8=class extends Vl{constructor(e){super(),this.shape=e}check(e,t){const n=this.shape(e);return!n&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),n}};const Ia=e=>new p8(e),BXn=qs(p8);var a1=class extends Vl{constructor(e){super(),this.shape=e}check(e,t){const n=this.shape.some(r=>r===e);return!n&&t?.extend(null,this.shape.join(" | "),e.toString()),n}};const l1=(...e)=>new a1(e),Yre=qs(a1);var dYe=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),Kre=e=>{if(zv.check(e))return[dYe(e)];if(Yre.check(e))return e.shape.map(t=>t+"");if(sie.check(e))return["[+-]?\\d+.?\\d*"];if(aie.check(e))return[".*"];if(c1.check(e))return e.shape.map(Kre).flat(1);zl()},fYe=class extends Vl{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Kre).map(t=>`(${t.join("|")})`).join("")+"$")}check(e,t){const n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),n}};const HXn=qs(fYe);var hYe=Symbol("optional"),Xre=class extends Vl{constructor(e){super(),this.shape=e}check(e,t){const n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,"undefined (optional)","()"),n}get[hYe](){return!0}};const pYe=qs(Xre);var Jre=class extends Vl{check(e,t){return t?.extend(null,"never",typeof e),!1}};const zXn=new Jre,UXn=qs(Jre);var Zre=class FVe extends Vl{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}static _dilutes=!0;get partial(){return new FVe(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):Ov(this.shape,(r,i)=>{const o=this._isPartial&&!r8(t,i)||r.check(t[i],n);return!o&&n?.extend(i.toString(),r.toString(),typeof t[i],"Object property does not match"),o})}};const mYe=e=>new Zre(e),gYe=qs(Zre),yYe=Ia(e=>e!=null&&(e.constructor===Object||e.constructor==null));var Qre=class extends Vl{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Ov(e,(n,r)=>{const i=this.shape.keys.check(r,t);return!i&&t?.extend(r+"","Record",typeof e,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(n,t)})}};const $re=(e,t)=>new Qre(e,t),bYe=qs(Qre);var eie=class extends Vl{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Ov(this.shape,(n,r)=>{const i=n.check(e[r],t);return!i&&t?.extend(r.toString(),"Tuple",typeof n),i})}};const vYe=(...e)=>new eie(e),VXn=qs(eie);var tie=class extends Vl{constructor(e){super(),this.shape=e.length===1?e[0]:new m8(e)}check(e,t){const n=Q0(e)&&jB(e,r=>this.shape.check(r));return!n&&t?.extend(null,"Array",""),n}};const nie=(...e)=>new tie(e),wYe=qs(tie),AYe=Ia(e=>Q0(e));var rie=class extends Vl{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){const n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}};const xYe=(e,t=null)=>new rie(e,t),WXn=qs(rie),SYe=xYe(Vl);var TYe=class extends Vl{constructor(e){super(),this.len=e.length-1,this.args=vYe(...e.slice(-1)),this.res=e[this.len]}check(e,t){const n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,"function",typeof e),n}};const IYe=qs(TYe),kYe=Ia(e=>typeof e=="function");var EYe=class extends Vl{constructor(e){super(),this.shape=e}check(e,t){const n=jB(this.shape,r=>r.check(e,t));return!n&&t?.extend(null,"Intersectinon",typeof e),n}};const GXn=qs(EYe,e=>e.shape.length>0);var m8=class extends Vl{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){const n=qB(this.shape,r=>r.check(e,t));return t?.extend(null,"Union",typeof e),n}};const Bv=(...e)=>e.findIndex(t=>c1.check(t))>=0?Bv(...e.map(t=>LT(t)).map(t=>c1.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new m8(e),c1=qs(m8);var iie=()=>!0;const u1=Ia(iie),CYe=qs(p8,e=>e.shape===iie),g8=Ia(e=>typeof e=="bigint"),_Ye=Ia(e=>e===g8),oie=Ia(e=>typeof e=="symbol"),jXn=Ia(e=>e===oie),Hv=Ia(e=>typeof e=="number"),sie=Ia(e=>e===Hv),zv=Ia(e=>typeof e=="string"),aie=Ia(e=>e===zv),d1=Ia(e=>typeof e=="boolean"),PYe=Ia(e=>e===d1),lie=l1(void 0),qXn=qs(a1,e=>e.shape.length===1&&e.shape[0]===void 0),YXn=l1(void 0),f1=l1(null),RYe=qs(a1,e=>e.shape.length===1&&e.shape[0]===null),KXn=qs(Uint8Array),XXn=qs(h8,e=>e.shape===Uint8Array),LYe=Bv(Hv,zv,f1,lie,g8,d1,oie),JXn=(()=>{const e=nie(u1),t=$re(zv,u1),n=Bv(Hv,zv,f1,d1,e,t);return e.shape=n,t.shape.values=n,n})(),LT=e=>{if(SYe.check(e))return e;if(yYe.check(e)){const t={};for(const n in e)t[n]=LT(e[n]);return mYe(t)}else{if(AYe.check(e))return Bv(...e.map(LT));if(LYe.check(e))return l1(e);if(kYe.check(e))return qs(e)}zl()},cie=zqe?()=>{}:(e,t)=>{const n=new uYe;if(!t.check(e,n))throw Mf(`Expected value to be of type ${t.constructor.name}.
|
|
3
3
|
${n.toString()}`)};var NYe=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:LT(e),h:t}),this}else(e){return this.if(u1,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){const r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Mf("Unhandled pattern")}}},uie=(e=>new NYe(e))(u1).if(sie,(e,t)=>c8(t,vre,Z_)).if(aie,(e,t)=>lYe(t)).if(PYe,(e,t)=>jre(t)).if(_Ye,(e,t)=>BigInt(c8(t,vre,Z_))).if(c1,(e,t)=>Uv(t,d8(t,e.shape))).if(gYe,(e,t)=>{const n={};for(const r in e.shape){let i=e.shape[r];if(pYe.check(i)){if(jre(t))continue;i=i.shape}n[r]=uie(i,t)}return n}).if(wYe,(e,t)=>{const n=[],r=qre(t,0,42);for(let i=0;i<r;i++)n.push(Uv(t,e.shape));return n}).if(Yre,(e,t)=>d8(t,e.shape)).if(RYe,(e,t)=>null).if(IYe,(e,t)=>{const n=Uv(t,e.res);return()=>n}).if(CYe,(e,t)=>Uv(t,d8(t,[Hv,zv,f1,lie,g8,d1,nie(Hv),$re(Bv("a","b","c"),Hv)]))).if(bYe,(e,t)=>{const n={},r=c8(t,0,3);for(let i=0;i<r;i++){const o=Uv(t,e.shape.keys);n[o]=Uv(t,e.shape.values)}return n}).done();const Uv=(e,t)=>uie(LT(t),e),Cm=typeof document<"u"?document:{},QXn=Ia(e=>e.nodeType===BYe),$Xn=typeof DOMParser<"u"?new DOMParser:null,eJn=Ia(e=>e.nodeType===DYe),tJn=Ia(e=>e.nodeType===OYe),MYe=e=>Tqe(e,(t,n)=>`${n}:${t};`).join(""),DYe=Cm.ELEMENT_NODE,OYe=Cm.TEXT_NODE,nJn=Cm.CDATA_SECTION_NODE,rJn=Cm.COMMENT_NODE,FYe=Cm.DOCUMENT_NODE,iJn=Cm.DOCUMENT_TYPE_NODE,BYe=Cm.DOCUMENT_FRAGMENT_NODE,oJn=Ia(e=>e.nodeType===FYe);var h1=e=>class{constructor(n){this._=n}destroy(){e(this._)}},HYe=h1(clearTimeout);const y8=(e,t)=>new HYe(setTimeout(t,e));var sJn=h1(clearInterval);const aJn=h1(e=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(e));var lJn=h1(e=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(e));const ep=Symbol,die=ep(),fie=ep(),zYe=ep(),UYe=ep(),VYe=ep(),hie=ep(),WYe=ep(),b8=ep(),GYe=ep(),jYe=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[];let r=0;for(;r<e.length;r++){const i=e[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)t.push(i);else if(i.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){const i=e[r];i instanceof Symbol||n.push(i)}return n};var cJn=Nd(),qYe={[die]:$h("font-weight","bold"),[fie]:$h("font-weight","normal"),[zYe]:$h("color","blue"),[VYe]:$h("color","green"),[UYe]:$h("color","grey"),[hie]:$h("color","red"),[WYe]:$h("color","purple"),[b8]:$h("color","orange"),[GYe]:$h("color","black")},YYe=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[],r=Ul();let i=[],o=0;for(;o<e.length;o++){const s=e[o],a=qYe[s];if(a!==void 0)r.set(a.left,a.right);else{if(s===void 0)break;if(s.constructor===String||s.constructor===Number){const l=MYe(r);o>0||l.length>0?(t.push("%c"+s),n.push(l)):t.push(s)}else break}}for(o>0&&(i=n,i.unshift(t.join("")));o<e.length;o++){const s=e[o];s instanceof Symbol||i.push(s)}return i},pie=Vqe?YYe:jYe;const KYe=(...e)=>{console.log(...pie(e)),gie.forEach(t=>t.print(e))},mie=(...e)=>{console.warn(...pie(e)),e.unshift(b8),gie.forEach(t=>t.print(e))},gie=Jh(),yie=e=>({[Symbol.iterator](){return this},next:e}),XYe=(e,t)=>yie(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),v8=(e,t)=>yie(()=>{const{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var p1=class{constructor(e,t){this.clock=e,this.len=t}},Vv=class{constructor(){this.clients=new Map}},_m=(e,t,n)=>t.clients.forEach((r,i)=>{const o=e.doc.store.clients.get(i);if(o!=null){const s=o[o.length-1],a=s.id.clock+s.length;for(let l=0,c=r[l];l<r.length&&c.clock<a;c=r[++l])Oie(e,o,c.clock,c.len,n)}}),JYe=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){const i=Nu((n+r)/2),o=e[i],s=o.clock;if(s<=t){if(t<s+o.len)return i;n=i+1}else r=i-1}return null},Wv=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&JYe(n,t.clock)!==null},w8=e=>{e.clients.forEach(t=>{t.sort((i,o)=>i.clock-o.clock);let n,r;for(n=1,r=1;n<t.length;n++){const i=t[r-1],o=t[n];i.clock+i.len>=o.clock?t[r-1]=new p1(i.clock,Ld(i.len,o.clock+o.len-i.clock)):(r<n&&(t[r]=o),r++)}t.length=r})},A8=e=>{const t=new Vv;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){const o=r.slice();for(let s=n+1;s<e.length;s++)Xje(o,e[s].clients.get(i)||[]);t.clients.set(i,o)}});return w8(t),t},NT=(e,t,n,r)=>{Du(e.clients,t,()=>[]).push(new p1(n,r))},x8=()=>new Vv,bie=e=>{const t=x8();return e.clients.forEach((n,r)=>{const i=[];for(let o=0;o<n.length;o++){const s=n[o];if(s.deleted){const a=s.id.clock;let l=s.length;if(o+1<n.length)for(let c=n[o+1];o+1<n.length&&c.deleted;c=n[++o+1])l+=c.length;i.push(new p1(a,l))}}i.length>0&&t.clients.set(r,i)}),t},Gv=(e,t)=>{En(e.restEncoder,t.clients.size),Zh(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),En(e.restEncoder,n);const i=r.length;En(e.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];e.writeDsClock(s.clock),e.writeDsLen(s.len)}})},S8=e=>{const t=new Vv,n=Cr(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();const i=Cr(e.restDecoder),o=Cr(e.restDecoder);if(o>0){const s=Du(t.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new p1(e.readDsClock(),e.readDsLen()))}}return t},vie=(e,t,n)=>{const r=new Vv,i=Cr(e.restDecoder);for(let o=0;o<i;o++){e.resetDsCurVal();const s=Cr(e.restDecoder),a=Cr(e.restDecoder),l=n.clients.get(s)||[],c=_s(n,s);for(let u=0;u<a;u++){const d=e.readDsClock(),f=d+e.readDsLen();if(d<c){c<f&&NT(r,s,c,f-c);let h=Md(l,d),p=l[h];for(!p.deleted&&p.id.clock<d&&(l.splice(h+1,0,C1(t,p,d-p.id.clock)),h++);h<l.length&&(p=l[h++],p.id.clock<f);)p.deleted||(f<p.id.clock+p.length&&l.splice(h,0,C1(t,p,f-p.id.clock)),p.delete(t))}else NT(r,s,d,f-d)}}if(r.clients.size>0){const o=new ey;return En(o.restEncoder,0),Gv(o,r),o.toUint8Array()}return null},wie=Wre,tp=class BVe extends l8{constructor({guid:t=oYe(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=wie(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Nie,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Gre(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Gre(c=>{const u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const t=this._item;t!==null&&!this.shouldLoad&&vo(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Zh(this.subdocs).map(t=>t.guid))}transact(t,n=null){return vo(this,t,n)}get(t,n=ka){const r=Du(this.share,t,()=>{const o=new n;return o._integrate(this,null),o}),i=r.constructor;if(n!==ka&&i!==n)if(i===ka){const o=new n;o._map=r._map,r._map.forEach(s=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(t,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,I1)}getText(t=""){return this.get(t,UT)}getMap(t=""){return this.get(t,Ka)}getXmlElement(t=""){return this.get(t,Ou)}getXmlFragment(t=""){return this.get(t,Jv)}toJSON(){const t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,Zh(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new BVe({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,vo(t.parent.doc,r=>{const i=n.doc;t.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Aie=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Cr(this.restDecoder)}readDsLen(){return Cr(this.restDecoder)}},xie=class extends Aie{readLeftID(){return Hr(Cr(this.restDecoder),Cr(this.restDecoder))}readRightID(){return Hr(Cr(this.restDecoder),Cr(this.restDecoder))}readClient(){return Cr(this.restDecoder)}readInfo(){return Dv(this.restDecoder)}readString(){return Zc(this.restDecoder)}readParentInfo(){return Cr(this.restDecoder)===1}readTypeRef(){return Cr(this.restDecoder)}readLen(){return Cr(this.restDecoder)}readAny(){return PT(this.restDecoder)}readBuf(){return Jqe(Ya(this.restDecoder))}readJSON(){return JSON.parse(Zc(this.restDecoder))}readKey(){return Zc(this.restDecoder)}},ZYe=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Cr(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Cr(this.restDecoder)+1;return this.dsCurrVal+=e,e}},jv=class extends ZYe{constructor(e){super(e),this.keys=[],Cr(e),this.keyClockDecoder=new e8(Ya(e)),this.clientDecoder=new r1(Ya(e)),this.leftClockDecoder=new e8(Ya(e)),this.rightClockDecoder=new e8(Ya(e)),this.infoDecoder=new Ere(Ya(e),Dv),this.stringDecoder=new bqe(Ya(e)),this.parentInfoDecoder=new Ere(Ya(e),Dv),this.typeRefDecoder=new r1(Ya(e)),this.lenDecoder=new r1(Ya(e))}readLeftID(){return new qv(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new qv(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return PT(this.restDecoder)}readBuf(){return Ya(this.restDecoder)}readJSON(){return PT(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}},Sie=class{constructor(){this.restEncoder=ia()}toUint8Array(){return Fo(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){En(this.restEncoder,e)}writeDsLen(e){En(this.restEncoder,e)}},MT=class extends Sie{writeLeftID(e){En(this.restEncoder,e.client),En(this.restEncoder,e.clock)}writeRightID(e){En(this.restEncoder,e.client),En(this.restEncoder,e.clock)}writeClient(e){En(this.restEncoder,e)}writeInfo(e){KB(this.restEncoder,e)}writeString(e){Ta(this.restEncoder,e)}writeParentInfo(e){En(this.restEncoder,e?1:0)}writeTypeRef(e){En(this.restEncoder,e)}writeLen(e){En(this.restEncoder,e)}writeAny(e){Mv(this.restEncoder,e)}writeBuf(e){ns(this.restEncoder,e)}writeJSON(e){Ta(this.restEncoder,JSON.stringify(e))}writeKey(e){Ta(this.restEncoder,e)}},Tie=class{constructor(){this.restEncoder=ia(),this.dsCurrVal=0}toUint8Array(){return Fo(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,En(this.restEncoder,t)}writeDsLen(e){e===0&&zl(),En(this.restEncoder,e-1),this.dsCurrVal+=e}},ey=class extends Tie{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new QB,this.clientEncoder=new e1,this.leftClockEncoder=new QB,this.rightClockEncoder=new QB,this.infoEncoder=new xre(KB),this.stringEncoder=new hqe,this.parentInfoEncoder=new xre(KB),this.typeRefEncoder=new e1,this.lenEncoder=new e1}toUint8Array(){const e=ia();return En(e,0),ns(e,this.keyClockEncoder.toUint8Array()),ns(e,this.clientEncoder.toUint8Array()),ns(e,this.leftClockEncoder.toUint8Array()),ns(e,this.rightClockEncoder.toUint8Array()),ns(e,Fo(this.infoEncoder)),ns(e,this.stringEncoder.toUint8Array()),ns(e,Fo(this.parentInfoEncoder)),ns(e,this.typeRefEncoder.toUint8Array()),ns(e,this.lenEncoder.toUint8Array()),$_(e,Fo(this.restEncoder)),Fo(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Mv(this.restEncoder,e)}writeBuf(e){ns(this.restEncoder,e)}writeJSON(e){Mv(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},QYe=(e,t,n,r)=>{r=Ld(r,t[0].id.clock);const i=Md(t,r);En(e.restEncoder,t.length-i),e.writeClient(n),En(e.restEncoder,r);const o=t[i];o.write(e,r-o.id.clock);for(let s=i+1;s<t.length;s++)t[s].write(e,0)},T8=(e,t,n)=>{const r=new Map;n.forEach((i,o)=>{_s(t,o)>i&&r.set(o,i)}),BT(t).forEach((i,o)=>{n.has(o)||r.set(o,0)}),En(e.restEncoder,r.size),Zh(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{QYe(e,t.clients.get(i),i,o)})},$Ye=(e,t)=>{const n=Ul(),r=Cr(e.restDecoder);for(let i=0;i<r;i++){const o=Cr(e.restDecoder),s=new Array(o),a=e.readClient();let l=Cr(e.restDecoder);n.set(a,{i:0,refs:s});for(let c=0;c<o;c++){const u=e.readInfo();switch(31&u){case 0:{const d=e.readLen();s[c]=new Fu(Hr(a,l),d),l+=d;break}case 10:{const d=Cr(e.restDecoder);s[c]=new Bu(Hr(a,l),d),l+=d;break}default:{const d=(u&192)===0,f=new Bo(Hr(a,l),null,(u&128)===128?e.readLeftID():null,null,(u&64)===64?e.readRightID():null,d?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,d&&(u&32)===32?e.readString():null,poe(e,u));s[c]=f,l+=f.length}}}}return n},eKe=(e,t,n)=>{const r=[];let i=Zh(n.keys()).sort((h,p)=>h-p);if(i.length===0)return null;const o=()=>{if(i.length===0)return null;let h=n.get(i[i.length-1]);for(;h.refs.length===h.i;)if(i.pop(),i.length>0)h=n.get(i[i.length-1]);else return null;return h};let s=o();if(s===null)return null;const a=new Nie,l=new Map,c=(h,p)=>{const m=l.get(h);(m==null||m>p)&&l.set(h,p)};let u=s.refs[s.i++];const d=new Map,f=()=>{for(const h of r){const p=h.id.client,m=n.get(p);m?(m.i--,a.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[]):a.clients.set(p,[h]),i=i.filter(g=>g!==p)}r.length=0};for(;;){if(u.constructor!==Bu){const h=Du(d,u.id.client,()=>_s(t,u.id.client))-u.id.clock;if(h<0)r.push(u),c(u.id.client,u.id.clock-1),f();else{const p=u.getMissing(e,t);if(p!==null){r.push(u);const m=n.get(p)||{refs:[],i:0};if(m.refs.length===m.i)c(p,_s(t,p)),f();else{u=m.refs[m.i++];continue}}else(h===0||h<u.length)&&(u.integrate(e,h),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(s!==null&&s.i<s.refs.length)u=s.refs[s.i++];else{if(s=o(),s===null)break;u=s.refs[s.i++]}}if(a.clients.size>0){const h=new ey;return T8(h,a,new Map),En(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},tKe=(e,t)=>T8(e,t.doc.store,t.beforeState),nKe=(e,t,n,r=new jv(e))=>vo(t,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=eKe(i,a,$Ye(r,s)),c=a.pendingStructs;if(c){for(const[d,f]of c.missing)if(f<_s(a,d)){o=!0;break}if(l){for(const[d,f]of l.missing){const h=c.missing.get(d);(h==null||h>f)&&c.missing.set(d,f)}c.update=b1([c.update,l.update])}}else a.pendingStructs=l;const u=vie(r,i,a);if(a.pendingDs){const d=new jv(Qh(a.pendingDs));Cr(d.restDecoder);const f=vie(d,i,a);u&&f?a.pendingDs=b1([u,f]):a.pendingDs=u||f}else a.pendingDs=u;if(o){const d=a.pendingStructs.update;a.pendingStructs=null,m1(i.doc,d)}},n,!1),m1=(e,t,n,r=jv)=>{const i=Qh(t);nKe(i,e,n,new r(i))},Iie=(e,t,n)=>m1(e,t,n,xie),rKe=(e,t,n=new Map)=>{T8(e,t.store,n),Gv(e,bie(t.store))},iKe=(e,t=new Uint8Array([0]),n=new ey)=>{rKe(n,e,kie(t));const r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(SKe(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===MT)return AKe(r.map((i,o)=>o===0?i:IKe(i)));if(n.constructor===ey)return b1(r)}return r[0]},I8=(e,t)=>iKe(e,t,new MT),oKe=e=>{const t=new Map,n=Cr(e.restDecoder);for(let r=0;r<n;r++){const i=Cr(e.restDecoder),o=Cr(e.restDecoder);t.set(i,o)}return t},kie=e=>oKe(new Aie(Qh(e))),Eie=(e,t)=>(En(e.restEncoder,t.size),Zh(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{En(e.restEncoder,n),En(e.restEncoder,r)}),e),sKe=(e,t)=>Eie(e,BT(t.store)),aKe=(e,t=new Tie)=>(e instanceof Map?Eie(t,e):sKe(t,e),t.toUint8Array()),lKe=e=>aKe(e,new Sie),cKe=class{constructor(){this.l=[]}},Cie=()=>new cKe,_ie=(e,t)=>e.l.push(t),Pie=(e,t)=>{const n=e.l,r=n.length;e.l=n.filter(i=>t!==i),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Rie=(e,t,n)=>i8(e.l,[t,n]),qv=class{constructor(e,t){this.client=e,this.clock=t}},Yv=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Hr=(e,t)=>new qv(e,t),DT=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw zl()},OT=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},FT=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ty=e=>new FT(e.type==null?null:Hr(e.type.client,e.type.clock),e.tname??null,e.item==null?null:Hr(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),uKe=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},dKe=(e,t,n=0)=>new uKe(e,t,n),g1=(e,t,n)=>{let r=null,i=null;return e._item===null?i=DT(e):r=Hr(e._item.id.client,e._item.id.clock),new FT(r,i,t,n)},k8=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return g1(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return g1(e,Hr(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return g1(e,r.lastId,n);r=r.right}return g1(e,null,n)},fKe=(e,t)=>{const n=Kv(e,t);return{item:n,diff:t.clock-n.id.clock}},hKe=(e,t,n=!0)=>{const r=t.store,i=e.item,o=e.type,s=e.tname,a=e.assoc;let l=null,c=0;if(i!==null){if(_s(r,i.client)<=i.clock)return null;const u=n?G8(r,i):fKe(r,i),d=u.item;if(!(d instanceof Bo))return null;if(l=d.parent,l._item===null||!l._item.deleted){c=d.deleted||!d.countable?0:u.diff+(a>=0?0:1);let f=d.left;for(;f!==null;)!f.deleted&&f.countable&&(c+=f.length),f=f.left}}else{if(s!==null)l=t.get(s);else if(o!==null){if(_s(r,o.client)<=o.clock)return null;const{item:u}=n?G8(r,o):{item:Kv(r,o)};if(u instanceof Bo&&u.content instanceof np)l=u.content.type;else return null}else throw zl();a>=0?c=l._length:c=0}return dKe(l,c,e.assoc)},Lie=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Yv(e.item,t.item)&&Yv(e.type,t.type)&&e.assoc===t.assoc,E8=class{constructor(e,t){this.ds=e,this.sv=t}},C8=(e,t)=>new E8(e,t),uJn=C8(x8(),new Map),_8=e=>C8(bie(e.store),BT(e.store)),ny=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Wv(t.ds,e.id),P8=(e,t)=>{const n=Du(e.meta,P8,Jh),r=e.doc.store;n.has(t)||(t.sv.forEach((i,o)=>{i<_s(r,o)&&Ac(e,Hr(o,i))}),_m(e,t.ds,i=>{}),n.add(t))},Nie=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},BT=e=>{const t=new Map;return e.clients.forEach((n,r)=>{const i=n[n.length-1];t.set(r,i.id.clock+i.length)}),t},_s=(e,t)=>{const n=e.clients.get(t);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},Mie=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw zl()}n.push(t)},Md=(e,t)=>{let n=0,r=e.length-1,i=e[r],o=i.id.clock;if(o===t)return r;let s=Nu(t/(o+i.length-1)*r);for(;n<=r;){if(i=e[s],o=i.id.clock,o<=t){if(t<o+i.length)return s;n=s+1}else r=s-1;s=Nu((n+r)/2)}throw zl()},pKe=(e,t)=>{const n=e.clients.get(t.client);return n[Md(n,t.clock)]},Kv=pKe,R8=(e,t,n)=>{const r=Md(t,n),i=t[r];return i.id.clock<n&&i instanceof Bo?(t.splice(r+1,0,C1(e,i,n-i.id.clock)),r+1):r},Ac=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[R8(e,n,t.clock)]},Die=(e,t,n)=>{const r=t.clients.get(n.client),i=Md(r,n.clock),o=r[i];return n.clock!==o.id.clock+o.length-1&&o.constructor!==Fu&&r.splice(i+1,0,C1(e,o,n.clock-o.id.clock+1)),o},mKe=(e,t,n)=>{const r=e.clients.get(t.id.client);r[Md(r,t.id.clock)]=n},Oie=(e,t,n,r,i)=>{if(r===0)return;const o=n+r;let s=R8(e,t,n),a;do a=t[s++],o<a.id.clock+a.length&&R8(e,t,o),i(a);while(s<t.length&&t[s].id.clock<o)},gKe=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Vv,this.beforeState=BT(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Fie=(e,t)=>t.deleteSet.clients.size===0&&!Iqe(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(w8(t.deleteSet),tKe(e,t),Gv(e,t.deleteSet),!0),Bie=(e,t,n)=>{const r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Du(e.changed,t,Jh).add(n)},y1=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Bo&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const o=t-i;return o&&e.splice(t+1-o,o),o},yKe=(e,t,n)=>{for(const[r,i]of e.clients.entries()){const o=t.clients.get(r);for(let s=i.length-1;s>=0;s--){const a=i[s],l=a.clock+a.len;for(let c=Md(o,a.clock),u=o[c];c<o.length&&u.id.clock<l;u=o[++c]){const d=o[c];if(a.clock+a.len<=d.id.clock)break;d instanceof Bo&&d.deleted&&!d.keep&&n(d)&&d.gc(t,!1)}}}},bKe=(e,t)=>{e.clients.forEach((n,r)=>{const i=t.clients.get(r);for(let o=n.length-1;o>=0;o--){const s=n[o],a=Nf(i.length-1,1+Md(i,s.clock+s.len-1));for(let l=a,c=i[l];l>0&&c.id.clock>=s.clock;c=i[l])l-=1+y1(i,l)}})},Hie=(e,t)=>{if(t<e.length){const n=e[t],r=n.doc,i=r.store,o=n.deleteSet,s=n._mergeStructs;try{w8(o),n.afterState=BT(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=c,u._path=null}),l.sort((u,d)=>u.path.length-d.path.length),a.push(()=>{Rie(c._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&HKe(n)})}),i8(a,[])}finally{r.gc&&yKe(o,i,r.gcFilter),bKe(o,i),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=i.clients.get(d),p=Ld(Md(h,f),1);for(let m=h.length-1;m>=p;)m-=1+y1(h,m)}});for(let u=s.length-1;u>=0;u--){const{client:d,clock:f}=s[u].id,h=i.clients.get(d),p=Md(h,f);p+1<h.length&&y1(h,p+1)>1||p>0&&y1(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(KYe(b8,die,"[yjs] ",fie,hie,"Changed the client-id because another client seems to be using it."),r.clientID=wie()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new MT;Fie(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new ey;Fie(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=n;(a.size>0||c.size>0||l.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,n]),c.forEach(u=>u.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):Hie(e,t+1)}}},vo=(e,t,n=null,r=!0)=>{const i=e._transactionCleanups;let o=!1,s=null;e._transaction===null&&(o=!0,e._transaction=new gKe(e,n,r),i.push(e._transaction),i.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{s=t(e._transaction)}finally{if(o){const a=e._transaction===i[0];e._transaction=null,a&&Hie(i,0)}}return s},vKe=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},zie=(e,t,n)=>{_m(e,n.deletions,r=>{r instanceof Bo&&t.scope.some(i=>i===e.doc||OT(i,r))&&j8(r,!1)})},Uie=(e,t,n)=>{let r=null;const i=e.doc,o=e.scope;vo(i,a=>{for(;t.length>0&&e.currStackItem===null;){const l=i.store,c=t.pop(),u=new Set,d=[];let f=!1;_m(a,c.insertions,h=>{if(h instanceof Bo){if(h.redone!==null){let{item:p,diff:m}=G8(l,h.id);m>0&&(p=Ac(a,Hr(p.id.client,p.id.clock+m))),h=p}!h.deleted&&o.some(p=>p===a.doc||OT(p,h))&&d.push(h)}}),_m(a,c.deletions,h=>{h instanceof Bo&&o.some(p=>p===a.doc||OT(p,h))&&!Wv(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{f=hoe(a,h,u,c.insertions,e.ignoreRemoteMapChanges,e)!==null||f});for(let h=d.length-1;h>=0;h--){const p=d[h];e.deleteFilter(p)&&(p.delete(a),f=!0)}e.currStackItem=f?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},e);const s=e.currStackItem;if(s!=null){const a=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:s,type:n,changedParentTypes:a,origin:e},e]),e.currStackItem=null}return s},Vie=class extends l8{constructor(e,{captureTimeout:t=500,captureTransaction:n=a=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:s=Q0(e)?e[0].doc:e instanceof tp?e:e.doc}={}){super(),this.scope=[],this.doc=s,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=t,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(m=>a.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const l=this.undoing,c=this.redoing,u=l?this.redoStack:this.undoStack;l?this.stopCapturing():c||this.clear(!1,!0);const d=new Vv;a.afterState.forEach((m,g)=>{const y=a.beforeState.get(g)||0,v=m-y;v>0&&NT(d,g,y,v)});const f=Nd();let h=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!l&&!c){const m=u[u.length-1];m.deletions=A8([m.deletions,a.deleteSet]),m.insertions=A8([m.insertions,d])}else u.push(new vKe(a.deleteSet,d)),h=!0;!l&&!c&&(this.lastChange=f),_m(a,a.deleteSet,m=>{m instanceof Bo&&this.scope.some(g=>g===a.doc||OT(g,m))&&j8(m,!0)});const p=[{stackItem:u[u.length-1],origin:a.origin,type:l?"redo":"undo",changedParentTypes:a.changedParentTypes},this];h?this.emit("stack-item-added",p):this.emit("stack-item-updated",p)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const t=new Set(this.scope);e=Q0(e)?e:[e],e.forEach(n=>{t.has(n)||(t.add(n),(n instanceof ka?n.doc!==this.doc:n!==this.doc)&&mie("[yjs#509] Not same Y.Doc"),this.scope.push(n))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(r=>zie(n,this,r)),this.undoStack=[]),t&&(this.redoStack.forEach(r=>zie(n,this,r)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Uie(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Uie(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};function*wKe(e){const t=Cr(e.restDecoder);for(let n=0;n<t;n++){const r=Cr(e.restDecoder),i=e.readClient();let o=Cr(e.restDecoder);for(let s=0;s<r;s++){const a=e.readInfo();if(a===10){const l=Cr(e.restDecoder);yield new Bu(Hr(i,o),l),o+=l}else if((31&a)!==0){const l=(a&192)===0,c=new Bo(Hr(i,o),null,(a&128)===128?e.readLeftID():null,null,(a&64)===64?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(a&32)===32?e.readString():null,poe(e,a));yield c,o+=c.length}else{const l=e.readLen();yield new Fu(Hr(i,o),l),o+=l}}}}var L8=class{constructor(e,t){this.gen=wKe(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Bu);return this.curr}},N8=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},AKe=e=>b1(e,xie,MT),xKe=(e,t)=>{if(e.constructor===Fu){const{client:n,clock:r}=e.id;return new Fu(Hr(n,r+t),e.length-t)}else if(e.constructor===Bu){const{client:n,clock:r}=e.id;return new Bu(Hr(n,r+t),e.length-t)}else{const n=e,{client:r,clock:i}=n.id;return new Bo(Hr(r,i+t),null,Hr(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},b1=(e,t=jv,n=ey)=>{if(e.length===1)return e[0];const r=e.map(l=>new t(Qh(l)));let i=r.map(l=>new L8(l,!0)),o=null;const s=new n,a=new N8(s);for(;i=i.filter(u=>u.curr!==null),i.sort((u,d)=>{if(u.curr.id.client===d.curr.id.client){const f=u.curr.id.clock-d.curr.id.clock;return f===0?u.curr.constructor===d.curr.constructor?0:u.curr.constructor===Bu?1:-1:f}else return d.curr.id.client-u.curr.id.client}),i.length!==0;){const l=i[0],c=l.curr.id.client;if(o!==null){let u=l.curr,d=!1;for(;u!==null&&u.id.clock+u.length<=o.struct.id.clock+o.struct.length&&u.id.client>=o.struct.id.client;)u=l.next(),d=!0;if(u===null||u.id.client!==c||d&&u.id.clock>o.struct.id.clock+o.struct.length)continue;if(c!==o.struct.id.client)Pm(a,o.struct,o.offset),o={struct:u,offset:0},l.next();else if(o.struct.id.clock+o.struct.length<u.id.clock)if(o.struct.constructor===Bu)o.struct.length=u.id.clock+u.length-o.struct.id.clock;else{Pm(a,o.struct,o.offset);const f=u.id.clock-o.struct.id.clock-o.struct.length;o={struct:new Bu(Hr(c,o.struct.id.clock+o.struct.length),f),offset:0}}else{const f=o.struct.id.clock+o.struct.length-u.id.clock;f>0&&(o.struct.constructor===Bu?o.struct.length-=f:u=xKe(u,f)),o.struct.mergeWith(u)||(Pm(a,o.struct,o.offset),o={struct:u,offset:0},l.next())}}else o={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===c&&u.id.clock===o.struct.id.clock+o.struct.length&&u.constructor!==Bu;u=l.next())Pm(a,o.struct,o.offset),o={struct:u,offset:0}}return o!==null&&(Pm(a,o.struct,o.offset),o=null),M8(a),Gv(s,A8(r.map(l=>S8(l)))),s.toUint8Array()},SKe=(e,t,n=jv,r=ey)=>{const i=kie(t),o=new r,s=new N8(o),a=new n(Qh(e)),l=new L8(a,!1);for(;l.curr;){const c=l.curr,u=c.id.client,d=i.get(u)||0;if(l.curr.constructor===Bu){l.next();continue}if(c.id.clock+c.length>d)for(Pm(s,c,Ld(d-c.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)Pm(s,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=d;)l.next()}return M8(s),Gv(o,S8(a)),o.toUint8Array()},Wie=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Fo(e.encoder.restEncoder)}),e.encoder.restEncoder=ia(),e.written=0)},Pm=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Wie(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),En(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},M8=e=>{Wie(e);const t=e.encoder.restEncoder;En(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const r=e.clientStructs[n];En(t,r.written),$_(t,r.restEncoder)}},TKe=(e,t,n,r)=>{const i=new n(Qh(e)),o=new L8(i,!1),s=new r,a=new N8(s);for(let l=o.curr;l!==null;l=o.next())Pm(a,t(l),0);return M8(a),Gv(s,S8(i)),s.toUint8Array()},IKe=e=>TKe(e,Oqe,jv,MT),Gie="You must not compute changes after the event-handler fired.",v1=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=kKe(this.currentTarget,this.target))}deletes(e){return Wv(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Mf(Gie);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){const r=t._map.get(n);let i,o;if(this.adds(r)){let s=r.left;for(;s!==null&&this.adds(s);)s=s.left;if(this.deletes(r))if(s!==null&&this.deletes(s))i="delete",o=GB(s.content.getContent());else return;else s!==null&&this.deletes(s)?(i="update",o=GB(s.content.getContent())):(i="add",o=void 0)}else if(this.deletes(r))i="delete",o=GB(r.content.getContent());else return;e.set(n,{action:i,oldValue:o})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Mf(Gie);const t=this.target,n=Jh(),r=Jh(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let o=null;const s=()=>{o&&i.push(o)};for(let a=t._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((o===null||o.delete===void 0)&&(s(),o={delete:0}),o.delete+=a.length,r.add(a)):this.adds(a)?((o===null||o.insert===void 0)&&(s(),o={insert:[]}),o.insert=o.insert.concat(a.content.getContent()),n.add(a)):((o===null||o.retain===void 0)&&(s(),o={retain:0}),o.retain+=a.length);o!==null&&o.retain===void 0&&s()}this._changes=e}return e}},kKe=(e,t)=>{const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,i=t._item.parent._start;for(;i!==t._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;n.unshift(r)}t=t._item.parent}return n},gl=()=>{mie("Invalid access: Add Yjs type to a document before reading data.")},jie=80,D8=0,EKe=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=D8++}},CKe=e=>{e.timestamp=D8++},qie=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=D8++},_Ke=(e,t,n)=>{if(e.length>=jie){const r=e.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return qie(r,t,n),r}else{const r=new EKe(t,n);return e.push(r),r}},w1=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce((o,s)=>J_(t-o.index)<J_(t-s.index)?o:s);let r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,CKe(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&J_(n.index-i)<r.parent.length/jie?(qie(n,r,i),n):_Ke(e._searchMarker,r,i)},HT=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){const i=e[r];if(n>0){let o=i.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(i.index-=o.length);if(o===null||o.marker===!0){e.splice(r,1);continue}i.p=o,o.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=Ld(t,i.index+n))}},A1=(e,t,n)=>{const r=e,i=t.changedParentTypes;for(;Du(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Rie(r._eH,n,t)},ka=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Cie(),this._dEH=Cie(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Mu()}clone(){throw Mu()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){_ie(this._eH,e)}observeDeep(e){_ie(this._dEH,e)}unobserve(e){Pie(this._eH,e)}unobserveDeep(e){Pie(this._dEH,e)}toJSON(){}},Yie=(e,t,n)=>{e.doc??gl(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t;const i=[];let o=e._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const s=o.content.getContent();if(s.length<=t)t-=s.length;else{for(let a=t;a<s.length&&r>0;a++)i.push(s[a]),r--;t=0}}o=o.right}return i},Kie=e=>{e.doc??gl();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i<r.length;i++)t.push(r[i])}n=n.right}return t},Xie=(e,t)=>{const n=[];let r=e._start;for(;r!==null;){if(r.countable&&ny(r,t)){const i=r.content.getContent();for(let o=0;o<i.length;o++)n.push(i[o])}r=r.right}return n},zT=(e,t)=>{let n=0,r=e._start;for(e.doc??gl();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let o=0;o<i.length;o++)t(i[o],n++,e)}r=r.right}},Jie=(e,t)=>{const n=[];return zT(e,(r,i)=>{n.push(t(r,i,e))}),n},PKe=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}const i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},Zie=(e,t)=>{e.doc??gl();const n=w1(e,t);let r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},x1=(e,t,n,r)=>{let i=n;const o=e.doc,s=o.clientID,a=o.store,l=n===null?t._start:n.right;let c=[];const u=()=>{c.length>0&&(i=new Bo(Hr(s,_s(a,s)),i,i&&i.lastId,l,l&&l.id,t,null,new E1(c)),i.integrate(e,0),c=[])};r.forEach(d=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:i=new Bo(Hr(s,_s(a,s)),i,i&&i.lastId,l,l&&l.id,t,null,new V8(new Uint8Array(d))),i.integrate(e,0);break;case tp:i=new Bo(Hr(s,_s(a,s)),i,i&&i.lastId,l,l&&l.id,t,null,new W8(d)),i.integrate(e,0);break;default:if(d instanceof ka)i=new Bo(Hr(s,_s(a,s)),i,i&&i.lastId,l,l&&l.id,t,null,new np(d)),i.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Qie=()=>Mf("Length exceeded!"),$ie=(e,t,n,r)=>{if(n>t._length)throw Qie();if(n===0)return t._searchMarker&&HT(t._searchMarker,n,r.length),x1(e,t,null,r);const i=n,o=w1(t,n);let s=t._start;for(o!==null&&(s=o.p,n-=o.index,n===0&&(s=s.prev,n+=s&&s.countable&&!s.deleted?s.length:0));s!==null;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&Ac(e,Hr(s.id.client,s.id.clock+n));break}n-=s.length}return t._searchMarker&&HT(t._searchMarker,i,r.length),x1(e,t,s,r)},RKe=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return x1(e,t,r,n)},eoe=(e,t,n,r)=>{if(r===0)return;const i=n,o=r,s=w1(t,n);let a=t._start;for(s!==null&&(a=s.p,n-=s.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&Ac(e,Hr(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Ac(e,Hr(a.id.client,a.id.clock+r)),a.delete(e),r-=a.length),a=a.right;if(r>0)throw Qie();t._searchMarker&&HT(t._searchMarker,i,-o+r)},S1=(e,t,n)=>{const r=t._map.get(n);r!==void 0&&r.delete(e)},O8=(e,t,n,r)=>{const i=t._map.get(n)||null,o=e.doc,s=o.clientID;let a;if(r==null)a=new E1([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new E1([r]);break;case Uint8Array:a=new V8(r);break;case tp:a=new W8(r);break;default:if(r instanceof ka)a=new np(r);else throw new Error("Unexpected content type")}new Bo(Hr(s,_s(o.store,s)),i,i&&i.lastId,null,null,t,n,a).integrate(e,0)},F8=(e,t)=>{e.doc??gl();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},toe=e=>{const t={};return e.doc??gl(),e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},noe=(e,t)=>{e.doc??gl();const n=e._map.get(t);return n!==void 0&&!n.deleted},LKe=(e,t)=>{const n={};return e._map.forEach((r,i)=>{let o=r;for(;o!==null&&(!t.sv.has(o.id.client)||o.id.clock>=(t.sv.get(o.id.client)||0));)o=o.left;o!==null&&ny(o,t)&&(n[i]=o.content.getContent()[o.length-1])}),n},T1=e=>(e.doc??gl(),XYe(e._map.entries(),t=>!t[1].deleted)),NKe=class extends v1{},I1=class aF extends ka{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new aF;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new aF}clone(){const t=new aF;return t.insert(0,this.toArray().map(n=>n instanceof ka?n.clone():n)),t}get length(){return this.doc??gl(),this._length}_callObserver(t,n){super._callObserver(t,n),A1(this,t,new NKe(this,t))}insert(t,n){this.doc!==null?vo(this.doc,r=>{$ie(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?vo(this.doc,n=>{RKe(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?vo(this.doc,r=>{eoe(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return Zie(this,t)}toArray(){return Kie(this)}slice(t=0,n=this.length){return Yie(this,t,n)}toJSON(){return this.map(t=>t instanceof ka?t.toJSON():t)}map(t){return Jie(this,t)}forEach(t){zT(this,t)}[Symbol.iterator](){return PKe(this)}_write(t){t.writeTypeRef(sXe)}},MKe=e=>new I1,DKe=class extends v1{constructor(e,t,n){super(e,t),this.keysChanged=n}},Ka=class gee extends ka{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new gee}clone(){const t=new gee;return this.forEach((n,r)=>{t.set(r,n instanceof ka?n.clone():n)}),t}_callObserver(t,n){A1(this,t,new DKe(this,t,n))}toJSON(){this.doc??gl();const t={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];t[r]=i instanceof ka?i.toJSON():i}}),t}get size(){return[...T1(this)].length}keys(){return v8(T1(this),t=>t[0])}values(){return v8(T1(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return v8(T1(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??gl(),this._map.forEach((n,r)=>{n.deleted||t(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?vo(this.doc,n=>{S1(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?vo(this.doc,r=>{O8(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return F8(this,t)}has(t){return noe(this,t)}clear(){this.doc!==null?vo(this.doc,t=>{this.forEach(function(n,r,i){S1(t,i,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(aXe)}},OKe=e=>new Ka,Rm=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&Mqe(e,t),B8=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){this.right===null&&zl(),this.right.content.constructor===Ea?this.right.deleted||Xv(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},roe=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===Ea?t.right.deleted||Xv(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&Ac(e,Hr(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},k1=(e,t,n,r)=>{const i=new Map,o=r?w1(t,n):null;return o?roe(e,new B8(o.p.left,o.p,o.index,i),n-o.index):roe(e,new B8(null,t._start,0,i),n)},ioe=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Ea&&Rm(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=e.doc,o=i.clientID;r.forEach((s,a)=>{const l=n.left,c=n.right,u=new Bo(Hr(o,_s(i.store,o)),l,l&&l.lastId,c,c&&c.id,t,null,new Ea(a,s));u.integrate(e,0),n.right=u,n.forward()})},Xv=(e,t)=>{const{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},ooe=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===Ea&&Rm(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},soe=(e,t,n,r)=>{const i=e.doc,o=i.clientID,s=new Map;for(const a in r){const l=r[a],c=n.currentAttributes.get(a)??null;if(!Rm(c,l)){s.set(a,c);const{left:u,right:d}=n;n.right=new Bo(Hr(o,_s(i.store,o)),u,u&&u.lastId,d,d&&d.id,t,null,new Ea(a,l)),n.right.integrate(e,0),n.forward()}}return s},H8=(e,t,n,r,i)=>{n.currentAttributes.forEach((f,h)=>{i[h]===void 0&&(i[h]=null)});const o=e.doc,s=o.clientID;ooe(n,i);const a=soe(e,t,n,i),l=r.constructor===String?new Lm(r):r instanceof ka?new np(r):new VT(r);let{left:c,right:u,index:d}=n;t._searchMarker&&HT(t._searchMarker,n.index,l.getLength()),u=new Bo(Hr(s,_s(o.store,s)),c,c&&c.lastId,u,u&&u.id,t,null,l),u.integrate(e,0),n.right=u,n.index=d,n.forward(),ioe(e,t,n,a)},aoe=(e,t,n,r,i)=>{const o=e.doc,s=o.clientID;ooe(n,i);const a=soe(e,t,n,i);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Ea));){if(!n.right.deleted)switch(n.right.content.constructor){case Ea:{const{key:l,value:c}=n.right.content,u=i[l];if(u!==void 0){if(Rm(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}n.right.delete(e)}else n.currentAttributes.set(l,c);break}default:r<n.right.length&&Ac(e,Hr(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
4
4
|
`;n.right=new Bo(Hr(s,_s(o.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Lm(l)),n.right.integrate(e,0),n.forward()}ioe(e,t,n,a)},loe=(e,t,n,r,i)=>{let o=t;const s=Ul();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===Ea){const c=o.content;s.set(c.key,c)}o=o.right}let a=0,l=!1;for(;t!==o;){if(n===t&&(l=!0),!t.deleted){const c=t.content;if(c.constructor===Ea){const{key:u,value:d}=c,f=r.get(u)??null;(s.get(u)!==c||f===d)&&(t.delete(e),a++,!l&&(i.get(u)??null)===d&&f!==d&&(f===null?i.delete(u):i.set(u,f))),!l&&!t.deleted&&Xv(i,c)}}t=t.right}return a},FKe=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Ea){const r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},BKe=e=>{let t=0;return vo(e.doc,n=>{let r=e._start,i=e._start,o=Ul();const s=t8(o);for(;i;)i.deleted===!1&&(i.content.constructor===Ea?Xv(s,i.content):(t+=loe(n,r,i,o,s),o=t8(s),r=i)),i=i.right}),t},HKe=e=>{const t=new Set,n=e.doc;for(const[r,i]of e.afterState.entries()){const o=e.beforeState.get(r)||0;i!==o&&Oie(e,n.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===Ea&&s.constructor!==Fu&&t.add(s.parent)})}vo(n,r=>{_m(e,e.deleteSet,i=>{if(i instanceof Fu||!i.parent._hasFormatting||t.has(i.parent))return;const o=i.parent;i.content.constructor===Ea?t.add(o):FKe(r,i)});for(const i of t)BKe(i)})},coe=(e,t,n)=>{const r=n,i=t8(t.currentAttributes),o=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case np:case VT:case Lm:n<t.right.length&&Ac(e,Hr(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}o&&loe(e,o,t.right,i,t.currentAttributes);const s=(t.left||t.right).parent;return s._searchMarker&&HT(s._searchMarker,t.index,-r+n),t},zKe=class extends v1{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){return this._changes===null&&(this._changes={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set}),this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];vo(e,n=>{const r=new Map,i=new Map;let o=this.target._start,s=null;const a={};let l="",c=0,u=0;const d=()=>{if(s!==null){let f=null;switch(s){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof l=="object"||l.length>0)&&(f={insert:l},r.size>0&&(f.attributes={},r.forEach((h,p)=>{h!==null&&(f.attributes[p]=h)}))),l="";break;case"retain":c>0&&(f={retain:c},Nqe(a)||(f.attributes=Pqe({},a))),c=0;break}f&&t.push(f),s=null}};for(;o!==null;){switch(o.content.constructor){case np:case VT:this.adds(o)?this.deletes(o)||(d(),s="insert",l=o.content.getContent()[0],d()):this.deletes(o)?(s!=="delete"&&(d(),s="delete"),u+=1):o.deleted||(s!=="retain"&&(d(),s="retain"),c+=1);break;case Lm:this.adds(o)?this.deletes(o)||(s!=="insert"&&(d(),s="insert"),l+=o.content.str):this.deletes(o)?(s!=="delete"&&(d(),s="delete"),u+=o.length):o.deleted||(s!=="retain"&&(d(),s="retain"),c+=o.length);break;case Ea:{const{key:f,value:h}=o.content;if(this.adds(o))this.deletes(o)||(Rm(r.get(f)??null,h)?h!==null&&o.delete(n):(s==="retain"&&d(),Rm(h,i.get(f)??null)?delete a[f]:a[f]=h));else if(this.deletes(o)){i.set(f,h);const p=r.get(f)??null;Rm(p,h)||(s==="retain"&&d(),a[f]=p)}else if(!o.deleted){i.set(f,h);const p=a[f];p!==void 0&&(Rm(p,h)?p!==null&&o.delete(n):(s==="retain"&&d(),h===null?delete a[f]:a[f]=h))}o.deleted||(s==="insert"&&d(),Xv(r,o.content));break}}o=o.right}for(d();t.length>0;){const f=t[t.length-1];if(f.retain!==void 0&&f.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},UT=class yee extends ka{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??gl(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new yee}clone(){const t=new yee;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const r=new zKe(this,t,n);A1(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??gl();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Lm&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?vo(this.doc,r=>{const i=new B8(null,this._start,0,new Map);for(let o=0;o<t.length;o++){const s=t[o];if(s.insert!==void 0){const a=!n&&typeof s.insert=="string"&&o===t.length-1&&i.right===null&&s.insert.slice(-1)===`
|
|
5
|
-
`?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&H8(r,this,i,a,s.attributes||{})}else s.retain!==void 0?aoe(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&coe(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??gl();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const d={};let f=!1;o.forEach((p,m)=>{f=!0,d[m]=p});const h={insert:a};f&&(h.attributes=d),i.push(h),a=""}}const u=()=>{for(;l!==null;){if(ny(l,t)||n!==void 0&&ny(l,n))switch(l.content.constructor){case Lm:{const d=o.get("ychange");t!==void 0&&!ny(l,t)?(d===void 0||d.user!==l.id.client||d.type!=="removed")&&(c(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!ny(l,n)?(d===void 0||d.user!==l.id.client||d.type!=="added")&&(c(),o.set("ychange",r?r("added",l.id):{type:"added"})):d!==void 0&&(c(),o.delete("ychange")),a+=l.content.str;break}case np:case VT:{c();const d={insert:l.content.getContent()[0]};if(o.size>0){const f={};d.attributes=f,o.forEach((h,p)=>{f[p]=h})}i.push(d);break}case Ea:ny(l,t)&&(c(),Xv(o,l.content));break}l=l.right}c()};return t||n?vo(s,d=>{t&&P8(d,t),n&&P8(d,n),u()},"cleanup"):u(),i}insert(t,n,r){if(n.length<=0)return;const i=this.doc;i!==null?vo(i,o=>{const s=k1(o,this,t,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),H8(o,this,s,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){const i=this.doc;i!==null?vo(i,o=>{const s=k1(o,this,t,!r);H8(o,this,s,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;const r=this.doc;r!==null?vo(r,i=>{coe(i,k1(i,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;const i=this.doc;i!==null?vo(i,o=>{const s=k1(o,this,t,!1);s.right!==null&&aoe(o,this,s,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?vo(this.doc,n=>{S1(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?vo(this.doc,r=>{O8(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return F8(this,t)}getAttributes(){return toe(this)}_write(t){t.writeTypeRef(lXe)}},UKe=e=>new UT,z8=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??gl()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Ou||t.constructor===Jv)&&t._start!==null)e=t._start;else for(;e!==null;){const n=e.next;if(n!==null){e=n;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Jv=class bee extends ka{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new bee}clone(){const t=new bee;return t.insert(0,this.toArray().map(n=>n instanceof ka?n.clone():n)),t}get length(){return this.doc??gl(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new z8(this,t)}querySelector(t){t=t.toUpperCase();const n=new z8(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return n.done?null:n.value}querySelectorAll(t){return t=t.toUpperCase(),Zh(new z8(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){A1(this,t,new GKe(this,n,t))}toString(){return Jie(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){const i=t.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),zT(this,o=>{i.insertBefore(o.toDOM(t,n,r),null)}),i}insert(t,n){this.doc!==null?vo(this.doc,r=>{$ie(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)vo(this.doc,r=>{const i=t&&t instanceof ka?t._item:t;x1(r,this,i,n)});else{const r=this._prelimContent,i=t===null?0:r.findIndex(o=>o===t)+1;if(i===0&&t!==null)throw Mf("Reference item not found");r.splice(i,0,...n)}}delete(t,n=1){this.doc!==null?vo(this.doc,r=>{eoe(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Kie(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Zie(this,t)}slice(t=0,n=this.length){return Yie(this,t,n)}forEach(t){zT(this,t)}_write(t){t.writeTypeRef(uXe)}},VKe=e=>new Jv,Ou=class vee extends Jv{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new vee(this.nodeName)}clone(){const t=new vee(this.nodeName),n=this.getAttributes();return Rqe(n,(r,i)=>{t.setAttribute(i,r)}),t.insert(0,this.toArray().map(r=>r instanceof ka?r.clone():r)),t}toString(){const t=this.getAttributes(),n=[],r=[];for(const s in t)r.push(s);r.sort();const i=r.length;for(let s=0;s<i;s++){const a=r[s];n.push(a+'="'+t[a]+'"')}const o=this.nodeName.toLocaleLowerCase();return`<${o}${n.length>0?" "+n.join(" "):""}>${super.toString()}</${o}>`}removeAttribute(t){this.doc!==null?vo(this.doc,n=>{S1(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?vo(this.doc,r=>{O8(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return F8(this,t)}hasAttribute(t){return noe(this,t)}getAttributes(t){return t?LKe(this,t):toe(this)}toDOM(t=document,n={},r){const i=t.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const a=o[s];typeof a=="string"&&i.setAttribute(s,a)}return zT(this,s=>{i.appendChild(s.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(cXe),t.writeKey(this.nodeName)}},WKe=e=>new Ou(e.readKey()),GKe=class extends v1{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}},jKe=class wee extends Ka{constructor(t){super(),this.hookName=t}_copy(){return new wee(this.hookName)}clone(){const t=new wee(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){const i=n[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(dXe),t.writeKey(this.hookName)}},qKe=e=>new jKe(e.readKey()),Of=class Aee extends UT{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new Aee}clone(){const t=new Aee;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){const i=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(t=>{const n=[];for(const i in t.attributes){const o=[];for(const s in t.attributes[i])o.push({key:s,value:t.attributes[i][s]});o.sort((s,a)=>s.key<a.key?-1:1),n.push({nodeName:i,attrs:o})}n.sort((i,o)=>i.nodeName<o.nodeName?-1:1);let r="";for(let i=0;i<n.length;i++){const o=n[i];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){const a=o.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=t.insert;for(let i=n.length-1;i>=0;i--)r+=`</${n[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(fXe)}},YKe=e=>new Of,U8=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Mu()}mergeWith(e){return!1}write(e,t,n){throw Mu()}integrate(e,t){throw Mu()}},KKe=0,Fu=class extends U8{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Mie(e.doc.store,this)}write(e,t){e.writeInfo(KKe),e.writeLen(this.length-t)}getMissing(e,t){return null}},V8=class HVe{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new HVe(this.content)}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},XKe=e=>new V8(e.readBuf()),uoe=class xee{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new xee(this.len)}splice(t){const n=new xee(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){NT(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},JKe=e=>new uoe(e.readLen()),doe=(e,t)=>new tp({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),W8=class zVe{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new zVe(doe(this.doc.guid,this.opts))}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},ZKe=e=>new W8(doe(e.readString(),e.readAny())),VT=class UVe{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new UVe(this.embed)}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},QKe=e=>new VT(e.readJSON()),Ea=class VVe{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new VVe(this.key,this.value)}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},$Ke=e=>new Ea(e.readKey(),e.readJSON()),eXe=class See{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new See(this.arr)}splice(t){const n=new See(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const r=this.arr.length;t.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];t.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}},tXe=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const i=e.readString();i==="undefined"?n.push(void 0):n.push(JSON.parse(i))}return new eXe(n)},nXe=s1("node_env")==="development",E1=class Tee{constructor(t){this.arr=t,nXe&&Dre(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Tee(this.arr)}splice(t){const n=new Tee(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const r=this.arr.length;t.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];t.writeAny(o)}}getRef(){return 8}},rXe=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new E1(n)},Lm=class Iee{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Iee(this.str)}splice(t){const n=new Iee(this.str.slice(t));this.str=this.str.slice(0,t);const r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},iXe=e=>new Lm(e.readString()),oXe=[MKe,OKe,UKe,WKe,VKe,qKe,YKe],sXe=0,aXe=1,lXe=2,cXe=3,uXe=4,dXe=5,fXe=6,np=class WVe{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new WVe(this.type._copy())}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},hXe=e=>new np(oXe[e.readTypeRef()](e)),G8=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Hr(n.client,n.clock+r)),i=Kv(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Bo);return{item:i,diff:r}},j8=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},C1=(e,t,n)=>{const{client:r,clock:i}=t.id,o=new Bo(Hr(r,i+n),t,Hr(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&o.markDeleted(),t.keep&&(o.keep=!0),t.redone!==null&&(o.redone=Hr(t.redone.client,t.redone.clock+n)),t.right=o,o.right!==null&&(o.right.left=o),e._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),t.length=n,o},foe=(e,t)=>qB(e,n=>Wv(n.deletions,t)),hoe=(e,t,n,r,i,o)=>{const s=e.doc,a=s.store,l=s.clientID,c=t.redone;if(c!==null)return Ac(e,c);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||hoe(e,u,n,r,i,o)===null))return null;for(;u.redone!==null;)u=Ac(e,u.redone)}const h=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let g=d;for(;g!==null&&g.parent._item!==u;)g=g.redone===null?null:Ac(e,g.redone);if(g!==null&&g.parent._item===u){d=g;break}d=d.left}for(;f!==null;){let g=f;for(;g!==null&&g.parent._item!==u;)g=g.redone===null?null:Ac(e,g.redone);if(g!==null&&g.parent._item===u){f=g;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||Wv(r,d.right.id)||foe(o.undoStack,d.right.id)||foe(o.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ac(e,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(t.parentSub)||null;const p=Hr(l,_s(a,l)),m=new Bo(p,d,d&&d.lastId,f,f&&f.id,h,t.parentSub,t.content.copy());return t.redone=p,j8(m,!0),m.integrate(e,0),m},Bo=class kee extends U8{constructor(t,n,r,i,o,s,a,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=o,this.parent=s,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=_s(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=_s(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===qv&&this.id.client!==this.parent.client&&this.parent.clock>=_s(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Die(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Ac(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Fu||this.right&&this.right.constructor===Fu)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===kee?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===kee&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===qv){const r=Kv(n,this.parent);r.constructor===Fu?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=Die(t,t.doc.store,Hr(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,s=new Set;for(;i!==null&&i!==this.right;){if(s.add(i),o.add(i),Yv(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(Yv(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(Kv(t.doc.store,i.origin)))o.has(Kv(t.doc.store,i.origin))||(r=i,o.clear());else break;i=i.right}this.left=r}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Mie(t.doc.store,this),this.content.integrate(t,this),Bie(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new Fu(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:Hr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Yv(t.origin,this.lastId)&&this.right===t&&Yv(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),NT(t.deleteSet,this.id.client,this.id.clock,this.length),Bie(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw zl();this.content.gc(t),n?mKe(t,this,new Fu(this.id,this.length)):this.content=new uoe(this.length)}write(t,n){const r=n>0?Hr(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&31|(r===null?0:128)|(i===null?0:64)|(o===null?0:32);if(t.writeInfo(s),r!==null&&t.writeLeftID(r),i!==null&&t.writeRightID(i),r===null&&i===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=DT(a);t.writeParentInfo(!0),t.writeString(c)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else a.constructor===String?(t.writeParentInfo(!0),t.writeString(a)):a.constructor===qv?(t.writeParentInfo(!1),t.writeLeftID(a)):zl();o!==null&&t.writeString(o)}this.content.write(t,n)}},poe=(e,t)=>pXe[t&31](e),pXe=[()=>{zl()},JKe,tXe,XKe,iXe,QKe,$Ke,hXe,rXe,ZKe,()=>{zl()}],mXe=10,Bu=class extends U8{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){zl()}write(e,t){e.writeInfo(mXe),En(e.restEncoder,this.length-t)}getMissing(e,t){return null}},moe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},goe="__ $YJS$ __";moe[goe]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),moe[goe]=!0;const gXe=3e4;var yoe=class extends eYe{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Nd();this.getLocalState()!==null&&3e4/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((r,i)=>{i!==this.clientID&&3e4<=t-r.lastUpdated&&this.states.has(i)&&n.push(i)}),n.length>0&&Zv(this,n,"timeout")},Nu(gXe/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Nd()});const o=[],s=[],a=[],l=[];e===null?l.push(t):i==null?e!=null&&o.push(t):(s.push(t),Fv(i,e)||a.push(t)),(o.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:o,updated:a,removed:l},"local"]),this.emit("update",[{added:o,updated:s,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}};const Zv=(e,t,n)=>{const r=[];for(let i=0;i<t.length;i++){const o=t[i];if(e.states.has(o)){if(e.states.delete(o),o===e.clientID){const s=e.meta.get(o);e.meta.set(o,{clock:s.clock+1,lastUpdated:Nd()})}r.push(o)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},Nm=(e,t,n=e.states)=>{const r=t.length,i=ia();En(i,r);for(let o=0;o<r;o++){const s=t[o],a=n.get(s)||null,l=e.meta.get(s).clock;En(i,s),En(i,l),Ta(i,JSON.stringify(a))}return Fo(i)},boe=(e,t,n)=>{const r=Qh(t),i=Nd(),o=[],s=[],a=[],l=[],c=Cr(r);for(let u=0;u<c;u++){const d=Cr(r);let f=Cr(r);const h=JSON.parse(Zc(r)),p=e.meta.get(d),m=e.states.get(d),g=p===void 0?0:p.clock;(g<f||g===f&&h===null&&e.states.has(d))&&(h===null?d===e.clientID&&e.getLocalState()!=null?f++:e.states.delete(d):e.states.set(d,h),e.meta.set(d,{clock:f,lastUpdated:i}),p===void 0&&h!==null?o.push(d):p!==void 0&&h===null?l.push(d):h!==null&&(Fv(h,m)||a.push(d),s.push(d)))}(o.length>0||a.length>0||l.length>0)&&e.emit("change",[{added:o,updated:a,removed:l},n]),(o.length>0||s.length>0||l.length>0)&&e.emit("update",[{added:o,updated:s,removed:l},n])};var voe=class{callbacks={};on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(r=>r.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(r=>r!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};function yXe(e){return e||(e={}),{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function q8(e){return new Promise(t=>setTimeout(t,e))}function bXe(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=Math.pow(t.factor,e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){const r=Math.ceil(t.minDelay),i=Math.floor(n);n=Math.floor(Math.random()*(i-r+1))+r}return Math.round(n)}async function vXe(e,t){const n=yXe(t);for(const a of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const l=n[a];if(!Number.isInteger(l)||l<0)throw new Error(`Value for ${a} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw new Error("Value for factor must be a number greater than or equal to 0");if(n.delay<n.minDelay)throw new Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);const r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||bXe;async function o(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){const l=new Error("Attempt aborted");throw l.code="ATTEMPT_ABORTED",l}const a=async l=>{if(n.handleError&&await n.handleError(l,r,n),r.aborted||r.attemptsRemaining===0)throw l;r.attemptNum++;const c=i(r,n);return c&&await q8(c),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((l,c)=>{const u=setTimeout(()=>{if(n.handleTimeout)try{l(n.handleTimeout(r,n))}catch(d){c(d)}else{const d=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);d.code="ATTEMPT_TIMEOUT",c(d)}},n.timeout);e(r,n).then(d=>{clearTimeout(u),l(d)}).catch(d=>{clearTimeout(u),a(d).then(l).catch(c)})}):e(r,n).catch(a)}const s=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(s&&await q8(s),r.attemptNum<1&&n.initialJitter){const a=i(r,n);a&&await q8(a)}return o()}const woe=e=>Lqe(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");let yl=(function(e){return e[e.Sync=0]="Sync",e[e.Awareness=1]="Awareness",e[e.Auth=2]="Auth",e[e.QueryAwareness=3]="QueryAwareness",e[e.Stateless=5]="Stateless",e[e.CLOSE=7]="CLOSE",e[e.SyncStatus=8]="SyncStatus",e})({}),bl=(function(e){return e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e})({});var _1=class{data;encoder;decoder;constructor(e){this.data=e,this.encoder=ia(),this.decoder=Qh(new Uint8Array(this.data))}peekVarString(){return gqe(this.decoder)}readVarUint(){return Cr(this.decoder)}readVarString(){return Zc(this.decoder)}readVarUint8Array(){return Ya(this.decoder)}writeVarUint(e){return En(this.encoder,e)}writeVarString(e){return Ta(this.encoder,e)}writeVarUint8Array(e){return ns(this.encoder,e)}length(){return Q_(this.encoder)}},Aoe=class extends voe{messageQueue=[];configuration={url:"",document:void 0,WebSocketPolyfill:void 0,parameters:{},connect:!0,broadcast:!0,forceSyncInterval:!1,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,quiet:!1,providerMap:new Map};webSocket=null;webSocketHandlers={};shouldConnect=!0;status=bl.Disconnected;lastMessageReceived=0;identifier=0;intervals={forceSync:null,connectionChecker:null};connectionAttempt=null;constructor(e){super(),this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("status",this.onStatus.bind(this)),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),typeof e.connect<"u"&&(this.shouldConnect=e.connect),this.shouldConnect&&this.connect()}receivedOnOpenPayload=void 0;receivedOnStatusPayload=void 0;async onOpen(e){this.receivedOnOpenPayload=e}async onStatus(e){this.receivedOnStatusPayload=e}attach(e){let t;return this.configuration.providerMap.set(e.configuration.name,e),this.status===bl.Disconnected&&this.shouldConnect&&(t=this.connect()),this.receivedOnOpenPayload&&e.onOpen(this.receivedOnOpenPayload),this.receivedOnStatusPayload&&e.onStatus(this.receivedOnStatusPayload),t}detach(e){this.configuration.providerMap.delete(e.configuration.name)}setConfiguration(e={}){this.configuration={...this.configuration,...e}}cancelWebsocketRetry;async connect(){if(this.status===bl.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.receivedOnStatusPayload=void 0,this.shouldConnect=!0;const e=()=>{let r=!1;return{retryPromise:vXe(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,beforeAttempt:i=>{(!this.shouldConnect||r)&&i.abort()}}).catch(i=>{if(i&&i.code!=="ATTEMPT_ABORTED")throw i}),cancelFunc:()=>{r=!0}}},{retryPromise:t,cancelFunc:n}=e();return this.cancelWebsocketRetry=n,t}attachWebSocketListeners(e,t){const{identifier:n}=e,r=l=>this.emit("message",l),i=l=>this.emit("close",{event:l}),o=l=>this.emit("open",l),s=l=>{t(l)};this.webSocketHandlers[n]={message:r,close:i,open:o,error:s};const a=this.webSocketHandlers[e.identifier];Object.keys(a).forEach(l=>{e.addEventListener(l,a[l])})}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType="arraybuffer",n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=bl.Connecting,this.emit("status",{status:bl.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Nd();const t=new _1(e.data).peekVarString();this.configuration.providerMap.get(t)?.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=bl.Connected,this.emit("status",{status:bl.Connected}),this.emit("connect"),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}closeTries=0;checkConnection(){this.status===bl.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Nd()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){for(;this.configuration.url[this.configuration.url.length-1]==="/";)return this.configuration.url.slice(0,this.configuration.url.length-1);return this.configuration.url}get url(){const e=woe(this.configuration.parameters);return`${this.serverUrl}${e.length===0?"":`?${e}`}`}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch{}}send(e){this.webSocket?.readyState===Sqe.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){if(this.closeTries=0,this.cleanupWebSocket(),this.status===bl.Connected&&(this.status=bl.Disconnected,this.emit("status",{status:bl.Disconnected}),this.emit("disconnect",{event:e})),e.code===Cre.code&&(e.reason===Cre.reason?console.warn("[HocuspocusProvider] An authentication token is required, but you didn’t send one. Try adding a `token` to your HocuspocusProvider configuration. Won’t try again."):console.warn(`[HocuspocusProvider] Connection closed with status Unauthorized: ${e.reason}`),this.shouldConnect=!1),e.code===xqe.code&&!this.configuration.quiet){console.warn("[HocuspocusProvider] The provided authentication token isn’t allowed to connect to this server. Will try again.");return}e.code===Aqe.code&&(console.warn(`[HocuspocusProvider] Connection closed with status MessageTooBig: ${e.reason}`),this.shouldConnect=!1),this.connectionAttempt?this.rejectConnectionAttempt():this.shouldConnect&&this.connect(),!this.shouldConnect&&this.status!==bl.Disconnected&&(this.status=bl.Disconnected,this.emit("status",{status:bl.Disconnected}),this.emit("disconnect",{event:e}))}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}};const dJn=0,fJn=1,hJn=2,P1=(e,t)=>{En(e,0);const n=lKe(t);ns(e,n)},Y8=(e,t,n)=>{En(e,1),ns(e,I8(t,n))},wXe=(e,t,n)=>Y8(t,n,Ya(e)),xoe=(e,t,n,r)=>{try{Iie(t,Ya(e),n)}catch(i){r?.(i),console.error("Caught error while handling a Yjs update",i)}},Soe=(e,t)=>{En(e,2),ns(e,t)},AXe=xoe,Toe=(e,t,n,r,i)=>{const o=Cr(e);switch(o){case 0:wXe(e,t,n);break;case 1:xoe(e,n,r,i);break;case 2:AXe(e,n,r,i);break;default:throw new Error("Unknown message type")}return o};var Ff=class{encoder;type;constructor(){this.encoder=ia()}get(e){return e.encoder}toUint8Array(){return Fo(this.encoder)}},Ioe=class{message;broadcasted=!1;constructor(e){this.message=e}setBroadcasted(e){return this.broadcasted=e,this}apply(e,t){const{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case yl.Sync:this.applySyncMessage(e,t);break;case yl.Awareness:this.applyAwarenessMessage(e);break;case yl.Auth:this.applyAuthMessage(e);break;case yl.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case yl.Stateless:e.receiveStateless(Zc(n.decoder));break;case yl.SyncStatus:this.applySyncStatusMessage(e,n1(n.decoder)===1);break;default:throw new Error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&(this.broadcasted?e.broadcast(Ff,{encoder:n.encoder}):e.send(Ff,{encoder:n.encoder}))}applySyncMessage(e,t){const{message:n}=this;n.writeVarUint(yl.Sync);const r=Toe(n.decoder,n.encoder,e.document,e);t&&r===1&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;boe(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;wqe(t.decoder,e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(yl.Awareness),t.writeVarUint8Array(Nm(e.awareness,Array.from(e.awareness.getStates().keys())))}},koe=class{encoder;message;constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Fo(this.encoder)}send(e){e?.send(this.create())}broadcast(e){$0(e,this.create())}},xXe=class extends Ff{type=yl.Auth;description="Authentication";get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return Ta(this.encoder,e.documentName),En(this.encoder,this.type),vqe(this.encoder,e.token),this.encoder}},R1=class extends Ff{type=yl.Awareness;description="Awareness states update";get(e){if(typeof e.awareness>"u")throw new Error("The awareness message requires awareness as an argument");if(typeof e.clients>"u")throw new Error("The awareness message requires clients as an argument");Ta(this.encoder,e.documentName),En(this.encoder,this.type);let t;return e.states===void 0?t=Nm(e.awareness,e.clients):t=Nm(e.awareness,e.clients,e.states),ns(this.encoder,t),this.encoder}},SXe=class extends Ff{type=yl.CLOSE;description="Ask the server to close the connection";get(e){return Ta(this.encoder,e.documentName),En(this.encoder,this.type),this.encoder}},TXe=class extends Ff{type=yl.QueryAwareness;description="Queries awareness states";get(e){return Ta(this.encoder,e.documentName),En(this.encoder,this.type),this.encoder}},IXe=class extends Ff{type=yl.Stateless;description="A stateless message";get(e){return Ta(this.encoder,e.documentName),En(this.encoder,this.type),Ta(this.encoder,e.payload??""),this.encoder}},K8=class extends Ff{type=yl.Sync;description="First sync step";get(e){if(typeof e.document>"u")throw new Error("The sync step one message requires document as an argument");return Ta(this.encoder,e.documentName),En(this.encoder,this.type),P1(this.encoder,e.document),this.encoder}},kXe=class extends Ff{type=yl.Sync;description="Second sync step";get(e){if(typeof e.document>"u")throw new Error("The sync step two message requires document as an argument");return Ta(this.encoder,e.documentName),En(this.encoder,this.type),Y8(this.encoder,e.document),this.encoder}},EXe=class extends Ff{type=yl.Sync;description="A document update";get(e){return Ta(this.encoder,e.documentName),En(this.encoder,this.type),Soe(this.encoder,e.update),this.encoder}},CXe=class extends Error{code=1001},_Xe=class extends voe{configuration={name:"",document:void 0,awareness:void 0,token:null,parameters:{},broadcast:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onSynced:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,quiet:!1,connect:!0,preserveConnection:!0};subscribedToBroadcastChannel=!1;isSynced=!1;unsyncedChanges=0;status=bl.Disconnected;isAuthenticated=!1;authorizedScope=void 0;mux=Vre();intervals={forceSync:null};isConnected=!0;constructor(e){super(),this.setConfiguration(e),this.configuration.document=e.document?e.document:new tp,this.configuration.awareness=e.awareness!==void 0?e.awareness:new yoe(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("open",this.forwardOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("status",this.boundOnStatus),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.awareness?.on("update",()=>{this.emit("awarenessUpdate",{states:_re(this.awareness.getStates())})}),this.awareness?.on("change",()=>{this.emit("awarenessChange",{states:_re(this.awareness.getStates())})}),this.document.on("update",this.boundDocumentUpdateHandler),this.awareness?.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval=="number"&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.configuration.websocketProvider.attach(this)}boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this);boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this);boundBroadcastChannelSubscriber=this.broadcastChannelSubscriber.bind(this);boundPageHide=this.pageHide.bind(this);boundOnOpen=this.onOpen.bind(this);boundOnClose=this.onClose.bind(this);boundOnStatus=this.onStatus.bind(this);forwardConnect=e=>this.emit("connect",e);forwardOpen=e=>this.emit("open",e);forwardClose=e=>this.emit("close",e);forwardDisconnect=e=>this.emit("disconnect",e);forwardDestroy=e=>this.emit("destroy",e);onStatus({status:e}){this.status=e,this.configuration.onStatus({status:e}),this.emit("status",{status:e})}setConfiguration(e={}){if(!e.websocketProvider&&e.url){const t=e;this.configuration.websocketProvider=new Aoe({url:t.url,connect:t.connect,parameters:t.parameters})}this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",this.unsyncedChanges)}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",this.unsyncedChanges)}decrementUnsyncedChanges(){this.unsyncedChanges-=1,this.unsyncedChanges===0&&(this.synced=!0),this.emit("unsyncedChanges",this.unsyncedChanges)}forceSync(){this.resetUnsyncedChanges(),this.send(K8,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Zv(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(IXe,{documentName:this.configuration.name,payload:e})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(EXe,{update:e,documentName:this.configuration.name},!0))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){const i=e.concat(t).concat(n);this.send(R1,{awareness:this.awareness,clients:i,documentName:this.configuration.name},!0)}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,this.emit("synced",{state:e}),this.emit("sync",{state:e}))}receiveStateless(e){this.emit("stateless",{payload:e})}get isAuthenticationRequired(){return!!this.configuration.token&&!this.isAuthenticated}async connect(){return this.configuration.broadcast&&this.subscribeToBroadcastChannel(),this.configuration.websocketProvider.shouldConnect=!0,this.configuration.websocketProvider.attach(this)}disconnect(){this.disconnectBroadcastChannel(),this.configuration.websocketProvider.detach(this),this.isConnected=!1,this.configuration.preserveConnection||this.configuration.websocketProvider.disconnect()}async onOpen(e){this.isAuthenticated=!1,this.isConnected=!0,this.emit("open",{event:e});let t;try{t=await this.getToken()}catch(n){this.permissionDeniedHandler(`Failed to get token: ${n}`);return}this.isAuthenticationRequired&&this.send(xXe,{token:t,documentName:this.configuration.name}),this.startSync()}async getToken(){return typeof this.configuration.token=="function"?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(K8,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(R1,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t,n=!1){if(!this.isConnected)return;n&&this.mux(()=>{this.broadcast(e,t)});const r=new koe(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new _1(e.data),n=t.readVarString();t.writeVarString(n),this.emit("message",{event:e,message:new _1(e.data)}),new Ioe(t).apply(this,!0)}onClose(e){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Zv(this.awareness,Array.from(this.awareness.getStates().keys()).filter(t=>t!==this.document.clientID),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(Zv(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("open",this.forwardOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("status",this.boundOnStatus),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.send(SXe,{documentName:this.configuration.name}),this.disconnect(),!(typeof window>"u"||!("removeEventListener"in window))&&window.removeEventListener("pagehide",this.boundPageHide)}permissionDeniedHandler(e){this.emit("authenticationFailed",{reason:e}),this.isAuthenticated=!1,this.disconnect(),this.status=bl.Disconnected}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit("authenticated")}get broadcastChannel(){return`${this.configuration.name}`}broadcastChannelSubscriber(e){this.mux(()=>{const t=new _1(e),n=t.readVarString();t.writeVarString(n),new Ioe(t).setBroadcasted(!0).apply(this,!1)})}subscribeToBroadcastChannel(){this.subscribedToBroadcastChannel||(zre(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!0),this.mux(()=>{this.broadcast(K8,{document:this.document,documentName:this.configuration.name}),this.broadcast(kXe,{document:this.document,documentName:this.configuration.name}),this.broadcast(TXe,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.broadcast(R1,{awareness:this.awareness,clients:[this.document.clientID],document:this.document,documentName:this.configuration.name})})}disconnectBroadcastChannel(){this.awareness&&this.send(R1,{awareness:this.awareness,clients:[this.document.clientID],states:new Map,documentName:this.configuration.name},!0),this.subscribedToBroadcastChannel&&(Ure(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!1)}broadcast(e,t){this.configuration.broadcast&&this.subscribedToBroadcastChannel&&new koe(e,t).broadcast(this.broadcastChannel)}setAwarenessField(e,t){if(!this.awareness)throw new CXe(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}};const xc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",WT="application/pdf",L1="text/html",PXe={docx:xc,pdf:WT,html:L1},X8=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Ps={RESOLVED:"resolved",NEW:"new",ADD:"add",UPDATE:"update",DELETED:"deleted",PENDING:"pending",SELECTED:"selected",COMMENTS_LIST:"comments-list",CHANGE_ACCEPTED:"change-accepted",CHANGE_REJECTED:"change-rejected"};var RXe=(e,t)=>rp(e,t,J8),Eoe=(e,t)=>rp(e,t,WXe),LXe=(e,t)=>{const n=Eoe(e,t);return n?n.toLowerCase():null},Coe=(e,t)=>rp(e,t,GXe),NXe=(e,t)=>{const n=Coe(e,t);return n?n.toLowerCase():null},MXe=(e,t)=>rp(e,t,zXe),DXe=(e,t,n)=>VXe(e,t,n),OXe=(e,t)=>rp(e,t,jXe),FXe=(e,t)=>rp(e,t,UXe),BXe={decimal:RXe,decimalZero:FXe,lowerRoman:LXe,upperRoman:Eoe,lowerLetter:NXe,upperLetter:Coe,ordinal:MXe,custom:DXe,japaneseCounting:OXe};const _oe=({listLevel:e,lvlText:t,listNumberingType:n,customFormat:r})=>{if(typeof t!="string")return null;const i=BXe[n];return i?i(e,t,r):null};var HXe=(e,t)=>typeof t!="string"?"":e.reduce((n,r,i)=>Number(r)>9?n.replace(/^0/,"").replace(`%${i+1}`,r):n.replace(`%${i+1}`,r),t),rp=(e,t,n)=>HXe(e.map((r,i)=>n(r,i)),t),zXe=e=>{const t=["th","st","nd","rd"],n=e%100;return`${e}${t[(n-20)%10]||t[n]||t[0]}`},UXe=(e,t)=>e>=10||t===0?String(e):`0${e}`,VXe=(e,t,n)=>{if(typeof n!="string"||n.match(/(?:[0]+\d,\s){3}\.{3}/)==null)return rp(e,t,J8);const r=n.match(/(\d+)/);if(!r)throw new Error("Invalid format string: no numeric pattern found");const i=r[1].length;return rp(e,t,o=>String(o).padStart(i,"0"))},J8=e=>String(e),WXe=e=>{const t=[{value:1e3,numeral:"M"},{value:900,numeral:"CM"},{value:500,numeral:"D"},{value:400,numeral:"CD"},{value:100,numeral:"C"},{value:90,numeral:"XC"},{value:50,numeral:"L"},{value:40,numeral:"XL"},{value:10,numeral:"X"},{value:9,numeral:"IX"},{value:5,numeral:"V"},{value:4,numeral:"IV"},{value:1,numeral:"I"}];let n="",r=e;for(const{value:i,numeral:o}of t)for(;r>=i;)n+=o,r-=i;return n},GXe=e=>{if(e<1)return"";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(e-1)%26],n=Math.floor((e-1)/26)+1;return t.repeat(n)};const jXe=e=>{const t=["","一","二","三","四","五","六","七","八","九"],n=["","十","百","千"];if(e===0)return"零";if(e<10)return t[e];let r="",i=e,o=0;for(;i>0;){const s=i%10;if(s!==0?r=(s===1&&o>0?"":t[s])+(o>0?n[o]:"")+r:r&&i>0&&!r.startsWith("零")&&i%100!==0&&(r="零"+r),i=Math.floor(i/10),o+=1,o>3)break}return e>=10&&e<20&&(r=r.replace(/^一十/,"十")),r};var qXe=new Set(["","","○","o","■","□"]);const Z8=e=>!e||!qXe.has(e)?e:e===""?"•":e==="○"||e==="o"?"◦":e==="■"||e===""?"▪":e==="□"?"◯":e;var Poe=e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim().length>0){const t=Number(e);if(Number.isFinite(t))return t}};const Q8=e=>{if(!Array.isArray(e)||e.length===0)return;const t=Poe(e[e.length-1]);return t!=null&&t>0?t:void 0},N1=e=>{if(!e||typeof e!="object")return;const t=e,n=typeof t.markerText=="string"?t.markerText:void 0,r=typeof t.numberingType=="string"?t.numberingType:void 0,i=typeof t.customFormat=="string"?t.customFormat:void 0,o=Array.isArray(t.path)?t.path.map(Poe).filter(s=>s!=null):void 0;if(!(!n&&!r&&(!o||o.length===0)))return{markerText:n,numberingType:r,...o&&o.length>0?{path:o}:{},...i?{customFormat:i}:{}}};function YXe(e){return typeof e.captureStackTrace=="function"}var M1=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",YXe(Error)&&Error.captureStackTrace(this,this.constructor)}},KXe=class extends M1{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},XXe=class extends M1{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}};const D1=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const o=e.split(",");if(o.length!==2)throw new KXe(e);const s=atob(o[1]),a=Uint8Array.from(s,l=>l.charCodeAt(0));return new File([a],t,{type:n})}const r=await fetch(e);if(!r.ok)throw new XXe(e,new Error(`HTTP ${r.status}: ${r.statusText}`));const i=await r.blob();return new File([i],t,{type:n})}catch(r){throw r instanceof M1?r:new M1("Failed to create file object",r)}};function JXe(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const o=n[i]||0,s=r[i]||0;if(o>s)return 1;if(o<s)return-1}return 0}var $8={mounted(e,t){const n=r=>{e.contains(r.target)||t.value?.(r)};document.addEventListener("click",n),e.__clickOutsideHandler=n},unmounted(e){e.__clickOutsideHandler&&(document.removeEventListener("click",e.__clickOutsideHandler),delete e.__clickOutsideHandler)}};function ZXe(e){return e[1].user!==void 0}const QXe=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(ZXe).filter(([,r])=>{const i=r.user.email;return n.has(i)?!1:(n.add(i),!0)}).map(([r,i])=>{const o=i.user.email;let s=e.userColorMap.get(o);return s||(s=i.user.color||(e.config.colors.length>0?e.config.colors[e.colorIndex%e.config.colors.length]:void 0),e.userColorMap.set(o,s),e.colorIndex++),{clientId:r,...i.user,color:s}})},$Xe=e=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e};var eJe="https://ingest.superdoc.dev/v1/collect";const pJn="community-and-eval-agplv3";function tJe(){try{return"1.34.0-next.6"}catch{return"unknown"}}var nJe=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||eJe,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=tJe()}getBrowserInfo(){return typeof window>"u"?{userAgent:"",currentUrl:"",hostname:"",screenSize:{width:0,height:0}}:{userAgent:window.navigator.userAgent,currentUrl:window.location.href,hostname:window.location.hostname,screenSize:{width:window.screen.width,height:window.screen.height}}}trackDocumentOpen(e,t=null){if(!this.enabled)return;const n={timestamp:new Date().toISOString(),documentId:e,documentCreatedAt:t};this.sendEvent(n)}async sendEvent(e){const t={superdocVersion:this.superdocVersion,browserInfo:this.getBrowserInfo(),...this.metadata&&{metadata:this.metadata},events:[e]};try{await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-License-Key":this.licenseKey},body:JSON.stringify(t),credentials:"omit"})}catch{}}};function rJe(e,t){return e.type.name===t}function iJe(e,t){if(e.type.name!==t)throw new Error(`Expected node type "${t}", got "${e.type.name}"`)}function oJe(e,t){return e.type.name===t}function Jn(e,t,n={name:""}){const r=e.config[t];return typeof r=="function"?r.bind({...n}):r}function wo(e,t=null,...n){if(typeof e=="function"){const r=e;return t?r.bind(t)(...n):r(...n)}return e}var qn=class GVe{constructor(t){this.type="node",this.name="node",this.config={...t,name:t.name||this.name},this.name=this.config.name,this.group=this.config.group,this.config.addOptions?this.options=wo(Jn(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=wo(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new GVe(t)}};function sJe(e){return qn.create(e)}var vl=class jVe{constructor(t){this.type="mark",this.name="mark",this.config={...t,name:t.name||this.name},this.name=this.config.name,this.isExternal=!!this.config.isExternal,this.config.addOptions?this.options=wo(Jn(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=wo(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new jVe(t)}};function aJe(e){return vl.create(e)}var e9=Gi(((e,t)=>{t.exports={}})),lJe=Gi((e=>{(function(t){t.parser=function(V,D){return new r(V,D)},t.SAXParser=r,t.SAXStream=d,t.createStream=c,t.MAX_BUFFER_LENGTH=64*1024;var n=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(V,D){if(!(this instanceof r))return new r(V,D);var N=this;o(N),N.q=N.c="",N.bufferCheckPosition=t.MAX_BUFFER_LENGTH,N.encoding=null,N.opt=D||{},N.opt.lowercase=N.opt.lowercase||N.opt.lowercasetags,N.looseCase=N.opt.lowercase?"toLowerCase":"toUpperCase",N.opt.maxEntityCount=N.opt.maxEntityCount||512,N.opt.maxEntityDepth=N.opt.maxEntityDepth||4,N.entityCount=N.entityDepth=0,N.tags=[],N.closed=N.closedRoot=N.sawRoot=!1,N.tag=N.error=null,N.strict=!!V,N.noscript=!!(V||N.opt.noscript),N.state=C.BEGIN,N.strictEntities=N.opt.strictEntities,N.ENTITIES=N.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),N.attribList=[],N.opt.xmlns&&(N.ns=Object.create(g)),N.opt.unquotedAttributeValues===void 0&&(N.opt.unquotedAttributeValues=!V),N.trackPosition=N.opt.position!==!1,N.trackPosition&&(N.position=N.line=N.column=0),k(N,"onready")}Object.create||(Object.create=function(V){function D(){}return D.prototype=V,new D}),Object.keys||(Object.keys=function(V){var D=[];for(var N in V)V.hasOwnProperty(N)&&D.push(N);return D});function i(V){for(var D=Math.max(t.MAX_BUFFER_LENGTH,10),N=0,q=0,oe=n.length;q<oe;q++){var J=V[n[q]].length;if(J>D)switch(n[q]){case"textNode":U(V);break;case"cdata":B(V,"oncdata",V.cdata),V.cdata="";break;case"script":B(V,"onscript",V.script),V.script="";break;default:z(V,"Max buffer length exceeded: "+n[q])}N=Math.max(N,J)}V.bufferCheckPosition=t.MAX_BUFFER_LENGTH-N+V.position}function o(V){for(var D=0,N=n.length;D<N;D++)V[n[D]]=""}function s(V){U(V),V.cdata!==""&&(B(V,"oncdata",V.cdata),V.cdata=""),V.script!==""&&(B(V,"onscript",V.script),V.script="")}r.prototype={end:function(){Z(this)},write:ke,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var a;try{a=e9().Stream}catch{a=function(){}}a||(a=function(){});var l=t.EVENTS.filter(function(V){return V!=="error"&&V!=="end"});function c(V,D){return new d(V,D)}function u(V,D){if(V.length>=2){if(V[0]===255&&V[1]===254)return"utf-16le";if(V[0]===254&&V[1]===255)return"utf-16be"}return V.length>=3&&V[0]===239&&V[1]===187&&V[2]===191?"utf8":V.length>=4?V[0]===60&&V[1]===0&&V[2]===63&&V[3]===0?"utf-16le":V[0]===0&&V[1]===60&&V[2]===0&&V[3]===63?"utf-16be":"utf8":D?"utf8":null}function d(V,D){if(!(this instanceof d))return new d(V,D);a.apply(this),this._parser=new r(V,D),this.writable=!0,this.readable=!0;var N=this;this._parser.onend=function(){N.emit("end")},this._parser.onerror=function(q){N.emit("error",q),N._parser.error=null},this._decoder=null,this._decoderBuffer=null,l.forEach(function(q){Object.defineProperty(N,"on"+q,{get:function(){return N._parser["on"+q]},set:function(oe){if(!oe)return N.removeAllListeners(q),N._parser["on"+q]=oe,oe;N.on(q,oe)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(a.prototype,{constructor:{value:d}}),d.prototype._decodeBuffer=function(V,D){if(this._decoderBuffer&&(V=Buffer.concat([this._decoderBuffer,V]),this._decoderBuffer=null),!this._decoder){var N=u(V,D);if(!N)return this._decoderBuffer=V,"";this._parser.encoding=N,this._decoder=new TextDecoder(N)}return this._decoder.decode(V,{stream:!D})},d.prototype.write=function(V){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(V))V=this._decodeBuffer(V,!1);else if(this._decoderBuffer){var D=this._decodeBuffer(Buffer.alloc(0),!0);D&&(this._parser.write(D),this.emit("data",D))}return this._parser.write(V.toString()),this.emit("data",V),!0},d.prototype.end=function(V){if(V&&V.length&&this.write(V),this._decoderBuffer){var D=this._decodeBuffer(Buffer.alloc(0),!0);D&&(this._parser.write(D),this.emit("data",D))}else if(this._decoder){var N=this._decoder.decode();N&&(this._parser.write(N),this.emit("data",N))}return this._parser.end(),!0},d.prototype.on=function(V,D){var N=this;return!N._parser["on"+V]&&l.indexOf(V)!==-1&&(N._parser["on"+V]=function(){var q=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);q.splice(0,0,V),N.emit.apply(N,q)}),a.prototype.on.call(N,V,D)};var f="[CDATA[",h="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",m="http://www.w3.org/2000/xmlns/",g={xml:p,xmlns:m},y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,v=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function x(V){return V===" "||V===`
|
|
5
|
+
`?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&H8(r,this,i,a,s.attributes||{})}else s.retain!==void 0?aoe(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&coe(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??gl();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const d={};let f=!1;o.forEach((p,m)=>{f=!0,d[m]=p});const h={insert:a};f&&(h.attributes=d),i.push(h),a=""}}const u=()=>{for(;l!==null;){if(ny(l,t)||n!==void 0&&ny(l,n))switch(l.content.constructor){case Lm:{const d=o.get("ychange");t!==void 0&&!ny(l,t)?(d===void 0||d.user!==l.id.client||d.type!=="removed")&&(c(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!ny(l,n)?(d===void 0||d.user!==l.id.client||d.type!=="added")&&(c(),o.set("ychange",r?r("added",l.id):{type:"added"})):d!==void 0&&(c(),o.delete("ychange")),a+=l.content.str;break}case np:case VT:{c();const d={insert:l.content.getContent()[0]};if(o.size>0){const f={};d.attributes=f,o.forEach((h,p)=>{f[p]=h})}i.push(d);break}case Ea:ny(l,t)&&(c(),Xv(o,l.content));break}l=l.right}c()};return t||n?vo(s,d=>{t&&P8(d,t),n&&P8(d,n),u()},"cleanup"):u(),i}insert(t,n,r){if(n.length<=0)return;const i=this.doc;i!==null?vo(i,o=>{const s=k1(o,this,t,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),H8(o,this,s,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){const i=this.doc;i!==null?vo(i,o=>{const s=k1(o,this,t,!r);H8(o,this,s,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;const r=this.doc;r!==null?vo(r,i=>{coe(i,k1(i,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;const i=this.doc;i!==null?vo(i,o=>{const s=k1(o,this,t,!1);s.right!==null&&aoe(o,this,s,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?vo(this.doc,n=>{S1(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?vo(this.doc,r=>{O8(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return F8(this,t)}getAttributes(){return toe(this)}_write(t){t.writeTypeRef(lXe)}},UKe=e=>new UT,z8=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??gl()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Ou||t.constructor===Jv)&&t._start!==null)e=t._start;else for(;e!==null;){const n=e.next;if(n!==null){e=n;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Jv=class bee extends ka{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new bee}clone(){const t=new bee;return t.insert(0,this.toArray().map(n=>n instanceof ka?n.clone():n)),t}get length(){return this.doc??gl(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new z8(this,t)}querySelector(t){t=t.toUpperCase();const n=new z8(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return n.done?null:n.value}querySelectorAll(t){return t=t.toUpperCase(),Zh(new z8(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){A1(this,t,new GKe(this,n,t))}toString(){return Jie(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){const i=t.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),zT(this,o=>{i.insertBefore(o.toDOM(t,n,r),null)}),i}insert(t,n){this.doc!==null?vo(this.doc,r=>{$ie(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)vo(this.doc,r=>{const i=t&&t instanceof ka?t._item:t;x1(r,this,i,n)});else{const r=this._prelimContent,i=t===null?0:r.findIndex(o=>o===t)+1;if(i===0&&t!==null)throw Mf("Reference item not found");r.splice(i,0,...n)}}delete(t,n=1){this.doc!==null?vo(this.doc,r=>{eoe(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Kie(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Zie(this,t)}slice(t=0,n=this.length){return Yie(this,t,n)}forEach(t){zT(this,t)}_write(t){t.writeTypeRef(uXe)}},VKe=e=>new Jv,Ou=class vee extends Jv{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new vee(this.nodeName)}clone(){const t=new vee(this.nodeName),n=this.getAttributes();return Rqe(n,(r,i)=>{t.setAttribute(i,r)}),t.insert(0,this.toArray().map(r=>r instanceof ka?r.clone():r)),t}toString(){const t=this.getAttributes(),n=[],r=[];for(const s in t)r.push(s);r.sort();const i=r.length;for(let s=0;s<i;s++){const a=r[s];n.push(a+'="'+t[a]+'"')}const o=this.nodeName.toLocaleLowerCase();return`<${o}${n.length>0?" "+n.join(" "):""}>${super.toString()}</${o}>`}removeAttribute(t){this.doc!==null?vo(this.doc,n=>{S1(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?vo(this.doc,r=>{O8(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return F8(this,t)}hasAttribute(t){return noe(this,t)}getAttributes(t){return t?LKe(this,t):toe(this)}toDOM(t=document,n={},r){const i=t.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const a=o[s];typeof a=="string"&&i.setAttribute(s,a)}return zT(this,s=>{i.appendChild(s.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(cXe),t.writeKey(this.nodeName)}},WKe=e=>new Ou(e.readKey()),GKe=class extends v1{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}},jKe=class wee extends Ka{constructor(t){super(),this.hookName=t}_copy(){return new wee(this.hookName)}clone(){const t=new wee(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){const i=n[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(dXe),t.writeKey(this.hookName)}},qKe=e=>new jKe(e.readKey()),Of=class Aee extends UT{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new Aee}clone(){const t=new Aee;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){const i=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(t=>{const n=[];for(const i in t.attributes){const o=[];for(const s in t.attributes[i])o.push({key:s,value:t.attributes[i][s]});o.sort((s,a)=>s.key<a.key?-1:1),n.push({nodeName:i,attrs:o})}n.sort((i,o)=>i.nodeName<o.nodeName?-1:1);let r="";for(let i=0;i<n.length;i++){const o=n[i];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){const a=o.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=t.insert;for(let i=n.length-1;i>=0;i--)r+=`</${n[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(fXe)}},YKe=e=>new Of,U8=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Mu()}mergeWith(e){return!1}write(e,t,n){throw Mu()}integrate(e,t){throw Mu()}},KKe=0,Fu=class extends U8{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Mie(e.doc.store,this)}write(e,t){e.writeInfo(KKe),e.writeLen(this.length-t)}getMissing(e,t){return null}},V8=class HVe{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new HVe(this.content)}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},XKe=e=>new V8(e.readBuf()),uoe=class xee{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new xee(this.len)}splice(t){const n=new xee(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){NT(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},JKe=e=>new uoe(e.readLen()),doe=(e,t)=>new tp({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),W8=class zVe{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new zVe(doe(this.doc.guid,this.opts))}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},ZKe=e=>new W8(doe(e.readString(),e.readAny())),VT=class UVe{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new UVe(this.embed)}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},QKe=e=>new VT(e.readJSON()),Ea=class VVe{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new VVe(this.key,this.value)}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},$Ke=e=>new Ea(e.readKey(),e.readJSON()),eXe=class See{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new See(this.arr)}splice(t){const n=new See(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const r=this.arr.length;t.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];t.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}},tXe=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const i=e.readString();i==="undefined"?n.push(void 0):n.push(JSON.parse(i))}return new eXe(n)},nXe=s1("node_env")==="development",E1=class Tee{constructor(t){this.arr=t,nXe&&Dre(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Tee(this.arr)}splice(t){const n=new Tee(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const r=this.arr.length;t.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];t.writeAny(o)}}getRef(){return 8}},rXe=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new E1(n)},Lm=class Iee{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Iee(this.str)}splice(t){const n=new Iee(this.str.slice(t));this.str=this.str.slice(0,t);const r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},iXe=e=>new Lm(e.readString()),oXe=[MKe,OKe,UKe,WKe,VKe,qKe,YKe],sXe=0,aXe=1,lXe=2,cXe=3,uXe=4,dXe=5,fXe=6,np=class WVe{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new WVe(this.type._copy())}splice(t){throw Mu()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},hXe=e=>new np(oXe[e.readTypeRef()](e)),G8=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Hr(n.client,n.clock+r)),i=Kv(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Bo);return{item:i,diff:r}},j8=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},C1=(e,t,n)=>{const{client:r,clock:i}=t.id,o=new Bo(Hr(r,i+n),t,Hr(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&o.markDeleted(),t.keep&&(o.keep=!0),t.redone!==null&&(o.redone=Hr(t.redone.client,t.redone.clock+n)),t.right=o,o.right!==null&&(o.right.left=o),e._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),t.length=n,o},foe=(e,t)=>qB(e,n=>Wv(n.deletions,t)),hoe=(e,t,n,r,i,o)=>{const s=e.doc,a=s.store,l=s.clientID,c=t.redone;if(c!==null)return Ac(e,c);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||hoe(e,u,n,r,i,o)===null))return null;for(;u.redone!==null;)u=Ac(e,u.redone)}const h=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let g=d;for(;g!==null&&g.parent._item!==u;)g=g.redone===null?null:Ac(e,g.redone);if(g!==null&&g.parent._item===u){d=g;break}d=d.left}for(;f!==null;){let g=f;for(;g!==null&&g.parent._item!==u;)g=g.redone===null?null:Ac(e,g.redone);if(g!==null&&g.parent._item===u){f=g;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||Wv(r,d.right.id)||foe(o.undoStack,d.right.id)||foe(o.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ac(e,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(t.parentSub)||null;const p=Hr(l,_s(a,l)),m=new Bo(p,d,d&&d.lastId,f,f&&f.id,h,t.parentSub,t.content.copy());return t.redone=p,j8(m,!0),m.integrate(e,0),m},Bo=class kee extends U8{constructor(t,n,r,i,o,s,a,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=o,this.parent=s,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=_s(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=_s(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===qv&&this.id.client!==this.parent.client&&this.parent.clock>=_s(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Die(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Ac(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Fu||this.right&&this.right.constructor===Fu)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===kee?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===kee&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===qv){const r=Kv(n,this.parent);r.constructor===Fu?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=Die(t,t.doc.store,Hr(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,s=new Set;for(;i!==null&&i!==this.right;){if(s.add(i),o.add(i),Yv(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(Yv(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(Kv(t.doc.store,i.origin)))o.has(Kv(t.doc.store,i.origin))||(r=i,o.clear());else break;i=i.right}this.left=r}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Mie(t.doc.store,this),this.content.integrate(t,this),Bie(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new Fu(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:Hr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Yv(t.origin,this.lastId)&&this.right===t&&Yv(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),NT(t.deleteSet,this.id.client,this.id.clock,this.length),Bie(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw zl();this.content.gc(t),n?mKe(t,this,new Fu(this.id,this.length)):this.content=new uoe(this.length)}write(t,n){const r=n>0?Hr(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&31|(r===null?0:128)|(i===null?0:64)|(o===null?0:32);if(t.writeInfo(s),r!==null&&t.writeLeftID(r),i!==null&&t.writeRightID(i),r===null&&i===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=DT(a);t.writeParentInfo(!0),t.writeString(c)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else a.constructor===String?(t.writeParentInfo(!0),t.writeString(a)):a.constructor===qv?(t.writeParentInfo(!1),t.writeLeftID(a)):zl();o!==null&&t.writeString(o)}this.content.write(t,n)}},poe=(e,t)=>pXe[t&31](e),pXe=[()=>{zl()},JKe,tXe,XKe,iXe,QKe,$Ke,hXe,rXe,ZKe,()=>{zl()}],mXe=10,Bu=class extends U8{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){zl()}write(e,t){e.writeInfo(mXe),En(e.restEncoder,this.length-t)}getMissing(e,t){return null}},moe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},goe="__ $YJS$ __";moe[goe]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),moe[goe]=!0;const gXe=3e4;var yoe=class extends eYe{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Nd();this.getLocalState()!==null&&3e4/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((r,i)=>{i!==this.clientID&&3e4<=t-r.lastUpdated&&this.states.has(i)&&n.push(i)}),n.length>0&&Zv(this,n,"timeout")},Nu(gXe/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Nd()});const o=[],s=[],a=[],l=[];e===null?l.push(t):i==null?e!=null&&o.push(t):(s.push(t),Fv(i,e)||a.push(t)),(o.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:o,updated:a,removed:l},"local"]),this.emit("update",[{added:o,updated:s,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}};const Zv=(e,t,n)=>{const r=[];for(let i=0;i<t.length;i++){const o=t[i];if(e.states.has(o)){if(e.states.delete(o),o===e.clientID){const s=e.meta.get(o);e.meta.set(o,{clock:s.clock+1,lastUpdated:Nd()})}r.push(o)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},Nm=(e,t,n=e.states)=>{const r=t.length,i=ia();En(i,r);for(let o=0;o<r;o++){const s=t[o],a=n.get(s)||null,l=e.meta.get(s).clock;En(i,s),En(i,l),Ta(i,JSON.stringify(a))}return Fo(i)},boe=(e,t,n)=>{const r=Qh(t),i=Nd(),o=[],s=[],a=[],l=[],c=Cr(r);for(let u=0;u<c;u++){const d=Cr(r);let f=Cr(r);const h=JSON.parse(Zc(r)),p=e.meta.get(d),m=e.states.get(d),g=p===void 0?0:p.clock;(g<f||g===f&&h===null&&e.states.has(d))&&(h===null?d===e.clientID&&e.getLocalState()!=null?f++:e.states.delete(d):e.states.set(d,h),e.meta.set(d,{clock:f,lastUpdated:i}),p===void 0&&h!==null?o.push(d):p!==void 0&&h===null?l.push(d):h!==null&&(Fv(h,m)||a.push(d),s.push(d)))}(o.length>0||a.length>0||l.length>0)&&e.emit("change",[{added:o,updated:a,removed:l},n]),(o.length>0||s.length>0||l.length>0)&&e.emit("update",[{added:o,updated:s,removed:l},n])};var voe=class{callbacks={};on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(r=>r.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(r=>r!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};function yXe(e){return e||(e={}),{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function q8(e){return new Promise(t=>setTimeout(t,e))}function bXe(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=Math.pow(t.factor,e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){const r=Math.ceil(t.minDelay),i=Math.floor(n);n=Math.floor(Math.random()*(i-r+1))+r}return Math.round(n)}async function vXe(e,t){const n=yXe(t);for(const a of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const l=n[a];if(!Number.isInteger(l)||l<0)throw new Error(`Value for ${a} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw new Error("Value for factor must be a number greater than or equal to 0");if(n.delay<n.minDelay)throw new Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);const r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||bXe;async function o(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){const l=new Error("Attempt aborted");throw l.code="ATTEMPT_ABORTED",l}const a=async l=>{if(n.handleError&&await n.handleError(l,r,n),r.aborted||r.attemptsRemaining===0)throw l;r.attemptNum++;const c=i(r,n);return c&&await q8(c),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((l,c)=>{const u=setTimeout(()=>{if(n.handleTimeout)try{l(n.handleTimeout(r,n))}catch(d){c(d)}else{const d=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);d.code="ATTEMPT_TIMEOUT",c(d)}},n.timeout);e(r,n).then(d=>{clearTimeout(u),l(d)}).catch(d=>{clearTimeout(u),a(d).then(l).catch(c)})}):e(r,n).catch(a)}const s=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(s&&await q8(s),r.attemptNum<1&&n.initialJitter){const a=i(r,n);a&&await q8(a)}return o()}const woe=e=>Lqe(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");let yl=(function(e){return e[e.Sync=0]="Sync",e[e.Awareness=1]="Awareness",e[e.Auth=2]="Auth",e[e.QueryAwareness=3]="QueryAwareness",e[e.Stateless=5]="Stateless",e[e.CLOSE=7]="CLOSE",e[e.SyncStatus=8]="SyncStatus",e})({}),bl=(function(e){return e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e})({});var _1=class{data;encoder;decoder;constructor(e){this.data=e,this.encoder=ia(),this.decoder=Qh(new Uint8Array(this.data))}peekVarString(){return gqe(this.decoder)}readVarUint(){return Cr(this.decoder)}readVarString(){return Zc(this.decoder)}readVarUint8Array(){return Ya(this.decoder)}writeVarUint(e){return En(this.encoder,e)}writeVarString(e){return Ta(this.encoder,e)}writeVarUint8Array(e){return ns(this.encoder,e)}length(){return Q_(this.encoder)}},Aoe=class extends voe{messageQueue=[];configuration={url:"",document:void 0,WebSocketPolyfill:void 0,parameters:{},connect:!0,broadcast:!0,forceSyncInterval:!1,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,quiet:!1,providerMap:new Map};webSocket=null;webSocketHandlers={};shouldConnect=!0;status=bl.Disconnected;lastMessageReceived=0;identifier=0;intervals={forceSync:null,connectionChecker:null};connectionAttempt=null;constructor(e){super(),this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("status",this.onStatus.bind(this)),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),typeof e.connect<"u"&&(this.shouldConnect=e.connect),this.shouldConnect&&this.connect()}receivedOnOpenPayload=void 0;receivedOnStatusPayload=void 0;async onOpen(e){this.receivedOnOpenPayload=e}async onStatus(e){this.receivedOnStatusPayload=e}attach(e){let t;return this.configuration.providerMap.set(e.configuration.name,e),this.status===bl.Disconnected&&this.shouldConnect&&(t=this.connect()),this.receivedOnOpenPayload&&e.onOpen(this.receivedOnOpenPayload),this.receivedOnStatusPayload&&e.onStatus(this.receivedOnStatusPayload),t}detach(e){this.configuration.providerMap.delete(e.configuration.name)}setConfiguration(e={}){this.configuration={...this.configuration,...e}}cancelWebsocketRetry;async connect(){if(this.status===bl.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.receivedOnStatusPayload=void 0,this.shouldConnect=!0;const e=()=>{let r=!1;return{retryPromise:vXe(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,beforeAttempt:i=>{(!this.shouldConnect||r)&&i.abort()}}).catch(i=>{if(i&&i.code!=="ATTEMPT_ABORTED")throw i}),cancelFunc:()=>{r=!0}}},{retryPromise:t,cancelFunc:n}=e();return this.cancelWebsocketRetry=n,t}attachWebSocketListeners(e,t){const{identifier:n}=e,r=l=>this.emit("message",l),i=l=>this.emit("close",{event:l}),o=l=>this.emit("open",l),s=l=>{t(l)};this.webSocketHandlers[n]={message:r,close:i,open:o,error:s};const a=this.webSocketHandlers[e.identifier];Object.keys(a).forEach(l=>{e.addEventListener(l,a[l])})}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType="arraybuffer",n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=bl.Connecting,this.emit("status",{status:bl.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Nd();const t=new _1(e.data).peekVarString();this.configuration.providerMap.get(t)?.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=bl.Connected,this.emit("status",{status:bl.Connected}),this.emit("connect"),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}closeTries=0;checkConnection(){this.status===bl.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Nd()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){for(;this.configuration.url[this.configuration.url.length-1]==="/";)return this.configuration.url.slice(0,this.configuration.url.length-1);return this.configuration.url}get url(){const e=woe(this.configuration.parameters);return`${this.serverUrl}${e.length===0?"":`?${e}`}`}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch{}}send(e){this.webSocket?.readyState===Sqe.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){if(this.closeTries=0,this.cleanupWebSocket(),this.status===bl.Connected&&(this.status=bl.Disconnected,this.emit("status",{status:bl.Disconnected}),this.emit("disconnect",{event:e})),e.code===Cre.code&&(e.reason===Cre.reason?console.warn("[HocuspocusProvider] An authentication token is required, but you didn’t send one. Try adding a `token` to your HocuspocusProvider configuration. Won’t try again."):console.warn(`[HocuspocusProvider] Connection closed with status Unauthorized: ${e.reason}`),this.shouldConnect=!1),e.code===xqe.code&&!this.configuration.quiet){console.warn("[HocuspocusProvider] The provided authentication token isn’t allowed to connect to this server. Will try again.");return}e.code===Aqe.code&&(console.warn(`[HocuspocusProvider] Connection closed with status MessageTooBig: ${e.reason}`),this.shouldConnect=!1),this.connectionAttempt?this.rejectConnectionAttempt():this.shouldConnect&&this.connect(),!this.shouldConnect&&this.status!==bl.Disconnected&&(this.status=bl.Disconnected,this.emit("status",{status:bl.Disconnected}),this.emit("disconnect",{event:e}))}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}};const dJn=0,fJn=1,hJn=2,P1=(e,t)=>{En(e,0);const n=lKe(t);ns(e,n)},Y8=(e,t,n)=>{En(e,1),ns(e,I8(t,n))},wXe=(e,t,n)=>Y8(t,n,Ya(e)),xoe=(e,t,n,r)=>{try{Iie(t,Ya(e),n)}catch(i){r?.(i),console.error("Caught error while handling a Yjs update",i)}},Soe=(e,t)=>{En(e,2),ns(e,t)},AXe=xoe,Toe=(e,t,n,r,i)=>{const o=Cr(e);switch(o){case 0:wXe(e,t,n);break;case 1:xoe(e,n,r,i);break;case 2:AXe(e,n,r,i);break;default:throw new Error("Unknown message type")}return o};var Ff=class{encoder;type;constructor(){this.encoder=ia()}get(e){return e.encoder}toUint8Array(){return Fo(this.encoder)}},Ioe=class{message;broadcasted=!1;constructor(e){this.message=e}setBroadcasted(e){return this.broadcasted=e,this}apply(e,t){const{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case yl.Sync:this.applySyncMessage(e,t);break;case yl.Awareness:this.applyAwarenessMessage(e);break;case yl.Auth:this.applyAuthMessage(e);break;case yl.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case yl.Stateless:e.receiveStateless(Zc(n.decoder));break;case yl.SyncStatus:this.applySyncStatusMessage(e,n1(n.decoder)===1);break;default:throw new Error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&(this.broadcasted?e.broadcast(Ff,{encoder:n.encoder}):e.send(Ff,{encoder:n.encoder}))}applySyncMessage(e,t){const{message:n}=this;n.writeVarUint(yl.Sync);const r=Toe(n.decoder,n.encoder,e.document,e);t&&r===1&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;boe(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;wqe(t.decoder,e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(yl.Awareness),t.writeVarUint8Array(Nm(e.awareness,Array.from(e.awareness.getStates().keys())))}},koe=class{encoder;message;constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Fo(this.encoder)}send(e){e?.send(this.create())}broadcast(e){$0(e,this.create())}},xXe=class extends Ff{type=yl.Auth;description="Authentication";get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return Ta(this.encoder,e.documentName),En(this.encoder,this.type),vqe(this.encoder,e.token),this.encoder}},R1=class extends Ff{type=yl.Awareness;description="Awareness states update";get(e){if(typeof e.awareness>"u")throw new Error("The awareness message requires awareness as an argument");if(typeof e.clients>"u")throw new Error("The awareness message requires clients as an argument");Ta(this.encoder,e.documentName),En(this.encoder,this.type);let t;return e.states===void 0?t=Nm(e.awareness,e.clients):t=Nm(e.awareness,e.clients,e.states),ns(this.encoder,t),this.encoder}},SXe=class extends Ff{type=yl.CLOSE;description="Ask the server to close the connection";get(e){return Ta(this.encoder,e.documentName),En(this.encoder,this.type),this.encoder}},TXe=class extends Ff{type=yl.QueryAwareness;description="Queries awareness states";get(e){return Ta(this.encoder,e.documentName),En(this.encoder,this.type),this.encoder}},IXe=class extends Ff{type=yl.Stateless;description="A stateless message";get(e){return Ta(this.encoder,e.documentName),En(this.encoder,this.type),Ta(this.encoder,e.payload??""),this.encoder}},K8=class extends Ff{type=yl.Sync;description="First sync step";get(e){if(typeof e.document>"u")throw new Error("The sync step one message requires document as an argument");return Ta(this.encoder,e.documentName),En(this.encoder,this.type),P1(this.encoder,e.document),this.encoder}},kXe=class extends Ff{type=yl.Sync;description="Second sync step";get(e){if(typeof e.document>"u")throw new Error("The sync step two message requires document as an argument");return Ta(this.encoder,e.documentName),En(this.encoder,this.type),Y8(this.encoder,e.document),this.encoder}},EXe=class extends Ff{type=yl.Sync;description="A document update";get(e){return Ta(this.encoder,e.documentName),En(this.encoder,this.type),Soe(this.encoder,e.update),this.encoder}},CXe=class extends Error{code=1001},_Xe=class extends voe{configuration={name:"",document:void 0,awareness:void 0,token:null,parameters:{},broadcast:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onSynced:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,quiet:!1,connect:!0,preserveConnection:!0};subscribedToBroadcastChannel=!1;isSynced=!1;unsyncedChanges=0;status=bl.Disconnected;isAuthenticated=!1;authorizedScope=void 0;mux=Vre();intervals={forceSync:null};isConnected=!0;constructor(e){super(),this.setConfiguration(e),this.configuration.document=e.document?e.document:new tp,this.configuration.awareness=e.awareness!==void 0?e.awareness:new yoe(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("open",this.forwardOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("status",this.boundOnStatus),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.awareness?.on("update",()=>{this.emit("awarenessUpdate",{states:_re(this.awareness.getStates())})}),this.awareness?.on("change",()=>{this.emit("awarenessChange",{states:_re(this.awareness.getStates())})}),this.document.on("update",this.boundDocumentUpdateHandler),this.awareness?.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval=="number"&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.configuration.websocketProvider.attach(this)}boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this);boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this);boundBroadcastChannelSubscriber=this.broadcastChannelSubscriber.bind(this);boundPageHide=this.pageHide.bind(this);boundOnOpen=this.onOpen.bind(this);boundOnClose=this.onClose.bind(this);boundOnStatus=this.onStatus.bind(this);forwardConnect=e=>this.emit("connect",e);forwardOpen=e=>this.emit("open",e);forwardClose=e=>this.emit("close",e);forwardDisconnect=e=>this.emit("disconnect",e);forwardDestroy=e=>this.emit("destroy",e);onStatus({status:e}){this.status=e,this.configuration.onStatus({status:e}),this.emit("status",{status:e})}setConfiguration(e={}){if(!e.websocketProvider&&e.url){const t=e;this.configuration.websocketProvider=new Aoe({url:t.url,connect:t.connect,parameters:t.parameters})}this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",this.unsyncedChanges)}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",this.unsyncedChanges)}decrementUnsyncedChanges(){this.unsyncedChanges-=1,this.unsyncedChanges===0&&(this.synced=!0),this.emit("unsyncedChanges",this.unsyncedChanges)}forceSync(){this.resetUnsyncedChanges(),this.send(K8,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Zv(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(IXe,{documentName:this.configuration.name,payload:e})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(EXe,{update:e,documentName:this.configuration.name},!0))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){const i=e.concat(t).concat(n);this.send(R1,{awareness:this.awareness,clients:i,documentName:this.configuration.name},!0)}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,this.emit("synced",{state:e}),this.emit("sync",{state:e}))}receiveStateless(e){this.emit("stateless",{payload:e})}get isAuthenticationRequired(){return!!this.configuration.token&&!this.isAuthenticated}async connect(){return this.configuration.broadcast&&this.subscribeToBroadcastChannel(),this.configuration.websocketProvider.shouldConnect=!0,this.configuration.websocketProvider.attach(this)}disconnect(){this.disconnectBroadcastChannel(),this.configuration.websocketProvider.detach(this),this.isConnected=!1,this.configuration.preserveConnection||this.configuration.websocketProvider.disconnect()}async onOpen(e){this.isAuthenticated=!1,this.isConnected=!0,this.emit("open",{event:e});let t;try{t=await this.getToken()}catch(n){this.permissionDeniedHandler(`Failed to get token: ${n}`);return}this.isAuthenticationRequired&&this.send(xXe,{token:t,documentName:this.configuration.name}),this.startSync()}async getToken(){return typeof this.configuration.token=="function"?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(K8,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(R1,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t,n=!1){if(!this.isConnected)return;n&&this.mux(()=>{this.broadcast(e,t)});const r=new koe(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new _1(e.data),n=t.readVarString();t.writeVarString(n),this.emit("message",{event:e,message:new _1(e.data)}),new Ioe(t).apply(this,!0)}onClose(e){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Zv(this.awareness,Array.from(this.awareness.getStates().keys()).filter(t=>t!==this.document.clientID),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(Zv(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("open",this.forwardOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("status",this.boundOnStatus),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.send(SXe,{documentName:this.configuration.name}),this.disconnect(),!(typeof window>"u"||!("removeEventListener"in window))&&window.removeEventListener("pagehide",this.boundPageHide)}permissionDeniedHandler(e){this.emit("authenticationFailed",{reason:e}),this.isAuthenticated=!1,this.disconnect(),this.status=bl.Disconnected}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit("authenticated")}get broadcastChannel(){return`${this.configuration.name}`}broadcastChannelSubscriber(e){this.mux(()=>{const t=new _1(e),n=t.readVarString();t.writeVarString(n),new Ioe(t).setBroadcasted(!0).apply(this,!1)})}subscribeToBroadcastChannel(){this.subscribedToBroadcastChannel||(zre(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!0),this.mux(()=>{this.broadcast(K8,{document:this.document,documentName:this.configuration.name}),this.broadcast(kXe,{document:this.document,documentName:this.configuration.name}),this.broadcast(TXe,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.broadcast(R1,{awareness:this.awareness,clients:[this.document.clientID],document:this.document,documentName:this.configuration.name})})}disconnectBroadcastChannel(){this.awareness&&this.send(R1,{awareness:this.awareness,clients:[this.document.clientID],states:new Map,documentName:this.configuration.name},!0),this.subscribedToBroadcastChannel&&(Ure(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!1)}broadcast(e,t){this.configuration.broadcast&&this.subscribedToBroadcastChannel&&new koe(e,t).broadcast(this.broadcastChannel)}setAwarenessField(e,t){if(!this.awareness)throw new CXe(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}};const xc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",WT="application/pdf",L1="text/html",PXe={docx:xc,pdf:WT,html:L1},X8=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Ps={RESOLVED:"resolved",NEW:"new",ADD:"add",UPDATE:"update",DELETED:"deleted",PENDING:"pending",SELECTED:"selected",COMMENTS_LIST:"comments-list",CHANGE_ACCEPTED:"change-accepted",CHANGE_REJECTED:"change-rejected"};var RXe=(e,t)=>rp(e,t,J8),Eoe=(e,t)=>rp(e,t,WXe),LXe=(e,t)=>{const n=Eoe(e,t);return n?n.toLowerCase():null},Coe=(e,t)=>rp(e,t,GXe),NXe=(e,t)=>{const n=Coe(e,t);return n?n.toLowerCase():null},MXe=(e,t)=>rp(e,t,zXe),DXe=(e,t,n)=>VXe(e,t,n),OXe=(e,t)=>rp(e,t,jXe),FXe=(e,t)=>rp(e,t,UXe),BXe={decimal:RXe,decimalZero:FXe,lowerRoman:LXe,upperRoman:Eoe,lowerLetter:NXe,upperLetter:Coe,ordinal:MXe,custom:DXe,japaneseCounting:OXe};const _oe=({listLevel:e,lvlText:t,listNumberingType:n,customFormat:r})=>{if(typeof t!="string")return null;const i=BXe[n];return i?i(e,t,r):null};var HXe=(e,t)=>typeof t!="string"?"":e.reduce((n,r,i)=>Number(r)>9?n.replace(/^0/,"").replace(`%${i+1}`,r):n.replace(`%${i+1}`,r),t),rp=(e,t,n)=>HXe(e.map((r,i)=>n(r,i)),t),zXe=e=>{const t=["th","st","nd","rd"],n=e%100;return`${e}${t[(n-20)%10]||t[n]||t[0]}`},UXe=(e,t)=>e>=10||t===0?String(e):`0${e}`,VXe=(e,t,n)=>{if(typeof n!="string"||n.match(/(?:[0]+\d,\s){3}\.{3}/)==null)return rp(e,t,J8);const r=n.match(/(\d+)/);if(!r)throw new Error("Invalid format string: no numeric pattern found");const i=r[1].length;return rp(e,t,o=>String(o).padStart(i,"0"))},J8=e=>String(e),WXe=e=>{const t=[{value:1e3,numeral:"M"},{value:900,numeral:"CM"},{value:500,numeral:"D"},{value:400,numeral:"CD"},{value:100,numeral:"C"},{value:90,numeral:"XC"},{value:50,numeral:"L"},{value:40,numeral:"XL"},{value:10,numeral:"X"},{value:9,numeral:"IX"},{value:5,numeral:"V"},{value:4,numeral:"IV"},{value:1,numeral:"I"}];let n="",r=e;for(const{value:i,numeral:o}of t)for(;r>=i;)n+=o,r-=i;return n},GXe=e=>{if(e<1)return"";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(e-1)%26],n=Math.floor((e-1)/26)+1;return t.repeat(n)};const jXe=e=>{const t=["","一","二","三","四","五","六","七","八","九"],n=["","十","百","千"];if(e===0)return"零";if(e<10)return t[e];let r="",i=e,o=0;for(;i>0;){const s=i%10;if(s!==0?r=(s===1&&o>0?"":t[s])+(o>0?n[o]:"")+r:r&&i>0&&!r.startsWith("零")&&i%100!==0&&(r="零"+r),i=Math.floor(i/10),o+=1,o>3)break}return e>=10&&e<20&&(r=r.replace(/^一十/,"十")),r};var qXe=new Set(["","","○","o","■","□"]);const Z8=e=>!e||!qXe.has(e)?e:e===""?"•":e==="○"||e==="o"?"◦":e==="■"||e===""?"▪":e==="□"?"◯":e;var Poe=e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim().length>0){const t=Number(e);if(Number.isFinite(t))return t}};const Q8=e=>{if(!Array.isArray(e)||e.length===0)return;const t=Poe(e[e.length-1]);return t!=null&&t>0?t:void 0},N1=e=>{if(!e||typeof e!="object")return;const t=e,n=typeof t.markerText=="string"?t.markerText:void 0,r=typeof t.numberingType=="string"?t.numberingType:void 0,i=typeof t.customFormat=="string"?t.customFormat:void 0,o=Array.isArray(t.path)?t.path.map(Poe).filter(s=>s!=null):void 0;if(!(!n&&!r&&(!o||o.length===0)))return{markerText:n,numberingType:r,...o&&o.length>0?{path:o}:{},...i?{customFormat:i}:{}}};function YXe(e){return typeof e.captureStackTrace=="function"}var M1=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",YXe(Error)&&Error.captureStackTrace(this,this.constructor)}},KXe=class extends M1{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},XXe=class extends M1{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}};const D1=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const o=e.split(",");if(o.length!==2)throw new KXe(e);const s=atob(o[1]),a=Uint8Array.from(s,l=>l.charCodeAt(0));return new File([a],t,{type:n})}const r=await fetch(e);if(!r.ok)throw new XXe(e,new Error(`HTTP ${r.status}: ${r.statusText}`));const i=await r.blob();return new File([i],t,{type:n})}catch(r){throw r instanceof M1?r:new M1("Failed to create file object",r)}};function JXe(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const o=n[i]||0,s=r[i]||0;if(o>s)return 1;if(o<s)return-1}return 0}var $8={mounted(e,t){const n=r=>{e.contains(r.target)||t.value?.(r)};document.addEventListener("click",n),e.__clickOutsideHandler=n},unmounted(e){e.__clickOutsideHandler&&(document.removeEventListener("click",e.__clickOutsideHandler),delete e.__clickOutsideHandler)}};function ZXe(e){return e[1].user!==void 0}const QXe=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(ZXe).filter(([,r])=>{const i=r.user.email;return n.has(i)?!1:(n.add(i),!0)}).map(([r,i])=>{const o=i.user.email;let s=e.userColorMap.get(o);return s||(s=i.user.color||(e.config.colors.length>0?e.config.colors[e.colorIndex%e.config.colors.length]:void 0),e.userColorMap.set(o,s),e.colorIndex++),{clientId:r,...i.user,color:s}})},$Xe=e=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e};var eJe="https://ingest.superdoc.dev/v1/collect";const pJn="community-and-eval-agplv3";function tJe(){try{return"1.34.0-next.7"}catch{return"unknown"}}var nJe=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||eJe,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=tJe()}getBrowserInfo(){return typeof window>"u"?{userAgent:"",currentUrl:"",hostname:"",screenSize:{width:0,height:0}}:{userAgent:window.navigator.userAgent,currentUrl:window.location.href,hostname:window.location.hostname,screenSize:{width:window.screen.width,height:window.screen.height}}}trackDocumentOpen(e,t=null){if(!this.enabled)return;const n={timestamp:new Date().toISOString(),documentId:e,documentCreatedAt:t};this.sendEvent(n)}async sendEvent(e){const t={superdocVersion:this.superdocVersion,browserInfo:this.getBrowserInfo(),...this.metadata&&{metadata:this.metadata},events:[e]};try{await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-License-Key":this.licenseKey},body:JSON.stringify(t),credentials:"omit"})}catch{}}};function rJe(e,t){return e.type.name===t}function iJe(e,t){if(e.type.name!==t)throw new Error(`Expected node type "${t}", got "${e.type.name}"`)}function oJe(e,t){return e.type.name===t}function Jn(e,t,n={name:""}){const r=e.config[t];return typeof r=="function"?r.bind({...n}):r}function wo(e,t=null,...n){if(typeof e=="function"){const r=e;return t?r.bind(t)(...n):r(...n)}return e}var qn=class GVe{constructor(t){this.type="node",this.name="node",this.config={...t,name:t.name||this.name},this.name=this.config.name,this.group=this.config.group,this.config.addOptions?this.options=wo(Jn(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=wo(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new GVe(t)}};function sJe(e){return qn.create(e)}var vl=class jVe{constructor(t){this.type="mark",this.name="mark",this.config={...t,name:t.name||this.name},this.name=this.config.name,this.isExternal=!!this.config.isExternal,this.config.addOptions?this.options=wo(Jn(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=wo(Jn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new jVe(t)}};function aJe(e){return vl.create(e)}var e9=Gi(((e,t)=>{t.exports={}})),lJe=Gi((e=>{(function(t){t.parser=function(V,D){return new r(V,D)},t.SAXParser=r,t.SAXStream=d,t.createStream=c,t.MAX_BUFFER_LENGTH=64*1024;var n=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(V,D){if(!(this instanceof r))return new r(V,D);var N=this;o(N),N.q=N.c="",N.bufferCheckPosition=t.MAX_BUFFER_LENGTH,N.encoding=null,N.opt=D||{},N.opt.lowercase=N.opt.lowercase||N.opt.lowercasetags,N.looseCase=N.opt.lowercase?"toLowerCase":"toUpperCase",N.opt.maxEntityCount=N.opt.maxEntityCount||512,N.opt.maxEntityDepth=N.opt.maxEntityDepth||4,N.entityCount=N.entityDepth=0,N.tags=[],N.closed=N.closedRoot=N.sawRoot=!1,N.tag=N.error=null,N.strict=!!V,N.noscript=!!(V||N.opt.noscript),N.state=C.BEGIN,N.strictEntities=N.opt.strictEntities,N.ENTITIES=N.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),N.attribList=[],N.opt.xmlns&&(N.ns=Object.create(g)),N.opt.unquotedAttributeValues===void 0&&(N.opt.unquotedAttributeValues=!V),N.trackPosition=N.opt.position!==!1,N.trackPosition&&(N.position=N.line=N.column=0),k(N,"onready")}Object.create||(Object.create=function(V){function D(){}return D.prototype=V,new D}),Object.keys||(Object.keys=function(V){var D=[];for(var N in V)V.hasOwnProperty(N)&&D.push(N);return D});function i(V){for(var D=Math.max(t.MAX_BUFFER_LENGTH,10),N=0,q=0,oe=n.length;q<oe;q++){var J=V[n[q]].length;if(J>D)switch(n[q]){case"textNode":U(V);break;case"cdata":B(V,"oncdata",V.cdata),V.cdata="";break;case"script":B(V,"onscript",V.script),V.script="";break;default:z(V,"Max buffer length exceeded: "+n[q])}N=Math.max(N,J)}V.bufferCheckPosition=t.MAX_BUFFER_LENGTH-N+V.position}function o(V){for(var D=0,N=n.length;D<N;D++)V[n[D]]=""}function s(V){U(V),V.cdata!==""&&(B(V,"oncdata",V.cdata),V.cdata=""),V.script!==""&&(B(V,"onscript",V.script),V.script="")}r.prototype={end:function(){Z(this)},write:ke,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var a;try{a=e9().Stream}catch{a=function(){}}a||(a=function(){});var l=t.EVENTS.filter(function(V){return V!=="error"&&V!=="end"});function c(V,D){return new d(V,D)}function u(V,D){if(V.length>=2){if(V[0]===255&&V[1]===254)return"utf-16le";if(V[0]===254&&V[1]===255)return"utf-16be"}return V.length>=3&&V[0]===239&&V[1]===187&&V[2]===191?"utf8":V.length>=4?V[0]===60&&V[1]===0&&V[2]===63&&V[3]===0?"utf-16le":V[0]===0&&V[1]===60&&V[2]===0&&V[3]===63?"utf-16be":"utf8":D?"utf8":null}function d(V,D){if(!(this instanceof d))return new d(V,D);a.apply(this),this._parser=new r(V,D),this.writable=!0,this.readable=!0;var N=this;this._parser.onend=function(){N.emit("end")},this._parser.onerror=function(q){N.emit("error",q),N._parser.error=null},this._decoder=null,this._decoderBuffer=null,l.forEach(function(q){Object.defineProperty(N,"on"+q,{get:function(){return N._parser["on"+q]},set:function(oe){if(!oe)return N.removeAllListeners(q),N._parser["on"+q]=oe,oe;N.on(q,oe)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(a.prototype,{constructor:{value:d}}),d.prototype._decodeBuffer=function(V,D){if(this._decoderBuffer&&(V=Buffer.concat([this._decoderBuffer,V]),this._decoderBuffer=null),!this._decoder){var N=u(V,D);if(!N)return this._decoderBuffer=V,"";this._parser.encoding=N,this._decoder=new TextDecoder(N)}return this._decoder.decode(V,{stream:!D})},d.prototype.write=function(V){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(V))V=this._decodeBuffer(V,!1);else if(this._decoderBuffer){var D=this._decodeBuffer(Buffer.alloc(0),!0);D&&(this._parser.write(D),this.emit("data",D))}return this._parser.write(V.toString()),this.emit("data",V),!0},d.prototype.end=function(V){if(V&&V.length&&this.write(V),this._decoderBuffer){var D=this._decodeBuffer(Buffer.alloc(0),!0);D&&(this._parser.write(D),this.emit("data",D))}else if(this._decoder){var N=this._decoder.decode();N&&(this._parser.write(N),this.emit("data",N))}return this._parser.end(),!0},d.prototype.on=function(V,D){var N=this;return!N._parser["on"+V]&&l.indexOf(V)!==-1&&(N._parser["on"+V]=function(){var q=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);q.splice(0,0,V),N.emit.apply(N,q)}),a.prototype.on.call(N,V,D)};var f="[CDATA[",h="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",m="http://www.w3.org/2000/xmlns/",g={xml:p,xmlns:m},y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,v=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function x(V){return V===" "||V===`
|
|
6
6
|
`||V==="\r"||V===" "}function A(V){return V==='"'||V==="'"}function T(V){return V===">"||x(V)}function I(V,D){return V.test(D)}function P(V,D){return!I(V,D)}var C=0;t.STATE={BEGIN:C++,BEGIN_WHITESPACE:C++,TEXT:C++,TEXT_ENTITY:C++,OPEN_WAKA:C++,SGML_DECL:C++,SGML_DECL_QUOTED:C++,DOCTYPE:C++,DOCTYPE_QUOTED:C++,DOCTYPE_DTD:C++,DOCTYPE_DTD_QUOTED:C++,COMMENT_STARTING:C++,COMMENT:C++,COMMENT_ENDING:C++,COMMENT_ENDED:C++,CDATA:C++,CDATA_ENDING:C++,CDATA_ENDING_2:C++,PROC_INST:C++,PROC_INST_BODY:C++,PROC_INST_ENDING:C++,OPEN_TAG:C++,OPEN_TAG_SLASH:C++,ATTRIB:C++,ATTRIB_NAME:C++,ATTRIB_NAME_SAW_WHITE:C++,ATTRIB_VALUE:C++,ATTRIB_VALUE_QUOTED:C++,ATTRIB_VALUE_CLOSED:C++,ATTRIB_VALUE_UNQUOTED:C++,ATTRIB_VALUE_ENTITY_Q:C++,ATTRIB_VALUE_ENTITY_U:C++,CLOSE_TAG:C++,CLOSE_TAG_SAW_WHITE:C++,SCRIPT:C++,SCRIPT_ENDING:C++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(V){var D=t.ENTITIES[V],N=typeof D=="number"?String.fromCharCode(D):D;t.ENTITIES[V]=N});for(var R in t.STATE)t.STATE[t.STATE[R]]=R;C=t.STATE;function k(V,D,N){V[D]&&V[D](N)}function L(V){var D=V&&V.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);return D?D[2]:null}function _(V){return V?V.toLowerCase().replace(/[^a-z0-9]/g,""):null}function O(V,D){const N=_(V),q=_(D);return!N||!q?!0:q==="utf16"?N==="utf16le"||N==="utf16be":N===q}function F(V,D){if(!(!V.strict||!V.encoding||!D||D.name!=="xml")){var N=L(D.body);N&&!O(V.encoding,N)&&Q(V,"XML declaration encoding "+N+" does not match detected stream encoding "+V.encoding.toUpperCase())}}function B(V,D,N){V.textNode&&U(V),k(V,D,N)}function U(V){V.textNode=M(V.opt,V.textNode),V.textNode&&k(V,"ontext",V.textNode),V.textNode=""}function M(V,D){return V.trim&&(D=D.trim()),V.normalize&&(D=D.replace(/\s+/g," ")),D}function z(V,D){return U(V),V.trackPosition&&(D+=`
|
|
7
7
|
Line: `+V.line+`
|
|
8
8
|
Column: `+V.column+`
|
|
@@ -88,7 +88,7 @@ Actual: `+V.attribValue);else{var oe=V.tag,J=V.tags[V.tags.length-1]||V;oe.ns===
|
|
|
88
88
|
`,`
|
|
89
89
|
`);ls({editor:e,partId:i.partId,operation:"mutate",source:`story-runtime:commit:${n.storyType}`,mutate({part:c}){JAe(c,i,n.noteId,l)}})}function V5t(e,t,n){const r=t?e.footnotes:e.endnotes;if(!Array.isArray(r))return null;const i=r.find(o=>String(o.id)===String(n));return i?Array.isArray(i.content)?Qy({type:"doc",content:i.content.length>0?i.content:[{type:"paragraph"}]}):i.doc&&typeof i.doc=="object"?Qy(i.doc):i.type==="doc"||i.type==="footnoteBody"||i.type==="endnoteBody"?Qy(i):null:null}function W5t(e,t,n,r){const i=HN(e,t.childElementName).find(s=>s.attributes?.["w:id"]===n);if(!i)return!1;const o=r;return JV(o,t.childElementName),i.elements=o,!0}var ZV=new WeakMap;function G5t(e){const t=ZV.get(e);if(t)return t;const n={counters:new Map};return ZV.set(e,n),n}function j5t(e){return ZV.get(e)}function q5t(e,t){const n=e.counters.get(t)??0;return String(n)}function Y5t(e,t){const n=(e.counters.get(t)??0)+1;return e.counters.set(t,n),String(n)}var cA=new WeakMap;function K5t(e){let t=cA.get(e);return t||(t=new Map,cA.set(e,t)),t}function ixe(e){const{runtime:t,editor:n}=e;return{...t,editor:n,cacheable:!1,commit:t.commitEditor==null?t.commit:r=>{t.commitEditor?.(r,n)}}}function X5t(e,t,n){const r=K5t(e),i=t.storyKey;return r.set(i,{storyKey:i,editor:n,runtime:t}),()=>{Z5t(e,i,n)}}function QV(e,t){const n=cA.get(e)?.get(t);return n?ixe(n):null}function J5t(e){const t=cA.get(e);if(!t||t.size===0)return 0;let n=0;for(const r of[...t.values()])ixe(r).commit?.(e),n+=1;return n}function Z5t(e,t,n){const r=cA.get(e);if(!r)return;const i=r.get(t);i&&(n&&i.editor!==n||(r.delete(t),r.size===0&&cA.delete(e)))}var Ok=new WeakMap,$V=new WeakMap;function Q5t(e,t){return $V.get(e)?.has(t)??!1}function $5t(e,t){let n=$V.get(e);n||(n=new Set,$V.set(e,n)),n.add(t)}function oxe(e){let t=Ok.get(e);return t||(t=new GMt,Ok.set(e,t),eOt(e)),t}function eOt(e){typeof e.on=="function"&&(e.on("notes-part-changed",()=>{const t=Ok.get(e);t&&(t.invalidateByPrefix("fn:"),t.invalidateByPrefix("en:"))}),e.on("partChanged",t=>{const n=Ok.get(e);n&&t.parts.some(r=>Zy(r.partId))&&n.invalidateByPrefix("hf:")}))}var tOt={kind:"story",storyType:"body"};function nOt(e){return{locator:tOt,storyKey:rh,editor:e,kind:"body"}}function nl(e,t,n={}){if(t===void 0||t.storyType==="body")return rOt(e);const r=Uo(t),i=QV(e,r);if(i)return i;const o=oxe(e),s=o.get(r);if(s)return s;let a;switch(t.storyType){case"headerFooterSlot":a=S5t(e,t,n);break;case"headerFooterPart":a=T5t(e,t);break;case"footnote":case"endnote":a=U5t(e,t);break;default:{const c=t;throw new De("INVALID_INPUT",`Unknown story type on locator: ${JSON.stringify(c)}`)}}JH(a.editor);const l=j5t(e);if(l){const c=q5t(l,r);_me(a.editor,c)}return ZH(a.editor),l&&!Q5t(a.editor,r)&&($5t(a.editor,r),a.editor.on("transaction",({transaction:c})=>{c.docChanged&&Y5t(l,r)})),a.cacheable!==!1&&o.set(r,a),a}function rOt(e){const t=oxe(e),n=t.get(rh);if(n)return n;const r=nOt(e);return t.set(rh,r),r}function iOt(e){return Ok.get(e)}function eW(e,t){const n=nl(e,t.in).editor.state.doc;return vN(n,0,n.content.size,`
|
|
90
90
|
`,`
|
|
91
|
-
`)}var oOt=vs({findChildren:()=>lxe,findInlineNodes:()=>cxe,findMarkPosition:()=>sxe,flatten:()=>axe},1);const sxe=(e,t,n)=>{const r=e.resolve(t),i=r.parent,o=i.childAfter(r.parentOffset);if(!o.node)return null;const s=o.node.marks.find(d=>d.type.name===n);if(!s)return null;let a=r.index(),l=r.start()+o.offset;for(;a>0&&s.isInSet(i.child(a-1).marks);)l-=i.child(--a).nodeSize;let c=r.index()+1,u=r.start()+o.offset+o.node.nodeSize;for(;c<i.childCount&&s.isInSet(i.child(c).marks);)u+=i.child(c++).nodeSize;return{from:l,to:u,attrs:s.attrs}},axe=(e,t=!0)=>{if(!e)throw new Error('Invalid "node" parameter');const n=[];return e.descendants((r,i)=>{if(n.push({node:r,pos:i}),!t)return!1}),n},lxe=(e,t,n)=>{if(e){if(!t)throw new Error('Invalid "predicate" parameter')}else throw new Error('Invalid "node" parameter');return axe(e,n).filter(r=>t(r.node))},cxe=(e,t)=>lxe(e,n=>n.isInline,t),Nc=(e,t=null)=>{const n=[];if(!e?.doc)return n;const r=cxe(e.doc);return r.length?(r.forEach(({node:i,pos:o})=>{const{marks:s}=i,a=[Zl,Os,Xa];s.length>0&&s.forEach(l=>{a.includes(l.type.name)&&n.push({mark:l,from:o,to:o+i.nodeSize})})}),t?n.filter(({mark:i})=>i.attrs.id===t):n):n};var sOt=24;function aOt(e){try{const t=Nc(e.state);return Array.isArray(t)?t:[]}catch{return[]}}function lOt(e){let t=2166136261,n=16777619,r=3735928559;for(let i=0;i<e.length;i++){const o=e.charCodeAt(i);t=Math.imul(t^o,16777619),n=Math.imul(n^o,1540483477),r=Math.imul(r^o,461845907)}return t=Math.imul(t^t>>>16,2246822507),n=Math.imul(n^n>>>16,3432918353),r=Math.imul(r^r>>>16,461845907),((t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")+(r>>>0).toString(16).padStart(8,"0")).slice(0,sOt)}function cOt(e,t){const n=tW(t),r=gN(e.state.doc.textBetween(t.from,t.to," ",""))??"",i=us(t.attrs.author)??"",o=us(t.attrs.authorEmail)??"",s=us(t.attrs.date)??"";return lOt(`${n}|${t.from}|${t.to}|${i}|${o}|${s}|${r}`)}function tW(e){return e.hasFormat?"format":e.hasDelete&&!e.hasInsert?"delete":"insert"}var uxe=new WeakMap;function dxe(e,t,n){return n?e?(e[t]||(e[t]=n),e):{[t]:n}:e}function uOt(e){return e==="trackInsert"?"insert":e==="trackDelete"?"delete":e==="trackFormat"?"format":null}function uA(e){const t=e.state.doc,n=uxe.get(e);if(n&&n.doc===t)return n.grouped;const r=aOt(e),i=new Map;for(const s of r){const a=s.mark?.attrs??{},l=us(a.id);if(!l)continue;const c=i.get(l),u=s.mark.type.name,d=u===Zl,f=u===Os,h=u===Xa,p=us(a.sourceId),m=uOt(u);if(!c){i.set(l,{rawId:l,from:s.from,to:s.to,hasInsert:d,hasDelete:f,hasFormat:h,attrs:{...a},wordRevisionIds:m?dxe(void 0,m,p??void 0):void 0});continue}c.from=Math.min(c.from,s.from),c.to=Math.max(c.to,s.to),c.hasInsert=c.hasInsert||d,c.hasDelete=c.hasDelete||f,c.hasFormat=c.hasFormat||h,Object.keys(c.attrs).length===0&&Object.keys(a).length>0&&(c.attrs={...a}),m&&(c.wordRevisionIds=dxe(c.wordRevisionIds,m,p??void 0))}const o=Array.from(i.values()).map(s=>({...s,id:cOt(e,s)})).sort((s,a)=>s.from!==a.from?s.from-a.from:s.id.localeCompare(a.id));return uxe.set(e,{doc:t,grouped:o}),o}function fxe(e,t){return uA(e).find(n=>n.id===t)??null}function hxe(e){const t=uA(e),n=new Map;for(const r of t)n.set(r.rawId,r.id),n.set(r.id,r.id);return n}function dOt(e){return typeof e=="string"?{kind:"entity",entityType:"trackedChange",entityId:e}:e}function zN(e,t){const n=dOt(t),r=n.entityId,i=n.story??{kind:"story",storyType:"body"};if((n.story?Uo(n.story):"body")==="body"){const a=pxe(e,r);return a?{editor:e,story:i,runtimeRef:{storyKey:rh,rawId:a.rawId},change:a}:null}let o;try{o=nl(e,i)}catch{return null}const s=pxe(o.editor,r);return s?{editor:o.editor,story:o.locator,runtimeRef:{storyKey:o.storyKey,rawId:s.rawId},change:s,commit:o.commit}:null}function pxe(e,t){return uA(e).find(n=>n.id===t||n.rawId===t)??null}const mxe=["structuredContent","structuredContentBlock"],Fk="structuredContentBlock";function Bk(e){return mxe.includes(e.type.name)}function dA(e){const t=[];return e.descendants((n,r)=>(Bk(n)&&t.push({node:n,pos:r,kind:n.type.name==="structuredContentBlock"?"block":"inline"}),!0)),t}function xn(e,t){const n=t.nodeId,r=dA(e).filter(i=>String(i.node.attrs.id)===n);if(r.length===0)throw new De("TARGET_NOT_FOUND",`Content control with id "${n}" not found.`,{target:t});if(r.length>1)throw new De("AMBIGUOUS_TARGET",`Multiple content controls found with id "${n}".`,{target:t,count:r.length});return r[0]}function fa(e,t){return e?.elements?.find(n=>n.name===t)}function gxe(e,t){return fa(e,t)?.attributes}function UN(e,t,n){const r=e.elements?[...e.elements]:[],i=r.findIndex(o=>o.name===t);return i>=0?r[i]=n:r.push(n),{...e,elements:r}}function yxe(e,t){return e.elements?{...e,elements:e.elements.filter(n=>n.name!==t)}:e}var fOt=new Set(mxe);function $y(e,t,n){if(!e?.state)return!1;let r=null;if(e.state.doc.descendants((o,s)=>r!==null?!1:fOt.has(o.type.name)&&String(o.attrs.id)===String(t)?(r=s,!1):!0),r===null)return!1;const i=e.state.tr;for(const[o,s]of Object.entries(n))i.setNodeAttribute(r,o,s);if(i.steps.length===0)return!0;if(e.view?.dispatch)e.view.dispatch(i);else if(typeof e.dispatch=="function")e.dispatch(i);else return!1;return!0}function ef(e,t,n,r){const i=xn(e.state.doc,t).node.attrs.sdtPr??{name:"w:sdtPr",elements:[]},o=r(fa(i,n));let s;return o===null?s=yxe(i,n):s=UN(i,n,o),$y(e,t.nodeId,{sdtPr:s})}function nW(e,t,n,r,i,o){return ef(e,t,n,s=>{const a=s??{name:n,type:"element",elements:[]},l=a.elements?[...a.elements]:[],c=l.findIndex(d=>d.name===r),u={name:r,type:"element",attributes:{[i]:o}};return c>=0?l[c]={...l[c],attributes:{...l[c].attributes??{},[i]:o}}:l.push(u),{...a,elements:l}})}function hOt(e,t,n,r){return ef(e,t,n,i=>({name:n,type:"element",...i,elements:r}))}var pOt=["text","richText","date","checkbox","comboBox","dropDownList","repeatingSection","repeatingSectionItem","group"],mOt=["unlocked","sdtLocked","contentLocked","sdtContentLocked"],gOt=["boundingBox","tags","hidden"];function kp(e){const t=e.controlType??e.type;return typeof t=="string"&&pOt.includes(t)?t:"unknown"}function VN(e){const t=e.lockMode;return typeof t=="string"&&mOt.includes(t)?t:"unlocked"}function bxe(e){const t=e.appearance;if(typeof t=="string"&&gOt.includes(t))return t}function vxe(e){const t=e.sdtPr;if(!t)return;const n=gxe(t,"w:dataBinding");if(!n)return;const r=n["w:storeItemID"],i=n["w:xpath"];if(!(!r||!i))return{storeItemId:r,xpath:i,prefixMappings:n["w:prefixMappings"]}}function Ni(e){return{kind:e.kind,nodeType:"sdt",nodeId:String(e.node.attrs.id??"")}}function rW(e){const t=(fa(e,"w14:checkbox")??fa(e,"w:checkbox"))?.elements?.find(r=>r.name==="w14:checked"||r.name==="w:checked"),n=t?.attributes?.["w14:val"]??t?.attributes?.["w:val"];return n==="1"||n==="true"||n===!0}function iW(e,t){const n=fa(e,`w:${t}`);return{items:(n?.elements?.filter(r=>r.name==="w:listItem")??[]).map(r=>({displayText:String(r.attributes?.["w:displayText"]??""),value:String(r.attributes?.["w:value"]??"")})),selectedValue:n?.attributes?.["w:lastValue"]}}function yOt(e,t){if(!t)return{};switch(e){case"text":{const n=gxe(t,"w:text");if(!n)return{};const r=n["w:multiLine"];return{multiline:r==="1"||r==="true"||r===!0}}case"date":{const n=fa(t,"w:date");if(!n)return{};const r=fa(n,"w:dateFormat"),i=fa(n,"w:lid"),o=fa(n,"w:storeMappedDataAs"),s=fa(n,"w:calendar");return{dateFormat:r?.attributes?.["w:val"],dateLocale:i?.attributes?.["w:val"],storageFormat:o?.attributes?.["w:val"],calendar:s?.attributes?.["w:val"]}}case"checkbox":{const n=fa(t,"w14:checkbox")??fa(t,"w:checkbox");if(!n)return{};const r=n.elements?.find(o=>o.name==="w14:checkedState"),i=n.elements?.find(o=>o.name==="w14:uncheckedState");return{checked:rW(t),checkedSymbol:r?{font:String(r.attributes?.["w14:font"]??""),char:String(r.attributes?.["w14:val"]??"")}:void 0,uncheckedSymbol:i?{font:String(i.attributes?.["w14:font"]??""),char:String(i.attributes?.["w14:val"]??"")}:void 0}}case"comboBox":case"dropDownList":return iW(t,e);case"repeatingSection":{const n=fa(t,"w15:repeatingSection")??fa(t,"w:repeatingSection");if(!n)return{};const r=n.elements?.find(o=>o.name==="w15:allowInsertDeleteSection"||o.name==="w:allowInsertDeleteSection"),i=r?.attributes?.["w15:val"]??r?.attributes?.["w:val"];return{allowInsertDelete:i==="1"||i==="true"||i===!0}}default:return{}}}function Ig(e){const t=e.node.attrs,n=String(t.id??""),r=kp(t),i=VN(t),o=typeof t.sdtPr=="object"&&t.sdtPr!==null?t.sdtPr:void 0;let s;try{s=e.node.textContent||void 0}catch{s=void 0}const a=yOt(r,o);return{nodeType:"sdt",kind:e.kind,id:n,controlType:r,lockMode:i,properties:{tag:typeof t.tag=="string"?t.tag:void 0,alias:typeof t.alias=="string"?t.alias:void 0,appearance:bxe(t),placeholder:typeof t.placeholder=="string"?t.placeholder:void 0,color:typeof t.color=="string"?t.color:void 0,showingPlaceholder:typeof t.showingPlaceholder=="boolean"?t.showingPlaceholder:void 0,temporary:typeof t.temporary=="boolean"?t.temporary:void 0,tabIndex:typeof t.tabIndex=="number"?t.tabIndex:void 0,...a},binding:vxe(t),raw:o,target:{kind:e.kind,nodeType:"sdt",nodeId:n},text:s}}function bOt(e,t){const n=e??{},r=String(n.id??"");return{nodeType:"sdt",kind:t,id:r,controlType:kp(n),lockMode:VN(n),properties:{tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,appearance:bxe(n),placeholder:typeof n.placeholder=="string"?n.placeholder:void 0,color:typeof n.color=="string"?n.color:void 0,showingPlaceholder:typeof n.showingPlaceholder=="boolean"?n.showingPlaceholder:void 0,temporary:typeof n.temporary=="boolean"?n.temporary:void 0,tabIndex:typeof n.tabIndex=="number"?n.tabIndex:void 0},target:{kind:t,nodeType:"sdt",nodeId:r}}}function rl(e,t){const n=VN(e.node.attrs);if(n==="sdtLocked"||n==="sdtContentLocked")throw new De("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function sh(e,t){const n=VN(e.node.attrs);if(n==="contentLocked"||n==="sdtContentLocked")throw new De("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function ha(e,t,n){const r=kp(e.node.attrs),i=Array.isArray(t)?t:[t];if(!i.includes(r))throw new De("TYPE_MISMATCH",`Operation "${n}" requires control type ${i.join(" or ")}, but found "${r}".`,{expected:i,actual:r,operation:n})}function wxe(e,t){const n={success:!0,contentControl:e};return t&&(n.updatedRef=t),n}function ah(e,t){return{success:!1,failure:{code:e,message:t}}}function Hk(e,t){const n=e.length,r=t?.offset??0,i=t?.limit??n;return{items:e.slice(r,r+i),total:n}}function zk(e,t){const n=Kn(e).candidates.filter(r=>r.nodeId===t&&(r.nodeType==="paragraph"||r.nodeType==="listItem"));if(n.length===0)throw new De("TARGET_NOT_FOUND","Block target was not found.",{nodeId:t});if(n.length>1)throw new De("INVALID_TARGET","Block target id is ambiguous.",{nodeId:t,count:n.length});return n[0]}function Axe(e,t,n){const r=zk(e,t),i=zk(e,n);if(r.pos>i.pos)throw new De("INVALID_TARGET",'Block range "from" must precede "to" in document order.',{from:t,to:n});return Kn(e).candidates.filter(o=>(o.nodeType==="paragraph"||o.nodeType==="listItem")&&o.pos>=r.pos&&o.pos<=i.pos)}function td(e,t){const n=e.converter?.numbering?.definitions;if(!n)return;const r=n[t];if(!r?.elements)return;const i=r.elements.find(o=>o.name==="w:abstractNumId")?.attributes?.["w:val"];return i!=null?Number(i):void 0}function fA(e){return Kn(e).candidates.filter(t=>t.nodeType==="listItem").map(t=>WN(e,t))}function il(e,t){if(t.numId==null)return[t];const n=fA(e),r=n.findIndex(a=>a.address.nodeId===t.address.nodeId);if(r===-1)return[t];const i=t.numId;let o=r;for(let a=r-1;a>=0&&n[a].numId===i;a--)o=a;let s=r;for(let a=r+1;a<n.length&&n[a].numId===i;a++)s=a;return n.slice(o,s+1)}function xxe(e,t){const n=il(e,t),r=n.findIndex(i=>i.address.nodeId===t.address.nodeId);return n.slice(r)}function Sxe(e,t){const n=il(e,t);return n.length>0&&n[0].address.nodeId===t.address.nodeId}function vOt(e,t){if(t.numId==null)return"";const n=il(e,t)[0]?.address.nodeId??t.address.nodeId;return`${t.numId}:${n}`}function Txe(e){const t=new Map;let n,r;for(const i of e){if(i.numId==null){t.set(i.address.nodeId,""),n=void 0,r=void 0;continue}i.numId!==n&&(n=i.numId,r=i.address.nodeId),t.set(i.address.nodeId,`${n}:${r}`)}return t}function hA(e,t,n){if(t.numId==null)return null;const r=fA(e),i=il(e,t);if(n==="withNext"){const o=i[i.length-1],s=r.findIndex(a=>a.address.nodeId===o.address.nodeId);for(let a=s+1;a<r.length;a++){const l=r[a];if(l.numId!=null)return{sequence:il(e,l),numId:l.numId,abstractNumId:td(e,l.numId)}}}else{const o=i[0],s=r.findIndex(a=>a.address.nodeId===o.address.nodeId);for(let a=s-1;a>=0;a--){const l=r[a];if(l.numId!=null)return{sequence:il(e,l),numId:l.numId,abstractNumId:td(e,l.numId)}}}return null}function wOt(e,t){if(t.numId==null)return null;const n=td(e,t.numId);if(n==null)return null;const r=fA(e),i=il(e,t)[0],o=r.findIndex(s=>s.address.nodeId===i.address.nodeId);for(let s=o-1;s>=0;s--){const a=r[s];if(a.numId!=null&&td(e,a.numId)===n&&a.numId!==t.numId)return{sequence:il(e,a),numId:a.numId}}return null}function Ixe(e,t,n){const r=hA(e,t,n);if(!r)return{canJoin:!1,reason:"NO_ADJACENT_SEQUENCE"};if(r.numId===t.numId)return{canJoin:!1,reason:"ALREADY_SAME_SEQUENCE"};const i=t.numId!=null?td(e,t.numId):void 0;if(i==null||r.abstractNumId==null||i!==r.abstractNumId)return{canJoin:!1,reason:"INCOMPATIBLE_DEFINITIONS"};const o=r.sequence[0]?.address.nodeId??"";return{canJoin:!0,adjacentListId:`${r.numId}:${o}`}}function kxe(e,t){if(t.numId==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const n=td(e,t.numId);if(n==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const r=fA(e),i=il(e,t)[0],o=r.findIndex(a=>a.address.nodeId===i.address.nodeId);let s=!1;for(let a=o-1;a>=0;a--){const l=r[a];if(l.numId==null||(s=!0,td(e,l.numId)!==n))continue;if(l.numId===t.numId)return{canContinue:!1,reason:"ALREADY_CONTINUOUS"};const c=il(e,l)[0]?.address.nodeId??l.address.nodeId;return{canContinue:!0,previousListId:`${l.numId}:${c}`}}return s?{canContinue:!1,reason:"INCOMPATIBLE_DEFINITIONS"}:{canContinue:!1,reason:"NO_PREVIOUS_LIST"}}function AOt(e){const t=e.attrs??{},n=t.paragraphProperties?.numberingProperties??void 0,r=t.numberingProperties??void 0;return{numId:pN(n?.numId??r?.numId),level:pN(n?.ilvl??r?.ilvl)}}function xOt(e,t,n){if(!(t==null||n==null||!e.converter))try{const r=Gn.getListDefinitionDetails({numId:t,level:n,listType:void 0,editor:e}),i=typeof r?.listNumberingType=="string"?r.listNumberingType:void 0;return i==="bullet"?"bullet":typeof i=="string"&&i.length>0?"ordered":void 0}catch{return}}function SOt(e,t,n,r){const i=(t.node.attrs??{}).listRendering?.numberingType;return i==="bullet"?"bullet":typeof i=="string"&&i.length>0?"ordered":xOt(e,n,r)}function TOt(e){const t=e.node.textContent;return typeof t=="string"?t:void 0}function WN(e,t){const n=t.node.attrs??{},{numId:r,level:i}=AOt(t.node),o=N1(n.listRendering),s=o?.path,a=Q8(s),l=o?.markerText;return{candidate:t,address:{kind:"block",nodeType:"listItem",nodeId:t.nodeId},numId:r,level:i,kind:SOt(e,t,r,i),marker:l,path:s,ordinal:a,text:TOt(t)}}function Exe(e,t){return{address:e.address,listId:t,marker:e.marker,ordinal:e.ordinal,path:e.path,level:e.level,kind:e.kind,text:e.text}}function IOt(e,t){return t?!(t.kind&&e.kind!==t.kind||t.level!=null&&e.level!==t.level||t.ordinal!=null&&e.ordinal!==t.ordinal):!0}function kOt(e,t){if(!t)return;const n=e.candidates.filter(r=>r.nodeType===t.nodeType&&r.nodeId===t.nodeId);if(n.length===0)throw new De("TARGET_NOT_FOUND","List scope block was not found.",{within:t});if(n.length>1)throw new De("INVALID_TARGET","List scope block id is ambiguous.",{within:t,count:n.length});return{start:n[0].pos,end:n[0].end}}function EOt(e,t){return t?e.pos>=t.start&&e.end<=t.end:!0}function COt(e,t){if(t?.within&&t.within.kind!=="block")throw new De("INVALID_TARGET","lists.list only supports block within scopes.",{within:t.within});wg(t?.offset,t?.limit);const n=Kn(e),r=kOt(n,t?.within),i=n.candidates.filter(f=>f.nodeType==="listItem").map(f=>WN(e,f)),o=i.filter(f=>EOt(f.candidate,r)),s=t?.offset??0,a=s+(t?.limit??Number.POSITIVE_INFINITY),l=sr(e),c=Txe(i);let u=0;const d=[];for(const f of o){if(!IOt(f,t))continue;const h=u;if(u+=1,h<s||h>=a)continue;const p=c.get(f.address.nodeId)??"",m=Exe(f,p),g=Ho(m.address.nodeId,"stable","list"),{address:y,marker:v,ordinal:b,path:w,level:x,kind:A,text:T}=m;d.push(rs(m.address.nodeId,g,{address:y,listId:p,marker:v,ordinal:b,path:w,level:x,kind:A,text:T}))}return Yo({evaluatedRevision:l,total:u,items:d,page:{limit:t?.limit??u,offset:s,returned:d.length}})}function Jo(e,t){const n=Kn(e).candidates.filter(r=>r.nodeType==="listItem"&&r.nodeId===t.nodeId);if(n.length===0)throw new De("TARGET_NOT_FOUND","List item target was not found.",{target:t});if(n.length>1)throw new De("INVALID_TARGET","List item target id is ambiguous.",{target:t,count:n.length});return WN(e,n[0])}var _Ot=new Set(["text","date","checkbox","comboBox","dropDownList"]),Cxe=new WeakMap;function POt(e){const t=e.state.doc,n=Cxe.get(e),r=Lxe(e);if(n&&n.doc===t)return _xe(n.counts,r);const i=ROt(e);return Cxe.set(e,{doc:t,counts:i}),_xe(i,r)}function ROt(e){const t=eW(e,{}),n=Kn(e),r=vg(e),i=LOt(n),o=NOt(r);return{words:Pxe(t),characters:t.length,paragraphs:i.paragraphs,headings:i.headings,tables:i.tables,images:i.blockImages+o,comments:MOt(r),trackedChanges:DOt(e),sdtFields:OOt(e),lists:FOt(e,n)}}function _xe(e,t){return t!=null?{...e,pages:t}:{...e}}function Pxe(e){const t=e.trim().match(/\S+/g);return t?t.length:0}function LOt(e){let t=0,n=0,r=0,i=0;for(const o of e.candidates)switch(o.nodeType){case"paragraph":t++;break;case"heading":n++;break;case"table":r++;break;case"image":i++;break}return{paragraphs:t,headings:n,tables:r,blockImages:i}}function NOt(e){return e.byType.get("image")?.length??0}function MOt(e){const t=e.byType.get("comment")??[],n=new Set;for(const r of t){const i=mN(r.attrs??{});i&&n.add(i)}return n.size}function DOt(e){return uA(e).length}function OOt(e){return dA(e.state.doc).filter(t=>_Ot.has(kp(t.node.attrs??{}))).length}function FOt(e,t){const n=BOt(e,t);if(n.length===0)return 0;const r=Txe(n);let i=0,o,s;for(const a of n){const l=r.get(a.address.nodeId)??"";if(l){l!==o&&(i+=1),o=l,s=void 0;continue}o=void 0,(!s||HOt(s,a))&&(i+=1),s=a}return i}function BOt(e,t){return t.candidates.filter(n=>n.nodeType==="listItem").map(n=>WN(e,n))}function HOt(e,t){return zOt(e,t)?!0:UOt(e,t)}function zOt(e,t){return e.kind!=null&&t.kind!=null&&e.kind!==t.kind}function UOt(e,t){const n=Rxe(e),r=Rxe(t);return n==null||r==null||n!==r||e.ordinal==null||t.ordinal==null?!1:t.ordinal<=e.ordinal}function Rxe(e){return e.level!=null?e.level:e.path&&e.path.length>0?e.path.length-1:void 0}function Lxe(e){return e.currentTotalPages}function pA(e){const t=eW(e,{});return{words:Pxe(t),characters:VOt(t),charactersWithSpaces:WOt(t),pages:Lxe(e)}}function GN(e,t){switch(e){case"NUMWORDS":return String(t.words);case"NUMCHARS":return String(t.characters);case"NUMPAGES":return t.pages!=null?String(t.pages):null;default:return null}}function eb(e){return e.options?.parentEditor??e}function VOt(e){return e.replace(/\s/g,"").length}function WOt(e){return e.replace(/\n/g,"").length}function Nxe(e){const t=new Map,n=pA(eb(e));for(const r of["NUMWORDS","NUMCHARS","NUMPAGES"]){const i=GN(r,n);i!=null&&t.set(r,i)}return t}const oW="http://schemas.openxmlformats.org/officeDocument/2006/bibliography",GOt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",jOt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";var Mxe="/APA.XSL",Dxe="APA",Oxe="6",Fxe=Object.freeze({book:"Book",journalArticle:"JournalArticle",conferenceProceedings:"ConferenceProceedings",report:"Report",website:"InternetSite",patent:"Patent",case:"Case",statute:"Case",thesis:"Report",film:"Film",interview:"Interview",misc:"Misc"}),qOt=Object.freeze({book:"book",journalarticle:"journalArticle",conferenceproceedings:"conferenceProceedings",report:"report",internetsite:"website",documentfrominternetsite:"website",articleinaperiodical:"journalArticle",patent:"patent",case:"case",statute:"statute",thesis:"thesis",film:"film",interview:"interview",misc:"misc"}),sW=Object.freeze({title:"Title",year:"Year",publisher:"Publisher",city:"City",journalName:"JournalName",volume:"Volume",issue:"Issue",pages:"Pages",url:"URL",doi:"DOI",edition:"Edition",medium:"Medium",shortTitle:"ShortTitle",standardNumber:"StandardNumber"}),YOt=Object.freeze(Object.fromEntries(Object.entries(sW).map(([e,t])=>[t,e])));function kg(e){if(!e||typeof e!="string")return"";const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function jN(e){if(!e?.elements?.length)return"";const t=e.elements.find(n=>n?.type==="text");return typeof t?.text=="string"?t.text.trim():""}function mA(e,t){return{type:"element",name:e,elements:[{type:"text",text:String(t)}]}}function qN(e,t){const n=t??uV;return{declaration:{...n,attributes:{...n.attributes}},elements:[e]}}function Bxe(e,t){if(e?.elements?.length){for(const n of e.elements)if(!(!n||n.type!=="element")){if(kg(n.name)==="Person"){t.push(n);continue}Bxe(n,t)}}}function KOt(e){const t={};for(const n of e?.elements??[]){if(!n||n.type!=="element")continue;const r=kg(n.name),i=jN(n);i&&(r==="First"&&(t.first=i),r==="Middle"&&(t.middle=i),r==="Last"&&(t.last=i))}return typeof t.last=="string"&&t.last.length>0?t:null}function aW(e,t){const n=(e?.elements??[]).find(i=>i?.type==="element"&&kg(i.name)===t);if(!n)return[];const r=[];return Bxe(n,r),r.map(KOt).filter(Boolean)}function XOt(e){if(!e||typeof e.last!="string"||e.last.trim().length===0)return null;const t=[],n=e.last.trim(),r=typeof e.first=="string"?e.first.trim():"",i=typeof e.middle=="string"?e.middle.trim():"";return n&&t.push(mA("b:Last",n)),r&&t.push(mA("b:First",r)),i&&t.push(mA("b:Middle",i)),{type:"element",name:"b:Person",elements:t}}function JOt(e){const t=(e??[]).map(XOt).filter(Boolean);return t.length===0?null:{type:"element",name:"b:NameList",elements:t}}function lW(e,t){const n=JOt(t);return n?e==="Author"?{type:"element",name:"b:Author",elements:[{type:"element",name:"b:Author",elements:[n]}]}:{type:"element",name:`b:${e}`,elements:[n]}:null}function ZOt(e){return Fxe[typeof e=="string"?e.trim():""]??Fxe.misc}function QOt(e){return qOt[typeof e=="string"?e.trim().toLowerCase():""]??"misc"}function cW(e){if(!e||typeof e!="object")return null;const t=e.tag??e.sourceId,n=typeof t=="string"?t.trim():"";if(!n)return null;const r=typeof e.type=="string"?e.type:"misc",i=e.fields&&typeof e.fields=="object"?e.fields:{},o={};for(const s of Object.keys(sW)){const a=i[s];typeof a=="string"&&a.trim().length>0&&(o[s]=a.trim())}for(const s of["authors","editor","translator"]){const a=i[s];if(!Array.isArray(a))continue;const l=a.map(c=>{if(!c||typeof c!="object")return null;const u={first:typeof c.first=="string"?c.first.trim():void 0,middle:typeof c.middle=="string"?c.middle.trim():void 0,last:typeof c.last=="string"?c.last.trim():void 0};return u.last?u:null}).filter(Boolean);l.length>0&&(o[s]=l)}return{tag:n,type:r,fields:o}}function $Ot(e){const t={};let n="",r="misc";for(const a of e?.elements??[]){if(!a||a.type!=="element")continue;const l=kg(a.name);if(l==="Tag"){n=jN(a);continue}if(l==="SourceType"){r=QOt(jN(a));continue}const c=YOt[l];if(!c)continue;const u=jN(a);u&&(t[c]=u)}const i=aW(e,"Author");i.length>0&&(t.authors=i);const o=aW(e,"Editor");o.length>0&&(t.editor=o);const s=aW(e,"Translator");return s.length>0&&(t.translator=s),cW({tag:n,type:r,fields:t})}function e6t(e){const t=cW(e);if(!t)return null;const n=[mA("b:Tag",t.tag),mA("b:SourceType",ZOt(t.type))];for(const[s,a]of Object.entries(sW)){const l=t.fields?.[s];typeof l!="string"||l.length===0||n.push(mA(`b:${a}`,l))}const r=lW("Author",t.fields?.authors);r&&n.push(r);const i=lW("Editor",t.fields?.editor);i&&n.push(i);const o=lW("Translator",t.fields?.translator);return o&&n.push(o),{type:"element",name:"b:Source",elements:n}}function t6t(e){if(!e||e.type!=="element"||kg(e.name)!=="Sources")return!1;const t=e.attributes?.xmlns,n=e.attributes?.["xmlns:b"];return t==="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"||n==="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"}function Hxe(e){const t=/customXml\/item(\d+)\.xml$/i.exec(e||"");return t?Number.parseInt(t[1],10):null}function n6t(e){return e.startsWith("customXml/")?`../${e}`:e}function r6t(e){const t=e?.["word/_rels/document.xml.rels"];return t?.elements?.length&&t.elements.find(n=>kg(n.name)==="Relationships")||null}function i6t(e){e["word/_rels/document.xml.rels"]||(e["word/_rels/document.xml.rels"]=qN({type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]}));const t=e["word/_rels/document.xml.rels"];t.elements??=[];let n=t.elements.find(r=>kg(r.name)==="Relationships");return n||(n={type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]},t.elements.push(n)),n.elements??=[],n}function o6t(e){const t=(e?.elements??[]).map(n=>{const r=n?.attributes?.Id;if(typeof r!="string")return NaN;const i=/^rId(\d+)$/.exec(r);return i?Number.parseInt(i[1],10):NaN}).filter(n=>Number.isFinite(n));return`rId${(t.length>0?Math.max(...t):0)+1}`}function s6t(e){const t=new Set;for(const r of Object.keys(e??{})){const i=/customXml\/item(\d+)\.xml$/i.exec(r);i&&t.add(Number.parseInt(i[1],10));const o=/customXml\/itemProps(\d+)\.xml$/i.exec(r);o&&t.add(Number.parseInt(o[1],10))}let n=1;for(;t.has(n);)n+=1;return n}function a6t(e,t){const n=e.map(e6t).filter(Boolean),r=t.selectedStyle||Mxe,i=t.styleName||Dxe,o=t.version||Oxe;return{type:"element",name:"b:Sources",attributes:{"xmlns:b":oW,xmlns:oW,SelectedStyle:r,StyleName:i,Version:o},elements:n}}function l6t(e){const t=e?.elements?.[0]?.attributes?.["ds:itemID"];return typeof t=="string"&&t.length>0?t:null}function c6t(e){return{type:"element",name:"ds:datastoreItem",attributes:{"ds:itemID":e,"xmlns:ds":"http://schemas.openxmlformats.org/officeDocument/2006/customXml"},elements:[{type:"element",name:"ds:schemaRefs",elements:[{type:"element",name:"ds:schemaRef",attributes:{"ds:uri":oW}}]}]}}function u6t(e){return{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[{type:"element",name:"Relationship",attributes:{Id:"rId1",Type:jOt,Target:e}}]}}function zxe(e){const t=new Map;for(const n of e){const r=cW(n);r&&t.set(r.tag,r)}return Array.from(t.values())}function uW(){return{sources:[],partPath:null,itemPropsPath:null,itemRelsPath:null,selectedStyle:null,styleName:null,version:null}}function Uxe(e){const t=uW(),n=r6t(e);if(!n?.elements?.length)return t;const r=[];for(const i of n.elements){if(i?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml")continue;const o=i?.attributes?.Target,s=ip(o,"word");if(!s)continue;const a=e?.[s]?.elements?.[0];if(t6t(a)){if(!t.partPath){t.partPath=s,t.selectedStyle=a.attributes?.SelectedStyle??null,t.styleName=a.attributes?.StyleName??null,t.version=a.attributes?.Version??null;const l=Hxe(s);if(l!=null){const c=`customXml/itemProps${l}.xml`,u=`customXml/_rels/item${l}.xml.rels`;t.itemPropsPath=e[c]?c:null,t.itemRelsPath=e[u]?u:null}}for(const l of a.elements??[]){if(!l||l.type!=="element"||kg(l.name)!=="Source")continue;const c=$Ot(l);c&&r.push(c)}}}return t.sources=zxe(r),t}function d6t(e,t){const n=Uxe(e),r=zxe(Array.isArray(t?.sources)?t.sources:[]);if(r.length===0&&!n.partPath)return{...uW(),sources:[]};const i=t?.partPath||n.partPath,o=Hxe(i),s=o??s6t(e),a=o?i:`customXml/item${s}.xml`,l=`customXml/itemProps${s}.xml`,c=`customXml/_rels/item${s}.xml.rels`,u=t?.selectedStyle??n.selectedStyle??Mxe,d=t?.styleName??n.styleName??Dxe,f=t?.version??n.version??Oxe,h=e[a]?.declaration;e[a]=qN(a6t(r,{selectedStyle:u,styleName:d,version:f}),h);const p=i6t(e),m=n6t(a);p.elements.some(b=>b?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"?!1:ip(b?.attributes?.Target,"word")===a)||p.elements.push({type:"element",name:"Relationship",attributes:{Id:o6t(p),Type:GOt,Target:m}});const g=e[l],y=g?.declaration;e[l]=qN(c6t(l6t(g)||`{${yn().toUpperCase()}}`),y);const v=e[c]?.declaration;return e[c]=qN(u6t(`itemProps${s}.xml`),v),{sources:r,partPath:a,itemPropsPath:l,itemRelsPath:c,selectedStyle:u,styleName:d,version:f}}function f6t(e){return[e?.partPath,e?.itemPropsPath,e?.itemRelsPath].filter(t=>typeof t=="string"&&t.length>0)}var h6t=Kc(Mm(),1),p6t=Object.freeze({swiss:"Arial, sans-serif",roman:"Times New Roman, serif",modern:"Courier New, monospace",script:"cursive",decorative:"fantasy",system:"system-ui",auto:"sans-serif"}),Vxe="sans-serif",m6t=10,g6t="1.34.0-next.6",Wxe=(e,{allowOverrideTypeface:t=!0,allowOverrideSize:n=!0,themeResolver:r,state:i})=>{if(!e?.elements?.length||!i)return;const o=e.elements.find(l=>l.name==="w:rFonts");if(o?.attributes){const l=o.attributes["w:asciiTheme"];if(l){const u=r?.(l)||{};(t||!i.typeface)&&u.typeface&&(i.typeface=u.typeface),(t||!i.panose)&&u.panose&&(i.panose=u.panose)}const c=o.attributes["w:ascii"];(t||!i.typeface)&&c&&(i.typeface=c)}const s=e.elements.find(l=>l.name==="w:sz");if(s?.attributes?.["w:val"]){const l=Number(s.attributes["w:val"]);if(Number.isFinite(l)){i.fallbackSzTwips===void 0&&(i.fallbackSzTwips=l);const c=l/2;(n||i.fontSizePt===void 0)&&(i.fontSizePt=c)}}const a=e.elements.find(l=>l.name==="w:kern");a?.attributes?.["w:val"]&&(n||i.kern===void 0)&&(i.kern=a.attributes["w:val"])},nd=class No{static allowedElements=Object.freeze({"w:document":"doc","w:body":"body","w:p":"paragraph","w:r":"run","w:t":"text","w:delText":"text","w:br":"lineBreak","w:tbl":"table","w:tr":"tableRow","w:tc":"tableCell","w:drawing":"drawing","w:bookmarkStart":"bookmarkStart","w:sectPr":"sectionProperties","w:rPr":"runProperties","w:commentRangeStart":"commentRangeStart","w:commentRangeEnd":"commentRangeEnd","w:commentReference":"commentReference"});static markTypes=[{name:"w:b",type:"bold",property:"value"},{name:"w:i",type:"italic"},{name:"w:u",type:"underline",mark:"underline",property:"underlineType"},{name:"w:strike",type:"strike",mark:"strike",property:"value"},{name:"w:color",type:"color",mark:"textStyle",property:"color"},{name:"w:sz",type:"fontSize",mark:"textStyle",property:"fontSize"},{name:"w:rFonts",type:"fontFamily",mark:"textStyle",property:"fontFamily"},{name:"w:rStyle",type:"styleId",mark:"textStyle",property:"styleId"},{name:"w:jc",type:"textAlign",mark:"textStyle",property:"textAlign"},{name:"w:ind",type:"textIndent",mark:"textStyle",property:"textIndent"},{name:"w:spacing",type:"lineHeight",mark:"textStyle",property:"lineHeight"},{name:"w:spacing",type:"letterSpacing",mark:"textStyle",property:"letterSpacing"},{name:"link",type:"link",mark:"link",property:"href"},{name:"w:highlight",type:"highlight",mark:"highlight",property:"color"},{name:"w:shd",type:"highlight",mark:"highlight",property:"color"},{name:"w:caps",type:"textTransform",mark:"textStyle",property:"textTransform"}];static propertyTypes=Object.freeze({"w:pPr":"paragraphProperties","w:rPr":"runProperties","w:sectPr":"sectionProperties","w:numPr":"numberingProperties","w:tcPr":"tableCellProperties"});static elements=new Set(["w:document","w:body","w:p","w:r","w:t","w:delText"]);static getFontTableEntry(t,n){if(!t||!n)return null;const r=t["word/fontTable.xml"];if(!r?.elements?.length)return null;const i=r.elements.find(o=>o.name==="w:fonts");return i?.elements?.length&&i.elements.find(o=>o?.attributes?.["w:name"]===n)||null}static getFallbackFromFontTable(t,n){const r=No.getFontTableEntry(t,n)?.elements?.find(i=>i.name==="w:family")?.attributes?.["w:val"];return r?p6t[r.toLowerCase()]||Vxe:null}static toCssFontFamily(t,n){if(!t||t.includes(","))return t;const r=No.getFallbackFromFontTable(n,t)||Vxe;return r.split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).includes(t.trim().toLowerCase())?r:`${t}, ${r}`}constructor(t=null){this.debug=t?.debug||!1,this.domEnvironment={mockWindow:t?.mockWindow||null,mockDocument:t?.mockDocument||null},this.declaration=null,this.documentAttributes=null,this.convertedXml={},this.docx=t?.docx||[],this.media=t?.media||{},this.fonts=t?.fonts||{},this.trackedChangesOptions=t?.trackedChangesOptions||null,this.addedMedia={},this.comments=[],this.footnotes=[],this.footnoteProperties=null,this.bibliographyPart=uW(),this.viewSetting=null,this.inlineDocumentFonts=[],this.commentThreadingProfile=null,this.exportWarnings=[],this.docHiglightColors=new Set([]),this.xml=t?.xml,this.declaration=null,this.numbering={},this.translatedNumbering={},this.numbering=null,this.pageStyles=null,this.themeColors=null,this.initialJSON=null,this.headers={},this.headerIds={default:null,even:null,odd:null,first:null},this.headerEditors=[],this.footers={},this.footerIds={default:null,even:null,odd:null,first:null},this.footerEditors=[],this.importedBodyHasHeaderRef=!1,this.importedBodyHasFooterRef=!1,this.headerFooterModified=!1,this.linkedStyles=[],this.translatedLinkedStyles={},this.json=t?.json,this.tagsNotInSchema=["w:body"],this.savedTagsToRestore=[],this.documentInternalId=null,this.fileSource=t?.fileSource||null,this.documentId=t?.documentId||null,this.documentGuid=null,this.documentUniqueIdentifier=null,this.documentModified=!1,this.isBlankDoc=t?.isNewFile||!1,(this.docx.length||this.xml)&&this.parseFromXml()}get docxHelpers(){return ILt}parseFromXml(){if(this.docx?.forEach(t=>{this.convertedXml[t.name]=this.parseXmlToJson(t.content),t.name==="word/document.xml"&&(this.documentAttributes=this.convertedXml[t.name].elements[0]?.attributes),t.name==="word/styles.xml"&&(this.convertedXml[t.name]=hwe(this.convertedXml[t.name]))}),!this.convertedXml["word/styles.xml"]){for(let t=1;t<=5;t+=1)if(this.convertedXml[`word/styles${t}.xml`]!=null){this.convertedXml["word/styles.xml"]=hwe(this.convertedXml[`word/styles${t}.xml`]);break}}this.initialJSON=this.convertedXml["word/document.xml"],this.initialJSON||(this.initialJSON=this.parseXmlToJson(this.xml)),this.declaration=this.initialJSON?.declaration,this.resolveDocumentGuid()}parseXmlToJson(t){const n=t.replace(/(<w:(?:t|delText)(?:\s[^>]*)?>)(\s+)(<\/w:(?:t|delText)>)/g,"$1[[sdspace]]$2[[sdspace]]$3");return JSON.parse(h6t.xml2json(n,null,2))}static _matchesElementName(t,n){return!t||typeof t!="string"||!n?!1:t===n?!0:t.endsWith(`:${n}`)?t.slice(0,-(n.length+1)).length>0:!1}static _extractNamespacePrefix(t){if(!t||typeof t!="string")return"";const n=t.indexOf(":");return n>0?t.slice(0,n):""}static getStoredCustomProperty(t,n){try{const r=t.find(l=>l.name==="docProps/custom.xml");if(!r)return null;const i=new No,o=r.content,s=i.parseXmlToJson(o)?.elements?.find(l=>No._matchesElementName(l.name,"Properties"));if(!s?.elements)return null;const a=s.elements.find(l=>No._matchesElementName(l.name,"property")&&l.attributes?.name===n);return a?a.elements?.[0]?.elements?.[0]?.text?a.elements[0].elements[0].text:(console.warn(`Malformed property structure for "${n}"`),null):null}catch(r){return console.warn(`Error getting custom property ${n}:`,r),null}}static setStoredCustomProperty(t,n,r,i=!1){try{const o="docProps/custom.xml";t[o]||(t[o]=y6t());const s=t[o].elements?.find(d=>No._matchesElementName(d.name,"Properties"));if(!s)return null;s.elements||(s.elements=[]);const a=No._extractNamespacePrefix(s.name),l=a?`${a}:property`:"property";let c=s.elements.find(d=>No._matchesElementName(d.name,"property")&&d.attributes?.name===n);if(c&&i)return c.elements?.[0]?.elements?.[0]?.text?c.elements[0].elements[0].text:(console.warn(`Malformed existing property structure for "${n}"`),null);const u=typeof r=="function"?r():r;if(c)No._extractNamespacePrefix(c.name)!==a&&(c.name=l),c.elements?.[0]?.elements?.[0]?c.elements[0].elements[0].text=u:(console.warn(`Malformed property structure for "${n}", recreating structure`),c.elements=[{type:"element",name:"vt:lpwstr",elements:[{type:"text",text:u}]}]);else{const d=s.elements.filter(f=>f.attributes?.pid).map(f=>parseInt(f.attributes.pid,10)).filter(Number.isInteger);c={type:"element",name:l,attributes:{name:n,fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:d.length>0?Math.max(...d)+1:2},elements:[{type:"element",name:"vt:lpwstr",elements:[{type:"text",text:u}]}]},s.elements.push(c)}return u}catch(o){return console.warn(`Error setting custom property ${n}:`,o),null}}static getStoredSuperdocVersion(t){return No.getStoredCustomProperty(t,"SuperdocVersion")}static setStoredSuperdocVersion(t=this.convertedXml,n=g6t){return No.setStoredCustomProperty(t,"SuperdocVersion",n,!1)}static generateWordTimestamp(){const t=new Date;return t.setSeconds(0,0),t.toISOString().split(".")[0]+"Z"}getDocumentCreatedTimestamp(){const t=this.convertedXml["docProps/core.xml"];if(!t)return null;const n=t.elements?.find(r=>r.name==="cp:coreProperties"||No._matchesElementName(r.name,"coreProperties"));return n?.elements&&n.elements.find(r=>r.name==="dcterms:created"||No._matchesElementName(r.name,"created"))?.elements?.[0]?.text||null}setDocumentCreatedTimestamp(t){const n=this.convertedXml["docProps/core.xml"];if(!n)return;const r=n.elements?.find(o=>o.name==="cp:coreProperties"||No._matchesElementName(o.name,"coreProperties"));if(!r)return;r.elements||(r.elements=[]);let i=r.elements.find(o=>o.name==="dcterms:created"||No._matchesElementName(o.name,"created"));i?.elements?.[0]?i.elements[0].text=t:(i={type:"element",name:"dcterms:created",attributes:{"xsi:type":"dcterms:W3CDTF"},elements:[{type:"text",text:t}]},r.elements.push(i))}static extractDocumentGuid(t){try{const n=t.find(o=>o.name==="word/settings.xml");if(!n)return null;const r=new No().parseXmlToJson(n.content).elements?.[0];if(!r)return null;const i=r.elements?.find(o=>o.name==="w15:docId");if(i?.attributes?.["w15:val"])return i.attributes["w15:val"].replace(/[{}]/g,"")}catch{}return No.getStoredCustomProperty(t,"DocumentGuid")}getDocumentGuid(){return this.documentGuid}getSuperdocVersion(){return this.docx?No.getStoredSuperdocVersion(this.docx):null}resolveDocumentGuid(){const t=this.getMicrosoftDocId();if(t)this.documentGuid=t;else{const n=No.getStoredCustomProperty(this.docx,"DocumentGuid");n&&(this.documentGuid=n)}this.isBlankDoc&&this.setDocumentCreatedTimestamp(No.generateWordTimestamp())}getMicrosoftDocId(){return this.getDocumentInternalId(),this.documentInternalId?this.documentInternalId.replace(/[{}]/g,""):null}#e(){const t=`${this.documentGuid}|${this.getDocumentCreatedTimestamp()}`;return`HASH-${hse(new TextEncoder().encode(t)).toUpperCase()}`}async#t(){if(!this.fileSource)return`HASH-${yn().replace(/-/g,"").substring(0,8).toUpperCase()}`;try{let t;if(ArrayBuffer.isView(this.fileSource)){const n=this.fileSource;t=new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}else if(this.fileSource instanceof ArrayBuffer)t=new Uint8Array(this.fileSource);else if(this.fileSource instanceof Blob||this.fileSource instanceof File){const n=await this.fileSource.arrayBuffer();t=new Uint8Array(n)}else return`HASH-${yn().replace(/-/g,"").substring(0,8).toUpperCase()}`;return`HASH-${hse(t).toUpperCase()}`}catch(t){return console.warn("[super-converter] Could not generate content hash:",t),`HASH-${yn().replace(/-/g,"").substring(0,8).toUpperCase()}`}}async getDocumentIdentifier(){if(this.documentUniqueIdentifier)return this.documentUniqueIdentifier;const t=!!this.documentGuid,n=!!this.getDocumentCreatedTimestamp();return t&&n?this.documentUniqueIdentifier=this.#e():(t||(this.documentGuid=yn()),n||this.setDocumentCreatedTimestamp(No.generateWordTimestamp()),this.documentModified=!0,this.documentUniqueIdentifier=await this.#t()),this.documentUniqueIdentifier}promoteToGuid(){return this.documentGuid?this.documentGuid:(this.documentGuid=this.getMicrosoftDocId()||yn(),this.documentModified=!0,this.documentUniqueIdentifier=null,this.documentGuid)}getDocumentDefaultStyles(){const t=this.convertedXml["word/styles.xml"]?.elements?.[0]?.elements||[];if(!t.length)return{};const n=t.find(l=>l.name==="w:docDefaults"),r=t.find(l=>l.name==="w:style"&&l.attributes?.["w:styleId"]==="Normal"),i={typeface:void 0,panose:void 0,fontSizePt:void 0,kern:void 0,fallbackSzTwips:void 0},o=n?.elements?.find(l=>l.name==="w:rPrDefault");Wxe(o?.elements?.find(l=>l.name==="w:rPr")??o,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:i}),Wxe(r?.elements?.find(l=>l.name==="w:rPr")??null,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:i}),i.fontSizePt===void 0&&(Number.isFinite(i.fallbackSzTwips)?i.fontSizePt=i.fallbackSzTwips/2:i.fontSizePt=m6t);const s=i.typeface?No.toCssFontFamily(i.typeface,this.convertedXml):void 0,a={};return i.fontSizePt!==void 0&&(a.fontSizePt=i.fontSizePt),i.kern!==void 0&&(a.kern=i.kern),i.typeface&&(a.typeface=i.typeface),i.panose&&(a.panose=i.panose),s&&(a.fontFamilyCss=s),a}getDocumentFonts(){const t=[...new Set(this.inlineDocumentFonts||[])],n=this.getDocumentDefaultStyles?.()||{},r=typeof n.typeface=="string"?n.typeface:null,i=typeof n.fontFamilyCss=="string"?n.fontFamilyCss:null,o=r||(i?i.split(",")[0]?.replace(/["']/g,"").trim():null),s=d=>{const f=[...d];return o&&!f.includes(o)&&f.push(o),f},a=this.convertedXml["word/fontTable.xml"];if(!a)return s(t);const l=a.elements?.find(d=>d.name==="w:fonts");if(!l||!l.elements)return s(t);const c=l.elements.filter(d=>d.name==="w:font").map(d=>d.attributes["w:name"]),u=[...t,...c];return s([...new Set(u)])}getFontFaceImportString(){const t=this.convertedXml["word/fontTable.xml"];if(!t||!Object.keys(this.fonts).length)return;const n=t.elements.find(s=>s.name==="w:fonts")?.elements.filter(s=>s.elements?.some(a=>a?.attributes&&a.attributes["r:id"]&&a.attributes["w:fontKey"]))?.reduce((s,a)=>{const l=a.elements.filter(c=>c.name.startsWith("w:embed"))?.map(c=>({...c,fontFamily:a.attributes["w:name"]}));return[...s,...l]},[]),{elements:r}=this.convertedXml["word/_rels/fontTable.xml.rels"]?.elements.find(s=>s.name==="Relationships")||{},i=[];let o="";for(const s of n){const a=r.find(y=>y.attributes.Id===s.attributes["r:id"])?.attributes?.Target;if(!a)return;const l=this.fonts[`word/${a}`]?.buffer;if(!l)return;const c=oZe(l,s.attributes["w:fontKey"]);if(!c)return;const u=new Blob([c],{type:"font/ttf"}),d=URL.createObjectURL(u),f=s.name.includes("Regular"),h=s.name.includes("Bold"),p=s.name.includes("Italic"),m=s.name.includes("Light"),g=f?"normal":h?"bold":m?"200":"normal";i.includes(s.fontFamily)||i.push(s.fontFamily),o+=`
|
|
91
|
+
`)}var oOt=vs({findChildren:()=>lxe,findInlineNodes:()=>cxe,findMarkPosition:()=>sxe,flatten:()=>axe},1);const sxe=(e,t,n)=>{const r=e.resolve(t),i=r.parent,o=i.childAfter(r.parentOffset);if(!o.node)return null;const s=o.node.marks.find(d=>d.type.name===n);if(!s)return null;let a=r.index(),l=r.start()+o.offset;for(;a>0&&s.isInSet(i.child(a-1).marks);)l-=i.child(--a).nodeSize;let c=r.index()+1,u=r.start()+o.offset+o.node.nodeSize;for(;c<i.childCount&&s.isInSet(i.child(c).marks);)u+=i.child(c++).nodeSize;return{from:l,to:u,attrs:s.attrs}},axe=(e,t=!0)=>{if(!e)throw new Error('Invalid "node" parameter');const n=[];return e.descendants((r,i)=>{if(n.push({node:r,pos:i}),!t)return!1}),n},lxe=(e,t,n)=>{if(e){if(!t)throw new Error('Invalid "predicate" parameter')}else throw new Error('Invalid "node" parameter');return axe(e,n).filter(r=>t(r.node))},cxe=(e,t)=>lxe(e,n=>n.isInline,t),Nc=(e,t=null)=>{const n=[];if(!e?.doc)return n;const r=cxe(e.doc);return r.length?(r.forEach(({node:i,pos:o})=>{const{marks:s}=i,a=[Zl,Os,Xa];s.length>0&&s.forEach(l=>{a.includes(l.type.name)&&n.push({mark:l,from:o,to:o+i.nodeSize})})}),t?n.filter(({mark:i})=>i.attrs.id===t):n):n};var sOt=24;function aOt(e){try{const t=Nc(e.state);return Array.isArray(t)?t:[]}catch{return[]}}function lOt(e){let t=2166136261,n=16777619,r=3735928559;for(let i=0;i<e.length;i++){const o=e.charCodeAt(i);t=Math.imul(t^o,16777619),n=Math.imul(n^o,1540483477),r=Math.imul(r^o,461845907)}return t=Math.imul(t^t>>>16,2246822507),n=Math.imul(n^n>>>16,3432918353),r=Math.imul(r^r>>>16,461845907),((t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")+(r>>>0).toString(16).padStart(8,"0")).slice(0,sOt)}function cOt(e,t){const n=tW(t),r=gN(e.state.doc.textBetween(t.from,t.to," ",""))??"",i=us(t.attrs.author)??"",o=us(t.attrs.authorEmail)??"",s=us(t.attrs.date)??"";return lOt(`${n}|${t.from}|${t.to}|${i}|${o}|${s}|${r}`)}function tW(e){return e.hasFormat?"format":e.hasDelete&&!e.hasInsert?"delete":"insert"}var uxe=new WeakMap;function dxe(e,t,n){return n?e?(e[t]||(e[t]=n),e):{[t]:n}:e}function uOt(e){return e==="trackInsert"?"insert":e==="trackDelete"?"delete":e==="trackFormat"?"format":null}function uA(e){const t=e.state.doc,n=uxe.get(e);if(n&&n.doc===t)return n.grouped;const r=aOt(e),i=new Map;for(const s of r){const a=s.mark?.attrs??{},l=us(a.id);if(!l)continue;const c=i.get(l),u=s.mark.type.name,d=u===Zl,f=u===Os,h=u===Xa,p=us(a.sourceId),m=uOt(u);if(!c){i.set(l,{rawId:l,from:s.from,to:s.to,hasInsert:d,hasDelete:f,hasFormat:h,attrs:{...a},wordRevisionIds:m?dxe(void 0,m,p??void 0):void 0});continue}c.from=Math.min(c.from,s.from),c.to=Math.max(c.to,s.to),c.hasInsert=c.hasInsert||d,c.hasDelete=c.hasDelete||f,c.hasFormat=c.hasFormat||h,Object.keys(c.attrs).length===0&&Object.keys(a).length>0&&(c.attrs={...a}),m&&(c.wordRevisionIds=dxe(c.wordRevisionIds,m,p??void 0))}const o=Array.from(i.values()).map(s=>({...s,id:cOt(e,s)})).sort((s,a)=>s.from!==a.from?s.from-a.from:s.id.localeCompare(a.id));return uxe.set(e,{doc:t,grouped:o}),o}function fxe(e,t){return uA(e).find(n=>n.id===t)??null}function hxe(e){const t=uA(e),n=new Map;for(const r of t)n.set(r.rawId,r.id),n.set(r.id,r.id);return n}function dOt(e){return typeof e=="string"?{kind:"entity",entityType:"trackedChange",entityId:e}:e}function zN(e,t){const n=dOt(t),r=n.entityId,i=n.story??{kind:"story",storyType:"body"};if((n.story?Uo(n.story):"body")==="body"){const a=pxe(e,r);return a?{editor:e,story:i,runtimeRef:{storyKey:rh,rawId:a.rawId},change:a}:null}let o;try{o=nl(e,i)}catch{return null}const s=pxe(o.editor,r);return s?{editor:o.editor,story:o.locator,runtimeRef:{storyKey:o.storyKey,rawId:s.rawId},change:s,commit:o.commit}:null}function pxe(e,t){return uA(e).find(n=>n.id===t||n.rawId===t)??null}const mxe=["structuredContent","structuredContentBlock"],Fk="structuredContentBlock";function Bk(e){return mxe.includes(e.type.name)}function dA(e){const t=[];return e.descendants((n,r)=>(Bk(n)&&t.push({node:n,pos:r,kind:n.type.name==="structuredContentBlock"?"block":"inline"}),!0)),t}function xn(e,t){const n=t.nodeId,r=dA(e).filter(i=>String(i.node.attrs.id)===n);if(r.length===0)throw new De("TARGET_NOT_FOUND",`Content control with id "${n}" not found.`,{target:t});if(r.length>1)throw new De("AMBIGUOUS_TARGET",`Multiple content controls found with id "${n}".`,{target:t,count:r.length});return r[0]}function fa(e,t){return e?.elements?.find(n=>n.name===t)}function gxe(e,t){return fa(e,t)?.attributes}function UN(e,t,n){const r=e.elements?[...e.elements]:[],i=r.findIndex(o=>o.name===t);return i>=0?r[i]=n:r.push(n),{...e,elements:r}}function yxe(e,t){return e.elements?{...e,elements:e.elements.filter(n=>n.name!==t)}:e}var fOt=new Set(mxe);function $y(e,t,n){if(!e?.state)return!1;let r=null;if(e.state.doc.descendants((o,s)=>r!==null?!1:fOt.has(o.type.name)&&String(o.attrs.id)===String(t)?(r=s,!1):!0),r===null)return!1;const i=e.state.tr;for(const[o,s]of Object.entries(n))i.setNodeAttribute(r,o,s);if(i.steps.length===0)return!0;if(e.view?.dispatch)e.view.dispatch(i);else if(typeof e.dispatch=="function")e.dispatch(i);else return!1;return!0}function ef(e,t,n,r){const i=xn(e.state.doc,t).node.attrs.sdtPr??{name:"w:sdtPr",elements:[]},o=r(fa(i,n));let s;return o===null?s=yxe(i,n):s=UN(i,n,o),$y(e,t.nodeId,{sdtPr:s})}function nW(e,t,n,r,i,o){return ef(e,t,n,s=>{const a=s??{name:n,type:"element",elements:[]},l=a.elements?[...a.elements]:[],c=l.findIndex(d=>d.name===r),u={name:r,type:"element",attributes:{[i]:o}};return c>=0?l[c]={...l[c],attributes:{...l[c].attributes??{},[i]:o}}:l.push(u),{...a,elements:l}})}function hOt(e,t,n,r){return ef(e,t,n,i=>({name:n,type:"element",...i,elements:r}))}var pOt=["text","richText","date","checkbox","comboBox","dropDownList","repeatingSection","repeatingSectionItem","group"],mOt=["unlocked","sdtLocked","contentLocked","sdtContentLocked"],gOt=["boundingBox","tags","hidden"];function kp(e){const t=e.controlType??e.type;return typeof t=="string"&&pOt.includes(t)?t:"unknown"}function VN(e){const t=e.lockMode;return typeof t=="string"&&mOt.includes(t)?t:"unlocked"}function bxe(e){const t=e.appearance;if(typeof t=="string"&&gOt.includes(t))return t}function vxe(e){const t=e.sdtPr;if(!t)return;const n=gxe(t,"w:dataBinding");if(!n)return;const r=n["w:storeItemID"],i=n["w:xpath"];if(!(!r||!i))return{storeItemId:r,xpath:i,prefixMappings:n["w:prefixMappings"]}}function Ni(e){return{kind:e.kind,nodeType:"sdt",nodeId:String(e.node.attrs.id??"")}}function rW(e){const t=(fa(e,"w14:checkbox")??fa(e,"w:checkbox"))?.elements?.find(r=>r.name==="w14:checked"||r.name==="w:checked"),n=t?.attributes?.["w14:val"]??t?.attributes?.["w:val"];return n==="1"||n==="true"||n===!0}function iW(e,t){const n=fa(e,`w:${t}`);return{items:(n?.elements?.filter(r=>r.name==="w:listItem")??[]).map(r=>({displayText:String(r.attributes?.["w:displayText"]??""),value:String(r.attributes?.["w:value"]??"")})),selectedValue:n?.attributes?.["w:lastValue"]}}function yOt(e,t){if(!t)return{};switch(e){case"text":{const n=gxe(t,"w:text");if(!n)return{};const r=n["w:multiLine"];return{multiline:r==="1"||r==="true"||r===!0}}case"date":{const n=fa(t,"w:date");if(!n)return{};const r=fa(n,"w:dateFormat"),i=fa(n,"w:lid"),o=fa(n,"w:storeMappedDataAs"),s=fa(n,"w:calendar");return{dateFormat:r?.attributes?.["w:val"],dateLocale:i?.attributes?.["w:val"],storageFormat:o?.attributes?.["w:val"],calendar:s?.attributes?.["w:val"]}}case"checkbox":{const n=fa(t,"w14:checkbox")??fa(t,"w:checkbox");if(!n)return{};const r=n.elements?.find(o=>o.name==="w14:checkedState"),i=n.elements?.find(o=>o.name==="w14:uncheckedState");return{checked:rW(t),checkedSymbol:r?{font:String(r.attributes?.["w14:font"]??""),char:String(r.attributes?.["w14:val"]??"")}:void 0,uncheckedSymbol:i?{font:String(i.attributes?.["w14:font"]??""),char:String(i.attributes?.["w14:val"]??"")}:void 0}}case"comboBox":case"dropDownList":return iW(t,e);case"repeatingSection":{const n=fa(t,"w15:repeatingSection")??fa(t,"w:repeatingSection");if(!n)return{};const r=n.elements?.find(o=>o.name==="w15:allowInsertDeleteSection"||o.name==="w:allowInsertDeleteSection"),i=r?.attributes?.["w15:val"]??r?.attributes?.["w:val"];return{allowInsertDelete:i==="1"||i==="true"||i===!0}}default:return{}}}function Ig(e){const t=e.node.attrs,n=String(t.id??""),r=kp(t),i=VN(t),o=typeof t.sdtPr=="object"&&t.sdtPr!==null?t.sdtPr:void 0;let s;try{s=e.node.textContent||void 0}catch{s=void 0}const a=yOt(r,o);return{nodeType:"sdt",kind:e.kind,id:n,controlType:r,lockMode:i,properties:{tag:typeof t.tag=="string"?t.tag:void 0,alias:typeof t.alias=="string"?t.alias:void 0,appearance:bxe(t),placeholder:typeof t.placeholder=="string"?t.placeholder:void 0,color:typeof t.color=="string"?t.color:void 0,showingPlaceholder:typeof t.showingPlaceholder=="boolean"?t.showingPlaceholder:void 0,temporary:typeof t.temporary=="boolean"?t.temporary:void 0,tabIndex:typeof t.tabIndex=="number"?t.tabIndex:void 0,...a},binding:vxe(t),raw:o,target:{kind:e.kind,nodeType:"sdt",nodeId:n},text:s}}function bOt(e,t){const n=e??{},r=String(n.id??"");return{nodeType:"sdt",kind:t,id:r,controlType:kp(n),lockMode:VN(n),properties:{tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,appearance:bxe(n),placeholder:typeof n.placeholder=="string"?n.placeholder:void 0,color:typeof n.color=="string"?n.color:void 0,showingPlaceholder:typeof n.showingPlaceholder=="boolean"?n.showingPlaceholder:void 0,temporary:typeof n.temporary=="boolean"?n.temporary:void 0,tabIndex:typeof n.tabIndex=="number"?n.tabIndex:void 0},target:{kind:t,nodeType:"sdt",nodeId:r}}}function rl(e,t){const n=VN(e.node.attrs);if(n==="sdtLocked"||n==="sdtContentLocked")throw new De("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function sh(e,t){const n=VN(e.node.attrs);if(n==="contentLocked"||n==="sdtContentLocked")throw new De("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function ha(e,t,n){const r=kp(e.node.attrs),i=Array.isArray(t)?t:[t];if(!i.includes(r))throw new De("TYPE_MISMATCH",`Operation "${n}" requires control type ${i.join(" or ")}, but found "${r}".`,{expected:i,actual:r,operation:n})}function wxe(e,t){const n={success:!0,contentControl:e};return t&&(n.updatedRef=t),n}function ah(e,t){return{success:!1,failure:{code:e,message:t}}}function Hk(e,t){const n=e.length,r=t?.offset??0,i=t?.limit??n;return{items:e.slice(r,r+i),total:n}}function zk(e,t){const n=Kn(e).candidates.filter(r=>r.nodeId===t&&(r.nodeType==="paragraph"||r.nodeType==="listItem"));if(n.length===0)throw new De("TARGET_NOT_FOUND","Block target was not found.",{nodeId:t});if(n.length>1)throw new De("INVALID_TARGET","Block target id is ambiguous.",{nodeId:t,count:n.length});return n[0]}function Axe(e,t,n){const r=zk(e,t),i=zk(e,n);if(r.pos>i.pos)throw new De("INVALID_TARGET",'Block range "from" must precede "to" in document order.',{from:t,to:n});return Kn(e).candidates.filter(o=>(o.nodeType==="paragraph"||o.nodeType==="listItem")&&o.pos>=r.pos&&o.pos<=i.pos)}function td(e,t){const n=e.converter?.numbering?.definitions;if(!n)return;const r=n[t];if(!r?.elements)return;const i=r.elements.find(o=>o.name==="w:abstractNumId")?.attributes?.["w:val"];return i!=null?Number(i):void 0}function fA(e){return Kn(e).candidates.filter(t=>t.nodeType==="listItem").map(t=>WN(e,t))}function il(e,t){if(t.numId==null)return[t];const n=fA(e),r=n.findIndex(a=>a.address.nodeId===t.address.nodeId);if(r===-1)return[t];const i=t.numId;let o=r;for(let a=r-1;a>=0&&n[a].numId===i;a--)o=a;let s=r;for(let a=r+1;a<n.length&&n[a].numId===i;a++)s=a;return n.slice(o,s+1)}function xxe(e,t){const n=il(e,t),r=n.findIndex(i=>i.address.nodeId===t.address.nodeId);return n.slice(r)}function Sxe(e,t){const n=il(e,t);return n.length>0&&n[0].address.nodeId===t.address.nodeId}function vOt(e,t){if(t.numId==null)return"";const n=il(e,t)[0]?.address.nodeId??t.address.nodeId;return`${t.numId}:${n}`}function Txe(e){const t=new Map;let n,r;for(const i of e){if(i.numId==null){t.set(i.address.nodeId,""),n=void 0,r=void 0;continue}i.numId!==n&&(n=i.numId,r=i.address.nodeId),t.set(i.address.nodeId,`${n}:${r}`)}return t}function hA(e,t,n){if(t.numId==null)return null;const r=fA(e),i=il(e,t);if(n==="withNext"){const o=i[i.length-1],s=r.findIndex(a=>a.address.nodeId===o.address.nodeId);for(let a=s+1;a<r.length;a++){const l=r[a];if(l.numId!=null)return{sequence:il(e,l),numId:l.numId,abstractNumId:td(e,l.numId)}}}else{const o=i[0],s=r.findIndex(a=>a.address.nodeId===o.address.nodeId);for(let a=s-1;a>=0;a--){const l=r[a];if(l.numId!=null)return{sequence:il(e,l),numId:l.numId,abstractNumId:td(e,l.numId)}}}return null}function wOt(e,t){if(t.numId==null)return null;const n=td(e,t.numId);if(n==null)return null;const r=fA(e),i=il(e,t)[0],o=r.findIndex(s=>s.address.nodeId===i.address.nodeId);for(let s=o-1;s>=0;s--){const a=r[s];if(a.numId!=null&&td(e,a.numId)===n&&a.numId!==t.numId)return{sequence:il(e,a),numId:a.numId}}return null}function Ixe(e,t,n){const r=hA(e,t,n);if(!r)return{canJoin:!1,reason:"NO_ADJACENT_SEQUENCE"};if(r.numId===t.numId)return{canJoin:!1,reason:"ALREADY_SAME_SEQUENCE"};const i=t.numId!=null?td(e,t.numId):void 0;if(i==null||r.abstractNumId==null||i!==r.abstractNumId)return{canJoin:!1,reason:"INCOMPATIBLE_DEFINITIONS"};const o=r.sequence[0]?.address.nodeId??"";return{canJoin:!0,adjacentListId:`${r.numId}:${o}`}}function kxe(e,t){if(t.numId==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const n=td(e,t.numId);if(n==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const r=fA(e),i=il(e,t)[0],o=r.findIndex(a=>a.address.nodeId===i.address.nodeId);let s=!1;for(let a=o-1;a>=0;a--){const l=r[a];if(l.numId==null||(s=!0,td(e,l.numId)!==n))continue;if(l.numId===t.numId)return{canContinue:!1,reason:"ALREADY_CONTINUOUS"};const c=il(e,l)[0]?.address.nodeId??l.address.nodeId;return{canContinue:!0,previousListId:`${l.numId}:${c}`}}return s?{canContinue:!1,reason:"INCOMPATIBLE_DEFINITIONS"}:{canContinue:!1,reason:"NO_PREVIOUS_LIST"}}function AOt(e){const t=e.attrs??{},n=t.paragraphProperties?.numberingProperties??void 0,r=t.numberingProperties??void 0;return{numId:pN(n?.numId??r?.numId),level:pN(n?.ilvl??r?.ilvl)}}function xOt(e,t,n){if(!(t==null||n==null||!e.converter))try{const r=Gn.getListDefinitionDetails({numId:t,level:n,listType:void 0,editor:e}),i=typeof r?.listNumberingType=="string"?r.listNumberingType:void 0;return i==="bullet"?"bullet":typeof i=="string"&&i.length>0?"ordered":void 0}catch{return}}function SOt(e,t,n,r){const i=(t.node.attrs??{}).listRendering?.numberingType;return i==="bullet"?"bullet":typeof i=="string"&&i.length>0?"ordered":xOt(e,n,r)}function TOt(e){const t=e.node.textContent;return typeof t=="string"?t:void 0}function WN(e,t){const n=t.node.attrs??{},{numId:r,level:i}=AOt(t.node),o=N1(n.listRendering),s=o?.path,a=Q8(s),l=o?.markerText;return{candidate:t,address:{kind:"block",nodeType:"listItem",nodeId:t.nodeId},numId:r,level:i,kind:SOt(e,t,r,i),marker:l,path:s,ordinal:a,text:TOt(t)}}function Exe(e,t){return{address:e.address,listId:t,marker:e.marker,ordinal:e.ordinal,path:e.path,level:e.level,kind:e.kind,text:e.text}}function IOt(e,t){return t?!(t.kind&&e.kind!==t.kind||t.level!=null&&e.level!==t.level||t.ordinal!=null&&e.ordinal!==t.ordinal):!0}function kOt(e,t){if(!t)return;const n=e.candidates.filter(r=>r.nodeType===t.nodeType&&r.nodeId===t.nodeId);if(n.length===0)throw new De("TARGET_NOT_FOUND","List scope block was not found.",{within:t});if(n.length>1)throw new De("INVALID_TARGET","List scope block id is ambiguous.",{within:t,count:n.length});return{start:n[0].pos,end:n[0].end}}function EOt(e,t){return t?e.pos>=t.start&&e.end<=t.end:!0}function COt(e,t){if(t?.within&&t.within.kind!=="block")throw new De("INVALID_TARGET","lists.list only supports block within scopes.",{within:t.within});wg(t?.offset,t?.limit);const n=Kn(e),r=kOt(n,t?.within),i=n.candidates.filter(f=>f.nodeType==="listItem").map(f=>WN(e,f)),o=i.filter(f=>EOt(f.candidate,r)),s=t?.offset??0,a=s+(t?.limit??Number.POSITIVE_INFINITY),l=sr(e),c=Txe(i);let u=0;const d=[];for(const f of o){if(!IOt(f,t))continue;const h=u;if(u+=1,h<s||h>=a)continue;const p=c.get(f.address.nodeId)??"",m=Exe(f,p),g=Ho(m.address.nodeId,"stable","list"),{address:y,marker:v,ordinal:b,path:w,level:x,kind:A,text:T}=m;d.push(rs(m.address.nodeId,g,{address:y,listId:p,marker:v,ordinal:b,path:w,level:x,kind:A,text:T}))}return Yo({evaluatedRevision:l,total:u,items:d,page:{limit:t?.limit??u,offset:s,returned:d.length}})}function Jo(e,t){const n=Kn(e).candidates.filter(r=>r.nodeType==="listItem"&&r.nodeId===t.nodeId);if(n.length===0)throw new De("TARGET_NOT_FOUND","List item target was not found.",{target:t});if(n.length>1)throw new De("INVALID_TARGET","List item target id is ambiguous.",{target:t,count:n.length});return WN(e,n[0])}var _Ot=new Set(["text","date","checkbox","comboBox","dropDownList"]),Cxe=new WeakMap;function POt(e){const t=e.state.doc,n=Cxe.get(e),r=Lxe(e);if(n&&n.doc===t)return _xe(n.counts,r);const i=ROt(e);return Cxe.set(e,{doc:t,counts:i}),_xe(i,r)}function ROt(e){const t=eW(e,{}),n=Kn(e),r=vg(e),i=LOt(n),o=NOt(r);return{words:Pxe(t),characters:t.length,paragraphs:i.paragraphs,headings:i.headings,tables:i.tables,images:i.blockImages+o,comments:MOt(r),trackedChanges:DOt(e),sdtFields:OOt(e),lists:FOt(e,n)}}function _xe(e,t){return t!=null?{...e,pages:t}:{...e}}function Pxe(e){const t=e.trim().match(/\S+/g);return t?t.length:0}function LOt(e){let t=0,n=0,r=0,i=0;for(const o of e.candidates)switch(o.nodeType){case"paragraph":t++;break;case"heading":n++;break;case"table":r++;break;case"image":i++;break}return{paragraphs:t,headings:n,tables:r,blockImages:i}}function NOt(e){return e.byType.get("image")?.length??0}function MOt(e){const t=e.byType.get("comment")??[],n=new Set;for(const r of t){const i=mN(r.attrs??{});i&&n.add(i)}return n.size}function DOt(e){return uA(e).length}function OOt(e){return dA(e.state.doc).filter(t=>_Ot.has(kp(t.node.attrs??{}))).length}function FOt(e,t){const n=BOt(e,t);if(n.length===0)return 0;const r=Txe(n);let i=0,o,s;for(const a of n){const l=r.get(a.address.nodeId)??"";if(l){l!==o&&(i+=1),o=l,s=void 0;continue}o=void 0,(!s||HOt(s,a))&&(i+=1),s=a}return i}function BOt(e,t){return t.candidates.filter(n=>n.nodeType==="listItem").map(n=>WN(e,n))}function HOt(e,t){return zOt(e,t)?!0:UOt(e,t)}function zOt(e,t){return e.kind!=null&&t.kind!=null&&e.kind!==t.kind}function UOt(e,t){const n=Rxe(e),r=Rxe(t);return n==null||r==null||n!==r||e.ordinal==null||t.ordinal==null?!1:t.ordinal<=e.ordinal}function Rxe(e){return e.level!=null?e.level:e.path&&e.path.length>0?e.path.length-1:void 0}function Lxe(e){return e.currentTotalPages}function pA(e){const t=eW(e,{});return{words:Pxe(t),characters:VOt(t),charactersWithSpaces:WOt(t),pages:Lxe(e)}}function GN(e,t){switch(e){case"NUMWORDS":return String(t.words);case"NUMCHARS":return String(t.characters);case"NUMPAGES":return t.pages!=null?String(t.pages):null;default:return null}}function eb(e){return e.options?.parentEditor??e}function VOt(e){return e.replace(/\s/g,"").length}function WOt(e){return e.replace(/\n/g,"").length}function Nxe(e){const t=new Map,n=pA(eb(e));for(const r of["NUMWORDS","NUMCHARS","NUMPAGES"]){const i=GN(r,n);i!=null&&t.set(r,i)}return t}const oW="http://schemas.openxmlformats.org/officeDocument/2006/bibliography",GOt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",jOt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";var Mxe="/APA.XSL",Dxe="APA",Oxe="6",Fxe=Object.freeze({book:"Book",journalArticle:"JournalArticle",conferenceProceedings:"ConferenceProceedings",report:"Report",website:"InternetSite",patent:"Patent",case:"Case",statute:"Case",thesis:"Report",film:"Film",interview:"Interview",misc:"Misc"}),qOt=Object.freeze({book:"book",journalarticle:"journalArticle",conferenceproceedings:"conferenceProceedings",report:"report",internetsite:"website",documentfrominternetsite:"website",articleinaperiodical:"journalArticle",patent:"patent",case:"case",statute:"statute",thesis:"thesis",film:"film",interview:"interview",misc:"misc"}),sW=Object.freeze({title:"Title",year:"Year",publisher:"Publisher",city:"City",journalName:"JournalName",volume:"Volume",issue:"Issue",pages:"Pages",url:"URL",doi:"DOI",edition:"Edition",medium:"Medium",shortTitle:"ShortTitle",standardNumber:"StandardNumber"}),YOt=Object.freeze(Object.fromEntries(Object.entries(sW).map(([e,t])=>[t,e])));function kg(e){if(!e||typeof e!="string")return"";const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function jN(e){if(!e?.elements?.length)return"";const t=e.elements.find(n=>n?.type==="text");return typeof t?.text=="string"?t.text.trim():""}function mA(e,t){return{type:"element",name:e,elements:[{type:"text",text:String(t)}]}}function qN(e,t){const n=t??uV;return{declaration:{...n,attributes:{...n.attributes}},elements:[e]}}function Bxe(e,t){if(e?.elements?.length){for(const n of e.elements)if(!(!n||n.type!=="element")){if(kg(n.name)==="Person"){t.push(n);continue}Bxe(n,t)}}}function KOt(e){const t={};for(const n of e?.elements??[]){if(!n||n.type!=="element")continue;const r=kg(n.name),i=jN(n);i&&(r==="First"&&(t.first=i),r==="Middle"&&(t.middle=i),r==="Last"&&(t.last=i))}return typeof t.last=="string"&&t.last.length>0?t:null}function aW(e,t){const n=(e?.elements??[]).find(i=>i?.type==="element"&&kg(i.name)===t);if(!n)return[];const r=[];return Bxe(n,r),r.map(KOt).filter(Boolean)}function XOt(e){if(!e||typeof e.last!="string"||e.last.trim().length===0)return null;const t=[],n=e.last.trim(),r=typeof e.first=="string"?e.first.trim():"",i=typeof e.middle=="string"?e.middle.trim():"";return n&&t.push(mA("b:Last",n)),r&&t.push(mA("b:First",r)),i&&t.push(mA("b:Middle",i)),{type:"element",name:"b:Person",elements:t}}function JOt(e){const t=(e??[]).map(XOt).filter(Boolean);return t.length===0?null:{type:"element",name:"b:NameList",elements:t}}function lW(e,t){const n=JOt(t);return n?e==="Author"?{type:"element",name:"b:Author",elements:[{type:"element",name:"b:Author",elements:[n]}]}:{type:"element",name:`b:${e}`,elements:[n]}:null}function ZOt(e){return Fxe[typeof e=="string"?e.trim():""]??Fxe.misc}function QOt(e){return qOt[typeof e=="string"?e.trim().toLowerCase():""]??"misc"}function cW(e){if(!e||typeof e!="object")return null;const t=e.tag??e.sourceId,n=typeof t=="string"?t.trim():"";if(!n)return null;const r=typeof e.type=="string"?e.type:"misc",i=e.fields&&typeof e.fields=="object"?e.fields:{},o={};for(const s of Object.keys(sW)){const a=i[s];typeof a=="string"&&a.trim().length>0&&(o[s]=a.trim())}for(const s of["authors","editor","translator"]){const a=i[s];if(!Array.isArray(a))continue;const l=a.map(c=>{if(!c||typeof c!="object")return null;const u={first:typeof c.first=="string"?c.first.trim():void 0,middle:typeof c.middle=="string"?c.middle.trim():void 0,last:typeof c.last=="string"?c.last.trim():void 0};return u.last?u:null}).filter(Boolean);l.length>0&&(o[s]=l)}return{tag:n,type:r,fields:o}}function $Ot(e){const t={};let n="",r="misc";for(const a of e?.elements??[]){if(!a||a.type!=="element")continue;const l=kg(a.name);if(l==="Tag"){n=jN(a);continue}if(l==="SourceType"){r=QOt(jN(a));continue}const c=YOt[l];if(!c)continue;const u=jN(a);u&&(t[c]=u)}const i=aW(e,"Author");i.length>0&&(t.authors=i);const o=aW(e,"Editor");o.length>0&&(t.editor=o);const s=aW(e,"Translator");return s.length>0&&(t.translator=s),cW({tag:n,type:r,fields:t})}function e6t(e){const t=cW(e);if(!t)return null;const n=[mA("b:Tag",t.tag),mA("b:SourceType",ZOt(t.type))];for(const[s,a]of Object.entries(sW)){const l=t.fields?.[s];typeof l!="string"||l.length===0||n.push(mA(`b:${a}`,l))}const r=lW("Author",t.fields?.authors);r&&n.push(r);const i=lW("Editor",t.fields?.editor);i&&n.push(i);const o=lW("Translator",t.fields?.translator);return o&&n.push(o),{type:"element",name:"b:Source",elements:n}}function t6t(e){if(!e||e.type!=="element"||kg(e.name)!=="Sources")return!1;const t=e.attributes?.xmlns,n=e.attributes?.["xmlns:b"];return t==="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"||n==="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"}function Hxe(e){const t=/customXml\/item(\d+)\.xml$/i.exec(e||"");return t?Number.parseInt(t[1],10):null}function n6t(e){return e.startsWith("customXml/")?`../${e}`:e}function r6t(e){const t=e?.["word/_rels/document.xml.rels"];return t?.elements?.length&&t.elements.find(n=>kg(n.name)==="Relationships")||null}function i6t(e){e["word/_rels/document.xml.rels"]||(e["word/_rels/document.xml.rels"]=qN({type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]}));const t=e["word/_rels/document.xml.rels"];t.elements??=[];let n=t.elements.find(r=>kg(r.name)==="Relationships");return n||(n={type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]},t.elements.push(n)),n.elements??=[],n}function o6t(e){const t=(e?.elements??[]).map(n=>{const r=n?.attributes?.Id;if(typeof r!="string")return NaN;const i=/^rId(\d+)$/.exec(r);return i?Number.parseInt(i[1],10):NaN}).filter(n=>Number.isFinite(n));return`rId${(t.length>0?Math.max(...t):0)+1}`}function s6t(e){const t=new Set;for(const r of Object.keys(e??{})){const i=/customXml\/item(\d+)\.xml$/i.exec(r);i&&t.add(Number.parseInt(i[1],10));const o=/customXml\/itemProps(\d+)\.xml$/i.exec(r);o&&t.add(Number.parseInt(o[1],10))}let n=1;for(;t.has(n);)n+=1;return n}function a6t(e,t){const n=e.map(e6t).filter(Boolean),r=t.selectedStyle||Mxe,i=t.styleName||Dxe,o=t.version||Oxe;return{type:"element",name:"b:Sources",attributes:{"xmlns:b":oW,xmlns:oW,SelectedStyle:r,StyleName:i,Version:o},elements:n}}function l6t(e){const t=e?.elements?.[0]?.attributes?.["ds:itemID"];return typeof t=="string"&&t.length>0?t:null}function c6t(e){return{type:"element",name:"ds:datastoreItem",attributes:{"ds:itemID":e,"xmlns:ds":"http://schemas.openxmlformats.org/officeDocument/2006/customXml"},elements:[{type:"element",name:"ds:schemaRefs",elements:[{type:"element",name:"ds:schemaRef",attributes:{"ds:uri":oW}}]}]}}function u6t(e){return{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[{type:"element",name:"Relationship",attributes:{Id:"rId1",Type:jOt,Target:e}}]}}function zxe(e){const t=new Map;for(const n of e){const r=cW(n);r&&t.set(r.tag,r)}return Array.from(t.values())}function uW(){return{sources:[],partPath:null,itemPropsPath:null,itemRelsPath:null,selectedStyle:null,styleName:null,version:null}}function Uxe(e){const t=uW(),n=r6t(e);if(!n?.elements?.length)return t;const r=[];for(const i of n.elements){if(i?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml")continue;const o=i?.attributes?.Target,s=ip(o,"word");if(!s)continue;const a=e?.[s]?.elements?.[0];if(t6t(a)){if(!t.partPath){t.partPath=s,t.selectedStyle=a.attributes?.SelectedStyle??null,t.styleName=a.attributes?.StyleName??null,t.version=a.attributes?.Version??null;const l=Hxe(s);if(l!=null){const c=`customXml/itemProps${l}.xml`,u=`customXml/_rels/item${l}.xml.rels`;t.itemPropsPath=e[c]?c:null,t.itemRelsPath=e[u]?u:null}}for(const l of a.elements??[]){if(!l||l.type!=="element"||kg(l.name)!=="Source")continue;const c=$Ot(l);c&&r.push(c)}}}return t.sources=zxe(r),t}function d6t(e,t){const n=Uxe(e),r=zxe(Array.isArray(t?.sources)?t.sources:[]);if(r.length===0&&!n.partPath)return{...uW(),sources:[]};const i=t?.partPath||n.partPath,o=Hxe(i),s=o??s6t(e),a=o?i:`customXml/item${s}.xml`,l=`customXml/itemProps${s}.xml`,c=`customXml/_rels/item${s}.xml.rels`,u=t?.selectedStyle??n.selectedStyle??Mxe,d=t?.styleName??n.styleName??Dxe,f=t?.version??n.version??Oxe,h=e[a]?.declaration;e[a]=qN(a6t(r,{selectedStyle:u,styleName:d,version:f}),h);const p=i6t(e),m=n6t(a);p.elements.some(b=>b?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"?!1:ip(b?.attributes?.Target,"word")===a)||p.elements.push({type:"element",name:"Relationship",attributes:{Id:o6t(p),Type:GOt,Target:m}});const g=e[l],y=g?.declaration;e[l]=qN(c6t(l6t(g)||`{${yn().toUpperCase()}}`),y);const v=e[c]?.declaration;return e[c]=qN(u6t(`itemProps${s}.xml`),v),{sources:r,partPath:a,itemPropsPath:l,itemRelsPath:c,selectedStyle:u,styleName:d,version:f}}function f6t(e){return[e?.partPath,e?.itemPropsPath,e?.itemRelsPath].filter(t=>typeof t=="string"&&t.length>0)}var h6t=Kc(Mm(),1),p6t=Object.freeze({swiss:"Arial, sans-serif",roman:"Times New Roman, serif",modern:"Courier New, monospace",script:"cursive",decorative:"fantasy",system:"system-ui",auto:"sans-serif"}),Vxe="sans-serif",m6t=10,g6t="1.34.0-next.7",Wxe=(e,{allowOverrideTypeface:t=!0,allowOverrideSize:n=!0,themeResolver:r,state:i})=>{if(!e?.elements?.length||!i)return;const o=e.elements.find(l=>l.name==="w:rFonts");if(o?.attributes){const l=o.attributes["w:asciiTheme"];if(l){const u=r?.(l)||{};(t||!i.typeface)&&u.typeface&&(i.typeface=u.typeface),(t||!i.panose)&&u.panose&&(i.panose=u.panose)}const c=o.attributes["w:ascii"];(t||!i.typeface)&&c&&(i.typeface=c)}const s=e.elements.find(l=>l.name==="w:sz");if(s?.attributes?.["w:val"]){const l=Number(s.attributes["w:val"]);if(Number.isFinite(l)){i.fallbackSzTwips===void 0&&(i.fallbackSzTwips=l);const c=l/2;(n||i.fontSizePt===void 0)&&(i.fontSizePt=c)}}const a=e.elements.find(l=>l.name==="w:kern");a?.attributes?.["w:val"]&&(n||i.kern===void 0)&&(i.kern=a.attributes["w:val"])},nd=class No{static allowedElements=Object.freeze({"w:document":"doc","w:body":"body","w:p":"paragraph","w:r":"run","w:t":"text","w:delText":"text","w:br":"lineBreak","w:tbl":"table","w:tr":"tableRow","w:tc":"tableCell","w:drawing":"drawing","w:bookmarkStart":"bookmarkStart","w:sectPr":"sectionProperties","w:rPr":"runProperties","w:commentRangeStart":"commentRangeStart","w:commentRangeEnd":"commentRangeEnd","w:commentReference":"commentReference"});static markTypes=[{name:"w:b",type:"bold",property:"value"},{name:"w:i",type:"italic"},{name:"w:u",type:"underline",mark:"underline",property:"underlineType"},{name:"w:strike",type:"strike",mark:"strike",property:"value"},{name:"w:color",type:"color",mark:"textStyle",property:"color"},{name:"w:sz",type:"fontSize",mark:"textStyle",property:"fontSize"},{name:"w:rFonts",type:"fontFamily",mark:"textStyle",property:"fontFamily"},{name:"w:rStyle",type:"styleId",mark:"textStyle",property:"styleId"},{name:"w:jc",type:"textAlign",mark:"textStyle",property:"textAlign"},{name:"w:ind",type:"textIndent",mark:"textStyle",property:"textIndent"},{name:"w:spacing",type:"lineHeight",mark:"textStyle",property:"lineHeight"},{name:"w:spacing",type:"letterSpacing",mark:"textStyle",property:"letterSpacing"},{name:"link",type:"link",mark:"link",property:"href"},{name:"w:highlight",type:"highlight",mark:"highlight",property:"color"},{name:"w:shd",type:"highlight",mark:"highlight",property:"color"},{name:"w:caps",type:"textTransform",mark:"textStyle",property:"textTransform"}];static propertyTypes=Object.freeze({"w:pPr":"paragraphProperties","w:rPr":"runProperties","w:sectPr":"sectionProperties","w:numPr":"numberingProperties","w:tcPr":"tableCellProperties"});static elements=new Set(["w:document","w:body","w:p","w:r","w:t","w:delText"]);static getFontTableEntry(t,n){if(!t||!n)return null;const r=t["word/fontTable.xml"];if(!r?.elements?.length)return null;const i=r.elements.find(o=>o.name==="w:fonts");return i?.elements?.length&&i.elements.find(o=>o?.attributes?.["w:name"]===n)||null}static getFallbackFromFontTable(t,n){const r=No.getFontTableEntry(t,n)?.elements?.find(i=>i.name==="w:family")?.attributes?.["w:val"];return r?p6t[r.toLowerCase()]||Vxe:null}static toCssFontFamily(t,n){if(!t||t.includes(","))return t;const r=No.getFallbackFromFontTable(n,t)||Vxe;return r.split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).includes(t.trim().toLowerCase())?r:`${t}, ${r}`}constructor(t=null){this.debug=t?.debug||!1,this.domEnvironment={mockWindow:t?.mockWindow||null,mockDocument:t?.mockDocument||null},this.declaration=null,this.documentAttributes=null,this.convertedXml={},this.docx=t?.docx||[],this.media=t?.media||{},this.fonts=t?.fonts||{},this.trackedChangesOptions=t?.trackedChangesOptions||null,this.addedMedia={},this.comments=[],this.footnotes=[],this.footnoteProperties=null,this.bibliographyPart=uW(),this.viewSetting=null,this.inlineDocumentFonts=[],this.commentThreadingProfile=null,this.exportWarnings=[],this.docHiglightColors=new Set([]),this.xml=t?.xml,this.declaration=null,this.numbering={},this.translatedNumbering={},this.numbering=null,this.pageStyles=null,this.themeColors=null,this.initialJSON=null,this.headers={},this.headerIds={default:null,even:null,odd:null,first:null},this.headerEditors=[],this.footers={},this.footerIds={default:null,even:null,odd:null,first:null},this.footerEditors=[],this.importedBodyHasHeaderRef=!1,this.importedBodyHasFooterRef=!1,this.headerFooterModified=!1,this.linkedStyles=[],this.translatedLinkedStyles={},this.json=t?.json,this.tagsNotInSchema=["w:body"],this.savedTagsToRestore=[],this.documentInternalId=null,this.fileSource=t?.fileSource||null,this.documentId=t?.documentId||null,this.documentGuid=null,this.documentUniqueIdentifier=null,this.documentModified=!1,this.isBlankDoc=t?.isNewFile||!1,(this.docx.length||this.xml)&&this.parseFromXml()}get docxHelpers(){return ILt}parseFromXml(){if(this.docx?.forEach(t=>{this.convertedXml[t.name]=this.parseXmlToJson(t.content),t.name==="word/document.xml"&&(this.documentAttributes=this.convertedXml[t.name].elements[0]?.attributes),t.name==="word/styles.xml"&&(this.convertedXml[t.name]=hwe(this.convertedXml[t.name]))}),!this.convertedXml["word/styles.xml"]){for(let t=1;t<=5;t+=1)if(this.convertedXml[`word/styles${t}.xml`]!=null){this.convertedXml["word/styles.xml"]=hwe(this.convertedXml[`word/styles${t}.xml`]);break}}this.initialJSON=this.convertedXml["word/document.xml"],this.initialJSON||(this.initialJSON=this.parseXmlToJson(this.xml)),this.declaration=this.initialJSON?.declaration,this.resolveDocumentGuid()}parseXmlToJson(t){const n=t.replace(/(<w:(?:t|delText)(?:\s[^>]*)?>)(\s+)(<\/w:(?:t|delText)>)/g,"$1[[sdspace]]$2[[sdspace]]$3");return JSON.parse(h6t.xml2json(n,null,2))}static _matchesElementName(t,n){return!t||typeof t!="string"||!n?!1:t===n?!0:t.endsWith(`:${n}`)?t.slice(0,-(n.length+1)).length>0:!1}static _extractNamespacePrefix(t){if(!t||typeof t!="string")return"";const n=t.indexOf(":");return n>0?t.slice(0,n):""}static getStoredCustomProperty(t,n){try{const r=t.find(l=>l.name==="docProps/custom.xml");if(!r)return null;const i=new No,o=r.content,s=i.parseXmlToJson(o)?.elements?.find(l=>No._matchesElementName(l.name,"Properties"));if(!s?.elements)return null;const a=s.elements.find(l=>No._matchesElementName(l.name,"property")&&l.attributes?.name===n);return a?a.elements?.[0]?.elements?.[0]?.text?a.elements[0].elements[0].text:(console.warn(`Malformed property structure for "${n}"`),null):null}catch(r){return console.warn(`Error getting custom property ${n}:`,r),null}}static setStoredCustomProperty(t,n,r,i=!1){try{const o="docProps/custom.xml";t[o]||(t[o]=y6t());const s=t[o].elements?.find(d=>No._matchesElementName(d.name,"Properties"));if(!s)return null;s.elements||(s.elements=[]);const a=No._extractNamespacePrefix(s.name),l=a?`${a}:property`:"property";let c=s.elements.find(d=>No._matchesElementName(d.name,"property")&&d.attributes?.name===n);if(c&&i)return c.elements?.[0]?.elements?.[0]?.text?c.elements[0].elements[0].text:(console.warn(`Malformed existing property structure for "${n}"`),null);const u=typeof r=="function"?r():r;if(c)No._extractNamespacePrefix(c.name)!==a&&(c.name=l),c.elements?.[0]?.elements?.[0]?c.elements[0].elements[0].text=u:(console.warn(`Malformed property structure for "${n}", recreating structure`),c.elements=[{type:"element",name:"vt:lpwstr",elements:[{type:"text",text:u}]}]);else{const d=s.elements.filter(f=>f.attributes?.pid).map(f=>parseInt(f.attributes.pid,10)).filter(Number.isInteger);c={type:"element",name:l,attributes:{name:n,fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:d.length>0?Math.max(...d)+1:2},elements:[{type:"element",name:"vt:lpwstr",elements:[{type:"text",text:u}]}]},s.elements.push(c)}return u}catch(o){return console.warn(`Error setting custom property ${n}:`,o),null}}static getStoredSuperdocVersion(t){return No.getStoredCustomProperty(t,"SuperdocVersion")}static setStoredSuperdocVersion(t=this.convertedXml,n=g6t){return No.setStoredCustomProperty(t,"SuperdocVersion",n,!1)}static generateWordTimestamp(){const t=new Date;return t.setSeconds(0,0),t.toISOString().split(".")[0]+"Z"}getDocumentCreatedTimestamp(){const t=this.convertedXml["docProps/core.xml"];if(!t)return null;const n=t.elements?.find(r=>r.name==="cp:coreProperties"||No._matchesElementName(r.name,"coreProperties"));return n?.elements&&n.elements.find(r=>r.name==="dcterms:created"||No._matchesElementName(r.name,"created"))?.elements?.[0]?.text||null}setDocumentCreatedTimestamp(t){const n=this.convertedXml["docProps/core.xml"];if(!n)return;const r=n.elements?.find(o=>o.name==="cp:coreProperties"||No._matchesElementName(o.name,"coreProperties"));if(!r)return;r.elements||(r.elements=[]);let i=r.elements.find(o=>o.name==="dcterms:created"||No._matchesElementName(o.name,"created"));i?.elements?.[0]?i.elements[0].text=t:(i={type:"element",name:"dcterms:created",attributes:{"xsi:type":"dcterms:W3CDTF"},elements:[{type:"text",text:t}]},r.elements.push(i))}static extractDocumentGuid(t){try{const n=t.find(o=>o.name==="word/settings.xml");if(!n)return null;const r=new No().parseXmlToJson(n.content).elements?.[0];if(!r)return null;const i=r.elements?.find(o=>o.name==="w15:docId");if(i?.attributes?.["w15:val"])return i.attributes["w15:val"].replace(/[{}]/g,"")}catch{}return No.getStoredCustomProperty(t,"DocumentGuid")}getDocumentGuid(){return this.documentGuid}getSuperdocVersion(){return this.docx?No.getStoredSuperdocVersion(this.docx):null}resolveDocumentGuid(){const t=this.getMicrosoftDocId();if(t)this.documentGuid=t;else{const n=No.getStoredCustomProperty(this.docx,"DocumentGuid");n&&(this.documentGuid=n)}this.isBlankDoc&&this.setDocumentCreatedTimestamp(No.generateWordTimestamp())}getMicrosoftDocId(){return this.getDocumentInternalId(),this.documentInternalId?this.documentInternalId.replace(/[{}]/g,""):null}#e(){const t=`${this.documentGuid}|${this.getDocumentCreatedTimestamp()}`;return`HASH-${hse(new TextEncoder().encode(t)).toUpperCase()}`}async#t(){if(!this.fileSource)return`HASH-${yn().replace(/-/g,"").substring(0,8).toUpperCase()}`;try{let t;if(ArrayBuffer.isView(this.fileSource)){const n=this.fileSource;t=new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}else if(this.fileSource instanceof ArrayBuffer)t=new Uint8Array(this.fileSource);else if(this.fileSource instanceof Blob||this.fileSource instanceof File){const n=await this.fileSource.arrayBuffer();t=new Uint8Array(n)}else return`HASH-${yn().replace(/-/g,"").substring(0,8).toUpperCase()}`;return`HASH-${hse(t).toUpperCase()}`}catch(t){return console.warn("[super-converter] Could not generate content hash:",t),`HASH-${yn().replace(/-/g,"").substring(0,8).toUpperCase()}`}}async getDocumentIdentifier(){if(this.documentUniqueIdentifier)return this.documentUniqueIdentifier;const t=!!this.documentGuid,n=!!this.getDocumentCreatedTimestamp();return t&&n?this.documentUniqueIdentifier=this.#e():(t||(this.documentGuid=yn()),n||this.setDocumentCreatedTimestamp(No.generateWordTimestamp()),this.documentModified=!0,this.documentUniqueIdentifier=await this.#t()),this.documentUniqueIdentifier}promoteToGuid(){return this.documentGuid?this.documentGuid:(this.documentGuid=this.getMicrosoftDocId()||yn(),this.documentModified=!0,this.documentUniqueIdentifier=null,this.documentGuid)}getDocumentDefaultStyles(){const t=this.convertedXml["word/styles.xml"]?.elements?.[0]?.elements||[];if(!t.length)return{};const n=t.find(l=>l.name==="w:docDefaults"),r=t.find(l=>l.name==="w:style"&&l.attributes?.["w:styleId"]==="Normal"),i={typeface:void 0,panose:void 0,fontSizePt:void 0,kern:void 0,fallbackSzTwips:void 0},o=n?.elements?.find(l=>l.name==="w:rPrDefault");Wxe(o?.elements?.find(l=>l.name==="w:rPr")??o,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:i}),Wxe(r?.elements?.find(l=>l.name==="w:rPr")??null,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:i}),i.fontSizePt===void 0&&(Number.isFinite(i.fallbackSzTwips)?i.fontSizePt=i.fallbackSzTwips/2:i.fontSizePt=m6t);const s=i.typeface?No.toCssFontFamily(i.typeface,this.convertedXml):void 0,a={};return i.fontSizePt!==void 0&&(a.fontSizePt=i.fontSizePt),i.kern!==void 0&&(a.kern=i.kern),i.typeface&&(a.typeface=i.typeface),i.panose&&(a.panose=i.panose),s&&(a.fontFamilyCss=s),a}getDocumentFonts(){const t=[...new Set(this.inlineDocumentFonts||[])],n=this.getDocumentDefaultStyles?.()||{},r=typeof n.typeface=="string"?n.typeface:null,i=typeof n.fontFamilyCss=="string"?n.fontFamilyCss:null,o=r||(i?i.split(",")[0]?.replace(/["']/g,"").trim():null),s=d=>{const f=[...d];return o&&!f.includes(o)&&f.push(o),f},a=this.convertedXml["word/fontTable.xml"];if(!a)return s(t);const l=a.elements?.find(d=>d.name==="w:fonts");if(!l||!l.elements)return s(t);const c=l.elements.filter(d=>d.name==="w:font").map(d=>d.attributes["w:name"]),u=[...t,...c];return s([...new Set(u)])}getFontFaceImportString(){const t=this.convertedXml["word/fontTable.xml"];if(!t||!Object.keys(this.fonts).length)return;const n=t.elements.find(s=>s.name==="w:fonts")?.elements.filter(s=>s.elements?.some(a=>a?.attributes&&a.attributes["r:id"]&&a.attributes["w:fontKey"]))?.reduce((s,a)=>{const l=a.elements.filter(c=>c.name.startsWith("w:embed"))?.map(c=>({...c,fontFamily:a.attributes["w:name"]}));return[...s,...l]},[]),{elements:r}=this.convertedXml["word/_rels/fontTable.xml.rels"]?.elements.find(s=>s.name==="Relationships")||{},i=[];let o="";for(const s of n){const a=r.find(y=>y.attributes.Id===s.attributes["r:id"])?.attributes?.Target;if(!a)return;const l=this.fonts[`word/${a}`]?.buffer;if(!l)return;const c=oZe(l,s.attributes["w:fontKey"]);if(!c)return;const u=new Blob([c],{type:"font/ttf"}),d=URL.createObjectURL(u),f=s.name.includes("Regular"),h=s.name.includes("Bold"),p=s.name.includes("Italic"),m=s.name.includes("Light"),g=f?"normal":h?"bold":m?"200":"normal";i.includes(s.fontFamily)||i.push(s.fontFamily),o+=`
|
|
92
92
|
@font-face {
|
|
93
93
|
font-style: ${p?"italic":"normal"};
|
|
94
94
|
font-weight: ${g};
|
|
@@ -386,7 +386,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
386
386
|
`;const Qo={undo:WKt,redo:E2e,bold:TKt,italic:IKt,underline:kKt,color:KKt,link:bj,image:FKt,alignLeft:BKt,alignRight:zKt,alignCenter:HKt,alignJustify:UKt,bulletList:S2e,bulletListDisc:S2e,bulletListCircle:EKt,bulletListSquare:CKt,numberedList:yj,numberedListDecimal:_Kt,numberedListDecimalParen:PKt,numberedListUpperRoman:RKt,numberedListLowerRoman:LKt,numberedListUpperAlpha:NKt,numberedListUpperAlphaParen:MKt,numberedListLowerAlpha:DKt,numberedListLowerAlphaParen:OKt,indentLeft:I2e,indentRight:T2e,directionLtr:aXt,directionRtl:lXt,pageBreak:XKt,copyFormat:k2e,clearFormatting:VKt,trackChanges:qKt,trackChangesFinal:YKt,trackChangesOriginal:_2e,trackChangesAccept:GKt,trackChangesReject:jKt,documentMode:C2e,documentEditingMode:C2e,documentSuggestingMode:P2e,documentViewingMode:_2e,colorOption:JKt,colorOptionCheck:aD,linkInput:bj,removeLink:vj,openLink:ZKt,overflow:R2e,dropdownCaretUp:QKt,dropdownCaretDown:L2e,ruler:$Kt,paintbrush:eXt,highlight:tXt,ai:N2e,table:M2e,tableActions:nXt,splitCell:D2e,mergeCells:O2e,addRowBefore:Fp,addRowAfter:Fp,addColumnBefore:Fp,addColumnAfter:Fp,deleteRow:gb,deleteColumn:gb,deleteTable:gb,deleteBorders:B2e,fixTables:F2e,lineHeight:rXt,search:iXt,cut:H2e,copy:z2e,paste:U2e,strikethrough:oXt,formattingMarks:sXt};$t(),jn();var cXt=["onClick","innerHTML","aria-label","onKeydown"],uXt={__name:"AlignmentButtons",emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=Op(),r=t,i=Me([]),o=[{key:"left",ariaLabel:"Align left",icon:Qo.alignLeft},{key:"center",ariaLabel:"Align center",icon:Qo.alignCenter},{key:"right",ariaLabel:"Align right",icon:Qo.alignRight},{key:"justify",ariaLabel:"Justify",icon:Qo.alignJustify}],s=u=>{r("select",u)},a=u=>{if(u===i.value.length-1)return;const d=i.value[u+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=u=>{if(u===0)return;const d=i.value[u-1];d&&(d.setAttribute("tabindex","0"),d.focus())},c=(u,d)=>{switch(u.key){case"ArrowLeft":l(d);break;case"ArrowRight":a(d);break;case"Enter":s(o[d].key);break;default:break}};return Ei(()=>{const u=i.value[0];u&&(u.setAttribute("tabindex","0"),u.focus())}),(u,d)=>(We(),$e("div",{class:kr(["alignment-buttons",{"high-contrast":Ct(n)}])},[(We(),$e(Pn,null,Ai(o,(f,h)=>ht("div",{key:f.key,class:"button-icon",onClick:p=>s(f.key),innerHTML:f.icon,"data-item":"btn-textAlign-option",role:"menuitem","aria-label":f.ariaLabel,ref_for:!0,ref_key:"alignmentButtonsRefs",ref:i,onKeydown:ir(p=>c(p,h),["prevent"])},null,40,cXt)),64))],2))}},dXt=Un(uXt,[["__scopeId","data-v-3f7f0d98"]]);$t(),jn();var fXt=["onClick","innerHTML","aria-label","onKeydown"],hXt={__name:"StyleButtonsList",props:{buttons:{type:Array,required:!0},selectedStyle:{type:String,default:null},iconSize:{type:Number,default:25}},emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=Op(),r=t,i=e,o=Me([]),s=ft(()=>({width:`${i.iconSize}px`,height:`${i.iconSize}px`})),a=d=>{r("select",d)},l=d=>{if(d===o.value.length-1)return;const f=o.value[d+1];f&&(f.setAttribute("tabindex","0"),f.focus())},c=d=>{if(d===0)return;const f=o.value[d-1];f&&(f.setAttribute("tabindex","0"),f.focus())},u=(d,f)=>{switch(d.key){case"ArrowLeft":c(f);break;case"ArrowRight":l(f);break;case"Enter":a(i.buttons[f].key);break;default:break}};return Ei(()=>{const d=o.value[0];d&&(d.setAttribute("tabindex","0"),d.focus())}),(d,f)=>(We(),$e("div",{class:kr(["style-buttons-list",{"high-contrast":Ct(n)}])},[(We(!0),$e(Pn,null,Ai(i.buttons,(h,p)=>(We(),$e("div",{key:h.key,class:kr(["button-icon",{selected:i.selectedStyle===h.key}]),style:On(s.value),onClick:m=>a(h.key),innerHTML:h.icon,role:"menuitem","aria-label":h.ariaLabel,ref_for:!0,ref_key:"buttonRefs",ref:o,onKeydown:ir(m=>u(m,p),["prevent"])},null,46,fXt))),128))],2))}},V2e=Un(hXt,[["__scopeId","data-v-d374ab76"]]);const pXt=[{key:"disc",icon:Qo.bulletListDisc,ariaLabel:"Opaque circle"},{key:"circle",icon:Qo.bulletListCircle,ariaLabel:"Outline circle"},{key:"square",icon:Qo.bulletListSquare,ariaLabel:"Opaque square"}],mXt=[{key:"decimal",icon:Qo.numberedListDecimal,ariaLabel:"1. 2. 3."},{key:"decimal-paren",icon:Qo.numberedListDecimalParen,ariaLabel:"1) 2) 3)"},{key:"upper-roman",icon:Qo.numberedListUpperRoman,ariaLabel:"I. II. III."},{key:"lower-roman",icon:Qo.numberedListLowerRoman,ariaLabel:"i. ii. iii."},{key:"upper-alpha",icon:Qo.numberedListUpperAlpha,ariaLabel:"A. B. C."},{key:"upper-alpha-paren",icon:Qo.numberedListUpperAlphaParen,ariaLabel:"A) B) C)"},{key:"lower-alpha",icon:Qo.numberedListLowerAlpha,ariaLabel:"a. b. c."},{key:"lower-alpha-paren",icon:Qo.numberedListLowerAlphaParen,ariaLabel:"a) b) c)"}];$t(),jn();var gXt=["onClick","onKeydown"],yXt={class:"document-mode-column icon-column"},bXt=["innerHTML"],vXt={class:"document-mode-column text-column"},wXt={class:"document-mode-type"},AXt={class:"document-mode-description"},xXt={__name:"DocumentMode",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=Me([]),{isHighContrastMode:i}=Op(),o=e,s=u=>{n("select",u)},a=u=>{if(u===r.value.length-1)return;const d=r.value[u+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=u=>{if(u===0)return;const d=r.value[u-1];d&&(d.setAttribute("tabindex","0"),d.focus())},c=(u,d)=>{switch(u.key){case"ArrowDown":a(d);break;case"ArrowUp":l(d);break;case"Enter":s(o.options[d]);break;default:break}};return Ei(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(u,d)=>(We(),$e("div",{class:kr(["document-mode",{"high-contrast":Ct(i)}])},[(We(!0),$e(Pn,null,Ai(e.options,(f,h)=>(We(),$e("div",{class:kr(["option-item",{disabled:f.disabled}]),onClick:p=>s(f),"data-item":"btn-documentMode-option",role:"menuitem",ref_for:!0,ref_key:"documentModeRefs",ref:r,onKeydown:ir(p=>c(p,h),["prevent"])},[ht("div",yXt,[ht("div",{class:"icon-column__icon",innerHTML:f.icon},null,8,bXt)]),ht("div",vXt,[ht("div",wXt,Xn(f.label),1),ht("div",AXt,Xn(f.description),1)])],42,gXt))),256))],2))}},SXt=Un(xXt,[["__scopeId","data-v-8587478e"]]);$t(),jn();var TXt={key:0,class:"linked-style-buttons","data-editor-ui-surface":""},IXt=["onClick","onKeydown","aria-label"],kXt={__name:"LinkedStyle",props:{editor:{type:Object,required:!0},selectedOption:{type:String}},emits:["select"],setup(e,{emit:t}){const n=t,r=Me([]),i=e,o=c=>{n("select",c)},s=c=>{if(c===r.value.length-1)return;const u=r.value[c+1];u.setAttribute("tabindex","0"),u.focus()},a=c=>{if(c===0)return;const u=r.value[c-1];u.setAttribute("tabindex","0"),u.focus()},l=(c,u,d)=>{switch(c.key){case"ArrowDown":s(u);break;case"ArrowUp":a(u);break;case"Enter":c.preventDefault(),o(d);break;default:break}};return Ei(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(c,u)=>i.editor?(We(),$e("div",TXt,[(We(!0),$e(Pn,null,Ai(Ct(fG)(e.editor),(d,f)=>(We(),$e("div",{class:kr(["style-item",{selected:e.selectedOption===d.id}]),onClick:h=>o(d),onKeydown:h=>l(h,f,d),"aria-label":`Linked style - ${d.id}`,ref_for:!0,ref_key:"styleRefs",ref:r},[ht("div",{class:"style-name",style:On(Ct(hG)(d,null,null,!1)),"data-item":"btn-linkedStyles-option"},Xn(d.definition.attrs.name),5)],42,IXt))),256))])):Ft("",!0)}},EXt=Un(kXt,[["__scopeId","data-v-80e74746"]]);$t(),jn();var CXt={key:0,class:"link-title"},_Xt={key:1,class:"link-title"},PXt={key:2,class:"link-title"},RXt={key:3,class:"link-title"},LXt={key:4,class:"link-input-wrapper"},NXt={class:"input-row text-input-row"},MXt=["readonly"],DXt={class:"input-row url-input-row"},OXt=["innerHTML"],FXt=["readonly","onKeydown"],BXt=["innerHTML"],HXt={key:0,class:"input-row link-buttons"},zXt=["innerHTML"],UXt={key:5,class:"input-row go-to-anchor clickable"},VXt={__name:"LinkInput",props:{showInput:{type:Boolean,default:!0},showLink:{type:Boolean,default:!0},goToAnchor:{type:Function,default:()=>{}},editor:{type:Object,required:!0},closePopover:{type:Function,default:()=>{}}},setup(e){const t=e,{isHighContrastMode:n}=Op(),r=Me(!1),i=()=>{if(!t.editor||!t.editor.state)return"";const{state:A}=t.editor,{selection:T}=A,I=A.schema.marks.link;if(T.empty){const R=Kf(T.$from,I);return R?A.doc.textBetween(R.from,R.to," "):""}const P=Kf(T.$from,I),C=Kf(T.$to,I);if(P||C){const R=P||C;return A.doc.textBetween(R.from,R.to," ")}return A.doc.textBetween(T.from,T.to," ")},o=()=>{if(!t.editor||!t.editor.state)return"";const{state:A}=t.editor,{schema:T,selection:I}=A,P=T.marks.link;if(!P)return"";let C="";const{$from:R,empty:k}=I;if(k){let L=(A.storedMarks||R.marks()).find(_=>_.type===P);if(!L){const _=R.nodeAfter,O=R.nodeBefore,F=_&&Array.isArray(_.marks)?_.marks:[],B=O&&Array.isArray(O.marks)?O.marks:[];L=F.find(U=>U.type===P)||B.find(U=>U.type===P)}L&&L.attrs&&L.attrs.href&&(C=L.attrs.href)}else A.doc.nodesBetween(I.from,I.to,L=>{if(L.marks){const _=L.marks.find(O=>O.type===P);_&&_.attrs&&_.attrs.href&&(C=_.attrs.href)}});return C||""},s=Me(""),a=Me(""),l=Me(!1),c=/^[a-z][a-z0-9+.-]*:/i,u=ft(()=>a.value?a.value.startsWith("#")||c.test(a.value)?a.value:"https://"+a.value:""),d=ft(()=>u.value?Ju(u.value):null),f=ft(()=>d.value!==null),h=ft(()=>!l.value&&!!o()),p=ft(()=>!f.value),m=ft(()=>t.editor?.options?.documentMode==="viewing"),g=()=>{const A=d.value?.href;A&&window.open(A,"_blank")},y=()=>{s.value=i(),a.value=o()};Wn(()=>t.editor?.state?.selection,()=>{y()},{immediate:!0});const v=()=>{const A=document.querySelector(".link-input-ctn input");A&&A.focus()};Ei(()=>{y(),l.value=a.value.startsWith("#"),t.showInput&&v()});const b=()=>{if(m.value)return;const A=t.editor;if(!A)return;if(!a.value){A.commands?.unsetLink&&A.commands.unsetLink(),t.closePopover();return}if(!f.value){r.value=!0;return}const T=d.value?.href;if(!T){r.value=!0;return}const I=s.value||T;A.commands?.toggleLink&&A.commands.toggleLink({href:T,text:I});const P=A.view.state.selection.$to.pos;A.view.dispatch(A.view.state.tr.setSelection(new Et(A.view.state.doc.resolve(P)))),setTimeout(()=>A.view.focus(),100),t.closePopover()},w=()=>{t.editor&&t.editor.commands&&t.editor.commands.unsetLink&&(t.editor.commands.unsetLink(),t.closePopover())},x=A=>{const T=t.editor?.presentationEditor??null;T?T.goToAnchor(A):t.goToAnchor&&t.goToAnchor(A)};return(A,T)=>(We(),$e("div",{class:kr(["link-input-ctn",{"high-contrast":Ct(n)}])},[l.value?(We(),$e("div",CXt,"Page anchor")):m.value?(We(),$e("div",_Xt,"Link details")):h.value?(We(),$e("div",PXt,"Edit link")):(We(),$e("div",RXt,"Add link")),e.showInput&&!l.value?(We(),$e("div",LXt,[ht("div",NXt,[T[5]||(T[5]=ht("div",{class:"input-icon text-input-icon"},"T",-1)),_d(ht("input",{type:"text",name:"text",placeholder:"Text","onUpdate:modelValue":T[0]||(T[0]=I=>s.value=I),readonly:m.value,onKeydown:T[1]||(T[1]=Lf(ir(I=>!m.value&&b,["stop","prevent"]),["enter"]))},null,40,MXt),[[Xh,s.value]])]),ht("div",DXt,[ht("div",{class:"input-icon",innerHTML:Ct(Qo).linkInput},null,8,OXt),_d(ht("input",{type:"text",name:"link",placeholder:"Type or paste a link",class:kr({error:r.value}),"onUpdate:modelValue":T[2]||(T[2]=I=>a.value=I),readonly:m.value,onKeydown:[Lf(ir(b,["stop","prevent"]),["enter"]),T[3]||(T[3]=I=>r.value=!1)]},null,42,FXt),[[Xh,a.value]]),ht("div",{class:kr(["open-link-icon",{disabled:!f.value}]),innerHTML:Ct(Qo).openLink,onClick:g,"data-item":"btn-link-open"},null,10,BXt)]),m.value?Ft("",!0):(We(),$e("div",HXt,[h.value?(We(),$e("button",{key:0,class:"remove-btn",onClick:w,"data-item":"btn-link-remove"},[ht("div",{class:"remove-btn__icon",innerHTML:Ct(Qo).removeLink},null,8,zXt),T[6]||(T[6]=q0(" Remove ",-1))])):Ft("",!0),ht("button",{class:kr(["submit-btn",{"disable-btn":p.value}]),onClick:b,"data-item":"btn-link-apply"}," Apply ",2)]))])):l.value?(We(),$e("div",UXt,[ht("a",{onClick:T[4]||(T[4]=ir(I=>x(a.value),["stop","prevent"]))},"Go to "+Xn(a.value.startsWith("#_")?a.value.substring(2):a.value),1)])):Ft("",!0)],2))}},mE=Un(VXt,[["__scopeId","data-v-56a53c8c"]]);$t(),jn();var WXt=["aria-label","onClick","onKeydown"],GXt=["innerHTML"],jXt=["innerHTML"],lD=7,qXt={__name:"IconGridRow",props:{icons:{type:Array,required:!0},activeColor:{type:Object,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=e,i=ft(()=>p=>r.activeColor.value?r.activeColor.value.toUpperCase()===p.value:!1),o=(p,m)=>m===5||["#FFFFFF","#FAFF09"].includes(p)?{color:"#000"}:{color:"#FFF"},s=p=>{n("select",p.value)},a=Me([]),l=Me([]);Ei(()=>{if(!r.icons.every(m=>Array.isArray(m)))throw new Error("icon props must be 2d array");const p=l.value[0];p&&(p.setAttribute("tabindex","0"),p.focus())});const c=(p,m)=>{const g=lD*p+m+1,y=l.value[g];y&&(y.setAttribute("tabindex","0"),y.focus())},u=(p,m)=>{const g=lD*p+m-1,y=l.value[g];y&&(y.setAttribute("tabindex","0"),y.focus())},d=(p,m)=>{const g=m+lD*(p+1),y=l.value[g];y&&(y.setAttribute("tabindex","0"),y.focus())},f=(p,m)=>{const g=m+lD*(p-1),y=l.value[g];y&&(y.setAttribute("tabindex","0"),y.focus())},h=(p,m,g,y)=>{switch(p.key){case"ArrowRight":c(m,g);break;case"ArrowLeft":u(m,g);break;case"ArrowDown":d(m,g);break;case"ArrowUp":f(m,g);break;case"Enter":s(y);break;case"Escape":n("clickoutside");break;default:break}};return(p,m)=>(We(!0),$e(Pn,null,Ai(e.icons,(g,y)=>(We(),$e("div",{class:"option-row",key:y,role:"group",ref_for:!0,ref_key:"rowRefs",ref:a},[(We(!0),$e(Pn,null,Ai(g,(v,b)=>(We(),$e("div",{class:"option",key:b,"aria-label":v.label,role:"menuitem",ref_for:!0,ref_key:"iconRefs",ref:l,onClick:ir(w=>s(v),["stop","prevent"]),onKeydown:ir(w=>h(w,y,b,v),["prevent"])},[ht("div",{class:"option__icon",innerHTML:v.icon,style:On(v.style)},null,12,GXt),i.value(v)?(We(),$e("div",{key:0,class:"option__check",innerHTML:Ct(Qo).colorOptionCheck,style:On(o(v.value,b))},null,12,jXt)):Ft("",!0)],40,WXt))),128))]))),128))}},W2e=Un(qXt,[["__scopeId","data-v-59855ce7"]]),YXt=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 512c53.2 0 101.4-21.6 136.1-56.6l-298.3-235C140 257.1 128 292.3 128 320c0 106 86 192 192 192zM505.2 370.7c4.4-16.2 6.8-33.1 6.8-50.7c0-91.2-130.2-262.3-166.6-308.3C339.4 4.2 330.5 0 320.9 0l-1.8 0c-9.6 0-18.5 4.2-24.5 11.7C277.8 33 240.7 81.3 205.8 136L38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L505.2 370.7zM224 336c0 44.2 35.8 80 80 80c8.8 0 16 7.2 16 16s-7.2 16-16 16c-61.9 0-112-50.1-112-112c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>
|
|
387
387
|
`;$t(),jn();var KXt={class:"options-grid-wrap"},XXt=["innerHTML"],JXt={class:"option-grid-ctn"},ZXt={__name:"IconGrid",props:{icons:{type:Array,required:!0},customIcons:{type:Array,required:!1},activeColor:{type:Object,required:!1},hasNoneIcon:{type:Boolean,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=i=>{n("select",i)};return(i,o)=>(We(),$e("div",KXt,[e.hasNoneIcon?(We(),$e("div",{key:0,class:"none-option",role:"menuitem","aria-label":"Clear color selection",onClick:o[0]||(o[0]=s=>r("none"))},[ht("span",{innerHTML:Ct(YXt),class:"none-icon"},null,8,XXt),o[1]||(o[1]=q0(" None ",-1))])):Ft("",!0),ht("div",JXt,[Er(W2e,{icons:e.icons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"]),e.customIcons.flat().length?(We(),$e(Pn,{key:0},[o[2]||(o[2]=ht("span",{class:"option-grid-ctn__subtitle"},"Custom colors",-1)),Er(W2e,{icons:e.customIcons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"])],64)):Ft("",!0)])]))}},G2e=Un(ZXt,[["__scopeId","data-v-b243fab8"]]);$t();var QXt=e=>{e.expand.value=!1};const Vn=(e,t=null)=>({label:t,icon:Qo.colorOption,value:e,style:{color:e,boxShadow:"0 0 5px 1px rgba(0, 0, 0, 0.1)",borderRadius:"50%"}}),wj=(e,t,n=[],r=!1)=>{const i=o=>{t.iconColor.value=o,e.emitCommand({item:t,argument:o}),QXt(t)};return js("div",{},[js(G2e,{icons:Aj,customIcons:n,activeColor:t.iconColor,hasNoneIcon:r,onSelect:i})])},Aj=[[Vn("#111111","black"),Vn("#333333","dark gray"),Vn("#5C5C5C","medium gray"),Vn("#858585","light gray"),Vn("#ADADAD","very light gray"),Vn("#D6D6D6","transparent gray"),Vn("#FFFFFF","white")],[Vn("#860028","dark red"),Vn("#D2003F","red"),Vn("#DB3365","coral red"),Vn("#E4668C","light red"),Vn("#ED99B2","pale pink"),Vn("#F6CCD9","transparent pink"),Vn("#FF004D","bright pink")],[Vn("#83015E","dark purple"),Vn("#CD0194","purple"),Vn("#D734A9","orchid"),Vn("#E167BF","light purple"),Vn("#EB99D4","lavender"),Vn("#F5CCEA","transparent pink"),Vn("#FF00A8","neon pink")],[Vn("#8E220A","maroon"),Vn("#DD340F","red-orange"),Vn("#E45C3F","burnt orange"),Vn("#EB856F","peach"),Vn("#F1AE9F","pale peach"),Vn("#F8D6CF","transparent peach"),Vn("#FF7A00","orange")],[Vn("#947D02","olive"),Vn("#E7C302","mustard yellow"),Vn("#ECCF35","yellow"),Vn("#F1DB67","light yellow"),Vn("#F5E79A","very pale yellow"),Vn("#FAF3CC","transparent yellow"),Vn("#FAFF09","neon yellow")],[Vn("#055432","forest green"),Vn("#07834F","green"),Vn("#399C72","medium green"),Vn("#6AB595","light green"),Vn("#9CCDB9","mint"),Vn("#CDE6DC","transparent mint"),Vn("#05F38F","bright teal")],[Vn("#063E7E","navy blue"),Vn("#0A60C5","blue"),Vn("#3B80D1","sky blue"),Vn("#6CA0DC","cornflower blue"),Vn("#9DBFE8","light blue"),Vn("#CEDFF3","very light blue"),Vn("#21c8ce","cyan")],[Vn("#3E027A","deep purple"),Vn("#6103BF","indigo"),Vn("#8136CC","violet"),Vn("#A068D9","lavender pink"),Vn("#C09AE6","light lilac"),Vn("#DFCDF2","transparent lilac"),Vn("#A91DFF","neon purple")]],$Xt=()=>Aj.flat().map(e=>e.value);$t(),jn();var eJt=["data-cols","data-rows","onKeydown","onClick"],tJt=["aria-valuetext"],cD=5,nJt={__name:"TableGrid",emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=Me(0),i=Me(0),{isHighContrastMode:o}=Op(),s=Me([]),a=d=>{let f=d.target;f.dataset.grid||l([...f.parentElement.querySelectorAll("[data-item]")],parseInt(f.dataset.cols,10),parseInt(f.dataset.rows,10))},l=(d,f,h)=>{i.value=f,r.value=h;for(let p=0;p<d.length;p++){let m=d[p],g=parseInt(m.dataset.cols,10),y=parseInt(m.dataset.rows,10);g<=f&&y<=h?m.classList.add("selected"):m.classList.remove("selected")}},c=({cols:d,rows:f})=>{n("select",{cols:d,rows:f})},u=(d,f,h)=>{let p=f-1,m=h-1;switch(d.key){case"ArrowRight":{if(p>=4)return;const g=m*cD;s.value[g+p+1].setAttribute("tabindex","0"),s.value[g+p+1].focus(),l(s.value,f+1,h);break}case"ArrowLeft":{if(p<=0)return;const g=m*cD;s.value[g+p-1].setAttribute("tabindex","0"),s.value[g+p-1].focus(),l(s.value,f-1,h);break}case"ArrowDown":{if(m>=4)return;const g=(m+1)*cD;s.value[g+p].setAttribute("tabindex","0"),s.value[g+p].focus(),l(s.value,f,h+1);break}case"ArrowUp":{if(m<=0)return;const g=(m-1)*cD;s.value[g+p].setAttribute("tabindex","0"),s.value[g+p].focus(),l(s.value,f,h-1);break}case"Enter":c({cols:f,rows:h});break;default:break}};return Ei(()=>{s.value[0].setAttribute("tabindex","0"),s.value[0].focus(),l(s.value,1,1)}),(d,f)=>(We(),$e("div",{class:kr(["toolbar-table-grid-wrapper",{"high-contrast":Ct(o)}])},[ht("div",{class:"toolbar-table-grid",onMouseover:a,"data-grid":"true"},[(We(),$e(Pn,null,Ai(5,h=>(We(),$e(Pn,{key:h},[(We(),$e(Pn,null,Ai(5,p=>ht("div",{class:"toolbar-table-grid__item",key:`${h}_${p}`,"data-cols":p,"data-rows":h,"data-item":"true",ref_for:!0,ref_key:"tableGridItems",ref:s,onKeydown:ir(m=>u(m,p,h),["prevent"]),onClick:ir(m=>c({cols:p,rows:h}),["stop","prevent"])},null,40,eJt)),64))],64))),64))],32),ht("div",{class:"toolbar-table-grid-value","aria-valuetext":`${r.value} x ${i.value}`},Xn(r.value)+" x "+Xn(i.value),9,tJt)],2))}},j2e=Un(nJt,[["__scopeId","data-v-5cefb109"]]);$t(),jn();var rJt={class:"toolbar-table-actions"},iJt=["onClick","data-item","ariaLabel"],oJt={class:"toolbar-table-actions__icon"},sJt=["innerHTML"],aJt={class:"toolbar-table-actions__label"},lJt={__name:"TableActions",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=i=>{n("select",{command:i.command})};return(i,o)=>(We(),$e("div",rJt,[(We(!0),$e(Pn,null,Ai(e.options,s=>(We(),$e("div",{class:kr(["toolbar-table-actions__item",{"toolbar-table-actions__item--border":s.bottomBorder}]),onClick:a=>r(s),"data-item":s.props?.["data-item"]||"",ariaLabel:s.props?.ariaLabel,role:"menuitem"},[ht("div",oJt,[ht("div",{class:"toolbar-table-actions__icon-wrapper",innerHTML:s.icon},null,8,sJt)]),ht("div",aJt,Xn(s.label),1)],10,iJt))),256))]))}},q2e=Un(lJt,[["__scopeId","data-v-652015c8"]]);function cJt(e){let t=e;for(;t;){const n=window.getComputedStyle(t).overflowY;if(/(auto|scroll)/.test(n)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return document.scrollingElement||document.documentElement}function uJt(e,t={behavior:"smooth",block:"start"}){if(!e)return;const n=cJt(e),r=n.getBoundingClientRect(),i=e.getBoundingClientRect().top-r.top+n.scrollTop;n.scrollTo({top:t.block==="start"?i:i-n.clientHeight+e.offsetHeight,behavior:t.behavior})}var dJt=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
|
|
388
388
|
`;$t(),jn();var fJt={class:"search-input-ctn"},hJt={class:"row"},pJt=["onKeydown"],mJt={__name:"SearchInput",props:{searchRef:{type:Object}},emits:["submit"],setup(e,{emit:t}){const n=Me(""),r=t,i=()=>{r("submit",{value:n.value})};return(o,s)=>(We(),$e("div",fJt,[ht("div",hJt,[_d(ht("input",{ref:e.searchRef,"onUpdate:modelValue":s[0]||(s[0]=a=>n.value=a),class:"search-input",type:"text",name:"search",placeholder:"Type search string",onKeydown:Lf(ir(i,["stop","prevent"]),["enter"])},null,40,pJt),[[Xh,n.value]])]),ht("div",{class:"row submit"},[ht("button",{class:"submit-btn",onClick:i},"Apply")])]))}},gJt=Un(mJt,[["__scopeId","data-v-bfe34b7b"]]);const yJt=[{label:"Georgia",key:"Georgia, serif",fontWeight:400,props:{style:{fontFamily:"Georgia, serif"},"data-item":"btn-fontFamily-option"}},{label:"Arial",key:"Arial, sans-serif",fontWeight:400,props:{style:{fontFamily:"Arial, sans-serif"},"data-item":"btn-fontFamily-option"}},{label:"Courier New",key:"Courier New, monospace",fontWeight:400,props:{style:{fontFamily:"Courier New, monospace"},"data-item":"btn-fontFamily-option"}},{label:"Times New Roman",key:"Times New Roman, serif",fontWeight:400,props:{style:{fontFamily:"Times New Roman, serif"},"data-item":"btn-fontFamily-option"}}],bJt=[{label:"8",key:"8pt",props:{"data-item":"btn-fontSize-option"}},{label:"9",key:"9pt",props:{"data-item":"btn-fontSize-option"}},{label:"10",key:"10pt",props:{"data-item":"btn-fontSize-option"}},{label:"11",key:"11pt",props:{"data-item":"btn-fontSize-option"}},{label:"12",key:"12pt",props:{"data-item":"btn-fontSize-option"}},{label:"14",key:"14pt",props:{"data-item":"btn-fontSize-option"}},{label:"18",key:"18pt",props:{"data-item":"btn-fontSize-option"}},{label:"24",key:"24pt",props:{"data-item":"btn-fontSize-option"}},{label:"30",key:"30pt",props:{"data-item":"btn-fontSize-option"}},{label:"36",key:"36pt",props:{"data-item":"btn-fontSize-option"}},{label:"48",key:"48pt",props:{"data-item":"btn-fontSize-option"}},{label:"60",key:"60pt",props:{"data-item":"btn-fontSize-option"}},{label:"72",key:"72pt",props:{"data-item":"btn-fontSize-option"}},{label:"96",key:"96pt",props:{"data-item":"btn-fontSize-option"}}],gE={sm:768,md:1024,lg:1280,xl:1410},uD={undo:"undo",redo:"redo",bold:"bold",italic:"italic",underline:"underline",strike:"strikethrough",acceptTrackedChangeBySelection:"track-changes-accept-selection",rejectTrackedChangeOnSelection:"track-changes-reject-selection",ruler:"ruler",formattingMarks:"formatting-marks",zoom:"zoom",documentMode:"document-mode",link:"link",fontFamily:"font-family",fontSize:"font-size",list:"bullet-list",numberedlist:"numbered-list",table:"table-insert",image:"image",color:"text-color",highlight:"highlight-color",textAlign:"text-align",lineHeight:"line-height",linkedStyles:"linked-style",indentleft:"indent-decrease",indentright:"indent-increase",directionLtr:"direction-ltr",directionRtl:"direction-rtl",clearFormatting:"clear-formatting",copyFormat:"copy-format"},Y2e={addRowBefore:"table-add-row-before",addRowAfter:"table-add-row-after",deleteRow:"table-delete-row",addColumnBefore:"table-add-column-before",addColumnAfter:"table-add-column-after",deleteColumn:"table-delete-column",deleteTable:"table-delete",deleteCellAndTableBorders:"table-remove-borders",mergeCells:"table-merge-cells",splitCell:"table-split-cell",fixTables:"table-fix"},K2e=Object.values(Y2e),vJt=[...new Set([...Object.values(uD),...K2e])];var wJt=new Set(["link"]);const X2e=new Set(Object.keys(uD).filter(e=>!wJt.has(e)));$t();var ph=e=>{e.expand.value=!1};const AJt=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:i,availableWidth:o,role:s,isDev:a=!1}={})=>{const l=Ii({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),c=(r??yJt).map(cKt),u=Ii({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:c,onActivate:({fontFamily:Se})=>{if(!Se)return;Se=Se.split(",")[0],u.label.value=Se;const ne=c.find(Y=>Y.label===u.defaultLabel.value),Oe=c.find(Y=>Y.label===Se);Oe?u.selectedValue.value=Oe.key:ne?u.selectedValue.value=ne.key:u.selectedValue.value=""},onDeactivate:()=>{u.label.value=u.defaultLabel.value;const Se=c.find(ne=>ne.label===u.defaultLabel.value);Se?u.selectedValue.value=Se.key:u.selectedValue.value=""}}),d=Ii({type:"dropdown",dropdownStyles:{padding:0,outline:"none"},name:"ai",tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>{let Se="";if(e.activeEditor){const{state:Oe}=e.activeEditor,{from:Y,to:we,empty:Fe}=Oe.selection;Se=Fe?"":Oe.doc.textBetween(Y,we)}return js("div",{},[js(sD,{handleClose:()=>{ph(d)},selectedText:Se,editor:e.activeEditor,apiKey:e.config.aiApiKey,endpoint:e.config.aiEndpoint,superToolbar:e})])}}]}),f=bJt,h=Ii({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",minWidth:"50px",markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:f,onActivate:({fontSize:Se},ne=!1)=>{if(ne){h.label.value="",h.selectedValue.value="";return}const Oe=f.find(ae=>ae.label===String(h.defaultLabel.value));if(!Se){h.label.value=h.defaultLabel.value,Oe?h.selectedValue.value=Oe.key:h.selectedValue.value="";return}let Y=aKt(Se,12);Y<8&&(Y=8),Y>96&&(Y=96);let we=String(Y);const Fe=f.find(ae=>ae.label===we||ae.key===we);Fe?h.selectedValue.value=Fe.key:h.selectedValue.value="",h.label.value=we},onDeactivate:()=>{h.label.value=h.defaultLabel.value;const Se=f.find(ne=>ne.label===String(h.defaultLabel.value));Se?h.selectedValue.value=Se.key:h.selectedValue.value=""}}),p=Ii({type:"separator",name:"separator",isNarrow:!0}),m=Ii({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),g=Ii({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),y=Ii({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),v=Ii({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>wj(e,v,[],!0)}],onActivate:({color:Se})=>{v.iconColor.value=Se||""},onDeactivate:()=>v.iconColor.value=""}),b=Ii({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>wj(e,b)}],onActivate:({color:Se})=>{b.iconColor.value=Se},onDeactivate:()=>b.iconColor.value="#000"}),w=Me(null),x=Ii({type:"dropdown",name:"search",active:!1,icon:t.search,tooltip:n.search,group:"right",inputRef:w,attributes:{ariaLabel:"Search"},options:[{type:"render",key:"searchDropdown",render:()=>A()}]}),A=()=>js("div",{},[js(gJt,{onSubmit:({value:ne})=>{e.activeEditor.commands.search(ne,{searchModel:"visible"})},searchRef:w})]),T=Ii({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>I(T)}],onActivate:({href:Se})=>{Se?T.attributes.value={href:Se}:T.attributes.value={}},onDeactivate:()=>{T.attributes.value={},T.expand.value=!1}});function I(Se){return js("div",{},[js(mE,{editor:e.activeEditor,closePopover:()=>ph(Se),goToAnchor:()=>{if(ph(Se),!e.activeEditor||!Se.attributes.value?.href)return;const ne=Se.attributes.value?.href?.slice(1),Oe=e.activeEditor.element.querySelector(`a[name='${ne}']`);Oe&&uJt(Oe)}})])}const P=Ii({type:"options",name:"linkInput",command:"toggleLink",active:!1});T.childItem=P,P.parentItem=T;const C=Ii({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),R=Ii({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>k(R)}]});function k(Se){return js("div",{},[js(j2e,{onSelect:Oe=>{e.emitCommand({item:Se,argument:Oe}),ph(Se)}})])}const L=Ii({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>O(L)}]}),_=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function O(Se){return js(q2e,{options:_,onSelect:ne=>{ph(Se);const{command:Oe}=ne;e.emitCommand({item:Se,argument:{command:Oe}})}})}const F=Ii({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>js("div",{},[js(dXt,{onSelect:ne=>{ph(F);const Oe={...F,command:"setTextAlign"};Oe.command="setTextAlign",e.emitCommand({item:Oe,argument:ne}),B(F,ne)}})]),key:"alignment"}],onActivate:({textAlign:Se})=>{B(F,Se)},onDeactivate:()=>{B(F,"left")}}),B=(Se,ne)=>{let Oe=ne==="both"?"justify":ne,Y={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},we=Y[Oe]??Y.left;Se.icon.value=we},U=Ii({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const Se=ne=>{ph(U);const Oe={...U,command:"toggleBulletListStyle"};e.emitCommand({item:Oe,argument:ne})};return js(V2e,{buttons:pXt,iconSize:25,selectedStyle:U.selectedValue.value,onSelect:Se})}}]}),M=Ii({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const Se=ne=>{ph(M);const Oe={...M,command:"toggleOrderedListStyle"};e.emitCommand({item:Oe,argument:ne})};return js(V2e,{buttons:mXt,iconSize:30,selectedStyle:M.selectedValue.value,onSelect:Se})}}]}),z=Ii({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),Z=Ii({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),Q=Ii({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),W=Ii({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:Se})=>{Se&&(W.label.value=Se)}}),he=Ii({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),K=Ii({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),X=Ii({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),ee=Ii({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),be=Ii({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),xe=Ii({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),pe=(Se,ne)=>Se==="editor"?ne:Se==="suggester"?ne.filter(Oe=>Oe.value==="suggesting"):ne.filter(Oe=>Oe.value==="viewing"),ke=Se=>Se==="editor"?"Editing":Se==="suggester"?"Suggesting":"Viewing",V=Ii({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:ke(s),label:ke(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>N(V)}]}),D=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function N(Se){return js(SXt,{options:pe(s,D),onSelect:ne=>{ph(Se);const{label:Oe,icon:Y}=ne;V.label.value=Oe,V.icon.value=Y,e.emitCommand({item:V,argument:Oe})}})}const q=new Map([["separator",20],["zoom",71],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["ai",32],["default",32]]),oe=Ii({type:"button",name:"ruler",command:"toggleRuler",icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),J=Ii({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),re=Me(null),te=Ii({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const Se=ne=>{ph(te);const Oe={...te,command:"setLinkedStyle"};e.emitCommand({item:Oe,argument:ne}),re.value=ne.id};return js("div",{},[js(EXt,{editor:e.activeEditor,onSelect:Se,selectedOption:re.value})])}}],onActivate:({styleId:Se})=>{const ne=fG(e.activeEditor)?.find(Oe=>Oe.id===Se);te.label.value=ne&&ne.id!=="Normal"?ne.definition.attrs.name:n.formatText,te.disabled.value=!1},onDeactivate:()=>{te.disabled.value=!0,te.label.value=n.formatText}}),fe=(Se,ne)=>{if(ne.value==Se)return js("div",{innerHTML:dJt,class:"dropdown-select-icon"})},de=Ii({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(Se=>({label:Se.toFixed(2),key:Se,icon:()=>fe(Se,de.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),ue=20,ie=120,ce=32,Te=["linkedStyles","clearFormatting","copyFormat","ruler","formattingMarks"],ye=["zoom","fontFamily","fontSize","redo"],le=o<=gE.lg,Ae=e.config?.showFormattingMarksButton===!0;le&&(V.attributes.value={...V.attributes.value,className:`${V.attributes.value.className} toolbar-item--doc-mode-compact`}),le&&(te.attributes.value={...te.attributes.value,className:`${te.attributes.value.className} toolbar-item--linked-styles-compact`});let _e=[he,K,X,ee,W,u,p,h,p,l,m,g,y,b,v,p,T,C,R,L,p,F,U,M,z,Z,de,p,te,p,oe,...Ae?[J]:[],xe,be,d,Q,V];if(e.config?.superdoc?.config?.modules?.ai||(_e=_e.filter(Se=>Se.name.value!=="ai")),o<=gE.md&&i&&(_e=_e.filter(Se=>Se.type!=="separator")),e.config.mode!=="docx"){const Se=_e.findIndex(Oe=>Oe.name.value==="linkedStyles");_e.splice(Se-1,2);const ne=["ruler","zoom","undo","redo"];_e=_e.filter(Oe=>!ne.includes(Oe.name.value))}const Ue=[];a||(s==="viewer"&&Ue.push(X,ee),_e=_e.filter(Se=>!Ue.includes(Se)));const st=[x,he,Q,V].map(Se=>Se.name),me=Se=>st.includes(Se.name),Ie=[],Re=[];let ve=ce+ie;return _e.forEach(Se=>{const ne=q.get(Se.name.value)||q.get("default");if(o<gE.xl+ue&&Te.includes(Se.name.value)&&i){if(Ie.push(Se),Se.name.value==="linkedStyles"){const Oe=_e.findIndex(Y=>Y.name.value==="linkedStyles");_e.splice(Oe+1,1)}return}if(o<gE.sm&&ye.includes(Se.name.value)&&i){Ie.push(Se);return}if(me(Se)){Re.push(Se),ve+=ne;return}ve<o||!i?(Re.push(Se),ve+=ne):Ie.push(Se)}),{defaultItems:Re,overflowItems:Ie.filter(Se=>Se.type!=="separator")}};$t(),jn();var xJt={class:"toolbar-icon"},SJt=["innerHTML"],TJt={__name:"ToolbarButtonIcon",props:{name:{type:String,required:!0},color:{type:String,default:null},icon:{type:String,default:null}},setup(e){const t=e,n=ft(()=>{if(t.name==="color")return{backgroundColor:t.color||"#111111"};if(t.name==="highlight")return{backgroundColor:t.color||"#D6D6D6"}}),r=ft(()=>["color","highlight"].includes(t.name));return(i,o)=>(We(),$e("div",xJt,[ht("div",{class:kr(["toolbar-icon__icon",[`toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,SJt),r.value?(We(),$e("div",{key:0,class:"color-bar",style:On(n.value)},null,4)):Ft("",!0)]))}},J2e=Un(TJt,[["__scopeId","data-v-8c30c125"]]);$t(),jn();var IJt=["role","aria-label"],kJt=["data-item"],EJt=["data-item"],CJt={key:1,class:"button-label"},_Jt=["data-item","aria-label"],PJt=["innerHTML"],RJt={key:1,class:"button-label"},LJt={key:2},NJt=["onKeydown","id"],MJt=["placeholder","onKeydown","id"],DJt=["innerHTML"],OJt={"aria-live":"polite",class:"visually-hidden"},FJt={__name:"ToolbarButton",props:{iconColor:{type:String,default:null},active:{type:Boolean,default:!1},isNarrow:{type:Boolean,default:!1},isWide:{type:Boolean,default:!1},toolbarItem:{type:Object,required:!0},defaultLabel:{type:String,default:null},isOverflowItem:{type:Boolean,default:!1},allowEnterPropagation:{type:Boolean,default:!1}},emits:["buttonClick","textSubmit","mainClick"],setup(e,{emit:t}){const n=t,r=e,{name:i,active:o,icon:s,label:a,hideLabel:l,iconColor:c,hasCaret:u,splitButton:d,disabled:f,expand:h,inlineTextInputVisible:p,hasInlineTextInput:m,minWidth:g,style:y,attributes:v}=r.toolbarItem,b=ft(()=>!!d?.value&&!!u?.value),w=Me(a),x=Me(null),{isHighContrastMode:A}=Op(),T=()=>{m&&er(()=>{x.value?.focus(),x.value?.select()}),n("buttonClick")},I=O=>{f?.value||(O?.stopPropagation(),n("mainClick"))},P=()=>{b.value||T()},C=O=>{if(b.value){I(O);return}T()},R=O=>{r.allowEnterPropagation||O.stopPropagation(),C(O)},k=()=>{const O=w.value,F=O.match(/^\d+(\.5)?$/)?O:Math.floor(parseFloat(O)).toString();n("textSubmit",F),w.value=F},L=ft(()=>y.value?y.value:{minWidth:r.minWidth}),_=ft(()=>h?.value?Qo.dropdownCaretUp:Qo.dropdownCaretDown);return(O,F)=>(We(),$e("div",{class:kr(["toolbar-item",Ct(v).className]),style:On(L.value),role:e.isOverflowItem?"menuitem":"button","aria-label":Ct(v).ariaLabel,onClick:P,onKeydown:F[3]||(F[3]=Lf(B=>R(B),["enter"])),tabindex:"0"},[ht("div",{class:kr(["toolbar-button",{active:Ct(o),disabled:Ct(f),narrow:e.isNarrow,wide:e.isWide,split:b.value,"has-inline-text-input":Ct(m),"high-contrast":Ct(A)}]),"data-item":`btn-${Ct(i)||""}`},[b.value?(We(),$e("div",{key:0,class:"toolbar-button__main","data-item":`btn-${Ct(i)||""}-main`,onClick:F[0]||(F[0]=B=>I(B))},[Ct(s)?(We(),Ar(J2e,{key:0,color:Ct(c),class:"toolbar-icon",icon:Ct(s),name:Ct(i)},null,8,["color","icon","name"])):Ft("",!0),Ct(a)&&!Ct(l)&&!Ct(p)?(We(),$e("div",CJt,Xn(Ct(a)),1)):Ft("",!0)],8,EJt)):Ft("",!0),b.value?(We(),$e("div",{key:1,class:"toolbar-button__caret","data-item":`btn-${Ct(i)||""}-caret`,"aria-label":`${Ct(v).ariaLabel} options`,role:"button"},[ht("div",{class:"dropdown-caret",innerHTML:_.value,style:On({opacity:Ct(f)?.6:1})},null,12,PJt)],8,_Jt)):(We(),$e(Pn,{key:2},[Ct(s)?(We(),Ar(J2e,{key:0,color:Ct(c),class:"toolbar-icon",icon:Ct(s),name:Ct(i)},null,8,["color","icon","name"])):Ft("",!0),Ct(a)&&!Ct(l)&&!Ct(p)?(We(),$e("div",RJt,Xn(Ct(a)),1)):Ft("",!0),Ct(p)?(We(),$e("span",LJt,[Ct(i)==="fontSize"?_d((We(),$e("input",{key:0,"onUpdate:modelValue":F[1]||(F[1]=B=>w.value=B),onKeydown:Lf(ir(k,["prevent"]),["enter"]),type:"text",class:kr(["button-text-input button-text-input--font-size",{"high-contrast":Ct(A)}]),id:"inlineTextInput-"+Ct(i),autocomplete:"off",ref_key:"inlineInput",ref:x},null,42,NJt)),[[Xh,w.value]]):_d((We(),$e("input",{key:1,"onUpdate:modelValue":F[2]||(F[2]=B=>w.value=B),placeholder:Ct(a),onKeydown:Lf(ir(k,["prevent"]),["enter"]),type:"text",class:"button-text-input",id:"inlineTextInput-"+Ct(i),autocomplete:"off",ref_key:"inlineInput",ref:x},null,40,MJt)),[[Xh,w.value]])])):Ft("",!0),Ct(u)?(We(),$e("div",{key:3,class:"dropdown-caret",innerHTML:_.value,style:On({opacity:Ct(f)?.6:1})},null,12,DJt)):Ft("",!0)],64)),ht("div",OJt,Xn(`${Ct(v).ariaLabel} ${Ct(o)?"selected":"unset"}`),1)],10,kJt)],46,IJt))}},xj=Un(FJt,[["__scopeId","data-v-dcf6ef0b"]]);$t(),jn();var BJt={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},HJt={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=Op(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(i,o)=>(We(),$e("div",BJt,[ht("div",{class:"separator-inner",style:On({backgroundColor:r()})},null,4)]))}},zJt=Un(HJt,[["__scopeId","data-v-d027f7fc"]]);$t(),jn();var UJt={class:"overflow-menu"},VJt={class:"overflow-menu-trigger"},WJt={key:0,class:"overflow-menu_items",role:"group"},GJt={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0}},emits:["buttonClick","close"],setup(e,{emit:t}){const{proxy:n}=wc(),r=t,i=e,o=ft(()=>i.toolbarItem.expand.value),s=Me(!1),a=ft(()=>({...i.toolbarItem,active:o.value})),l=()=>{r("buttonClick",i.toolbarItem)},c=({item:d,argument:f})=>{n.$toolbar.emitCommand({item:d,argument:f})},u=d=>{d.key==="Escape"&&o.value&&!s.value&&(d.preventDefault(),r("close"))};return Ei(()=>{document.addEventListener("keydown",u,!0)}),Oo(()=>{document.removeEventListener("keydown",u,!0)}),(d,f)=>(We(),$e("div",UJt,[ht("div",VJt,[Er(xj,{"toolbar-item":a.value,onButtonClick:l},null,8,["toolbar-item"])]),o.value?(We(),$e("div",WJt,[Er(fD,{class:"superdoc-toolbar-overflow","toolbar-items":e.overflowItems,"from-overflow":"",onCommand:c,onDropdownUpdateShow:f[0]||(f[0]=h=>s.value=h)},null,8,["toolbar-items"])])):Ft("",!0)]))}},jJt=Un(GJt,[["__scopeId","data-v-35b48dff"]]);$t(),jn();var qJt={class:"toolbar-dropdown"},YJt=["onClick"],KJt={key:0,class:"toolbar-dropdown-option__icon"},XJt={class:"toolbar-dropdown-option__label"},dD='button, [href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])',JJt={__name:"ToolbarDropdown",props:{options:{type:Array,default:()=>[]},show:{type:Boolean,required:!0},placement:{type:String,default:"bottom-start"},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})},menuProps:{type:Function,default:null},nodeProps:{type:Function,default:null}},emits:["update:show","select"],setup(e,{emit:t}){const n=e,r=t,i=Me(null),o=Me(null),s=Me({top:"0px",left:"0px"}),a=Me([]),l=Me(-1),c=ft(()=>!!n.show),u=ft(()=>n.options.some(K=>K?.type==="render")),d=ft(()=>typeof n.menuProps!="function"?{}:n.menuProps()||{}),f=ft(()=>{const{class:K,style:X,...ee}=d.value;return ee}),h=ft(()=>{const K=d.value.class,X=n.options.length>0&&n.options.every(ee=>ee&&ee.type==="render");return["toolbar-dropdown-menu",K,{"toolbar-dropdown-menu--render-only":X}]}),p=ft(()=>{const K=d.value.style||{};return{...n.contentStyle,...K}}),m=ft(()=>({...p.value,position:"fixed",top:s.value.top,left:s.value.left,zIndex:2e3})),g=K=>{r("update:show",K)},y=()=>{c.value&&g(!1)},v=()=>{if(!i.value)return;const K=i.value.getBoundingClientRect(),X=o.value?.offsetWidth??0,ee=window.innerWidth||document.documentElement.clientWidth||0,be=8;let xe=K.left;n.placement==="bottom-end"&&(xe=K.right-X);const pe=Math.max(be,ee-X-be);xe=Math.min(Math.max(be,xe),pe),s.value={top:`${K.bottom+4}px`,left:`${xe}px`}},b=()=>{n.disabled||g(!c.value)},w=K=>typeof n.nodeProps!="function"?{}:n.nodeProps(K)||{},x=K=>{K?.disabled||K?.type!=="render"&&(r("select",K?.key,K),y())},A=K=>K?.type==="render",T=K=>!K?.disabled&&K?.type!=="render",I=K=>typeof K?.icon=="function"||!!K?.icon,P=K=>typeof K?.icon=="function"?K.icon(K):K?.icon||null,C=K=>K?typeof K=="string"?K.split(/\s+/).includes("selected"):Array.isArray(K)?K.some(C):typeof K=="object"?!!K.selected:!1:!1,R=K=>C(K?.props?.class)||C(K?.class),k=()=>n.options.map((K,X)=>T(K)?X:-1).filter(K=>K>=0),L=()=>{const K=n.options.findIndex(X=>T(X)&&R(X));return K>=0?K:k()[0]??-1},_=(K,X)=>{if(!K){delete a.value[X];return}a.value[X]=K},O=()=>{a.value.forEach((X,ee)=>{X&&X.setAttribute("tabindex",ee===l.value?"0":"-1")});const K=a.value[l.value];K&&typeof K.focus=="function"&&K.focus()},F=K=>{const X=k();if(!X.length){l.value=-1;return}const ee=X.indexOf(l.value);if(ee<0){l.value=K>0?X[0]:X[X.length-1];return}l.value=X[(ee+K+X.length)%X.length]},B=()=>{let K=n.options[l.value];if(!T(K)){const X=k()[0];K=X===void 0?null:n.options[X]}K&&x(K)},U=pT({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(K){return()=>typeof K.option.render!="function"?null:K.option.render()}}),M=pT({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(K){return()=>P(K.option)}}),z=K=>{if(!c.value)return;const X=K.target;if(!(X instanceof Element))return;const ee=i.value?.contains(X),be=o.value?.contains(X);ee||be||y()},Z=Me(null),Q=()=>{const K=i.value,X=document.activeElement;if(K&&X instanceof HTMLElement&&K.contains(X)){Z.value=X;return}Z.value=K?.matches?.(dD)?K:K?.querySelector(dD)},W=()=>{const K=Z.value;if(K instanceof HTMLElement&&document.contains(K)){K.focus();return}const X=i.value;if(!X)return;const ee=X.matches?.(dD)?X:X.querySelector(dD);if(ee instanceof HTMLElement){ee.focus();return}X.setAttribute("tabindex","-1"),X.focus()},he=K=>{if(!c.value)return;const{key:X}=K;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(X)){if(X==="Escape"){K.preventDefault(),y(),er(()=>{requestAnimationFrame(W)});return}if(!u.value){if(K.preventDefault(),X==="ArrowDown"){F(1),O();return}if(X==="ArrowUp"){F(-1),O();return}X==="Enter"&&B()}}};return Wn(c,async K=>{if(!K){l.value=-1,a.value=[];return}Q(),await er(),v(),!u.value&&(l.value=L(),O())},{immediate:!0}),Wn(c,K=>{K?(document.addEventListener("pointerdown",z,!0),document.addEventListener("keydown",he,!0),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0)):(document.removeEventListener("pointerdown",z,!0),document.removeEventListener("keydown",he,!0),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0))},{immediate:!0}),Oo(()=>{document.removeEventListener("pointerdown",z,!0),document.removeEventListener("keydown",he,!0),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}),(K,X)=>(We(),$e("div",qJt,[ht("div",{ref_key:"triggerRef",ref:i,class:"toolbar-dropdown-trigger",onClick:b},[gT(K.$slots,"trigger",{},void 0,!0)],512),(We(),Ar(Sv,{to:"body"},[Er(LB,{name:"fade-in-scale-up-transition"},{default:Cd(()=>[c.value?(We(),$e("div",xm({key:0,ref_key:"menuRef",ref:o,class:h.value,style:m.value},f.value),[(We(!0),$e(Pn,null,Ai(e.options,(ee,be)=>(We(),$e("div",xm({key:ee.key,ref_for:!0,ref:xe=>_(xe,be),class:["toolbar-dropdown-option",[ee.class,ee.props?.class,{disabled:ee.disabled,render:A(ee)}]],tabindex:"-1",onClick:xe=>x(ee)},{ref_for:!0},{...ee.props,...w(ee)}),[A(ee)?(We(),Ar(Ct(U),{key:0,option:ee},null,8,["option"])):(We(),$e(Pn,{key:1},[I(ee)?(We(),$e("span",KJt,[Er(Ct(M),{option:ee},null,8,["option"])])):Ft("",!0),ht("span",XJt,Xn(ee.label),1)],64))],16,YJt))),128))],16)):Ft("",!0)]),_:1})]))]))}},ZJt=Un(JJt,[["__scopeId","data-v-261e2a66"]]);$t(),jn();var QJt=Object.assign({inheritAttrs:!1},{__name:"SdTooltip",props:{trigger:{type:String,default:"hover"},delay:{type:Number,default:100},duration:{type:Number,default:100},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})}},setup(e){const t=e,n=UGe(),r=Me(!1),i=Me(null),o=Me(null),s=Me({top:"0px",left:"0px"});let a=null,l=null;const c=ft(()=>["sd-tooltip-content",n.class]),u=ft(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),d=()=>{a&&(window.clearTimeout(a),a=null)},f=()=>{l&&(window.clearTimeout(l),l=null)},h=()=>{if(!i.value||!o.value)return;const T=i.value.getBoundingClientRect(),I=o.value.offsetWidth,P=o.value.offsetHeight,C=window.innerWidth||document.documentElement.clientWidth||0,R=8;let k=T.left+T.width/2-I/2;k=Math.max(R,Math.min(k,C-I-R)),s.value={top:`${T.top-P-10}px`,left:`${k}px`}},p=async()=>{t.disabled||(d(),f(),!r.value&&(r.value=!0,await er(),h()))},m=()=>{f(),d(),r.value&&(r.value=!1)},g=()=>{if(d(),f(),!r.value){if(t.delay===0){p();return}l=window.setTimeout(()=>{l=null,p()},t.delay)}},y=()=>{if(f(),d(),!!r.value){if(t.duration===0){m();return}a=window.setTimeout(()=>{a=null,m()},t.duration)}},v=()=>{t.trigger==="hover"&&g()},b=()=>{t.trigger==="hover"&&y()},w=()=>{f(),d()},x=()=>{y()},A=T=>{T.key==="Escape"&&m()};return Wn(()=>t.disabled,T=>{T&&m()}),Wn(r,T=>{T?(window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),document.addEventListener("keydown",A,!0)):(window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),document.removeEventListener("keydown",A,!0))}),Oo(()=>{f(),d(),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),document.removeEventListener("keydown",A,!0)}),(T,I)=>(We(),$e(Pn,null,[ht("span",{ref_key:"triggerRef",ref:i,class:"sd-tooltip-trigger",onMouseenter:v,onMouseleave:b,onFocusin:v,onFocusout:b},[gT(T.$slots,"trigger",{},void 0,!0)],544),(We(),Ar(Sv,{to:"body"},[Er(LB,{name:"fade-in-scale-up-transition"},{default:Cd(()=>[r.value&&!e.disabled?(We(),$e("div",{key:0,ref_key:"contentRef",ref:o,class:kr(c.value),style:On(u.value),onMouseenter:w,onMouseleave:x},[I[0]||(I[0]=ht("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),gT(T.$slots,"default",{},void 0,!0)],38)):Ft("",!0)]),_:3})]))],64))}}),Z2e=Un(QJt,[["__scopeId","data-v-d8dd2f5a"]]);$t(),jn();var $Jt=["onKeydown","tabindex","data-item-id"],eZt={key:0},tZt={key:0},nZt={key:0},rZt={__name:"ButtonGroup",props:{toolbarItems:{type:Array,required:!0},overflowItems:{type:Array,default:()=>[]},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},position:{type:String,default:"left"},fromOverflow:{type:Boolean,default:!1},compactSideGroups:{type:Boolean,default:!1}},emits:["command","item-clicked","dropdown-update-show"],setup(e,{emit:t}){const n=t,{proxy:r}=wc(),i=Me([]),o=Me(null),s=e,a=Me(null),{isHighContrastMode:l}=Op(),c=window.matchMedia("(max-width: 768px)").matches,u=ft(()=>s.position==="left"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-start"}:s.position==="right"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-end"}:{flexGrow:c?0:1,justifyContent:"center"}),d=U=>U.type==="button",f=U=>U.type==="dropdown",h=U=>U.type==="separator",p=U=>U.type==="overflow",m=U=>{if(!U)return!1;const M=U.expand;return typeof M=="object"&&M!==null&&"value"in M?!!M.value:!!M},g=(U,M)=>{U?.expand&&(U.expand.value=M)},y=(U,M=null)=>{if(!U.disabled.value){if(p(U)){const z=!m(U);z&&w(),g(U,z),a.value=z?U:null,n("item-clicked");return}f(U)||(a.value&&f(a.value)&&m(a.value)&&w(),n("item-clicked"),n("command",{item:U,argument:M??U.argument?.value??null}))}},v=(U,M)=>{U.disabled.value||(a.value=null,n("command",{item:U,argument:M}))},b=U=>{if(U.disabled.value)return;w();const M=U.splitButtonCommand,z=U.command,Z=M||z;if(!Z)return;const Q={...U,command:Z};n("item-clicked"),n("command",{item:Q,argument:null})},w=()=>{const U=r?.$toolbar?.toolbarItems||[],M=r?.$toolbar?.overflowItems||[],z=[...U,...M];(z.length?z:s.toolbarItems).forEach(Z=>{const Q=p(Z)&&!s.fromOverflow;(f(Z)||Q)&&g(Z,!1)}),a.value=null},x=(U,M)=>{w(),n("command",{item:U,argument:U.dropdownValueKey.value?M[U.dropdownValueKey.value]:M.label,option:M}),U.selectedValue.value=M.key},A=U=>U.nestedOptions?.value?.length?U.nestedOptions.value.map(M=>{const z=M?.type!=="render"&&U.selectedValue.value===M.key;return{...M,props:{...M.props,class:z?"selected":""}}}):[],T=(U,M)=>({role:"menuitem",ariaLabel:`${M.attributes.value.ariaLabel} - ${U.label}`}),I=U=>{const M=U.target,z=U.target.closest(".toolbar-item-ctn").nextElementSibling;z&&(M.setAttribute("tabindex","-1"),z.setAttribute("tabindex","0"),z.focus())},P=U=>{const M=U.target,z=U.target.closest(".toolbar-item-ctn").previousElementSibling;z&&(M.setAttribute("tabindex","-1"),z.setAttribute("tabindex","0"),z.focus())},C=U=>{const M=U.target.closest(".button-group").nextElementSibling;if(M)M.setAttribute("tabindex","0"),M.focus();else{const z=document.querySelector(".ProseMirror");z&&z.focus()}},R=U=>{const M=U.target.closest(".button-group").previousElementSibling;M&&(M.setAttribute("tabindex","0"),M.focus())},k=U=>{if(!U.disabled.value){if(f(U)){O(!m(U),U);return}y(U,null,!1)}},L=(U,M)=>{const z=U.target.nodeName==="INPUT"||U.target.nodeName==="TEXTAREA",Z=M.name.value==="fontSize";if(!(z&&Z)&&["Enter"," ","Spacebar","Escape","ArrowRight","ArrowLeft","Tab"].includes(U.key))switch(U.preventDefault(),U.key){case"Enter":case" ":case"Spacebar":k(M);break;case"Escape":w();break;case"ArrowRight":w(),I(U);break;case"ArrowLeft":w(),P(U);break;case"Tab":U.shiftKey?R(U):C(U);break;default:break}},_=U=>{const M=i.value.find(z=>!z.classList.contains("disabled"));M&&(M.setAttribute("tabindex","0"),M.focus())},O=(U,M)=>{if(n("item-clicked"),!U){w(),n("dropdown-update-show",!1);return}w(),a.value=M,g(M,!0),n("dropdown-update-show",!0)},F=U=>{if(!a.value)return;const M=U.target;M instanceof Element&&(M.closest(".sd-toolbar-dropdown-menu")||o.value?.contains(M)||w())};return Wn(()=>m(a.value),U=>{U?document.addEventListener("pointerdown",F,!0):document.removeEventListener("pointerdown",F,!0)},{immediate:!0}),Oo(()=>{document.removeEventListener("pointerdown",F,!0)}),(U,M)=>(We(),$e("div",{style:On(u.value),class:"button-group",role:"group",onFocus:_,ref_key:"buttonGroupRef",ref:o},[(We(!0),$e(Pn,null,Ai(e.toolbarItems,(z,Z)=>(We(),$e("div",{key:z.id.value,class:kr([{narrow:z.isNarrow.value,wide:z.isWide.value,disabled:z.disabled.value},"toolbar-item-ctn"]),onKeydown:Q=>L(Q,z),ref_for:!0,ref_key:"toolbarItemRefs",ref:i,tabindex:Z===0?0:-1,"data-item-id":z.id.value},[h(z)?(We(),Ar(zJt,{key:0,style:{width:"20px"}})):Ft("",!0),f(z)&&z.nestedOptions?.value?.length?(We(),Ar(ZJt,{key:1,options:A(z),disabled:z.disabled.value,show:m(z),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"toolbar-button sd-editor-toolbar-dropdown",onSelect:(Q,W)=>x(z,W),"onUpdate:show":Q=>O(Q,z),style:On(z.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":Ct(l)}]}),"node-props":Q=>T(Q,z)},{trigger:Cd(()=>[Er(Z2e,{trigger:"hover",disabled:!z.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Cd(()=>[Er(xj,{"toolbar-item":z,disabled:z.disabled.value,"allow-enter-propagation":!0,onTextSubmit:Q=>v(z,Q),onMainClick:Q=>b(z)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick"])]),default:Cd(()=>[ht("div",null,[q0(Xn(z.tooltip)+" ",1),z.disabled.value?(We(),$e("span",eZt,"(disabled)")):Ft("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):d(z)?(We(),Ar(Z2e,{key:2,trigger:"hover",class:"sd-editor-toolbar-tooltip","content-style":{fontFamily:s.uiFontFamily}},{trigger:Cd(()=>[Er(xj,{"toolbar-item":z,"is-overflow-item":e.fromOverflow,onTextSubmit:Q=>v(z,Q),onButtonClick:Q=>y(z)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:Cd(()=>[z.tooltip?(We(),$e("div",tZt,[q0(Xn(z.tooltip)+" ",1),z.disabled.value?(We(),$e("span",nZt,"(disabled)")):Ft("",!0)])):Ft("",!0)]),_:2},1032,["content-style"])):Ft("",!0),p(z)&&e.overflowItems.length?(We(),Ar(jJt,{key:3,"toolbar-item":z,onButtonClick:Q=>y(z),"overflow-items":e.overflowItems,onClose:w},null,8,["toolbar-item","onButtonClick","overflow-items"])):Ft("",!0)],42,$Jt))),128))],36))}},fD=Un(rZt,[["__scopeId","data-v-109576cd"]]);$t(),jn();var iZt="Arial, Helvetica, sans-serif",oZt={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=wc();let r=Me(1);const i=Me(!1);let o=null;const s=ft(()=>{const w=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof w=="string"&&w.trim()?w.trim():iZt}),a=n.$toolbar.config?.toolbarGroups?.includes("left"),l=n.$toolbar.config?.toolbarGroups?.includes("right"),c=n.$toolbar.config?.toolbarButtonsExclude||[],u=w=>n.$toolbar.getToolbarItemByGroup(w).filter(x=>!c.includes(x.name.value)),d=()=>{i.value=n.$toolbar.getAvailableWidth()<=gE.lg},f=async w=>{if(w.metaKey&&w.key==="f"){const x=n.$toolbar.getToolbarItemByName("search");x&&(w.preventDefault(),x.expand.value=!0,await er(),x.inputRef.value&&x.inputRef.value.focus())}},p=lKt(async()=>{await n.$toolbar.onToolbarResize(),d(),r.value+=1},300);function m(){window.removeEventListener("resize",p),window.removeEventListener("keydown",f),o?.disconnect(),o=null}function g(){m(),window.addEventListener("resize",p),window.addEventListener("keydown",f),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(o=new ResizeObserver(()=>{p()}),o.observe(n.$toolbar.toolbarContainer)),d()}Ei(g),Gte(g),jte(m),Oo(m);const y=({item:w,argument:x,option:A})=>{n.$toolbar.emitCommand({item:w,argument:x,option:A})},v=()=>{const w=n.$toolbar.activeEditor;w&&(w.options?.isHeaderOrFooter||w.commands?.restoreSelection())},b=w=>{w.target.closest('input, textarea, [contenteditable="true"]')||w.preventDefault()};return(w,x)=>(We(),$e("div",{class:"superdoc-toolbar",key:Ct(r),role:"toolbar","aria-label":"Toolbar","data-editor-ui-surface":"",onMousedown:b},[Ct(a)?(We(),Ar(fD,{key:0,tabindex:"0","toolbar-items":u("left"),"compact-side-groups":i.value,"ui-font-family":s.value,position:"left",onCommand:y,onItemClicked:v,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","compact-side-groups","ui-font-family"])):Ft("",!0),Er(fD,{tabindex:"0","toolbar-items":u("center"),"overflow-items":Ct(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":s.value,position:"center",onCommand:y,onItemClicked:v},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),Ct(l)?(We(),Ar(fD,{key:1,tabindex:"0","toolbar-items":u("right"),"compact-side-groups":i.value,"ui-font-family":s.value,position:"right",onCommand:y,onItemClicked:v,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","compact-side-groups","ui-font-family"])):Ft("",!0)],32))}},Q2e=Un(oZt,[["__scopeId","data-v-bae4cd8a"]]);const $2e={bold:"Bold",fontFamily:"Font",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",directionLtr:"Left-to-right",directionRtl:"Right-to-left",zoom:"Zoom",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",formattingMarks:"Show or hide formatting marks",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},sZt=(e,t={})=>{const n=e?.runProperties?.fontFamily;if(!n)return null;const[r]=Gm({fontFamily:n},t);return r?.attrs?.fontFamily??null},aZt=e=>{let t=null;return e&&(e.startsWith("#")||e.startsWith(".")?t=document.querySelector(e):t=document.getElementById(e),!t)?null:t};$t();var e_e=class Hee extends fF.default{static#e=new Set(["bold","italic","underline","strike","highlight","color","fontSize","fontFamily"]);config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...Qo},texts:{...$2e},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,editor:null,aiApiKey:null,aiEndpoint:null,customButtons:[],showFormattingMarksButton:!1};constructor(t){if(super(),this.config={...this.config,...t},this.toolbarItems=[],this.overflowItems=[],this.isDev=t.isDev||!1,this.superdoc=t.superdoc,this.role=t.role||"editor",this.toolbarContainer=null,this.controller=null,this.snapshot=null,this._unsubscribeController=null,this.config.editor&&(this.config.mode=this.config.editor.options.mode),this.config.icons={...Qo,...t.icons},this.config.texts={...$2e,...t.texts},this.config.hideButtons=t.hideButtons??!0,this.config.responsiveToContainer=t.responsiveToContainer??!1,this.pendingMarkCommands=[],this.stickyStoredMarks=null,this._boundEditorHandlers={transaction:null,selectionUpdate:null,focus:null},this._restoreFocusTimeoutId=null,!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=aZt(this.config.selector),this.toolbarContainer){const n=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",n)}this.#t(),this.#i({superToolbar:this,icons:this.config.icons,texts:this.config.texts,fonts:this.config.fonts,hideButtons:this.config.hideButtons,isDev:t.isDev}),!(this.config.selector&&!this.toolbarContainer)&&(this.app=kT(Q2e),this.app.directive("click-outside",$8),this.app.config.globalProperties.$toolbar=this,this.toolbarContainer&&(this.toolbar=this.app.mount(this.toolbarContainer)),this.activeEditor=t.editor||null,this.initHeadlessToolbar(),this.updateToolbarState())}createHeadlessToolbar(){return this.superdoc?iKt({superdoc:this.superdoc,commands:vJt}):null}initHeadlessToolbar(){this.superdoc&&(this.destroyHeadlessToolbar(),this.controller=this.createHeadlessToolbar(),this.snapshot=this.controller.getSnapshot(),this._unsubscribeController=this.controller.subscribe(({snapshot:t})=>{this.snapshot=t,this.updateToolbarState()}))}destroyHeadlessToolbar(){this._unsubscribeController?.(),this.controller?.destroy(),this.controller=null,this.snapshot=null,this._unsubscribeController=null}#t(){this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}setActiveEditor(t){this.activeEditor&&this._boundEditorHandlers.transaction&&(this.activeEditor.off("transaction",this._boundEditorHandlers.transaction),this.activeEditor.off("selectionUpdate",this._boundEditorHandlers.selectionUpdate),this.activeEditor.off("focus",this._boundEditorHandlers.focus),this._boundEditorHandlers.transaction=null,this._boundEditorHandlers.selectionUpdate=null,this._boundEditorHandlers.focus=null),this.activeEditor=t,t&&(this._boundEditorHandlers.transaction=this.onEditorTransaction.bind(this),this._boundEditorHandlers.selectionUpdate=this.onEditorSelectionUpdate.bind(this),this._boundEditorHandlers.focus=this.onEditorFocus.bind(this),this.activeEditor.on("transaction",this._boundEditorHandlers.transaction),this.activeEditor.on("selectionUpdate",this._boundEditorHandlers.selectionUpdate),this.activeEditor.on("focus",this._boundEditorHandlers.focus))}getToolbarItemByGroup(t){return this.toolbarItems.filter(n=>(n.group?.value||"center")===t)}getToolbarItemByName(t){return this.toolbarItems.find(n=>n.name.value===t)}getAvailableWidth(){const t=document.documentElement.clientWidth,n=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?n:t}#i({superToolbar:t,icons:n,texts:r,fonts:i,hideButtons:o,isDev:s=!1}={}){const{defaultItems:a,overflowItems:l}=AJt({superToolbar:t,toolbarIcons:n,toolbarTexts:r,toolbarFonts:i,hideButtons:o,availableWidth:this.getAvailableWidth(),role:this.role,isDev:s}),c=this.config.customButtons||[];c.length&&a.push(...c.map(d=>Ii({...d})));let u=[...a.map(d=>d.name.value),...l.map(d=>d.name.value)];this.config.groups&&(u=Object.values(this.config.groups).flatMap(d=>d)),this.toolbarItems=a.filter(d=>u.includes(d.name.value)).filter(d=>!this.config.excludeItems.includes(d.name.value)),this.overflowItems=l.filter(d=>u.includes(d.name.value))}#n(){if(!this.activeEditor||!this.activeEditor.converter)return;const{typeface:t="Arial",fontSizePt:n=12}=this.activeEditor.converter.getDocumentDefaultStyles()??{},r=this.toolbarItems.find(o=>o.name.value==="fontSize");r&&(r.defaultLabel.value=n);const i=this.toolbarItems.find(o=>o.name.value==="fontFamily");i&&(i.defaultLabel.value=t)}#r(){if(!this.activeEditor||!this.activeEditor.converter||!this.activeEditor.converter.docHiglightColors.size)return;const t=this.toolbarItems.find(s=>s.name.value==="highlight");if(!t)return;const n=$Xt(),r=7,i=Array.from(this.activeEditor.converter.docHiglightColors).reduce((s,a,l)=>{const c=Math.floor(l/r);return s[c]||(s[c]=[]),n.includes(a)||s[c].push(Vn(a)),s},[]),o={key:"color",type:"render",render:()=>wj(this,t,i,!0)};t.nestedOptions.value=[o]}#o(){const t=this.getToolbarItemByName("documentMode");if(!t)return;const n=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),r=this.config.texts||{},i=this.config.icons||{},o={editing:{label:r.documentEditingMode||"Editing",icon:i.documentEditingMode||i.documentMode},suggesting:{label:r.documentSuggestingMode||"Suggesting",icon:i.documentSuggestingMode||i.documentMode},viewing:{label:r.documentViewingMode||"Viewing",icon:i.documentViewingMode||i.documentMode}},s=o[n]||o.editing;t.label?.value!==void 0&&(t.label.value=s.label),t.defaultLabel?.value!==void 0&&(t.defaultLabel.value=s.label),t.icon?.value!==void 0&&s.icon&&(t.icon.value=s.icon)}#l(){if(!this.activeEditor?.state)return null;const{state:t}=this.activeEditor,n=t.selection;if(!n?.empty)return null;const r=Sl(i=>i.type.name==="paragraph")(n);return!r||r.node?.content?.size!==0?null:sZt(kl(this.activeEditor,r.node,t.doc.resolve(r.pos)),this.activeEditor?.converter?.convertedXml??{})||null}#c(t){return!!t?.active&&t?.value==null}#u(t){if(t.name.value==="tableActions"){const a=K2e.map(l=>this.snapshot?.commands?.[l]).some(l=>l&&!l.disabled);return t.setDisabled(!a),!0}const n=uD[t.name.value];if(!n)return!1;const r=this.snapshot?.commands?.[n],i=()=>{t.setDisabled(!!r?.disabled)},o={textAlign:()=>{r?.value?t.activate({textAlign:r.value}):t.deactivate()},lineHeight:()=>{t.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const a=typeof r.value=="number"?`${r.value}%`:String(r.value);t.onActivate({zoom:a})}},documentMode:()=>{this.#o()},link:()=>{t.active.value=!!r?.active,t.attributes.value=r?.value?{href:r.value}:{}},fontFamily:()=>{if(r?.value!=null){t.activate({fontFamily:r.value});return}const a=this.#l();if(a){t.activate({fontFamily:a});return}t.deactivate()},fontSize:()=>{if(r?.value!=null){t.activate({fontSize:r.value});return}if(this.#c(r)){t.activate({},!0);return}t.deactivate()},color:()=>{r?.value!=null?t.activate({color:r.value}):t.deactivate()},highlight:()=>{r?.value!=null?t.activate({color:r.value}):t.deactivate()},linkedStyles:()=>{r?.value!=null?t.activate({styleId:r.value}):t.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(t.activate(),t.selectedValue.value=fge(r.value)):(t.deactivate(),t.selectedValue.value=null)},numberedlist:()=>{r?.active?(t.activate(),t.selectedValue.value=r.value):(t.deactivate(),t.selectedValue.value=null)},default:()=>{r?.active?t.activate():t.deactivate()}},s=o[t.name.value]??o.default;return i(),s(),!0}#d(t,n){const r=t?.name?.value==="tableActions",i=r?Y2e[n?.command]:uD[t?.name?.value];return!i||!this.controller?.execute?!1:(r?this.controller.execute(i):this.controller.execute(i,n),!0)}updateToolbarState(){this.#o(),this.#n(),this.#r();const t=this.snapshot?.commands?.["document-mode"]?.value||"editing";if(!this.activeEditor||t==="viewing"){this.#f(),this.toolbarItems.forEach(r=>{r.allowWithoutEditor?.value&&this.#u(r)});return}const{state:n}=this.activeEditor;if(!n){this.#f();return}[...this.toolbarItems,...this.overflowItems].forEach(r=>{r.resetDisabled(),this.#u(r)})}onToolbarResize=()=>{this.#i({superToolbar:this,icons:this.config.icons,texts:this.config.texts,fonts:this.config.fonts,hideButtons:this.config.hideButtons,isDev:this.isDev}),this.role==="viewer"&&this.#f(),this.updateToolbarState()};#f(){this.activeEditor=null,this.toolbarItems.forEach(t=>{const{allowWithoutEditor:n}=t;n.value||t.setDisabled(!0)})}onEditorTransaction({transaction:t}){!t.docChanged&&!t.selectionSet||this.updateToolbarState()}#a(){!this.activeEditor||this.activeEditor.options.isHeaderOrFooter||(clearTimeout(this._restoreFocusTimeoutId),this._restoreFocusTimeoutId=setTimeout(()=>{this._restoreFocusTimeoutId=null,!(!this.activeEditor||this.activeEditor.options.isHeaderOrFooter)&&this.activeEditor.focus()},0))}emitCommand({item:t,argument:n,option:r}){const i=this.activeEditor?.view?.hasFocus,o=!!(typeof i=="function"&&i.call(this.activeEditor.view)),{command:s}=t,a=this.isMarkToggle(t),l=!!t?.restoreEditorFocus,c=n!=null,u=t?.type==="dropdown"&&!c,d=t?.command==="setFontFamily"||t?.command==="setFontSize";if(!(u&&d)){if(!o&&a&&!this.activeEditor?.options?.isHeaderOrFooter){this.pendingMarkCommands.push({command:s,argument:n,item:t});const f=t?.labelAttr?.value;f&&n?t?.activate?.({[f]:n}):t?.activate?.(),this.activeEditor&&!this.activeEditor.options.isHeaderOrFooter&&this.activeEditor.focus();return}if(this.activeEditor&&!this.activeEditor.options.isHeaderOrFooter&&this.activeEditor.focus(),!!s){if(t?.name?.value==="tableActions"&&this.#d(t,n)){this.updateToolbarState();return}if(X2e.has(t?.name?.value)&&this.#d(t,n)){a&&this.#s(),this.updateToolbarState(),l&&this.#a();return}if(this.activeEditor&&this.activeEditor.commands&&s in this.activeEditor.commands)this.activeEditor.commands[s](n);else if(typeof s=="function")s({item:t,argument:n,option:r});else{const f=new Error(`[super-toolbar 🎨] Command not found: ${s}`);throw this.emit("exception",{error:f,editor:this.activeEditor}),f}a&&this.#s(),this.updateToolbarState(),l&&this.#a()}}}onEditorSelectionUpdate(){if(this.activeEditor){if(this.pendingMarkCommands.length){const t=this.pendingMarkCommands;this.pendingMarkCommands=[],t.forEach(({command:n,argument:r,item:i})=>{if(n)try{if(X2e.has(i?.name?.value)&&this.#d(i,r)){this.#y({command:n,argument:r});return}this.activeEditor.commands&&n in this.activeEditor.commands&&this.activeEditor.commands[n](r),this.#y({command:n,argument:r})}catch(o){const s=new Error(`[super-toolbar 🎨] Failed to execute pending command: ${n}`);this.emit("exception",{error:s,editor:this.activeEditor,originalError:o}),console.error(s,o)}}),this.#s(),this.updateToolbarState();return}this.#w()&&this.updateToolbarState()}}onEditorFocus(){if(this.pendingMarkCommands.length){this.onEditorSelectionUpdate();return}this.#w()&&this.updateToolbarState()}isMarkToggle(t){const n=t?.name?.value;return Hee.#e.has(n)}#s(){if(!this.activeEditor)return;const{selection:t,storedMarks:n}=this.activeEditor.state||{};t?.empty&&(this.stickyStoredMarks=n?.length?[...n]:null)}#w(){if(!this.activeEditor||!this.stickyStoredMarks?.length)return!1;const{state:t,view:n}=this.activeEditor,{selection:r,storedMarks:i}=t||{};if(!r?.empty||i?.length||!n?.dispatch||!t?.tr||Xu(this.activeEditor).some(s=>Hee.#e.has(s.name)))return!1;const o=t.tr.setStoredMarks(this.stickyStoredMarks);return n.dispatch(o),!0}#y({command:t,argument:n}){if(!this.activeEditor||!this.activeEditor.state?.selection?.empty||this.activeEditor.state?.storedMarks?.length||t!=="setFontSize")return;const{state:r,view:i}=this.activeEditor,o=r.schema?.marks?.textStyle;if(!o||!i?.dispatch||!r?.tr)return;const[s,a]=Bf(n??"");if(Number.isNaN(s))return;const l=Math.min(96,Math.max(8,Number(s))),c=a||"pt",u=o.create({fontSize:`${l}${c}`}),d=r.tr.setStoredMarks([u]);i.dispatch(d)}destroy(){this._restoreFocusTimeoutId!==null&&(clearTimeout(this._restoreFocusTimeoutId),this._restoreFocusTimeoutId=null),this.destroyHeadlessToolbar(),this.app?.unmount()}},lZt=class zee{static createSchemaByExtensions(t,n){const r=t.filter(a=>a.type==="node"),i=t.filter(a=>a.type==="mark"),o=r.find(a=>Jn(a,"topNode"))?.name,s=cn.getAttributesFromExtensions(t);return new nse({topNode:o,nodes:zee.#e(r,s,n),marks:zee.#t(i,s,n)})}static#e(t,n,r){const i=t.map(o=>{const s=n.filter(p=>p.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:r},l=Object.fromEntries(s.map(p=>[p.name,{default:p?.attribute?.default}])),c=t.reduce((p,m)=>{const g=Jn(m,"extendNodeSchema",a);return{...p,...g?g(o):{}}},{}),u=X7({content:wo(Jn(o,"content",a)),group:wo(Jn(o,"group",a)),marks:wo(Jn(o,"marks",a)),inline:wo(Jn(o,"inline",a)),atom:wo(Jn(o,"atom",a)),selectable:wo(Jn(o,"selectable",a)),draggable:wo(Jn(o,"draggable",a)),code:wo(Jn(o,"code",a)),defining:wo(Jn(o,"defining",a)),isolating:wo(Jn(o,"isolating",a)),leafText:Jn(o,"leafText",a),summary:Jn(o,"summary",a),attrs:l,...c});(typeof o.validChildren=="function"||Array.isArray(o.validChildren))&&Object.defineProperty(u,"validChildren",{enumerable:!1,configurable:!1,get:()=>o.validChildren});const d=wo(Jn(o,"parseDOM",a));d&&(u.parseDOM=d.map(p=>cn.insertExtensionAttrsToParseRule(p,s)));const f=Jn(o,"renderDOM",a);f&&(u.toDOM=p=>f({node:p,htmlAttributes:cn.getAttributesToRender(p,s)}));const h=Jn(o,"renderText",a);return h&&(u.toText=h),[o.name,u]});return Object.fromEntries(i)}static#t(t,n,r){const i=t.map(o=>{const s=n.filter(f=>f.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:r},l=Object.fromEntries(s.map(f=>[f.name,{default:f?.attribute?.default}])),c=X7({group:wo(Jn(o,"group",a)),inclusive:wo(Jn(o,"inclusive",a)),excludes:wo(Jn(o,"excludes",a)),spanning:wo(Jn(o,"spanning",a)),code:wo(Jn(o,"code",a)),attrs:l}),u=wo(Jn(o,"parseDOM",a));u&&(c.parseDOM=u.map(f=>cn.insertExtensionAttrsToParseRule(f,s)));const d=Jn(o,"renderDOM",a);return d&&(c.toDOM=f=>d({mark:f,htmlAttributes:cn.getAttributesToRender(f,s)})),[o.name,c]});return Object.fromEntries(i)}},WA,t_e,n_e,r_e,i_e,cZt=Le((()=>{WA=class extends Error{constructor(e){super(e),this.name="EditorError"}},t_e=class extends WA{constructor(e){super(e),this.name="InvalidStateError"}},n_e=class extends WA{constructor(e){super(e),this.name="NoSourcePathError"}},r_e=class extends WA{constructor(e){super(e),this.name="FileSystemNotAvailableError"}},i_e=class extends WA{constructor(e,t){super(e),this.name="DocumentLoadError",this.cause=t}}})),ma,$o,yE=Le((()=>{cZt(),ma={PASSWORD_REQUIRED:"DOCX_PASSWORD_REQUIRED",PASSWORD_INVALID:"DOCX_PASSWORD_INVALID",ENCRYPTION_UNSUPPORTED:"DOCX_ENCRYPTION_UNSUPPORTED",DECRYPTION_FAILED:"DOCX_DECRYPTION_FAILED"},$o=class extends WA{constructor(e,t,n){super(t),this.name="DocxEncryptionError",this.code=e,this.cause=n}}}));const uZt=si.create({name:"commands",addCommands(){return{...c9t}}});var Sj=e=>{const t=e?.state?.tr;t&&e.dispatch?.($R(t))};const dZt=e=>{const{view:t}=e;return Sj(t),e.commands.first(({commands:n})=>[()=>n.splitRunToParagraph?.()??!1,()=>n.newlineInCode(),()=>n.createParagraphNear(),()=>n.liftEmptyBlock(),()=>n.splitBlock()])},bE=e=>{const{view:t}=e;return Sj(t),e.commands.first(({commands:n,tr:r})=>[()=>n.undoInputRule(),()=>(r.setMeta("inputType","deleteContentBackward"),!1),()=>n.deleteBlockSdtAtTextBlockStart(),()=>n.backspaceEmptyRunParagraph(),()=>n.backspaceSkipEmptyRun(),()=>n.backspaceAtomBefore(),()=>n.backspaceNextToRun(),()=>n.backspaceAcrossRuns(),()=>n.mixedBidiBackspace?.()??!1,()=>n.deleteSelection(),()=>n.removeNumberingProperties(),()=>n.joinBackward(),()=>n.selectNodeBackward()])},GA=e=>{const{view:t}=e;return Sj(t),e.commands.first(({commands:n})=>[()=>n.deleteBlockSdtAtTextBlockStart(),()=>n.deleteSkipEmptyRun(),()=>n.deleteAtomAfter(),()=>n.deleteNextToRun(),()=>n.deleteSelection(),()=>n.joinForward(),()=>n.selectNodeForward()])},fZt=si.create({name:"keymap",addShortcuts(){const e={Enter:()=>dZt(this.editor),"Shift-Enter":()=>this.editor.commands.insertLineBreak(),"Mod-Enter":()=>this.editor.commands.insertPageBreak(),Backspace:()=>bE(this.editor),"Mod-Backspace":()=>bE(this.editor),"Shift-Backspace":()=>bE(this.editor),Delete:()=>GA(this.editor),"Mod-Delete":()=>GA(this.editor),"Mod-a":()=>this.editor.commands.selectAll(),Tab:()=>this.editor.commands.insertTabNode(),ArrowLeft:()=>this.editor.commands.skipTab(-1),ArrowRight:()=>this.editor.commands.skipTab(1)},t={...e},n={...e,"Ctrl-h":()=>bE(this.editor),"Alt-Backspace":()=>bE(this.editor),"Ctrl-d":()=>GA(this.editor),"Ctrl-Alt-Backspace":()=>GA(this.editor),"Alt-Delete":()=>GA(this.editor),"Alt-d":()=>GA(this.editor),"Ctrl-a":()=>this.editor.commands.selectAll(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd(),"Ctrl-t":()=>this.editor.commands.insertTabChar()};return r9()||hJe()?n:t}});var hZt=e=>{const t=globalThis;if(t.__SD_DEBUG_STORY_INPUT__!==!0)return;const n=Array.isArray(t.__SD_DEBUG_STORY_INPUT_LOG__)?t.__SD_DEBUG_STORY_INPUT_LOG__:[];n.push(e),n.length>200&&n.splice(0,n.length-200),t.__SD_DEBUG_STORY_INPUT_LOG__=n},o_e=e=>{const t=e?.options?.documentId??"";return t.startsWith("hf:")||t.startsWith("fn:")||t.startsWith("en:")||e?.options?.isHeaderOrFooter===!0||e?.options?.headerFooterType==="header"||e?.options?.headerFooterType==="footer"},jA=(e,t,n,r,i={})=>{if(!o_e(n))return;let o=null;const s=e?.dom?.ownerDocument?.getSelection?.()??null;try{e?.dom&&s?.anchorNode&&e.dom.contains(s.anchorNode)&&(o=e.posAtDOM(s.anchorNode,s.anchorOffset,-1))}catch{o=null}hZt({phase:r,documentId:n?.options?.documentId??null,inputType:t?.inputType??null,data:t?.data??null,cancelable:t?.cancelable??null,defaultPrevented:t?.defaultPrevented??null,selectionFrom:e?.state?.selection?.from??null,selectionTo:e?.state?.selection?.to??null,domAnchorPos:o,...i})},pZt=(e,t,n)=>{const r=t?.inputType==="insertText",i=typeof t?.data=="string"&&t.data.length>0,o=t?.isComposing===!0;if(jA(e,t,n,"beforeinput:start",{isInsertTextInput:r,hasTextData:i,isComposing:o}),!r||!i||o)return jA(e,t,n,"beforeinput:skip"),!1;const s=e.state.selection;if(s.empty&&!o_e(n))return jA(e,t,n,"beforeinput:skip-empty-selection"),!1;const a=e.state.tr.insertText(t.data,s.from,s.to),l=Math.max(0,Math.min(s.from+t.data.length,a.doc.content.size));try{a.setSelection(Et.create(a.doc,l))}catch{a.setSelection(An.near(a.doc.resolve(l),1))}return a.setMeta("inputType","insertText"),e.dispatch(a),t.preventDefault(),jA(e,t,n,"beforeinput:handled"),!0},mZt=(e,t)=>{if(!e.composing||t?.isComposing)return!1;const n=t?.inputType??null;return n?!["insertCompositionText","deleteCompositionText"].includes(n):!1},gZt=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);const yZt=si.create({name:"editable",addPmPlugins(){const e=this.editor,t=()=>!e.options.editable&&!e.options.allowSelectionInViewMode,n=(r,i)=>e.options.editable?!1:(i.preventDefault(),!0);return[new Tr({key:new Jr("editable"),props:{editable:()=>e.options.editable,handleDOMEvents:{beforeinput:(r,i)=>(jA(r,i,e,"dom:beforeinput"),e.options.editable?(mZt(r,i)&&byt(r),!!pZt(r,i,e)):(i.preventDefault(),!0)),input:(r,i)=>(jA(r,i,e,"dom:input"),!1),compositionstart:(r,i)=>n(r,i),compositionupdate:(r,i)=>n(r,i),compositionend:(r,i)=>n(r,i),mousedown:(r,i)=>t()?(i.preventDefault(),!0):!1,focus:(r,i)=>t()?(i.preventDefault(),r.dom.blur(),!0):!1},handleClick:()=>t(),handleDoubleClick:()=>t(),handleTripleClick:()=>t(),handleKeyDown:(r,i)=>e.options.editable?!1:!(e.options.allowSelectionInViewMode&&(gZt.has(i.key)||(i.ctrlKey||i.metaKey)&&["c","a"].includes(i.key.toLowerCase()))),handlePaste:()=>!e.options.editable,handleDrop:()=>!e.options.editable}})]}}),bZt=si.create({name:"editorFocus",addPmPlugins(){const e=this.editor;return[new Tr({key:new Jr("editorFocus"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),vZt=si.create({name:"positionTracker",addStorage(){return{tracker:null}},addPmPlugins(){return[fGt()]},onCreate(){const e=this.editor?.positionTracker??this.storage.tracker;if(e){this.storage.tracker=e,this.editor.positionTracker=e;return}const t=new GEe(this.editor);this.storage.tracker=t,this.editor.positionTracker=t},onDestroy(){this.editor?.positionTracker===this.storage.tracker&&(this.editor.positionTracker=null),this.storage.tracker=null}}),wZt=si.create({name:"selectionHandle",addPmPlugins(){return[x6t()]}});var vE=class{#e=new Map;on(e,t){const n=this.#e.get(e);n?n.push(t):this.#e.set(e,[t])}emit(e,...t){const n=this.#e.get(e);if(n)for(const r of n)r.apply(this,t)}safeEmit(e,...t){const n=this.#e.get(e);if(!n)return[];const r=[];for(const i of n)try{i.apply(this,t)}catch(o){r.push(o instanceof Error?o:new Error(String(o)))}return r}off(e,t){const n=this.#e.get(e);n&&(t?this.#e.set(e,n.filter(r=>r!==t)):this.#e.delete(e))}once(e,t){const n=(...r)=>{this.off(e,n),t.apply(this,r)};this.on(e,n)}removeAllListeners(){this.#e=new Map}};function AZt(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}var xZt=class f_{editor;schema;extensions;externalExtensions=[];splittableMarks=[];constructor(t,n,r){this.editor=r,this.externalExtensions=n||[],this.externalExtensions=this.externalExtensions.map(i=>({...i,isExternal:!0})),this.extensions=f_.getResolvedExtensions([...t,...this.externalExtensions]),this.schema=lZt.createSchemaByExtensions(this.extensions,r),this.#e()}static create(...t){return new f_(...t)}static getResolvedExtensions(t){return f_.sortByPriority(t)}static sortByPriority(t){return t.sort((r,i)=>{const o=Jn(r,"priority")||100,s=Jn(i,"priority")||100;return o>s?-1:o<s?1:0})}get attributes(){return cn.getAttributesFromExtensions(this.extensions)}get commands(){let t={};for(const n of this.extensions){const r=Jn(n,"addCommands",{name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Pw(n.name,this.schema)});r&&(t={...t,...r()})}return t}get helpers(){const t={};for(const n of this.extensions){const r=n.name;if(!r)continue;const i=Jn(n,"addHelpers",{name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Pw(n.name,this.schema)});i&&(t[r]=i())}return t}get plugins(){const t=this.editor,n=f_.sortByPriority([...this.extensions].reverse()),r=[],i=n.map(o=>{const s={name:o.name,options:o.options,storage:o.storage,editor:t,type:Pw(o.name,this.schema)},a=[],l=Jn(o,"addShortcuts",s);let c={};if(l){const f=Object.entries(l()).map(([h,p])=>[h,(...m)=>p({editor:t,keymapArgs:m})]);c={...Object.fromEntries(f)}}a.push(Cyt(c));const u=Jn(o,"addInputRules",s);AZt(o,t.options.enableInputRules)&&u&&r.push(...u());const d=Jn(o,"addPmPlugins",s);return d&&a.push(...d()),a}).flat();return[WAt({editor:t,rules:r}),...i]}get nodeViews(){const{editor:t}=this,n=this.extensions.filter(r=>r.type==="node").filter(r=>!!Jn(r,"addNodeView")).map(r=>{const i=this.attributes.filter(l=>l.type===r.name),o=Jn(r,"addNodeView",{name:r.name,options:r.options,storage:r.storage,editor:t,type:lu(r.name,this.schema)});if(!o)return null;const s=o();if(!s)return null;const a=(l,c,u,d)=>s({editor:t,node:l,getPos:u,decorations:d,htmlAttributes:cn.getAttributesToRender(l,i),extension:r,extensionAttrs:i});return[r.name,a]}).filter(Boolean);return Object.fromEntries(n)}#e(){for(const t of this.extensions){this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Pw(t.name,this.schema)};t.type==="mark"&&(wo(Jn(t,"keepOnSplit",n))??!0)&&this.splittableMarks.push(t.name),this.#t(t)}}#t(t){const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Pw(t.name,this.schema)},r=Jn(t,"onBeforeCreate",n),i=Jn(t,"onCreate",n),o=Jn(t,"onUpdate",n),s=Jn(t,"onSelectionUpdate",n),a=Jn(t,"onTransaction",n),l=Jn(t,"onFocus",n),c=Jn(t,"onBlur",n),u=Jn(t,"onDestroy",n);r&&this.editor.on("beforeCreate",r),i&&this.editor.on("create",i),o&&this.editor.on("update",o),s&&this.editor.on("selectionUpdate",s),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),c&&this.editor.on("blur",c),u&&this.editor.on("destroy",u)}},SZt={initial:e=>{const{state:t}=e,n=typeof e.view?.dispatch=="function"?e.view.dispatch.bind(e.view):e.dispatch.bind(e),{tr:r}=t;if(n)return t.doc.descendants((i,o)=>{if(i.type.name==="paragraph"){const{attrs:s}=i,{spacing:a}=s;if(!a)return;const l={line:sy(oa(a.line)),lineSpaceBefore:sy(oa(a.lineSpaceBefore)),lineSpaceAfter:sy(oa(a.lineSpaceAfter))};r.setNodeMarkup(o,void 0,{...s,spacing:{...a,...l}})}}),n(r),!0}};const s_e=e=>{if(e==="initial"||e==="0.4.14")return Object.values(SZt)};var a_e=Gi(((e,t)=>{(function(n){typeof e=="object"&&typeof t<"u"?t.exports=n():typeof define=="function"&&define.amd?define([],n):(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).JSZip=n()})(function(){return(function n(r,i,o){function s(c,u){if(!i[c]){if(!r[c]){var d=typeof require=="function"&&require;if(!u&&d)return d(c,!0);if(a)return a(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var h=i[c]={exports:{}};r[c][0].call(h.exports,function(p){var m=r[c][1][p];return s(m||p)},h,h.exports,n,r,i,o)}return i[c].exports}for(var a=typeof require=="function"&&require,l=0;l<o.length;l++)s(o[l]);return s})({1:[function(n,r,i){"use strict";var o=n("./utils"),s=n("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,u,d,f,h,p,m,g=[],y=0,v=l.length,b=v,w=o.getTypeOf(l)!=="string";y<l.length;)b=v-y,d=w?(c=l[y++],u=y<v?l[y++]:0,y<v?l[y++]:0):(c=l.charCodeAt(y++),u=y<v?l.charCodeAt(y++):0,y<v?l.charCodeAt(y++):0),f=c>>2,h=(3&c)<<4|u>>4,p=1<b?(15&u)<<2|d>>6:64,m=2<b?63&d:64,g.push(a.charAt(f)+a.charAt(h)+a.charAt(p)+a.charAt(m));return g.join("")},i.decode=function(l){var c,u,d,f,h,p,m=0,g=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var v,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&b--,l.charAt(l.length-2)===a.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=s.uint8array?new Uint8Array(0|b):new Array(0|b);m<l.length;)c=a.indexOf(l.charAt(m++))<<2|(f=a.indexOf(l.charAt(m++)))>>4,u=(15&f)<<4|(h=a.indexOf(l.charAt(m++)))>>2,d=(3&h)<<6|(p=a.indexOf(l.charAt(m++))),v[g++]=c,h!==64&&(v[g++]=u),p!==64&&(v[g++]=d);return v}},{"./support":30,"./utils":32}],2:[function(n,r,i){"use strict";var o=n("./external"),s=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(u,d,f,h,p){this.compressedSize=u,this.uncompressedSize=d,this.crc32=f,this.compression=h,this.compressedContent=p}c.prototype={getContentWorker:function(){var u=new s(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new s(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,d,f){return u.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){"use strict";var o=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){"use strict";var o=n("./utils"),s=(function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l})();r.exports=function(a,l){return a!==void 0&&a.length?o.getTypeOf(a)!=="string"?(function(c,u,d,f){var h=s,p=f+d;c^=-1;for(var m=f;m<p;m++)c=c>>>8^h[255&(c^u[m])];return-1^c})(0|l,a,a.length,0):(function(c,u,d,f){var h=s,p=f+d;c^=-1;for(var m=f;m<p;m++)c=c>>>8^h[255&(c^u.charCodeAt(m))];return-1^c})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,i){"use strict";i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){"use strict";var o=null;o=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:o}},{lie:37}],7:[function(n,r,i){"use strict";var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),c=o?"uint8array":"array";function u(d,f){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=f,this.meta={}}i.magic="\b\0",a.inherits(u,l),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,d.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(f){d.push({data:f,meta:d.meta})}},i.compressWorker=function(d){return new u("Deflate",d)},i.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){"use strict";function o(h,p){var m,g="";for(m=0;m<p;m++)g+=String.fromCharCode(255&h),h>>>=8;return g}function s(h,p,m,g,y,v){var b,w,x=h.file,A=h.compression,T=v!==c.utf8encode,I=a.transformTo("string",v(x.name)),P=a.transformTo("string",c.utf8encode(x.name)),C=x.comment,R=a.transformTo("string",v(C)),k=a.transformTo("string",c.utf8encode(C)),L=P.length!==x.name.length,_=k.length!==C.length,O="",F="",B="",U=x.dir,M=x.date,z={crc32:0,compressedSize:0,uncompressedSize:0};p&&!m||(z.crc32=h.crc32,z.compressedSize=h.compressedSize,z.uncompressedSize=h.uncompressedSize);var Z=0;p&&(Z|=8),T||!L&&!_||(Z|=2048);var Q=0,W=0;U&&(Q|=16),y==="UNIX"?(W=798,Q|=(function(K,X){var ee=K;return K||(ee=X?16893:33204),(65535&ee)<<16})(x.unixPermissions,U)):(W=20,Q|=(function(K){return 63&(K||0)})(x.dosPermissions)),b=M.getUTCHours(),b<<=6,b|=M.getUTCMinutes(),b<<=5,b|=M.getUTCSeconds()/2,w=M.getUTCFullYear()-1980,w<<=4,w|=M.getUTCMonth()+1,w<<=5,w|=M.getUTCDate(),L&&(F=o(1,1)+o(u(I),4)+P,O+="up"+o(F.length,2)+F),_&&(B=o(1,1)+o(u(R),4)+k,O+="uc"+o(B.length,2)+B);var he="";return he+=`
|
|
389
|
-
\0`,he+=o(Z,2),he+=A.magic,he+=o(b,2),he+=o(w,2),he+=o(z.crc32,4),he+=o(z.compressedSize,4),he+=o(z.uncompressedSize,4),he+=o(I.length,2),he+=o(O.length,2),{fileRecord:d.LOCAL_FILE_HEADER+he+I+O,dirRecord:d.CENTRAL_FILE_HEADER+o(W,2)+he+o(R.length,2)+"\0\0\0\0"+o(Q,4)+o(g,4)+I+O+R}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function f(h,p,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(h){var p=h.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:m?(p+100*(m-g-1))/m:100}}))},f.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var p=this.streamFiles&&!h.file.dir;if(p){var m=s(h,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(h){this.accumulate=!1;var p=this.streamFiles&&!h.file.dir,m=s(h,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),p)this.push({data:(function(g){return d.DATA_DESCRIPTOR+o(g.crc32,4)+o(g.compressedSize,4)+o(g.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var h=this.bytesWritten,p=0;p<this.dirRecords.length;p++)this.push({data:this.dirRecords[p],meta:{percent:100}});var m=this.bytesWritten-h,g=(function(y,v,b,w,x){var A=a.transformTo("string",x(w));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(y,2)+o(y,2)+o(v,4)+o(b,4)+o(A.length,2)+A})(this.dirRecords.length,m,h,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(h){this._sources.push(h);var p=this;return h.on("data",function(m){p.processChunk(m)}),h.on("end",function(){p.closedSource(p.previous.streamInfo),p._sources.length?p.prepareNextSource():p.end()}),h.on("error",function(m){p.error(m)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(h){var p=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var m=0;m<p.length;m++)try{p[m].error(h)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,p=0;p<h.length;p++)h[p].lock()},r.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){"use strict";var o=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(a,l,c){var u=new s(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{a.forEach(function(f,h){d++;var p=(function(v,b){var w=v||b,x=o[w];if(!x)throw new Error(w+" is not a valid compression method !");return x})(h.options.compression,l.compression),m=h.options.compressionOptions||l.compressionOptions||{},g=h.dir,y=h.date;h._compressWorker(p,m).withStreamInfo("file",{name:f,dir:g,date:y,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(u)}),u.entriesCount=d}catch(f){u.error(f)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){"use strict";function o(){if(!(this instanceof o))return new o;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new o;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(o.prototype=n("./object")).loadAsync=n("./load"),o.support=n("./support"),o.defaults=n("./defaults"),o.version="3.10.1",o.loadAsync=function(s,a){return new o().loadAsync(s,a)},o.external=n("./external"),r.exports=o},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){"use strict";var o=n("./utils"),s=n("./external"),a=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),u=n("./nodejsUtils");function d(f){return new s.Promise(function(h,p){var m=f.decompressed.getContentWorker().pipe(new c);m.on("error",function(g){p(g)}).on("end",function(){m.streamInfo.crc32!==f.decompressed.crc32?p(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}r.exports=function(f,h){var p=this;return h=o.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),u.isNode&&u.isStream(f)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):o.prepareContent("the loaded zip file",f,!0,h.optimizedBinaryString,h.base64).then(function(m){var g=new l(h);return g.load(m),g}).then(function(m){var g=[s.Promise.resolve(m)],y=m.files;if(h.checkCRC32)for(var v=0;v<y.length;v++)g.push(d(y[v]));return s.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,v=0;v<y.length;v++){var b=y[v],w=b.fileNameStr,x=o.resolve(b.fileNameStr);p.file(x,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:h.createFolders}),b.dir||(p.file(x).unsafeOriginalName=w)}return g.zipComment.length&&(p.comment=g.zipComment),p})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){"use strict";var o=n("../utils"),s=n("../stream/GenericWorker");function a(l,c){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}o.inherits(a,s),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){"use strict";var o=n("readable-stream").Readable;function s(a,l,c){o.call(this,l),this._helper=a;var u=this;a.on("data",function(d,f){u.push(d)||u._helper.pause(),c&&c(f)}).on("error",function(d){u.emit("error",d)}).on("end",function(){u.push(null)})}n("../utils").inherits(s,o),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){"use strict";r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(o,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(o,s);if(typeof o=="number")throw new Error('The "data" argument must not be a number');return new Buffer(o,s)},allocBuffer:function(o){if(Buffer.alloc)return Buffer.alloc(o);var s=new Buffer(o);return s.fill(0),s},isBuffer:function(o){return Buffer.isBuffer(o)},isStream:function(o){return o&&typeof o.on=="function"&&typeof o.pause=="function"&&typeof o.resume=="function"}}},{}],15:[function(n,r,i){"use strict";function o(w,x,A){var T,I=a.getTypeOf(x),P=a.extend(A||{},u);P.date=P.date||new Date,P.compression!==null&&(P.compression=P.compression.toUpperCase()),typeof P.unixPermissions=="string"&&(P.unixPermissions=parseInt(P.unixPermissions,8)),P.unixPermissions&&16384&P.unixPermissions&&(P.dir=!0),P.dosPermissions&&16&P.dosPermissions&&(P.dir=!0),P.dir&&(w=y(w)),P.createFolders&&(T=g(w))&&v.call(this,T,!0);var C=I==="string"&&P.binary===!1&&P.base64===!1;A&&A.binary!==void 0||(P.binary=!C),(x instanceof d&&x.uncompressedSize===0||P.dir||!x||x.length===0)&&(P.base64=!1,P.binary=!0,x="",P.compression="STORE",I="string");var R=null;R=x instanceof d||x instanceof l?x:p.isNode&&p.isStream(x)?new m(w,x):a.prepareContent(w,x,P.binary,P.optimizedBinaryString,P.base64);var k=new f(w,R,P);this.files[w]=k}var s=n("./utf8"),a=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),u=n("./defaults"),d=n("./compressedObject"),f=n("./zipObject"),h=n("./generate"),p=n("./nodejsUtils"),m=n("./nodejs/NodejsStreamInputAdapter"),g=function(w){w.slice(-1)==="/"&&(w=w.substring(0,w.length-1));var x=w.lastIndexOf("/");return 0<x?w.substring(0,x):""},y=function(w){return w.slice(-1)!=="/"&&(w+="/"),w},v=function(w,x){return x=x!==void 0?x:u.createFolders,w=y(w),this.files[w]||o.call(this,w,null,{dir:!0,createFolders:x}),this.files[w]};function b(w){return Object.prototype.toString.call(w)==="[object RegExp]"}r.exports={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(w){var x,A,T;for(x in this.files)T=this.files[x],(A=x.slice(this.root.length,x.length))&&x.slice(0,this.root.length)===this.root&&w(A,T)},filter:function(w){var x=[];return this.forEach(function(A,T){w(A,T)&&x.push(T)}),x},file:function(w,x,A){if(arguments.length!==1)return w=this.root+w,o.call(this,w,x,A),this;if(b(w)){var T=w;return this.filter(function(P,C){return!C.dir&&T.test(P)})}var I=this.files[this.root+w];return I&&!I.dir?I:null},folder:function(w){if(!w)return this;if(b(w))return this.filter(function(I,P){return P.dir&&w.test(I)});var x=this.root+w,A=v.call(this,x),T=this.clone();return T.root=A.name,T},remove:function(w){w=this.root+w;var x=this.files[w];if(x||(w.slice(-1)!=="/"&&(w+="/"),x=this.files[w]),x&&!x.dir)delete this.files[w];else for(var A=this.filter(function(I,P){return P.name.slice(0,w.length)===w}),T=0;T<A.length;T++)delete this.files[A[T].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(w){var x,A={};try{if((A=a.extend(w||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),A.type==="binarystring"&&(A.type="string"),!A.type)throw new Error("No output type specified.");a.checkSupport(A.type),A.platform!=="darwin"&&A.platform!=="freebsd"&&A.platform!=="linux"&&A.platform!=="sunos"||(A.platform="UNIX"),A.platform==="win32"&&(A.platform="DOS");var T=A.comment||this.comment||"";x=h.generateWorker(this,A,T)}catch(I){(x=new l("error")).error(I)}return new c(x,A.type||"string",A.mimeType)},generateAsync:function(w,x){return this.generateInternalStream(w).accumulate(x)},generateNodeStream:function(w,x){return(w=w||{}).type||(w.type="nodebuffer"),this.generateInternalStream(w).toNodejsStream(x)}}},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){"use strict";r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){"use strict";var o=n("./DataReader");function s(a){o.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}n("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),d=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===c&&this.data[f+2]===u&&this.data[f+3]===d)return f-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),d=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&c===f[1]&&u===f[2]&&d===f[3]},s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){"use strict";var o=n("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return o.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){"use strict";var o=n("./Uint8ArrayReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){"use strict";var o=n("./DataReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){"use strict";var o=n("./ArrayReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){"use strict";var o=n("../utils"),s=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var f=o.getTypeOf(d);return o.checkSupport(f),f!=="string"||s.uint8array?f==="nodebuffer"?new c(d):s.uint8array?new u(o.transformTo("uint8array",d)):new a(o.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){"use strict";i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){"use strict";var o=n("./GenericWorker"),s=n("../utils");function a(l){o.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(a,o),a.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){"use strict";var o=n("./GenericWorker"),s=n("../crc32");function a(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,o),a.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}o.inherits(a,s),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}s.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=o.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}o.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){"use strict";function o(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(l){a.processChunk(l)}),s.on("end",function(){a.end()}),s.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=o},{}],29:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),d=null;if(c.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(p,m){return new u.Promise(function(g,y){var v=[],b=p._internalType,w=p._outputType,x=p._mimeType;p.on("data",function(A,T){v.push(A),m&&m(T)}).on("error",function(A){v=[],y(A)}).on("end",function(){try{g((function(A,T,I){switch(A){case"blob":return o.newBlob(o.transformTo("arraybuffer",T),I);case"base64":return l.encode(T);default:return o.transformTo(A,T)}})(w,(function(A,T){var I,P=0,C=null,R=0;for(I=0;I<T.length;I++)R+=T[I].length;switch(A){case"string":return T.join("");case"array":return Array.prototype.concat.apply([],T);case"uint8array":for(C=new Uint8Array(R),I=0;I<T.length;I++)C.set(T[I],P),P+=T[I].length;return C;case"nodebuffer":return Buffer.concat(T);default:throw new Error("concat : unsupported type '"+A+"'")}})(b,v),x))}catch(A){y(A)}v=[]}).resume()})}function h(p,m,g){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=g,o.checkSupport(y),this._worker=p.pipe(new s(y)),p.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}h.prototype={accumulate:function(p){return f(this,p)},on:function(p,m){var g=this;return p==="data"?this._worker.on(p,function(y){m.call(g,y.data,y.meta)}):this._worker.on(p,function(){o.delay(m,arguments,g)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(p){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},p)}},r.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){"use strict";if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var o=new ArrayBuffer(0);try{i.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(o),i.blob=s.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){"use strict";for(var o=n("./utils"),s=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}i.utf8encode=function(h){return s.nodebuffer?a.newBufferFrom(h,"utf-8"):(function(p){var m,g,y,v,b,w=p.length,x=0;for(v=0;v<w;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),x+=g<128?1:g<2048?2:g<65536?3:4;for(m=s.uint8array?new Uint8Array(x):new Array(x),v=b=0;b<x;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m})(h)},i.utf8decode=function(h){return s.nodebuffer?o.transformTo("nodebuffer",h).toString("utf-8"):(function(p){var m,g,y,v,b=p.length,w=new Array(2*b);for(m=g=0;m<b;)if((y=p[m++])<128)w[g++]=y;else if(4<(v=c[y]))w[g++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<b;)y=y<<6|63&p[m++],v--;1<v?w[g++]=65533:y<65536?w[g++]=y:(y-=65536,w[g++]=55296|y>>10&1023,w[g++]=56320|1023&y)}return w.length!==g&&(w.subarray?w=w.subarray(0,g):w.length=g),o.applyFromCharCode(w)})(h=o.transformTo(s.uint8array?"uint8array":"array",h))},o.inherits(d,l),d.prototype.processChunk=function(h){var p=o.transformTo(s.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var m=p;(p=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),p.set(m,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var g=(function(v,b){var w;for((b=b||v.length)>v.length&&(b=v.length),w=b-1;0<=w&&(192&v[w])==128;)w--;return w<0||w===0?b:w+c[v[w]]>b?w:b})(p),y=p;g!==p.length&&(s.uint8array?(y=p.subarray(0,g),this.leftOver=p.subarray(g,p.length)):(y=p.slice(0,g),this.leftOver=p.slice(g,p.length))),this.push({data:i.utf8decode(y),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,o.inherits(f,l),f.prototype.processChunk=function(h){this.push({data:i.utf8encode(h.data),meta:h.meta})},i.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){"use strict";var o=n("./support"),s=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function c(m){return m}function u(m,g){for(var y=0;y<m.length;++y)g[y]=255&m.charCodeAt(y);return g}n("setimmediate"),i.newBlob=function(m,g){i.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(m,g,y){var v=[],b=0,w=m.length;if(w<=y)return String.fromCharCode.apply(null,m);for(;b<w;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,m.slice(b,Math.min(b+y,w)))):v.push(String.fromCharCode.apply(null,m.subarray(b,Math.min(b+y,w)))),b+=y;return v.join("")},stringifyByChar:function(m){for(var g="",y=0;y<m.length;y++)g+=String.fromCharCode(m[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return o.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return o.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function f(m){var g=65536,y=i.getTypeOf(m),v=!0;if(y==="uint8array"?v=d.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return d.stringifyByChunk(m,y,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(m)}function h(m,g){for(var y=0;y<m.length;y++)g[y]=m[y];return g}i.applyFromCharCode=f;var p={};p.string={string:c,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return p.string.uint8array(m).buffer},uint8array:function(m){return u(m,new Uint8Array(m.length))},nodebuffer:function(m){return u(m,a.allocBuffer(m.length))}},p.array={string:f,array:c,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},p.arraybuffer={string:function(m){return f(new Uint8Array(m))},array:function(m){return h(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:c,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},p.uint8array={string:f,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:c,nodebuffer:function(m){return a.newBufferFrom(m)}},p.nodebuffer={string:f,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return p.nodebuffer.uint8array(m).buffer},uint8array:function(m){return h(m,new Uint8Array(m.length))},nodebuffer:c},i.transformTo=function(m,g){return g=g||"",m?(i.checkSupport(m),p[i.getTypeOf(g)][m](g)):g},i.resolve=function(m){for(var g=m.split("/"),y=[],v=0;v<g.length;v++){var b=g[v];b==="."||b===""&&v!==0&&v!==g.length-1||(b===".."?y.pop():y.push(b))}return y.join("/")},i.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":o.nodebuffer&&a.isBuffer(m)?"nodebuffer":o.uint8array&&m instanceof Uint8Array?"uint8array":o.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(m){if(!o[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(m){var g,y,v="";for(y=0;y<(m||"").length;y++)v+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return v},i.delay=function(m,g,y){setImmediate(function(){m.apply(y||null,g||[])})},i.inherits=function(m,g){function y(){}y.prototype=g.prototype,m.prototype=new y},i.extend=function(){var m,g,y={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&y[g]===void 0&&(y[g]=arguments[m][g]);return y},i.prepareContent=function(m,g,y,v,b){return l.Promise.resolve(g).then(function(w){return o.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)&&typeof FileReader<"u"?new l.Promise(function(x,A){var T=new FileReader;T.onload=function(I){x(I.target.result)},T.onerror=function(I){A(I.target.error)},T.readAsArrayBuffer(w)}):w}).then(function(w){var x=i.getTypeOf(w);return x?(x==="arraybuffer"?w=i.transformTo("uint8array",w):x==="string"&&(b?w=s.decode(w):y&&v!==!0&&(w=(function(A){return u(A,o.uint8array?new Uint8Array(A.length):new Array(A.length))})(w))),w):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){"use strict";var o=n("./reader/readerFor"),s=n("./utils"),a=n("./signature"),l=n("./zipEntry"),c=n("./support");function u(d){this.files=[],this.loadOptions=d}u.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(f)+", expected "+s.pretty(d)+")")}},isSignature:function(d,f){var h=this.reader.index;this.reader.setIndex(d);var p=this.reader.readString(4)===f;return this.reader.setIndex(h),p},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),f=c.uint8array?"uint8array":"array",h=s.transformTo(f,d);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,f,h,p=this.zip64EndOfCentralSize-44;0<p;)d=this.reader.readInt(2),f=this.reader.readInt(4),h=this.reader.readData(f),this.zip64ExtensibleData[d]={id:d,length:f,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,f;for(d=0;d<this.files.length;d++)f=this.files[d],this.reader.setIndex(f.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var f=d;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var p=f-h;if(0<p)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=p);else if(p<0)throw new Error("Corrupted zip: missing "+Math.abs(p)+" bytes.")},prepareReader:function(d){this.reader=o(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){"use strict";var o=n("./reader/readerFor"),s=n("./utils"),a=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),u=n("./compressions"),d=n("./support");function f(h,p){this.options=h,this.loadOptions=p}f.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var p,m;if(h.skip(22),this.fileNameLength=h.readInt(2),m=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((p=(function(g){for(var y in u)if(Object.prototype.hasOwnProperty.call(u,y)&&u[y].magic===g)return u[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,p,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var p=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(p),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=o(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var p,m,g,y=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<y;)p=h.readInt(2),m=h.readInt(2),g=h.readData(m),this.extraFields[p]={id:p,length:m,value:g};h.setIndex(y)},handleUTF8:function(){var h=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var p=this.findExtraFieldUnicodePath();if(p!==null)this.fileNameStr=p;else{var m=s.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=s.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var p=o(h.value);return p.readInt(1)!==1||l(this.fileName)!==p.readInt(4)?null:c.utf8decode(p.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var p=o(h.value);return p.readInt(1)!==1||l(this.fileComment)!==p.readInt(4)?null:c.utf8decode(p.readData(h.length-5))}return null}},r.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){"use strict";function o(p,m,g){this.name=p,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var s=n("./stream/StreamHelper"),a=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),u=n("./stream/GenericWorker");o.prototype={internalStream:function(p){var m=null,g="string";try{if(!p)throw new Error("No output type specified.");var y=(g=p.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!v&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(b){(m=new u("error")).error(b)}return new s(m,g,"")},async:function(p,m){return this.internalStream(p).accumulate(m)},nodeStream:function(p,m){return this.internalStream(p||"nodebuffer").toNodejsStream(m)},_compressWorker:function(p,m){if(this._data instanceof c&&this._data.compression.magic===p.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,p,m)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new a(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<d.length;h++)o.prototype[d[h]]=f;r.exports=o},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(o){"use strict";var s,a,l=o.MutationObserver||o.WebKitMutationObserver;if(l){var c=0,u=new l(p),d=o.document.createTextNode("");u.observe(d,{characterData:!0}),s=function(){d.data=c=++c%2}}else if(o.setImmediate||o.MessageChannel===void 0)s="document"in o&&"onreadystatechange"in o.document.createElement("script")?function(){var m=o.document.createElement("script");m.onreadystatechange=function(){p(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},o.document.documentElement.appendChild(m)}:function(){setTimeout(p,0)};else{var f=new o.MessageChannel;f.port1.onmessage=p,s=function(){f.port2.postMessage(0)}}var h=[];function p(){var m,g;a=!0;for(var y=h.length;y;){for(g=h,h=[],m=-1;++m<y;)g[m]();y=h.length}a=!1}r.exports=function(m){h.push(m)!==1||a||s()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){"use strict";var o=n("immediate");function s(){}var a={},l=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function d(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,y!==s&&m(this,y)}function f(y,v,b){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function h(y,v,b){o(function(){var w;try{w=v(b)}catch(x){return a.reject(y,x)}w===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,w)})}function p(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function m(y,v){var b=!1;function w(T){b||(b=!0,a.reject(y,T))}function x(T){b||(b=!0,a.resolve(y,T))}var A=g(function(){v(x,w)});A.status==="error"&&w(A.value)}function g(y,v){var b={};try{b.value=y(v),b.status="success"}catch(w){b.status="error",b.value=w}return b}(r.exports=d).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(y()).then(function(){return b})},function(b){return v.resolve(y()).then(function(){throw b})})},d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,v){if(typeof y!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var b=new this.constructor(s);return this.state!==u?h(b,this.state===c?y:v,this.outcome):this.queue.push(new f(b,y,v)),b},f.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},f.prototype.otherCallFulfilled=function(y){h(this.promise,this.onFulfilled,y)},f.prototype.callRejected=function(y){a.reject(this.promise,y)},f.prototype.otherCallRejected=function(y){h(this.promise,this.onRejected,y)},a.resolve=function(y,v){var b=g(p,v);if(b.status==="error")return a.reject(y,b.value);var w=b.value;if(w)m(y,w);else{y.state=c,y.outcome=v;for(var x=-1,A=y.queue.length;++x<A;)y.queue[x].callFulfilled(v)}return y},a.reject=function(y,v){y.state=l,y.outcome=v;for(var b=-1,w=y.queue.length;++b<w;)y.queue[b].callRejected(v);return y},d.resolve=function(y){return y instanceof this?y:a.resolve(new this(s),y)},d.reject=function(y){var v=new this(s);return a.reject(v,y)},d.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var x=new Array(b),A=0,T=-1,I=new this(s);++T<b;)P(y[T],T);return I;function P(C,R){v.resolve(C).then(function(k){x[R]=k,++A!==b||w||(w=!0,a.resolve(I,x))},function(k){w||(w=!0,a.reject(I,k))})}},d.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var x=-1,A=new this(s);++x<b;)T=y[x],v.resolve(T).then(function(I){w||(w=!0,a.resolve(A,I))},function(I){w||(w=!0,a.reject(A,I))});var T;return A}},{immediate:36}],38:[function(n,r,i){"use strict";var o={};(0,n("./lib/utils/common").assign)(o,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=o},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){"use strict";var o=n("./zlib/deflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),u=Object.prototype.toString,d=0,f=-1,h=0,p=8;function m(y){if(!(this instanceof m))return new m(y);this.options=s.assign({level:f,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var b=o.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(b!==d)throw new Error(l[b]);if(v.header&&o.deflateSetHeader(this.strm,v.header),v.dictionary){var w;if(w=typeof v.dictionary=="string"?a.string2buf(v.dictionary):u.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(b=o.deflateSetDictionary(this.strm,w))!==d)throw new Error(l[b]);this._dict_set=!0}}function g(y,v){var b=new m(v);if(b.push(y,!0),b.err)throw b.msg||l[b.err];return b.result}m.prototype.push=function(y,v){var b,w,x=this.strm,A=this.options.chunkSize;if(this.ended)return!1;w=v===~~v?v:v===!0?4:0,typeof y=="string"?x.input=a.string2buf(y):u.call(y)==="[object ArrayBuffer]"?x.input=new Uint8Array(y):x.input=y,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new s.Buf8(A),x.next_out=0,x.avail_out=A),(b=o.deflate(x,w))!==1&&b!==d)return this.onEnd(b),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(x.output,x.next_out))):this.onData(s.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&b!==1);return w===4?(b=o.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===d):w!==2||(this.onEnd(d),!(x.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=m,i.deflate=g,i.deflateRaw=function(y,v){return(v=v||{}).raw=!0,g(y,v)},i.gzip=function(y,v){return(v=v||{}).gzip=!0,g(y,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){"use strict";var o=n("./zlib/inflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=n("./zlib/gzheader"),f=Object.prototype.toString;function h(m){if(!(this instanceof h))return new h(m);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var y=o.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(c[y]);this.header=new d,o.inflateGetHeader(this.strm,this.header)}function p(m,g){var y=new h(g);if(y.push(m,!0),y.err)throw y.msg||c[y.err];return y.result}h.prototype.push=function(m,g){var y,v,b,w,x,A,T=this.strm,I=this.options.chunkSize,P=this.options.dictionary,C=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?T.input=a.binstring2buf(m):f.call(m)==="[object ArrayBuffer]"?T.input=new Uint8Array(m):T.input=m,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(I),T.next_out=0,T.avail_out=I),(y=o.inflate(T,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&P&&(A=typeof P=="string"?a.string2buf(P):f.call(P)==="[object ArrayBuffer]"?new Uint8Array(P):P,y=o.inflateSetDictionary(this.strm,A)),y===l.Z_BUF_ERROR&&C===!0&&(y=l.Z_OK,C=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&y!==l.Z_STREAM_END&&(T.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=a.utf8border(T.output,T.next_out),w=T.next_out-b,x=a.buf2string(T.output,b),T.next_out=w,T.avail_out=I-w,w&&s.arraySet(T.output,T.output,b,w,0),this.onData(x)):this.onData(s.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(C=!0)}while((0<T.avail_in||T.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(y=o.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(T.avail_out=0))},h.prototype.onData=function(m){this.chunks.push(m)},h.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Inflate=h,i.inflate=p,i.inflateRaw=function(m,g){return(g=g||{}).raw=!0,p(m,g)},i.ungzip=p},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){"use strict";var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var d in u)u.hasOwnProperty(d)&&(l[d]=u[d])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var s={arraySet:function(l,c,u,d,f){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+d),f);else for(var h=0;h<d;h++)l[f+h]=c[u+h]},flattenChunks:function(l){var c,u,d,f,h,p;for(c=d=0,u=l.length;c<u;c++)d+=l[c].length;for(p=new Uint8Array(d),c=f=0,u=l.length;c<u;c++)h=l[c],p.set(h,f),f+=h.length;return p}},a={arraySet:function(l,c,u,d,f){for(var h=0;h<d;h++)l[f+h]=c[u+h]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(o)},{}],42:[function(n,r,i){"use strict";var o=n("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new o.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function u(d,f){if(f<65537&&(d.subarray&&a||!d.subarray&&s))return String.fromCharCode.apply(null,o.shrinkBuf(d,f));for(var h="",p=0;p<f;p++)h+=String.fromCharCode(d[p]);return h}l[254]=l[254]=1,i.string2buf=function(d){var f,h,p,m,g,y=d.length,v=0;for(m=0;m<y;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),v+=h<128?1:h<2048?2:h<65536?3:4;for(f=new o.Buf8(v),m=g=0;g<v;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),h<128?f[g++]=h:(h<2048?f[g++]=192|h>>>6:(h<65536?f[g++]=224|h>>>12:(f[g++]=240|h>>>18,f[g++]=128|h>>>12&63),f[g++]=128|h>>>6&63),f[g++]=128|63&h);return f},i.buf2binstring=function(d){return u(d,d.length)},i.binstring2buf=function(d){for(var f=new o.Buf8(d.length),h=0,p=f.length;h<p;h++)f[h]=d.charCodeAt(h);return f},i.buf2string=function(d,f){var h,p,m,g,y=f||d.length,v=new Array(2*y);for(h=p=0;h<y;)if((m=d[h++])<128)v[p++]=m;else if(4<(g=l[m]))v[p++]=65533,h+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&h<y;)m=m<<6|63&d[h++],g--;1<g?v[p++]=65533:m<65536?v[p++]=m:(m-=65536,v[p++]=55296|m>>10&1023,v[p++]=56320|1023&m)}return u(v,p)},i.utf8border=function(d,f){var h;for((f=f||d.length)>d.length&&(f=d.length),h=f-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?f:h+l[d[h]]>f?h:f}},{"./common":41}],43:[function(n,r,i){"use strict";r.exports=function(o,s,a,l){for(var c=65535&o|0,u=o>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3<a?2e3:a;u=u+(c=c+s[l++]|0)|0,--d;);c%=65521,u%=65521}return c|u<<16|0}},{}],44:[function(n,r,i){"use strict";r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){"use strict";var o=(function(){for(var s,a=[],l=0;l<256;l++){s=l;for(var c=0;c<8;c++)s=1&s?3988292384^s>>>1:s>>>1;a[l]=s}return a})();r.exports=function(s,a,l,c){var u=o,d=c+l;s^=-1;for(var f=c;f<d;f++)s=s>>>8^u[255&(s^a[f])];return-1^s}},{}],46:[function(n,r,i){"use strict";var o,s=n("../utils/common"),a=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),d=0,f=4,h=0,p=-2,m=-1,g=4,y=2,v=8,b=9,w=286,x=30,A=19,T=2*w+1,I=15,P=3,C=258,R=C+P+1,k=42,L=113,_=1,O=2,F=3,B=4;function U(N,q){return N.msg=u[q],q}function M(N){return(N<<1)-(4<N?9:0)}function z(N){for(var q=N.length;0<=--q;)N[q]=0}function Z(N){var q=N.state,oe=q.pending;oe>N.avail_out&&(oe=N.avail_out),oe!==0&&(s.arraySet(N.output,q.pending_buf,q.pending_out,oe,N.next_out),N.next_out+=oe,q.pending_out+=oe,N.total_out+=oe,N.avail_out-=oe,q.pending-=oe,q.pending===0&&(q.pending_out=0))}function Q(N,q){a._tr_flush_block(N,0<=N.block_start?N.block_start:-1,N.strstart-N.block_start,q),N.block_start=N.strstart,Z(N.strm)}function W(N,q){N.pending_buf[N.pending++]=q}function he(N,q){N.pending_buf[N.pending++]=q>>>8&255,N.pending_buf[N.pending++]=255&q}function K(N,q){var oe,J,re=N.max_chain_length,te=N.strstart,fe=N.prev_length,de=N.nice_match,ue=N.strstart>N.w_size-R?N.strstart-(N.w_size-R):0,ie=N.window,ce=N.w_mask,Te=N.prev,ye=N.strstart+C,le=ie[te+fe-1],Ae=ie[te+fe];N.prev_length>=N.good_match&&(re>>=2),de>N.lookahead&&(de=N.lookahead);do if(ie[(oe=q)+fe]===Ae&&ie[oe+fe-1]===le&&ie[oe]===ie[te]&&ie[++oe]===ie[te+1]){te+=2,oe++;do;while(ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&te<ye);if(J=C-(ye-te),te=ye-C,fe<J){if(N.match_start=q,de<=(fe=J))break;le=ie[te+fe-1],Ae=ie[te+fe]}}while((q=Te[q&ce])>ue&&--re!=0);return fe<=N.lookahead?fe:N.lookahead}function X(N){var q,oe,J,re,te,fe,de,ue,ie,ce,Te=N.w_size;do{if(re=N.window_size-N.lookahead-N.strstart,N.strstart>=Te+(Te-R)){for(s.arraySet(N.window,N.window,Te,Te,0),N.match_start-=Te,N.strstart-=Te,N.block_start-=Te,q=oe=N.hash_size;J=N.head[--q],N.head[q]=Te<=J?J-Te:0,--oe;);for(q=oe=Te;J=N.prev[--q],N.prev[q]=Te<=J?J-Te:0,--oe;);re+=Te}if(N.strm.avail_in===0)break;if(fe=N.strm,de=N.window,ue=N.strstart+N.lookahead,ie=re,ce=void 0,ce=fe.avail_in,ie<ce&&(ce=ie),oe=ce===0?0:(fe.avail_in-=ce,s.arraySet(de,fe.input,fe.next_in,ce,ue),fe.state.wrap===1?fe.adler=l(fe.adler,de,ce,ue):fe.state.wrap===2&&(fe.adler=c(fe.adler,de,ce,ue)),fe.next_in+=ce,fe.total_in+=ce,ce),N.lookahead+=oe,N.lookahead+N.insert>=P)for(te=N.strstart-N.insert,N.ins_h=N.window[te],N.ins_h=(N.ins_h<<N.hash_shift^N.window[te+1])&N.hash_mask;N.insert&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[te+P-1])&N.hash_mask,N.prev[te&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=te,te++,N.insert--,!(N.lookahead+N.insert<P)););}while(N.lookahead<R&&N.strm.avail_in!==0)}function ee(N,q){for(var oe,J;;){if(N.lookahead<R){if(X(N),N.lookahead<R&&q===d)return _;if(N.lookahead===0)break}if(oe=0,N.lookahead>=P&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+P-1])&N.hash_mask,oe=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),oe!==0&&N.strstart-oe<=N.w_size-R&&(N.match_length=K(N,oe)),N.match_length>=P)if(J=a._tr_tally(N,N.strstart-N.match_start,N.match_length-P),N.lookahead-=N.match_length,N.match_length<=N.max_lazy_match&&N.lookahead>=P){for(N.match_length--;N.strstart++,N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+P-1])&N.hash_mask,oe=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart,--N.match_length!=0;);N.strstart++}else N.strstart+=N.match_length,N.match_length=0,N.ins_h=N.window[N.strstart],N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+1])&N.hash_mask;else J=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++;if(J&&(Q(N,!1),N.strm.avail_out===0))return _}return N.insert=N.strstart<P-1?N.strstart:P-1,q===f?(Q(N,!0),N.strm.avail_out===0?F:B):N.last_lit&&(Q(N,!1),N.strm.avail_out===0)?_:O}function be(N,q){for(var oe,J,re;;){if(N.lookahead<R){if(X(N),N.lookahead<R&&q===d)return _;if(N.lookahead===0)break}if(oe=0,N.lookahead>=P&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+P-1])&N.hash_mask,oe=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),N.prev_length=N.match_length,N.prev_match=N.match_start,N.match_length=P-1,oe!==0&&N.prev_length<N.max_lazy_match&&N.strstart-oe<=N.w_size-R&&(N.match_length=K(N,oe),N.match_length<=5&&(N.strategy===1||N.match_length===P&&4096<N.strstart-N.match_start)&&(N.match_length=P-1)),N.prev_length>=P&&N.match_length<=N.prev_length){for(re=N.strstart+N.lookahead-P,J=a._tr_tally(N,N.strstart-1-N.prev_match,N.prev_length-P),N.lookahead-=N.prev_length-1,N.prev_length-=2;++N.strstart<=re&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+P-1])&N.hash_mask,oe=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),--N.prev_length!=0;);if(N.match_available=0,N.match_length=P-1,N.strstart++,J&&(Q(N,!1),N.strm.avail_out===0))return _}else if(N.match_available){if((J=a._tr_tally(N,0,N.window[N.strstart-1]))&&Q(N,!1),N.strstart++,N.lookahead--,N.strm.avail_out===0)return _}else N.match_available=1,N.strstart++,N.lookahead--}return N.match_available&&(J=a._tr_tally(N,0,N.window[N.strstart-1]),N.match_available=0),N.insert=N.strstart<P-1?N.strstart:P-1,q===f?(Q(N,!0),N.strm.avail_out===0?F:B):N.last_lit&&(Q(N,!1),N.strm.avail_out===0)?_:O}function xe(N,q,oe,J,re){this.good_length=N,this.max_lazy=q,this.nice_length=oe,this.max_chain=J,this.func=re}function pe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*T),this.dyn_dtree=new s.Buf16(2*(2*x+1)),this.bl_tree=new s.Buf16(2*(2*A+1)),z(this.dyn_ltree),z(this.dyn_dtree),z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(I+1),this.heap=new s.Buf16(2*w+1),z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*w+1),z(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ke(N){var q;return N&&N.state?(N.total_in=N.total_out=0,N.data_type=y,(q=N.state).pending=0,q.pending_out=0,q.wrap<0&&(q.wrap=-q.wrap),q.status=q.wrap?k:L,N.adler=q.wrap===2?0:1,q.last_flush=d,a._tr_init(q),h):U(N,p)}function V(N){var q=ke(N);return q===h&&(function(oe){oe.window_size=2*oe.w_size,z(oe.head),oe.max_lazy_match=o[oe.level].max_lazy,oe.good_match=o[oe.level].good_length,oe.nice_match=o[oe.level].nice_length,oe.max_chain_length=o[oe.level].max_chain,oe.strstart=0,oe.block_start=0,oe.lookahead=0,oe.insert=0,oe.match_length=oe.prev_length=P-1,oe.match_available=0,oe.ins_h=0})(N.state),q}function D(N,q,oe,J,re,te){if(!N)return p;var fe=1;if(q===m&&(q=6),J<0?(fe=0,J=-J):15<J&&(fe=2,J-=16),re<1||b<re||oe!==v||J<8||15<J||q<0||9<q||te<0||g<te)return U(N,p);J===8&&(J=9);var de=new pe;return(N.state=de).strm=N,de.wrap=fe,de.gzhead=null,de.w_bits=J,de.w_size=1<<de.w_bits,de.w_mask=de.w_size-1,de.hash_bits=re+7,de.hash_size=1<<de.hash_bits,de.hash_mask=de.hash_size-1,de.hash_shift=~~((de.hash_bits+P-1)/P),de.window=new s.Buf8(2*de.w_size),de.head=new s.Buf16(de.hash_size),de.prev=new s.Buf16(de.w_size),de.lit_bufsize=1<<re+6,de.pending_buf_size=4*de.lit_bufsize,de.pending_buf=new s.Buf8(de.pending_buf_size),de.d_buf=1*de.lit_bufsize,de.l_buf=3*de.lit_bufsize,de.level=q,de.strategy=te,de.method=oe,V(N)}o=[new xe(0,0,0,0,function(N,q){var oe=65535;for(oe>N.pending_buf_size-5&&(oe=N.pending_buf_size-5);;){if(N.lookahead<=1){if(X(N),N.lookahead===0&&q===d)return _;if(N.lookahead===0)break}N.strstart+=N.lookahead,N.lookahead=0;var J=N.block_start+oe;if((N.strstart===0||N.strstart>=J)&&(N.lookahead=N.strstart-J,N.strstart=J,Q(N,!1),N.strm.avail_out===0)||N.strstart-N.block_start>=N.w_size-R&&(Q(N,!1),N.strm.avail_out===0))return _}return N.insert=0,q===f?(Q(N,!0),N.strm.avail_out===0?F:B):(N.strstart>N.block_start&&(Q(N,!1),N.strm.avail_out),_)}),new xe(4,4,8,4,ee),new xe(4,5,16,8,ee),new xe(4,6,32,32,ee),new xe(4,4,16,16,be),new xe(8,16,32,32,be),new xe(8,16,128,128,be),new xe(8,32,128,256,be),new xe(32,128,258,1024,be),new xe(32,258,258,4096,be)],i.deflateInit=function(N,q){return D(N,q,v,15,8,0)},i.deflateInit2=D,i.deflateReset=V,i.deflateResetKeep=ke,i.deflateSetHeader=function(N,q){return N&&N.state?N.state.wrap!==2?p:(N.state.gzhead=q,h):p},i.deflate=function(N,q){var oe,J,re,te;if(!N||!N.state||5<q||q<0)return N?U(N,p):p;if(J=N.state,!N.output||!N.input&&N.avail_in!==0||J.status===666&&q!==f)return U(N,N.avail_out===0?-5:p);if(J.strm=N,oe=J.last_flush,J.last_flush=q,J.status===k)if(J.wrap===2)N.adler=0,W(J,31),W(J,139),W(J,8),J.gzhead?(W(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(J.gzhead.extra?4:0)+(J.gzhead.name?8:0)+(J.gzhead.comment?16:0)),W(J,255&J.gzhead.time),W(J,J.gzhead.time>>8&255),W(J,J.gzhead.time>>16&255),W(J,J.gzhead.time>>24&255),W(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),W(J,255&J.gzhead.os),J.gzhead.extra&&J.gzhead.extra.length&&(W(J,255&J.gzhead.extra.length),W(J,J.gzhead.extra.length>>8&255)),J.gzhead.hcrc&&(N.adler=c(N.adler,J.pending_buf,J.pending,0)),J.gzindex=0,J.status=69):(W(J,0),W(J,0),W(J,0),W(J,0),W(J,0),W(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),W(J,3),J.status=L);else{var fe=v+(J.w_bits-8<<4)<<8;fe|=(2<=J.strategy||J.level<2?0:J.level<6?1:J.level===6?2:3)<<6,J.strstart!==0&&(fe|=32),fe+=31-fe%31,J.status=L,he(J,fe),J.strstart!==0&&(he(J,N.adler>>>16),he(J,65535&N.adler)),N.adler=1}if(J.status===69)if(J.gzhead.extra){for(re=J.pending;J.gzindex<(65535&J.gzhead.extra.length)&&(J.pending!==J.pending_buf_size||(J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),Z(N),re=J.pending,J.pending!==J.pending_buf_size));)W(J,255&J.gzhead.extra[J.gzindex]),J.gzindex++;J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),J.gzindex===J.gzhead.extra.length&&(J.gzindex=0,J.status=73)}else J.status=73;if(J.status===73)if(J.gzhead.name){re=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),Z(N),re=J.pending,J.pending===J.pending_buf_size)){te=1;break}te=J.gzindex<J.gzhead.name.length?255&J.gzhead.name.charCodeAt(J.gzindex++):0,W(J,te)}while(te!==0);J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),te===0&&(J.gzindex=0,J.status=91)}else J.status=91;if(J.status===91)if(J.gzhead.comment){re=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),Z(N),re=J.pending,J.pending===J.pending_buf_size)){te=1;break}te=J.gzindex<J.gzhead.comment.length?255&J.gzhead.comment.charCodeAt(J.gzindex++):0,W(J,te)}while(te!==0);J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),te===0&&(J.status=103)}else J.status=103;if(J.status===103&&(J.gzhead.hcrc?(J.pending+2>J.pending_buf_size&&Z(N),J.pending+2<=J.pending_buf_size&&(W(J,255&N.adler),W(J,N.adler>>8&255),N.adler=0,J.status=L)):J.status=L),J.pending!==0){if(Z(N),N.avail_out===0)return J.last_flush=-1,h}else if(N.avail_in===0&&M(q)<=M(oe)&&q!==f)return U(N,-5);if(J.status===666&&N.avail_in!==0)return U(N,-5);if(N.avail_in!==0||J.lookahead!==0||q!==d&&J.status!==666){var de=J.strategy===2?(function(ue,ie){for(var ce;;){if(ue.lookahead===0&&(X(ue),ue.lookahead===0)){if(ie===d)return _;break}if(ue.match_length=0,ce=a._tr_tally(ue,0,ue.window[ue.strstart]),ue.lookahead--,ue.strstart++,ce&&(Q(ue,!1),ue.strm.avail_out===0))return _}return ue.insert=0,ie===f?(Q(ue,!0),ue.strm.avail_out===0?F:B):ue.last_lit&&(Q(ue,!1),ue.strm.avail_out===0)?_:O})(J,q):J.strategy===3?(function(ue,ie){for(var ce,Te,ye,le,Ae=ue.window;;){if(ue.lookahead<=C){if(X(ue),ue.lookahead<=C&&ie===d)return _;if(ue.lookahead===0)break}if(ue.match_length=0,ue.lookahead>=P&&0<ue.strstart&&(Te=Ae[ye=ue.strstart-1])===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]){le=ue.strstart+C;do;while(Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&ye<le);ue.match_length=C-(le-ye),ue.match_length>ue.lookahead&&(ue.match_length=ue.lookahead)}if(ue.match_length>=P?(ce=a._tr_tally(ue,1,ue.match_length-P),ue.lookahead-=ue.match_length,ue.strstart+=ue.match_length,ue.match_length=0):(ce=a._tr_tally(ue,0,ue.window[ue.strstart]),ue.lookahead--,ue.strstart++),ce&&(Q(ue,!1),ue.strm.avail_out===0))return _}return ue.insert=0,ie===f?(Q(ue,!0),ue.strm.avail_out===0?F:B):ue.last_lit&&(Q(ue,!1),ue.strm.avail_out===0)?_:O})(J,q):o[J.level].func(J,q);if(de!==F&&de!==B||(J.status=666),de===_||de===F)return N.avail_out===0&&(J.last_flush=-1),h;if(de===O&&(q===1?a._tr_align(J):q!==5&&(a._tr_stored_block(J,0,0,!1),q===3&&(z(J.head),J.lookahead===0&&(J.strstart=0,J.block_start=0,J.insert=0))),Z(N),N.avail_out===0))return J.last_flush=-1,h}return q!==f?h:J.wrap<=0?1:(J.wrap===2?(W(J,255&N.adler),W(J,N.adler>>8&255),W(J,N.adler>>16&255),W(J,N.adler>>24&255),W(J,255&N.total_in),W(J,N.total_in>>8&255),W(J,N.total_in>>16&255),W(J,N.total_in>>24&255)):(he(J,N.adler>>>16),he(J,65535&N.adler)),Z(N),0<J.wrap&&(J.wrap=-J.wrap),J.pending!==0?h:1)},i.deflateEnd=function(N){var q;return N&&N.state?(q=N.state.status)!==k&&q!==69&&q!==73&&q!==91&&q!==103&&q!==L&&q!==666?U(N,p):(N.state=null,q===L?U(N,-3):h):p},i.deflateSetDictionary=function(N,q){var oe,J,re,te,fe,de,ue,ie,ce=q.length;if(!N||!N.state||(te=(oe=N.state).wrap)===2||te===1&&oe.status!==k||oe.lookahead)return p;for(te===1&&(N.adler=l(N.adler,q,ce,0)),oe.wrap=0,ce>=oe.w_size&&(te===0&&(z(oe.head),oe.strstart=0,oe.block_start=0,oe.insert=0),ie=new s.Buf8(oe.w_size),s.arraySet(ie,q,ce-oe.w_size,oe.w_size,0),q=ie,ce=oe.w_size),fe=N.avail_in,de=N.next_in,ue=N.input,N.avail_in=ce,N.next_in=0,N.input=q,X(oe);oe.lookahead>=P;){for(J=oe.strstart,re=oe.lookahead-(P-1);oe.ins_h=(oe.ins_h<<oe.hash_shift^oe.window[J+P-1])&oe.hash_mask,oe.prev[J&oe.w_mask]=oe.head[oe.ins_h],oe.head[oe.ins_h]=J,J++,--re;);oe.strstart=J,oe.lookahead=P-1,X(oe)}return oe.strstart+=oe.lookahead,oe.block_start=oe.strstart,oe.insert=oe.lookahead,oe.lookahead=0,oe.match_length=oe.prev_length=P-1,oe.match_available=0,N.next_in=de,N.input=ue,N.avail_in=fe,oe.wrap=te,h},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){"use strict";r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){"use strict";r.exports=function(o,s){var a=o.state,l=o.next_in,c,u,d,f,h,p,m,g,y,v,b,w,x,A,T,I,P,C,R,k,L,_=o.input,O;c=l+(o.avail_in-5),u=o.next_out,O=o.output,d=u-(s-o.avail_out),f=u+(o.avail_out-257),h=a.dmax,p=a.wsize,m=a.whave,g=a.wnext,y=a.window,v=a.hold,b=a.bits,w=a.lencode,x=a.distcode,A=(1<<a.lenbits)-1,T=(1<<a.distbits)-1;e:do{b<15&&(v+=_[l++]<<b,b+=8,v+=_[l++]<<b,b+=8),I=w[v&A];t:for(;;){if(v>>>=P=I>>>24,b-=P,(P=I>>>16&255)===0)O[u++]=65535&I;else{if(!(16&P)){if((64&P)==0){I=w[(65535&I)+(v&(1<<P)-1)];continue t}if(32&P){a.mode=12;break e}o.msg="invalid literal/length code",a.mode=30;break e}C=65535&I,(P&=15)&&(b<P&&(v+=_[l++]<<b,b+=8),C+=v&(1<<P)-1,v>>>=P,b-=P),b<15&&(v+=_[l++]<<b,b+=8,v+=_[l++]<<b,b+=8),I=x[v&T];n:for(;;){if(v>>>=P=I>>>24,b-=P,!(16&(P=I>>>16&255))){if((64&P)==0){I=x[(65535&I)+(v&(1<<P)-1)];continue n}o.msg="invalid distance code",a.mode=30;break e}if(R=65535&I,b<(P&=15)&&(v+=_[l++]<<b,(b+=8)<P&&(v+=_[l++]<<b,b+=8)),h<(R+=v&(1<<P)-1)){o.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=P,b-=P,(P=u-d)<R){if(m<(P=R-P)&&a.sane){o.msg="invalid distance too far back",a.mode=30;break e}if(L=y,(k=0)===g){if(k+=p-P,P<C){for(C-=P;O[u++]=y[k++],--P;);k=u-R,L=O}}else if(g<P){if(k+=p+g-P,(P-=g)<C){for(C-=P;O[u++]=y[k++],--P;);if(k=0,g<C){for(C-=P=g;O[u++]=y[k++],--P;);k=u-R,L=O}}}else if(k+=g-P,P<C){for(C-=P;O[u++]=y[k++],--P;);k=u-R,L=O}for(;2<C;)O[u++]=L[k++],O[u++]=L[k++],O[u++]=L[k++],C-=3;C&&(O[u++]=L[k++],1<C&&(O[u++]=L[k++]))}else{for(k=u-R;O[u++]=O[k++],O[u++]=O[k++],O[u++]=O[k++],2<(C-=3););C&&(O[u++]=O[k++],1<C&&(O[u++]=O[k++]))}break}}break}}while(l<c&&u<f);l-=C=b>>3,v&=(1<<(b-=C<<3))-1,o.next_in=l,o.next_out=u,o.avail_in=l<c?c-l+5:5-(l-c),o.avail_out=u<f?f-u+257:257-(u-f),a.hold=v,a.bits=b}},{}],49:[function(n,r,i){"use strict";var o=n("../utils/common"),s=n("./adler32"),a=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),u=1,d=2,f=0,h=-2,p=1,m=852,g=592;function y(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(k){var L;return k&&k.state?(L=k.state,k.total_in=k.total_out=L.total=0,k.msg="",L.wrap&&(k.adler=1&L.wrap),L.mode=p,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new o.Buf32(m),L.distcode=L.distdyn=new o.Buf32(g),L.sane=1,L.back=-1,f):h}function w(k){var L;return k&&k.state?((L=k.state).wsize=0,L.whave=0,L.wnext=0,b(k)):h}function x(k,L){var _,O;return k&&k.state?(O=k.state,L<0?(_=0,L=-L):(_=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?h:(O.window!==null&&O.wbits!==L&&(O.window=null),O.wrap=_,O.wbits=L,w(k))):h}function A(k,L){var _,O;return k?(O=new v,(k.state=O).window=null,(_=x(k,L))!==f&&(k.state=null),_):h}var T,I,P=!0;function C(k){if(P){var L;for(T=new o.Buf32(512),I=new o.Buf32(32),L=0;L<144;)k.lens[L++]=8;for(;L<256;)k.lens[L++]=9;for(;L<280;)k.lens[L++]=7;for(;L<288;)k.lens[L++]=8;for(c(u,k.lens,0,288,T,0,k.work,{bits:9}),L=0;L<32;)k.lens[L++]=5;c(d,k.lens,0,32,I,0,k.work,{bits:5}),P=!1}k.lencode=T,k.lenbits=9,k.distcode=I,k.distbits=5}function R(k,L,_,O){var F,B=k.state;return B.window===null&&(B.wsize=1<<B.wbits,B.wnext=0,B.whave=0,B.window=new o.Buf8(B.wsize)),O>=B.wsize?(o.arraySet(B.window,L,_-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):(O<(F=B.wsize-B.wnext)&&(F=O),o.arraySet(B.window,L,_-O,F,B.wnext),(O-=F)?(o.arraySet(B.window,L,_-O,O,0),B.wnext=O,B.whave=B.wsize):(B.wnext+=F,B.wnext===B.wsize&&(B.wnext=0),B.whave<B.wsize&&(B.whave+=F))),0}i.inflateReset=w,i.inflateReset2=x,i.inflateResetKeep=b,i.inflateInit=function(k){return A(k,15)},i.inflateInit2=A,i.inflate=function(k,L){var _,O,F,B,U,M,z,Z,Q,W,he,K,X,ee,be,xe,pe,ke,V,D,N,q,oe,J,re=0,te=new o.Buf8(4),fe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return h;(_=k.state).mode===12&&(_.mode=13),U=k.next_out,F=k.output,z=k.avail_out,B=k.next_in,O=k.input,M=k.avail_in,Z=_.hold,Q=_.bits,W=M,he=z,q=f;e:for(;;)switch(_.mode){case p:if(_.wrap===0){_.mode=13;break}for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(2&_.wrap&&Z===35615){te[_.check=0]=255&Z,te[1]=Z>>>8&255,_.check=a(_.check,te,2,0),Q=Z=0,_.mode=2;break}if(_.flags=0,_.head&&(_.head.done=!1),!(1&_.wrap)||(((255&Z)<<8)+(Z>>8))%31){k.msg="incorrect header check",_.mode=30;break}if((15&Z)!=8){k.msg="unknown compression method",_.mode=30;break}if(Q-=4,N=8+(15&(Z>>>=4)),_.wbits===0)_.wbits=N;else if(N>_.wbits){k.msg="invalid window size",_.mode=30;break}_.dmax=1<<N,k.adler=_.check=1,_.mode=512&Z?10:12,Q=Z=0;break;case 2:for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(_.flags=Z,(255&_.flags)!=8){k.msg="unknown compression method",_.mode=30;break}if(57344&_.flags){k.msg="unknown header flags set",_.mode=30;break}_.head&&(_.head.text=Z>>8&1),512&_.flags&&(te[0]=255&Z,te[1]=Z>>>8&255,_.check=a(_.check,te,2,0)),Q=Z=0,_.mode=3;case 3:for(;Q<32;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.head&&(_.head.time=Z),512&_.flags&&(te[0]=255&Z,te[1]=Z>>>8&255,te[2]=Z>>>16&255,te[3]=Z>>>24&255,_.check=a(_.check,te,4,0)),Q=Z=0,_.mode=4;case 4:for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.head&&(_.head.xflags=255&Z,_.head.os=Z>>8),512&_.flags&&(te[0]=255&Z,te[1]=Z>>>8&255,_.check=a(_.check,te,2,0)),Q=Z=0,_.mode=5;case 5:if(1024&_.flags){for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.length=Z,_.head&&(_.head.extra_len=Z),512&_.flags&&(te[0]=255&Z,te[1]=Z>>>8&255,_.check=a(_.check,te,2,0)),Q=Z=0}else _.head&&(_.head.extra=null);_.mode=6;case 6:if(1024&_.flags&&(M<(K=_.length)&&(K=M),K&&(_.head&&(N=_.head.extra_len-_.length,_.head.extra||(_.head.extra=new Array(_.head.extra_len)),o.arraySet(_.head.extra,O,B,K,N)),512&_.flags&&(_.check=a(_.check,O,K,B)),M-=K,B+=K,_.length-=K),_.length))break e;_.length=0,_.mode=7;case 7:if(2048&_.flags){if(M===0)break e;for(K=0;N=O[B+K++],_.head&&N&&_.length<65536&&(_.head.name+=String.fromCharCode(N)),N&&K<M;);if(512&_.flags&&(_.check=a(_.check,O,K,B)),M-=K,B+=K,N)break e}else _.head&&(_.head.name=null);_.length=0,_.mode=8;case 8:if(4096&_.flags){if(M===0)break e;for(K=0;N=O[B+K++],_.head&&N&&_.length<65536&&(_.head.comment+=String.fromCharCode(N)),N&&K<M;);if(512&_.flags&&(_.check=a(_.check,O,K,B)),M-=K,B+=K,N)break e}else _.head&&(_.head.comment=null);_.mode=9;case 9:if(512&_.flags){for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(Z!==(65535&_.check)){k.msg="header crc mismatch",_.mode=30;break}Q=Z=0}_.head&&(_.head.hcrc=_.flags>>9&1,_.head.done=!0),k.adler=_.check=0,_.mode=12;break;case 10:for(;Q<32;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}k.adler=_.check=y(Z),Q=Z=0,_.mode=11;case 11:if(_.havedict===0)return k.next_out=U,k.avail_out=z,k.next_in=B,k.avail_in=M,_.hold=Z,_.bits=Q,2;k.adler=_.check=1,_.mode=12;case 12:if(L===5||L===6)break e;case 13:if(_.last){Z>>>=7&Q,Q-=7&Q,_.mode=27;break}for(;Q<3;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}switch(_.last=1&Z,Q-=1,3&(Z>>>=1)){case 0:_.mode=14;break;case 1:if(C(_),_.mode=20,L!==6)break;Z>>>=2,Q-=2;break e;case 2:_.mode=17;break;case 3:k.msg="invalid block type",_.mode=30}Z>>>=2,Q-=2;break;case 14:for(Z>>>=7&Q,Q-=7&Q;Q<32;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if((65535&Z)!=(Z>>>16^65535)){k.msg="invalid stored block lengths",_.mode=30;break}if(_.length=65535&Z,Q=Z=0,_.mode=15,L===6)break e;case 15:_.mode=16;case 16:if(K=_.length){if(M<K&&(K=M),z<K&&(K=z),K===0)break e;o.arraySet(F,O,B,K,U),M-=K,B+=K,z-=K,U+=K,_.length-=K;break}_.mode=12;break;case 17:for(;Q<14;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(_.nlen=257+(31&Z),Z>>>=5,Q-=5,_.ndist=1+(31&Z),Z>>>=5,Q-=5,_.ncode=4+(15&Z),Z>>>=4,Q-=4,286<_.nlen||30<_.ndist){k.msg="too many length or distance symbols",_.mode=30;break}_.have=0,_.mode=18;case 18:for(;_.have<_.ncode;){for(;Q<3;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.lens[fe[_.have++]]=7&Z,Z>>>=3,Q-=3}for(;_.have<19;)_.lens[fe[_.have++]]=0;if(_.lencode=_.lendyn,_.lenbits=7,oe={bits:_.lenbits},q=c(0,_.lens,0,19,_.lencode,0,_.work,oe),_.lenbits=oe.bits,q){k.msg="invalid code lengths set",_.mode=30;break}_.have=0,_.mode=19;case 19:for(;_.have<_.nlen+_.ndist;){for(;xe=(re=_.lencode[Z&(1<<_.lenbits)-1])>>>16&255,pe=65535&re,!((be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(pe<16)Z>>>=be,Q-=be,_.lens[_.have++]=pe;else{if(pe===16){for(J=be+2;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(Z>>>=be,Q-=be,_.have===0){k.msg="invalid bit length repeat",_.mode=30;break}N=_.lens[_.have-1],K=3+(3&Z),Z>>>=2,Q-=2}else if(pe===17){for(J=be+3;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}Q-=be,N=0,K=3+(7&(Z>>>=be)),Z>>>=3,Q-=3}else{for(J=be+7;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}Q-=be,N=0,K=11+(127&(Z>>>=be)),Z>>>=7,Q-=7}if(_.have+K>_.nlen+_.ndist){k.msg="invalid bit length repeat",_.mode=30;break}for(;K--;)_.lens[_.have++]=N}}if(_.mode===30)break;if(_.lens[256]===0){k.msg="invalid code -- missing end-of-block",_.mode=30;break}if(_.lenbits=9,oe={bits:_.lenbits},q=c(u,_.lens,0,_.nlen,_.lencode,0,_.work,oe),_.lenbits=oe.bits,q){k.msg="invalid literal/lengths set",_.mode=30;break}if(_.distbits=6,_.distcode=_.distdyn,oe={bits:_.distbits},q=c(d,_.lens,_.nlen,_.ndist,_.distcode,0,_.work,oe),_.distbits=oe.bits,q){k.msg="invalid distances set",_.mode=30;break}if(_.mode=20,L===6)break e;case 20:_.mode=21;case 21:if(6<=M&&258<=z){k.next_out=U,k.avail_out=z,k.next_in=B,k.avail_in=M,_.hold=Z,_.bits=Q,l(k,he),U=k.next_out,F=k.output,z=k.avail_out,B=k.next_in,O=k.input,M=k.avail_in,Z=_.hold,Q=_.bits,_.mode===12&&(_.back=-1);break}for(_.back=0;xe=(re=_.lencode[Z&(1<<_.lenbits)-1])>>>16&255,pe=65535&re,!((be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(xe&&(240&xe)==0){for(ke=be,V=xe,D=pe;xe=(re=_.lencode[D+((Z&(1<<ke+V)-1)>>ke)])>>>16&255,pe=65535&re,!(ke+(be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}Z>>>=ke,Q-=ke,_.back+=ke}if(Z>>>=be,Q-=be,_.back+=be,_.length=pe,xe===0){_.mode=26;break}if(32&xe){_.back=-1,_.mode=12;break}if(64&xe){k.msg="invalid literal/length code",_.mode=30;break}_.extra=15&xe,_.mode=22;case 22:if(_.extra){for(J=_.extra;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.length+=Z&(1<<_.extra)-1,Z>>>=_.extra,Q-=_.extra,_.back+=_.extra}_.was=_.length,_.mode=23;case 23:for(;xe=(re=_.distcode[Z&(1<<_.distbits)-1])>>>16&255,pe=65535&re,!((be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if((240&xe)==0){for(ke=be,V=xe,D=pe;xe=(re=_.distcode[D+((Z&(1<<ke+V)-1)>>ke)])>>>16&255,pe=65535&re,!(ke+(be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}Z>>>=ke,Q-=ke,_.back+=ke}if(Z>>>=be,Q-=be,_.back+=be,64&xe){k.msg="invalid distance code",_.mode=30;break}_.offset=pe,_.extra=15&xe,_.mode=24;case 24:if(_.extra){for(J=_.extra;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.offset+=Z&(1<<_.extra)-1,Z>>>=_.extra,Q-=_.extra,_.back+=_.extra}if(_.offset>_.dmax){k.msg="invalid distance too far back",_.mode=30;break}_.mode=25;case 25:if(z===0)break e;if(K=he-z,_.offset>K){if((K=_.offset-K)>_.whave&&_.sane){k.msg="invalid distance too far back",_.mode=30;break}X=K>_.wnext?(K-=_.wnext,_.wsize-K):_.wnext-K,K>_.length&&(K=_.length),ee=_.window}else ee=F,X=U-_.offset,K=_.length;for(z<K&&(K=z),z-=K,_.length-=K;F[U++]=ee[X++],--K;);_.length===0&&(_.mode=21);break;case 26:if(z===0)break e;F[U++]=_.length,z--,_.mode=21;break;case 27:if(_.wrap){for(;Q<32;){if(M===0)break e;M--,Z|=O[B++]<<Q,Q+=8}if(he-=z,k.total_out+=he,_.total+=he,he&&(k.adler=_.check=_.flags?a(_.check,F,he,U-he):s(_.check,F,he,U-he)),he=z,(_.flags?Z:y(Z))!==_.check){k.msg="incorrect data check",_.mode=30;break}Q=Z=0}_.mode=28;case 28:if(_.wrap&&_.flags){for(;Q<32;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(Z!==(4294967295&_.total)){k.msg="incorrect length check",_.mode=30;break}Q=Z=0}_.mode=29;case 29:q=1;break e;case 30:q=-3;break e;case 31:return-4;default:return h}return k.next_out=U,k.avail_out=z,k.next_in=B,k.avail_in=M,_.hold=Z,_.bits=Q,(_.wsize||he!==k.avail_out&&_.mode<30&&(_.mode<27||L!==4))&&R(k,k.output,k.next_out,he-k.avail_out)?(_.mode=31,-4):(W-=k.avail_in,he-=k.avail_out,k.total_in+=W,k.total_out+=he,_.total+=he,_.wrap&&he&&(k.adler=_.check=_.flags?a(_.check,F,he,k.next_out-he):s(_.check,F,he,k.next_out-he)),k.data_type=_.bits+(_.last?64:0)+(_.mode===12?128:0)+(_.mode===20||_.mode===15?256:0),(W==0&&he===0||L===4)&&q===f&&(q=-5),q)},i.inflateEnd=function(k){if(!k||!k.state)return h;var L=k.state;return L.window&&(L.window=null),k.state=null,f},i.inflateGetHeader=function(k,L){var _;return k&&k.state?(2&(_=k.state).wrap)==0?h:((_.head=L).done=!1,f):h},i.inflateSetDictionary=function(k,L){var _,O=L.length;return k&&k.state?(_=k.state).wrap!==0&&_.mode!==11?h:_.mode===11&&s(1,L,O,0)!==_.check?-3:R(k,L,O,O)?(_.mode=31,-4):(_.havedict=1,f):h},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){"use strict";var o=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(u,d,f,h,p,m,g,y){var v,b,w,x,A,T,I,P,C,R=y.bits,k=0,L=0,_=0,O=0,F=0,B=0,U=0,M=0,z=0,Z=0,Q=null,W=0,he=new o.Buf16(16),K=new o.Buf16(16),X=null,ee=0;for(k=0;k<=15;k++)he[k]=0;for(L=0;L<h;L++)he[d[f+L]]++;for(F=R,O=15;1<=O&&he[O]===0;O--);if(O<F&&(F=O),O===0)return p[m++]=20971520,p[m++]=20971520,y.bits=1,0;for(_=1;_<O&&he[_]===0;_++);for(F<_&&(F=_),k=M=1;k<=15;k++)if(M<<=1,(M-=he[k])<0)return-1;if(0<M&&(u===0||O!==1))return-1;for(K[1]=0,k=1;k<15;k++)K[k+1]=K[k]+he[k];for(L=0;L<h;L++)d[f+L]!==0&&(g[K[d[f+L]]++]=L);if(T=u===0?(Q=X=g,19):u===1?(Q=s,W-=257,X=a,ee-=257,256):(Q=l,X=c,-1),k=_,A=m,U=L=Z=0,w=-1,x=(z=1<<(B=F))-1,u===1&&852<z||u===2&&592<z)return 1;for(;;){for(I=k-U,C=g[L]<T?(P=0,g[L]):g[L]>T?(P=X[ee+g[L]],Q[W+g[L]]):(P=96,0),v=1<<k-U,_=b=1<<B;p[A+(Z>>U)+(b-=v)]=I<<24|P<<16|C|0,b!==0;);for(v=1<<k-1;Z&v;)v>>=1;if(v!==0?(Z&=v-1,Z+=v):Z=0,L++,--he[k]==0){if(k===O)break;k=d[f+g[L]]}if(F<k&&(Z&x)!==w){for(U===0&&(U=F),A+=_,M=1<<(B=k-U);B+U<O&&!((M-=he[B+U])<=0);)B++,M<<=1;if(z+=1<<B,u===1&&852<z||u===2&&592<z)return 1;p[w=Z&x]=F<<24|B<<16|A-m|0}}return Z!==0&&(p[A+Z]=k-U<<24|4194304),y.bits=F,0}},{"../utils/common":41}],51:[function(n,r,i){"use strict";r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){"use strict";var o=n("../utils/common"),s=0,a=1;function l(re){for(var te=re.length;0<=--te;)re[te]=0}var c=0,u=29,d=256,f=d+1+u,h=30,p=19,m=2*f+1,g=15,y=16,v=7,b=256,w=16,x=17,A=18,T=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],I=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],P=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],R=new Array(2*(f+2));l(R);var k=new Array(2*h);l(k);var L=new Array(512);l(L);var _=new Array(256);l(_);var O=new Array(u);l(O);var F,B,U,M=new Array(h);function z(re,te,fe,de,ue){this.static_tree=re,this.extra_bits=te,this.extra_base=fe,this.elems=de,this.max_length=ue,this.has_stree=re&&re.length}function Z(re,te){this.dyn_tree=re,this.max_code=0,this.stat_desc=te}function Q(re){return re<256?L[re]:L[256+(re>>>7)]}function W(re,te){re.pending_buf[re.pending++]=255&te,re.pending_buf[re.pending++]=te>>>8&255}function he(re,te,fe){re.bi_valid>y-fe?(re.bi_buf|=te<<re.bi_valid&65535,W(re,re.bi_buf),re.bi_buf=te>>y-re.bi_valid,re.bi_valid+=fe-y):(re.bi_buf|=te<<re.bi_valid&65535,re.bi_valid+=fe)}function K(re,te,fe){he(re,fe[2*te],fe[2*te+1])}function X(re,te){for(var fe=0;fe|=1&re,re>>>=1,fe<<=1,0<--te;);return fe>>>1}function ee(re,te,fe){var de,ue,ie=new Array(g+1),ce=0;for(de=1;de<=g;de++)ie[de]=ce=ce+fe[de-1]<<1;for(ue=0;ue<=te;ue++){var Te=re[2*ue+1];Te!==0&&(re[2*ue]=X(ie[Te]++,Te))}}function be(re){var te;for(te=0;te<f;te++)re.dyn_ltree[2*te]=0;for(te=0;te<h;te++)re.dyn_dtree[2*te]=0;for(te=0;te<p;te++)re.bl_tree[2*te]=0;re.dyn_ltree[2*b]=1,re.opt_len=re.static_len=0,re.last_lit=re.matches=0}function xe(re){8<re.bi_valid?W(re,re.bi_buf):0<re.bi_valid&&(re.pending_buf[re.pending++]=re.bi_buf),re.bi_buf=0,re.bi_valid=0}function pe(re,te,fe,de){var ue=2*te,ie=2*fe;return re[ue]<re[ie]||re[ue]===re[ie]&&de[te]<=de[fe]}function ke(re,te,fe){for(var de=re.heap[fe],ue=fe<<1;ue<=re.heap_len&&(ue<re.heap_len&&pe(te,re.heap[ue+1],re.heap[ue],re.depth)&&ue++,!pe(te,de,re.heap[ue],re.depth));)re.heap[fe]=re.heap[ue],fe=ue,ue<<=1;re.heap[fe]=de}function V(re,te,fe){var de,ue,ie,ce,Te=0;if(re.last_lit!==0)for(;de=re.pending_buf[re.d_buf+2*Te]<<8|re.pending_buf[re.d_buf+2*Te+1],ue=re.pending_buf[re.l_buf+Te],Te++,de===0?K(re,ue,te):(K(re,(ie=_[ue])+d+1,te),(ce=T[ie])!==0&&he(re,ue-=O[ie],ce),K(re,ie=Q(--de),fe),(ce=I[ie])!==0&&he(re,de-=M[ie],ce)),Te<re.last_lit;);K(re,b,te)}function D(re,te){var fe,de,ue,ie=te.dyn_tree,ce=te.stat_desc.static_tree,Te=te.stat_desc.has_stree,ye=te.stat_desc.elems,le=-1;for(re.heap_len=0,re.heap_max=m,fe=0;fe<ye;fe++)ie[2*fe]!==0?(re.heap[++re.heap_len]=le=fe,re.depth[fe]=0):ie[2*fe+1]=0;for(;re.heap_len<2;)ie[2*(ue=re.heap[++re.heap_len]=le<2?++le:0)]=1,re.depth[ue]=0,re.opt_len--,Te&&(re.static_len-=ce[2*ue+1]);for(te.max_code=le,fe=re.heap_len>>1;1<=fe;fe--)ke(re,ie,fe);for(ue=ye;fe=re.heap[1],re.heap[1]=re.heap[re.heap_len--],ke(re,ie,1),de=re.heap[1],re.heap[--re.heap_max]=fe,re.heap[--re.heap_max]=de,ie[2*ue]=ie[2*fe]+ie[2*de],re.depth[ue]=(re.depth[fe]>=re.depth[de]?re.depth[fe]:re.depth[de])+1,ie[2*fe+1]=ie[2*de+1]=ue,re.heap[1]=ue++,ke(re,ie,1),2<=re.heap_len;);re.heap[--re.heap_max]=re.heap[1],(function(Ae,_e){var Ue,st,me,Ie,Re,ve,Se=_e.dyn_tree,ne=_e.max_code,Oe=_e.stat_desc.static_tree,Y=_e.stat_desc.has_stree,we=_e.stat_desc.extra_bits,Fe=_e.stat_desc.extra_base,ae=_e.stat_desc.max_length,et=0;for(Ie=0;Ie<=g;Ie++)Ae.bl_count[Ie]=0;for(Se[2*Ae.heap[Ae.heap_max]+1]=0,Ue=Ae.heap_max+1;Ue<m;Ue++)ae<(Ie=Se[2*Se[2*(st=Ae.heap[Ue])+1]+1]+1)&&(Ie=ae,et++),Se[2*st+1]=Ie,ne<st||(Ae.bl_count[Ie]++,Re=0,Fe<=st&&(Re=we[st-Fe]),ve=Se[2*st],Ae.opt_len+=ve*(Ie+Re),Y&&(Ae.static_len+=ve*(Oe[2*st+1]+Re)));if(et!==0){do{for(Ie=ae-1;Ae.bl_count[Ie]===0;)Ie--;Ae.bl_count[Ie]--,Ae.bl_count[Ie+1]+=2,Ae.bl_count[ae]--,et-=2}while(0<et);for(Ie=ae;Ie!==0;Ie--)for(st=Ae.bl_count[Ie];st!==0;)ne<(me=Ae.heap[--Ue])||(Se[2*me+1]!==Ie&&(Ae.opt_len+=(Ie-Se[2*me+1])*Se[2*me],Se[2*me+1]=Ie),st--)}})(re,te),ee(ie,le,re.bl_count)}function N(re,te,fe){var de,ue,ie=-1,ce=te[1],Te=0,ye=7,le=4;for(ce===0&&(ye=138,le=3),te[2*(fe+1)+1]=65535,de=0;de<=fe;de++)ue=ce,ce=te[2*(de+1)+1],++Te<ye&&ue===ce||(Te<le?re.bl_tree[2*ue]+=Te:ue!==0?(ue!==ie&&re.bl_tree[2*ue]++,re.bl_tree[2*w]++):Te<=10?re.bl_tree[2*x]++:re.bl_tree[2*A]++,ie=ue,le=(Te=0)===ce?(ye=138,3):ue===ce?(ye=6,3):(ye=7,4))}function q(re,te,fe){var de,ue,ie=-1,ce=te[1],Te=0,ye=7,le=4;for(ce===0&&(ye=138,le=3),de=0;de<=fe;de++)if(ue=ce,ce=te[2*(de+1)+1],!(++Te<ye&&ue===ce)){if(Te<le)for(;K(re,ue,re.bl_tree),--Te!=0;);else ue!==0?(ue!==ie&&(K(re,ue,re.bl_tree),Te--),K(re,w,re.bl_tree),he(re,Te-3,2)):Te<=10?(K(re,x,re.bl_tree),he(re,Te-3,3)):(K(re,A,re.bl_tree),he(re,Te-11,7));ie=ue,le=(Te=0)===ce?(ye=138,3):ue===ce?(ye=6,3):(ye=7,4)}}l(M);var oe=!1;function J(re,te,fe,de){he(re,(c<<1)+(de?1:0),3),(function(ue,ie,ce,Te){xe(ue),Te&&(W(ue,ce),W(ue,~ce)),o.arraySet(ue.pending_buf,ue.window,ie,ce,ue.pending),ue.pending+=ce})(re,te,fe,!0)}i._tr_init=function(re){oe||((function(){var te,fe,de,ue,ie,ce=new Array(g+1);for(ue=de=0;ue<u-1;ue++)for(O[ue]=de,te=0;te<1<<T[ue];te++)_[de++]=ue;for(_[de-1]=ue,ue=ie=0;ue<16;ue++)for(M[ue]=ie,te=0;te<1<<I[ue];te++)L[ie++]=ue;for(ie>>=7;ue<h;ue++)for(M[ue]=ie<<7,te=0;te<1<<I[ue]-7;te++)L[256+ie++]=ue;for(fe=0;fe<=g;fe++)ce[fe]=0;for(te=0;te<=143;)R[2*te+1]=8,te++,ce[8]++;for(;te<=255;)R[2*te+1]=9,te++,ce[9]++;for(;te<=279;)R[2*te+1]=7,te++,ce[7]++;for(;te<=287;)R[2*te+1]=8,te++,ce[8]++;for(ee(R,f+1,ce),te=0;te<h;te++)k[2*te+1]=5,k[2*te]=X(te,5);F=new z(R,T,d+1,f,g),B=new z(k,I,0,h,g),U=new z(new Array(0),P,0,p,v)})(),oe=!0),re.l_desc=new Z(re.dyn_ltree,F),re.d_desc=new Z(re.dyn_dtree,B),re.bl_desc=new Z(re.bl_tree,U),re.bi_buf=0,re.bi_valid=0,be(re)},i._tr_stored_block=J,i._tr_flush_block=function(re,te,fe,de){var ue,ie,ce=0;0<re.level?(re.strm.data_type===2&&(re.strm.data_type=(function(Te){var ye,le=4093624447;for(ye=0;ye<=31;ye++,le>>>=1)if(1&le&&Te.dyn_ltree[2*ye]!==0)return s;if(Te.dyn_ltree[18]!==0||Te.dyn_ltree[20]!==0||Te.dyn_ltree[26]!==0)return a;for(ye=32;ye<d;ye++)if(Te.dyn_ltree[2*ye]!==0)return a;return s})(re)),D(re,re.l_desc),D(re,re.d_desc),ce=(function(Te){var ye;for(N(Te,Te.dyn_ltree,Te.l_desc.max_code),N(Te,Te.dyn_dtree,Te.d_desc.max_code),D(Te,Te.bl_desc),ye=p-1;3<=ye&&Te.bl_tree[2*C[ye]+1]===0;ye--);return Te.opt_len+=3*(ye+1)+5+5+4,ye})(re),ue=re.opt_len+3+7>>>3,(ie=re.static_len+3+7>>>3)<=ue&&(ue=ie)):ue=ie=fe+5,fe+4<=ue&&te!==-1?J(re,te,fe,de):re.strategy===4||ie===ue?(he(re,2+(de?1:0),3),V(re,R,k)):(he(re,4+(de?1:0),3),(function(Te,ye,le,Ae){var _e;for(he(Te,ye-257,5),he(Te,le-1,5),he(Te,Ae-4,4),_e=0;_e<Ae;_e++)he(Te,Te.bl_tree[2*C[_e]+1],3);q(Te,Te.dyn_ltree,ye-1),q(Te,Te.dyn_dtree,le-1)})(re,re.l_desc.max_code+1,re.d_desc.max_code+1,ce+1),V(re,re.dyn_ltree,re.dyn_dtree)),be(re),de&&xe(re)},i._tr_tally=function(re,te,fe){return re.pending_buf[re.d_buf+2*re.last_lit]=te>>>8&255,re.pending_buf[re.d_buf+2*re.last_lit+1]=255&te,re.pending_buf[re.l_buf+re.last_lit]=255&fe,re.last_lit++,te===0?re.dyn_ltree[2*fe]++:(re.matches++,te--,re.dyn_ltree[2*(_[fe]+d+1)]++,re.dyn_dtree[2*Q(te)]++),re.last_lit===re.lit_bufsize-1},i._tr_align=function(re){he(re,2,3),K(re,b,R),(function(te){te.bi_valid===16?(W(te,te.bi_buf),te.bi_buf=0,te.bi_valid=0):8<=te.bi_valid&&(te.pending_buf[te.pending++]=255&te.bi_buf,te.bi_buf>>=8,te.bi_valid-=8)})(re)}},{"../utils/common":41}],53:[function(n,r,i){"use strict";r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(o){(function(s,a){"use strict";if(!s.setImmediate){var l,c,u,d,f=1,h={},p=!1,m=s.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(s);g=g&&g.setTimeout?g:s,l={}.toString.call(s.process)==="[object process]"?function(w){process.nextTick(function(){v(w)})}:(function(){if(s.postMessage&&!s.importScripts){var w=!0,x=s.onmessage;return s.onmessage=function(){w=!1},s.postMessage("","*"),s.onmessage=x,w}})()?(d="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",b,!1):s.attachEvent("onmessage",b),function(w){s.postMessage(d+w,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(w){v(w.data)},function(w){u.port2.postMessage(w)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(w){var x=m.createElement("script");x.onreadystatechange=function(){v(w),x.onreadystatechange=null,c.removeChild(x),x=null},c.appendChild(x)}):function(w){setTimeout(v,0,w)},g.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var x=new Array(arguments.length-1),A=0;A<x.length;A++)x[A]=arguments[A+1];return h[f]={callback:w,args:x},l(f),f++},g.clearImmediate=y}function y(w){delete h[w]}function v(w){if(p)setTimeout(v,0,w);else{var x=h[w];if(x){p=!0;try{(function(A){var T=A.callback,I=A.args;switch(I.length){case 0:T();break;case 1:T(I[0]);break;case 2:T(I[0],I[1]);break;case 3:T(I[0],I[1],I[2]);break;default:T.apply(a,I)}})(x)}finally{y(w),p=!1}}}}function b(w){w.source===s&&typeof w.data=="string"&&w.data.indexOf(d)===0&&v(+w.data.slice(d.length))}})(typeof self>"u"?o===void 0?this:o:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})),l_e=Kc(a_e(),1);const c_e=e=>/\.xml$|\.rels$/i.test(e);function TZt(e){if(e.length>=2){const n=e[0],r=e[1];if(n===255&&r===254)return"utf-16le";if(n===254&&r===255)return"utf-16be"}let t=0;for(let n=0;n<Math.min(64,e.length);n++)e[n]===0&&t++;return t>16?"utf-16le":"utf-8"}function u_e(e){return e&&e.charCodeAt(0)===65279?e.slice(1):e}function d_e(e){if(typeof e=="string")return u_e(e);let t=null;if(e&&typeof e=="object"&&(e instanceof Uint8Array?t=e:typeof Buffer<"u"&&Buffer.isBuffer&&Buffer.isBuffer(e)?t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):ArrayBuffer.isView&&ArrayBuffer.isView(e)?t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.constructor&&(e instanceof ArrayBuffer||e.constructor.name==="ArrayBuffer")&&(t=new Uint8Array(e))),!t)throw new Error("Unsupported content type for XML");const n=TZt(t);let r=new TextDecoder(n).decode(t);return r=u_e(r),n!=="utf-8"&&(r=r.replace(/(<\?xml\b[^?]*?)\bencoding\s*=\s*["'][^"']*["']/i,'$1encoding="UTF-8"')),r}const Tj=[{zipPath:"word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"},{zipPath:"docProps/core.xml",contentType:"application/vnd.openxmlformats-package.core-properties+xml",relationshipType:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"},{zipPath:"docProps/app.xml",contentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"},{zipPath:"docProps/custom.xml",contentType:"application/vnd.openxmlformats-officedocument.custom-properties+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"}];var IZt=Kc(Mm(),1),kZt="SD_OPC_QUOT",EZt=/SD_OPC_QUOT/g;function CZt(e){return String(e).replace(/"/g,kZt).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(EZt,""")}function f_e(e){return IZt.js2xml(e,{spaces:0,attributeValueFn:CZt})}var _Zt=Kc(Mm(),1),PZt="http://schemas.openxmlformats.org/package/2006/relationships";function Ij(e,t,n){if(n&&Object.prototype.hasOwnProperty.call(n,e))return n[e];if(t)return Array.isArray(t)?t.find(r=>r.name===e)?.content:t[e]}function RZt(e,t,n){return Ij(e,t,n)!=null}function h_e(e){try{return _Zt.xml2js(e,{compact:!1})}catch{return null}}function p_e(e){return f_e(e)}function m_e(e,t){return e?.elements?.find(n=>n.name?(n.name.includes(":")?n.name.split(":").pop():n.name)===t:!1)}function g_e(){return{declaration:{attributes:{version:"1.0",encoding:"UTF-8",standalone:"yes"}},elements:[{type:"element",name:"Relationships",attributes:{xmlns:PZt},elements:[]}]}}function LZt(e){let t=0;for(const n of e.elements||[]){const r=n.attributes?.Id;if(!r)continue;const i=r.match(/^rId(\d+)$/);i&&(t=Math.max(t,parseInt(i[1],10)))}return t}function NZt(e,t){e.elements||(e.elements=[]);const n=new Map;for(const o of Tj)n.set(`/${o.zipPath}`,o);const r=new Map;for(let o=0;o<e.elements.length;o++){const s=e.elements[o];if(s.name!=="Override")continue;const a=s.attributes?.PartName;!a||!n.has(a)||(r.has(a)||r.set(a,[]),r.get(a).push(o))}const i=new Set;for(const[o,s]of n){const a=t.has(s.zipPath),l=r.get(o)||[];if(!a){for(const c of l)i.add(c);continue}if(l.length===0)e.elements.push({type:"element",name:"Override",attributes:{PartName:o,ContentType:s.contentType}});else{e.elements[l[0]].attributes.ContentType=s.contentType;for(let c=1;c<l.length;c++)i.add(l[c])}}if(i.size>0){const o=[...i].sort((s,a)=>a-s);for(const s of o)e.elements.splice(s,1)}}function MZt(e,t){e.elements||(e.elements=[]);const n=new Map;for(const s of Tj)n.set(s.relationshipType,s);const r=new Map;for(let s=0;s<e.elements.length;s++){const a=e.elements[s];if(a.name!=="Relationship")continue;const l=a.attributes?.Type;!l||!n.has(l)||(r.has(l)||r.set(l,[]),r.get(l).push({index:s,element:a}))}const i=new Set;let o=LZt(e);for(const[s,a]of n){const l=t.has(a.zipPath),c=r.get(s)||[];if(!l){for(const{index:u}of c)i.add(u);continue}if(c.length===0)o++,e.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${o}`,Type:s,Target:a.zipPath}});else{c[0].element.attributes.Target=a.zipPath;for(let u=1;u<c.length;u++)i.add(c[u].index)}}if(i.size>0){const s=[...i].sort((a,l)=>l-a);for(const a of s)e.elements.splice(a,1)}}function y_e({baseFiles:e,updatedDocs:t}){const n=new Set;for(const c of Tj)RZt(c.zipPath,e,t)&&n.add(c.zipPath);const r=Ij("[Content_Types].xml",e,t);if(r==null)throw new Error("syncPackageMetadata: [Content_Types].xml is missing from the package. Cannot safely reconcile package metadata without an existing content types file.");const i=h_e(r);if(!i)throw new Error("syncPackageMetadata: [Content_Types].xml could not be parsed as valid XML. Cannot safely reconcile package metadata from a malformed content types file.");const o=m_e(i,"Types");if(!o)throw new Error("syncPackageMetadata: [Content_Types].xml does not contain a <Types> root element.");NZt(o,n);const s=Ij("_rels/.rels",e,t);let a;if(s==null)a=g_e();else if(a=h_e(s),!a)throw new Error("syncPackageMetadata: _rels/.rels could not be parsed as valid XML. Cannot safely reconcile root relationships from a malformed rels file.");let l=m_e(a,"Relationships");return l||(a=g_e(),l=a.elements[0]),MZt(l,n),{contentTypesXml:p_e(i),relsXml:p_e(a)}}var DZt=Kc(Mm(),1);const b_e=[{zipPath:"word/numbering.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",relTarget:"numbering.xml"}];function OZt(e){let t=0;for(const n of e){const r=n.attributes?.Id?.match(/^rId(\d+)$/);r&&(t=Math.max(t,Number(r[1])))}return t}function FZt(e,t){if(!e)return e;let n;try{n=DZt.xml2js(e,{compact:!1})}catch{return e}const r=n?.elements?.find(s=>s.name==="Relationships");if(!r)return e;r.elements||(r.elements=[]);let i=!1,o=OZt(r.elements);for(const s of b_e)t(s.zipPath)&&(r.elements.some(a=>a.attributes?.Type===s.relationshipType)||(o++,r.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${o}`,Type:s.relationshipType,Target:s.relTarget}}),i=!0));return i?f_e(n):e}var BZt=vs({detectContainerType:()=>kj},1);function v_e(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function kj(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);return v_e(t,w_e)?"zip":v_e(t,A_e)?"cfb":"unknown"}var w_e,A_e,x_e=Le((()=>{w_e=[80,75,3,4],A_e=[208,207,17,224,161,177,26,225]}));function S_e(e){const t=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}function HZt(e,t){return(e+1)*t}function wE(e,t){return e.getUint16(t,!0)}function Pl(e,t){return e.getUint32(t,!0)}function zZt(e,t){const n=BigInt(e.getUint32(t,!0));return BigInt(e.getUint32(t+4,!0))<<32n|n}function UZt(e){return T_e.decode(e).replace(/\u0000+$/g,"")}var Ej,VZt,WZt,GZt,jZt,qZt,YZt,Cj,KZt,XZt,AE,JZt,ZZt,QZt,T_e,$Zt=Le((()=>{Ej=new Uint8Array([208,207,17,224,161,177,26,225]),VZt=512,WZt=128,GZt=109,jZt=512,qZt=4096,YZt=4294967295,Cj=4294967294,KZt=4294967292,XZt=4294967295,AE={STORAGE:1,STREAM:2,ROOT:5},JZt=65534,ZZt=3,QZt=4,T_e=new TextDecoder("utf-16le")}));function xE(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function I_e(e,t,n,r){if(t<0||n<0||t+n>e.length)throw new Error(`CFB ${r} exceeds available data`)}function eQt(e){if(e.length<512)throw new Error(`CFB header is truncated (${e.length} bytes)`);for(let c=0;c<Ej.length;c++)if(e[c]!==Ej[c])throw new Error("Invalid CFB signature");const t=xE(e),n=wE(t,26),r=wE(t,28),i=wE(t,30),o=wE(t,32),s=1<<i,a=1<<o;if(r!==65534)throw new Error(`Unsupported CFB byte order: 0x${r.toString(16)}`);if(!(n===3&&s===512||n===4&&s===4096))throw new Error(`Unsupported CFB major version ${n} with sector size ${s}`);const l=[];for(let c=0;c<109;c++){const u=Pl(t,76+c*4);u!==4294967295&&l.push(u)}return{sectorSize:s,miniSectorSize:a,numberOfFatSectors:Pl(t,44),firstDirectorySector:Pl(t,48),miniStreamCutoffSize:Pl(t,56),firstMiniFatSector:Pl(t,60),numberOfMiniFatSectors:Pl(t,64),firstDifatSector:Pl(t,68),numberOfDifatSectors:Pl(t,72),difatEntries:l}}function _j(e,t,n){if(n>=4294967292)throw new Error(`Invalid sector id 0x${n.toString(16)}`);const r=HZt(n,t.sectorSize);return I_e(e,r,t.sectorSize,`sector ${n}`),e.subarray(r,r+t.sectorSize)}function tQt(e,t){const n=[...t.difatEntries];let r=t.firstDifatSector;for(let i=0;i<t.numberOfDifatSectors&&!(r===4294967294||r===4294967295);i++){const o=xE(_j(e,t,r)),s=t.sectorSize/4-1;for(let a=0;a<s;a++){const l=Pl(o,a*4);l!==4294967295&&n.push(l)}r=Pl(o,t.sectorSize-4)}if(n.length<t.numberOfFatSectors)throw new Error(`CFB DIFAT only exposed ${n.length} FAT sectors, expected ${t.numberOfFatSectors}`);return n.slice(0,t.numberOfFatSectors)}function nQt(e,t){const n=tQt(e,t),r=[];for(const i of n){const o=xE(_j(e,t,i)),s=t.sectorSize/4;for(let a=0;a<s;a++)r.push(Pl(o,a*4))}return r}function hD(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const i=[],o=new Set;let s=r;for(;s!==Cj;){if(o.has(s))throw new Error(`CFB sector chain loop detected at sector ${s}`);if(s>=n.length)throw new Error(`CFB sector ${s} is out of FAT bounds`);o.add(s),i.push(_j(e,t,s));const a=n[s];if(a==null)throw new Error(`CFB FAT missing next sector for sector ${s}`);s=a}return S_e(i)}function rQt(e,t){const n=zZt(e,t);if(n>BigInt(Number.MAX_SAFE_INTEGER))throw new Error(`CFB stream is too large to fit in a JavaScript number: ${n.toString()}`);return Number(n)}function iQt(e){const t=[];for(let n=0;n+128<=e.length;n+=128){const r=e.subarray(n,n+128),i=xE(r),o=wE(i,64),s=r.subarray(0,Math.max(0,Math.min(o,64)-2));t.push({name:UZt(s),objectType:r[66],leftSiblingId:Pl(i,68),rightSiblingId:Pl(i,72),childId:Pl(i,76),startSector:Pl(i,116),streamSize:rQt(i,120)})}return t}function Pj(e,t,n,r=new Set){if(t===4294967295)return!1;if(t>=e.length)throw new Error(`CFB directory entry id ${t} is out of bounds`);if(r.has(t))throw new Error(`CFB directory tree loop detected at entry id ${t}`);r.add(t);const i=e[t];return!!(Pj(e,i.leftSiblingId,n,r)||n(i)===!0||Pj(e,i.rightSiblingId,n,r))}function oQt(e,t){const n=t.split("/").map(i=>i.trim()).filter(Boolean);let r=e[0];for(const i of n){if(r.objectType!==AE.ROOT&&r.objectType!==AE.STORAGE)return null;let o=null;if(Pj(e,r.childId,s=>s.name.toLowerCase()===i.toLowerCase()?(o=s,!0):!1),!o)return null;r=o}return r}function sQt(e,t,n,r){return e.streamSize===0||e.startSector===4294967294?new Uint8Array(0):hD(t,n,r,e.startSector).subarray(0,e.streamSize)}function aQt(e,t,n){if(t.numberOfMiniFatSectors===0||t.firstMiniFatSector===4294967294)return[];const r=hD(e,t,n,t.firstMiniFatSector),i=xE(r),o=Math.floor(r.length/4),s=[];for(let a=0;a<o;a++)s.push(Pl(i,a*4));return s}function lQt(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const i=[],o=new Set;let s=r;for(;s!==Cj;){if(o.has(s))throw new Error(`CFB mini sector chain loop detected at mini sector ${s}`);if(s>=t.length)throw new Error(`CFB mini sector ${s} is out of MiniFAT bounds`);o.add(s);const a=s*n;I_e(e,a,n,`mini sector ${s}`),i.push(e.subarray(a,a+n));const l=t[s];if(l==null)throw new Error(`CFB MiniFAT missing next sector for mini sector ${s}`);s=l}return S_e(i)}function cQt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e),n=eQt(t),r=nQt(t,n),i=iQt(hD(t,n,r,n.firstDirectorySector));if(i.length===0||i[0].objectType!==AE.ROOT)throw new Error("CFB root directory entry is missing");const o=i[0],s=aQt(t,n,r),a=sQt(o,t,n,r);return{getStream(l){const c=oQt(i,l);return!c||c.objectType!==AE.STREAM?null:c.streamSize<n.miniStreamCutoffSize?lQt(a,s,n.miniSectorSize,c.startSector).subarray(0,c.streamSize):hD(t,n,r,c.startSector).subarray(0,c.streamSize)}}}var uQt=Le((()=>{$Zt()}));function dQt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);let n;try{n=cQt(t)}catch(o){throw new $o(ma.DECRYPTION_FAILED,"Failed to parse OLE/CFB container",o instanceof Error?o:void 0)}const r=n.getStream("/EncryptionInfo");if(!r)throw new $o(ma.DECRYPTION_FAILED,"CFB container missing EncryptionInfo stream");const i=n.getStream("/EncryptedPackage");if(!i)throw new $o(ma.DECRYPTION_FAILED,"CFB container missing EncryptedPackage stream");return{encryptionInfo:r,encryptedPackage:i}}var fQt=Le((()=>{uQt(),yE()}));function k_e(e,t){return e[t]|e[t+1]<<8}function Rj(e,t){const n=new RegExp(`<(?:\\w+:)?${t}\\b([^>]*)/?>`),r=e.match(n);if(!r)return null;const i={},o=/(\w+)="([^"]*)"/g;let s;for(;(s=o.exec(r[1]))!==null;)i[s[1]]=s[2];return i}function hQt(e){if(typeof atob=="function"){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}return new Uint8Array(Buffer.from(e,"base64"))}function qA(e,t,n){const r=e?.[t];if(r==null)throw new $o(ma.DECRYPTION_FAILED,`Missing required attribute "${t}" on <${n}>`);return r}function yb(e,t,n){return hQt(qA(e,t,n))}function YA(e,t,n){const r=parseInt(qA(e,t,n),10);if(Number.isNaN(r))throw new $o(ma.DECRYPTION_FAILED,`Invalid integer for attribute "${t}" on <${n}>`);return r}function pQt(e){const t=new TextDecoder("utf-8").decode(e),n=Rj(t,"keyData"),r=Rj(t,"dataIntegrity"),i=Rj(t,"encryptedKey");return{keySalt:yb(n,"saltValue","keyData"),keyBits:YA(n,"keyBits","keyData"),hashAlgorithm:qA(n,"hashAlgorithm","keyData"),hashSize:YA(n,"hashSize","keyData"),blockSize:YA(n,"blockSize","keyData"),cipherAlgorithm:qA(n,"cipherAlgorithm","keyData"),cipherChaining:qA(n,"cipherChaining","keyData"),spinCount:YA(i,"spinCount","encryptedKey"),passwordSalt:yb(i,"saltValue","encryptedKey"),passwordHashAlgorithm:qA(i,"hashAlgorithm","encryptedKey"),passwordKeyBits:YA(i,"keyBits","encryptedKey"),passwordBlockSize:YA(i,"blockSize","encryptedKey"),encryptedVerifierHashInput:yb(i,"encryptedVerifierHashInput","encryptedKey"),encryptedVerifierHashValue:yb(i,"encryptedVerifierHashValue","encryptedKey"),encryptedKeyValue:yb(i,"encryptedKeyValue","encryptedKey"),encryptedHmacKey:yb(r,"encryptedHmacKey","dataIntegrity"),encryptedHmacValue:yb(r,"encryptedHmacValue","dataIntegrity")}}function mQt(e){if(e.length<pD)throw new $o(ma.DECRYPTION_FAILED,`EncryptionInfo too short: ${e.length} bytes (minimum ${pD})`);const t=k_e(e,0),n=k_e(e,2);if(t===E_e&&n===C_e)return{type:"agile",params:pQt(e.subarray(pD))};throw(t===__e||t===P_e)&&n===R_e?new $o(ma.ENCRYPTION_UNSUPPORTED,"Standard Encryption (Office 2007) is not yet supported. Only Agile Encryption (Office 2010+) is supported."):t<=2?new $o(ma.ENCRYPTION_UNSUPPORTED,"Legacy RC4 encryption is not supported. Only Agile Encryption (Office 2010+) is supported."):new $o(ma.ENCRYPTION_UNSUPPORTED,`Unrecognized EncryptionInfo version=${t} reserved=${n}`)}var E_e,C_e,__e,P_e,R_e,pD,gQt=Le((()=>{yE(),E_e=4,C_e=4,__e=3,P_e=4,R_e=3,pD=8}));function Lj(){const e=globalThis.crypto?.subtle;if(!e)throw new $o(ma.DECRYPTION_FAILED,"Web Crypto API (SubtleCrypto) is not available in this environment");return e}function SE(e){const t={SHA1:"SHA-1","SHA-1":"SHA-1",SHA256:"SHA-256","SHA-256":"SHA-256",SHA384:"SHA-384","SHA-384":"SHA-384",SHA512:"SHA-512","SHA-512":"SHA-512"}[e];if(!t)throw new $o(ma.DECRYPTION_FAILED,`Unsupported hash algorithm: ${e}`);return t}function yQt(e){const t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}function KA(...e){const t=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}function L_e(e){const t=new Uint8Array(4);return t[0]=e&255,t[1]=e>>>8&255,t[2]=e>>>16&255,t[3]=e>>>24&255,t}function XA(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}async function JA(e,t){const n=await Lj().digest(e,XA(t));return new Uint8Array(n)}async function ZA(e,t,n){const r=Lj(),i=16,o=await r.importKey("raw",XA(e),{name:"AES-CBC"},!1,["encrypt","decrypt"]),s=n.subarray(n.length-i),a=new Uint8Array(i);a.fill(i);const l=new Uint8Array(await r.encrypt({name:"AES-CBC",iv:XA(s)},o,a)).subarray(0,i),c=new Uint8Array(n.length+i);c.set(n),c.set(l,n.length);const u=await r.decrypt({name:"AES-CBC",iv:XA(t)},o,c);return new Uint8Array(u).subarray(0,n.length)}async function Nj(e,t,n,r,i,o){const s=SE(i);let a=await JA(s,KA(t,yQt(e)));for(let d=0;d<n;d++)a=await JA(s,KA(L_e(d),a));const l=await JA(s,KA(a,o)),c=r/8;if(l.length>=c)return l.subarray(0,c);const u=new Uint8Array(c);return u.set(l),u.fill(54,l.length),u}async function Mj(e,t,n,r){let i;if(n?i=await JA(SE(e),KA(t,n)):i=t,i.length>=r)return i.subarray(0,r);const o=new Uint8Array(r);return o.set(i),o.fill(54,i.length),o}async function bQt(e,t){const{passwordSalt:n,spinCount:r,passwordHashAlgorithm:i,passwordKeyBits:o,passwordBlockSize:s}=t,a=await Nj(e,n,r,o,i,M_e),l=await Nj(e,n,r,o,i,D_e),c=await Nj(e,n,r,o,i,O_e),u=await Mj(i,n,void 0,s),d=await ZA(a,u,t.encryptedVerifierHashInput),f=await ZA(l,u,t.encryptedVerifierHashValue),h=await JA(SE(i),d);if(!N_e(h,f.subarray(0,h.length)))throw new $o(ma.PASSWORD_INVALID,"The password is incorrect");return ZA(c,u,t.encryptedKeyValue)}function N_e(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function vQt(e,t,n){const{keySalt:r,hashAlgorithm:i,blockSize:o}=t,s=SE(i);if(n.length<Dj)throw new $o(ma.DECRYPTION_FAILED,"EncryptedPackage too short to contain size header");const a=n[0]|n[1]<<8|n[2]<<16|n[3]<<24>>>0,l=n.subarray(Dj),c=Math.ceil(l.length/mD),u=[];for(let d=0;d<c;d++){const f=d*mD,h=Math.min(f+mD,l.length),p=l.subarray(f,h),m=await JA(s,KA(r,L_e(d))),g=await ZA(e,m.length>=o?m.subarray(0,o):m,p);u.push(g)}return KA(...u).subarray(0,a)}async function wQt(e,t,n){const{keySalt:r,hashAlgorithm:i,blockSize:o,hashSize:s}=t,a=SE(i),l=Lj(),c=(await ZA(e,await Mj(i,r,F_e,o),t.encryptedHmacKey)).subarray(0,s),u=await ZA(e,await Mj(i,r,B_e,o),t.encryptedHmacValue),d=await l.importKey("raw",XA(c),{name:"HMAC",hash:a},!1,["sign"]),f=new Uint8Array(await l.sign("HMAC",d,XA(n)));if(!N_e(f,u.subarray(0,f.length)))throw new $o(ma.DECRYPTION_FAILED,"Data integrity check failed — the encrypted package may be corrupt or tampered with")}async function AQt(e,t,n){try{const r=await bQt(e,t);return await wQt(r,t,n),await vQt(r,t,n)}catch(r){throw r instanceof $o?r:new $o(ma.DECRYPTION_FAILED,"Decryption failed unexpectedly",r instanceof Error?r:void 0)}}var M_e,D_e,O_e,F_e,B_e,mD,Dj,xQt=Le((()=>{yE(),M_e=new Uint8Array([254,167,210,118,59,75,158,121]),D_e=new Uint8Array([215,170,15,109,48,97,52,78]),O_e=new Uint8Array([20,110,11,231,171,172,208,214]),F_e=new Uint8Array([95,178,173,1,12,185,225,246]),B_e=new Uint8Array([160,103,127,2,178,44,132,51]),mD=4096,Dj=8})),SQt=vs({decryptDocxIfNeeded:()=>IQt},1);function TQt(e){if(kj(e)!=="zip")throw new $o(ma.DECRYPTION_FAILED,"Decrypted output is not a valid ZIP archive — the file may be corrupt")}async function IQt(e,t){const n=e instanceof Uint8Array?e:new Uint8Array(e),r=kj(n);if(r==="zip")return{data:n,wasEncrypted:!1};if(r==="unknown")throw new $o(ma.DECRYPTION_FAILED,"Unrecognized file format — expected a .docx (ZIP) or encrypted .docx (OLE/CFB)");if(!t?.password)throw new $o(ma.PASSWORD_REQUIRED,"This document is password-protected. A password is required to open it.");const i=dQt(n),{params:o}=mQt(i.encryptionInfo),s=await AQt(t.password,o,i.encryptedPackage);return TQt(s),{data:s,wasEncrypted:!0}}var kQt=Le((()=>{x_e(),fQt(),gQt(),xQt(),yE()})),H_e=Kc(Mm(),1),Oj=new Set(["png","jpg","jpeg","gif","bmp","tiff","tif","emf","wmf","svg","webp"]),Fj={tif:"tiff",jpg:"jpeg",svg:"svg+xml"},EQt="application/vnd.openxmlformats-officedocument.customXmlProperties+xml",z_e={odttf:"application/vnd.openxmlformats-officedocument.obfuscatedFont",ttf:"application/x-font-ttf",otf:"application/vnd.ms-opentype"},CQt=class{constructor(e={}){this.debug=e.debug||!1,this.zip=new l_e.default,this.files=[],this.media={},this.mediaFiles={},this.fonts={},this.decryptedFileData=null}async#e(e,t){if(e instanceof Uint8Array||typeof Buffer<"u"&&Buffer.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,Math.min(t,e.byteLength));if(e instanceof ArrayBuffer)return new Uint8Array(e,0,Math.min(t,e.byteLength));if(typeof Blob<"u"&&e instanceof Blob)try{if(typeof e.arrayBuffer=="function"){const n=await e.arrayBuffer();return new Uint8Array(n,0,Math.min(t,n.byteLength))}}catch{}return new Uint8Array(0)}async getDocxData(e,t=!1,n={}){const{detectContainerType:r}=await Promise.resolve().then(()=>(x_e(),BZt)),i=r(await this.#e(e,8));let o=e;if(i==="cfb"){const{decryptDocxIfNeeded:l}=await Promise.resolve().then(()=>(kQt(),SQt)),c=await l(e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(await e.arrayBuffer()),{password:n.password});o=c.data,this.decryptedFileData=c.data}const s=await this.unzip(o),a=Object.entries(s.files);for(const[,l]of a){const c=l.name;if(c_e(c)){const u=d_e(await l.async("uint8array"));this.files.push({name:c,content:u})}else if(c.startsWith("word/media")&&c!=="word/media/"||l.name.startsWith("media")&&l.name!=="media/"||c.startsWith("media")&&c!=="media/"||c.startsWith("word/embeddings")&&c!=="word/embeddings/")if(t){const u=(await l.async("nodebuffer")).toString("base64");this.mediaFiles[c]=u}else{const u=await l.async("base64");let d=this.getFileExtension(c)?.toLowerCase(),f=null;if((!Oj.has(d)||d==="tmp")&&(f=q1(u),f&&(d=f)),Oj.has(d)){const h=Fj[d]||d;this.mediaFiles[c]=`data:image/${h};base64,${u}`;const p=await l.async("blob"),m=new File([p],c,{type:p.type}),g=URL.createObjectURL(m);this.media[c]=g}else this.mediaFiles[c]=u}else if(c.startsWith("word/fonts")&&c!=="word/fonts/"){const u=await l.async("uint8array");this.fonts[c]=u}}return this.files}getFileExtension(e){const t=e.split(".");return t.length<2?null:t[t.length-1]}async updateContentTypes(e,t,n,r={},i={}){const o=Object.keys(r||{}),s=Object.keys(t).map(k=>this.getFileExtension(k)).filter(k=>k&&Oj.has(k)),a=Object.entries(t).filter(([k])=>!this.getFileExtension(k)).map(([k,L])=>({name:k,contentType:this.#i(L)})).filter(k=>k.contentType),l="[Content_Types].xml";let c;n?Array.isArray(e.files)?c=e.files.find(k=>k.name===l)?.content||"":c=e.files?.[l]||"":c=await e.file(l).async("string");let u="";const d=QJe(c),f=new Set;for(let k of s){if(d.includes(k)||f.has(k))continue;const L=`<Default Extension="${k}" ContentType="image/${Fj[k]||k}"/>`;u+=L,f.add(k)}if(i){const k=new Set(Object.keys(i).map(L=>this.getFileExtension(L)).filter(L=>L&&z_e[L]));for(const L of k)d.includes(L)||f.has(L)||(u+=`<Default Extension="${L}" ContentType="${z_e[L]}"/>`,f.add(L))}const h=JSON.parse(H_e.xml2json(c,null,2)).elements?.find(k=>k.name==="Types")||{},p=k=>h.elements?.some(L=>L.name==="Override"&&L.attributes.PartName===k);for(const{name:k,contentType:L}of a){const _=`/${k}`;p(_)||(u+=`<Override PartName="${_}" ContentType="${L}" />`)}const m=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/comments.xml"),g=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/commentsExtended.xml"),y=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/commentsIds.xml"),v=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/commentsExtensible.xml"),b=k=>r&&Object.prototype.hasOwnProperty.call(r,k)?r[k]!==null:e?.files?n&&Array.isArray(e.files)?e.files.some(L=>L.name===k):!!e.files[k]:!1;b("word/comments.xml")&&(m||(u+='<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />')),b("word/commentsExtended.xml")&&(g||(u+='<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />')),b("word/commentsIds.xml")&&(y||(u+='<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />')),b("word/commentsExtensible.xml")&&(v||(u+='<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />'));const w=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/footnotes.xml"),x=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/endnotes.xml");b("word/footnotes.xml")&&(w||(u+='<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" />')),b("word/endnotes.xml")&&(x||(u+='<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" />'));for(const k of b_e)b(k.zipPath)&&!p(`/${k.zipPath}`)&&(u+=`<Override PartName="/${k.zipPath}" ContentType="${k.contentType}" />`);const A=new Set(o);e?.files&&(n&&Array.isArray(e.files)?e.files.forEach(k=>A.add(k.name)):Object.keys(e.files).forEach(k=>A.add(k))),A.forEach(k=>{if(!/^customXml\/itemProps\d+\.xml$/i.test(k)||!b(k))return;const L=`/${k}`;p(L)||(u+=`<Override PartName="${L}" ContentType="${EQt}" />`)}),A.forEach(k=>{if(k.includes(".rels")||!k.includes("header")&&!k.includes("footer"))return;const L=h.elements?.some(O=>O.name==="Override"&&O.attributes.PartName===`/${k}`),_=`<Override PartName="/${k}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${k.includes("header")?"header":"footer"}+xml"/>`;L||(u+=_)});const T=cV.map(k=>`/word/${k}`).filter(k=>!b(k.slice(1))),I="application/vnd.openxmlformats-officedocument.customXmlProperties+xml";if(h?.elements?.length)for(const k of h.elements){if(k?.name!=="Override"||k?.attributes?.ContentType!==I)continue;const L=k?.attributes?.PartName;typeof L!="string"||!L.startsWith("/")||b(L.slice(1))||T.push(L)}const P='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';let C=c.replace(P,`${P}${u}`);for(const k of T){const L=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),_=new RegExp(`\\s*<Override[^>]*PartName="${L}"[^>]*/>`,"g");C=C.replace(_,"")}let R=r["word/_rels/document.xml.rels"];if(R||(n?Array.isArray(e.files)?R=e.files.find(k=>k.name==="word/_rels/document.xml.rels")?.content:R=e.files?.["word/_rels/document.xml.rels"]:R=await e.file("word/_rels/document.xml.rels")?.async("string")),R)try{H_e.xml2js(R,{compact:!1}).elements?.find(k=>k.name==="Relationships")?.elements?.forEach(k=>{const L=k.attributes?.Type,_=k.attributes?.Target;if(!L||!_)return;const O=L.includes("/header"),F=L.includes("/footer");if(!O&&!F)return;let B=_.replace(/^\.\//,"");B.startsWith("../")&&(B=B.slice(3)),B.startsWith("/")&&(B=B.slice(1));const U=B.startsWith("word/")?B:`word/${B}`;A.add(U)})}catch(k){console.warn("Failed to parse document relationships while updating content types",k)}if(A.forEach(k=>{if(k.includes(".rels")||!k.includes("header")&&!k.includes("footer")||C.includes(`PartName="/${k}"`))return;const L=`<Override PartName="/${k}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${k.includes("header")?"header":"footer"}+xml"/>`;C=C.replace("</Types>",`${L}</Types>`)}),R){const k=FZt(R,b);k!==R&&(n?r["word/_rels/document.xml.rels"]=k:e.file("word/_rels/document.xml.rels",k))}if(n)return C;e.file(l,C)}async#t(e){const t={};e.forEach(s=>{t[s]=""});const n=e.file("[Content_Types].xml");n&&(t["[Content_Types].xml"]=await n.async("string"));const r=e.file("_rels/.rels");r&&(t["_rels/.rels"]=await r.async("string"));const{contentTypesXml:i,relsXml:o}=y_e({baseFiles:t,updatedDocs:{}});e.file("[Content_Types].xml",i),e.file("_rels/.rels",o)}async unzip(e){return await this.zip.loadAsync(e)}async updateZip({docx:e,updatedDocs:t,originalDocxFile:n,media:r,fonts:i,isHeadless:o,compression:s="DEFLATE"}){let a;n?a=await this.exportFromOriginalFile(n,t,r,i):a=await this.exportFromCollaborativeDocx(e,t,r,i);const l=o?"nodebuffer":"blob";return await a.generateAsync({type:l,mimeType:xc,compression:s,compressionOptions:s==="DEFLATE"?{level:6}:void 0})}async exportFromCollaborativeDocx(e,t,n,r){if(!Array.isArray(e))throw new Error("Collaborative DOCX export requires base package entries");const i=new l_e.default;for(const o of e){const s=o.content;i.file(o.name,s)}Object.keys(t).forEach(o=>{t[o]===null?i.remove(o):i.file(o,t[o])}),Object.keys(n).forEach(o=>{const s=n[o],a=typeof s=="string"?XT(s):s;i.file(o,a)});for(const[o,s]of Object.entries(r))i.file(o,s);return await this.updateContentTypes(i,n,!1,t,r),await this.#t(i),i}async exportFromOriginalFile(e,t,n,r){const i=await this.unzip(e),o=[];if(i.forEach((s,a)=>{const l=a.async("uint8array").then(c=>{i.file(a.name,c_e(a.name)?d_e(c):c)});o.push(l)}),await Promise.all(o),Object.keys(t).forEach(s=>{t[s]===null?i.remove(s):i.file(s,t[s])}),Object.keys(n).forEach(s=>{i.file(s,n[s])}),r)for(const[s,a]of Object.entries(r))i.file(s,a);return await this.updateContentTypes(i,n,!1,t,r),await this.#t(i),i}#i(e){if(e==null)return null;if(typeof e=="string"&&e.startsWith("data:image/"))return e.match(/^data:(image\/[a-zA-Z0-9.+-]+);/i)?.[1]?.toLowerCase()||null;let t=null;return e instanceof ArrayBuffer?t=q1(new Uint8Array(e)):ArrayBuffer.isView(e)?t=q1(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):typeof e=="string"&&(t=q1(e.startsWith("data:")?e.split(",",2)[1]:e)),t?`image/${Fj[t]||t}`:null}},Bj=CQt;const _Qt=(e,t)=>{const{doc:n}=e.state,r=n.nodeAt(t);if(r&&r.type.name==="image"){const i=e.state.tr.setSelection(mn.create(n,t));return e.dispatch(i),!0}return!1};function PQt(e,t="sans-serif"){const n=(r,i)=>{const o=document.createElement("canvas").getContext("2d");o.textBaseline="top";const s="abcdefghijklmnopqrstuvwxyz0123456789";o.font=`72px ${i}`;const a=o.measureText(s),l=a.width,c=a.actualBoundingBoxDescent;o.font=`72px "${r}", ${i}`;const u=o.measureText(s),d=u.width,f=u.actualBoundingBoxDescent;return d!==l||f!==c};return n(e,t)?!0:n(e,t==="sans-serif"?"serif":"sans-serif")}var TE=(...e)=>{};const RQt=e=>{const t=[];if(TE("ATTEMPTING MIGRATIONS"),!e.converter.numbering)return t;const{state:n}=e,{doc:r}=n,i=typeof e.view?.dispatch=="function"?e.view.dispatch.bind(e.view):e.dispatch.bind(e),o=["orderedList","bulletList"];let s=0;r.descendants((l,c)=>{if(!o.includes(l.type.name)||c<s)return;const u=gD(l,e,0);u.length>0&&t.push({from:c,to:c+l.nodeSize,listNode:l,replacement:u}),s=c+l.nodeSize});let a=n.tr;if(t.length>0)for(let l=t.length-1;l>=0;l--){const{from:c,to:u,replacement:d,listNode:f}=t[l],h=[];for(const p of d)if(p.node.type.name==="listItem"){const m=f.type.create(f.attrs,[p.node]);h.push(m)}else h.push(p.node);TE("NODES TO INSERT",h),a=a.replaceWith(c,u,h)}return a.setMeta("listsv2migration",t),e.options.migrated=!0,i(a),t};function gD(e,t,n=0,r=null){const i=[],o=["orderedList","bulletList"],s=e.type.name,a=LQt(e),l=NQt(e,t);if(TE("Needs migration?",a),!a)return l?i:MQt(e,t);let c=parseInt(e.attrs?.listId);TE("LIST ID",c,"SHARED NUM ID",r),(!c||Number.isNaN(c))&&(c=Gn.getNewListId(t)),(!Gn.getListDefinitionDetails({numId:c,level:n,editor:t})||!r&&!c)&&(c=Gn.getNewListId(t),TE("Genearted new list ID",c,"for list type",s),Gn.generateNewListDefinition({numId:c,listType:s,editor:t})),r||(r=c);for(const u of e.content.content)if(!u.content.content?.length)i.push({node:u,baseLevel:n});else if(u.content.content.length===1){const d=u.content.content[0];if(o.includes(d.type.name)){const f=gD(d,t,n+1,r);i.push(...f)}else{const f=Gn.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});i.push({node:f,baseLevel:n})}}else{const d=u.content.content[0];if(o.includes(d.type.name)){const f=gD(d,t,n+1,r);i.push(...f)}else if(d.type.name==="paragraph"||d.isTextblock){const f=Gn.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});i.push({node:f,baseLevel:n})}else i.push({node:d});for(let f of u.content.content.slice(1))if(o.includes(f.type.name)){const h=gD(f,t,n+1,r);i.push(...h)}else i.push({node:f})}return i}var LQt=e=>{const t=e.content;if(t?.content?.length>1)return!0;const n=t.firstChild;if(n&&n.type.name==="listItem"){const{attrs:r}=n,{level:i,listNumberingType:o}=r||{};return typeof i>"u"||!o?!0:(n?.content?.content).filter(s=>["bulletList","orderedList"].includes(s.type.name)).length>0}return!1},NQt=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:i,level:o}=r||{},{abstract:s}=Gn.getListDefinitionDetails({numId:i,level:o,listType:n,editor:t})||{};return!!s},MQt=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:i}=r||{};return Gn.generateNewListDefinition({numId:i,listType:n,editor:t})};const DQt=async(e=[],t)=>{const n=pu(t.state),r=[];if(!n.length)return e;for(const i of n){const o=i.node?.attrs?.type,s=e.find(l=>l.input_id===i.node.attrs.fieldId);if(s&&(!o||o!=="html")){r.push(s);continue}const a=s?.input_value;a&&await new Promise((l,c)=>{const u=document.createElement("div");t.createChildEditor({element:u,html:a,onCreate:({editor:d})=>{const{migrated:f}=d.options;f&&(s.input_value=d.getHTML(),r.push(s)),l()},onError:d=>{c(d)}})})}return r},OQt=(e,t={})=>e.options.isChildEditor?null:new qp({...e.options,pagination:!1,suppressDefaultDocxStyles:!0,ydoc:null,collaborationProvider:null,fileSource:null,initialState:null,documentId:null,isCommentsEnabled:!1,isNewFile:!1,fragment:!1,onCreate:()=>null,onListDefinitionsChange:FQt,...t,isChildEditor:!0,parentEditor:e});var FQt=e=>{const{editor:t,numbering:n}=e,{parentEditor:r={}}=t.options,{converter:i}=r;if(!i)return;i.numbering=n;const{tr:o}=r.state;o.setMeta("updatedListItemNodeViews",!0),r.dispatch(o)};function U_e(e,t=[]){const n="[SuperValidator]",r="color: teal; font-weight: bold;",i=[n,...t.map(a=>`[${a}]`)],o=i.map(()=>"%c%s").join(" "),s=i.map(a=>[r,a]).flat();return{debug:(...a)=>{e&&console.debug(o,...s,...a)},withPrefix:a=>U_e(e,[...t,a])}}function BQt(e,t,n,r){let i=!1;const o=[];return e.forEach(({node:s,pos:a})=>{const{rId:l,src:c}=s.attrs;if(!l&&c){const u=Ww(t,"image-rid:ensureValidImageRID",{target:c,type:"image"});u&&(r.debug("Assigned rId for image:",u,"at pos:",a),n.setNodeMarkup(a,void 0,{...s.attrs,rId:u}),o.push(`Added missing rId to image at pos ${a}`),i=!0)}}),{modified:i,results:o}}function HQt({editor:e,logger:t}){const n=(r,i)=>{const o=[BQt(i.image||[],e,r,t)];return{modified:o.some(s=>s.modified),results:o.flatMap(s=>s.results)}};return n.requiredElements={nodes:["image"]},n}function zQt(e,t,n,r){let i=!1;const o=[];return e.forEach(({mark:s,from:a,to:l})=>{const{rId:c,href:u,anchor:d}=s.attrs;if(!c&&u&&!d){const f=Ww(t,"link-rid:ensureValidLinkRID",{target:u,type:"hyperlink"});if(f){r.debug("Assigned rId for link:",f,"from pos:",a,"to pos:",l);const h=t.schema.marks.link,p=h.create({...s.attrs,rId:f});n.removeMark(a,l,h),n.addMark(a,l,p),o.push(`Added missing rId to link from pos ${a} to ${l}`),i=!0}}}),{modified:i,results:o}}function UQt({editor:e,logger:t}){const n=(r,i)=>{const o=[zQt(i.link||[],e,r,t)];return{modified:o.some(s=>s.modified),results:o.flatMap(s=>s.results)}};return n.requiredElements={marks:["link"]},n}const VQt={imageNodeValidator:HQt,linkMarkValidator:UQt};function WQt({editor:e,logger:t}){return()=>{const n=[];let r=!1;const i=e?.converter?.convertedXml,o="word/numbering.xml",s=i?.[o];if(!s||!s.elements?.length||!s.elements[0].elements?.length)return n.push(`${o} is not a valid xml`),{results:n,modified:r};const a=[];let l=s.elements[0];return V_e(l,a),a.length?(r=!0,n.push("Removed invalid <w:num> by numId:"+a.join(", ")),t?.debug?.(`Removed invalid <w:num> by numId: ${a.join(", ")}`)):n.push("No <w:num> entries with null/invalid numId found."),{results:n,modified:r}}}function V_e(e,t){if(!e||!Array.isArray(e.elements))return;const n=[];for(const r of e.elements){if(r?.type==="element"){if(r.name==="w:num"){const i=(r.attributes||{})["w:numId"],o=i==null?null:String(i).trim();if(o==null||o===""||/^null$/i.test(o)||!/^\d+$/.test(o)){t.push(o??"missing node");continue}}Array.isArray(r.elements)&&r.elements.length&&V_e(r,t)}n.push(r)}e.elements=n}function GQt({editor:e,logger:t}){return()=>{const n=[];let r=!1;const i=e?.converter?.convertedXml;if(!i||typeof i!="object")return{results:n,modified:r};const{relsKey:o,wasNormalized:s}=jQt(i,n);if(!o)return{results:n,modified:r};s&&(r=!0);const{root:a,wasFixed:l}=qQt(i[o],o,n);if(!a)return{results:n,modified:r};l&&(r=!0),YQt(a)&&(r=!0);const{filteredIds:c,binMediaTargets:u,wasProcessed:d}=KQt(a,i,n);d&&(r=!0),XQt(i,c,n,t)&&(r=!0);const f=i["[Content_Types].xml"];return u.size>0||f?JQt(i,u,n)&&(r=!0):n.push("[Content_Types].xml not found or not parseable. Skipped content types patch."),{results:n,modified:r}}}function jQt(e,t){const n=["word/_rels/document.xml.rels","word/document.xml.rels","_rels/document.xml.rels","document.xml.rels"].find(i=>e?.[i]?.elements);if(!n)return{relsKey:null,wasNormalized:!1};const r="word/_rels/document.xml.rels";return n!==r?(e[r]=e[n],delete e[n],t.push(`Normalized relationships location to ${r} (was ${n})`),{relsKey:r,wasNormalized:!0}):{relsKey:n,wasNormalized:!1}}function qQt(e,t,n){const r=e?.elements?.[0];if(!r||r.type!=="element")return n.push(`${t} is not a valid xml`),{root:null,wasFixed:!1};const i="http://schemas.openxmlformats.org/package/2006/relationships";let o=!1;return r.name!=="Relationships"&&(r.name="Relationships",n.push('Fixed relationships root element name to "Relationships"'),o=!0),r.attributes=r.attributes||{},r.attributes.xmlns!==i&&(r.attributes.xmlns=i,n.push(`Set relationships xmlns to ${i}`),o=!0),{root:r,wasFixed:o}}function YQt(e){const t=e.elements?.filter(n=>n?.type==="element"&&n.name==="Relationship")||[];return e.elements?.length!==t.length?(e.elements=t,!0):!1}function KQt(e,t,n){const r=new Set,i=new Set;let o=!1;const s=v=>{const b=/^rId(\d+)$/.exec(String(v||""));return b?parseInt(b[1],10):null},a=(v,b)=>typeof v=="string"&&new RegExp(`/relationships/${b}$`,"i").test(v),l=v=>a(v,"hyperlink"),c=v=>a(v,"image"),u=v=>/^https?:\/\//i.test(v||"")||/^mailto:/i.test(v||""),d=new Set;let f=0;for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes.Id,w=s(b);Number.isInteger(w)&&(f=Math.max(f,w)),typeof b=="string"&&b&&d.add(b)}let h=f;const p=v=>{if(v&&!d.has(v))return d.add(v),v;let b;do h+=1,b=`rId${h}`;while(d.has(b));return d.add(b),b},m=new Set,g=[];function y(v,b){return typeof v[b]=="string"?v[b].trim():""}for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes;let w=y(b,"Id");const x=y(b,"Type");let A=y(b,"Target"),T=y(b,"TargetMode");if(!A){n.push(`Removed relationship "${w}" without Target`),o=!0;continue}if(l(x)&&u(A)&&T.toLowerCase()!=="external"&&(b.TargetMode="External",T="External",n.push(`Set TargetMode="External" for hyperlink ${w}`),o=!0),c(x)){const I=ip(A,"word");I&&/^media\/.+\.bin$/i.test(A)&&I in t&&r.add(`/${I}`)}if(T.toLowerCase()!=="external"&&!u(A)&&!(ip(A,"word")in t))if(c(x))n.push(`Warning: image relationship ${w} target not found: ${A}.`);else{n.push(`Removed relationship ${w} with missing target: ${A}`),o=!0;continue}if(!w){const I=p(null);b.Id=I,n.push(`Assigned missing Id "${I}"`),o=!0,w=I}if(m.has(w)){n.push(`Removed duplicate relationship with ID "${w}"`),o=!0;continue}m.add(w),g.push(v)}(e.elements.length!==g.length||e.elements.some((v,b)=>v!==g[b]))&&(e.elements=g,o=!0);for(const v of e.elements){const b=v.attributes?.Id;typeof b=="string"&&b&&i.add(b)}return{filteredIds:i,binMediaTargets:r,wasProcessed:o}}function XQt(e,t,n,r){const i=e["word/document.xml"];if(i?.elements?.length){const o=i.elements[0];if(o?.type==="element"){const s=[];if(W_e(o,t,s),s.length)return n.push(`Fixed ${s.length} missing relationship references`),r?.debug?.(`Fixed ${s.length} missing relationship references in document`),!0}}return!1}function JQt(e,t,n){const r="[Content_Types].xml",i=e[r];return typeof i=="string"?ZQt(i,t,n,e,r):i?.elements?.length?QQt(i,t,n):!1}function ZQt(e,t,n,r,i){const o='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">',s=(c,u,d)=>new RegExp(`<Default\\s+Extension="${u}"\\b`,"i").test(c)?c:c.replace(o,`${o}<Default Extension="${u}" ContentType="${d}"/>`),a=(c,u,d)=>{const f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`<Override\\s+PartName="${f}"\\b`,"i").test(c)?c:c.replace(o,`${o}<Override PartName="${u}" ContentType="${d}" />`)};let l=e;l=s(l,"rels","application/vnd.openxmlformats-package.relationships+xml"),l=s(l,"xml","application/xml");for(const c of t)l=a(l,c,"image/png"),n.push(`Added Content Types Override for "${c}" as image/png`);return l!==e?(r[i]=l,!0):!1}function QQt(e,t,n){const r=e.elements.find(c=>c.name==="Types")||e.elements[0];r.elements=r.elements||[];const i=c=>r.elements.some(u=>u.name==="Default"&&u.attributes?.Extension===c),o=(c,u)=>{r.elements.unshift({type:"element",name:"Default",attributes:{Extension:c,ContentType:u}})},s=c=>r.elements.some(u=>u.name==="Override"&&u.attributes?.PartName===c),a=(c,u)=>{r.elements.unshift({type:"element",name:"Override",attributes:{PartName:c,ContentType:u}})};let l=!1;i("rels")||(o("rels","application/vnd.openxmlformats-package.relationships+xml"),l=!0),i("xml")||(o("xml","application/xml"),l=!0);for(const c of t)s(c)||(a(c,"image/png"),n.push(`Added Content Types Override for "${c}" as image/png`),l=!0);return l}function W_e(e,t,n){if(e?.elements?.length)for(const r of e.elements){if(r?.type!=="element")continue;const i=r.attributes?.["r:id"];typeof i=="string"&&!t.has(i)&&(delete r.attributes["r:id"],n.push(`Removed invalid r:id="${i}"`)),W_e(r,t,n)}}const $Qt={numberingValidator:WQt,relationshipsValidator:GQt};var G_e=class{#e;#t;#i;#n;#r;constructor(e){this.#e=e.editor,this.dryRun=e.dryRun||!1,this.debug=e.debug||!1,this.logger=U_e(this.debug);const{stateValidators:t,xmlValidators:n,nodeTypes:r,markTypes:i}=this.#o();this.#t=t,this.#i=n,this.#n=r,this.#r=i}#o(){const e=new Set,t=new Set,n=r=>Object.fromEntries(Object.entries(r).map(([i,o])=>{const s=this.logger.withPrefix(i),a=o({editor:this.#e,logger:s});return this.#l(a,e,t),[i,a]}));return{stateValidators:n(VQt),xmlValidators:n($Qt),nodeTypes:e,markTypes:t}}#l(e,t,n){e.requiredElements&&typeof e.requiredElements=="object"&&(e.requiredElements.nodes&&e.requiredElements.nodes.forEach(r=>{t.add(r)}),e.requiredElements.marks&&e.requiredElements.marks.forEach(r=>{n.add(r)}))}#c(){const{doc:e}=this.#e.state,t={};this.#n.forEach(r=>t[r]=[]),this.#r.forEach(r=>t[r]=[]);const n=(r,i)=>{this.#n.has(r.type.name)&&t[r.type.name].push({node:r,pos:i}),r.isText&&r.marks&&r.marks.forEach(o=>{this.#r.has(o.type.name)&&t[o.type.name].push({mark:o,node:r,pos:i,from:i,to:i+r.nodeSize})})};return e.descendants(n),t}validateActiveDocument(){const e=this.#e.state;if(!e)return{modified:!1,results:[]};const{tr:t}=e,n=this.#c();this.logger.debug("Document analysis:",n);let r=!1;const i=[];return Object.entries(this.#t).forEach(([o,s])=>{this.logger.debug(`🕵 Validating with ${o}...`);const{results:a,modified:l}=s(t,n);i.push({key:o,results:a}),r=r||l}),this.dryRun?this.logger.debug("DRY RUN: No changes applied to the document."):this.#u(t),this.logger.debug("Results:",i),{modified:r,results:i}}validateDocumentExport(){const e=this.#e.state;if(!e)return{modified:!1,results:[]};const{tr:t}=e;let n=!1;const r=[];return Object.entries(this.#i).forEach(([i,o])=>{this.logger.debug(`🕵 Validating export with ${i}...`);const{results:s,modified:a}=o();r.push({key:i,results:s}),n=n||a}),!this.dryRun&&n?this.#u(t):this.logger.debug("DRY RUN: No export changes applied to the document."),this.logger.debug("Export validation results:",r),{modified:n,results:r}}#u(e){if(typeof this.#e?.dispatch=="function"){this.#e.dispatch(e);return}this.#e?.view?.dispatch?.(e)}},yD=null;const QA=()=>{if(yD!==null)return yD;try{const e=typeof globalThis<"u"&&typeof globalThis.window<"u"&&typeof globalThis.document<"u"&&typeof globalThis.document.createElement=="function";return yD=e,e}catch{return yD=!1,!1}};var e$t="1.34.0-next.6",t$t=["group","content","marks","inline","atom","defining","code","tableRole","summary"],n$t=["group","inclusive","excludes","spanning","code"];function j_e(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>{const r=n?.default;return[t,{default:r??null,required:r===void 0}]})):{}}function q_e(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]).filter(([,n])=>n!==void 0))}function r$t(e,t){if(!e||typeof e!="object")throw new Error("Invalid schema: schema must be a valid ProseMirror Schema object.");const n=t||"current",r=[];e.spec.nodes.forEach((o,s)=>{r.push({name:o,attrs:j_e(s.attrs),...q_e(s,t$t)})});const i=[];return e.spec.marks.forEach((o,s)=>{i.push({name:o,attrs:j_e(s.attrs),...q_e(s,n$t)})}),{version:e$t,schemaVersion:n,topNode:e.topNodeType?.name,nodes:r,marks:i}}const i$t=e=>{const t=document.createElement("div");t.innerHTML=e;const n=[],r=[],i=o=>{for(;r.length&&r[r.length-1].level>=o;){const s=r.pop();r.length?r[r.length-1].el.appendChild(s.el):n.push(s.el.outerHTML)}};return Array.from(t.childNodes).forEach(o=>{if(o.nodeType!==Node.ELEMENT_NODE){n.push(o.outerHTML||o.textContent);return}if(o.tagName.toLowerCase()==="ol"||o.tagName.toLowerCase()==="ul"){const s=s$t(o),a=a$t(s),l=s.getAttribute("data-num-fmt"),c=s.getAttribute("data-lvl-text"),u=o.tagName.toLowerCase(),d=s.cloneNode(!0);if(d.setAttribute("aria-level",a+1),d.style.setProperty("list-style-type",o$t(l,c)),!r.length||r[r.length-1].level<a){const f=document.createElement(u);r.push({tag:u,level:a,el:f})}else if(r[r.length-1].level>a)i(a+1);else if(r[r.length-1].tag!==u){i(a);const f=document.createElement(u);r.push({tag:u,level:a,el:f})}r[r.length-1].el.appendChild(d)}else i(0),n.push(o.outerHTML)}),i(0),n.join("")},o$t=(e,t)=>{const n=new Map([["●","disc"],["◦","circle"],["▪","square"]]);if(e==="bullet")return n.get(t)||"disc";const r=new Map([["decimal","decimal"],["lowerLetter","lower-alpha"],["upperLetter","upper-alpha"],["lowerRoman","lower-roman"],["upperRoman","upper-roman"]]);return t.startsWith("0")?"decimal-leading-zero":r.get(e)};function s$t(e){return Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE)||null}const a$t=e=>{const t=e.getAttribute("data-level");return t?parseInt(t,10):0};var l$t=/^Heading[1-9]$/i;function c$t(e,t){const n=e.content.firstChild;if(!n||n.type.name==="paragraph")return e;const r=t.selection.$from,i=t.selection.$to;if(!r||!i)return e;let o=null,s=-1;for(let d=r.depth;d>=0;d--){const f=r.node(d);if(f?.type?.name==="paragraph"){i.depth>=d&&i.node(d)===f&&(o=f,s=d);break}}if(!o)return e;const a=r.parentOffset,l=i.parentOffset;if(a!==0||l!==o.content.size||r.depth!==s||i.depth!==s)return e;const c=o.attrs?.paragraphProperties?.styleId;if(typeof c!="string"||!l$t.test(c))return e;const u=o.type.create(o.attrs,e.content,o.marks);return new Ht(_t.from(u),0,0)}var u$t=1,d$t=10,f$t=150,h$t=1.2,p$t=1,m$t=[".list-marker",".sd-editor-tab",".ProseMirror-trailingBreak"].join(", "),g$t="span.sd-paragraph-content",Y_e="p, div, h1, h2, h3, h4, h5, h6, blockquote, table",y$t='<meta name="Generator" content="Microsoft Word">',b$t=new Map([["decimal","decimal"],["lowerLetter","alpha-lower"],["upperLetter","alpha-upper"],["lowerRoman","roman-lower"],["upperRoman","roman-upper"],["bullet","bullet"]]);function K_e(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE){const r=n;if(r.matches(Y_e))return r}n=n.parentNode}return null}function v$t(e){const t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),!!t.querySelector(Y_e)}function w$t(e){const t=[],n=globalThis.getComputedStyle?.(e),r=e.style.color||(n?.color&&n.color!=="rgb(0, 0, 0)"?n.color:""),i=e.style.fontFamily||"",o=e.style.fontSize||(n?.fontSize&&n.fontSize!=="16px"?n.fontSize:""),s=e.style.textTransform||(n?.textTransform&&n.textTransform!=="none"?n.textTransform:""),a=e.style.fontWeight||(n?.fontWeight&&n.fontWeight!=="400"?n.fontWeight:"");return r&&t.push(`color: ${r}`),i&&t.push(`font-family: ${i}`),o&&t.push(`font-size: ${o}`),s&&t.push(`text-transform: ${s}`),a&&t.push(`font-weight: ${a}`),t.join("; ")}function A$t(e,t){const n=e.cloneContents();if(v$t(n))return n;const r=K_e(e.startContainer,t.dom),i=K_e(e.endContainer,t.dom);if(!r||r!==i)return n;const o=r.cloneNode(!1),s=w$t(r);if(s){const l=document.createElement("span");l.setAttribute("style",s),l.appendChild(n),o.appendChild(l)}else o.appendChild(n);const a=document.createDocumentFragment();return a.appendChild(o),a}function x$t(e,t){let n;try{n=e.posAtDOM(t,0)}catch{return null}const{doc:r}=e.state;if(n<0||n>r.content.size)return null;const i=r.resolve(n);for(let o=i.depth;o>0;o-=1){const s=i.node(o);if(s.type.name==="paragraph")return s}return null}function S$t(e){e.querySelectorAll("p[data-num-id], p[data-list-numbering-type]").forEach(t=>{const n=t.getAttribute("data-list-numbering-type"),r=t.getAttribute("data-marker-type");n&&!t.hasAttribute("data-num-fmt")&&t.setAttribute("data-num-fmt",n),r&&!t.hasAttribute("data-lvl-text")&&t.setAttribute("data-lvl-text",r)})}function T$t(e,t){const n=Array.from(e.querySelectorAll("[data-sd-block-id]"));n.length!==0&&n.forEach(r=>{const i=r.getAttribute("data-sd-block-id");if(!i)return;const o=t.dom.querySelector(`[data-sd-block-id="${globalThis.CSS?.escape?.(i)??i}"]`);if(!o)return;const s=x$t(t,o),a=s?.attrs?.paragraphProperties?.sectPr;if(!a||typeof a!="object")return;r.setAttribute("data-sd-sect-pr",JSON.stringify(a));const l=s?.attrs?.pageBreakSource;typeof l=="string"&&l.length>0&&r.setAttribute("data-sd-page-break-source",l)})}function I$t(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.map(n=>Number(n)).filter(n=>Number.isFinite(n)):[]}catch{return[]}}function k$t(e,t,n,r){if(t==="bullet")return n||r||"•";if(r?.includes("%"))return r;const i=n.match(/[.)]$/)?.[0]||".";return`%${e+1}${i}`}function E$t(e){const t=document.createDocumentFragment();t.appendChild(document.createComment("[if !supportLists]"));const n=document.createElement("span");return n.textContent=e,t.appendChild(n),t.appendChild(document.createComment("[endif]")),t}function C$t(e){if(Array.from(e.querySelectorAll("p[data-num-id], p[data-list-numbering-type]")).length===0)return null;const t=e.cloneNode(!0),n=[".MsoNormal {}",".MsoListParagraph {}"],r=new Set;return t.querySelectorAll("p[data-num-id], p[data-list-numbering-type]").forEach(i=>{const o=Number.parseInt(i.getAttribute("data-level")||"0",10)||0,s=o+1,a=i.getAttribute("data-num-id")||"1",l=a,c=i.getAttribute("data-num-fmt")||i.getAttribute("data-list-numbering-type")||"decimal",u=b$t.get(c)||"decimal",d=i.getAttribute("data-marker-type")||i.getAttribute("data-lvl-text")||"1.",f=k$t(o,c,d,i.getAttribute("data-lvl-text")),h=`${l}:${s}:${a}`,p=i.getAttribute("style"),m=`mso-list:l${l} level${s} lfo${a}`;i.setAttribute("class","MsoListParagraph"),i.setAttribute("style",p?`${m};${p}`:m),r.has(h)||(n.push(`@list l${l}:level${s} lfo${a} { mso-level-number-format: ${u}; mso-level-text: "${f}"; }`),r.add(h));const g=I$t(i.getAttribute("data-list-level")),y=g[o]??g[g.length-1]??1,v=c==="bullet"?d:`${d}`.trim()||`${y}.`;i.prepend(E$t(v))}),`${y$t}<style>${n.join(`
|
|
389
|
+
\0`,he+=o(Z,2),he+=A.magic,he+=o(b,2),he+=o(w,2),he+=o(z.crc32,4),he+=o(z.compressedSize,4),he+=o(z.uncompressedSize,4),he+=o(I.length,2),he+=o(O.length,2),{fileRecord:d.LOCAL_FILE_HEADER+he+I+O,dirRecord:d.CENTRAL_FILE_HEADER+o(W,2)+he+o(R.length,2)+"\0\0\0\0"+o(Q,4)+o(g,4)+I+O+R}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function f(h,p,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(h){var p=h.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:m?(p+100*(m-g-1))/m:100}}))},f.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var p=this.streamFiles&&!h.file.dir;if(p){var m=s(h,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(h){this.accumulate=!1;var p=this.streamFiles&&!h.file.dir,m=s(h,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),p)this.push({data:(function(g){return d.DATA_DESCRIPTOR+o(g.crc32,4)+o(g.compressedSize,4)+o(g.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var h=this.bytesWritten,p=0;p<this.dirRecords.length;p++)this.push({data:this.dirRecords[p],meta:{percent:100}});var m=this.bytesWritten-h,g=(function(y,v,b,w,x){var A=a.transformTo("string",x(w));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(y,2)+o(y,2)+o(v,4)+o(b,4)+o(A.length,2)+A})(this.dirRecords.length,m,h,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(h){this._sources.push(h);var p=this;return h.on("data",function(m){p.processChunk(m)}),h.on("end",function(){p.closedSource(p.previous.streamInfo),p._sources.length?p.prepareNextSource():p.end()}),h.on("error",function(m){p.error(m)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(h){var p=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var m=0;m<p.length;m++)try{p[m].error(h)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,p=0;p<h.length;p++)h[p].lock()},r.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){"use strict";var o=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(a,l,c){var u=new s(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{a.forEach(function(f,h){d++;var p=(function(v,b){var w=v||b,x=o[w];if(!x)throw new Error(w+" is not a valid compression method !");return x})(h.options.compression,l.compression),m=h.options.compressionOptions||l.compressionOptions||{},g=h.dir,y=h.date;h._compressWorker(p,m).withStreamInfo("file",{name:f,dir:g,date:y,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(u)}),u.entriesCount=d}catch(f){u.error(f)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){"use strict";function o(){if(!(this instanceof o))return new o;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new o;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(o.prototype=n("./object")).loadAsync=n("./load"),o.support=n("./support"),o.defaults=n("./defaults"),o.version="3.10.1",o.loadAsync=function(s,a){return new o().loadAsync(s,a)},o.external=n("./external"),r.exports=o},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){"use strict";var o=n("./utils"),s=n("./external"),a=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),u=n("./nodejsUtils");function d(f){return new s.Promise(function(h,p){var m=f.decompressed.getContentWorker().pipe(new c);m.on("error",function(g){p(g)}).on("end",function(){m.streamInfo.crc32!==f.decompressed.crc32?p(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}r.exports=function(f,h){var p=this;return h=o.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),u.isNode&&u.isStream(f)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):o.prepareContent("the loaded zip file",f,!0,h.optimizedBinaryString,h.base64).then(function(m){var g=new l(h);return g.load(m),g}).then(function(m){var g=[s.Promise.resolve(m)],y=m.files;if(h.checkCRC32)for(var v=0;v<y.length;v++)g.push(d(y[v]));return s.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,v=0;v<y.length;v++){var b=y[v],w=b.fileNameStr,x=o.resolve(b.fileNameStr);p.file(x,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:h.createFolders}),b.dir||(p.file(x).unsafeOriginalName=w)}return g.zipComment.length&&(p.comment=g.zipComment),p})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){"use strict";var o=n("../utils"),s=n("../stream/GenericWorker");function a(l,c){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}o.inherits(a,s),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){"use strict";var o=n("readable-stream").Readable;function s(a,l,c){o.call(this,l),this._helper=a;var u=this;a.on("data",function(d,f){u.push(d)||u._helper.pause(),c&&c(f)}).on("error",function(d){u.emit("error",d)}).on("end",function(){u.push(null)})}n("../utils").inherits(s,o),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){"use strict";r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(o,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(o,s);if(typeof o=="number")throw new Error('The "data" argument must not be a number');return new Buffer(o,s)},allocBuffer:function(o){if(Buffer.alloc)return Buffer.alloc(o);var s=new Buffer(o);return s.fill(0),s},isBuffer:function(o){return Buffer.isBuffer(o)},isStream:function(o){return o&&typeof o.on=="function"&&typeof o.pause=="function"&&typeof o.resume=="function"}}},{}],15:[function(n,r,i){"use strict";function o(w,x,A){var T,I=a.getTypeOf(x),P=a.extend(A||{},u);P.date=P.date||new Date,P.compression!==null&&(P.compression=P.compression.toUpperCase()),typeof P.unixPermissions=="string"&&(P.unixPermissions=parseInt(P.unixPermissions,8)),P.unixPermissions&&16384&P.unixPermissions&&(P.dir=!0),P.dosPermissions&&16&P.dosPermissions&&(P.dir=!0),P.dir&&(w=y(w)),P.createFolders&&(T=g(w))&&v.call(this,T,!0);var C=I==="string"&&P.binary===!1&&P.base64===!1;A&&A.binary!==void 0||(P.binary=!C),(x instanceof d&&x.uncompressedSize===0||P.dir||!x||x.length===0)&&(P.base64=!1,P.binary=!0,x="",P.compression="STORE",I="string");var R=null;R=x instanceof d||x instanceof l?x:p.isNode&&p.isStream(x)?new m(w,x):a.prepareContent(w,x,P.binary,P.optimizedBinaryString,P.base64);var k=new f(w,R,P);this.files[w]=k}var s=n("./utf8"),a=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),u=n("./defaults"),d=n("./compressedObject"),f=n("./zipObject"),h=n("./generate"),p=n("./nodejsUtils"),m=n("./nodejs/NodejsStreamInputAdapter"),g=function(w){w.slice(-1)==="/"&&(w=w.substring(0,w.length-1));var x=w.lastIndexOf("/");return 0<x?w.substring(0,x):""},y=function(w){return w.slice(-1)!=="/"&&(w+="/"),w},v=function(w,x){return x=x!==void 0?x:u.createFolders,w=y(w),this.files[w]||o.call(this,w,null,{dir:!0,createFolders:x}),this.files[w]};function b(w){return Object.prototype.toString.call(w)==="[object RegExp]"}r.exports={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(w){var x,A,T;for(x in this.files)T=this.files[x],(A=x.slice(this.root.length,x.length))&&x.slice(0,this.root.length)===this.root&&w(A,T)},filter:function(w){var x=[];return this.forEach(function(A,T){w(A,T)&&x.push(T)}),x},file:function(w,x,A){if(arguments.length!==1)return w=this.root+w,o.call(this,w,x,A),this;if(b(w)){var T=w;return this.filter(function(P,C){return!C.dir&&T.test(P)})}var I=this.files[this.root+w];return I&&!I.dir?I:null},folder:function(w){if(!w)return this;if(b(w))return this.filter(function(I,P){return P.dir&&w.test(I)});var x=this.root+w,A=v.call(this,x),T=this.clone();return T.root=A.name,T},remove:function(w){w=this.root+w;var x=this.files[w];if(x||(w.slice(-1)!=="/"&&(w+="/"),x=this.files[w]),x&&!x.dir)delete this.files[w];else for(var A=this.filter(function(I,P){return P.name.slice(0,w.length)===w}),T=0;T<A.length;T++)delete this.files[A[T].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(w){var x,A={};try{if((A=a.extend(w||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),A.type==="binarystring"&&(A.type="string"),!A.type)throw new Error("No output type specified.");a.checkSupport(A.type),A.platform!=="darwin"&&A.platform!=="freebsd"&&A.platform!=="linux"&&A.platform!=="sunos"||(A.platform="UNIX"),A.platform==="win32"&&(A.platform="DOS");var T=A.comment||this.comment||"";x=h.generateWorker(this,A,T)}catch(I){(x=new l("error")).error(I)}return new c(x,A.type||"string",A.mimeType)},generateAsync:function(w,x){return this.generateInternalStream(w).accumulate(x)},generateNodeStream:function(w,x){return(w=w||{}).type||(w.type="nodebuffer"),this.generateInternalStream(w).toNodejsStream(x)}}},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){"use strict";r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){"use strict";var o=n("./DataReader");function s(a){o.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}n("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),d=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===c&&this.data[f+2]===u&&this.data[f+3]===d)return f-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),d=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&c===f[1]&&u===f[2]&&d===f[3]},s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){"use strict";var o=n("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return o.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){"use strict";var o=n("./Uint8ArrayReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){"use strict";var o=n("./DataReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){"use strict";var o=n("./ArrayReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){"use strict";var o=n("../utils"),s=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var f=o.getTypeOf(d);return o.checkSupport(f),f!=="string"||s.uint8array?f==="nodebuffer"?new c(d):s.uint8array?new u(o.transformTo("uint8array",d)):new a(o.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){"use strict";i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){"use strict";var o=n("./GenericWorker"),s=n("../utils");function a(l){o.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(a,o),a.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){"use strict";var o=n("./GenericWorker"),s=n("../crc32");function a(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,o),a.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}o.inherits(a,s),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}s.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=o.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}o.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){"use strict";function o(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(l){a.processChunk(l)}),s.on("end",function(){a.end()}),s.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=o},{}],29:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),d=null;if(c.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(p,m){return new u.Promise(function(g,y){var v=[],b=p._internalType,w=p._outputType,x=p._mimeType;p.on("data",function(A,T){v.push(A),m&&m(T)}).on("error",function(A){v=[],y(A)}).on("end",function(){try{g((function(A,T,I){switch(A){case"blob":return o.newBlob(o.transformTo("arraybuffer",T),I);case"base64":return l.encode(T);default:return o.transformTo(A,T)}})(w,(function(A,T){var I,P=0,C=null,R=0;for(I=0;I<T.length;I++)R+=T[I].length;switch(A){case"string":return T.join("");case"array":return Array.prototype.concat.apply([],T);case"uint8array":for(C=new Uint8Array(R),I=0;I<T.length;I++)C.set(T[I],P),P+=T[I].length;return C;case"nodebuffer":return Buffer.concat(T);default:throw new Error("concat : unsupported type '"+A+"'")}})(b,v),x))}catch(A){y(A)}v=[]}).resume()})}function h(p,m,g){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=g,o.checkSupport(y),this._worker=p.pipe(new s(y)),p.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}h.prototype={accumulate:function(p){return f(this,p)},on:function(p,m){var g=this;return p==="data"?this._worker.on(p,function(y){m.call(g,y.data,y.meta)}):this._worker.on(p,function(){o.delay(m,arguments,g)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(p){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},p)}},r.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){"use strict";if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var o=new ArrayBuffer(0);try{i.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(o),i.blob=s.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){"use strict";for(var o=n("./utils"),s=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}i.utf8encode=function(h){return s.nodebuffer?a.newBufferFrom(h,"utf-8"):(function(p){var m,g,y,v,b,w=p.length,x=0;for(v=0;v<w;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),x+=g<128?1:g<2048?2:g<65536?3:4;for(m=s.uint8array?new Uint8Array(x):new Array(x),v=b=0;b<x;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m})(h)},i.utf8decode=function(h){return s.nodebuffer?o.transformTo("nodebuffer",h).toString("utf-8"):(function(p){var m,g,y,v,b=p.length,w=new Array(2*b);for(m=g=0;m<b;)if((y=p[m++])<128)w[g++]=y;else if(4<(v=c[y]))w[g++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<b;)y=y<<6|63&p[m++],v--;1<v?w[g++]=65533:y<65536?w[g++]=y:(y-=65536,w[g++]=55296|y>>10&1023,w[g++]=56320|1023&y)}return w.length!==g&&(w.subarray?w=w.subarray(0,g):w.length=g),o.applyFromCharCode(w)})(h=o.transformTo(s.uint8array?"uint8array":"array",h))},o.inherits(d,l),d.prototype.processChunk=function(h){var p=o.transformTo(s.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var m=p;(p=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),p.set(m,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var g=(function(v,b){var w;for((b=b||v.length)>v.length&&(b=v.length),w=b-1;0<=w&&(192&v[w])==128;)w--;return w<0||w===0?b:w+c[v[w]]>b?w:b})(p),y=p;g!==p.length&&(s.uint8array?(y=p.subarray(0,g),this.leftOver=p.subarray(g,p.length)):(y=p.slice(0,g),this.leftOver=p.slice(g,p.length))),this.push({data:i.utf8decode(y),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,o.inherits(f,l),f.prototype.processChunk=function(h){this.push({data:i.utf8encode(h.data),meta:h.meta})},i.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){"use strict";var o=n("./support"),s=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function c(m){return m}function u(m,g){for(var y=0;y<m.length;++y)g[y]=255&m.charCodeAt(y);return g}n("setimmediate"),i.newBlob=function(m,g){i.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(m,g,y){var v=[],b=0,w=m.length;if(w<=y)return String.fromCharCode.apply(null,m);for(;b<w;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,m.slice(b,Math.min(b+y,w)))):v.push(String.fromCharCode.apply(null,m.subarray(b,Math.min(b+y,w)))),b+=y;return v.join("")},stringifyByChar:function(m){for(var g="",y=0;y<m.length;y++)g+=String.fromCharCode(m[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return o.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return o.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function f(m){var g=65536,y=i.getTypeOf(m),v=!0;if(y==="uint8array"?v=d.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return d.stringifyByChunk(m,y,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(m)}function h(m,g){for(var y=0;y<m.length;y++)g[y]=m[y];return g}i.applyFromCharCode=f;var p={};p.string={string:c,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return p.string.uint8array(m).buffer},uint8array:function(m){return u(m,new Uint8Array(m.length))},nodebuffer:function(m){return u(m,a.allocBuffer(m.length))}},p.array={string:f,array:c,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},p.arraybuffer={string:function(m){return f(new Uint8Array(m))},array:function(m){return h(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:c,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},p.uint8array={string:f,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:c,nodebuffer:function(m){return a.newBufferFrom(m)}},p.nodebuffer={string:f,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return p.nodebuffer.uint8array(m).buffer},uint8array:function(m){return h(m,new Uint8Array(m.length))},nodebuffer:c},i.transformTo=function(m,g){return g=g||"",m?(i.checkSupport(m),p[i.getTypeOf(g)][m](g)):g},i.resolve=function(m){for(var g=m.split("/"),y=[],v=0;v<g.length;v++){var b=g[v];b==="."||b===""&&v!==0&&v!==g.length-1||(b===".."?y.pop():y.push(b))}return y.join("/")},i.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":o.nodebuffer&&a.isBuffer(m)?"nodebuffer":o.uint8array&&m instanceof Uint8Array?"uint8array":o.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(m){if(!o[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(m){var g,y,v="";for(y=0;y<(m||"").length;y++)v+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return v},i.delay=function(m,g,y){setImmediate(function(){m.apply(y||null,g||[])})},i.inherits=function(m,g){function y(){}y.prototype=g.prototype,m.prototype=new y},i.extend=function(){var m,g,y={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&y[g]===void 0&&(y[g]=arguments[m][g]);return y},i.prepareContent=function(m,g,y,v,b){return l.Promise.resolve(g).then(function(w){return o.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)&&typeof FileReader<"u"?new l.Promise(function(x,A){var T=new FileReader;T.onload=function(I){x(I.target.result)},T.onerror=function(I){A(I.target.error)},T.readAsArrayBuffer(w)}):w}).then(function(w){var x=i.getTypeOf(w);return x?(x==="arraybuffer"?w=i.transformTo("uint8array",w):x==="string"&&(b?w=s.decode(w):y&&v!==!0&&(w=(function(A){return u(A,o.uint8array?new Uint8Array(A.length):new Array(A.length))})(w))),w):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){"use strict";var o=n("./reader/readerFor"),s=n("./utils"),a=n("./signature"),l=n("./zipEntry"),c=n("./support");function u(d){this.files=[],this.loadOptions=d}u.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(f)+", expected "+s.pretty(d)+")")}},isSignature:function(d,f){var h=this.reader.index;this.reader.setIndex(d);var p=this.reader.readString(4)===f;return this.reader.setIndex(h),p},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),f=c.uint8array?"uint8array":"array",h=s.transformTo(f,d);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,f,h,p=this.zip64EndOfCentralSize-44;0<p;)d=this.reader.readInt(2),f=this.reader.readInt(4),h=this.reader.readData(f),this.zip64ExtensibleData[d]={id:d,length:f,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,f;for(d=0;d<this.files.length;d++)f=this.files[d],this.reader.setIndex(f.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var f=d;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var p=f-h;if(0<p)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=p);else if(p<0)throw new Error("Corrupted zip: missing "+Math.abs(p)+" bytes.")},prepareReader:function(d){this.reader=o(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){"use strict";var o=n("./reader/readerFor"),s=n("./utils"),a=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),u=n("./compressions"),d=n("./support");function f(h,p){this.options=h,this.loadOptions=p}f.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var p,m;if(h.skip(22),this.fileNameLength=h.readInt(2),m=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((p=(function(g){for(var y in u)if(Object.prototype.hasOwnProperty.call(u,y)&&u[y].magic===g)return u[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,p,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var p=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(p),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=o(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var p,m,g,y=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<y;)p=h.readInt(2),m=h.readInt(2),g=h.readData(m),this.extraFields[p]={id:p,length:m,value:g};h.setIndex(y)},handleUTF8:function(){var h=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var p=this.findExtraFieldUnicodePath();if(p!==null)this.fileNameStr=p;else{var m=s.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=s.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var p=o(h.value);return p.readInt(1)!==1||l(this.fileName)!==p.readInt(4)?null:c.utf8decode(p.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var p=o(h.value);return p.readInt(1)!==1||l(this.fileComment)!==p.readInt(4)?null:c.utf8decode(p.readData(h.length-5))}return null}},r.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){"use strict";function o(p,m,g){this.name=p,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var s=n("./stream/StreamHelper"),a=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),u=n("./stream/GenericWorker");o.prototype={internalStream:function(p){var m=null,g="string";try{if(!p)throw new Error("No output type specified.");var y=(g=p.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!v&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(b){(m=new u("error")).error(b)}return new s(m,g,"")},async:function(p,m){return this.internalStream(p).accumulate(m)},nodeStream:function(p,m){return this.internalStream(p||"nodebuffer").toNodejsStream(m)},_compressWorker:function(p,m){if(this._data instanceof c&&this._data.compression.magic===p.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,p,m)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new a(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<d.length;h++)o.prototype[d[h]]=f;r.exports=o},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(o){"use strict";var s,a,l=o.MutationObserver||o.WebKitMutationObserver;if(l){var c=0,u=new l(p),d=o.document.createTextNode("");u.observe(d,{characterData:!0}),s=function(){d.data=c=++c%2}}else if(o.setImmediate||o.MessageChannel===void 0)s="document"in o&&"onreadystatechange"in o.document.createElement("script")?function(){var m=o.document.createElement("script");m.onreadystatechange=function(){p(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},o.document.documentElement.appendChild(m)}:function(){setTimeout(p,0)};else{var f=new o.MessageChannel;f.port1.onmessage=p,s=function(){f.port2.postMessage(0)}}var h=[];function p(){var m,g;a=!0;for(var y=h.length;y;){for(g=h,h=[],m=-1;++m<y;)g[m]();y=h.length}a=!1}r.exports=function(m){h.push(m)!==1||a||s()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){"use strict";var o=n("immediate");function s(){}var a={},l=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function d(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,y!==s&&m(this,y)}function f(y,v,b){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function h(y,v,b){o(function(){var w;try{w=v(b)}catch(x){return a.reject(y,x)}w===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,w)})}function p(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function m(y,v){var b=!1;function w(T){b||(b=!0,a.reject(y,T))}function x(T){b||(b=!0,a.resolve(y,T))}var A=g(function(){v(x,w)});A.status==="error"&&w(A.value)}function g(y,v){var b={};try{b.value=y(v),b.status="success"}catch(w){b.status="error",b.value=w}return b}(r.exports=d).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(y()).then(function(){return b})},function(b){return v.resolve(y()).then(function(){throw b})})},d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,v){if(typeof y!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var b=new this.constructor(s);return this.state!==u?h(b,this.state===c?y:v,this.outcome):this.queue.push(new f(b,y,v)),b},f.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},f.prototype.otherCallFulfilled=function(y){h(this.promise,this.onFulfilled,y)},f.prototype.callRejected=function(y){a.reject(this.promise,y)},f.prototype.otherCallRejected=function(y){h(this.promise,this.onRejected,y)},a.resolve=function(y,v){var b=g(p,v);if(b.status==="error")return a.reject(y,b.value);var w=b.value;if(w)m(y,w);else{y.state=c,y.outcome=v;for(var x=-1,A=y.queue.length;++x<A;)y.queue[x].callFulfilled(v)}return y},a.reject=function(y,v){y.state=l,y.outcome=v;for(var b=-1,w=y.queue.length;++b<w;)y.queue[b].callRejected(v);return y},d.resolve=function(y){return y instanceof this?y:a.resolve(new this(s),y)},d.reject=function(y){var v=new this(s);return a.reject(v,y)},d.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var x=new Array(b),A=0,T=-1,I=new this(s);++T<b;)P(y[T],T);return I;function P(C,R){v.resolve(C).then(function(k){x[R]=k,++A!==b||w||(w=!0,a.resolve(I,x))},function(k){w||(w=!0,a.reject(I,k))})}},d.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var x=-1,A=new this(s);++x<b;)T=y[x],v.resolve(T).then(function(I){w||(w=!0,a.resolve(A,I))},function(I){w||(w=!0,a.reject(A,I))});var T;return A}},{immediate:36}],38:[function(n,r,i){"use strict";var o={};(0,n("./lib/utils/common").assign)(o,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=o},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){"use strict";var o=n("./zlib/deflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),u=Object.prototype.toString,d=0,f=-1,h=0,p=8;function m(y){if(!(this instanceof m))return new m(y);this.options=s.assign({level:f,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var b=o.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(b!==d)throw new Error(l[b]);if(v.header&&o.deflateSetHeader(this.strm,v.header),v.dictionary){var w;if(w=typeof v.dictionary=="string"?a.string2buf(v.dictionary):u.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(b=o.deflateSetDictionary(this.strm,w))!==d)throw new Error(l[b]);this._dict_set=!0}}function g(y,v){var b=new m(v);if(b.push(y,!0),b.err)throw b.msg||l[b.err];return b.result}m.prototype.push=function(y,v){var b,w,x=this.strm,A=this.options.chunkSize;if(this.ended)return!1;w=v===~~v?v:v===!0?4:0,typeof y=="string"?x.input=a.string2buf(y):u.call(y)==="[object ArrayBuffer]"?x.input=new Uint8Array(y):x.input=y,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new s.Buf8(A),x.next_out=0,x.avail_out=A),(b=o.deflate(x,w))!==1&&b!==d)return this.onEnd(b),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(x.output,x.next_out))):this.onData(s.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&b!==1);return w===4?(b=o.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===d):w!==2||(this.onEnd(d),!(x.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=m,i.deflate=g,i.deflateRaw=function(y,v){return(v=v||{}).raw=!0,g(y,v)},i.gzip=function(y,v){return(v=v||{}).gzip=!0,g(y,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){"use strict";var o=n("./zlib/inflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=n("./zlib/gzheader"),f=Object.prototype.toString;function h(m){if(!(this instanceof h))return new h(m);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var y=o.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(c[y]);this.header=new d,o.inflateGetHeader(this.strm,this.header)}function p(m,g){var y=new h(g);if(y.push(m,!0),y.err)throw y.msg||c[y.err];return y.result}h.prototype.push=function(m,g){var y,v,b,w,x,A,T=this.strm,I=this.options.chunkSize,P=this.options.dictionary,C=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?T.input=a.binstring2buf(m):f.call(m)==="[object ArrayBuffer]"?T.input=new Uint8Array(m):T.input=m,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(I),T.next_out=0,T.avail_out=I),(y=o.inflate(T,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&P&&(A=typeof P=="string"?a.string2buf(P):f.call(P)==="[object ArrayBuffer]"?new Uint8Array(P):P,y=o.inflateSetDictionary(this.strm,A)),y===l.Z_BUF_ERROR&&C===!0&&(y=l.Z_OK,C=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&y!==l.Z_STREAM_END&&(T.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=a.utf8border(T.output,T.next_out),w=T.next_out-b,x=a.buf2string(T.output,b),T.next_out=w,T.avail_out=I-w,w&&s.arraySet(T.output,T.output,b,w,0),this.onData(x)):this.onData(s.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(C=!0)}while((0<T.avail_in||T.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(y=o.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(T.avail_out=0))},h.prototype.onData=function(m){this.chunks.push(m)},h.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Inflate=h,i.inflate=p,i.inflateRaw=function(m,g){return(g=g||{}).raw=!0,p(m,g)},i.ungzip=p},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){"use strict";var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var d in u)u.hasOwnProperty(d)&&(l[d]=u[d])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var s={arraySet:function(l,c,u,d,f){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+d),f);else for(var h=0;h<d;h++)l[f+h]=c[u+h]},flattenChunks:function(l){var c,u,d,f,h,p;for(c=d=0,u=l.length;c<u;c++)d+=l[c].length;for(p=new Uint8Array(d),c=f=0,u=l.length;c<u;c++)h=l[c],p.set(h,f),f+=h.length;return p}},a={arraySet:function(l,c,u,d,f){for(var h=0;h<d;h++)l[f+h]=c[u+h]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(o)},{}],42:[function(n,r,i){"use strict";var o=n("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new o.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function u(d,f){if(f<65537&&(d.subarray&&a||!d.subarray&&s))return String.fromCharCode.apply(null,o.shrinkBuf(d,f));for(var h="",p=0;p<f;p++)h+=String.fromCharCode(d[p]);return h}l[254]=l[254]=1,i.string2buf=function(d){var f,h,p,m,g,y=d.length,v=0;for(m=0;m<y;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),v+=h<128?1:h<2048?2:h<65536?3:4;for(f=new o.Buf8(v),m=g=0;g<v;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),h<128?f[g++]=h:(h<2048?f[g++]=192|h>>>6:(h<65536?f[g++]=224|h>>>12:(f[g++]=240|h>>>18,f[g++]=128|h>>>12&63),f[g++]=128|h>>>6&63),f[g++]=128|63&h);return f},i.buf2binstring=function(d){return u(d,d.length)},i.binstring2buf=function(d){for(var f=new o.Buf8(d.length),h=0,p=f.length;h<p;h++)f[h]=d.charCodeAt(h);return f},i.buf2string=function(d,f){var h,p,m,g,y=f||d.length,v=new Array(2*y);for(h=p=0;h<y;)if((m=d[h++])<128)v[p++]=m;else if(4<(g=l[m]))v[p++]=65533,h+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&h<y;)m=m<<6|63&d[h++],g--;1<g?v[p++]=65533:m<65536?v[p++]=m:(m-=65536,v[p++]=55296|m>>10&1023,v[p++]=56320|1023&m)}return u(v,p)},i.utf8border=function(d,f){var h;for((f=f||d.length)>d.length&&(f=d.length),h=f-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?f:h+l[d[h]]>f?h:f}},{"./common":41}],43:[function(n,r,i){"use strict";r.exports=function(o,s,a,l){for(var c=65535&o|0,u=o>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3<a?2e3:a;u=u+(c=c+s[l++]|0)|0,--d;);c%=65521,u%=65521}return c|u<<16|0}},{}],44:[function(n,r,i){"use strict";r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){"use strict";var o=(function(){for(var s,a=[],l=0;l<256;l++){s=l;for(var c=0;c<8;c++)s=1&s?3988292384^s>>>1:s>>>1;a[l]=s}return a})();r.exports=function(s,a,l,c){var u=o,d=c+l;s^=-1;for(var f=c;f<d;f++)s=s>>>8^u[255&(s^a[f])];return-1^s}},{}],46:[function(n,r,i){"use strict";var o,s=n("../utils/common"),a=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),d=0,f=4,h=0,p=-2,m=-1,g=4,y=2,v=8,b=9,w=286,x=30,A=19,T=2*w+1,I=15,P=3,C=258,R=C+P+1,k=42,L=113,_=1,O=2,F=3,B=4;function U(N,q){return N.msg=u[q],q}function M(N){return(N<<1)-(4<N?9:0)}function z(N){for(var q=N.length;0<=--q;)N[q]=0}function Z(N){var q=N.state,oe=q.pending;oe>N.avail_out&&(oe=N.avail_out),oe!==0&&(s.arraySet(N.output,q.pending_buf,q.pending_out,oe,N.next_out),N.next_out+=oe,q.pending_out+=oe,N.total_out+=oe,N.avail_out-=oe,q.pending-=oe,q.pending===0&&(q.pending_out=0))}function Q(N,q){a._tr_flush_block(N,0<=N.block_start?N.block_start:-1,N.strstart-N.block_start,q),N.block_start=N.strstart,Z(N.strm)}function W(N,q){N.pending_buf[N.pending++]=q}function he(N,q){N.pending_buf[N.pending++]=q>>>8&255,N.pending_buf[N.pending++]=255&q}function K(N,q){var oe,J,re=N.max_chain_length,te=N.strstart,fe=N.prev_length,de=N.nice_match,ue=N.strstart>N.w_size-R?N.strstart-(N.w_size-R):0,ie=N.window,ce=N.w_mask,Te=N.prev,ye=N.strstart+C,le=ie[te+fe-1],Ae=ie[te+fe];N.prev_length>=N.good_match&&(re>>=2),de>N.lookahead&&(de=N.lookahead);do if(ie[(oe=q)+fe]===Ae&&ie[oe+fe-1]===le&&ie[oe]===ie[te]&&ie[++oe]===ie[te+1]){te+=2,oe++;do;while(ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&ie[++te]===ie[++oe]&&te<ye);if(J=C-(ye-te),te=ye-C,fe<J){if(N.match_start=q,de<=(fe=J))break;le=ie[te+fe-1],Ae=ie[te+fe]}}while((q=Te[q&ce])>ue&&--re!=0);return fe<=N.lookahead?fe:N.lookahead}function X(N){var q,oe,J,re,te,fe,de,ue,ie,ce,Te=N.w_size;do{if(re=N.window_size-N.lookahead-N.strstart,N.strstart>=Te+(Te-R)){for(s.arraySet(N.window,N.window,Te,Te,0),N.match_start-=Te,N.strstart-=Te,N.block_start-=Te,q=oe=N.hash_size;J=N.head[--q],N.head[q]=Te<=J?J-Te:0,--oe;);for(q=oe=Te;J=N.prev[--q],N.prev[q]=Te<=J?J-Te:0,--oe;);re+=Te}if(N.strm.avail_in===0)break;if(fe=N.strm,de=N.window,ue=N.strstart+N.lookahead,ie=re,ce=void 0,ce=fe.avail_in,ie<ce&&(ce=ie),oe=ce===0?0:(fe.avail_in-=ce,s.arraySet(de,fe.input,fe.next_in,ce,ue),fe.state.wrap===1?fe.adler=l(fe.adler,de,ce,ue):fe.state.wrap===2&&(fe.adler=c(fe.adler,de,ce,ue)),fe.next_in+=ce,fe.total_in+=ce,ce),N.lookahead+=oe,N.lookahead+N.insert>=P)for(te=N.strstart-N.insert,N.ins_h=N.window[te],N.ins_h=(N.ins_h<<N.hash_shift^N.window[te+1])&N.hash_mask;N.insert&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[te+P-1])&N.hash_mask,N.prev[te&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=te,te++,N.insert--,!(N.lookahead+N.insert<P)););}while(N.lookahead<R&&N.strm.avail_in!==0)}function ee(N,q){for(var oe,J;;){if(N.lookahead<R){if(X(N),N.lookahead<R&&q===d)return _;if(N.lookahead===0)break}if(oe=0,N.lookahead>=P&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+P-1])&N.hash_mask,oe=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),oe!==0&&N.strstart-oe<=N.w_size-R&&(N.match_length=K(N,oe)),N.match_length>=P)if(J=a._tr_tally(N,N.strstart-N.match_start,N.match_length-P),N.lookahead-=N.match_length,N.match_length<=N.max_lazy_match&&N.lookahead>=P){for(N.match_length--;N.strstart++,N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+P-1])&N.hash_mask,oe=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart,--N.match_length!=0;);N.strstart++}else N.strstart+=N.match_length,N.match_length=0,N.ins_h=N.window[N.strstart],N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+1])&N.hash_mask;else J=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++;if(J&&(Q(N,!1),N.strm.avail_out===0))return _}return N.insert=N.strstart<P-1?N.strstart:P-1,q===f?(Q(N,!0),N.strm.avail_out===0?F:B):N.last_lit&&(Q(N,!1),N.strm.avail_out===0)?_:O}function be(N,q){for(var oe,J,re;;){if(N.lookahead<R){if(X(N),N.lookahead<R&&q===d)return _;if(N.lookahead===0)break}if(oe=0,N.lookahead>=P&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+P-1])&N.hash_mask,oe=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),N.prev_length=N.match_length,N.prev_match=N.match_start,N.match_length=P-1,oe!==0&&N.prev_length<N.max_lazy_match&&N.strstart-oe<=N.w_size-R&&(N.match_length=K(N,oe),N.match_length<=5&&(N.strategy===1||N.match_length===P&&4096<N.strstart-N.match_start)&&(N.match_length=P-1)),N.prev_length>=P&&N.match_length<=N.prev_length){for(re=N.strstart+N.lookahead-P,J=a._tr_tally(N,N.strstart-1-N.prev_match,N.prev_length-P),N.lookahead-=N.prev_length-1,N.prev_length-=2;++N.strstart<=re&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+P-1])&N.hash_mask,oe=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),--N.prev_length!=0;);if(N.match_available=0,N.match_length=P-1,N.strstart++,J&&(Q(N,!1),N.strm.avail_out===0))return _}else if(N.match_available){if((J=a._tr_tally(N,0,N.window[N.strstart-1]))&&Q(N,!1),N.strstart++,N.lookahead--,N.strm.avail_out===0)return _}else N.match_available=1,N.strstart++,N.lookahead--}return N.match_available&&(J=a._tr_tally(N,0,N.window[N.strstart-1]),N.match_available=0),N.insert=N.strstart<P-1?N.strstart:P-1,q===f?(Q(N,!0),N.strm.avail_out===0?F:B):N.last_lit&&(Q(N,!1),N.strm.avail_out===0)?_:O}function xe(N,q,oe,J,re){this.good_length=N,this.max_lazy=q,this.nice_length=oe,this.max_chain=J,this.func=re}function pe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*T),this.dyn_dtree=new s.Buf16(2*(2*x+1)),this.bl_tree=new s.Buf16(2*(2*A+1)),z(this.dyn_ltree),z(this.dyn_dtree),z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(I+1),this.heap=new s.Buf16(2*w+1),z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*w+1),z(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ke(N){var q;return N&&N.state?(N.total_in=N.total_out=0,N.data_type=y,(q=N.state).pending=0,q.pending_out=0,q.wrap<0&&(q.wrap=-q.wrap),q.status=q.wrap?k:L,N.adler=q.wrap===2?0:1,q.last_flush=d,a._tr_init(q),h):U(N,p)}function V(N){var q=ke(N);return q===h&&(function(oe){oe.window_size=2*oe.w_size,z(oe.head),oe.max_lazy_match=o[oe.level].max_lazy,oe.good_match=o[oe.level].good_length,oe.nice_match=o[oe.level].nice_length,oe.max_chain_length=o[oe.level].max_chain,oe.strstart=0,oe.block_start=0,oe.lookahead=0,oe.insert=0,oe.match_length=oe.prev_length=P-1,oe.match_available=0,oe.ins_h=0})(N.state),q}function D(N,q,oe,J,re,te){if(!N)return p;var fe=1;if(q===m&&(q=6),J<0?(fe=0,J=-J):15<J&&(fe=2,J-=16),re<1||b<re||oe!==v||J<8||15<J||q<0||9<q||te<0||g<te)return U(N,p);J===8&&(J=9);var de=new pe;return(N.state=de).strm=N,de.wrap=fe,de.gzhead=null,de.w_bits=J,de.w_size=1<<de.w_bits,de.w_mask=de.w_size-1,de.hash_bits=re+7,de.hash_size=1<<de.hash_bits,de.hash_mask=de.hash_size-1,de.hash_shift=~~((de.hash_bits+P-1)/P),de.window=new s.Buf8(2*de.w_size),de.head=new s.Buf16(de.hash_size),de.prev=new s.Buf16(de.w_size),de.lit_bufsize=1<<re+6,de.pending_buf_size=4*de.lit_bufsize,de.pending_buf=new s.Buf8(de.pending_buf_size),de.d_buf=1*de.lit_bufsize,de.l_buf=3*de.lit_bufsize,de.level=q,de.strategy=te,de.method=oe,V(N)}o=[new xe(0,0,0,0,function(N,q){var oe=65535;for(oe>N.pending_buf_size-5&&(oe=N.pending_buf_size-5);;){if(N.lookahead<=1){if(X(N),N.lookahead===0&&q===d)return _;if(N.lookahead===0)break}N.strstart+=N.lookahead,N.lookahead=0;var J=N.block_start+oe;if((N.strstart===0||N.strstart>=J)&&(N.lookahead=N.strstart-J,N.strstart=J,Q(N,!1),N.strm.avail_out===0)||N.strstart-N.block_start>=N.w_size-R&&(Q(N,!1),N.strm.avail_out===0))return _}return N.insert=0,q===f?(Q(N,!0),N.strm.avail_out===0?F:B):(N.strstart>N.block_start&&(Q(N,!1),N.strm.avail_out),_)}),new xe(4,4,8,4,ee),new xe(4,5,16,8,ee),new xe(4,6,32,32,ee),new xe(4,4,16,16,be),new xe(8,16,32,32,be),new xe(8,16,128,128,be),new xe(8,32,128,256,be),new xe(32,128,258,1024,be),new xe(32,258,258,4096,be)],i.deflateInit=function(N,q){return D(N,q,v,15,8,0)},i.deflateInit2=D,i.deflateReset=V,i.deflateResetKeep=ke,i.deflateSetHeader=function(N,q){return N&&N.state?N.state.wrap!==2?p:(N.state.gzhead=q,h):p},i.deflate=function(N,q){var oe,J,re,te;if(!N||!N.state||5<q||q<0)return N?U(N,p):p;if(J=N.state,!N.output||!N.input&&N.avail_in!==0||J.status===666&&q!==f)return U(N,N.avail_out===0?-5:p);if(J.strm=N,oe=J.last_flush,J.last_flush=q,J.status===k)if(J.wrap===2)N.adler=0,W(J,31),W(J,139),W(J,8),J.gzhead?(W(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(J.gzhead.extra?4:0)+(J.gzhead.name?8:0)+(J.gzhead.comment?16:0)),W(J,255&J.gzhead.time),W(J,J.gzhead.time>>8&255),W(J,J.gzhead.time>>16&255),W(J,J.gzhead.time>>24&255),W(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),W(J,255&J.gzhead.os),J.gzhead.extra&&J.gzhead.extra.length&&(W(J,255&J.gzhead.extra.length),W(J,J.gzhead.extra.length>>8&255)),J.gzhead.hcrc&&(N.adler=c(N.adler,J.pending_buf,J.pending,0)),J.gzindex=0,J.status=69):(W(J,0),W(J,0),W(J,0),W(J,0),W(J,0),W(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),W(J,3),J.status=L);else{var fe=v+(J.w_bits-8<<4)<<8;fe|=(2<=J.strategy||J.level<2?0:J.level<6?1:J.level===6?2:3)<<6,J.strstart!==0&&(fe|=32),fe+=31-fe%31,J.status=L,he(J,fe),J.strstart!==0&&(he(J,N.adler>>>16),he(J,65535&N.adler)),N.adler=1}if(J.status===69)if(J.gzhead.extra){for(re=J.pending;J.gzindex<(65535&J.gzhead.extra.length)&&(J.pending!==J.pending_buf_size||(J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),Z(N),re=J.pending,J.pending!==J.pending_buf_size));)W(J,255&J.gzhead.extra[J.gzindex]),J.gzindex++;J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),J.gzindex===J.gzhead.extra.length&&(J.gzindex=0,J.status=73)}else J.status=73;if(J.status===73)if(J.gzhead.name){re=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),Z(N),re=J.pending,J.pending===J.pending_buf_size)){te=1;break}te=J.gzindex<J.gzhead.name.length?255&J.gzhead.name.charCodeAt(J.gzindex++):0,W(J,te)}while(te!==0);J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),te===0&&(J.gzindex=0,J.status=91)}else J.status=91;if(J.status===91)if(J.gzhead.comment){re=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),Z(N),re=J.pending,J.pending===J.pending_buf_size)){te=1;break}te=J.gzindex<J.gzhead.comment.length?255&J.gzhead.comment.charCodeAt(J.gzindex++):0,W(J,te)}while(te!==0);J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),te===0&&(J.status=103)}else J.status=103;if(J.status===103&&(J.gzhead.hcrc?(J.pending+2>J.pending_buf_size&&Z(N),J.pending+2<=J.pending_buf_size&&(W(J,255&N.adler),W(J,N.adler>>8&255),N.adler=0,J.status=L)):J.status=L),J.pending!==0){if(Z(N),N.avail_out===0)return J.last_flush=-1,h}else if(N.avail_in===0&&M(q)<=M(oe)&&q!==f)return U(N,-5);if(J.status===666&&N.avail_in!==0)return U(N,-5);if(N.avail_in!==0||J.lookahead!==0||q!==d&&J.status!==666){var de=J.strategy===2?(function(ue,ie){for(var ce;;){if(ue.lookahead===0&&(X(ue),ue.lookahead===0)){if(ie===d)return _;break}if(ue.match_length=0,ce=a._tr_tally(ue,0,ue.window[ue.strstart]),ue.lookahead--,ue.strstart++,ce&&(Q(ue,!1),ue.strm.avail_out===0))return _}return ue.insert=0,ie===f?(Q(ue,!0),ue.strm.avail_out===0?F:B):ue.last_lit&&(Q(ue,!1),ue.strm.avail_out===0)?_:O})(J,q):J.strategy===3?(function(ue,ie){for(var ce,Te,ye,le,Ae=ue.window;;){if(ue.lookahead<=C){if(X(ue),ue.lookahead<=C&&ie===d)return _;if(ue.lookahead===0)break}if(ue.match_length=0,ue.lookahead>=P&&0<ue.strstart&&(Te=Ae[ye=ue.strstart-1])===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]){le=ue.strstart+C;do;while(Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&Te===Ae[++ye]&&ye<le);ue.match_length=C-(le-ye),ue.match_length>ue.lookahead&&(ue.match_length=ue.lookahead)}if(ue.match_length>=P?(ce=a._tr_tally(ue,1,ue.match_length-P),ue.lookahead-=ue.match_length,ue.strstart+=ue.match_length,ue.match_length=0):(ce=a._tr_tally(ue,0,ue.window[ue.strstart]),ue.lookahead--,ue.strstart++),ce&&(Q(ue,!1),ue.strm.avail_out===0))return _}return ue.insert=0,ie===f?(Q(ue,!0),ue.strm.avail_out===0?F:B):ue.last_lit&&(Q(ue,!1),ue.strm.avail_out===0)?_:O})(J,q):o[J.level].func(J,q);if(de!==F&&de!==B||(J.status=666),de===_||de===F)return N.avail_out===0&&(J.last_flush=-1),h;if(de===O&&(q===1?a._tr_align(J):q!==5&&(a._tr_stored_block(J,0,0,!1),q===3&&(z(J.head),J.lookahead===0&&(J.strstart=0,J.block_start=0,J.insert=0))),Z(N),N.avail_out===0))return J.last_flush=-1,h}return q!==f?h:J.wrap<=0?1:(J.wrap===2?(W(J,255&N.adler),W(J,N.adler>>8&255),W(J,N.adler>>16&255),W(J,N.adler>>24&255),W(J,255&N.total_in),W(J,N.total_in>>8&255),W(J,N.total_in>>16&255),W(J,N.total_in>>24&255)):(he(J,N.adler>>>16),he(J,65535&N.adler)),Z(N),0<J.wrap&&(J.wrap=-J.wrap),J.pending!==0?h:1)},i.deflateEnd=function(N){var q;return N&&N.state?(q=N.state.status)!==k&&q!==69&&q!==73&&q!==91&&q!==103&&q!==L&&q!==666?U(N,p):(N.state=null,q===L?U(N,-3):h):p},i.deflateSetDictionary=function(N,q){var oe,J,re,te,fe,de,ue,ie,ce=q.length;if(!N||!N.state||(te=(oe=N.state).wrap)===2||te===1&&oe.status!==k||oe.lookahead)return p;for(te===1&&(N.adler=l(N.adler,q,ce,0)),oe.wrap=0,ce>=oe.w_size&&(te===0&&(z(oe.head),oe.strstart=0,oe.block_start=0,oe.insert=0),ie=new s.Buf8(oe.w_size),s.arraySet(ie,q,ce-oe.w_size,oe.w_size,0),q=ie,ce=oe.w_size),fe=N.avail_in,de=N.next_in,ue=N.input,N.avail_in=ce,N.next_in=0,N.input=q,X(oe);oe.lookahead>=P;){for(J=oe.strstart,re=oe.lookahead-(P-1);oe.ins_h=(oe.ins_h<<oe.hash_shift^oe.window[J+P-1])&oe.hash_mask,oe.prev[J&oe.w_mask]=oe.head[oe.ins_h],oe.head[oe.ins_h]=J,J++,--re;);oe.strstart=J,oe.lookahead=P-1,X(oe)}return oe.strstart+=oe.lookahead,oe.block_start=oe.strstart,oe.insert=oe.lookahead,oe.lookahead=0,oe.match_length=oe.prev_length=P-1,oe.match_available=0,N.next_in=de,N.input=ue,N.avail_in=fe,oe.wrap=te,h},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){"use strict";r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){"use strict";r.exports=function(o,s){var a=o.state,l=o.next_in,c,u,d,f,h,p,m,g,y,v,b,w,x,A,T,I,P,C,R,k,L,_=o.input,O;c=l+(o.avail_in-5),u=o.next_out,O=o.output,d=u-(s-o.avail_out),f=u+(o.avail_out-257),h=a.dmax,p=a.wsize,m=a.whave,g=a.wnext,y=a.window,v=a.hold,b=a.bits,w=a.lencode,x=a.distcode,A=(1<<a.lenbits)-1,T=(1<<a.distbits)-1;e:do{b<15&&(v+=_[l++]<<b,b+=8,v+=_[l++]<<b,b+=8),I=w[v&A];t:for(;;){if(v>>>=P=I>>>24,b-=P,(P=I>>>16&255)===0)O[u++]=65535&I;else{if(!(16&P)){if((64&P)==0){I=w[(65535&I)+(v&(1<<P)-1)];continue t}if(32&P){a.mode=12;break e}o.msg="invalid literal/length code",a.mode=30;break e}C=65535&I,(P&=15)&&(b<P&&(v+=_[l++]<<b,b+=8),C+=v&(1<<P)-1,v>>>=P,b-=P),b<15&&(v+=_[l++]<<b,b+=8,v+=_[l++]<<b,b+=8),I=x[v&T];n:for(;;){if(v>>>=P=I>>>24,b-=P,!(16&(P=I>>>16&255))){if((64&P)==0){I=x[(65535&I)+(v&(1<<P)-1)];continue n}o.msg="invalid distance code",a.mode=30;break e}if(R=65535&I,b<(P&=15)&&(v+=_[l++]<<b,(b+=8)<P&&(v+=_[l++]<<b,b+=8)),h<(R+=v&(1<<P)-1)){o.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=P,b-=P,(P=u-d)<R){if(m<(P=R-P)&&a.sane){o.msg="invalid distance too far back",a.mode=30;break e}if(L=y,(k=0)===g){if(k+=p-P,P<C){for(C-=P;O[u++]=y[k++],--P;);k=u-R,L=O}}else if(g<P){if(k+=p+g-P,(P-=g)<C){for(C-=P;O[u++]=y[k++],--P;);if(k=0,g<C){for(C-=P=g;O[u++]=y[k++],--P;);k=u-R,L=O}}}else if(k+=g-P,P<C){for(C-=P;O[u++]=y[k++],--P;);k=u-R,L=O}for(;2<C;)O[u++]=L[k++],O[u++]=L[k++],O[u++]=L[k++],C-=3;C&&(O[u++]=L[k++],1<C&&(O[u++]=L[k++]))}else{for(k=u-R;O[u++]=O[k++],O[u++]=O[k++],O[u++]=O[k++],2<(C-=3););C&&(O[u++]=O[k++],1<C&&(O[u++]=O[k++]))}break}}break}}while(l<c&&u<f);l-=C=b>>3,v&=(1<<(b-=C<<3))-1,o.next_in=l,o.next_out=u,o.avail_in=l<c?c-l+5:5-(l-c),o.avail_out=u<f?f-u+257:257-(u-f),a.hold=v,a.bits=b}},{}],49:[function(n,r,i){"use strict";var o=n("../utils/common"),s=n("./adler32"),a=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),u=1,d=2,f=0,h=-2,p=1,m=852,g=592;function y(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(k){var L;return k&&k.state?(L=k.state,k.total_in=k.total_out=L.total=0,k.msg="",L.wrap&&(k.adler=1&L.wrap),L.mode=p,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new o.Buf32(m),L.distcode=L.distdyn=new o.Buf32(g),L.sane=1,L.back=-1,f):h}function w(k){var L;return k&&k.state?((L=k.state).wsize=0,L.whave=0,L.wnext=0,b(k)):h}function x(k,L){var _,O;return k&&k.state?(O=k.state,L<0?(_=0,L=-L):(_=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?h:(O.window!==null&&O.wbits!==L&&(O.window=null),O.wrap=_,O.wbits=L,w(k))):h}function A(k,L){var _,O;return k?(O=new v,(k.state=O).window=null,(_=x(k,L))!==f&&(k.state=null),_):h}var T,I,P=!0;function C(k){if(P){var L;for(T=new o.Buf32(512),I=new o.Buf32(32),L=0;L<144;)k.lens[L++]=8;for(;L<256;)k.lens[L++]=9;for(;L<280;)k.lens[L++]=7;for(;L<288;)k.lens[L++]=8;for(c(u,k.lens,0,288,T,0,k.work,{bits:9}),L=0;L<32;)k.lens[L++]=5;c(d,k.lens,0,32,I,0,k.work,{bits:5}),P=!1}k.lencode=T,k.lenbits=9,k.distcode=I,k.distbits=5}function R(k,L,_,O){var F,B=k.state;return B.window===null&&(B.wsize=1<<B.wbits,B.wnext=0,B.whave=0,B.window=new o.Buf8(B.wsize)),O>=B.wsize?(o.arraySet(B.window,L,_-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):(O<(F=B.wsize-B.wnext)&&(F=O),o.arraySet(B.window,L,_-O,F,B.wnext),(O-=F)?(o.arraySet(B.window,L,_-O,O,0),B.wnext=O,B.whave=B.wsize):(B.wnext+=F,B.wnext===B.wsize&&(B.wnext=0),B.whave<B.wsize&&(B.whave+=F))),0}i.inflateReset=w,i.inflateReset2=x,i.inflateResetKeep=b,i.inflateInit=function(k){return A(k,15)},i.inflateInit2=A,i.inflate=function(k,L){var _,O,F,B,U,M,z,Z,Q,W,he,K,X,ee,be,xe,pe,ke,V,D,N,q,oe,J,re=0,te=new o.Buf8(4),fe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return h;(_=k.state).mode===12&&(_.mode=13),U=k.next_out,F=k.output,z=k.avail_out,B=k.next_in,O=k.input,M=k.avail_in,Z=_.hold,Q=_.bits,W=M,he=z,q=f;e:for(;;)switch(_.mode){case p:if(_.wrap===0){_.mode=13;break}for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(2&_.wrap&&Z===35615){te[_.check=0]=255&Z,te[1]=Z>>>8&255,_.check=a(_.check,te,2,0),Q=Z=0,_.mode=2;break}if(_.flags=0,_.head&&(_.head.done=!1),!(1&_.wrap)||(((255&Z)<<8)+(Z>>8))%31){k.msg="incorrect header check",_.mode=30;break}if((15&Z)!=8){k.msg="unknown compression method",_.mode=30;break}if(Q-=4,N=8+(15&(Z>>>=4)),_.wbits===0)_.wbits=N;else if(N>_.wbits){k.msg="invalid window size",_.mode=30;break}_.dmax=1<<N,k.adler=_.check=1,_.mode=512&Z?10:12,Q=Z=0;break;case 2:for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(_.flags=Z,(255&_.flags)!=8){k.msg="unknown compression method",_.mode=30;break}if(57344&_.flags){k.msg="unknown header flags set",_.mode=30;break}_.head&&(_.head.text=Z>>8&1),512&_.flags&&(te[0]=255&Z,te[1]=Z>>>8&255,_.check=a(_.check,te,2,0)),Q=Z=0,_.mode=3;case 3:for(;Q<32;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.head&&(_.head.time=Z),512&_.flags&&(te[0]=255&Z,te[1]=Z>>>8&255,te[2]=Z>>>16&255,te[3]=Z>>>24&255,_.check=a(_.check,te,4,0)),Q=Z=0,_.mode=4;case 4:for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.head&&(_.head.xflags=255&Z,_.head.os=Z>>8),512&_.flags&&(te[0]=255&Z,te[1]=Z>>>8&255,_.check=a(_.check,te,2,0)),Q=Z=0,_.mode=5;case 5:if(1024&_.flags){for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.length=Z,_.head&&(_.head.extra_len=Z),512&_.flags&&(te[0]=255&Z,te[1]=Z>>>8&255,_.check=a(_.check,te,2,0)),Q=Z=0}else _.head&&(_.head.extra=null);_.mode=6;case 6:if(1024&_.flags&&(M<(K=_.length)&&(K=M),K&&(_.head&&(N=_.head.extra_len-_.length,_.head.extra||(_.head.extra=new Array(_.head.extra_len)),o.arraySet(_.head.extra,O,B,K,N)),512&_.flags&&(_.check=a(_.check,O,K,B)),M-=K,B+=K,_.length-=K),_.length))break e;_.length=0,_.mode=7;case 7:if(2048&_.flags){if(M===0)break e;for(K=0;N=O[B+K++],_.head&&N&&_.length<65536&&(_.head.name+=String.fromCharCode(N)),N&&K<M;);if(512&_.flags&&(_.check=a(_.check,O,K,B)),M-=K,B+=K,N)break e}else _.head&&(_.head.name=null);_.length=0,_.mode=8;case 8:if(4096&_.flags){if(M===0)break e;for(K=0;N=O[B+K++],_.head&&N&&_.length<65536&&(_.head.comment+=String.fromCharCode(N)),N&&K<M;);if(512&_.flags&&(_.check=a(_.check,O,K,B)),M-=K,B+=K,N)break e}else _.head&&(_.head.comment=null);_.mode=9;case 9:if(512&_.flags){for(;Q<16;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(Z!==(65535&_.check)){k.msg="header crc mismatch",_.mode=30;break}Q=Z=0}_.head&&(_.head.hcrc=_.flags>>9&1,_.head.done=!0),k.adler=_.check=0,_.mode=12;break;case 10:for(;Q<32;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}k.adler=_.check=y(Z),Q=Z=0,_.mode=11;case 11:if(_.havedict===0)return k.next_out=U,k.avail_out=z,k.next_in=B,k.avail_in=M,_.hold=Z,_.bits=Q,2;k.adler=_.check=1,_.mode=12;case 12:if(L===5||L===6)break e;case 13:if(_.last){Z>>>=7&Q,Q-=7&Q,_.mode=27;break}for(;Q<3;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}switch(_.last=1&Z,Q-=1,3&(Z>>>=1)){case 0:_.mode=14;break;case 1:if(C(_),_.mode=20,L!==6)break;Z>>>=2,Q-=2;break e;case 2:_.mode=17;break;case 3:k.msg="invalid block type",_.mode=30}Z>>>=2,Q-=2;break;case 14:for(Z>>>=7&Q,Q-=7&Q;Q<32;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if((65535&Z)!=(Z>>>16^65535)){k.msg="invalid stored block lengths",_.mode=30;break}if(_.length=65535&Z,Q=Z=0,_.mode=15,L===6)break e;case 15:_.mode=16;case 16:if(K=_.length){if(M<K&&(K=M),z<K&&(K=z),K===0)break e;o.arraySet(F,O,B,K,U),M-=K,B+=K,z-=K,U+=K,_.length-=K;break}_.mode=12;break;case 17:for(;Q<14;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(_.nlen=257+(31&Z),Z>>>=5,Q-=5,_.ndist=1+(31&Z),Z>>>=5,Q-=5,_.ncode=4+(15&Z),Z>>>=4,Q-=4,286<_.nlen||30<_.ndist){k.msg="too many length or distance symbols",_.mode=30;break}_.have=0,_.mode=18;case 18:for(;_.have<_.ncode;){for(;Q<3;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.lens[fe[_.have++]]=7&Z,Z>>>=3,Q-=3}for(;_.have<19;)_.lens[fe[_.have++]]=0;if(_.lencode=_.lendyn,_.lenbits=7,oe={bits:_.lenbits},q=c(0,_.lens,0,19,_.lencode,0,_.work,oe),_.lenbits=oe.bits,q){k.msg="invalid code lengths set",_.mode=30;break}_.have=0,_.mode=19;case 19:for(;_.have<_.nlen+_.ndist;){for(;xe=(re=_.lencode[Z&(1<<_.lenbits)-1])>>>16&255,pe=65535&re,!((be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(pe<16)Z>>>=be,Q-=be,_.lens[_.have++]=pe;else{if(pe===16){for(J=be+2;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(Z>>>=be,Q-=be,_.have===0){k.msg="invalid bit length repeat",_.mode=30;break}N=_.lens[_.have-1],K=3+(3&Z),Z>>>=2,Q-=2}else if(pe===17){for(J=be+3;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}Q-=be,N=0,K=3+(7&(Z>>>=be)),Z>>>=3,Q-=3}else{for(J=be+7;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}Q-=be,N=0,K=11+(127&(Z>>>=be)),Z>>>=7,Q-=7}if(_.have+K>_.nlen+_.ndist){k.msg="invalid bit length repeat",_.mode=30;break}for(;K--;)_.lens[_.have++]=N}}if(_.mode===30)break;if(_.lens[256]===0){k.msg="invalid code -- missing end-of-block",_.mode=30;break}if(_.lenbits=9,oe={bits:_.lenbits},q=c(u,_.lens,0,_.nlen,_.lencode,0,_.work,oe),_.lenbits=oe.bits,q){k.msg="invalid literal/lengths set",_.mode=30;break}if(_.distbits=6,_.distcode=_.distdyn,oe={bits:_.distbits},q=c(d,_.lens,_.nlen,_.ndist,_.distcode,0,_.work,oe),_.distbits=oe.bits,q){k.msg="invalid distances set",_.mode=30;break}if(_.mode=20,L===6)break e;case 20:_.mode=21;case 21:if(6<=M&&258<=z){k.next_out=U,k.avail_out=z,k.next_in=B,k.avail_in=M,_.hold=Z,_.bits=Q,l(k,he),U=k.next_out,F=k.output,z=k.avail_out,B=k.next_in,O=k.input,M=k.avail_in,Z=_.hold,Q=_.bits,_.mode===12&&(_.back=-1);break}for(_.back=0;xe=(re=_.lencode[Z&(1<<_.lenbits)-1])>>>16&255,pe=65535&re,!((be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(xe&&(240&xe)==0){for(ke=be,V=xe,D=pe;xe=(re=_.lencode[D+((Z&(1<<ke+V)-1)>>ke)])>>>16&255,pe=65535&re,!(ke+(be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}Z>>>=ke,Q-=ke,_.back+=ke}if(Z>>>=be,Q-=be,_.back+=be,_.length=pe,xe===0){_.mode=26;break}if(32&xe){_.back=-1,_.mode=12;break}if(64&xe){k.msg="invalid literal/length code",_.mode=30;break}_.extra=15&xe,_.mode=22;case 22:if(_.extra){for(J=_.extra;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.length+=Z&(1<<_.extra)-1,Z>>>=_.extra,Q-=_.extra,_.back+=_.extra}_.was=_.length,_.mode=23;case 23:for(;xe=(re=_.distcode[Z&(1<<_.distbits)-1])>>>16&255,pe=65535&re,!((be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if((240&xe)==0){for(ke=be,V=xe,D=pe;xe=(re=_.distcode[D+((Z&(1<<ke+V)-1)>>ke)])>>>16&255,pe=65535&re,!(ke+(be=re>>>24)<=Q);){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}Z>>>=ke,Q-=ke,_.back+=ke}if(Z>>>=be,Q-=be,_.back+=be,64&xe){k.msg="invalid distance code",_.mode=30;break}_.offset=pe,_.extra=15&xe,_.mode=24;case 24:if(_.extra){for(J=_.extra;Q<J;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}_.offset+=Z&(1<<_.extra)-1,Z>>>=_.extra,Q-=_.extra,_.back+=_.extra}if(_.offset>_.dmax){k.msg="invalid distance too far back",_.mode=30;break}_.mode=25;case 25:if(z===0)break e;if(K=he-z,_.offset>K){if((K=_.offset-K)>_.whave&&_.sane){k.msg="invalid distance too far back",_.mode=30;break}X=K>_.wnext?(K-=_.wnext,_.wsize-K):_.wnext-K,K>_.length&&(K=_.length),ee=_.window}else ee=F,X=U-_.offset,K=_.length;for(z<K&&(K=z),z-=K,_.length-=K;F[U++]=ee[X++],--K;);_.length===0&&(_.mode=21);break;case 26:if(z===0)break e;F[U++]=_.length,z--,_.mode=21;break;case 27:if(_.wrap){for(;Q<32;){if(M===0)break e;M--,Z|=O[B++]<<Q,Q+=8}if(he-=z,k.total_out+=he,_.total+=he,he&&(k.adler=_.check=_.flags?a(_.check,F,he,U-he):s(_.check,F,he,U-he)),he=z,(_.flags?Z:y(Z))!==_.check){k.msg="incorrect data check",_.mode=30;break}Q=Z=0}_.mode=28;case 28:if(_.wrap&&_.flags){for(;Q<32;){if(M===0)break e;M--,Z+=O[B++]<<Q,Q+=8}if(Z!==(4294967295&_.total)){k.msg="incorrect length check",_.mode=30;break}Q=Z=0}_.mode=29;case 29:q=1;break e;case 30:q=-3;break e;case 31:return-4;default:return h}return k.next_out=U,k.avail_out=z,k.next_in=B,k.avail_in=M,_.hold=Z,_.bits=Q,(_.wsize||he!==k.avail_out&&_.mode<30&&(_.mode<27||L!==4))&&R(k,k.output,k.next_out,he-k.avail_out)?(_.mode=31,-4):(W-=k.avail_in,he-=k.avail_out,k.total_in+=W,k.total_out+=he,_.total+=he,_.wrap&&he&&(k.adler=_.check=_.flags?a(_.check,F,he,k.next_out-he):s(_.check,F,he,k.next_out-he)),k.data_type=_.bits+(_.last?64:0)+(_.mode===12?128:0)+(_.mode===20||_.mode===15?256:0),(W==0&&he===0||L===4)&&q===f&&(q=-5),q)},i.inflateEnd=function(k){if(!k||!k.state)return h;var L=k.state;return L.window&&(L.window=null),k.state=null,f},i.inflateGetHeader=function(k,L){var _;return k&&k.state?(2&(_=k.state).wrap)==0?h:((_.head=L).done=!1,f):h},i.inflateSetDictionary=function(k,L){var _,O=L.length;return k&&k.state?(_=k.state).wrap!==0&&_.mode!==11?h:_.mode===11&&s(1,L,O,0)!==_.check?-3:R(k,L,O,O)?(_.mode=31,-4):(_.havedict=1,f):h},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){"use strict";var o=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(u,d,f,h,p,m,g,y){var v,b,w,x,A,T,I,P,C,R=y.bits,k=0,L=0,_=0,O=0,F=0,B=0,U=0,M=0,z=0,Z=0,Q=null,W=0,he=new o.Buf16(16),K=new o.Buf16(16),X=null,ee=0;for(k=0;k<=15;k++)he[k]=0;for(L=0;L<h;L++)he[d[f+L]]++;for(F=R,O=15;1<=O&&he[O]===0;O--);if(O<F&&(F=O),O===0)return p[m++]=20971520,p[m++]=20971520,y.bits=1,0;for(_=1;_<O&&he[_]===0;_++);for(F<_&&(F=_),k=M=1;k<=15;k++)if(M<<=1,(M-=he[k])<0)return-1;if(0<M&&(u===0||O!==1))return-1;for(K[1]=0,k=1;k<15;k++)K[k+1]=K[k]+he[k];for(L=0;L<h;L++)d[f+L]!==0&&(g[K[d[f+L]]++]=L);if(T=u===0?(Q=X=g,19):u===1?(Q=s,W-=257,X=a,ee-=257,256):(Q=l,X=c,-1),k=_,A=m,U=L=Z=0,w=-1,x=(z=1<<(B=F))-1,u===1&&852<z||u===2&&592<z)return 1;for(;;){for(I=k-U,C=g[L]<T?(P=0,g[L]):g[L]>T?(P=X[ee+g[L]],Q[W+g[L]]):(P=96,0),v=1<<k-U,_=b=1<<B;p[A+(Z>>U)+(b-=v)]=I<<24|P<<16|C|0,b!==0;);for(v=1<<k-1;Z&v;)v>>=1;if(v!==0?(Z&=v-1,Z+=v):Z=0,L++,--he[k]==0){if(k===O)break;k=d[f+g[L]]}if(F<k&&(Z&x)!==w){for(U===0&&(U=F),A+=_,M=1<<(B=k-U);B+U<O&&!((M-=he[B+U])<=0);)B++,M<<=1;if(z+=1<<B,u===1&&852<z||u===2&&592<z)return 1;p[w=Z&x]=F<<24|B<<16|A-m|0}}return Z!==0&&(p[A+Z]=k-U<<24|4194304),y.bits=F,0}},{"../utils/common":41}],51:[function(n,r,i){"use strict";r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){"use strict";var o=n("../utils/common"),s=0,a=1;function l(re){for(var te=re.length;0<=--te;)re[te]=0}var c=0,u=29,d=256,f=d+1+u,h=30,p=19,m=2*f+1,g=15,y=16,v=7,b=256,w=16,x=17,A=18,T=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],I=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],P=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],R=new Array(2*(f+2));l(R);var k=new Array(2*h);l(k);var L=new Array(512);l(L);var _=new Array(256);l(_);var O=new Array(u);l(O);var F,B,U,M=new Array(h);function z(re,te,fe,de,ue){this.static_tree=re,this.extra_bits=te,this.extra_base=fe,this.elems=de,this.max_length=ue,this.has_stree=re&&re.length}function Z(re,te){this.dyn_tree=re,this.max_code=0,this.stat_desc=te}function Q(re){return re<256?L[re]:L[256+(re>>>7)]}function W(re,te){re.pending_buf[re.pending++]=255&te,re.pending_buf[re.pending++]=te>>>8&255}function he(re,te,fe){re.bi_valid>y-fe?(re.bi_buf|=te<<re.bi_valid&65535,W(re,re.bi_buf),re.bi_buf=te>>y-re.bi_valid,re.bi_valid+=fe-y):(re.bi_buf|=te<<re.bi_valid&65535,re.bi_valid+=fe)}function K(re,te,fe){he(re,fe[2*te],fe[2*te+1])}function X(re,te){for(var fe=0;fe|=1&re,re>>>=1,fe<<=1,0<--te;);return fe>>>1}function ee(re,te,fe){var de,ue,ie=new Array(g+1),ce=0;for(de=1;de<=g;de++)ie[de]=ce=ce+fe[de-1]<<1;for(ue=0;ue<=te;ue++){var Te=re[2*ue+1];Te!==0&&(re[2*ue]=X(ie[Te]++,Te))}}function be(re){var te;for(te=0;te<f;te++)re.dyn_ltree[2*te]=0;for(te=0;te<h;te++)re.dyn_dtree[2*te]=0;for(te=0;te<p;te++)re.bl_tree[2*te]=0;re.dyn_ltree[2*b]=1,re.opt_len=re.static_len=0,re.last_lit=re.matches=0}function xe(re){8<re.bi_valid?W(re,re.bi_buf):0<re.bi_valid&&(re.pending_buf[re.pending++]=re.bi_buf),re.bi_buf=0,re.bi_valid=0}function pe(re,te,fe,de){var ue=2*te,ie=2*fe;return re[ue]<re[ie]||re[ue]===re[ie]&&de[te]<=de[fe]}function ke(re,te,fe){for(var de=re.heap[fe],ue=fe<<1;ue<=re.heap_len&&(ue<re.heap_len&&pe(te,re.heap[ue+1],re.heap[ue],re.depth)&&ue++,!pe(te,de,re.heap[ue],re.depth));)re.heap[fe]=re.heap[ue],fe=ue,ue<<=1;re.heap[fe]=de}function V(re,te,fe){var de,ue,ie,ce,Te=0;if(re.last_lit!==0)for(;de=re.pending_buf[re.d_buf+2*Te]<<8|re.pending_buf[re.d_buf+2*Te+1],ue=re.pending_buf[re.l_buf+Te],Te++,de===0?K(re,ue,te):(K(re,(ie=_[ue])+d+1,te),(ce=T[ie])!==0&&he(re,ue-=O[ie],ce),K(re,ie=Q(--de),fe),(ce=I[ie])!==0&&he(re,de-=M[ie],ce)),Te<re.last_lit;);K(re,b,te)}function D(re,te){var fe,de,ue,ie=te.dyn_tree,ce=te.stat_desc.static_tree,Te=te.stat_desc.has_stree,ye=te.stat_desc.elems,le=-1;for(re.heap_len=0,re.heap_max=m,fe=0;fe<ye;fe++)ie[2*fe]!==0?(re.heap[++re.heap_len]=le=fe,re.depth[fe]=0):ie[2*fe+1]=0;for(;re.heap_len<2;)ie[2*(ue=re.heap[++re.heap_len]=le<2?++le:0)]=1,re.depth[ue]=0,re.opt_len--,Te&&(re.static_len-=ce[2*ue+1]);for(te.max_code=le,fe=re.heap_len>>1;1<=fe;fe--)ke(re,ie,fe);for(ue=ye;fe=re.heap[1],re.heap[1]=re.heap[re.heap_len--],ke(re,ie,1),de=re.heap[1],re.heap[--re.heap_max]=fe,re.heap[--re.heap_max]=de,ie[2*ue]=ie[2*fe]+ie[2*de],re.depth[ue]=(re.depth[fe]>=re.depth[de]?re.depth[fe]:re.depth[de])+1,ie[2*fe+1]=ie[2*de+1]=ue,re.heap[1]=ue++,ke(re,ie,1),2<=re.heap_len;);re.heap[--re.heap_max]=re.heap[1],(function(Ae,_e){var Ue,st,me,Ie,Re,ve,Se=_e.dyn_tree,ne=_e.max_code,Oe=_e.stat_desc.static_tree,Y=_e.stat_desc.has_stree,we=_e.stat_desc.extra_bits,Fe=_e.stat_desc.extra_base,ae=_e.stat_desc.max_length,et=0;for(Ie=0;Ie<=g;Ie++)Ae.bl_count[Ie]=0;for(Se[2*Ae.heap[Ae.heap_max]+1]=0,Ue=Ae.heap_max+1;Ue<m;Ue++)ae<(Ie=Se[2*Se[2*(st=Ae.heap[Ue])+1]+1]+1)&&(Ie=ae,et++),Se[2*st+1]=Ie,ne<st||(Ae.bl_count[Ie]++,Re=0,Fe<=st&&(Re=we[st-Fe]),ve=Se[2*st],Ae.opt_len+=ve*(Ie+Re),Y&&(Ae.static_len+=ve*(Oe[2*st+1]+Re)));if(et!==0){do{for(Ie=ae-1;Ae.bl_count[Ie]===0;)Ie--;Ae.bl_count[Ie]--,Ae.bl_count[Ie+1]+=2,Ae.bl_count[ae]--,et-=2}while(0<et);for(Ie=ae;Ie!==0;Ie--)for(st=Ae.bl_count[Ie];st!==0;)ne<(me=Ae.heap[--Ue])||(Se[2*me+1]!==Ie&&(Ae.opt_len+=(Ie-Se[2*me+1])*Se[2*me],Se[2*me+1]=Ie),st--)}})(re,te),ee(ie,le,re.bl_count)}function N(re,te,fe){var de,ue,ie=-1,ce=te[1],Te=0,ye=7,le=4;for(ce===0&&(ye=138,le=3),te[2*(fe+1)+1]=65535,de=0;de<=fe;de++)ue=ce,ce=te[2*(de+1)+1],++Te<ye&&ue===ce||(Te<le?re.bl_tree[2*ue]+=Te:ue!==0?(ue!==ie&&re.bl_tree[2*ue]++,re.bl_tree[2*w]++):Te<=10?re.bl_tree[2*x]++:re.bl_tree[2*A]++,ie=ue,le=(Te=0)===ce?(ye=138,3):ue===ce?(ye=6,3):(ye=7,4))}function q(re,te,fe){var de,ue,ie=-1,ce=te[1],Te=0,ye=7,le=4;for(ce===0&&(ye=138,le=3),de=0;de<=fe;de++)if(ue=ce,ce=te[2*(de+1)+1],!(++Te<ye&&ue===ce)){if(Te<le)for(;K(re,ue,re.bl_tree),--Te!=0;);else ue!==0?(ue!==ie&&(K(re,ue,re.bl_tree),Te--),K(re,w,re.bl_tree),he(re,Te-3,2)):Te<=10?(K(re,x,re.bl_tree),he(re,Te-3,3)):(K(re,A,re.bl_tree),he(re,Te-11,7));ie=ue,le=(Te=0)===ce?(ye=138,3):ue===ce?(ye=6,3):(ye=7,4)}}l(M);var oe=!1;function J(re,te,fe,de){he(re,(c<<1)+(de?1:0),3),(function(ue,ie,ce,Te){xe(ue),Te&&(W(ue,ce),W(ue,~ce)),o.arraySet(ue.pending_buf,ue.window,ie,ce,ue.pending),ue.pending+=ce})(re,te,fe,!0)}i._tr_init=function(re){oe||((function(){var te,fe,de,ue,ie,ce=new Array(g+1);for(ue=de=0;ue<u-1;ue++)for(O[ue]=de,te=0;te<1<<T[ue];te++)_[de++]=ue;for(_[de-1]=ue,ue=ie=0;ue<16;ue++)for(M[ue]=ie,te=0;te<1<<I[ue];te++)L[ie++]=ue;for(ie>>=7;ue<h;ue++)for(M[ue]=ie<<7,te=0;te<1<<I[ue]-7;te++)L[256+ie++]=ue;for(fe=0;fe<=g;fe++)ce[fe]=0;for(te=0;te<=143;)R[2*te+1]=8,te++,ce[8]++;for(;te<=255;)R[2*te+1]=9,te++,ce[9]++;for(;te<=279;)R[2*te+1]=7,te++,ce[7]++;for(;te<=287;)R[2*te+1]=8,te++,ce[8]++;for(ee(R,f+1,ce),te=0;te<h;te++)k[2*te+1]=5,k[2*te]=X(te,5);F=new z(R,T,d+1,f,g),B=new z(k,I,0,h,g),U=new z(new Array(0),P,0,p,v)})(),oe=!0),re.l_desc=new Z(re.dyn_ltree,F),re.d_desc=new Z(re.dyn_dtree,B),re.bl_desc=new Z(re.bl_tree,U),re.bi_buf=0,re.bi_valid=0,be(re)},i._tr_stored_block=J,i._tr_flush_block=function(re,te,fe,de){var ue,ie,ce=0;0<re.level?(re.strm.data_type===2&&(re.strm.data_type=(function(Te){var ye,le=4093624447;for(ye=0;ye<=31;ye++,le>>>=1)if(1&le&&Te.dyn_ltree[2*ye]!==0)return s;if(Te.dyn_ltree[18]!==0||Te.dyn_ltree[20]!==0||Te.dyn_ltree[26]!==0)return a;for(ye=32;ye<d;ye++)if(Te.dyn_ltree[2*ye]!==0)return a;return s})(re)),D(re,re.l_desc),D(re,re.d_desc),ce=(function(Te){var ye;for(N(Te,Te.dyn_ltree,Te.l_desc.max_code),N(Te,Te.dyn_dtree,Te.d_desc.max_code),D(Te,Te.bl_desc),ye=p-1;3<=ye&&Te.bl_tree[2*C[ye]+1]===0;ye--);return Te.opt_len+=3*(ye+1)+5+5+4,ye})(re),ue=re.opt_len+3+7>>>3,(ie=re.static_len+3+7>>>3)<=ue&&(ue=ie)):ue=ie=fe+5,fe+4<=ue&&te!==-1?J(re,te,fe,de):re.strategy===4||ie===ue?(he(re,2+(de?1:0),3),V(re,R,k)):(he(re,4+(de?1:0),3),(function(Te,ye,le,Ae){var _e;for(he(Te,ye-257,5),he(Te,le-1,5),he(Te,Ae-4,4),_e=0;_e<Ae;_e++)he(Te,Te.bl_tree[2*C[_e]+1],3);q(Te,Te.dyn_ltree,ye-1),q(Te,Te.dyn_dtree,le-1)})(re,re.l_desc.max_code+1,re.d_desc.max_code+1,ce+1),V(re,re.dyn_ltree,re.dyn_dtree)),be(re),de&&xe(re)},i._tr_tally=function(re,te,fe){return re.pending_buf[re.d_buf+2*re.last_lit]=te>>>8&255,re.pending_buf[re.d_buf+2*re.last_lit+1]=255&te,re.pending_buf[re.l_buf+re.last_lit]=255&fe,re.last_lit++,te===0?re.dyn_ltree[2*fe]++:(re.matches++,te--,re.dyn_ltree[2*(_[fe]+d+1)]++,re.dyn_dtree[2*Q(te)]++),re.last_lit===re.lit_bufsize-1},i._tr_align=function(re){he(re,2,3),K(re,b,R),(function(te){te.bi_valid===16?(W(te,te.bi_buf),te.bi_buf=0,te.bi_valid=0):8<=te.bi_valid&&(te.pending_buf[te.pending++]=255&te.bi_buf,te.bi_buf>>=8,te.bi_valid-=8)})(re)}},{"../utils/common":41}],53:[function(n,r,i){"use strict";r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(o){(function(s,a){"use strict";if(!s.setImmediate){var l,c,u,d,f=1,h={},p=!1,m=s.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(s);g=g&&g.setTimeout?g:s,l={}.toString.call(s.process)==="[object process]"?function(w){process.nextTick(function(){v(w)})}:(function(){if(s.postMessage&&!s.importScripts){var w=!0,x=s.onmessage;return s.onmessage=function(){w=!1},s.postMessage("","*"),s.onmessage=x,w}})()?(d="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",b,!1):s.attachEvent("onmessage",b),function(w){s.postMessage(d+w,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(w){v(w.data)},function(w){u.port2.postMessage(w)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(w){var x=m.createElement("script");x.onreadystatechange=function(){v(w),x.onreadystatechange=null,c.removeChild(x),x=null},c.appendChild(x)}):function(w){setTimeout(v,0,w)},g.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var x=new Array(arguments.length-1),A=0;A<x.length;A++)x[A]=arguments[A+1];return h[f]={callback:w,args:x},l(f),f++},g.clearImmediate=y}function y(w){delete h[w]}function v(w){if(p)setTimeout(v,0,w);else{var x=h[w];if(x){p=!0;try{(function(A){var T=A.callback,I=A.args;switch(I.length){case 0:T();break;case 1:T(I[0]);break;case 2:T(I[0],I[1]);break;case 3:T(I[0],I[1],I[2]);break;default:T.apply(a,I)}})(x)}finally{y(w),p=!1}}}}function b(w){w.source===s&&typeof w.data=="string"&&w.data.indexOf(d)===0&&v(+w.data.slice(d.length))}})(typeof self>"u"?o===void 0?this:o:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})),l_e=Kc(a_e(),1);const c_e=e=>/\.xml$|\.rels$/i.test(e);function TZt(e){if(e.length>=2){const n=e[0],r=e[1];if(n===255&&r===254)return"utf-16le";if(n===254&&r===255)return"utf-16be"}let t=0;for(let n=0;n<Math.min(64,e.length);n++)e[n]===0&&t++;return t>16?"utf-16le":"utf-8"}function u_e(e){return e&&e.charCodeAt(0)===65279?e.slice(1):e}function d_e(e){if(typeof e=="string")return u_e(e);let t=null;if(e&&typeof e=="object"&&(e instanceof Uint8Array?t=e:typeof Buffer<"u"&&Buffer.isBuffer&&Buffer.isBuffer(e)?t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):ArrayBuffer.isView&&ArrayBuffer.isView(e)?t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.constructor&&(e instanceof ArrayBuffer||e.constructor.name==="ArrayBuffer")&&(t=new Uint8Array(e))),!t)throw new Error("Unsupported content type for XML");const n=TZt(t);let r=new TextDecoder(n).decode(t);return r=u_e(r),n!=="utf-8"&&(r=r.replace(/(<\?xml\b[^?]*?)\bencoding\s*=\s*["'][^"']*["']/i,'$1encoding="UTF-8"')),r}const Tj=[{zipPath:"word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"},{zipPath:"docProps/core.xml",contentType:"application/vnd.openxmlformats-package.core-properties+xml",relationshipType:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"},{zipPath:"docProps/app.xml",contentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"},{zipPath:"docProps/custom.xml",contentType:"application/vnd.openxmlformats-officedocument.custom-properties+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"}];var IZt=Kc(Mm(),1),kZt="SD_OPC_QUOT",EZt=/SD_OPC_QUOT/g;function CZt(e){return String(e).replace(/"/g,kZt).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(EZt,""")}function f_e(e){return IZt.js2xml(e,{spaces:0,attributeValueFn:CZt})}var _Zt=Kc(Mm(),1),PZt="http://schemas.openxmlformats.org/package/2006/relationships";function Ij(e,t,n){if(n&&Object.prototype.hasOwnProperty.call(n,e))return n[e];if(t)return Array.isArray(t)?t.find(r=>r.name===e)?.content:t[e]}function RZt(e,t,n){return Ij(e,t,n)!=null}function h_e(e){try{return _Zt.xml2js(e,{compact:!1})}catch{return null}}function p_e(e){return f_e(e)}function m_e(e,t){return e?.elements?.find(n=>n.name?(n.name.includes(":")?n.name.split(":").pop():n.name)===t:!1)}function g_e(){return{declaration:{attributes:{version:"1.0",encoding:"UTF-8",standalone:"yes"}},elements:[{type:"element",name:"Relationships",attributes:{xmlns:PZt},elements:[]}]}}function LZt(e){let t=0;for(const n of e.elements||[]){const r=n.attributes?.Id;if(!r)continue;const i=r.match(/^rId(\d+)$/);i&&(t=Math.max(t,parseInt(i[1],10)))}return t}function NZt(e,t){e.elements||(e.elements=[]);const n=new Map;for(const o of Tj)n.set(`/${o.zipPath}`,o);const r=new Map;for(let o=0;o<e.elements.length;o++){const s=e.elements[o];if(s.name!=="Override")continue;const a=s.attributes?.PartName;!a||!n.has(a)||(r.has(a)||r.set(a,[]),r.get(a).push(o))}const i=new Set;for(const[o,s]of n){const a=t.has(s.zipPath),l=r.get(o)||[];if(!a){for(const c of l)i.add(c);continue}if(l.length===0)e.elements.push({type:"element",name:"Override",attributes:{PartName:o,ContentType:s.contentType}});else{e.elements[l[0]].attributes.ContentType=s.contentType;for(let c=1;c<l.length;c++)i.add(l[c])}}if(i.size>0){const o=[...i].sort((s,a)=>a-s);for(const s of o)e.elements.splice(s,1)}}function MZt(e,t){e.elements||(e.elements=[]);const n=new Map;for(const s of Tj)n.set(s.relationshipType,s);const r=new Map;for(let s=0;s<e.elements.length;s++){const a=e.elements[s];if(a.name!=="Relationship")continue;const l=a.attributes?.Type;!l||!n.has(l)||(r.has(l)||r.set(l,[]),r.get(l).push({index:s,element:a}))}const i=new Set;let o=LZt(e);for(const[s,a]of n){const l=t.has(a.zipPath),c=r.get(s)||[];if(!l){for(const{index:u}of c)i.add(u);continue}if(c.length===0)o++,e.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${o}`,Type:s,Target:a.zipPath}});else{c[0].element.attributes.Target=a.zipPath;for(let u=1;u<c.length;u++)i.add(c[u].index)}}if(i.size>0){const s=[...i].sort((a,l)=>l-a);for(const a of s)e.elements.splice(a,1)}}function y_e({baseFiles:e,updatedDocs:t}){const n=new Set;for(const c of Tj)RZt(c.zipPath,e,t)&&n.add(c.zipPath);const r=Ij("[Content_Types].xml",e,t);if(r==null)throw new Error("syncPackageMetadata: [Content_Types].xml is missing from the package. Cannot safely reconcile package metadata without an existing content types file.");const i=h_e(r);if(!i)throw new Error("syncPackageMetadata: [Content_Types].xml could not be parsed as valid XML. Cannot safely reconcile package metadata from a malformed content types file.");const o=m_e(i,"Types");if(!o)throw new Error("syncPackageMetadata: [Content_Types].xml does not contain a <Types> root element.");NZt(o,n);const s=Ij("_rels/.rels",e,t);let a;if(s==null)a=g_e();else if(a=h_e(s),!a)throw new Error("syncPackageMetadata: _rels/.rels could not be parsed as valid XML. Cannot safely reconcile root relationships from a malformed rels file.");let l=m_e(a,"Relationships");return l||(a=g_e(),l=a.elements[0]),MZt(l,n),{contentTypesXml:p_e(i),relsXml:p_e(a)}}var DZt=Kc(Mm(),1);const b_e=[{zipPath:"word/numbering.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",relTarget:"numbering.xml"}];function OZt(e){let t=0;for(const n of e){const r=n.attributes?.Id?.match(/^rId(\d+)$/);r&&(t=Math.max(t,Number(r[1])))}return t}function FZt(e,t){if(!e)return e;let n;try{n=DZt.xml2js(e,{compact:!1})}catch{return e}const r=n?.elements?.find(s=>s.name==="Relationships");if(!r)return e;r.elements||(r.elements=[]);let i=!1,o=OZt(r.elements);for(const s of b_e)t(s.zipPath)&&(r.elements.some(a=>a.attributes?.Type===s.relationshipType)||(o++,r.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${o}`,Type:s.relationshipType,Target:s.relTarget}}),i=!0));return i?f_e(n):e}var BZt=vs({detectContainerType:()=>kj},1);function v_e(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function kj(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);return v_e(t,w_e)?"zip":v_e(t,A_e)?"cfb":"unknown"}var w_e,A_e,x_e=Le((()=>{w_e=[80,75,3,4],A_e=[208,207,17,224,161,177,26,225]}));function S_e(e){const t=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}function HZt(e,t){return(e+1)*t}function wE(e,t){return e.getUint16(t,!0)}function Pl(e,t){return e.getUint32(t,!0)}function zZt(e,t){const n=BigInt(e.getUint32(t,!0));return BigInt(e.getUint32(t+4,!0))<<32n|n}function UZt(e){return T_e.decode(e).replace(/\u0000+$/g,"")}var Ej,VZt,WZt,GZt,jZt,qZt,YZt,Cj,KZt,XZt,AE,JZt,ZZt,QZt,T_e,$Zt=Le((()=>{Ej=new Uint8Array([208,207,17,224,161,177,26,225]),VZt=512,WZt=128,GZt=109,jZt=512,qZt=4096,YZt=4294967295,Cj=4294967294,KZt=4294967292,XZt=4294967295,AE={STORAGE:1,STREAM:2,ROOT:5},JZt=65534,ZZt=3,QZt=4,T_e=new TextDecoder("utf-16le")}));function xE(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function I_e(e,t,n,r){if(t<0||n<0||t+n>e.length)throw new Error(`CFB ${r} exceeds available data`)}function eQt(e){if(e.length<512)throw new Error(`CFB header is truncated (${e.length} bytes)`);for(let c=0;c<Ej.length;c++)if(e[c]!==Ej[c])throw new Error("Invalid CFB signature");const t=xE(e),n=wE(t,26),r=wE(t,28),i=wE(t,30),o=wE(t,32),s=1<<i,a=1<<o;if(r!==65534)throw new Error(`Unsupported CFB byte order: 0x${r.toString(16)}`);if(!(n===3&&s===512||n===4&&s===4096))throw new Error(`Unsupported CFB major version ${n} with sector size ${s}`);const l=[];for(let c=0;c<109;c++){const u=Pl(t,76+c*4);u!==4294967295&&l.push(u)}return{sectorSize:s,miniSectorSize:a,numberOfFatSectors:Pl(t,44),firstDirectorySector:Pl(t,48),miniStreamCutoffSize:Pl(t,56),firstMiniFatSector:Pl(t,60),numberOfMiniFatSectors:Pl(t,64),firstDifatSector:Pl(t,68),numberOfDifatSectors:Pl(t,72),difatEntries:l}}function _j(e,t,n){if(n>=4294967292)throw new Error(`Invalid sector id 0x${n.toString(16)}`);const r=HZt(n,t.sectorSize);return I_e(e,r,t.sectorSize,`sector ${n}`),e.subarray(r,r+t.sectorSize)}function tQt(e,t){const n=[...t.difatEntries];let r=t.firstDifatSector;for(let i=0;i<t.numberOfDifatSectors&&!(r===4294967294||r===4294967295);i++){const o=xE(_j(e,t,r)),s=t.sectorSize/4-1;for(let a=0;a<s;a++){const l=Pl(o,a*4);l!==4294967295&&n.push(l)}r=Pl(o,t.sectorSize-4)}if(n.length<t.numberOfFatSectors)throw new Error(`CFB DIFAT only exposed ${n.length} FAT sectors, expected ${t.numberOfFatSectors}`);return n.slice(0,t.numberOfFatSectors)}function nQt(e,t){const n=tQt(e,t),r=[];for(const i of n){const o=xE(_j(e,t,i)),s=t.sectorSize/4;for(let a=0;a<s;a++)r.push(Pl(o,a*4))}return r}function hD(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const i=[],o=new Set;let s=r;for(;s!==Cj;){if(o.has(s))throw new Error(`CFB sector chain loop detected at sector ${s}`);if(s>=n.length)throw new Error(`CFB sector ${s} is out of FAT bounds`);o.add(s),i.push(_j(e,t,s));const a=n[s];if(a==null)throw new Error(`CFB FAT missing next sector for sector ${s}`);s=a}return S_e(i)}function rQt(e,t){const n=zZt(e,t);if(n>BigInt(Number.MAX_SAFE_INTEGER))throw new Error(`CFB stream is too large to fit in a JavaScript number: ${n.toString()}`);return Number(n)}function iQt(e){const t=[];for(let n=0;n+128<=e.length;n+=128){const r=e.subarray(n,n+128),i=xE(r),o=wE(i,64),s=r.subarray(0,Math.max(0,Math.min(o,64)-2));t.push({name:UZt(s),objectType:r[66],leftSiblingId:Pl(i,68),rightSiblingId:Pl(i,72),childId:Pl(i,76),startSector:Pl(i,116),streamSize:rQt(i,120)})}return t}function Pj(e,t,n,r=new Set){if(t===4294967295)return!1;if(t>=e.length)throw new Error(`CFB directory entry id ${t} is out of bounds`);if(r.has(t))throw new Error(`CFB directory tree loop detected at entry id ${t}`);r.add(t);const i=e[t];return!!(Pj(e,i.leftSiblingId,n,r)||n(i)===!0||Pj(e,i.rightSiblingId,n,r))}function oQt(e,t){const n=t.split("/").map(i=>i.trim()).filter(Boolean);let r=e[0];for(const i of n){if(r.objectType!==AE.ROOT&&r.objectType!==AE.STORAGE)return null;let o=null;if(Pj(e,r.childId,s=>s.name.toLowerCase()===i.toLowerCase()?(o=s,!0):!1),!o)return null;r=o}return r}function sQt(e,t,n,r){return e.streamSize===0||e.startSector===4294967294?new Uint8Array(0):hD(t,n,r,e.startSector).subarray(0,e.streamSize)}function aQt(e,t,n){if(t.numberOfMiniFatSectors===0||t.firstMiniFatSector===4294967294)return[];const r=hD(e,t,n,t.firstMiniFatSector),i=xE(r),o=Math.floor(r.length/4),s=[];for(let a=0;a<o;a++)s.push(Pl(i,a*4));return s}function lQt(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const i=[],o=new Set;let s=r;for(;s!==Cj;){if(o.has(s))throw new Error(`CFB mini sector chain loop detected at mini sector ${s}`);if(s>=t.length)throw new Error(`CFB mini sector ${s} is out of MiniFAT bounds`);o.add(s);const a=s*n;I_e(e,a,n,`mini sector ${s}`),i.push(e.subarray(a,a+n));const l=t[s];if(l==null)throw new Error(`CFB MiniFAT missing next sector for mini sector ${s}`);s=l}return S_e(i)}function cQt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e),n=eQt(t),r=nQt(t,n),i=iQt(hD(t,n,r,n.firstDirectorySector));if(i.length===0||i[0].objectType!==AE.ROOT)throw new Error("CFB root directory entry is missing");const o=i[0],s=aQt(t,n,r),a=sQt(o,t,n,r);return{getStream(l){const c=oQt(i,l);return!c||c.objectType!==AE.STREAM?null:c.streamSize<n.miniStreamCutoffSize?lQt(a,s,n.miniSectorSize,c.startSector).subarray(0,c.streamSize):hD(t,n,r,c.startSector).subarray(0,c.streamSize)}}}var uQt=Le((()=>{$Zt()}));function dQt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);let n;try{n=cQt(t)}catch(o){throw new $o(ma.DECRYPTION_FAILED,"Failed to parse OLE/CFB container",o instanceof Error?o:void 0)}const r=n.getStream("/EncryptionInfo");if(!r)throw new $o(ma.DECRYPTION_FAILED,"CFB container missing EncryptionInfo stream");const i=n.getStream("/EncryptedPackage");if(!i)throw new $o(ma.DECRYPTION_FAILED,"CFB container missing EncryptedPackage stream");return{encryptionInfo:r,encryptedPackage:i}}var fQt=Le((()=>{uQt(),yE()}));function k_e(e,t){return e[t]|e[t+1]<<8}function Rj(e,t){const n=new RegExp(`<(?:\\w+:)?${t}\\b([^>]*)/?>`),r=e.match(n);if(!r)return null;const i={},o=/(\w+)="([^"]*)"/g;let s;for(;(s=o.exec(r[1]))!==null;)i[s[1]]=s[2];return i}function hQt(e){if(typeof atob=="function"){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}return new Uint8Array(Buffer.from(e,"base64"))}function qA(e,t,n){const r=e?.[t];if(r==null)throw new $o(ma.DECRYPTION_FAILED,`Missing required attribute "${t}" on <${n}>`);return r}function yb(e,t,n){return hQt(qA(e,t,n))}function YA(e,t,n){const r=parseInt(qA(e,t,n),10);if(Number.isNaN(r))throw new $o(ma.DECRYPTION_FAILED,`Invalid integer for attribute "${t}" on <${n}>`);return r}function pQt(e){const t=new TextDecoder("utf-8").decode(e),n=Rj(t,"keyData"),r=Rj(t,"dataIntegrity"),i=Rj(t,"encryptedKey");return{keySalt:yb(n,"saltValue","keyData"),keyBits:YA(n,"keyBits","keyData"),hashAlgorithm:qA(n,"hashAlgorithm","keyData"),hashSize:YA(n,"hashSize","keyData"),blockSize:YA(n,"blockSize","keyData"),cipherAlgorithm:qA(n,"cipherAlgorithm","keyData"),cipherChaining:qA(n,"cipherChaining","keyData"),spinCount:YA(i,"spinCount","encryptedKey"),passwordSalt:yb(i,"saltValue","encryptedKey"),passwordHashAlgorithm:qA(i,"hashAlgorithm","encryptedKey"),passwordKeyBits:YA(i,"keyBits","encryptedKey"),passwordBlockSize:YA(i,"blockSize","encryptedKey"),encryptedVerifierHashInput:yb(i,"encryptedVerifierHashInput","encryptedKey"),encryptedVerifierHashValue:yb(i,"encryptedVerifierHashValue","encryptedKey"),encryptedKeyValue:yb(i,"encryptedKeyValue","encryptedKey"),encryptedHmacKey:yb(r,"encryptedHmacKey","dataIntegrity"),encryptedHmacValue:yb(r,"encryptedHmacValue","dataIntegrity")}}function mQt(e){if(e.length<pD)throw new $o(ma.DECRYPTION_FAILED,`EncryptionInfo too short: ${e.length} bytes (minimum ${pD})`);const t=k_e(e,0),n=k_e(e,2);if(t===E_e&&n===C_e)return{type:"agile",params:pQt(e.subarray(pD))};throw(t===__e||t===P_e)&&n===R_e?new $o(ma.ENCRYPTION_UNSUPPORTED,"Standard Encryption (Office 2007) is not yet supported. Only Agile Encryption (Office 2010+) is supported."):t<=2?new $o(ma.ENCRYPTION_UNSUPPORTED,"Legacy RC4 encryption is not supported. Only Agile Encryption (Office 2010+) is supported."):new $o(ma.ENCRYPTION_UNSUPPORTED,`Unrecognized EncryptionInfo version=${t} reserved=${n}`)}var E_e,C_e,__e,P_e,R_e,pD,gQt=Le((()=>{yE(),E_e=4,C_e=4,__e=3,P_e=4,R_e=3,pD=8}));function Lj(){const e=globalThis.crypto?.subtle;if(!e)throw new $o(ma.DECRYPTION_FAILED,"Web Crypto API (SubtleCrypto) is not available in this environment");return e}function SE(e){const t={SHA1:"SHA-1","SHA-1":"SHA-1",SHA256:"SHA-256","SHA-256":"SHA-256",SHA384:"SHA-384","SHA-384":"SHA-384",SHA512:"SHA-512","SHA-512":"SHA-512"}[e];if(!t)throw new $o(ma.DECRYPTION_FAILED,`Unsupported hash algorithm: ${e}`);return t}function yQt(e){const t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}function KA(...e){const t=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}function L_e(e){const t=new Uint8Array(4);return t[0]=e&255,t[1]=e>>>8&255,t[2]=e>>>16&255,t[3]=e>>>24&255,t}function XA(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}async function JA(e,t){const n=await Lj().digest(e,XA(t));return new Uint8Array(n)}async function ZA(e,t,n){const r=Lj(),i=16,o=await r.importKey("raw",XA(e),{name:"AES-CBC"},!1,["encrypt","decrypt"]),s=n.subarray(n.length-i),a=new Uint8Array(i);a.fill(i);const l=new Uint8Array(await r.encrypt({name:"AES-CBC",iv:XA(s)},o,a)).subarray(0,i),c=new Uint8Array(n.length+i);c.set(n),c.set(l,n.length);const u=await r.decrypt({name:"AES-CBC",iv:XA(t)},o,c);return new Uint8Array(u).subarray(0,n.length)}async function Nj(e,t,n,r,i,o){const s=SE(i);let a=await JA(s,KA(t,yQt(e)));for(let d=0;d<n;d++)a=await JA(s,KA(L_e(d),a));const l=await JA(s,KA(a,o)),c=r/8;if(l.length>=c)return l.subarray(0,c);const u=new Uint8Array(c);return u.set(l),u.fill(54,l.length),u}async function Mj(e,t,n,r){let i;if(n?i=await JA(SE(e),KA(t,n)):i=t,i.length>=r)return i.subarray(0,r);const o=new Uint8Array(r);return o.set(i),o.fill(54,i.length),o}async function bQt(e,t){const{passwordSalt:n,spinCount:r,passwordHashAlgorithm:i,passwordKeyBits:o,passwordBlockSize:s}=t,a=await Nj(e,n,r,o,i,M_e),l=await Nj(e,n,r,o,i,D_e),c=await Nj(e,n,r,o,i,O_e),u=await Mj(i,n,void 0,s),d=await ZA(a,u,t.encryptedVerifierHashInput),f=await ZA(l,u,t.encryptedVerifierHashValue),h=await JA(SE(i),d);if(!N_e(h,f.subarray(0,h.length)))throw new $o(ma.PASSWORD_INVALID,"The password is incorrect");return ZA(c,u,t.encryptedKeyValue)}function N_e(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function vQt(e,t,n){const{keySalt:r,hashAlgorithm:i,blockSize:o}=t,s=SE(i);if(n.length<Dj)throw new $o(ma.DECRYPTION_FAILED,"EncryptedPackage too short to contain size header");const a=n[0]|n[1]<<8|n[2]<<16|n[3]<<24>>>0,l=n.subarray(Dj),c=Math.ceil(l.length/mD),u=[];for(let d=0;d<c;d++){const f=d*mD,h=Math.min(f+mD,l.length),p=l.subarray(f,h),m=await JA(s,KA(r,L_e(d))),g=await ZA(e,m.length>=o?m.subarray(0,o):m,p);u.push(g)}return KA(...u).subarray(0,a)}async function wQt(e,t,n){const{keySalt:r,hashAlgorithm:i,blockSize:o,hashSize:s}=t,a=SE(i),l=Lj(),c=(await ZA(e,await Mj(i,r,F_e,o),t.encryptedHmacKey)).subarray(0,s),u=await ZA(e,await Mj(i,r,B_e,o),t.encryptedHmacValue),d=await l.importKey("raw",XA(c),{name:"HMAC",hash:a},!1,["sign"]),f=new Uint8Array(await l.sign("HMAC",d,XA(n)));if(!N_e(f,u.subarray(0,f.length)))throw new $o(ma.DECRYPTION_FAILED,"Data integrity check failed — the encrypted package may be corrupt or tampered with")}async function AQt(e,t,n){try{const r=await bQt(e,t);return await wQt(r,t,n),await vQt(r,t,n)}catch(r){throw r instanceof $o?r:new $o(ma.DECRYPTION_FAILED,"Decryption failed unexpectedly",r instanceof Error?r:void 0)}}var M_e,D_e,O_e,F_e,B_e,mD,Dj,xQt=Le((()=>{yE(),M_e=new Uint8Array([254,167,210,118,59,75,158,121]),D_e=new Uint8Array([215,170,15,109,48,97,52,78]),O_e=new Uint8Array([20,110,11,231,171,172,208,214]),F_e=new Uint8Array([95,178,173,1,12,185,225,246]),B_e=new Uint8Array([160,103,127,2,178,44,132,51]),mD=4096,Dj=8})),SQt=vs({decryptDocxIfNeeded:()=>IQt},1);function TQt(e){if(kj(e)!=="zip")throw new $o(ma.DECRYPTION_FAILED,"Decrypted output is not a valid ZIP archive — the file may be corrupt")}async function IQt(e,t){const n=e instanceof Uint8Array?e:new Uint8Array(e),r=kj(n);if(r==="zip")return{data:n,wasEncrypted:!1};if(r==="unknown")throw new $o(ma.DECRYPTION_FAILED,"Unrecognized file format — expected a .docx (ZIP) or encrypted .docx (OLE/CFB)");if(!t?.password)throw new $o(ma.PASSWORD_REQUIRED,"This document is password-protected. A password is required to open it.");const i=dQt(n),{params:o}=mQt(i.encryptionInfo),s=await AQt(t.password,o,i.encryptedPackage);return TQt(s),{data:s,wasEncrypted:!0}}var kQt=Le((()=>{x_e(),fQt(),gQt(),xQt(),yE()})),H_e=Kc(Mm(),1),Oj=new Set(["png","jpg","jpeg","gif","bmp","tiff","tif","emf","wmf","svg","webp"]),Fj={tif:"tiff",jpg:"jpeg",svg:"svg+xml"},EQt="application/vnd.openxmlformats-officedocument.customXmlProperties+xml",z_e={odttf:"application/vnd.openxmlformats-officedocument.obfuscatedFont",ttf:"application/x-font-ttf",otf:"application/vnd.ms-opentype"},CQt=class{constructor(e={}){this.debug=e.debug||!1,this.zip=new l_e.default,this.files=[],this.media={},this.mediaFiles={},this.fonts={},this.decryptedFileData=null}async#e(e,t){if(e instanceof Uint8Array||typeof Buffer<"u"&&Buffer.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,Math.min(t,e.byteLength));if(e instanceof ArrayBuffer)return new Uint8Array(e,0,Math.min(t,e.byteLength));if(typeof Blob<"u"&&e instanceof Blob)try{if(typeof e.arrayBuffer=="function"){const n=await e.arrayBuffer();return new Uint8Array(n,0,Math.min(t,n.byteLength))}}catch{}return new Uint8Array(0)}async getDocxData(e,t=!1,n={}){const{detectContainerType:r}=await Promise.resolve().then(()=>(x_e(),BZt)),i=r(await this.#e(e,8));let o=e;if(i==="cfb"){const{decryptDocxIfNeeded:l}=await Promise.resolve().then(()=>(kQt(),SQt)),c=await l(e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(await e.arrayBuffer()),{password:n.password});o=c.data,this.decryptedFileData=c.data}const s=await this.unzip(o),a=Object.entries(s.files);for(const[,l]of a){const c=l.name;if(c_e(c)){const u=d_e(await l.async("uint8array"));this.files.push({name:c,content:u})}else if(c.startsWith("word/media")&&c!=="word/media/"||l.name.startsWith("media")&&l.name!=="media/"||c.startsWith("media")&&c!=="media/"||c.startsWith("word/embeddings")&&c!=="word/embeddings/")if(t){const u=(await l.async("nodebuffer")).toString("base64");this.mediaFiles[c]=u}else{const u=await l.async("base64");let d=this.getFileExtension(c)?.toLowerCase(),f=null;if((!Oj.has(d)||d==="tmp")&&(f=q1(u),f&&(d=f)),Oj.has(d)){const h=Fj[d]||d;this.mediaFiles[c]=`data:image/${h};base64,${u}`;const p=await l.async("blob"),m=new File([p],c,{type:p.type}),g=URL.createObjectURL(m);this.media[c]=g}else this.mediaFiles[c]=u}else if(c.startsWith("word/fonts")&&c!=="word/fonts/"){const u=await l.async("uint8array");this.fonts[c]=u}}return this.files}getFileExtension(e){const t=e.split(".");return t.length<2?null:t[t.length-1]}async updateContentTypes(e,t,n,r={},i={}){const o=Object.keys(r||{}),s=Object.keys(t).map(k=>this.getFileExtension(k)).filter(k=>k&&Oj.has(k)),a=Object.entries(t).filter(([k])=>!this.getFileExtension(k)).map(([k,L])=>({name:k,contentType:this.#i(L)})).filter(k=>k.contentType),l="[Content_Types].xml";let c;n?Array.isArray(e.files)?c=e.files.find(k=>k.name===l)?.content||"":c=e.files?.[l]||"":c=await e.file(l).async("string");let u="";const d=QJe(c),f=new Set;for(let k of s){if(d.includes(k)||f.has(k))continue;const L=`<Default Extension="${k}" ContentType="image/${Fj[k]||k}"/>`;u+=L,f.add(k)}if(i){const k=new Set(Object.keys(i).map(L=>this.getFileExtension(L)).filter(L=>L&&z_e[L]));for(const L of k)d.includes(L)||f.has(L)||(u+=`<Default Extension="${L}" ContentType="${z_e[L]}"/>`,f.add(L))}const h=JSON.parse(H_e.xml2json(c,null,2)).elements?.find(k=>k.name==="Types")||{},p=k=>h.elements?.some(L=>L.name==="Override"&&L.attributes.PartName===k);for(const{name:k,contentType:L}of a){const _=`/${k}`;p(_)||(u+=`<Override PartName="${_}" ContentType="${L}" />`)}const m=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/comments.xml"),g=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/commentsExtended.xml"),y=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/commentsIds.xml"),v=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/commentsExtensible.xml"),b=k=>r&&Object.prototype.hasOwnProperty.call(r,k)?r[k]!==null:e?.files?n&&Array.isArray(e.files)?e.files.some(L=>L.name===k):!!e.files[k]:!1;b("word/comments.xml")&&(m||(u+='<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />')),b("word/commentsExtended.xml")&&(g||(u+='<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />')),b("word/commentsIds.xml")&&(y||(u+='<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />')),b("word/commentsExtensible.xml")&&(v||(u+='<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />'));const w=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/footnotes.xml"),x=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/endnotes.xml");b("word/footnotes.xml")&&(w||(u+='<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" />')),b("word/endnotes.xml")&&(x||(u+='<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" />'));for(const k of b_e)b(k.zipPath)&&!p(`/${k.zipPath}`)&&(u+=`<Override PartName="/${k.zipPath}" ContentType="${k.contentType}" />`);const A=new Set(o);e?.files&&(n&&Array.isArray(e.files)?e.files.forEach(k=>A.add(k.name)):Object.keys(e.files).forEach(k=>A.add(k))),A.forEach(k=>{if(!/^customXml\/itemProps\d+\.xml$/i.test(k)||!b(k))return;const L=`/${k}`;p(L)||(u+=`<Override PartName="${L}" ContentType="${EQt}" />`)}),A.forEach(k=>{if(k.includes(".rels")||!k.includes("header")&&!k.includes("footer"))return;const L=h.elements?.some(O=>O.name==="Override"&&O.attributes.PartName===`/${k}`),_=`<Override PartName="/${k}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${k.includes("header")?"header":"footer"}+xml"/>`;L||(u+=_)});const T=cV.map(k=>`/word/${k}`).filter(k=>!b(k.slice(1))),I="application/vnd.openxmlformats-officedocument.customXmlProperties+xml";if(h?.elements?.length)for(const k of h.elements){if(k?.name!=="Override"||k?.attributes?.ContentType!==I)continue;const L=k?.attributes?.PartName;typeof L!="string"||!L.startsWith("/")||b(L.slice(1))||T.push(L)}const P='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';let C=c.replace(P,`${P}${u}`);for(const k of T){const L=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),_=new RegExp(`\\s*<Override[^>]*PartName="${L}"[^>]*/>`,"g");C=C.replace(_,"")}let R=r["word/_rels/document.xml.rels"];if(R||(n?Array.isArray(e.files)?R=e.files.find(k=>k.name==="word/_rels/document.xml.rels")?.content:R=e.files?.["word/_rels/document.xml.rels"]:R=await e.file("word/_rels/document.xml.rels")?.async("string")),R)try{H_e.xml2js(R,{compact:!1}).elements?.find(k=>k.name==="Relationships")?.elements?.forEach(k=>{const L=k.attributes?.Type,_=k.attributes?.Target;if(!L||!_)return;const O=L.includes("/header"),F=L.includes("/footer");if(!O&&!F)return;let B=_.replace(/^\.\//,"");B.startsWith("../")&&(B=B.slice(3)),B.startsWith("/")&&(B=B.slice(1));const U=B.startsWith("word/")?B:`word/${B}`;A.add(U)})}catch(k){console.warn("Failed to parse document relationships while updating content types",k)}if(A.forEach(k=>{if(k.includes(".rels")||!k.includes("header")&&!k.includes("footer")||C.includes(`PartName="/${k}"`))return;const L=`<Override PartName="/${k}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${k.includes("header")?"header":"footer"}+xml"/>`;C=C.replace("</Types>",`${L}</Types>`)}),R){const k=FZt(R,b);k!==R&&(n?r["word/_rels/document.xml.rels"]=k:e.file("word/_rels/document.xml.rels",k))}if(n)return C;e.file(l,C)}async#t(e){const t={};e.forEach(s=>{t[s]=""});const n=e.file("[Content_Types].xml");n&&(t["[Content_Types].xml"]=await n.async("string"));const r=e.file("_rels/.rels");r&&(t["_rels/.rels"]=await r.async("string"));const{contentTypesXml:i,relsXml:o}=y_e({baseFiles:t,updatedDocs:{}});e.file("[Content_Types].xml",i),e.file("_rels/.rels",o)}async unzip(e){return await this.zip.loadAsync(e)}async updateZip({docx:e,updatedDocs:t,originalDocxFile:n,media:r,fonts:i,isHeadless:o,compression:s="DEFLATE"}){let a;n?a=await this.exportFromOriginalFile(n,t,r,i):a=await this.exportFromCollaborativeDocx(e,t,r,i);const l=o?"nodebuffer":"blob";return await a.generateAsync({type:l,mimeType:xc,compression:s,compressionOptions:s==="DEFLATE"?{level:6}:void 0})}async exportFromCollaborativeDocx(e,t,n,r){if(!Array.isArray(e))throw new Error("Collaborative DOCX export requires base package entries");const i=new l_e.default;for(const o of e){const s=o.content;i.file(o.name,s)}Object.keys(t).forEach(o=>{t[o]===null?i.remove(o):i.file(o,t[o])}),Object.keys(n).forEach(o=>{const s=n[o],a=typeof s=="string"?XT(s):s;i.file(o,a)});for(const[o,s]of Object.entries(r))i.file(o,s);return await this.updateContentTypes(i,n,!1,t,r),await this.#t(i),i}async exportFromOriginalFile(e,t,n,r){const i=await this.unzip(e),o=[];if(i.forEach((s,a)=>{const l=a.async("uint8array").then(c=>{i.file(a.name,c_e(a.name)?d_e(c):c)});o.push(l)}),await Promise.all(o),Object.keys(t).forEach(s=>{t[s]===null?i.remove(s):i.file(s,t[s])}),Object.keys(n).forEach(s=>{i.file(s,n[s])}),r)for(const[s,a]of Object.entries(r))i.file(s,a);return await this.updateContentTypes(i,n,!1,t,r),await this.#t(i),i}#i(e){if(e==null)return null;if(typeof e=="string"&&e.startsWith("data:image/"))return e.match(/^data:(image\/[a-zA-Z0-9.+-]+);/i)?.[1]?.toLowerCase()||null;let t=null;return e instanceof ArrayBuffer?t=q1(new Uint8Array(e)):ArrayBuffer.isView(e)?t=q1(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):typeof e=="string"&&(t=q1(e.startsWith("data:")?e.split(",",2)[1]:e)),t?`image/${Fj[t]||t}`:null}},Bj=CQt;const _Qt=(e,t)=>{const{doc:n}=e.state,r=n.nodeAt(t);if(r&&r.type.name==="image"){const i=e.state.tr.setSelection(mn.create(n,t));return e.dispatch(i),!0}return!1};function PQt(e,t="sans-serif"){const n=(r,i)=>{const o=document.createElement("canvas").getContext("2d");o.textBaseline="top";const s="abcdefghijklmnopqrstuvwxyz0123456789";o.font=`72px ${i}`;const a=o.measureText(s),l=a.width,c=a.actualBoundingBoxDescent;o.font=`72px "${r}", ${i}`;const u=o.measureText(s),d=u.width,f=u.actualBoundingBoxDescent;return d!==l||f!==c};return n(e,t)?!0:n(e,t==="sans-serif"?"serif":"sans-serif")}var TE=(...e)=>{};const RQt=e=>{const t=[];if(TE("ATTEMPTING MIGRATIONS"),!e.converter.numbering)return t;const{state:n}=e,{doc:r}=n,i=typeof e.view?.dispatch=="function"?e.view.dispatch.bind(e.view):e.dispatch.bind(e),o=["orderedList","bulletList"];let s=0;r.descendants((l,c)=>{if(!o.includes(l.type.name)||c<s)return;const u=gD(l,e,0);u.length>0&&t.push({from:c,to:c+l.nodeSize,listNode:l,replacement:u}),s=c+l.nodeSize});let a=n.tr;if(t.length>0)for(let l=t.length-1;l>=0;l--){const{from:c,to:u,replacement:d,listNode:f}=t[l],h=[];for(const p of d)if(p.node.type.name==="listItem"){const m=f.type.create(f.attrs,[p.node]);h.push(m)}else h.push(p.node);TE("NODES TO INSERT",h),a=a.replaceWith(c,u,h)}return a.setMeta("listsv2migration",t),e.options.migrated=!0,i(a),t};function gD(e,t,n=0,r=null){const i=[],o=["orderedList","bulletList"],s=e.type.name,a=LQt(e),l=NQt(e,t);if(TE("Needs migration?",a),!a)return l?i:MQt(e,t);let c=parseInt(e.attrs?.listId);TE("LIST ID",c,"SHARED NUM ID",r),(!c||Number.isNaN(c))&&(c=Gn.getNewListId(t)),(!Gn.getListDefinitionDetails({numId:c,level:n,editor:t})||!r&&!c)&&(c=Gn.getNewListId(t),TE("Genearted new list ID",c,"for list type",s),Gn.generateNewListDefinition({numId:c,listType:s,editor:t})),r||(r=c);for(const u of e.content.content)if(!u.content.content?.length)i.push({node:u,baseLevel:n});else if(u.content.content.length===1){const d=u.content.content[0];if(o.includes(d.type.name)){const f=gD(d,t,n+1,r);i.push(...f)}else{const f=Gn.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});i.push({node:f,baseLevel:n})}}else{const d=u.content.content[0];if(o.includes(d.type.name)){const f=gD(d,t,n+1,r);i.push(...f)}else if(d.type.name==="paragraph"||d.isTextblock){const f=Gn.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});i.push({node:f,baseLevel:n})}else i.push({node:d});for(let f of u.content.content.slice(1))if(o.includes(f.type.name)){const h=gD(f,t,n+1,r);i.push(...h)}else i.push({node:f})}return i}var LQt=e=>{const t=e.content;if(t?.content?.length>1)return!0;const n=t.firstChild;if(n&&n.type.name==="listItem"){const{attrs:r}=n,{level:i,listNumberingType:o}=r||{};return typeof i>"u"||!o?!0:(n?.content?.content).filter(s=>["bulletList","orderedList"].includes(s.type.name)).length>0}return!1},NQt=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:i,level:o}=r||{},{abstract:s}=Gn.getListDefinitionDetails({numId:i,level:o,listType:n,editor:t})||{};return!!s},MQt=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:i}=r||{};return Gn.generateNewListDefinition({numId:i,listType:n,editor:t})};const DQt=async(e=[],t)=>{const n=pu(t.state),r=[];if(!n.length)return e;for(const i of n){const o=i.node?.attrs?.type,s=e.find(l=>l.input_id===i.node.attrs.fieldId);if(s&&(!o||o!=="html")){r.push(s);continue}const a=s?.input_value;a&&await new Promise((l,c)=>{const u=document.createElement("div");t.createChildEditor({element:u,html:a,onCreate:({editor:d})=>{const{migrated:f}=d.options;f&&(s.input_value=d.getHTML(),r.push(s)),l()},onError:d=>{c(d)}})})}return r},OQt=(e,t={})=>e.options.isChildEditor?null:new qp({...e.options,pagination:!1,suppressDefaultDocxStyles:!0,ydoc:null,collaborationProvider:null,fileSource:null,initialState:null,documentId:null,isCommentsEnabled:!1,isNewFile:!1,fragment:!1,onCreate:()=>null,onListDefinitionsChange:FQt,...t,isChildEditor:!0,parentEditor:e});var FQt=e=>{const{editor:t,numbering:n}=e,{parentEditor:r={}}=t.options,{converter:i}=r;if(!i)return;i.numbering=n;const{tr:o}=r.state;o.setMeta("updatedListItemNodeViews",!0),r.dispatch(o)};function U_e(e,t=[]){const n="[SuperValidator]",r="color: teal; font-weight: bold;",i=[n,...t.map(a=>`[${a}]`)],o=i.map(()=>"%c%s").join(" "),s=i.map(a=>[r,a]).flat();return{debug:(...a)=>{e&&console.debug(o,...s,...a)},withPrefix:a=>U_e(e,[...t,a])}}function BQt(e,t,n,r){let i=!1;const o=[];return e.forEach(({node:s,pos:a})=>{const{rId:l,src:c}=s.attrs;if(!l&&c){const u=Ww(t,"image-rid:ensureValidImageRID",{target:c,type:"image"});u&&(r.debug("Assigned rId for image:",u,"at pos:",a),n.setNodeMarkup(a,void 0,{...s.attrs,rId:u}),o.push(`Added missing rId to image at pos ${a}`),i=!0)}}),{modified:i,results:o}}function HQt({editor:e,logger:t}){const n=(r,i)=>{const o=[BQt(i.image||[],e,r,t)];return{modified:o.some(s=>s.modified),results:o.flatMap(s=>s.results)}};return n.requiredElements={nodes:["image"]},n}function zQt(e,t,n,r){let i=!1;const o=[];return e.forEach(({mark:s,from:a,to:l})=>{const{rId:c,href:u,anchor:d}=s.attrs;if(!c&&u&&!d){const f=Ww(t,"link-rid:ensureValidLinkRID",{target:u,type:"hyperlink"});if(f){r.debug("Assigned rId for link:",f,"from pos:",a,"to pos:",l);const h=t.schema.marks.link,p=h.create({...s.attrs,rId:f});n.removeMark(a,l,h),n.addMark(a,l,p),o.push(`Added missing rId to link from pos ${a} to ${l}`),i=!0}}}),{modified:i,results:o}}function UQt({editor:e,logger:t}){const n=(r,i)=>{const o=[zQt(i.link||[],e,r,t)];return{modified:o.some(s=>s.modified),results:o.flatMap(s=>s.results)}};return n.requiredElements={marks:["link"]},n}const VQt={imageNodeValidator:HQt,linkMarkValidator:UQt};function WQt({editor:e,logger:t}){return()=>{const n=[];let r=!1;const i=e?.converter?.convertedXml,o="word/numbering.xml",s=i?.[o];if(!s||!s.elements?.length||!s.elements[0].elements?.length)return n.push(`${o} is not a valid xml`),{results:n,modified:r};const a=[];let l=s.elements[0];return V_e(l,a),a.length?(r=!0,n.push("Removed invalid <w:num> by numId:"+a.join(", ")),t?.debug?.(`Removed invalid <w:num> by numId: ${a.join(", ")}`)):n.push("No <w:num> entries with null/invalid numId found."),{results:n,modified:r}}}function V_e(e,t){if(!e||!Array.isArray(e.elements))return;const n=[];for(const r of e.elements){if(r?.type==="element"){if(r.name==="w:num"){const i=(r.attributes||{})["w:numId"],o=i==null?null:String(i).trim();if(o==null||o===""||/^null$/i.test(o)||!/^\d+$/.test(o)){t.push(o??"missing node");continue}}Array.isArray(r.elements)&&r.elements.length&&V_e(r,t)}n.push(r)}e.elements=n}function GQt({editor:e,logger:t}){return()=>{const n=[];let r=!1;const i=e?.converter?.convertedXml;if(!i||typeof i!="object")return{results:n,modified:r};const{relsKey:o,wasNormalized:s}=jQt(i,n);if(!o)return{results:n,modified:r};s&&(r=!0);const{root:a,wasFixed:l}=qQt(i[o],o,n);if(!a)return{results:n,modified:r};l&&(r=!0),YQt(a)&&(r=!0);const{filteredIds:c,binMediaTargets:u,wasProcessed:d}=KQt(a,i,n);d&&(r=!0),XQt(i,c,n,t)&&(r=!0);const f=i["[Content_Types].xml"];return u.size>0||f?JQt(i,u,n)&&(r=!0):n.push("[Content_Types].xml not found or not parseable. Skipped content types patch."),{results:n,modified:r}}}function jQt(e,t){const n=["word/_rels/document.xml.rels","word/document.xml.rels","_rels/document.xml.rels","document.xml.rels"].find(i=>e?.[i]?.elements);if(!n)return{relsKey:null,wasNormalized:!1};const r="word/_rels/document.xml.rels";return n!==r?(e[r]=e[n],delete e[n],t.push(`Normalized relationships location to ${r} (was ${n})`),{relsKey:r,wasNormalized:!0}):{relsKey:n,wasNormalized:!1}}function qQt(e,t,n){const r=e?.elements?.[0];if(!r||r.type!=="element")return n.push(`${t} is not a valid xml`),{root:null,wasFixed:!1};const i="http://schemas.openxmlformats.org/package/2006/relationships";let o=!1;return r.name!=="Relationships"&&(r.name="Relationships",n.push('Fixed relationships root element name to "Relationships"'),o=!0),r.attributes=r.attributes||{},r.attributes.xmlns!==i&&(r.attributes.xmlns=i,n.push(`Set relationships xmlns to ${i}`),o=!0),{root:r,wasFixed:o}}function YQt(e){const t=e.elements?.filter(n=>n?.type==="element"&&n.name==="Relationship")||[];return e.elements?.length!==t.length?(e.elements=t,!0):!1}function KQt(e,t,n){const r=new Set,i=new Set;let o=!1;const s=v=>{const b=/^rId(\d+)$/.exec(String(v||""));return b?parseInt(b[1],10):null},a=(v,b)=>typeof v=="string"&&new RegExp(`/relationships/${b}$`,"i").test(v),l=v=>a(v,"hyperlink"),c=v=>a(v,"image"),u=v=>/^https?:\/\//i.test(v||"")||/^mailto:/i.test(v||""),d=new Set;let f=0;for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes.Id,w=s(b);Number.isInteger(w)&&(f=Math.max(f,w)),typeof b=="string"&&b&&d.add(b)}let h=f;const p=v=>{if(v&&!d.has(v))return d.add(v),v;let b;do h+=1,b=`rId${h}`;while(d.has(b));return d.add(b),b},m=new Set,g=[];function y(v,b){return typeof v[b]=="string"?v[b].trim():""}for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes;let w=y(b,"Id");const x=y(b,"Type");let A=y(b,"Target"),T=y(b,"TargetMode");if(!A){n.push(`Removed relationship "${w}" without Target`),o=!0;continue}if(l(x)&&u(A)&&T.toLowerCase()!=="external"&&(b.TargetMode="External",T="External",n.push(`Set TargetMode="External" for hyperlink ${w}`),o=!0),c(x)){const I=ip(A,"word");I&&/^media\/.+\.bin$/i.test(A)&&I in t&&r.add(`/${I}`)}if(T.toLowerCase()!=="external"&&!u(A)&&!(ip(A,"word")in t))if(c(x))n.push(`Warning: image relationship ${w} target not found: ${A}.`);else{n.push(`Removed relationship ${w} with missing target: ${A}`),o=!0;continue}if(!w){const I=p(null);b.Id=I,n.push(`Assigned missing Id "${I}"`),o=!0,w=I}if(m.has(w)){n.push(`Removed duplicate relationship with ID "${w}"`),o=!0;continue}m.add(w),g.push(v)}(e.elements.length!==g.length||e.elements.some((v,b)=>v!==g[b]))&&(e.elements=g,o=!0);for(const v of e.elements){const b=v.attributes?.Id;typeof b=="string"&&b&&i.add(b)}return{filteredIds:i,binMediaTargets:r,wasProcessed:o}}function XQt(e,t,n,r){const i=e["word/document.xml"];if(i?.elements?.length){const o=i.elements[0];if(o?.type==="element"){const s=[];if(W_e(o,t,s),s.length)return n.push(`Fixed ${s.length} missing relationship references`),r?.debug?.(`Fixed ${s.length} missing relationship references in document`),!0}}return!1}function JQt(e,t,n){const r="[Content_Types].xml",i=e[r];return typeof i=="string"?ZQt(i,t,n,e,r):i?.elements?.length?QQt(i,t,n):!1}function ZQt(e,t,n,r,i){const o='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">',s=(c,u,d)=>new RegExp(`<Default\\s+Extension="${u}"\\b`,"i").test(c)?c:c.replace(o,`${o}<Default Extension="${u}" ContentType="${d}"/>`),a=(c,u,d)=>{const f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`<Override\\s+PartName="${f}"\\b`,"i").test(c)?c:c.replace(o,`${o}<Override PartName="${u}" ContentType="${d}" />`)};let l=e;l=s(l,"rels","application/vnd.openxmlformats-package.relationships+xml"),l=s(l,"xml","application/xml");for(const c of t)l=a(l,c,"image/png"),n.push(`Added Content Types Override for "${c}" as image/png`);return l!==e?(r[i]=l,!0):!1}function QQt(e,t,n){const r=e.elements.find(c=>c.name==="Types")||e.elements[0];r.elements=r.elements||[];const i=c=>r.elements.some(u=>u.name==="Default"&&u.attributes?.Extension===c),o=(c,u)=>{r.elements.unshift({type:"element",name:"Default",attributes:{Extension:c,ContentType:u}})},s=c=>r.elements.some(u=>u.name==="Override"&&u.attributes?.PartName===c),a=(c,u)=>{r.elements.unshift({type:"element",name:"Override",attributes:{PartName:c,ContentType:u}})};let l=!1;i("rels")||(o("rels","application/vnd.openxmlformats-package.relationships+xml"),l=!0),i("xml")||(o("xml","application/xml"),l=!0);for(const c of t)s(c)||(a(c,"image/png"),n.push(`Added Content Types Override for "${c}" as image/png`),l=!0);return l}function W_e(e,t,n){if(e?.elements?.length)for(const r of e.elements){if(r?.type!=="element")continue;const i=r.attributes?.["r:id"];typeof i=="string"&&!t.has(i)&&(delete r.attributes["r:id"],n.push(`Removed invalid r:id="${i}"`)),W_e(r,t,n)}}const $Qt={numberingValidator:WQt,relationshipsValidator:GQt};var G_e=class{#e;#t;#i;#n;#r;constructor(e){this.#e=e.editor,this.dryRun=e.dryRun||!1,this.debug=e.debug||!1,this.logger=U_e(this.debug);const{stateValidators:t,xmlValidators:n,nodeTypes:r,markTypes:i}=this.#o();this.#t=t,this.#i=n,this.#n=r,this.#r=i}#o(){const e=new Set,t=new Set,n=r=>Object.fromEntries(Object.entries(r).map(([i,o])=>{const s=this.logger.withPrefix(i),a=o({editor:this.#e,logger:s});return this.#l(a,e,t),[i,a]}));return{stateValidators:n(VQt),xmlValidators:n($Qt),nodeTypes:e,markTypes:t}}#l(e,t,n){e.requiredElements&&typeof e.requiredElements=="object"&&(e.requiredElements.nodes&&e.requiredElements.nodes.forEach(r=>{t.add(r)}),e.requiredElements.marks&&e.requiredElements.marks.forEach(r=>{n.add(r)}))}#c(){const{doc:e}=this.#e.state,t={};this.#n.forEach(r=>t[r]=[]),this.#r.forEach(r=>t[r]=[]);const n=(r,i)=>{this.#n.has(r.type.name)&&t[r.type.name].push({node:r,pos:i}),r.isText&&r.marks&&r.marks.forEach(o=>{this.#r.has(o.type.name)&&t[o.type.name].push({mark:o,node:r,pos:i,from:i,to:i+r.nodeSize})})};return e.descendants(n),t}validateActiveDocument(){const e=this.#e.state;if(!e)return{modified:!1,results:[]};const{tr:t}=e,n=this.#c();this.logger.debug("Document analysis:",n);let r=!1;const i=[];return Object.entries(this.#t).forEach(([o,s])=>{this.logger.debug(`🕵 Validating with ${o}...`);const{results:a,modified:l}=s(t,n);i.push({key:o,results:a}),r=r||l}),this.dryRun?this.logger.debug("DRY RUN: No changes applied to the document."):this.#u(t),this.logger.debug("Results:",i),{modified:r,results:i}}validateDocumentExport(){const e=this.#e.state;if(!e)return{modified:!1,results:[]};const{tr:t}=e;let n=!1;const r=[];return Object.entries(this.#i).forEach(([i,o])=>{this.logger.debug(`🕵 Validating export with ${i}...`);const{results:s,modified:a}=o();r.push({key:i,results:s}),n=n||a}),!this.dryRun&&n?this.#u(t):this.logger.debug("DRY RUN: No export changes applied to the document."),this.logger.debug("Export validation results:",r),{modified:n,results:r}}#u(e){if(typeof this.#e?.dispatch=="function"){this.#e.dispatch(e);return}this.#e?.view?.dispatch?.(e)}},yD=null;const QA=()=>{if(yD!==null)return yD;try{const e=typeof globalThis<"u"&&typeof globalThis.window<"u"&&typeof globalThis.document<"u"&&typeof globalThis.document.createElement=="function";return yD=e,e}catch{return yD=!1,!1}};var e$t="1.34.0-next.7",t$t=["group","content","marks","inline","atom","defining","code","tableRole","summary"],n$t=["group","inclusive","excludes","spanning","code"];function j_e(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>{const r=n?.default;return[t,{default:r??null,required:r===void 0}]})):{}}function q_e(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]).filter(([,n])=>n!==void 0))}function r$t(e,t){if(!e||typeof e!="object")throw new Error("Invalid schema: schema must be a valid ProseMirror Schema object.");const n=t||"current",r=[];e.spec.nodes.forEach((o,s)=>{r.push({name:o,attrs:j_e(s.attrs),...q_e(s,t$t)})});const i=[];return e.spec.marks.forEach((o,s)=>{i.push({name:o,attrs:j_e(s.attrs),...q_e(s,n$t)})}),{version:e$t,schemaVersion:n,topNode:e.topNodeType?.name,nodes:r,marks:i}}const i$t=e=>{const t=document.createElement("div");t.innerHTML=e;const n=[],r=[],i=o=>{for(;r.length&&r[r.length-1].level>=o;){const s=r.pop();r.length?r[r.length-1].el.appendChild(s.el):n.push(s.el.outerHTML)}};return Array.from(t.childNodes).forEach(o=>{if(o.nodeType!==Node.ELEMENT_NODE){n.push(o.outerHTML||o.textContent);return}if(o.tagName.toLowerCase()==="ol"||o.tagName.toLowerCase()==="ul"){const s=s$t(o),a=a$t(s),l=s.getAttribute("data-num-fmt"),c=s.getAttribute("data-lvl-text"),u=o.tagName.toLowerCase(),d=s.cloneNode(!0);if(d.setAttribute("aria-level",a+1),d.style.setProperty("list-style-type",o$t(l,c)),!r.length||r[r.length-1].level<a){const f=document.createElement(u);r.push({tag:u,level:a,el:f})}else if(r[r.length-1].level>a)i(a+1);else if(r[r.length-1].tag!==u){i(a);const f=document.createElement(u);r.push({tag:u,level:a,el:f})}r[r.length-1].el.appendChild(d)}else i(0),n.push(o.outerHTML)}),i(0),n.join("")},o$t=(e,t)=>{const n=new Map([["●","disc"],["◦","circle"],["▪","square"]]);if(e==="bullet")return n.get(t)||"disc";const r=new Map([["decimal","decimal"],["lowerLetter","lower-alpha"],["upperLetter","upper-alpha"],["lowerRoman","lower-roman"],["upperRoman","upper-roman"]]);return t.startsWith("0")?"decimal-leading-zero":r.get(e)};function s$t(e){return Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE)||null}const a$t=e=>{const t=e.getAttribute("data-level");return t?parseInt(t,10):0};var l$t=/^Heading[1-9]$/i;function c$t(e,t){const n=e.content.firstChild;if(!n||n.type.name==="paragraph")return e;const r=t.selection.$from,i=t.selection.$to;if(!r||!i)return e;let o=null,s=-1;for(let d=r.depth;d>=0;d--){const f=r.node(d);if(f?.type?.name==="paragraph"){i.depth>=d&&i.node(d)===f&&(o=f,s=d);break}}if(!o)return e;const a=r.parentOffset,l=i.parentOffset;if(a!==0||l!==o.content.size||r.depth!==s||i.depth!==s)return e;const c=o.attrs?.paragraphProperties?.styleId;if(typeof c!="string"||!l$t.test(c))return e;const u=o.type.create(o.attrs,e.content,o.marks);return new Ht(_t.from(u),0,0)}var u$t=1,d$t=10,f$t=150,h$t=1.2,p$t=1,m$t=[".list-marker",".sd-editor-tab",".ProseMirror-trailingBreak"].join(", "),g$t="span.sd-paragraph-content",Y_e="p, div, h1, h2, h3, h4, h5, h6, blockquote, table",y$t='<meta name="Generator" content="Microsoft Word">',b$t=new Map([["decimal","decimal"],["lowerLetter","alpha-lower"],["upperLetter","alpha-upper"],["lowerRoman","roman-lower"],["upperRoman","roman-upper"],["bullet","bullet"]]);function K_e(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE){const r=n;if(r.matches(Y_e))return r}n=n.parentNode}return null}function v$t(e){const t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),!!t.querySelector(Y_e)}function w$t(e){const t=[],n=globalThis.getComputedStyle?.(e),r=e.style.color||(n?.color&&n.color!=="rgb(0, 0, 0)"?n.color:""),i=e.style.fontFamily||"",o=e.style.fontSize||(n?.fontSize&&n.fontSize!=="16px"?n.fontSize:""),s=e.style.textTransform||(n?.textTransform&&n.textTransform!=="none"?n.textTransform:""),a=e.style.fontWeight||(n?.fontWeight&&n.fontWeight!=="400"?n.fontWeight:"");return r&&t.push(`color: ${r}`),i&&t.push(`font-family: ${i}`),o&&t.push(`font-size: ${o}`),s&&t.push(`text-transform: ${s}`),a&&t.push(`font-weight: ${a}`),t.join("; ")}function A$t(e,t){const n=e.cloneContents();if(v$t(n))return n;const r=K_e(e.startContainer,t.dom),i=K_e(e.endContainer,t.dom);if(!r||r!==i)return n;const o=r.cloneNode(!1),s=w$t(r);if(s){const l=document.createElement("span");l.setAttribute("style",s),l.appendChild(n),o.appendChild(l)}else o.appendChild(n);const a=document.createDocumentFragment();return a.appendChild(o),a}function x$t(e,t){let n;try{n=e.posAtDOM(t,0)}catch{return null}const{doc:r}=e.state;if(n<0||n>r.content.size)return null;const i=r.resolve(n);for(let o=i.depth;o>0;o-=1){const s=i.node(o);if(s.type.name==="paragraph")return s}return null}function S$t(e){e.querySelectorAll("p[data-num-id], p[data-list-numbering-type]").forEach(t=>{const n=t.getAttribute("data-list-numbering-type"),r=t.getAttribute("data-marker-type");n&&!t.hasAttribute("data-num-fmt")&&t.setAttribute("data-num-fmt",n),r&&!t.hasAttribute("data-lvl-text")&&t.setAttribute("data-lvl-text",r)})}function T$t(e,t){const n=Array.from(e.querySelectorAll("[data-sd-block-id]"));n.length!==0&&n.forEach(r=>{const i=r.getAttribute("data-sd-block-id");if(!i)return;const o=t.dom.querySelector(`[data-sd-block-id="${globalThis.CSS?.escape?.(i)??i}"]`);if(!o)return;const s=x$t(t,o),a=s?.attrs?.paragraphProperties?.sectPr;if(!a||typeof a!="object")return;r.setAttribute("data-sd-sect-pr",JSON.stringify(a));const l=s?.attrs?.pageBreakSource;typeof l=="string"&&l.length>0&&r.setAttribute("data-sd-page-break-source",l)})}function I$t(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.map(n=>Number(n)).filter(n=>Number.isFinite(n)):[]}catch{return[]}}function k$t(e,t,n,r){if(t==="bullet")return n||r||"•";if(r?.includes("%"))return r;const i=n.match(/[.)]$/)?.[0]||".";return`%${e+1}${i}`}function E$t(e){const t=document.createDocumentFragment();t.appendChild(document.createComment("[if !supportLists]"));const n=document.createElement("span");return n.textContent=e,t.appendChild(n),t.appendChild(document.createComment("[endif]")),t}function C$t(e){if(Array.from(e.querySelectorAll("p[data-num-id], p[data-list-numbering-type]")).length===0)return null;const t=e.cloneNode(!0),n=[".MsoNormal {}",".MsoListParagraph {}"],r=new Set;return t.querySelectorAll("p[data-num-id], p[data-list-numbering-type]").forEach(i=>{const o=Number.parseInt(i.getAttribute("data-level")||"0",10)||0,s=o+1,a=i.getAttribute("data-num-id")||"1",l=a,c=i.getAttribute("data-num-fmt")||i.getAttribute("data-list-numbering-type")||"decimal",u=b$t.get(c)||"decimal",d=i.getAttribute("data-marker-type")||i.getAttribute("data-lvl-text")||"1.",f=k$t(o,c,d,i.getAttribute("data-lvl-text")),h=`${l}:${s}:${a}`,p=i.getAttribute("style"),m=`mso-list:l${l} level${s} lfo${a}`;i.setAttribute("class","MsoListParagraph"),i.setAttribute("style",p?`${m};${p}`:m),r.has(h)||(n.push(`@list l${l}:level${s} lfo${a} { mso-level-number-format: ${u}; mso-level-text: "${f}"; }`),r.add(h));const g=I$t(i.getAttribute("data-list-level")),y=g[o]??g[g.length-1]??1,v=c==="bullet"?d:`${d}`.trim()||`${y}.`;i.prepend(E$t(v))}),`${y$t}<style>${n.join(`
|
|
390
390
|
`)}</style>${t.innerHTML}`}function X_e(e){if(e instanceof Document)return e.getSelection();if(typeof ShadowRoot<"u"&&e instanceof ShadowRoot){const t=e;return typeof t.getSelection=="function"?t.getSelection()??null:t.ownerDocument.getSelection()}return typeof document<"u"?document.getSelection():null}function _$t(e,t){const n=X_e(e.root);if(!n||n.isCollapsed||n.rangeCount===0)return null;const r=document.createElement("div");let i=!1;for(let o=0;o<n.rangeCount;o+=1){const s=n.getRangeAt(o),a=s.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?s.commonAncestorContainer:s.commonAncestorContainer.parentElement;a&&!e.dom.contains(a)||(r.appendChild(A$t(s,e)),i=!0)}return i?(r.querySelectorAll(m$t).forEach(o=>{o.parentNode?.removeChild(o)}),r.querySelectorAll(g$t).forEach(o=>{const s=o.parentNode;if(s){for(;o.firstChild;)s.insertBefore(o.firstChild,o);s.removeChild(o)}}),r.querySelectorAll("[contenteditable], [draggable], [spellcheck], [data-pm-slice]").forEach(o=>{o.removeAttribute("contenteditable"),o.removeAttribute("draggable"),o.removeAttribute("spellcheck"),o.removeAttribute("data-pm-slice")}),r.querySelectorAll("[class]").forEach(o=>{const s=(o.getAttribute("class")||"").split(/\s+/).filter(Boolean).filter(a=>!a.startsWith("ProseMirror"));s.length>0?o.setAttribute("class",s.join(" ")):o.removeAttribute("class")}),FAt(r,e,t),S$t(r),T$t(r,e),C$t(r)||r.innerHTML||null):null}var J_e=class{constructor(){this.view=null,this.eventListenerCleanups=[],this.resizeTimeoutId=null}attach({element:e,state:t,editorProps:n={},dispatchTransaction:r,handleClick:i}){return this.view?.destroy(),this.view=new Spe(e,{...n&&typeof n=="object"?n:{},dispatchTransaction:r,state:t,handleClick:i}),this.view}destroy(){this.resizeTimeoutId!==null&&(clearTimeout(this.resizeTimeoutId),this.resizeTimeoutId=null);for(const e of this.eventListenerCleanups)e();this.eventListenerCleanups=[],this.view?.destroy(),this.view=null}initContainerElement(e){if(!QA()){e.isHeadless=!0,e.element=null;return}if(!e.element&&e.selector){const{selector:t}=e;let n=null;if(t.startsWith("#")||t.startsWith(".")){const r=document.querySelector(t);n=r instanceof HTMLElement?r:null}else n=document.getElementById(t);e.element=n,["text","html"].includes(e.mode)&&e.element&&e.element.classList.add("sd-super-editor-html")}if(e.isHeadless){e.element=null;return}e.element=e.element||document.createElement("div"),jM(e.element)}initFonts(e){const t=e.converter.getFontFaceImportString();if(t?.styleString?.length)try{const n=document.createElement("style");n.textContent=t.styleString,document.head.appendChild(n),e.fontsImported=t.fontsImported}catch(n){console.warn("Failed to inject fonts into DOM:",n)}}updateEditorStyles(e,t,n){!n||!t||(this.#e(e,t,n),e.isWebLayout()?this.#t(t,n):this.#i(e,t,n))}#e(e,t,n){n.setAttribute("role","document"),n.setAttribute("aria-multiline","true"),n.setAttribute("aria-label","Main content area, start typing to enter text."),n.setAttribute("aria-description",""),n.classList.remove("view-mode"),t.style.boxSizing="border-box",t.style.isolation="isolate",n.style.outline="none",n.style.border="none",t.style.backgroundColor="#fff",n.style.backgroundColor="#fff";const{typeface:r,fontSizePt:i,fontFamilyCss:o}=e.converter.getDocumentDefaultStyles()??{},s=o||r;s&&(t.style.fontFamily=s),i&&(t.style.fontSize=`${i}pt`),n.style.lineHeight=e.options.isHeaderOrFooter?String(p$t):String(h$t),t.style.transformOrigin="top left",t.style.touchAction="auto";const a=t.style;("webkitOverflowScrolling"in t.style||typeof a=="object")&&(a.webkitOverflowScrolling="touch")}#t(e,t){e.style.width="",e.style.minWidth="",e.style.minHeight="",e.style.paddingLeft="",e.style.paddingRight="",t.style.paddingTop="0",t.style.paddingBottom="0"}#i(e,t,n){const{pageSize:r,pageMargins:i}=e.converter.pageStyles??{};r?.width!=null&&(t.style.width=`${r.width}in`,t.style.minWidth=`${r.width}in`,r?.height!=null&&(t.style.minHeight=`${r.height}in`)),i&&(t.style.paddingLeft=`${i.left}in`,t.style.paddingRight=`${i.right}in`),e.presentationEditor&&i?.top!=null?n.style.paddingTop=`${i.top}in`:e.presentationEditor?n.style.paddingTop=`${u$t}in`:n.style.paddingTop="0",n.style.paddingBottom="0"}initDefaultStyles(e,t=e.element){if(e.options.isHeadless||e.options.suppressDefaultDocxStyles||!t)return;const n=t.querySelector(".ProseMirror"),r=n instanceof HTMLElement?n:null;r&&(this.updateEditorStyles(e,t,r),this.initMobileStyles(e,t))}initMobileStyles(e,t){if(!t||e.isWebLayout())return;const n=t.offsetWidth,r=()=>{const o=n,s=document.documentElement.clientWidth-d$t;e.options.scale=Math.min(1,s/o);const a=t.closest(".super-editor"),l=t.closest(".super-editor-container");!(a instanceof HTMLElement)||!(l instanceof HTMLElement)||(e.options.scale<1?(a.style.maxWidth=`${o*e.options.scale}px`,l.style.minWidth="0px",t.style.transform=`scale(${e.options.scale})`):(a.style.maxWidth="",l.style.minWidth="",t.style.transform="none"))};r();const i=()=>{this.resizeTimeoutId!==null&&clearTimeout(this.resizeTimeoutId),this.resizeTimeoutId=setTimeout(()=>{r(),this.resizeTimeoutId=null},f$t)};if("orientation"in screen&&"addEventListener"in screen.orientation)screen.orientation.addEventListener("change",i),this.eventListenerCleanups.push(()=>{screen.orientation.removeEventListener("change",i)});else{const o=typeof window.matchMedia=="function"?window.matchMedia("(orientation: portrait)"):null;o?.addEventListener&&(o.addEventListener("change",i),this.eventListenerCleanups.push(()=>{o.removeEventListener("change",i)}))}window.addEventListener("resize",i),this.eventListenerCleanups.push(()=>{window.removeEventListener("resize",i)})}registerCopyHandler(e){const t=this.view?.dom;if(!t||!QA())return;const n=r=>{try{const i=r.clipboardData;if(!i||(r.preventDefault(),!this.view))return;const{from:o,to:s}=this.view.state.selection;let a="",l="";if(o!==s){const g=c$t(this.view.state.doc.slice(o,s),this.view.state);a=JSON.stringify(g.toJSON()),i.setData("application/x-superdoc-slice",a),l=Cge(a,e),l&&i.setData(Ege,l)}const c=_$t(this.view,e),u=this.view.state.doc.attrs?.bodySectPr,d=u&&Rge(u)?JSON.stringify(u):"";if(c){i.setData("text/html",Iz(c,a,d,l)),i.setData("text/plain",X_e(this.view.root)?.toString()??"");return}const f=this.view.state.doc.slice(o,s).content,h=document.createElement("div"),p=Hf.fromSchema(this.view.state.schema);h.appendChild(p.serializeFragment(f)),kz(h,f,e);const m=i$t(h.innerHTML);i.setData("text/html",Iz(m,a,d,l)),i.setData("text/plain",this.view.state.doc.textBetween(o,s,`
|
|
391
391
|
`))}catch(i){console.warn("Failed to transform copied content:",i)}};t.addEventListener("copy",n),this.eventListenerCleanups.push(()=>{t.removeEventListener("copy",n)})}initDevTools(e){if(!e.options.isHeaderOrFooter&&e.options.isDebug)try{window.superdocdev={converter:e.converter,editor:e}}catch(t){console.warn("Failed to initialize developer tools:",t)}}};const P$t="data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,UEsDBBQAAAAIAAAAIQAykW9XXgEAAKUFAAATABwAW0NvbnRlbnRfVHlwZXNdLnhtbFVUCQADMNDOEjDQzhJ1eAsAAQT1AQAABBQAAAC1lMtqwzAQRfeF/oPRNthKuiilxMmij2UbaPoBijRORPVCmrz+vuM4NaWkMeSxMcgz994zQsxwvLEmW0FM2ruSDYo+y8BJr7Sbl+xz+po/sCyhcEoY76BkW0hsPLq9GU63AVJGapdKtkAMj5wnuQArUuEDOKpUPlqBdIxzHoT8EnPgd/3+PZfeITjMsfZgo+EzVGJpMHvZ0O+GJIJJLHtqGuuskokQjJYCqc5XTv1JyfcJBSl3PWmhQ+pRA+MHE+rK/wF73TtdTdQKsomI+CYsdfG1j4orL5eWlMVxmwOcvqq0hFZfu4XoJaREd25N0Vas0K7XxeGWdgaRlJcHaa07IRJuDaTLEzS+3fGASIJrAOydOxHWMPu4GsUv806QinKnYmbg8hitdScE0hqA5js4m2NncyySOifRh0RrJZ4w9s/eqNU5DRwgoj7+6tpEsj57PqhXkgJ1IJvvluzoG1BLAwQKAAAAAACTZE1bAAAAAAAAAAAAAAAACQAcAGRvY1Byb3BzL1VUCQADhhztaIcc7Wh1eAsAAQT1AQAABBQAAABQSwMEFAAAAAgAAAAhACEYr1llAQAAxQIAABAAHABkb2NQcm9wcy9hcHAueG1sVVQJAAMw0M4SMNDOEnV4CwABBPUBAAAEFAAAAJ1STU/DMAy9I/Efqt63dBwmNHlBaAhx4GPSCpyjxG0j0iRKson9e5wVSoEbOdnP9st7TuDqvTfFAUPUzq7LxbwqC7TSKW3bdflc384uyyImYZUwzuK6PGIsr/j5GWyD8xiSxlgQhY3rskvJrxiLssNexDmVLVUaF3qRKA0tc02jJd44ue/RJnZRVUuG7wmtQjXzI2E5MK4O6b+kysmsL77UR098HGrsvREJ+WOeNHPlUg9sRKF2SZha98grgscEtqLFyBfAhgBeXVAx9wwBbDoRhEy0vwxOMrj23mgpEu2VP2gZXHRNKp5OYos8DWzaAmRgh3IfdDpmqmkK99ri6YIhIFVBtEH47gROMthJYXBD1nkjTERg3wBsXO+FJTo2RsT3Fp997W7yFj5HfoITi686dTsvJP4yO8FhRygqUj8KGAG4o8cIJrPTrG1RffX8LeT1vQy/ki+W84rOaV9fGLkevwv/AFBLAwQUAAAACAAAACEACvOn+GYBAADtAgAAEQAcAGRvY1Byb3BzL2NvcmUueG1sVVQJAAMw0M4SMNDOEnV4CwABBPUBAAAEFAAAAJ2SXU+DMBSG7038D6T3UGBqDAGWTLMrZ0yc0XhX27Otjn6k7cb27y0wmMRdeXc+nvP29G3z6UFUwR6M5UoWKIliFICkinG5LtDbch7eo8A6IhmplIQCHcGiaXl9lVOdUWXgxSgNxnGwgVeSNqO6QBvndIaxpRsQxEaekL65UkYQ51OzxprQLVkDTuP4DgtwhBFHcCMY6kERnSQZHST1zlStAKMYKhAgncVJlOAz68AIe3Gg7fwiBXdHDRfRvjnQB8sHsK7rqJ60qN8/wR+Lp9f2qiGXjVcUUJkzmjnuKihzfA59ZHdf30BdVx4SH1MDxClTPnO6DWZgJKlapq83jm/hWCvDrJ8eZR5jYKnh2vl37LRHBU9XxLqFf9gVBzY7jo/5224mDOx58y/KtCWGND+Z3K0GLPDmZJ2Vfed98vC4nKMyjdObMEnD5G6Zpll8m8XxZ7PdaP4sKE4L/FuxF+gMGn/Q8gdQSwMECgAAAAAAk2RNWwAAAAAAAAAAAAAAAAYAHABfcmVscy9VVAkAA4Yc7WiHHO1odXgLAAEE9QEAAAQUAAAAUEsDBBQAAAAIAAAAIQAekRq36QAAAE4CAAALABwAX3JlbHMvLnJlbHNVVAkAAzDQzhIw0M4SdXgLAAEE9QEAAAQUAAAArZLBasMwDEDvg/2D0b1R2sEYo04vY9DbGNkHCFtJTBPb2GrX/v082NgCXelhR8vS05PQenOcRnXglF3wGpZVDYq9Cdb5XsNb+7x4AJWFvKUxeNZw4gyb5vZm/cojSSnKg4tZFYrPGgaR+IiYzcAT5SpE9uWnC2kiKc/UYySzo55xVdf3mH4zoJkx1dZqSFt7B6o9Rb6GHbrOGX4KZj+xlzMtkI/C3rJdxFTqk7gyjWop9SwabDAvJZyRYqwKGvC80ep6o7+nxYmFLAmhCYkv+3xmXBJa/ueK5hk/Nu8hWbRf4W8bnF1B8wFQSwMECgAAAAAAk2RNWwAAAAAAAAAAAAAAAAUAHAB3b3JkL1VUCQADhhztaIcc7Wh1eAsAAQT1AQAABBQAAABQSwMEFAAAAAgAoWRNW+xw0GIQAgAAtAcAABIAHAB3b3JkL2ZvbnRUYWJsZS54bWxVVAkAA54c7WieHO1odXgLAAEE9QEAAAQUAAAAvZPBbqMwEIbvlfoOlu8NhpA0RSFV222kvexh1T6AY0ywFtvI44Tk7dcYiBSyuy3tqiCEGf75mPnHLO8PskR7bkBoleJwQjDiiulMqG2KX1/WNwuMwFKV0VIrnuIjB3y/ur5a1kmulQXk8hUkkqW4sLZKggBYwSWFia64ci9zbSS17tFsA0nNr111w7SsqBUbUQp7DCJC5vj6CrmjZZn3oHSeC8a/abaTXFkPCQwvHVYrKEQFZ8j6Pcham6wymnEA170sW6ikQp2zwviCJgUzGnRuJ663rjbPc4yQ+JUsB5TZOEr0Z8qc8cM40KIDBS7zAiaycbD5CSayIexjZQ0p2W4UJ5r2FTW3Jn0IhMxmxThmP8GgyaWWFhSKCywf1+/sxDxKNwgkWfJ9q7Shm9KR3CZDbosgD0btZJobaieO+j6Qdwiv2mK6nxLViaLSUV6E5IB+8Br91JKqXtZJK6o08NCp97RMMWkanZMpmZHYXZFbxTg4T2EFNcDtKYUMBTmVojz2743/6kBSCcuKXrGnRjQdD0Ugtk6ygw1J8TMhJHper3EbCVP85CK3i9ljF4maSvxx10WmpwhpIsxz/GPYcpjnnDT915dB6+Bf/HzSOyO4aRx908tb59+d97TxMv60l1Jn3PzbzFwcePYRJ+PpVzv54MZevunho9uPsfewPT/rIdQC4P/sx4evdrFfwuo3UEsDBBQAAAAIAAAAIQCWFrgr1QIAAIgLAAARABwAd29yZC9kb2N1bWVudC54bWxVVAkAAzDQzhIw0M4SdXgLAAEE9QEAAAQUAAAApZZbb9sgFMffJ+07WH5v8S1OYjWttGab+jCpWrcPQIDEqAYsILd9+h3s+LJ5qxz3CXPg/PjDORxz93AShXdg2nAlV354G/gek0RRLncr/+ePLzcL3zMWS4oLJdnKPzPjP9x//HB3zKgie8Gk9QAhTXYsycrPrS0zhAzJmcDmVnCilVFbe0uUQGq75YSho9IURUEYVF+lVoQZA+s9YnnAxr/gyGkcjWp8BGcHTBDJsbbs1DHCqyEztESLISiaAIIdRuEQFV+NSpFTNQAlk0CgakCaTSP9Y3PpNFI0JM2nkeIhaTGNNEgnMUxwVTIJg1ulBbbQ1TsksH7dlzcALrHlG15wewZmkDYYzOXrBEXg1RJETK8mzJFQlBUxbShq5e+1zC7+N62/k57V/pem9WDFuGVhuSViJ1sY2/jqMWdXu68vhaU6NaRZAeeopMl52VYHMZUGg3kDObx1AAdR+G1lC0detf+VtnUdhg44Rv4ldqKolb9NDIMR0XSI1mOMhD/XbJQIyOBu4UlH0zvccGTxaQDRAJASNvJn0TAWFwYi3e12HD7yWjWctOVw2uNME9MD0P1ViChudLjGufdYhlqaX4drYoScL7Y4xybvE9l1G5y1uLPonXe5e9+l+qrVvuxo/H20p668HuV1GwzSvyNYmveJeclxCVVXkOxpJ5XGmwIUwVXz4LZ4VQS8Ol1d49U3wGti7VUJ5Lmq5d/DO22j6Nm1JQwkWYk1foI0T8JlmqTz0K+s8Jezzhoks+VivpyBNYM3If0OJkiveD3/1JqetTPGYZA8fm6Na7bF+8IOpz/3JiMnwzBin/VYfiV89/ILBqFihVGUBG4iJHQ4W8A3qid8w45oFRTWMKmnaL7LbdfdKGuV6PoF2/ZGc4Ypg3XnUdXdKmV73d3eVt3LckQVBqymxITVcyozvIe/aheSrOCSPXNLQGWcVqOo2Xf1WUcEdU/o+99QSwMEFAAAAAgAAAAhAMrnZYorBAAAvgwAABEAHAB3b3JkL3NldHRpbmdzLnhtbFVUCQADMNDOEjDQzhJ1eAsAAQT1AQAABBQAAAC1V22PmzgQ/n7S/QfE58uG1ySLmq3yervV5lqVre6zAZNYa2Nkm03T0/33GwwO9BZVSav9hJln5pnxeGYM795/ZdR6wUISXsxt98axLVykPCPFfm5/edqOZrYlFSoyRHmB5/YJS/v93e+/vTtGEisFatICikJGLJ3bB6XKaDyW6QEzJG94iQsAcy4YUvAq9mOGxHNVjlLOSqRIQihRp7HnOBO7peFzuxJF1FKMGEkFlzxXtUnE85ykuH0YC3GJ38ZkzdOK4UJpj2OBKcTAC3kgpTRs7GfZADwYkpcfbeKFUaN3dJ0LtnvkIjtbXBJebVAKnmIp4YAYNQGSonMcvCI6+74B3+0WNRWYu45e9SMPryPwXhFMUvz1Oo5ZyzEGyz4Pya7jmZx5SNbj+blgegRZdRWF55s46kdt3uOSmcoO19GZMxrXtkihA5KHPiO+boPhme7EunxLekkFNtAjSQQSp375sTR62BdcoIRCOFCGFlSSpaOzmqOsH1ZTHZbJg6WTa9/B1PnGObOOUYlFCq0HI8tz7HENQMHzPFZIAVEkS0ypnmEpxQj8HqO9QAymj5FomwznqKLqCSWx4iUovSDY3tRQpgckUKqwiEuUAtuKF0pwavQy/hdXK5hkAhqttdBzrVvFzYwEiwIx2PB3c2/HM1xHVgly+cnYxrsb9l3+3xGHmS5Ihp/qRMfqRPEWgo/JN7wosg+VVAQY9fT7hQh+FAAuas8foTSeTiXeYqQqSNMbOdMnsaWk3BEhuHgoMqiNN3NG8hwLcECg1nZQPkTwo87zPUYZXKVv5LeS+G9Qhs70n6Asn5dcKc7uT+UBcv1rJ6nrfdwvX/ggyKRZfOZcnVVhbPnr6bKJtEYvQXzXCVabQWTibN1hm0XgO/4gsnLXbjCMhLPlaggJboOJuxhCJqG3CcIhZLH0Zv5sCFku3Wk4iKxW/srfDiIbZz28n83Km04HY9vees7tpj2d9kxYVH9qfBJmVTe2xRqLFWKJIMja1R8j41ojEc9LUhg8wTClcR+Jq8SAo1EDSIYo3UKJGcBp5BmR5Rrnek13SOw73lZDDEphyn44c9VTG4s/Ba/KBj0KVDYNa1TcIGgtSaEeCTNyWSWxsSrgXulBVZF9fBE6T116jpGCBtCD7xHpRtK6uBh9idtGoyKumwTvUFk2vZbs3blNyf6g3Lo9FLxl8M2qX5K912KexrwG0y8orXcG2u2ik3lG1tPzjczvZIGRBZ0sNLKwk02MbFLLDjBdBVx1z9D2ZlnLc04pP+LsvsNficwlmBI48fjEku5uu2kwSiTMoRKuQcWFwf7QmBtEGU8f6vs6aOT+YhGuF860gUN9fSo9qiC1n3G+RBJnLWZMw8b0n8nEmbjuajYKZpvb0WYaBKOZu7wdTafO1PW3rufPnH/bPjA/Hnf/AVBLAwQUAAAACAAAACEA24Vsw30EAACXHQAAEgAcAHdvcmQvbnVtYmVyaW5nLnhtbFVUCQADMNDOEjDQzhJ1eAsAAQT1AQAABBQAAADNmc1u4zYQx+8F+g6CgB4Tifq2sM4iySZFFttF0U3RMy3RlhB+CBRlx9d9mT5CH2tfoaRkyXLkxJIctz4pJjk/zQxnyL+dDx+fCdaWiOcpo1MdXJq6hmjE4pQupvqfj/cXga7lAtIYYkbRVF+jXP949fNPH1YhLcgMcblQkwyah6ssmuqJEFloGHmUIALzS5JGnOVsLi4jRgw2n6cRMlaMx4ZlArP8K+MsQnkuObeQLmGub3DRcz9azOFKGiugY0QJ5AI9bxlgMMQ1JkbQBVkjQDJCC3RR9mCUZyivOiBnFEh61SG540h7gvPGkawuyR9HsrukYBypU06kW+AsQ1ROzhknUMiPfGEQyJ+K7EKCMyjSWYpTsZZM06sxMKVPIzySVg2B2PFggm8QFiNsxzWFTfWC03Bjf9HYK9fDyn7zaCwQ7vda+bqJgZ4FzkVty/vkrjL/xKKCICrKrBkcYZlHRvMkzZrTgYylycmkhizfSsCSYL052UDPVnvtaPtUbcMW2Mf9zd4RXHn+NhGYPXZTIRqLPi7svrP2hMgK3r54VGpayQU9D58aYHUAXoR6XhY1I9gwjGjb3YqT9myrmuM1nDRuccY50wLExSCEZdd+qIcyb7HyWMTJMFy9R4ayhQImME/aRDQsQLfBrUkr39niuKb6lbMi29LS42gP2+N1RYcFaHovdzDLj3PmWwIzeeqSKHxYUMbhDEuPZKtpslu0cge0qlzVQ6s6QKv3WisLSFOnln4lhRqc5YLDSHwtiLbz6UFWuxR8khlyJFUeV4OVprueC8RvOIJPaomi0Fy9LVxCeQUAD1jejenrhpohBRbpF7RE+HGdoXpNsp7xNP5NzWE1V60VJMP1Chfc3Tp3ZlDN4KWaSOWjcioUGZb3remYE9M0QelD6WPjRGUnZeg9aQZnBcZINMRHeQfVUz++/9OMf47qUYzmm+XZ71w9UqrCVMNT3bdKTxJIF6Ugtj1TrTWaxXzzuGdU5Cq5eZTKOvy2JjOGS9NrmbedgZRKcIzmUGZmAyspRunYy0yATibsckTeZ/JSXCK14ujMsKF5AY4zLjG3rOAp4tpXtGpl58VolHcXDsua1cma+/5Z+/H976F5s4A3Lm9/ydXqO1neytru2LAE2Xsa7AQJGtxwVhD83x3nnGXHyTycdce5Z9pxjj3yCH/vjvPOtONcc+RR/n4d559lx7n+yLP6P+q44Ew7znNGHuHHd5yxo24PSl8wRvq6gW8C++b6OOl7d+c5wL91+kjf+57bGKMoJRDv3cdfwOU7a9+echVMRhYlZivEvyAh92J/RNbgiA6p1p5aEtwcE9IfjEC6PyJ7X0Q8XSQDBCUIeoTUVX/3I0N6s+acwTt0SP71VGynKzp3cEiHhFtPOXWyovOGF11HU/Uquq4AOknR+YN36JAC6ilaTld0wfCQDmiXnoriZEU3GV50HVnxStF1NQAt737auvPVD2dhXJQ/q5WDMlTHn3jWy5/LHpprv34X3cO09jGdwHWB7wDwOhO0mUbrH6pX/wJQSwMEFAAAAAgAAAAhAL5+dmJWAQAA0AMAABQAHAB3b3JkL3dlYlNldHRpbmdzLnhtbFVUCQADMNDOEjDQzhJ1eAsAAQT1AQAABBQAAACd01FvwiAQAOD3JfsPhHelumlMYzVZFpe9LEu2/QAKV0sGXAO46n79aLWuiy92T0DLfbnjYLneG02+wHmFNqOTcUIJWIFS2W1GP943owUlPnAruUYLGT2Ap+vV7c2yTmvI3yCEuNOTqFifGpHRMoQqZcyLEgz3Y6zAxp8FOsNDXLotM9x97qqRQFPxoHKlVTiwaZLM6Ylx1yhYFErAI4qdARvaeOZARxGtL1XlO62+RqvRycqhAO9jPUYfPcOVPTOT+wvIKOHQYxHGsZhTRi0VwydJOzP6F5gNA6YXwFzAfpixOBksRvYdJYc587OjZM/5XzI9QO4GEdO7Lo9maMJ7lpdBlsO4rkesieWBl9yXfRGGFTg7cwfTnLcR6fPWouO5jlK8QSReAtLC5NiFZiDHxpKuBNKeC13FJ4ZVUEZ9wwbdg8Pag2PNZ6411q8vT3HB/rzD1Q9QSwMEFAAAAAgAAAAhAD+v4WZfDwAADaYAAA8AHAB3b3JkL3N0eWxlcy54bWxVVAkAAzDQzhIw0M4SdXgLAAEE9QEAAAQUAAAA3Z1tc9s2Esff38x9B45e9V6ksp5lT92O7STnzCWpWzvX1xAJWaj5oCOpOO6nPwB8EKUlKC64UdRMZlqL4v4I4L+7xIIU+dMvXwLf+czjREThZW/w41nP4aEbeSJ8vOx9enj7at5zkpSFHvOjkF/2XnjS++Xnf/7jp+eLJH3xeeJIQJhcBO5lb5Wm64t+P3FXPGDJj9Gah/LLZRQHLJUf48d+wOKnzfqVGwVrloqF8EX60h+enU17OSZuQ4mWS+Hy15G7CXiYavt+zH1JjMJkJdZJQXtuQ3uOYm8dRy5PEtnpwM94ARNhiRmMASgQbhwl0TL9UXYmb5FGSfPBmf4r8LeACQ4wBICpy7/gGPOc0ZeWVY7wcJxpyRFehWPXmArA26AQw1HRDvU/ZV5hJV7qrXC4QqO+smUpW7FkVSVyXAcnJe4lUOMduBfvHsMoZgtfkqQHOdIJHA12MhXU/5xMWKfogqPHpfezjC4vcl/zJdv4aaI+xndx/jH/pP/3NgrTxHm+YIkrxGXvKhZMDvHzBWdJepUI9iBbLg8fCNmS26swEerLlfqjsrObXPYeRCBD+SN/dn6PAhY6P1xH3otzc/+vXl8d6InHodzzM/Mve8NsU/JXuWFcbLlJ9rf5LHwstvHw1af7ausqmxbCk01i8av7K204GF/44pGlm1g2S33ShCwRxd6N7Db/km5k++XO/Xw8+vujtC4/ZXvtDalMGDJ93GdZTH7Ll+8j94l796n84rJ31ss2fnp3F4solpnqsnd+nm+854G4FZ7Hw8qO4Up4/I8VDz8l3Ntu/+2tzjb5BjfahPLv0WyqZfYT780Xl69V7pLfhkzp9VEZaG02Yntwbf6/AjbIB7jOfsWZSuDOYB9xjkYMlUVS6W09c7PX9wH6QKNjHWh8rANNjnWg6bEONDvWgebHOtD51z6QCD2Z3wf1hwHUQxxDNKI5hmBDcwyxhOYYQgXNMUQCmmNwdDTH4MdojsFNEZw0ck1eWHH2kcHbm7mHzxF23MOnBDvu4TOAHfdwwrfjHs7vdtzD6dyOezh723EPJ2s8N5tqOe9kmIVp5yhbRlEaRil31PS0M42FkqWrWhqeOunxmKSTBJgss+Un4s40l+nPhz1k0u18nqqCzomWzlI8quKkc8N5+Jn70Zo7zPMkjxAYc1k+GUbExqdjvuQxD11O6dh0UF+E3Ak3wYLAN9fskYzFQ494+AoiSVIoHZpt0pUKEkHg1AFz44hgzsLI8sN7kXQfKwVxrje+z4lYH2lcTLO61wYa07000JjulYHGdC8MKppRDVFOIxqpnEY0YDmNaNwy/6Qat5xGNG45jWjcclr3cXsQqc/3Zx2D9mt3N36UUCS8e/EY6vXTzqR8zdS5YzF7jNl65ahl54MzLfRx9JLzA8U5rSRRzeu1i6hVZxFuug/oDo0quEoeUXiVPKIAK3ndQ+yDnCarCdotTT1zv1mktUHbviq4Z/4mm9B2jzaWdvewbQC8FXFCFgb1WAIP/qims7dEU71tK7s3bMvqHlb7WYm0eTmSoJV+5D7RpOHblzWPZVn21Jn0NvL96Jl7dMT7NI4yX6uG/HDYOuTfBOsVS0QCEO1P9cUdDM4Htu7coTufiZBGtzevAiZ8h24Gcfvw4b3zEK1VmakGhgZ4HaVpFJAx85XAH/7gi3/RNPBKFsHhC1Fvr4iWhzTsRhCcZDJS5BGR5DRThILkHKp5/+Evi4jFHg3tLubZTUMpJyLes2DtU8WWzIvPMv8QzIY0778sFmpdiCqoHkhglWXDZLP4k7vdU93HyCFZGfp1k+r1Rz3V7X61dwfXfZqwg+s+RdBqytOD8l+Czu7gund2B0fV2RufJYkwXkK15lF1t+BR97d78ZfzIj+KlxufbgALINkIFkCyIYz8TRAmlD3WPMIOax51fwldRvMIluQ079+x8MjE0DAqJTSMSgYNo9JAw0gF6H6HTgXW/TadCqz7vToZjGgKUIFR+Rnp6Z/oKk8FRuVnGkblZxpG5WcaRuVno9cOXy7lJJjuFFNBUvlcBUl3oglTHqyjmMUvRMg3Pn9kBAukGe0ujpbq1yRRmN3ETTGd3SxSysl2hqMS+Q++IGuaYlG2i2BFlPl+FBGtrW1PONpy9961Q2b65xydm3DnM5evIt/jsaFPjfXy/Zq5Ai6dtr9Y8l48rlLnflWu9lcx07ODlkXBvmN2+IB1Yz4dNl5m8sQmKBoKf0wxHbU3HgLj8WHj7Uxix3LS0hIec3rYcjtL3rGctbSEx5y3tBwBy6Z4eM3ip1pHmDX5T1njGZxv1nhhvjCuPWyTI5WWdS44a/KinVBxrlxXXS2A6rSLGbN9u+Ax22OiyEzBhJOZ0jquzIimAPudfxZJ7Rr1gevf5d0TIO+PW2fO3zZRCi5TD9v/qOudnDiFCXdqOaP2F652sox5HFunGzOidd4xI1onIDOiVSYymqNSkpnSOjeZEa2TlBmBzlbwjIDLVtAel62gvU22ghSbbNVhFmBGtJ4OmBHoQIUIdKB2mCmYEahABeZWgQop6ECFCHSgQgQ6UOEEDBeo0B4XqNDeJlAhxSZQIQUdqBCBDlSIQAcqRKADFSLQgWo5tzeaWwUqpKADFSLQgQoR6EAddwxUaI8LVGhvE6iQYhOokIIOVIhABypEoAMVItCBChHoQIUIVKACc6tAhRR0oEIEOlAhAh2ok46BCu1xgQrtbQIVUmwCFVLQgQoR6ECFCHSgQgQ6UCECHagQgQpUYG4VqJCCDlSIQAcqRKADddoxUKE9LlChvU2gQopNoEIKOlAhAh2oEIEOVIhABypEoAMVIlCBCsytAhVS0IEKEehAhYgm/8wvUZpusx/gVz2Nd+wjfueTNer36k+5d9ZQ26OKVplZ7X+LcB1FT07tDw9Ho/YQsfBFpJeoDZfVq9wZ+sLnrzfNv/Bp8RiPtl3Jfwuhr5kC+LitJVhTGTe5fNUSFHnjJk+vWoJZ57gp+1YtwWlw3JR0dVwWN6XI0xEwbkozFeOBwbwpW1fM4RA35eiKIRzhpsxcMYQD3JSPK4YTRyXnfetJy3GalveXAkKTO1YIMzOhyS2hVsa1/daimQlt1TMT2spoJqD0NGLwwppRaIXNKDupYZhhpbYPVDMBKzUkWEkNMPZSQ5S11BBlJzVMjFipIQErtX1yNhOspAYYe6khylpqiLKTGp7KsFJDAlZqSMBK3fGEbMTYSw1R1lJDlJ3UcHKHlRoSsFJDAlZqSLCSGmDspYYoa6khyk5qUCWjpYYErNSQgJUaEqykBhh7qSHKWmqIapJar6LYV0sVc9wkrGKIOyFXDHHJuWJoUS1VrC2rpQrBslqCWtlVS1XR7Kqlqnp21VJVRrtqCehpVy3VCmtXLdUqbFctmaXGVUt1UtsHql21VCc1rloySo2rlhqlxlVLjVLjqiWz1LhqqU5qXLVUJ7V9crarloxS46qlRqlx1VKj1LhqySw1rlqqkxpXLdVJjauW6qTueEK2q5YapcZVS41S46ols9S4aqlOaly1VCc1rlqqkxpXLRmlxlVLjVLjqqVGqXHVkllqXLVUJzWuWqqTGlct1UmNq5aMUuOqpUapcdVSo9S4aumDNBEEj4C6D1icOnTPi7tlySpl3R9O+CmMeRL5n7nn0Hb1PaqX/eed118ptn6dn9w/lWOmnoBe+bmSlz0BNgfqHd955WuqlLFqiZO/5yvfrBucX67NjqgNDxyqhOfXigcAv325lT7Cgsle/RrWHTxUD0as2a4cotheHOZmxeLs262rFvuc7/fl+SJO1Avcsq/Pzoaj0evZdbbXOns12xPn64/y+P3ig9SHJ/pTkv2AVpov1DPF5AiMpvq3V2yZ8viyN8+jNsqe2vT+s18eKZcuP0btW+CKV76xPyuvfNt/H5z68k2+TX2vXwlXa+kmaWXztfBE1jhXRXnZrrfj2VT7ht5ZZ4DLHtPxv92sbkpR9xm8zQjbF8gVF5urL5AbF30tXu1m4zxDo/MMKZ1n2MJ5tmGZ7bcTlF/ZvQYt3WvwfbrXaAjdK9vW0b1GRvcaUbrX6Dtxr2Gzex1yomO4ynAOXSXb1tFVxkZXGVO6yvjEXWVe9ZSx0VNGX8dTRPbfm4TEbzp6xMToERNKj5h8Hx4xPs3c0dEHpkYfmFL6wPTEfcAs++ToiWByrv7tO4F609LWBR6EeoPv1ZTAA2ZGD5hResDsb+sB0yME/pE1nxs1n1NqPj8pzaGys6PH9nCm/rXR+TXFnO/cqPM5pc7nJ67z/AgRTK+sKweVufkD1Q3rX/mLkcon++jXIu1rbnh7kkGvQTu9zO1O1SpsQ5v1Km3jwl3+sHaTQ7X2qHThZ1LLP96FyqGe83fYZy31vrBeseMN9/0PLNs7Wpt39fkyzb4dnM1rvl9kr4Qw2sf62oER0N9tTL/shHm8s5dE5j9qMa6T6keGweHOHiXWcaRb+rC7SeTQ6OXe/fbtrIHut/K2WG51tnlmL3HVxoEpXQ0OpCpz8vle1qO6LHciJR02SjokknSIO/t8/wp3WXFEKjxqVHhEpPDoayn8d1/0Q6o1blRrTKTW+NTUOvbCG1KVSaMqEyJVJqemysnpMG3UYUqkw/TUdDjqahRSklmjJDMiSWanJslpiTBvFGFOJML81EQ46koOUpLzRknOiSQ5PzVJvslyWvZgi/2xzrZSrKNpUtMi2iAv2FBrZNtF7r0L4656fcWXdMP8/En6jctjxyyBtk3W3XpV9PuJx+XgbifLZXqcwunzhDgRbiWqdYOu4VbxJbP6p1m2Hl+z+iAtX6K9L1D5BUWoFrDGaB1YRGu4CbI/hA/vhyq/BDE9mB64Je+bTECAVwwm36Lm3RHL5BZdQ3fXvczecOJzxq8sWX3MZq8B2Fcm20oRrZrUFKpDmztrD92ANige3venW3BUEcvj2khtmGSOz9S/NhpS18PbgasVp2vMVBQ2a3IwYI46cvUOrC6fbN+rsT9We6/dOOTRcChGYwv3FPpSl7pQpZ6R12LO19Jdyk7nD44rn2a3323wuDuco9R4BOqEetg7jnifVT4W9Ylu920oFAmverimvDeyKSjW117lAqneL5GelL9X+y91j5yTZUeuJ61OPuyW6+PlpdSvfKT+tmeHfhgxKjJ7NcbmU90afWU3+0SS/L/peijwo0bX7Xo62AmSAx57cnHfmCO3z9Y0DeB2j65Zsrjmh8qSi+yo+WglMqn4N2xNM3ZgSjmpH9Hir+Tn/wNQSwMECgAAAAAAk2RNWwAAAAAAAAAAAAAAAAsAHAB3b3JkL3RoZW1lL1VUCQADhhztaIcc7Wh1eAsAAQT1AQAABBQAAABQSwMEFAAAAAgAAAAhAGeA/LSbBgAAzSAAABUAHAB3b3JkL3RoZW1lL3RoZW1lMS54bWxVVAkAAzDQzhIw0M4SdXgLAAEE9QEAAAQUAAAA7VlPb9s2FL8P2HcgdHf1x5IsBXUL/23XJm3RpB16ZGRaYkyJAkknMYoCQ3vaZcCAbthlwG47DMMKrMCKXfZhCrTYug8xSnZs0abatE23AksMxCL5e48/vvf4+ExdvHycEnCIGMc0axv2BcsAKIvoCGdx27izN2wEBuACZiNIaIbaxgxx4/KlTz+5CLdEglIEpHzGt2DbSITIt0yTR7Ib8gs0R5kcG1OWQiGbLDZHDB5JvSkxHcvyzRTizAAZTKXam+MxjhDYK1Qal06UD4j8lwledESE7UbljFWJEjua2MUXn/EeYeAQkrYh5xnRoz10LAxAIBdyoG1Y5Z9hXrpoLoWIqJGtyA3Lv4XcQmA0cUo5Fu8vBa2BE7j2Ur8z17+JGwTFZ6mvBMAokiu1N7C251uBs8BWQPNHje6wZTdVfEV/c1N/6HcdV8E3V3h3c43DcND3FLy7wnsb+I7ldMOmgvdWeH8D7w46LWeg4EtQQnA22UT7rSDwF+glZEzJVS089H2r1V/AVyizEl1z+UzUxVoKDygbSkDpXChwBsQsR2MYSVwnF5SDPuY5gTMD5DCjXHZbjm3LwHMtZ/kpLQ63EKxIz7sivtFV8AE8YjgXbeOa1GpUIC+ePXv+8Onzh789f/To+cNfwDaOE6GRuwqzuCr36sev//7+C/DXrz+8evyNHs+r+Jc/f/ny9z9ep14otL598vLpkxffffXnT4818A6D+1X4Hk4RBzfQEbhNU7lAzQRon72dxF4CcVWik8UcZrCQ0aAHIlHQN2aQQA2ui1Q73mUyXeiAV6YHCuHdhE0F1gCvJ6kC3KGUdCnTrul6MVfVCtMs1k/OplXcbQgPdXP31rw8mOYy7rFOZS9BCs1bRLocxihDAhRjdIKQRuwexopdd3DEKKdjAe5h0IVYa5I9vC/0QldxKv0y0xGU/lZss3MXdCnRqe+jQxUp9wYkOpWIKGa8AqcCplrGMCVV5DYUiY7k7oxFisG5kJ6OEaFgMEKc62RusplC9zqUeUvr9h0yS1UkE3iiQ25DSqvIPp30EpjmWs44S6rYz/hEhigEt6jQkqDqDina0g8wq3X3XYzE2+3tOzIN6QOkGJky3ZZAVN2PMzKGSKe8w1IlxXYY1kZHdxorob2NEIFHcIQQuPOZDk9zqid9LZFZ5SrS2eYaVGO1aGeIy1qpKG40jsVcCdldFNMaPjuztcQzg1kKWZ3mGxM1ZAb7TG5GXbySaKKkUsyKTasncZOn8FRabyVQCauizfXxOmPZ2+4xKXPwDjLorWVkYj+1bfYgQfqA2YMYbOvSrRSZ6kWK7VSKTbVyY3XTrtxgrhU9Kc7eUAH9N5XPB6t5zr7aqUso6zVOHW69sulRNsIff2HTh9PsFpJnyXldc17X/B/rmrr9fF7NnFcz59XMv1bNrAoYs3rZU2pJa29+xpiQXTEjaJuXpQ+Xe380lJ1loxRaXjTliXxcTKfgYgbLZ8Co+ByLZDeBuZzGLmeI+UJ1zEFOuSyfjFrdZfE1TXfoaHGPZ5/cbUoBKFb9lrfsl6WamPf6rdVF6FJ92Yp5lYBXKj09icpkKommhkSreToStnVWLEINi8B+HQuz4hV5OAFYXIt77pyRDDcZ0qPCT3P5E++euafrjKku29EsL3TPzNMKiUq4qSQqYZjIw2O9+4x9HYZ6VztaGq3gQ/ja3MwNJFNb4EjuuaYn1UQwbxtj+bNJPqa51MeLTAVJnLWNSCwM/S6ZJWdc9CFP5rByaL7+FAvEAMGpjPWqG0i24mY7LevjJRdaH5/lzHUno/EYRaKmZ9WUY3Ml2tH3BBcNOpWkd5PREdgnU3YbSkN5Lbsw4AhzsbTmCLNKcK+suJauFltReQO02qKQ5AlcnCjVZD6Hl89LOpV1lEzXV2XqTLgfD8/i1H2z0FrSrDlAWrVZ7MMd8hVWTT0rT5vrwsB6/Snx/gdChVqgp9bUU6s7O86wIKhM59fYzan15nueButRa1bqyrK18XKb7h/IyO/LanVKBJ9fkB3L8rt38lpyngnK3pPscizAlOG2cd/yOm7P8XoNK/AGDbfpWo3A6zQbHc9r2gPPtvpd54E0ikhS25vPPZQ/9sls8e6+7N94f5+elNoXIpqatKyDzVK4fH9vO/Xv7wGWlrnvO8OwGXb9RtjsDBtuvxs0wp7fbfT9Xqs/7Pe8IBw+MMBhCXY7zZ7rD4KGb/d6Dde3CvpB2Gi5jtNxW51g4HYeLGwtV37yfWLektelfwBQSwMECgAAAAAAk2RNWwAAAAAAAAAAAAAAAAsAHAB3b3JkL19yZWxzL1VUCQADhhztaIcc7Wh1eAsAAQT1AQAABBQAAABQSwMEFAAAAAgAAAAhALO+ix3+AAAAtgMAABwAHAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzVVQJAAMw0M4SiBztaHV4CwABBPUBAAAEFAAAAK2TzWrDMBCE74W+g9h7LTttQwmRcymBXFv3AWR7/UP1Y6RNWr99RUoShwbTg44zYme+hdV6860VO6DzvTUCsiQFhqaydW9aAR/F9uEFmCdpaqmsQQEjetjk93frN1SSwpDv+sGzkGK8gI5oWHHuqw619Ikd0ISXxjotKUjX8kFWn7JFvkjTJXfTDMivMtmuFuB29SOwYhzwP9m2afoKX22112joRgX3SBQ28yFTuhZJwMlJQhbw2wiLqAg0KpwCHPVcfRaz3ux1iS5sfCE4W3MQy5gQFGbxAnCUv2Y2x/Ack6GxhgpZqgnH2ZqDeIoJ8YXl+5+TnJgnEH712/IfUEsBAh4DFAAAAAgAAAAhADKRb1deAQAApQUAABMAGAAAAAAAAQAAAKSBAAAAAFtDb250ZW50X1R5cGVzXS54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMKAAAAAACTZE1bAAAAAAAAAAAAAAAACQAYAAAAAAAAABAA7UGrAQAAZG9jUHJvcHMvVVQFAAOGHO1odXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAAAAhACEYr1llAQAAxQIAABAAGAAAAAAAAQAAAKSB7gEAAGRvY1Byb3BzL2FwcC54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMUAAAACAAAACEACvOn+GYBAADtAgAAEQAYAAAAAAABAAAApIGdAwAAZG9jUHJvcHMvY29yZS54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMKAAAAAACTZE1bAAAAAAAAAAAAAAAABgAYAAAAAAAAABAA7UFOBQAAX3JlbHMvVVQFAAOGHO1odXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAAAAhAB6RGrfpAAAATgIAAAsAGAAAAAAAAQAAAKSBjgUAAF9yZWxzLy5yZWxzVVQFAAMw0M4SdXgLAAEE9QEAAAQUAAAAUEsBAh4DCgAAAAAAk2RNWwAAAAAAAAAAAAAAAAUAGAAAAAAAAAAQAO1BvAYAAHdvcmQvVVQFAAOGHO1odXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAoWRNW+xw0GIQAgAAtAcAABIAGAAAAAAAAQAAAKSB+wYAAHdvcmQvZm9udFRhYmxlLnhtbFVUBQADnhztaHV4CwABBPUBAAAEFAAAAFBLAQIeAxQAAAAIAAAAIQCWFrgr1QIAAIgLAAARABgAAAAAAAEAAACkgVcJAAB3b3JkL2RvY3VtZW50LnhtbFVUBQADMNDOEnV4CwABBPUBAAAEFAAAAFBLAQIeAxQAAAAIAAAAIQDK52WKKwQAAL4MAAARABgAAAAAAAEAAACkgXcMAAB3b3JkL3NldHRpbmdzLnhtbFVUBQADMNDOEnV4CwABBPUBAAAEFAAAAFBLAQIeAxQAAAAIAAAAIQDbhWzDfQQAAJcdAAASABgAAAAAAAEAAACkge0QAAB3b3JkL251bWJlcmluZy54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMUAAAACAAAACEAvn52YlYBAADQAwAAFAAYAAAAAAABAAAApIG2FQAAd29yZC93ZWJTZXR0aW5ncy54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMUAAAACAAAACEAP6/hZl8PAAANpgAADwAYAAAAAAABAAAApIFaFwAAd29yZC9zdHlsZXMueG1sVVQFAAMw0M4SdXgLAAEE9QEAAAQUAAAAUEsBAh4DCgAAAAAAk2RNWwAAAAAAAAAAAAAAAAsAGAAAAAAAAAAQAO1BAicAAHdvcmQvdGhlbWUvVVQFAAOGHO1odXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAAAAhAGeA/LSbBgAAzSAAABUAGAAAAAAAAQAAAKSBRycAAHdvcmQvdGhlbWUvdGhlbWUxLnhtbFVUBQADMNDOEnV4CwABBPUBAAAEFAAAAFBLAQIeAwoAAAAAAJNkTVsAAAAAAAAAAAAAAAALABgAAAAAAAAAEADtQTEuAAB3b3JkL19yZWxzL1VUBQADhhztaHV4CwABBPUBAAAEFAAAAFBLAQIeAxQAAAAIAAAAIQCzvosd/gAAALYDAAAcABgAAAAAAAEAAACkgXYuAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzVVQFAAMw0M4SdXgLAAEE9QEAAAQUAAAAUEsFBgAAAAARABEAqQUAAMovAAAAAA==";function IE(e){return kE(e)}function Z_e(e){return n1e(e)}function Q_e(e,t){const{nodeType:n,anchor:r,attrs:i}=t,o=$_e(e,r);return n==="hyperlink"?{kind:"hyperlink",hyperlink:{...typeof i?.href=="string"?{href:i.href}:{},...typeof i?.anchor=="string"?{anchor:i.anchor}:{},...typeof i?.tooltip=="string"?{tooltip:i.tooltip}:{},inlines:[{kind:"run",run:{text:o}}]}}:{kind:"run",run:{text:o}}}function R$t(e,t){const n=e.attrs;return n?n.sdBlockId===t||n.paraId===t||n.blockId===t||n.id===t||n.uuid===t:!1}function $_e(e,t){try{const n=e.state.doc;let r="";return n.descendants((i,o)=>{if(R$t(i,t.start.blockId)&&i.isBlock){const s=o+1+t.start.offset,a=o+1+t.end.offset;return r=n.textBetween(s,Math.min(a,o+i.nodeSize-1),""),!1}return!0}),r}catch{return""}}function L$t(e,t){const n=e.state.doc,r=[];n.forEach(s=>{r.push(kE(s))});const i=N$t(e),o=O$t(e);return{modelVersion:"sdm/1",body:r,...i.length>0&&{sections:i},...o&&{numbering:o}}}function N$t(e){let t;try{t=Zs(e)}catch{return[]}return t.map(n=>M$t(n.domain))}function M$t(e){const t={id:e.address.sectionId};return e.breakType&&(t.breakType=e.breakType),e.pageSetup&&(t.pageSetup=e.pageSetup),e.margins&&(t.margins={top:e.margins.top,right:e.margins.right,bottom:e.margins.bottom,left:e.margins.left,gutter:e.margins.gutter}),e.headerFooterMargins&&(t.headerFooterMargins=e.headerFooterMargins),e.columns&&(t.columns=e.columns),e.lineNumbering&&(t.lineNumbering=e.lineNumbering),e.pageNumbering&&(t.pageNumbering=e.pageNumbering),e.titlePage!=null&&(t.titlePage=e.titlePage),e.oddEvenHeadersFooters!=null&&(t.oddEvenHeadersFooters=e.oddEvenHeadersFooters),e.verticalAlign&&(t.verticalAlign=e.verticalAlign),e.sectionDirection&&(t.sectionDirection=e.sectionDirection),t}var D$t=new Set(["bullet"]);function O$t(e){const t=e.converter?.translatedNumbering;if(!t)return;const{definitions:n={},abstracts:r={}}=t,i=Object.entries(n);if(i.length===0)return;const o={definitions:{}};for(const[s,a]of i){if(!a)continue;const l=a.abstractNumId,c=(l!=null?r[l]:void 0)?.levels;if(!c)continue;const u=[];for(const d of Object.values(c)){const f=d.numFmt?.val,h=a.lvlOverrides?.[d.ilvl]?.startOverride??d.start;u.push({level:d.ilvl,kind:f&&D$t.has(f)?"bullet":"ordered",...f!=null&&{format:f},...d.lvlText!=null&&{text:d.lvlText},...h!=null&&{start:h},...d.lvlRestart!=null&&{restartAfterLevel:d.lvlRestart}})}u.length>0&&(o.definitions[s]={levels:u})}return Object.keys(o.definitions).length>0?o:void 0}function kE(e){const t=e.type.name;switch(t){case"paragraph":return F$t(e);case"heading":return B$t(e);case"table":return z$t(e);case"bulletList":case"orderedList":return W$t(e,t==="orderedList");case"listItem":return j$t(e);case"image":return q$t(e);case"tableOfContents":return Y$t(e);case"sdt":case"structuredContentBlock":return X$t(e);case"sectionBreak":return Z$t(e);case"pageBreak":case"horizontalRule":return Q$t(e);case"drawing":return $$t(e);default:return een(e)}}function F$t(e){const t=e.attrs,n=tA(t?.paragraphProperties?.styleId);return n&&n>=1&&n<=6?e1e(e,t,n):H$t(e,t)}function B$t(e){const t=e.attrs;return e1e(e,t,e.attrs?.level??tA(t?.paragraphProperties?.styleId)??1)}function H$t(e,t){const n=EE(e),r={kind:"paragraph",id:af(e),paragraph:{inlines:n}},i=t?.paragraphProperties?.styleId??e.attrs?.paragraphStyle;i&&(r.paragraph.styleRef=i);const o=o1e(t);return o&&(r.paragraph.props=o),r}function e1e(e,t,n){const r=EE(e),i={kind:"heading",id:af(e),heading:{level:n,inlines:r}},o=t?.paragraphProperties?.styleId??e.attrs?.paragraphStyle;o&&(i.heading.styleRef=o);const s=o1e(t);return s&&(i.heading.props=s),i}function z$t(e){const t=e.attrs,n=e.attrs,r=[];e.forEach(l=>{l.type.name==="tableRow"&&r.push(U$t(l))});const i={kind:"table",id:af(e),table:{rows:r}},o=t?.tableProperties?.tableStyleId??n?.tableStyleId;o&&(i.table.styleRef=o);const s=fen(t,n);s&&(i.table.props=s);const a=n?.grid??n?.tableGridModel??t?.tableGrid?.colWidths;if(a&&Array.isArray(a)){const l=a.map(c=>typeof c=="number"?c:c?.col??c?.width).filter(c=>typeof c=="number"&&Number.isFinite(c)).map(c=>({width:c}));l.length>0&&(i.table.columns=l)}if(n?.needsTableStyleNormalization===!0){const l=Hj(i.ext)?{...i.ext}:{},c=Hj(l.superdoc)?{...l.superdoc}:{};c.needsTableStyleNormalization=!0,i.ext={...l,superdoc:c}}return i}function U$t(e){const t=[];e.forEach(i=>{(i.type.name==="tableCell"||i.type.name==="tableHeader")&&t.push(V$t(i))});const n={cells:t},r=e.attrs;return(r?.minHeight!==void 0||r?.cantSplit!==void 0)&&(n.props={},r.minHeight!==void 0&&(n.props.minHeight=r.minHeight),r.cantSplit!==void 0&&(n.props.cantSplit=r.cantSplit)),n}function V$t(e){const t=e.attrs,n=[];e.forEach(o=>{n.push(kE(o))});const r={content:n};t?.colspan&&t.colspan>1&&(r.colSpan=t.colspan),t?.rowspan&&t.rowspan>1&&(r.rowSpan=t.rowspan);const i=t?.tableCellProperties?.vAlign??t?.verticalAlign;return i&&(r.props={verticalAlign:i}),r}function W$t(e,t){const n=[];e.forEach(o=>{o.type.name==="listItem"&&n.push(G$t(o))});const r={kind:"list",id:af(e),list:{items:n,levels:[{level:0,kind:t?"ordered":"bullet"}]}},i=e.attrs;return i?.listStyleId&&(r.list.styleRef=i.listStyleId),r}function G$t(e){const t=[];return e.forEach(n=>{t.push(kE(n))}),{level:e.attrs?.level??0,content:t}}function j$t(e){const t=EE(e);return{kind:"paragraph",id:af(e),paragraph:{inlines:t}}}function q$t(e){const t=e.attrs;return{kind:"image",id:af(e),image:{src:t?.src??"",...t?.alt?{alt:t.alt}:{},...t?.size?{geometry:{width:t.size.width,height:t.size.height}}:{}}}}function Y$t(e){const t=e.attrs?.instruction??"",n=db(t);return{kind:"toc",id:af(e),toc:{...t?{instruction:t}:{},...n.source?{sourceConfig:n.source}:{},...n.display?{displayConfig:n.display}:{},...n.preserved?{preservedSwitches:n.preserved}:{},entryCount:e.childCount}}}var K$t={unlocked:"none",sdtLocked:"sdt",contentLocked:"content",sdtContentLocked:"both"};function t1e(e){const t=K$t[e.lockMode],n=e.controlType??e.type;return{...e.tag?{tag:e.tag}:{},...e.alias?{alias:e.alias}:{},...typeof n=="string"?{type:n}:{},...e.appearance?{appearance:e.appearance}:{},...e.placeholder?{placeholder:e.placeholder}:{},...t&&t!=="none"?{lock:t}:{}}}function X$t(e){const t=[];return e.forEach(n=>{t.push(kE(n))}),{kind:"sdt",id:i1e(e),sdt:{...t1e(e.attrs??{}),scope:"block",...t.length>0?{content:t}:{}}}}function J$t(e){const t=EE(e);return{kind:"sdt",id:i1e(e),sdt:{...t1e(e.attrs??{}),scope:"inline",...t.length>0?{inlines:t}:{}}}}function Z$t(e){return{kind:"sectionBreak",id:af(e),sectionBreak:{targetSectionId:e.attrs?.targetSectionId??""}}}function Q$t(e){const t=e.attrs?.breakType??"page";return{kind:"break",id:af(e),break:{type:t==="column"?"column":"page"}}}function $$t(e){return{kind:"drawing",id:af(e),drawing:{source:e.attrs?.source??{type:"unknown"},...e.attrs?.geometry?{geometry:e.attrs.geometry}:{},...e.attrs?.layout?{layout:e.attrs.layout}:{}}}}function een(e){const t=EE(e);return{kind:"paragraph",id:af(e),paragraph:{inlines:t}}}function EE(e){const t=[];return e.forEach(n=>{const r=n1e(n);t.push(r)}),t}function n1e(e){if(e.isText)return ren(e);switch(e.type.name){case"run":return ten(e);case"image":return oen(e);case"tab":return sen();case"hardBreak":case"lineBreak":return aen();case"footnoteRef":case"footnoteReference":return len(e);case"endnoteRef":case"endnoteReference":return cen(e);case"field":return uen(e);case"structuredContent":return J$t(e);default:return den(e)}}function ten(e){const t=(e.attrs??{}).runProperties,n=e.textContent;let r;if(e.forEach(a=>{r||(r=a.marks?.find(l=>l.type.name==="link"))}),r)return nen(e,r);const i={kind:"run",run:{text:n}},o=typeof t?.rStyle=="string"?t.rStyle:typeof t?.styleId=="string"?t.styleId:void 0;o&&(i.run.styleRef=o);const s=r1e(t);return s&&(i.run.props=s),i}function nen(e,t){const n=t.attrs,r={kind:"run",run:{text:e.textContent}},i=e.attrs?.runProperties,o=r1e(i);return o&&(r.run.props=o),{kind:"hyperlink",hyperlink:{...typeof n.href=="string"?{href:n.href}:{},...typeof n.anchor=="string"?{anchor:n.anchor}:{},...typeof n.tooltip=="string"?{tooltip:n.tooltip}:{},inlines:[r]}}}function r1e(e){if(!e)return;const t={};let n=!1;const r=l=>{if(typeof l=="boolean")return l;if(l&&typeof l=="object"){const c=l,u=c.val??c.value;return typeof u=="boolean"?u:typeof u=="string"?u!=="0"&&u!=="false"&&u!=="none":!0}if(typeof l=="string")return l!=="0"&&l!=="false"};r(e.bold??e.b)&&(t.bold=!0,n=!0),r(e.italic??e.i)&&(t.italic=!0,n=!0);const i=e.underline??e.u;if(i!==void 0&&i!=="none"&&i!==!1&&(t.underline=typeof i=="object"?i:{style:"single"},n=!0),r(e.strike??e.dstrike)&&(t.strikethrough=!0,n=!0),e.highlight){const l=e.highlight,c=typeof l=="string"?l:l?.val??l?.color;typeof c=="string"&&(t.highlight=c,n=!0)}if(e.color){const l=e.color;t.color=typeof l=="string"?{model:"rgb",value:l}:l,n=!0}const o=e.sz??e.size??e.fontSize;if(typeof o=="number")t.fontSize=o,n=!0;else if(typeof o=="string"){const l=Number.parseFloat(o);Number.isFinite(l)&&(t.fontSize=l,n=!0)}const s=e.rFonts??e.fontFamily;if(s){if(typeof s=="string")t.fontFamily=s,n=!0;else if(typeof s=="object"){const l=s.ascii??s.hAnsi??s.eastAsia??s.cs;typeof l=="string"&&(t.fontFamily=l,n=!0),t.fonts=s,n=!0}}const a=e.lang;return a&&(t.lang=typeof a=="string"?{val:a}:a,n=!0),r(e.caps)&&(t.caps=!0,n=!0),r(e.smallCaps)&&(t.smallCaps=!0,n=!0),r(e.vanish)&&(t.vanish=!0,n=!0),n?t:void 0}function ren(e){const t=e.marks,n=t.find(s=>s.type.name==="link");if(n)return ien(e,n);const r={kind:"run",run:{text:e.text??""}},i=men(t);i&&(r.run.styleRef=i);const o=gen(t);return o&&(r.run.props=o),r}function ien(e,t){const n=t.attrs,r={kind:"run",run:{text:e.text??""}},i=e.marks.filter(a=>a!==t),o=a1e(i);o&&(r.run.props=o);const s=s1e(i);return s&&(r.run.styleRef=s),{kind:"hyperlink",hyperlink:{...typeof n.href=="string"?{href:n.href}:{},...typeof n.anchor=="string"?{anchor:n.anchor}:{},...typeof n.tooltip=="string"?{tooltip:n.tooltip}:{},inlines:[r]}}}function oen(e){const t=e.attrs;return{kind:"image",image:{src:t?.src??"",...t?.alt?{alt:t.alt}:{},...t?.size?{geometry:{width:t.size.width,height:t.size.height}}:{}}}}function sen(){return{kind:"tab",tab:{}}}function aen(){return{kind:"lineBreak",lineBreak:{}}}function len(e){return{kind:"footnoteRef",footnoteRef:{...e.attrs?.id?{noteId:e.attrs.id}:{},...e.attrs?.noteId?{noteId:e.attrs.noteId}:{}}}}function cen(e){return{kind:"endnoteRef",endnoteRef:{...e.attrs?.id?{noteId:e.attrs.id}:{},...e.attrs?.noteId?{noteId:e.attrs.noteId}:{}}}}function uen(e){return{kind:"field",field:{...e.attrs?.fieldType?{fieldType:e.attrs.fieldType}:{},...e.attrs?.instruction?{instruction:e.attrs.instruction}:{},...e.attrs?.resultText?{resultText:e.attrs.resultText}:{},placement:"inline"}}}function den(e){return{kind:"run",run:{text:e.textContent??""}}}function af(e){const t=e.attrs?.sdBlockId;return typeof t=="string"&&t.length>0?t:void 0}function i1e(e){const t=e.attrs??{},n=t.id??t.sdBlockId;return typeof n=="number"?String(n):typeof n=="string"&&n.length>0?n:void 0}function Hj(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function fen(e,t){const n=e?.tableProperties,r={};let i=!1;const o=pen(n?.tableWidth??t?.tableWidth);o&&(r.width=o,i=!0);const s=n?.tableLayout??t?.tableLayout;(s==="fixed"||s==="autofit")&&(r.layout=s,i=!0);const a=hen(n?.justification??t?.justification);return a&&(r.alignment=a,i=!0),i?r:void 0}function hen(e){if(typeof e=="string")switch(e){case"start":case"left":return"left";case"end":case"right":return"right";case"center":case"inside":case"outside":return e;default:return}}function pen(e){if(!Hj(e))return;const t=typeof e.type=="string"?e.type.toLowerCase():void 0,n=typeof e.value=="number"?e.value:typeof e.width=="number"?e.width:void 0;if(t==="auto")return{kind:"auto"};if(t==="nil"||t==="none")return{kind:"none"};if(t==="pct"&&typeof n=="number"&&Number.isFinite(n))return{kind:"percent",value:n};if(t==="dxa"&&typeof n=="number"&&Number.isFinite(n))return{kind:"points",value:n/20};if(typeof n=="number"&&Number.isFinite(n))return{kind:"points",value:n}}function o1e(e){const t=e?.paragraphProperties;if(!t)return;const n=t,r={};let i=!1;return t.justification&&(r.alignment=t.justification==="both"?"justify":t.justification,i=!0),t.indent&&(r.indent=t.indent,i=!0),t.spacing&&(r.spacing=t.spacing,i=!0),t.keepNext!==void 0&&(r.keepWithNext=t.keepNext,i=!0),t.keepLines!==void 0&&(r.keepLines=t.keepLines,i=!0),t.pageBreakBefore!==void 0&&(r.pageBreakBefore=t.pageBreakBefore,i=!0),t.widowControl!==void 0&&(r.widowControl=t.widowControl,i=!0),t.outlineLvl!==void 0&&(r.outlineLevel=t.outlineLvl,i=!0),t.numberingProperties&&(r.numbering={numId:String(t.numberingProperties.numId??""),level:t.numberingProperties.ilvl},i=!0),n.tabs&&(r.tabs=n.tabs,i=!0),n.borders&&(r.borders=n.borders,i=!0),n.shading&&(r.shading=n.shading,i=!0),n.rightToLeft!==void 0&&(r.bidi=n.rightToLeft,i=!0),n.markRunProps&&(r.markRunProps=n.markRunProps,i=!0),i?r:void 0}function men(e){return s1e(e)}function s1e(e){const t=e.find(n=>n.type.name==="textStyle");if(t)return typeof t.attrs?.rStyle=="string"?t.attrs.rStyle:void 0}function gen(e){return a1e(e)}function a1e(e){const t={};let n=!1;for(const r of e)switch(r.type.name){case"bold":t.bold=!0,n=!0;break;case"italic":t.italic=!0,n=!0;break;case"underline":t.underline=r.attrs&&typeof r.attrs=="object"&&Object.keys(r.attrs).length>0?r.attrs:{style:"single"},n=!0;break;case"strikethrough":t.strikethrough=!0,n=!0;break;case"highlight":{const i=r.attrs?.color;typeof i=="string"&&(t.highlight=i,n=!0);break}case"textStyle":{const i=r.attrs;if(!i)break;i.color&&(t.color=i.color,n=!0),i.fontSize!==void 0&&(t.fontSize=i.fontSize,n=!0),i.fontSizeCs!==void 0&&(t.fontSizeCs=i.fontSizeCs,n=!0),i.fontFamily&&(t.fontFamily=i.fontFamily,n=!0),i.fonts&&(t.fonts=i.fonts,n=!0),i.caps&&(t.caps=!0,n=!0),i.smallCaps&&(t.smallCaps=!0,n=!0),i.vanish&&(t.vanish=!0,n=!0),i.characterSpacing!==void 0&&(t.characterSpacing=i.characterSpacing,n=!0);break}}return n?t:void 0}function yen(e,t){return L$t(e,t.options)}function bD(e){if(typeof e=="number")return e;if(e&&typeof e=="object"&&typeof e.value=="number")return e.value}function ben(e){switch(e){case"start":return"left";case"end":return"right";case"left":case"center":case"right":return e;default:return}}function zj(e){const t=e?.paragraphProperties??void 0,n=t?.indent?{left:t.indent.left,right:t.indent.right,firstLine:t.indent.firstLine,hanging:t.indent.hanging}:void 0,r=t?.spacing?{before:t.spacing.before,after:t.spacing.after,line:t.spacing.line}:void 0,i=t?.justification,o=i==="both"?"justify":i,s=t?.numberingProperties?{numId:pN(t.numberingProperties.numId),level:pN(t.numberingProperties.ilvl)}:void 0;return{styleId:t?.styleId??void 0,alignment:o??void 0,indentation:n,spacing:r,keepWithNext:t?.keepNext??void 0,outlineLevel:t?.outlineLvl??void 0,paragraphNumbering:s}}function ven(e){const t=N1(e?.listRendering);if(!t)return;const n={};return t.markerText&&(n.marker=t.markerText),Array.isArray(t.path)&&(n.path=t.path),n.ordinal=Q8(t.path),Object.keys(n).length?n:void 0}function wen(e){const t=e.node.attrs;return{nodeType:"paragraph",kind:"block",properties:zj(t)}}function Aen(e){const t=e.node.attrs,n=zj(t),r=tA(t?.paragraphProperties?.styleId)??(n.outlineLevel!=null?n.outlineLevel+1:void 0);if(!r||r<1||r>6)throw new De("INVALID_TARGET",`Node "${e.nodeId}" does not have a valid heading level.`);return{nodeType:"heading",kind:"block",properties:{...n,headingLevel:r}}}function xen(e){const t=e.node.attrs;return{nodeType:"listItem",kind:"block",properties:{...zj(t),numbering:ven(t)}}}function Sen(e){const t=e.node.attrs?.tableProperties??void 0;return{nodeType:"table",kind:"block",properties:{layout:t?.tableLayout??void 0,width:bD(t?.tableWidth??null)??void 0,alignment:ben(t?.justification)}}}function Ten(){return{nodeType:"tableRow",kind:"block",properties:{}}}function Ien(e){const t=e.node.attrs,n=t?.tableCellProperties??void 0;return{nodeType:"tableCell",kind:"block",properties:{width:bD(n?.cellWidth??null)??(Array.isArray(t?.colwidth)&&t.colwidth.length>0?t.colwidth[0]:void 0),shading:n?.shading?.fill??t?.background?.color??void 0,vMerge:n?.vMerge==="continue"||n?.vMerge==="restart"||t?.rowspan&&t.rowspan>1?!0:void 0,gridSpan:n?.gridSpan??t?.colspan??void 0,padding:bD(n?.cellMargins?.top??null)??bD(t?.cellMargins?.top??null)}}}function ken(e){const t=e.node,n=t.attrs?.instruction??"",r=db(n),i=t.childCount;return{nodeType:"tableOfContents",kind:"block",properties:{instruction:n,sourceConfig:r.source,displayConfig:r.display,preservedSwitches:r.preserved,entryCount:i}}}function Een(e){if(!e)return null;const t=e.match(/^inset\(\s*([\d.]+)%\s+([\d.]+)%\s+([\d.]+)%\s+([\d.]+)%\s*\)$/);return t?{top:parseFloat(t[1]),right:parseFloat(t[2]),bottom:parseFloat(t[3]),left:parseFloat(t[4])}:null}function Cen(e,t){if(!e)return!1;try{const n=e.resolve(t),r=n.depth-1;if(r<0)return!1;const i=n.before(r+1)+n.node(r+1).nodeSize;if(i>=e.content.size)return!1;const o=e.nodeAt(i);return!o||o.type.name!=="paragraph"?!1:o.attrs?.paragraphProperties?.styleId==="Caption"}catch{return!1}}function _en(e,t,n,r){const i=!!e?.isAnchor,o=e?.wrap,s=e?.transformData,a=s&&(s.rotation||s.verticalFlip||s.horizontalFlip)?{rotation:s.rotation??void 0,verticalFlip:s.verticalFlip??void 0,horizontalFlip:s.horizontalFlip??void 0}:null;return{nodeType:"image",kind:t,properties:{src:e?.src??void 0,alt:e?.alt??void 0,size:e?.size?{width:e.size.width,height:e.size.height,unit:void 0}:void 0,placement:i?"floating":"inline",wrap:{type:o?.type??"Inline",attrs:o?.attrs??void 0},anchorData:e?.anchorData??null,marginOffset:e?.marginOffset??null,relativeHeight:e?.relativeHeight??null,name:e?.alt??void 0,description:e?.title??void 0,transform:a,crop:Een(e?.clipPath),lockAspectRatio:e?.lockAspectRatio??!0,decorative:e?.decorative??!1,hyperlink:e?.hyperlink??null,hasCaption:r!=null?Cen(n,r):!1}}}function Pen(e){const t=e.mark?.attrs??e.attrs??{};return{nodeType:"hyperlink",kind:"inline",properties:{href:typeof t.href=="string"?t.href:void 0,anchor:typeof t.anchor=="string"?t.anchor:typeof t.docLocation=="string"?t.docLocation:void 0,tooltip:typeof t.tooltip=="string"?t.tooltip:void 0}}}function Ren(e){const t=mN(e.mark?.attrs??e.attrs??{});if(!t)throw new De("INVALID_TARGET","Comment node is missing a commentId attribute.");return{nodeType:"comment",kind:"inline",properties:{commentId:t}}}function Len(e){const t=e.attrs??e.node?.attrs??{};return{nodeType:"bookmark",kind:"inline",properties:{name:typeof t.name=="string"?t.name:void 0,bookmarkId:typeof t.id=="string"?t.id:void 0}}}function Nen(e){const t=e.node?.attrs??e.attrs??{};return{nodeType:"footnoteRef",kind:"inline",properties:{noteId:typeof t.id=="string"?t.id:void 0}}}function Men(e){const t=e.trim().toLowerCase();if(t){if(t==="0"||t==="false"||t==="off"||t==="none")return!1;if(t==="1"||t==="true"||t==="on"||t==="single")return!0}}function $A(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="string")return Men(e);if(e&&typeof e=="object"){const t=e,n=$A(t.val??t.value??t.type??t["w:val"]??t["w:value"]);return n??!0}}function Den(e){for(const t of e){if(t==null)continue;if(typeof t=="string"){const r=t.trim().toLowerCase();if(!r)continue;return r!=="none"&&r!=="false"&&r!=="0"}const n=$A(t);if(n!=null)return n}}function Oen(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;if(typeof t.val=="string")return t.val;if(typeof t.value=="string")return t.value;if(typeof t["w:val"]=="string")return t["w:val"]}}function Fen(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e,n=t.val??t.value??t["w:val"];if(typeof n=="string"){const i=n.trim();return i?i.toLowerCase()==="none"?"transparent":i:void 0}const r=t.fill??t["w:fill"];if(typeof r=="string"){const i=r.trim();return!i||i.toLowerCase()==="auto"?void 0:i.startsWith("#")?i:`#${i}`}}}function Ben(e){const t=e.rFonts;if(t&&typeof t=="object"){const r=t,i=r.ascii??r.hAnsi??r.eastAsia??r.cs;if(typeof i=="string")return i}const n=e.fontFamily;if(typeof n=="string")return n;if(n&&typeof n=="object"){const r=n,i=r.ascii??r.hAnsi??r.eastAsia??r.cs;if(typeof i=="string")return i}}function Hen(e){const t=e.sz??e.size??e.fontSize;if(typeof t=="number")return t;if(typeof t=="string"){const n=Number.parseFloat(t);return Number.isFinite(n)?n:void 0}}function zen(e){const t=e.node?.attrs??e.attrs??{},n=t.runProperties&&typeof t.runProperties=="object"?t.runProperties:void 0,r=Den([n?.underline,n?.u]),i=$A(n?.strike)??$A(n?.dstrike)??void 0,o=n?.lang,s=typeof o=="string"?o:o&&typeof o=="object"&&typeof o.val=="string"?o.val:void 0;return{nodeType:"run",kind:"inline",properties:{bold:$A(n?.bold)??void 0,italic:$A(n?.italic)??void 0,underline:r??void 0,strike:i,font:n?Ben(n):void 0,size:n?Hen(n):void 0,color:Oen(n?.color),highlight:Fen(n?.highlight),styleId:typeof n?.rStyle=="string"?n.rStyle:typeof n?.styleId=="string"?n.styleId:void 0,language:s}}}function Uen(){return{nodeType:"tab",kind:"inline",properties:{}}}function Ven(){return{nodeType:"lineBreak",kind:"inline",properties:{}}}function ex(e){return"anchor"in e}function l1e(e,t,n){const r=t??e.nodeType,i=ex(e)?"inline":"block";switch(r){case"paragraph":if(i!=="block")throw new De("INVALID_TARGET","Paragraph nodes can only be resolved as blocks.");return wen(e);case"heading":if(i!=="block")throw new De("INVALID_TARGET","Heading nodes can only be resolved as blocks.");return Aen(e);case"listItem":if(i!=="block")throw new De("INVALID_TARGET","ListItem nodes can only be resolved as blocks.");return xen(e);case"table":if(i!=="block")throw new De("INVALID_TARGET","Table nodes can only be resolved as blocks.");return Sen(e);case"tableRow":if(i!=="block")throw new De("INVALID_TARGET","TableRow nodes can only be resolved as blocks.");return Ten();case"tableCell":if(i!=="block")throw new De("INVALID_TARGET","TableCell nodes can only be resolved as blocks.");return Ien(e);case"image":{const o=e.node?.attrs;return _en(o,i,n,e.pos)}case"sdt":{const o=e.node?.attrs;return bOt(o,i)}case"tableOfContents":if(i!=="block")throw new De("INVALID_TARGET","TableOfContents nodes can only be resolved as blocks.");return ken(e);case"hyperlink":if(!ex(e))throw new De("INVALID_TARGET","Hyperlink nodes can only be resolved inline.");return Pen(e);case"comment":if(!ex(e))throw new De("INVALID_TARGET","Comment nodes can only be resolved inline.");return Ren(e);case"run":if(!ex(e))throw new De("INVALID_TARGET","Run nodes can only be resolved inline.");return zen(e);case"bookmark":if(!ex(e))throw new De("INVALID_TARGET","Bookmark nodes can only be resolved inline.");return Len(e);case"footnoteRef":if(!ex(e))throw new De("INVALID_TARGET","Footnote references can only be resolved inline.");return Nen(e);case"tab":return Uen();case"lineBreak":return Ven();default:throw new De("INVALID_TARGET",`Node type "${r}" is not implemented yet.`)}}function c1e(e,t,n,r){if(n.kind==="block"){const o=ih(t,n);return o?l1e(o,n.nodeType,e.state.doc):void 0}const i=Ck(r??vg(e),n);if(i)return l1e(i,n.nodeType)}function Wen(e,t,n){const r=[];let i;for(const o of n){if(o.kind==="inline"){i??=vg(e);const a=c1e(e,t,o,i);a&&r.push(a);continue}const s=c1e(e,t,o);s&&r.push(s)}return r}var u1e=30,Gen=new Set(["sdt","image"]),jen=new Set(["paragraph","table","tableRow","tableCell","tableHeader","structuredContentBlock","sdt","image"]),qen=new Set(["text","run","structuredContent","image","tab","lineBreak","hardBreak","hard_break","footnoteReference","bookmarkStart","bookmarkEnd","commentRangeStart","commentRangeEnd"]);function Yen(e){if(e)return To(e.paraId)??To(e.sdBlockId)??To(e.blockId)??To(e.id)??To(e.uuid)}function Ken(e){return!!(e&&Gen.has(e))}function d1e(e,t,n){return n.kind==="block"?ih(t,n)?.pos??Number.MAX_SAFE_INTEGER:Ck(vg(e),n)?.pos??Number.MAX_SAFE_INTEGER}function Xen(e,t,n,r,i){const o=e.state.doc.content.size,s=Math.max(0,n-u1e),a=Math.min(o,r+u1e),l=e.state.doc.textBetween(s,a," ").replace(/ {2,}/g," "),c=e.state.doc.textBetween(s,n," "),u=e.state.doc.textBetween(n,r," "),d=c.replace(/ {2,}/g," "),f=u.replace(/ {2,}/g," ");return{address:t,snippet:l,highlightRange:{start:d.length,end:d.length+f.length},textRanges:i?.length?i:void 0}}function Jen(e,t,n){const r=t.pos+1,i=t.end-1;if(n.from<r||n.to>i)return;const o=e.state.doc.textBetween(r,n.from,`
|
|
392
392
|
`,"").length,s=e.state.doc.textBetween(r,n.to,`
|
|
@@ -419,7 +419,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
419
419
|
`,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}var jvn=Le((()=>{})),qvn=Le((()=>{jvn()})),hDe,Yvn=Le((()=>{hDe={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"}}));function Kvn(e,t){const n=t||{};return IK({file:n.file||void 0,location:!1,schema:n.space==="svg"?n5:t5,verbose:n.verbose||!1},e)}function IK(e,t){let n;switch(t.nodeName){case"#comment":{const r=t;return n={type:"comment",value:r.data},r5(e,r,n),n}case"#document":case"#document-fragment":{const r=t,i="mode"in r?r.mode==="quirks"||r.mode==="limited-quirks":!1;if(n={type:"root",children:pDe(e,t.childNodes),data:{quirksMode:i}},e.file&&e.location){const o=String(e.file),s=Gvn(o),a=s.toPoint(0),l=s.toPoint(o.length);n.position={start:a,end:l}}return n}case"#documentType":{const r=t;return n={type:"doctype"},r5(e,r,n),n}case"#text":{const r=t;return n={type:"text",value:r.value},r5(e,r,n),n}default:return n=Xvn(e,t),n}}function pDe(e,t){let n=-1;const r=[];for(;++n<t.length;){const i=IK(e,t[n]);r.push(i)}return r}function Xvn(e,t){const n=e.schema;e.schema=t.namespaceURI===hDe.svg?n5:t5;let r=-1;const i={};for(;++r<t.attrs.length;){const s=t.attrs[r],a=(s.prefix?s.prefix+":":"")+s.name;kK.call(gDe,a)||(i[a]=s.value)}const o=(e.schema.space==="svg"?dDe:uDe)(t.tagName,i,pDe(e,t.childNodes));if(r5(e,t,o),o.tagName==="template"){const s=t,a=s.sourceCodeLocation,l=a&&a.startTag&&Ox(a.startTag),c=a&&a.endTag&&Ox(a.endTag),u=IK(e,s.content);l&&c&&e.file&&(u.position={start:l.end,end:c.start}),o.content=u}return e.schema=n,o}function r5(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const r=Jvn(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function Jvn(e,t,n){const r=Ox(n);if(t.type==="element"){const i=t.children[t.children.length-1];if(r&&!n.endTag&&i&&i.position&&i.position.end&&(r.end=Object.assign({},i.position.end)),e.verbose){const o={};let s;if(n.attrs)for(s in n.attrs)kK.call(n.attrs,s)&&(o[nDe(e.schema,s).property]=Ox(n.attrs[s]));n.startTag;const a=Ox(n.startTag),l=n.endTag?Ox(n.endTag):void 0,c={opening:a};l&&(c.closing=l),c.properties=o,t.data={position:c}}}return r}function Ox(e){const t=mDe({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=mDe({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function mDe(e){return e.line&&e.column?e:void 0}var kK,gDe,Zvn=Le((()=>{Vy(),Wvn(),xK(),qvn(),Yvn(),kK={}.hasOwnProperty,gDe=Object.prototype})),Qvn=Le((()=>{Zvn()}));function yDe(e){return e>=55296&&e<=57343}function $vn(e){return e>=56320&&e<=57343}function ewn(e,t){return(e-55296)*1024+9216+t}function bDe(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function vDe(e){return e>=64976&&e<=65007||wDe.has(e)}var wDe,twn,Ne,uc,EK=Le((()=>{wDe=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),twn="�",(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(Ne||(Ne={})),uc={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"}})),wt,i5=Le((()=>{(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(wt||(wt={}))})),ADe,xDe,nwn=Le((()=>{EK(),i5(),ADe=65536,xDe=class{constructor(e){this.handler=e,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=ADe,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(e,t){const{line:n,col:r,offset:i}=this,o=r+t,s=i+t;return{code:e,startLine:n,endLine:n,startCol:o,endCol:o,startOffset:s,endOffset:s}}_err(e){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(e,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(e){if(this.pos!==this.html.length-1){const t=this.html.charCodeAt(this.pos+1);if($vn(t))return this.pos++,this._addGap(),ewn(e,t)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,Ne.EOF;return this._err(wt.surrogateInInputStream),e}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(e,t){this.html.length>0?this.html+=e:this.html=e,this.endOfChunkHit=!1,this.lastChunkWritten=t}insertHtmlAtCurrentPos(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(e,t){if(this.pos+e.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(t)return this.html.startsWith(e,this.pos);for(let n=0;n<e.length;n++)if((this.html.charCodeAt(this.pos+n)|32)!==e.charCodeAt(n))return!1;return!0}peek(e){const t=this.pos+e;if(t>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Ne.EOF;const n=this.html.charCodeAt(t);return n===Ne.CARRIAGE_RETURN?Ne.LINE_FEED:n}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Ne.EOF;let e=this.html.charCodeAt(this.pos);return e===Ne.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,Ne.LINE_FEED):e===Ne.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,yDe(e)&&(e=this._processSurrogate(e)),this.handler.onParseError===null||e>31&&e<127||e===Ne.LINE_FEED||e===Ne.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e)}_checkForProblematicCharacters(e){bDe(e)?this._err(wt.controlCharacterInInputStream):vDe(e)&&this._err(wt.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}}));function SDe(e,t){for(let n=e.attrs.length-1;n>=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}var Mi,CK=Le((()=>{(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})(Mi||(Mi={}))})),TDe,rwn=Le((()=>{TDe=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏઑඡ༉༦ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲϏϢϸontourIntegraìȹoɴ\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲy;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱còJTabcdfgorstרׯؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ߂ߐĀiyޱrc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣসে্ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४ĀnrࢃgleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpwਖਛgȀLRlr৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼અઋp;椅y;䐜Ādl੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑඞcy;䐊cute;䅃ƀaeyહાron;䅇dil;䅅;䐝ƀgswે૰ativeƀMTV૨ediumSpace;怋hiĀcn૦ëeryThiîtedĀGLଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷreak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪௫ఄ಄ದൡඅ櫬Āoungruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater;EFGLSTஶஷ扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨setĀ;Eೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂෛ෧ขภยา฿ไlig;䅒cute耻Ó䃓Āiyීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲcr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬืde耻Õ䃕es;樷ml耻Ö䃖erĀBP๋Āar๐๓r;怾acĀek๚;揞et;掴arenthesis;揜ҀacfhilorsງຊຏຒດຝະrtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ檻cedesȀ;EST່້扺qual;檯lantEqual;扼ilde;找me;怳Ādpuct;戏ortionĀ;aȥl;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL憒ar;懥eftArrow;懄eiling;按oǵ\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄቕቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHcቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗ĀeiቻDzኀ\0ኇefore;戴a;䎘ĀcnኘkSpace;쀀 Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtèa;䎖r;愨pf;愤cr;쀀𝒵ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒;Eaeiopᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;eᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;eᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰᝃᝈ០៦ᠹᡐᜍ᥈ᥰot;櫭ĀcrᛶkȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;tbrk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯᝳ;䎲;愶een;扬r;쀀𝔟gcostuvwឍឝឳេ៕៛ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀakoᠦᠵĀcn៲ᠣkƀlst֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ;敛;敘;攘;攔;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģbar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;elƀ;bhᥨᥩᥫ䁜;槅sub;柈ŬᥴlĀ;e怢t»pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭒\0᯽\0ᰌƀcprᦲute;䄇̀;abcdsᦿᧀᧄ᧕᧙戩nd;橄rcup;橉Āau᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r;Ecefms᩠ᩢᩫ᪤᪪旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ\0\0aĀ;t䀬;䁀ƀ;fl戁îᅠeĀmxent»eóɍǧ\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯delprvw᭠᭬᭷ᮂᮬᯔarrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;pᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰻᰿ᱝᱩᱵᲞᲬᲷᴍᵻᶑᶫᶻ᷆᷍ròar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂᳖᳜᳠mƀ;oș᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄĀDoḆᴴoôĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»ṺƀaeiἒἚls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧\0耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₥₰₴⃰℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽ƀ;qsؾٌlanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqrⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0proør;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼ròòΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonóquigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roøurĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨íistĀ;sடr;쀀𝔫ȀEest⩦⩹⩼ƀ;qs⩭ƀ;qs⩴lanôií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast⭕⭚⭟lleìl;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖchimpqu⮽⯍⯙⬄⯤⯯Ȁ;cerല⯆ഷ⯉uå;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭ååഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñĀ;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;cⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācrir;榿;쀀𝔬ͯ\0\0\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕⶥⶨrò᪀Āirⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔǒr;榷rp;榹;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ\0\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ脀¶;l䂶leìЃɩ\0\0m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳ᤈ⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t⾴ïrel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⋢⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔ABHabcdefhilmnoprstuxけさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstwガクシスゼゾダッデナp;極Ā;fゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ìâヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘rrowĀ;tㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowóarpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓ròaòՑ;怏oustĀ;a㈞掱che»mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì耻䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;qኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫwar;椪lig耻ß䃟㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rëƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproøim»ኬsðኞĀas㚺㚮ðrn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈadempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xôheadĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roðtré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜtré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0)))}));function iwn(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=IDe.get(e))!==null&&t!==void 0?t:e}var _K,IDe,own,swn=Le((()=>{IDe=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),own=(_K=String.fromCodePoint)!==null&&_K!==void 0?_K:function(e){let t="";return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t}}));function PK(e){return e>=Fa.ZERO&&e<=Fa.NINE}function awn(e){return e>=Fa.UPPER_A&&e<=Fa.UPPER_F||e>=Fa.LOWER_A&&e<=Fa.LOWER_F}function lwn(e){return e>=Fa.UPPER_A&&e<=Fa.UPPER_Z||e>=Fa.LOWER_A&&e<=Fa.LOWER_Z||PK(e)}function cwn(e){return e===Fa.EQUALS||lwn(e)}function uwn(e,t,n,r){const i=(t&Qg.BRANCH_LENGTH)>>7,o=t&Qg.JUMP_TABLE;if(i===0)return o!==0&&r===o?n:-1;if(o){const l=r-o;return l<0||l>=i?-1:e[n+l]-1}let s=n,a=s+i-1;for(;s<=a;){const l=s+a>>>1,c=e[l];if(c<r)s=l+1;else if(c>r)a=l-1;else return e[l+i]}return-1}var Fa,kDe,Qg,Ba,Gp,EDe,dwn=Le((()=>{swn(),rwn(),(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(Fa||(Fa={})),kDe=32,(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Qg||(Qg={})),(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(Ba||(Ba={})),(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Gp||(Gp={})),EDe=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=Ba.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Gp.Strict}startEntity(e){this.decodeMode=e,this.state=Ba.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case Ba.EntityStart:return e.charCodeAt(t)===Fa.NUM?(this.state=Ba.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=Ba.NamedEntity,this.stateNamedEntity(e,t));case Ba.NumericStart:return this.stateNumericStart(e,t);case Ba.NumericDecimal:return this.stateNumericDecimal(e,t);case Ba.NumericHex:return this.stateNumericHex(e,t);case Ba.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|kDe)===Fa.LOWER_X?(this.state=Ba.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=Ba.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,n,r){if(t!==n){const i=n-t;this.result=this.result*Math.pow(r,i)+Number.parseInt(e.substr(t,i),r),this.consumed+=i}}stateNumericHex(e,t){const n=t;for(;t<e.length;){const r=e.charCodeAt(t);if(PK(r)||awn(r))t+=1;else return this.addToNumericResult(e,n,t,16),this.emitNumericEntity(r,3)}return this.addToNumericResult(e,n,t,16),-1}stateNumericDecimal(e,t){const n=t;for(;t<e.length;){const r=e.charCodeAt(t);if(PK(r))t+=1;else return this.addToNumericResult(e,n,t,10),this.emitNumericEntity(r,2)}return this.addToNumericResult(e,n,t,10),-1}emitNumericEntity(e,t){var n;if(this.consumed<=t)return(n=this.errors)===null||n===void 0||n.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===Fa.SEMI)this.consumed+=1;else if(this.decodeMode===Gp.Strict)return 0;return this.emitCodePoint(iwn(this.result),this.consumed),this.errors&&(e!==Fa.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){const{decodeTree:n}=this;let r=n[this.treeIndex],i=(r&Qg.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){const o=e.charCodeAt(t);if(this.treeIndex=uwn(n,r,this.treeIndex+Math.max(1,i),o),this.treeIndex<0)return this.result===0||this.decodeMode===Gp.Attribute&&(i===0||cwn(o))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],i=(r&Qg.VALUE_LENGTH)>>14,i!==0){if(o===Fa.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==Gp.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;const{result:t,decodeTree:n}=this,r=(n[t]&Qg.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,r,this.consumed),(e=this.errors)===null||e===void 0||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){const{decodeTree:r}=this;return this.emitCodePoint(t===1?r[e]&~Qg.VALUE_LENGTH:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case Ba.NamedEntity:return this.result!==0&&(this.decodeMode!==Gp.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Ba.NumericDecimal:return this.emitNumericEntity(0,2);case Ba.NumericHex:return this.emitNumericEntity(0,3);case Ba.NumericStart:return(e=this.errors)===null||e===void 0||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Ba.EntityStart:return 0}}}}));function o5(e){var t;return(t=CDe.get(e))!==null&&t!==void 0?t:j.UNKNOWN}var Bt,Lb,cd,pt,j,CDe,Vt,_De,s5,fwn,$g=Le((()=>{(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(Bt||(Bt={})),(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(Lb||(Lb={})),(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(cd||(cd={})),(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(pt||(pt={})),(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(j||(j={})),CDe=new Map([[pt.A,j.A],[pt.ADDRESS,j.ADDRESS],[pt.ANNOTATION_XML,j.ANNOTATION_XML],[pt.APPLET,j.APPLET],[pt.AREA,j.AREA],[pt.ARTICLE,j.ARTICLE],[pt.ASIDE,j.ASIDE],[pt.B,j.B],[pt.BASE,j.BASE],[pt.BASEFONT,j.BASEFONT],[pt.BGSOUND,j.BGSOUND],[pt.BIG,j.BIG],[pt.BLOCKQUOTE,j.BLOCKQUOTE],[pt.BODY,j.BODY],[pt.BR,j.BR],[pt.BUTTON,j.BUTTON],[pt.CAPTION,j.CAPTION],[pt.CENTER,j.CENTER],[pt.CODE,j.CODE],[pt.COL,j.COL],[pt.COLGROUP,j.COLGROUP],[pt.DD,j.DD],[pt.DESC,j.DESC],[pt.DETAILS,j.DETAILS],[pt.DIALOG,j.DIALOG],[pt.DIR,j.DIR],[pt.DIV,j.DIV],[pt.DL,j.DL],[pt.DT,j.DT],[pt.EM,j.EM],[pt.EMBED,j.EMBED],[pt.FIELDSET,j.FIELDSET],[pt.FIGCAPTION,j.FIGCAPTION],[pt.FIGURE,j.FIGURE],[pt.FONT,j.FONT],[pt.FOOTER,j.FOOTER],[pt.FOREIGN_OBJECT,j.FOREIGN_OBJECT],[pt.FORM,j.FORM],[pt.FRAME,j.FRAME],[pt.FRAMESET,j.FRAMESET],[pt.H1,j.H1],[pt.H2,j.H2],[pt.H3,j.H3],[pt.H4,j.H4],[pt.H5,j.H5],[pt.H6,j.H6],[pt.HEAD,j.HEAD],[pt.HEADER,j.HEADER],[pt.HGROUP,j.HGROUP],[pt.HR,j.HR],[pt.HTML,j.HTML],[pt.I,j.I],[pt.IMG,j.IMG],[pt.IMAGE,j.IMAGE],[pt.INPUT,j.INPUT],[pt.IFRAME,j.IFRAME],[pt.KEYGEN,j.KEYGEN],[pt.LABEL,j.LABEL],[pt.LI,j.LI],[pt.LINK,j.LINK],[pt.LISTING,j.LISTING],[pt.MAIN,j.MAIN],[pt.MALIGNMARK,j.MALIGNMARK],[pt.MARQUEE,j.MARQUEE],[pt.MATH,j.MATH],[pt.MENU,j.MENU],[pt.META,j.META],[pt.MGLYPH,j.MGLYPH],[pt.MI,j.MI],[pt.MO,j.MO],[pt.MN,j.MN],[pt.MS,j.MS],[pt.MTEXT,j.MTEXT],[pt.NAV,j.NAV],[pt.NOBR,j.NOBR],[pt.NOFRAMES,j.NOFRAMES],[pt.NOEMBED,j.NOEMBED],[pt.NOSCRIPT,j.NOSCRIPT],[pt.OBJECT,j.OBJECT],[pt.OL,j.OL],[pt.OPTGROUP,j.OPTGROUP],[pt.OPTION,j.OPTION],[pt.P,j.P],[pt.PARAM,j.PARAM],[pt.PLAINTEXT,j.PLAINTEXT],[pt.PRE,j.PRE],[pt.RB,j.RB],[pt.RP,j.RP],[pt.RT,j.RT],[pt.RTC,j.RTC],[pt.RUBY,j.RUBY],[pt.S,j.S],[pt.SCRIPT,j.SCRIPT],[pt.SEARCH,j.SEARCH],[pt.SECTION,j.SECTION],[pt.SELECT,j.SELECT],[pt.SOURCE,j.SOURCE],[pt.SMALL,j.SMALL],[pt.SPAN,j.SPAN],[pt.STRIKE,j.STRIKE],[pt.STRONG,j.STRONG],[pt.STYLE,j.STYLE],[pt.SUB,j.SUB],[pt.SUMMARY,j.SUMMARY],[pt.SUP,j.SUP],[pt.TABLE,j.TABLE],[pt.TBODY,j.TBODY],[pt.TEMPLATE,j.TEMPLATE],[pt.TEXTAREA,j.TEXTAREA],[pt.TFOOT,j.TFOOT],[pt.TD,j.TD],[pt.TH,j.TH],[pt.THEAD,j.THEAD],[pt.TITLE,j.TITLE],[pt.TR,j.TR],[pt.TRACK,j.TRACK],[pt.TT,j.TT],[pt.U,j.U],[pt.UL,j.UL],[pt.SVG,j.SVG],[pt.VAR,j.VAR],[pt.WBR,j.WBR],[pt.XMP,j.XMP]]),Vt=j,_De={[Bt.HTML]:new Set([Vt.ADDRESS,Vt.APPLET,Vt.AREA,Vt.ARTICLE,Vt.ASIDE,Vt.BASE,Vt.BASEFONT,Vt.BGSOUND,Vt.BLOCKQUOTE,Vt.BODY,Vt.BR,Vt.BUTTON,Vt.CAPTION,Vt.CENTER,Vt.COL,Vt.COLGROUP,Vt.DD,Vt.DETAILS,Vt.DIR,Vt.DIV,Vt.DL,Vt.DT,Vt.EMBED,Vt.FIELDSET,Vt.FIGCAPTION,Vt.FIGURE,Vt.FOOTER,Vt.FORM,Vt.FRAME,Vt.FRAMESET,Vt.H1,Vt.H2,Vt.H3,Vt.H4,Vt.H5,Vt.H6,Vt.HEAD,Vt.HEADER,Vt.HGROUP,Vt.HR,Vt.HTML,Vt.IFRAME,Vt.IMG,Vt.INPUT,Vt.LI,Vt.LINK,Vt.LISTING,Vt.MAIN,Vt.MARQUEE,Vt.MENU,Vt.META,Vt.NAV,Vt.NOEMBED,Vt.NOFRAMES,Vt.NOSCRIPT,Vt.OBJECT,Vt.OL,Vt.P,Vt.PARAM,Vt.PLAINTEXT,Vt.PRE,Vt.SCRIPT,Vt.SECTION,Vt.SELECT,Vt.SOURCE,Vt.STYLE,Vt.SUMMARY,Vt.TABLE,Vt.TBODY,Vt.TD,Vt.TEMPLATE,Vt.TEXTAREA,Vt.TFOOT,Vt.TH,Vt.THEAD,Vt.TITLE,Vt.TR,Vt.TRACK,Vt.UL,Vt.WBR,Vt.XMP]),[Bt.MATHML]:new Set([Vt.MI,Vt.MO,Vt.MN,Vt.MS,Vt.MTEXT,Vt.ANNOTATION_XML]),[Bt.SVG]:new Set([Vt.TITLE,Vt.FOREIGN_OBJECT,Vt.DESC]),[Bt.XLINK]:new Set,[Bt.XML]:new Set,[Bt.XMLNS]:new Set},s5=new Set([Vt.H1,Vt.H2,Vt.H3,Vt.H4,Vt.H5,Vt.H6]),fwn=new Set([pt.STYLE,pt.SCRIPT,pt.XMP,pt.IFRAME,pt.NOEMBED,pt.NOFRAMES,pt.PLAINTEXT])}));function hwn(e){return e>=Ne.DIGIT_0&&e<=Ne.DIGIT_9}function oC(e){return e>=Ne.LATIN_CAPITAL_A&&e<=Ne.LATIN_CAPITAL_Z}function pwn(e){return e>=Ne.LATIN_SMALL_A&&e<=Ne.LATIN_SMALL_Z}function e0(e){return pwn(e)||oC(e)}function PDe(e){return e0(e)||hwn(e)}function a5(e){return e+32}function RDe(e){return e===Ne.SPACE||e===Ne.LINE_FEED||e===Ne.TABULATION||e===Ne.FORM_FEED}function LDe(e){return RDe(e)||e===Ne.SOLIDUS||e===Ne.GREATER_THAN_SIGN}function mwn(e){return e===Ne.NULL?wt.nullCharacterReference:e>1114111?wt.characterReferenceOutsideUnicodeRange:yDe(e)?wt.surrogateCharacterReference:vDe(e)?wt.noncharacterCharacterReference:bDe(e)||e===Ne.CARRIAGE_RETURN?wt.controlCharacterReference:null}var ze,dc,NDe,MDe=Le((()=>{nwn(),EK(),CK(),dwn(),i5(),$g(),(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(ze||(ze={})),dc={DATA:ze.DATA,RCDATA:ze.RCDATA,RAWTEXT:ze.RAWTEXT,SCRIPT_DATA:ze.SCRIPT_DATA,PLAINTEXT:ze.PLAINTEXT,CDATA_SECTION:ze.CDATA_SECTION},NDe=class{constructor(e,t){this.options=e,this.handler=t,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=ze.DATA,this.returnState=ze.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new xDe(t),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new EDe(TDe,(n,r)=>{this.preprocessor.pos=this.entityStartPos+r-1,this._flushCodePointConsumedAsCharacterReference(n)},t.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(wt.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:n=>{this._err(wt.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+n)},validateNumericCharacterReference:n=>{const r=mwn(n);r&&this._err(r,1)}}:void 0)}_err(e,t=0){var n,r;(r=(n=this.handler).onParseError)===null||r===void 0||r.call(n,this.preprocessor.getError(e,t))}getCurrentLocation(e){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-e,startOffset:this.preprocessor.offset-e,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const e=this._consume();this._ensureHibernation()||this._callState(e)}this.inLoop=!1}}pause(){this.paused=!0}resume(e){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||e?.())}write(e,t,n){this.active=!0,this.preprocessor.write(e,t),this._runParsingLoop(),this.paused||n?.()}insertHtmlAtCurrentPos(e){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(e),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(e){this.consumedAfterSnapshot+=e;for(let t=0;t<e;t++)this.preprocessor.advance()}_consumeSequenceIfMatch(e,t){return this.preprocessor.startsWith(e,t)?(this._advanceBy(e.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:Mi.START_TAG,tagName:"",tagID:j.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:Mi.END_TAG,tagName:"",tagID:j.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(e){this.currentToken={type:Mi.COMMENT,data:"",location:this.getCurrentLocation(e)}}_createDoctypeToken(e){this.currentToken={type:Mi.DOCTYPE,name:e,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(e,t){this.currentCharacterToken={type:e,chars:t,location:this.currentLocation}}_createAttr(e){this.currentAttr={name:e,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var e,t;const n=this.currentToken;if(SDe(n,this.currentAttr.name)===null){if(n.attrs.push(this.currentAttr),n.location&&this.currentLocation){const r=(e=(t=n.location).attrs)!==null&&e!==void 0?e:t.attrs=Object.create(null);r[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(wt.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(e){this._emitCurrentCharacterToken(e.location),this.currentToken=null,e.location&&(e.location.endLine=this.preprocessor.line,e.location.endCol=this.preprocessor.col+1,e.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const e=this.currentToken;this.prepareToken(e),e.tagID=o5(e.tagName),e.type===Mi.START_TAG?(this.lastStartTagName=e.tagName,this.handler.onStartTag(e)):(e.attrs.length>0&&this._err(wt.endTagWithAttributes),e.selfClosing&&this._err(wt.endTagWithTrailingSolidus),this.handler.onEndTag(e)),this.preprocessor.dropParsedChunk()}emitCurrentComment(e){this.prepareToken(e),this.handler.onComment(e),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(e){this.prepareToken(e),this.handler.onDoctype(e),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(e){if(this.currentCharacterToken){switch(e&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=e.startLine,this.currentCharacterToken.location.endCol=e.startCol,this.currentCharacterToken.location.endOffset=e.startOffset),this.currentCharacterToken.type){case Mi.CHARACTER:this.handler.onCharacter(this.currentCharacterToken);break;case Mi.NULL_CHARACTER:this.handler.onNullCharacter(this.currentCharacterToken);break;case Mi.WHITESPACE_CHARACTER:this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}this.currentCharacterToken=null}}_emitEOFToken(){const e=this.getCurrentLocation(0);e&&(e.endLine=e.startLine,e.endCol=e.startCol,e.endOffset=e.startOffset),this._emitCurrentCharacterToken(e),this.handler.onEof({type:Mi.EOF,location:e}),this.active=!1}_appendCharToCurrentCharacterToken(e,t){if(this.currentCharacterToken)if(this.currentCharacterToken.type===e){this.currentCharacterToken.chars+=t;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(e,t)}_emitCodePoint(e){const t=RDe(e)?Mi.WHITESPACE_CHARACTER:e===Ne.NULL?Mi.NULL_CHARACTER:Mi.CHARACTER;this._appendCharToCurrentCharacterToken(t,String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(Mi.CHARACTER,e)}_startCharacterReference(){this.returnState=this.state,this.state=ze.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Gp.Attribute:Gp.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===ze.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===ze.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===ze.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case ze.DATA:this._stateData(e);break;case ze.RCDATA:this._stateRcdata(e);break;case ze.RAWTEXT:this._stateRawtext(e);break;case ze.SCRIPT_DATA:this._stateScriptData(e);break;case ze.PLAINTEXT:this._statePlaintext(e);break;case ze.TAG_OPEN:this._stateTagOpen(e);break;case ze.END_TAG_OPEN:this._stateEndTagOpen(e);break;case ze.TAG_NAME:this._stateTagName(e);break;case ze.RCDATA_LESS_THAN_SIGN:this._stateRcdataLessThanSign(e);break;case ze.RCDATA_END_TAG_OPEN:this._stateRcdataEndTagOpen(e);break;case ze.RCDATA_END_TAG_NAME:this._stateRcdataEndTagName(e);break;case ze.RAWTEXT_LESS_THAN_SIGN:this._stateRawtextLessThanSign(e);break;case ze.RAWTEXT_END_TAG_OPEN:this._stateRawtextEndTagOpen(e);break;case ze.RAWTEXT_END_TAG_NAME:this._stateRawtextEndTagName(e);break;case ze.SCRIPT_DATA_LESS_THAN_SIGN:this._stateScriptDataLessThanSign(e);break;case ze.SCRIPT_DATA_END_TAG_OPEN:this._stateScriptDataEndTagOpen(e);break;case ze.SCRIPT_DATA_END_TAG_NAME:this._stateScriptDataEndTagName(e);break;case ze.SCRIPT_DATA_ESCAPE_START:this._stateScriptDataEscapeStart(e);break;case ze.SCRIPT_DATA_ESCAPE_START_DASH:this._stateScriptDataEscapeStartDash(e);break;case ze.SCRIPT_DATA_ESCAPED:this._stateScriptDataEscaped(e);break;case ze.SCRIPT_DATA_ESCAPED_DASH:this._stateScriptDataEscapedDash(e);break;case ze.SCRIPT_DATA_ESCAPED_DASH_DASH:this._stateScriptDataEscapedDashDash(e);break;case ze.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataEscapedLessThanSign(e);break;case ze.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:this._stateScriptDataEscapedEndTagOpen(e);break;case ze.SCRIPT_DATA_ESCAPED_END_TAG_NAME:this._stateScriptDataEscapedEndTagName(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPE_START:this._stateScriptDataDoubleEscapeStart(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPED:this._stateScriptDataDoubleEscaped(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:this._stateScriptDataDoubleEscapedDash(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:this._stateScriptDataDoubleEscapedDashDash(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataDoubleEscapedLessThanSign(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPE_END:this._stateScriptDataDoubleEscapeEnd(e);break;case ze.BEFORE_ATTRIBUTE_NAME:this._stateBeforeAttributeName(e);break;case ze.ATTRIBUTE_NAME:this._stateAttributeName(e);break;case ze.AFTER_ATTRIBUTE_NAME:this._stateAfterAttributeName(e);break;case ze.BEFORE_ATTRIBUTE_VALUE:this._stateBeforeAttributeValue(e);break;case ze.ATTRIBUTE_VALUE_DOUBLE_QUOTED:this._stateAttributeValueDoubleQuoted(e);break;case ze.ATTRIBUTE_VALUE_SINGLE_QUOTED:this._stateAttributeValueSingleQuoted(e);break;case ze.ATTRIBUTE_VALUE_UNQUOTED:this._stateAttributeValueUnquoted(e);break;case ze.AFTER_ATTRIBUTE_VALUE_QUOTED:this._stateAfterAttributeValueQuoted(e);break;case ze.SELF_CLOSING_START_TAG:this._stateSelfClosingStartTag(e);break;case ze.BOGUS_COMMENT:this._stateBogusComment(e);break;case ze.MARKUP_DECLARATION_OPEN:this._stateMarkupDeclarationOpen(e);break;case ze.COMMENT_START:this._stateCommentStart(e);break;case ze.COMMENT_START_DASH:this._stateCommentStartDash(e);break;case ze.COMMENT:this._stateComment(e);break;case ze.COMMENT_LESS_THAN_SIGN:this._stateCommentLessThanSign(e);break;case ze.COMMENT_LESS_THAN_SIGN_BANG:this._stateCommentLessThanSignBang(e);break;case ze.COMMENT_LESS_THAN_SIGN_BANG_DASH:this._stateCommentLessThanSignBangDash(e);break;case ze.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:this._stateCommentLessThanSignBangDashDash(e);break;case ze.COMMENT_END_DASH:this._stateCommentEndDash(e);break;case ze.COMMENT_END:this._stateCommentEnd(e);break;case ze.COMMENT_END_BANG:this._stateCommentEndBang(e);break;case ze.DOCTYPE:this._stateDoctype(e);break;case ze.BEFORE_DOCTYPE_NAME:this._stateBeforeDoctypeName(e);break;case ze.DOCTYPE_NAME:this._stateDoctypeName(e);break;case ze.AFTER_DOCTYPE_NAME:this._stateAfterDoctypeName(e);break;case ze.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._stateAfterDoctypePublicKeyword(e);break;case ze.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:this._stateBeforeDoctypePublicIdentifier(e);break;case ze.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypePublicIdentifierDoubleQuoted(e);break;case ze.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypePublicIdentifierSingleQuoted(e);break;case ze.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:this._stateAfterDoctypePublicIdentifier(e);break;case ze.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break;case ze.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._stateAfterDoctypeSystemKeyword(e);break;case ze.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:this._stateBeforeDoctypeSystemIdentifier(e);break;case ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypeSystemIdentifierDoubleQuoted(e);break;case ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypeSystemIdentifierSingleQuoted(e);break;case ze.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:this._stateAfterDoctypeSystemIdentifier(e);break;case ze.BOGUS_DOCTYPE:this._stateBogusDoctype(e);break;case ze.CDATA_SECTION:this._stateCdataSection(e);break;case ze.CDATA_SECTION_BRACKET:this._stateCdataSectionBracket(e);break;case ze.CDATA_SECTION_END:this._stateCdataSectionEnd(e);break;case ze.CHARACTER_REFERENCE:this._stateCharacterReference();break;case ze.AMBIGUOUS_AMPERSAND:this._stateAmbiguousAmpersand(e);break;default:throw new Error("Unknown state")}}_stateData(e){switch(e){case Ne.LESS_THAN_SIGN:this.state=ze.TAG_OPEN;break;case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this._emitCodePoint(e);break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.LESS_THAN_SIGN:this.state=ze.RCDATA_LESS_THAN_SIGN;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case Ne.LESS_THAN_SIGN:this.state=ze.RAWTEXT_LESS_THAN_SIGN;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case Ne.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_LESS_THAN_SIGN;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case Ne.NULL:this._err(wt.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateTagOpen(e){if(e0(e))this._createStartTagToken(),this.state=ze.TAG_NAME,this._stateTagName(e);else switch(e){case Ne.EXCLAMATION_MARK:this.state=ze.MARKUP_DECLARATION_OPEN;break;case Ne.SOLIDUS:this.state=ze.END_TAG_OPEN;break;case Ne.QUESTION_MARK:this._err(wt.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=ze.BOGUS_COMMENT,this._stateBogusComment(e);break;case Ne.EOF:this._err(wt.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break;default:this._err(wt.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=ze.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(e0(e))this._createEndTagToken(),this.state=ze.TAG_NAME,this._stateTagName(e);else switch(e){case Ne.GREATER_THAN_SIGN:this._err(wt.missingEndTagName),this.state=ze.DATA;break;case Ne.EOF:this._err(wt.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break;default:this._err(wt.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=ze.BOGUS_COMMENT,this._stateBogusComment(e)}}_stateTagName(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=ze.BEFORE_ATTRIBUTE_NAME;break;case Ne.SOLIDUS:this.state=ze.SELF_CLOSING_START_TAG;break;case Ne.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentTagToken();break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),t.tagName+="�";break;case Ne.EOF:this._err(wt.eofInTag),this._emitEOFToken();break;default:t.tagName+=String.fromCodePoint(oC(e)?a5(e):e)}}_stateRcdataLessThanSign(e){e===Ne.SOLIDUS?this.state=ze.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=ze.RCDATA,this._stateRcdata(e))}_stateRcdataEndTagOpen(e){e0(e)?(this.state=ze.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(e)):(this._emitChars("</"),this.state=ze.RCDATA,this._stateRcdata(e))}handleSpecialEndTag(e){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const t=this.currentToken;switch(t.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=ze.BEFORE_ATTRIBUTE_NAME,!1;case Ne.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=ze.SELF_CLOSING_START_TAG,!1;case Ne.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=ze.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ze.RCDATA,this._stateRcdata(e))}_stateRawtextLessThanSign(e){e===Ne.SOLIDUS?this.state=ze.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=ze.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagOpen(e){e0(e)?(this.state=ze.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(e)):(this._emitChars("</"),this.state=ze.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ze.RAWTEXT,this._stateRawtext(e))}_stateScriptDataLessThanSign(e){switch(e){case Ne.SOLIDUS:this.state=ze.SCRIPT_DATA_END_TAG_OPEN;break;case Ne.EXCLAMATION_MARK:this.state=ze.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break;default:this._emitChars("<"),this.state=ze.SCRIPT_DATA,this._stateScriptData(e)}}_stateScriptDataEndTagOpen(e){e0(e)?(this.state=ze.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(e)):(this._emitChars("</"),this.state=ze.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ze.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStart(e){e===Ne.HYPHEN_MINUS?(this.state=ze.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=ze.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStartDash(e){e===Ne.HYPHEN_MINUS?(this.state=ze.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=ze.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscaped(e){switch(e){case Ne.HYPHEN_MINUS:this.state=ze.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._err(wt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataEscapedDash(e){switch(e){case Ne.HYPHEN_MINUS:this.state=ze.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this.state=ze.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case Ne.EOF:this._err(wt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ze.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedDashDash(e){switch(e){case Ne.HYPHEN_MINUS:this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case Ne.GREATER_THAN_SIGN:this.state=ze.SCRIPT_DATA,this._emitChars(">");break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this.state=ze.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case Ne.EOF:this._err(wt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ze.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===Ne.SOLIDUS?this.state=ze.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:e0(e)?(this._emitChars("<"),this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars("<"),this.state=ze.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){e0(e)?(this.state=ze.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars("</"),this.state=ze.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ze.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscapeStart(e){if(this.preprocessor.startsWith(uc.SCRIPT,!1)&&LDe(this.preprocessor.peek(uc.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<uc.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=ze.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscaped(e){switch(e){case Ne.HYPHEN_MINUS:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._err(wt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDash(e){switch(e){case Ne.HYPHEN_MINUS:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case Ne.EOF:this._err(wt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDashDash(e){switch(e){case Ne.HYPHEN_MINUS:this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case Ne.GREATER_THAN_SIGN:this.state=ze.SCRIPT_DATA,this._emitChars(">");break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case Ne.EOF:this._err(wt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===Ne.SOLIDUS?(this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(uc.SCRIPT,!1)&&LDe(this.preprocessor.peek(uc.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<uc.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=ze.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateBeforeAttributeName(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.SOLIDUS:case Ne.GREATER_THAN_SIGN:case Ne.EOF:this.state=ze.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case Ne.EQUALS_SIGN:this._err(wt.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=ze.ATTRIBUTE_NAME;break;default:this._createAttr(""),this.state=ze.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateAttributeName(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:case Ne.SOLIDUS:case Ne.GREATER_THAN_SIGN:case Ne.EOF:this._leaveAttrName(),this.state=ze.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case Ne.EQUALS_SIGN:this._leaveAttrName(),this.state=ze.BEFORE_ATTRIBUTE_VALUE;break;case Ne.QUOTATION_MARK:case Ne.APOSTROPHE:case Ne.LESS_THAN_SIGN:this._err(wt.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(e);break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this.currentAttr.name+="�";break;default:this.currentAttr.name+=String.fromCodePoint(oC(e)?a5(e):e)}}_stateAfterAttributeName(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.SOLIDUS:this.state=ze.SELF_CLOSING_START_TAG;break;case Ne.EQUALS_SIGN:this.state=ze.BEFORE_ATTRIBUTE_VALUE;break;case Ne.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentTagToken();break;case Ne.EOF:this._err(wt.eofInTag),this._emitEOFToken();break;default:this._createAttr(""),this.state=ze.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateBeforeAttributeValue(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.QUOTATION_MARK:this.state=ze.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:this.state=ze.ATTRIBUTE_VALUE_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(wt.missingAttributeValue),this.state=ze.DATA,this.emitCurrentTagToken();break;default:this.state=ze.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(e)}}_stateAttributeValueDoubleQuoted(e){switch(e){case Ne.QUOTATION_MARK:this.state=ze.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this.currentAttr.value+="�";break;case Ne.EOF:this._err(wt.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueSingleQuoted(e){switch(e){case Ne.APOSTROPHE:this.state=ze.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this.currentAttr.value+="�";break;case Ne.EOF:this._err(wt.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueUnquoted(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this._leaveAttrValue(),this.state=ze.BEFORE_ATTRIBUTE_NAME;break;case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=ze.DATA,this.emitCurrentTagToken();break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this.currentAttr.value+="�";break;case Ne.QUOTATION_MARK:case Ne.APOSTROPHE:case Ne.LESS_THAN_SIGN:case Ne.EQUALS_SIGN:case Ne.GRAVE_ACCENT:this._err(wt.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(e);break;case Ne.EOF:this._err(wt.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAfterAttributeValueQuoted(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this._leaveAttrValue(),this.state=ze.BEFORE_ATTRIBUTE_NAME;break;case Ne.SOLIDUS:this._leaveAttrValue(),this.state=ze.SELF_CLOSING_START_TAG;break;case Ne.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=ze.DATA,this.emitCurrentTagToken();break;case Ne.EOF:this._err(wt.eofInTag),this._emitEOFToken();break;default:this._err(wt.missingWhitespaceBetweenAttributes),this.state=ze.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateSelfClosingStartTag(e){switch(e){case Ne.GREATER_THAN_SIGN:{const t=this.currentToken;t.selfClosing=!0,this.state=ze.DATA,this.emitCurrentTagToken();break}case Ne.EOF:this._err(wt.eofInTag),this._emitEOFToken();break;default:this._err(wt.unexpectedSolidusInTag),this.state=ze.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateBogusComment(e){const t=this.currentToken;switch(e){case Ne.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentComment(t);break;case Ne.EOF:this.emitCurrentComment(t),this._emitEOFToken();break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),t.data+="�";break;default:t.data+=String.fromCodePoint(e)}}_stateMarkupDeclarationOpen(e){this._consumeSequenceIfMatch(uc.DASH_DASH,!0)?(this._createCommentToken(uc.DASH_DASH.length+1),this.state=ze.COMMENT_START):this._consumeSequenceIfMatch(uc.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(uc.DOCTYPE.length+1),this.state=ze.DOCTYPE):this._consumeSequenceIfMatch(uc.CDATA_START,!0)?this.inForeignNode?this.state=ze.CDATA_SECTION:(this._err(wt.cdataInHtmlContent),this._createCommentToken(uc.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=ze.BOGUS_COMMENT):this._ensureHibernation()||(this._err(wt.incorrectlyOpenedComment),this._createCommentToken(2),this.state=ze.BOGUS_COMMENT,this._stateBogusComment(e))}_stateCommentStart(e){switch(e){case Ne.HYPHEN_MINUS:this.state=ze.COMMENT_START_DASH;break;case Ne.GREATER_THAN_SIGN:{this._err(wt.abruptClosingOfEmptyComment),this.state=ze.DATA;const t=this.currentToken;this.emitCurrentComment(t);break}default:this.state=ze.COMMENT,this._stateComment(e)}}_stateCommentStartDash(e){const t=this.currentToken;switch(e){case Ne.HYPHEN_MINUS:this.state=ze.COMMENT_END;break;case Ne.GREATER_THAN_SIGN:this._err(wt.abruptClosingOfEmptyComment),this.state=ze.DATA,this.emitCurrentComment(t);break;case Ne.EOF:this._err(wt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=ze.COMMENT,this._stateComment(e)}}_stateComment(e){const t=this.currentToken;switch(e){case Ne.HYPHEN_MINUS:this.state=ze.COMMENT_END_DASH;break;case Ne.LESS_THAN_SIGN:t.data+="<",this.state=ze.COMMENT_LESS_THAN_SIGN;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),t.data+="�";break;case Ne.EOF:this._err(wt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=String.fromCodePoint(e)}}_stateCommentLessThanSign(e){const t=this.currentToken;switch(e){case Ne.EXCLAMATION_MARK:t.data+="!",this.state=ze.COMMENT_LESS_THAN_SIGN_BANG;break;case Ne.LESS_THAN_SIGN:t.data+="<";break;default:this.state=ze.COMMENT,this._stateComment(e)}}_stateCommentLessThanSignBang(e){e===Ne.HYPHEN_MINUS?this.state=ze.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=ze.COMMENT,this._stateComment(e))}_stateCommentLessThanSignBangDash(e){e===Ne.HYPHEN_MINUS?this.state=ze.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=ze.COMMENT_END_DASH,this._stateCommentEndDash(e))}_stateCommentLessThanSignBangDashDash(e){e!==Ne.GREATER_THAN_SIGN&&e!==Ne.EOF&&this._err(wt.nestedComment),this.state=ze.COMMENT_END,this._stateCommentEnd(e)}_stateCommentEndDash(e){const t=this.currentToken;switch(e){case Ne.HYPHEN_MINUS:this.state=ze.COMMENT_END;break;case Ne.EOF:this._err(wt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=ze.COMMENT,this._stateComment(e)}}_stateCommentEnd(e){const t=this.currentToken;switch(e){case Ne.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentComment(t);break;case Ne.EXCLAMATION_MARK:this.state=ze.COMMENT_END_BANG;break;case Ne.HYPHEN_MINUS:t.data+="-";break;case Ne.EOF:this._err(wt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--",this.state=ze.COMMENT,this._stateComment(e)}}_stateCommentEndBang(e){const t=this.currentToken;switch(e){case Ne.HYPHEN_MINUS:t.data+="--!",this.state=ze.COMMENT_END_DASH;break;case Ne.GREATER_THAN_SIGN:this._err(wt.incorrectlyClosedComment),this.state=ze.DATA,this.emitCurrentComment(t);break;case Ne.EOF:this._err(wt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--!",this.state=ze.COMMENT,this._stateComment(e)}}_stateDoctype(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=ze.BEFORE_DOCTYPE_NAME;break;case Ne.GREATER_THAN_SIGN:this.state=ze.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e);break;case Ne.EOF:{this._err(wt.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(wt.missingWhitespaceBeforeDoctypeName),this.state=ze.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e)}}_stateBeforeDoctypeName(e){if(oC(e))this._createDoctypeToken(String.fromCharCode(a5(e))),this.state=ze.DOCTYPE_NAME;else switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),this._createDoctypeToken("�"),this.state=ze.DOCTYPE_NAME;break;case Ne.GREATER_THAN_SIGN:{this._err(wt.missingDoctypeName),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break}case Ne.EOF:{this._err(wt.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(e)),this.state=ze.DOCTYPE_NAME}}_stateDoctypeName(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=ze.AFTER_DOCTYPE_NAME;break;case Ne.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),t.name+="�";break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.name+=String.fromCodePoint(oC(e)?a5(e):e)}}_stateAfterDoctypeName(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._consumeSequenceIfMatch(uc.PUBLIC,!1)?this.state=ze.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(uc.SYSTEM,!1)?this.state=ze.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(wt.invalidCharacterSequenceAfterDoctypeName),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e))}}_stateAfterDoctypePublicKeyword(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=ze.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break;case Ne.QUOTATION_MARK:this._err(wt.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=ze.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:this._err(wt.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=ze.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(wt.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(wt.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.QUOTATION_MARK:t.publicId="",this.state=ze.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:t.publicId="",this.state=ze.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(wt.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(wt.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypePublicIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case Ne.QUOTATION_MARK:this.state=ze.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),t.publicId+="�";break;case Ne.GREATER_THAN_SIGN:this._err(wt.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateDoctypePublicIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case Ne.APOSTROPHE:this.state=ze.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),t.publicId+="�";break;case Ne.GREATER_THAN_SIGN:this._err(wt.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateAfterDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=ze.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break;case Ne.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Ne.QUOTATION_MARK:this._err(wt.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:this._err(wt.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(wt.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBetweenDoctypePublicAndSystemIdentifiers(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Ne.QUOTATION_MARK:t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(wt.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateAfterDoctypeSystemKeyword(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=ze.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break;case Ne.QUOTATION_MARK:this._err(wt.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:this._err(wt.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(wt.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(wt.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.QUOTATION_MARK:t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(wt.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(wt.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypeSystemIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case Ne.QUOTATION_MARK:this.state=ze.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),t.systemId+="�";break;case Ne.GREATER_THAN_SIGN:this._err(wt.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateDoctypeSystemIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case Ne.APOSTROPHE:this.state=ze.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter),t.systemId+="�";break;case Ne.GREATER_THAN_SIGN:this._err(wt.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateAfterDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Ne.EOF:this._err(wt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(wt.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBogusDoctype(e){const t=this.currentToken;switch(e){case Ne.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Ne.NULL:this._err(wt.unexpectedNullCharacter);break;case Ne.EOF:this.emitCurrentDoctype(t),this._emitEOFToken();break;default:}}_stateCdataSection(e){switch(e){case Ne.RIGHT_SQUARE_BRACKET:this.state=ze.CDATA_SECTION_BRACKET;break;case Ne.EOF:this._err(wt.eofInCdata),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateCdataSectionBracket(e){e===Ne.RIGHT_SQUARE_BRACKET?this.state=ze.CDATA_SECTION_END:(this._emitChars("]"),this.state=ze.CDATA_SECTION,this._stateCdataSection(e))}_stateCdataSectionEnd(e){switch(e){case Ne.GREATER_THAN_SIGN:this.state=ze.DATA;break;case Ne.RIGHT_SQUARE_BRACKET:this._emitChars("]");break;default:this._emitChars("]]"),this.state=ze.CDATA_SECTION,this._stateCdataSection(e)}}_stateCharacterReference(){let e=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(e<0)if(this.preprocessor.lastChunkWritten)e=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}e===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(Ne.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&PDe(this.preprocessor.peek(1))?ze.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(e){PDe(e)?this._flushCodePointConsumedAsCharacterReference(e):(e===Ne.SEMICOLON&&this._err(wt.unknownNamedCharacterReference),this.state=this.returnState,this._callState(e))}}})),RK,LK,sC,DDe,ODe,NK,MK,FDe,BDe,HDe,zDe,UDe,gwn=Le((()=>{$g(),RK=new Set([j.DD,j.DT,j.LI,j.OPTGROUP,j.OPTION,j.P,j.RB,j.RP,j.RT,j.RTC]),LK=new Set([...RK,j.CAPTION,j.COLGROUP,j.TBODY,j.TD,j.TFOOT,j.TH,j.THEAD,j.TR]),sC=new Set([j.APPLET,j.CAPTION,j.HTML,j.MARQUEE,j.OBJECT,j.TABLE,j.TD,j.TEMPLATE,j.TH]),DDe=new Set([...sC,j.OL,j.UL]),ODe=new Set([...sC,j.BUTTON]),NK=new Set([j.ANNOTATION_XML,j.MI,j.MN,j.MO,j.MS,j.MTEXT]),MK=new Set([j.DESC,j.FOREIGN_OBJECT,j.TITLE]),FDe=new Set([j.TR,j.TEMPLATE,j.HTML]),BDe=new Set([j.TBODY,j.TFOOT,j.THEAD,j.TEMPLATE,j.HTML]),HDe=new Set([j.TABLE,j.TEMPLATE,j.HTML]),zDe=new Set([j.TD,j.TH]),UDe=class{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(e,t,n){this.treeAdapter=t,this.handler=n,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=j.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===j.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===Bt.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(e,t){this.stackTop++,this.items[this.stackTop]=e,this.current=e,this.tagIDs[this.stackTop]=t,this.currentTagId=t,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(e,t,!0)}pop(){const e=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!0)}replace(e,t){const n=this._indexOf(e);this.items[n]=t,n===this.stackTop&&(this.current=t)}insertAfter(e,t,n){const r=this._indexOf(e)+1;this.items.splice(r,0,t),this.tagIDs.splice(r,0,n),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}popUntilTagNamePopped(e){let t=this.stackTop+1;do t=this.tagIDs.lastIndexOf(e,t-1);while(t>0&&this.treeAdapter.getNamespaceURI(this.items[t])!==Bt.HTML);this.shortenToLength(Math.max(t,0))}shortenToLength(e){for(;this.stackTop>=e;){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,this.stackTop<e)}}popUntilElementPopped(e){const t=this._indexOf(e);this.shortenToLength(Math.max(t,0))}popUntilPopped(e,t){const n=this._indexOfTagNames(e,t);this.shortenToLength(Math.max(n,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(s5,Bt.HTML)}popUntilTableCellPopped(){this.popUntilPopped(zDe,Bt.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(e,t){for(let n=this.stackTop;n>=0;n--)if(e.has(this.tagIDs[n])&&this.treeAdapter.getNamespaceURI(this.items[n])===t)return n;return-1}clearBackTo(e,t){const n=this._indexOfTagNames(e,t);this.shortenToLength(n+1)}clearBackToTableContext(){this.clearBackTo(HDe,Bt.HTML)}clearBackToTableBodyContext(){this.clearBackTo(BDe,Bt.HTML)}clearBackToTableRowContext(){this.clearBackTo(FDe,Bt.HTML)}remove(e){const t=this._indexOf(e);t>=0&&(t===this.stackTop?this.pop():(this.items.splice(t,1),this.tagIDs.splice(t,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===j.BODY?this.items[1]:null}contains(e){return this._indexOf(e)>-1}getCommonAncestor(e){const t=this._indexOf(e)-1;return t>=0?this.items[t]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===j.HTML}hasInDynamicScope(e,t){for(let n=this.stackTop;n>=0;n--){const r=this.tagIDs[n];switch(this.treeAdapter.getNamespaceURI(this.items[n])){case Bt.HTML:if(r===e)return!0;if(t.has(r))return!1;break;case Bt.SVG:if(MK.has(r))return!1;break;case Bt.MATHML:if(NK.has(r))return!1;break}}return!0}hasInScope(e){return this.hasInDynamicScope(e,sC)}hasInListItemScope(e){return this.hasInDynamicScope(e,DDe)}hasInButtonScope(e){return this.hasInDynamicScope(e,ODe)}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){const t=this.tagIDs[e];switch(this.treeAdapter.getNamespaceURI(this.items[e])){case Bt.HTML:if(s5.has(t))return!0;if(sC.has(t))return!1;break;case Bt.SVG:if(MK.has(t))return!1;break;case Bt.MATHML:if(NK.has(t))return!1;break}}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Bt.HTML)switch(this.tagIDs[t]){case e:return!0;case j.TABLE:case j.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--)if(this.treeAdapter.getNamespaceURI(this.items[e])===Bt.HTML)switch(this.tagIDs[e]){case j.TBODY:case j.THEAD:case j.TFOOT:return!0;case j.TABLE:case j.HTML:return!1}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Bt.HTML)switch(this.tagIDs[t]){case e:return!0;case j.OPTION:case j.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&RK.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&LK.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;this.currentTagId!==void 0&&this.currentTagId!==e&&LK.has(this.currentTagId);)this.pop()}}})),l5,Sh,DK,VDe,ywn=Le((()=>{l5=3,(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Sh||(Sh={})),DK={type:Sh.Marker},VDe=class{constructor(e){this.treeAdapter=e,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(e,t){const n=[],r=t.length,i=this.treeAdapter.getTagName(e),o=this.treeAdapter.getNamespaceURI(e);for(let s=0;s<this.entries.length;s++){const a=this.entries[s];if(a.type===Sh.Marker)break;const{element:l}=a;if(this.treeAdapter.getTagName(l)===i&&this.treeAdapter.getNamespaceURI(l)===o){const c=this.treeAdapter.getAttrList(l);c.length===r&&n.push({idx:s,attrs:c})}}return n}_ensureNoahArkCondition(e){if(this.entries.length<l5)return;const t=this.treeAdapter.getAttrList(e),n=this._getNoahArkConditionCandidates(e,t);if(n.length<l5)return;const r=new Map(t.map(o=>[o.name,o.value]));let i=0;for(let o=0;o<n.length;o++){const s=n[o];s.attrs.every(a=>r.get(a.name)===a.value)&&(i+=1,i>=l5&&this.entries.splice(s.idx,1))}}insertMarker(){this.entries.unshift(DK)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:Sh.Element,element:e,token:t})}insertElementAfterBookmark(e,t){const n=this.entries.indexOf(this.bookmark);this.entries.splice(n,0,{type:Sh.Element,element:e,token:t})}removeEntry(e){const t=this.entries.indexOf(e);t!==-1&&this.entries.splice(t,1)}clearToLastMarker(){const e=this.entries.indexOf(DK);e===-1?this.entries.length=0:this.entries.splice(0,e+1)}getElementEntryInScopeWithTagName(e){const t=this.entries.find(n=>n.type===Sh.Marker||this.treeAdapter.getTagName(n.element)===e);return t&&t.type===Sh.Element?t:null}getElementEntry(e){return this.entries.find(t=>t.type===Sh.Element&&t.element===e)}}})),jp,OK=Le((()=>{$g(),jp={createDocument(){return{nodeName:"#document",mode:cd.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const r=e.childNodes.indexOf(n);e.childNodes.splice(r,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,r){const i=e.childNodes.find(o=>o.nodeName==="#documentType");if(i)i.name=t,i.publicId=n,i.systemId=r;else{const o={nodeName:"#documentType",name:t,publicId:n,systemId:r,parentNode:null};jp.appendChild(e,o)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(jp.isTextNode(n)){n.value+=t;return}}jp.appendChild(e,jp.createTextNode(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&jp.isTextNode(r)?r.value+=t:jp.insertBefore(e,jp.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(r=>r.name));for(let r=0;r<t.length;r++)n.has(t[r].name)||e.attrs.push(t[r])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName==="#text"},isCommentNode(e){return e.nodeName==="#comment"},isDocumentTypeNode(e){return e.nodeName==="#documentType"},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,"tagName")},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}}}));function WDe(e,t){return t.some(n=>e.startsWith(n))}function bwn(e){return e.name===FK&&e.publicId===null&&(e.systemId===null||e.systemId===GDe)}function vwn(e){if(e.name!==FK)return cd.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===jDe)return cd.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),YDe.has(n))return cd.QUIRKS;let r=t===null?qDe:BK;if(WDe(n,r))return cd.QUIRKS;if(r=t===null?HK:KDe,WDe(n,r))return cd.LIMITED_QUIRKS}return cd.NO_QUIRKS}var FK,GDe,jDe,BK,qDe,YDe,HK,KDe,wwn=Le((()=>{$g(),FK="html",GDe="about:legacy-compat",jDe="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",BK=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],qDe=[...BK,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],YDe=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),HK=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],KDe=[...HK,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"]}));function Awn(e){const t=e.tagID;return t===j.FONT&&e.attrs.some(({name:n})=>n===Lb.COLOR||n===Lb.SIZE||n===Lb.FACE)||n3e.has(t)}function XDe(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===ZDe){e.attrs[t].name=QDe;break}}function JDe(e){for(let t=0;t<e.attrs.length;t++){const n=$De.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function zK(e){for(let t=0;t<e.attrs.length;t++){const n=e3e.get(e.attrs[t].name);n&&(e.attrs[t].prefix=n.prefix,e.attrs[t].name=n.name,e.attrs[t].namespace=n.namespace)}}function xwn(e){const t=t3e.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=o5(e.tagName))}function Swn(e,t){return t===Bt.MATHML&&(e===j.MI||e===j.MO||e===j.MN||e===j.MS||e===j.MTEXT)}function Twn(e,t,n){if(t===Bt.MATHML&&e===j.ANNOTATION_XML){for(let r=0;r<n.length;r++)if(n[r].name===Lb.ENCODING){const i=n[r].value.toLowerCase();return i===UK.TEXT_HTML||i===UK.APPLICATION_XML}}return t===Bt.SVG&&(e===j.FOREIGN_OBJECT||e===j.DESC||e===j.TITLE)}function Iwn(e,t,n,r){return(!r||r===Bt.HTML)&&Twn(e,t,n)||(!r||r===Bt.MATHML)&&Swn(e,t)}var UK,ZDe,QDe,$De,e3e,t3e,n3e,r3e=Le((()=>{$g(),UK={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},ZDe="definitionurl",QDe="definitionURL",$De=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),e3e=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:Bt.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:Bt.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:Bt.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:Bt.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:Bt.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:Bt.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:Bt.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:Bt.XML}],["xml:space",{prefix:"xml",name:"space",namespace:Bt.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:Bt.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:Bt.XMLNS}]]),t3e=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),n3e=new Set([j.B,j.BIG,j.BLOCKQUOTE,j.BODY,j.BR,j.CENTER,j.CODE,j.DD,j.DIV,j.DL,j.DT,j.EM,j.EMBED,j.H1,j.H2,j.H3,j.H4,j.H5,j.H6,j.HEAD,j.HR,j.I,j.IMG,j.LI,j.LISTING,j.MENU,j.META,j.NOBR,j.OL,j.P,j.PRE,j.RUBY,j.S,j.SMALL,j.SPAN,j.STRONG,j.STRIKE,j.SUB,j.SUP,j.TABLE,j.TT,j.U,j.UL,j.VAR])}));function kwn(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):u3e(e,t),n}function Ewn(e,t){let n=null,r=e.openElements.stackTop;for(;r>=0;r--){const i=e.openElements.items[r];if(i===t.element)break;e._isSpecialElement(i,e.openElements.tagIDs[r])&&(n=i)}return n||(e.openElements.shortenToLength(Math.max(r,0)),e.activeFormattingElements.removeEntry(t)),n}function Cwn(e,t,n){let r=t,i=e.openElements.getCommonAncestor(t);for(let o=0,s=i;s!==n;o++,s=i){i=e.openElements.getCommonAncestor(s);const a=e.activeFormattingElements.getElementEntry(s),l=a&&o>=x3e;!a||l?(l&&e.activeFormattingElements.removeEntry(a),e.openElements.remove(s)):(s=_wn(e,a),r===t&&(e.activeFormattingElements.bookmark=a),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(s,r),r=s)}return r}function _wn(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),r=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,r),t.element=r,r}function Pwn(e,t,n){const r=o5(e.treeAdapter.getTagName(t));if(e._isElementCausesFosterParenting(r))e._fosterParentElement(n);else{const i=e.treeAdapter.getNamespaceURI(t);r===j.TEMPLATE&&i===Bt.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function Rwn(e,t,n){const r=e.treeAdapter.getNamespaceURI(n.element),{token:i}=n,o=e.treeAdapter.createElement(i.tagName,r,i.attrs);e._adoptNodes(t,o),e.treeAdapter.appendChild(t,o),e.activeFormattingElements.insertElementAfterBookmark(o,i),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,o,i.tagID)}function VK(e,t){for(let n=0;n<A3e;n++){const r=kwn(e,t);if(!r)break;const i=Ewn(e,r);if(!i)break;e.activeFormattingElements.bookmark=r;const o=Cwn(e,i,r.element),s=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(o),s&&Pwn(e,s,o),Rwn(e,i,r)}}function WK(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function Lwn(e,t){e._appendCommentNode(t,e.openElements.items[0])}function Nwn(e,t){e._appendCommentNode(t,e.document)}function GK(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let r=e.openElements.stackTop;r>=n;r--)e._setEndLocation(e.openElements.items[r],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const r=e.openElements.items[0],i=e.treeAdapter.getNodeSourceCodeLocation(r);if(i&&!i.endTag&&(e._setEndLocation(r,t),e.openElements.stackTop>=1)){const o=e.openElements.items[1],s=e.treeAdapter.getNodeSourceCodeLocation(o);s&&!s.endTag&&e._setEndLocation(o,t)}}}}function Mwn(e,t){e._setDocumentType(t);const n=t.forceQuirks?cd.QUIRKS:vwn(t);bwn(t)||e._err(t,wt.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=Ze.BEFORE_HTML}function aC(e,t){e._err(t,wt.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,cd.QUIRKS),e.insertionMode=Ze.BEFORE_HTML,e._processToken(t)}function Dwn(e,t){t.tagID===j.HTML?(e._insertElement(t,Bt.HTML),e.insertionMode=Ze.BEFORE_HEAD):lC(e,t)}function Own(e,t){const n=t.tagID;(n===j.HTML||n===j.HEAD||n===j.BODY||n===j.BR)&&lC(e,t)}function lC(e,t){e._insertFakeRootElement(),e.insertionMode=Ze.BEFORE_HEAD,e._processToken(t)}function Fwn(e,t){switch(t.tagID){case j.HTML:Rl(e,t);break;case j.HEAD:e._insertElement(t,Bt.HTML),e.headElement=e.openElements.current,e.insertionMode=Ze.IN_HEAD;break;default:cC(e,t)}}function Bwn(e,t){const n=t.tagID;n===j.HEAD||n===j.BODY||n===j.HTML||n===j.BR?cC(e,t):e._err(t,wt.endTagWithoutMatchingOpenElement)}function cC(e,t){e._insertFakeElement(pt.HEAD,j.HEAD),e.headElement=e.openElements.current,e.insertionMode=Ze.IN_HEAD,e._processToken(t)}function uf(e,t){switch(t.tagID){case j.HTML:Rl(e,t);break;case j.BASE:case j.BASEFONT:case j.BGSOUND:case j.LINK:case j.META:e._appendElement(t,Bt.HTML),t.ackSelfClosing=!0;break;case j.TITLE:e._switchToTextParsing(t,dc.RCDATA);break;case j.NOSCRIPT:e.options.scriptingEnabled?e._switchToTextParsing(t,dc.RAWTEXT):(e._insertElement(t,Bt.HTML),e.insertionMode=Ze.IN_HEAD_NO_SCRIPT);break;case j.NOFRAMES:case j.STYLE:e._switchToTextParsing(t,dc.RAWTEXT);break;case j.SCRIPT:e._switchToTextParsing(t,dc.SCRIPT_DATA);break;case j.TEMPLATE:e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=Ze.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(Ze.IN_TEMPLATE);break;case j.HEAD:e._err(t,wt.misplacedStartTagForHeadElement);break;default:uC(e,t)}}function Hwn(e,t){switch(t.tagID){case j.HEAD:e.openElements.pop(),e.insertionMode=Ze.AFTER_HEAD;break;case j.BODY:case j.BR:case j.HTML:uC(e,t);break;case j.TEMPLATE:Nb(e,t);break;default:e._err(t,wt.endTagWithoutMatchingOpenElement)}}function Nb(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==j.TEMPLATE&&e._err(t,wt.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(j.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,wt.endTagWithoutMatchingOpenElement)}function uC(e,t){e.openElements.pop(),e.insertionMode=Ze.AFTER_HEAD,e._processToken(t)}function zwn(e,t){switch(t.tagID){case j.HTML:Rl(e,t);break;case j.BASEFONT:case j.BGSOUND:case j.HEAD:case j.LINK:case j.META:case j.NOFRAMES:case j.STYLE:uf(e,t);break;case j.NOSCRIPT:e._err(t,wt.nestedNoscriptInHead);break;default:dC(e,t)}}function Uwn(e,t){switch(t.tagID){case j.NOSCRIPT:e.openElements.pop(),e.insertionMode=Ze.IN_HEAD;break;case j.BR:dC(e,t);break;default:e._err(t,wt.endTagWithoutMatchingOpenElement)}}function dC(e,t){const n=t.type===Mi.EOF?wt.openElementsLeftAfterEof:wt.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=Ze.IN_HEAD,e._processToken(t)}function Vwn(e,t){switch(t.tagID){case j.HTML:Rl(e,t);break;case j.BODY:e._insertElement(t,Bt.HTML),e.framesetOk=!1,e.insertionMode=Ze.IN_BODY;break;case j.FRAMESET:e._insertElement(t,Bt.HTML),e.insertionMode=Ze.IN_FRAMESET;break;case j.BASE:case j.BASEFONT:case j.BGSOUND:case j.LINK:case j.META:case j.NOFRAMES:case j.SCRIPT:case j.STYLE:case j.TEMPLATE:case j.TITLE:e._err(t,wt.abandonedHeadElementChild),e.openElements.push(e.headElement,j.HEAD),uf(e,t),e.openElements.remove(e.headElement);break;case j.HEAD:e._err(t,wt.misplacedStartTagForHeadElement);break;default:fC(e,t)}}function Wwn(e,t){switch(t.tagID){case j.BODY:case j.HTML:case j.BR:fC(e,t);break;case j.TEMPLATE:Nb(e,t);break;default:e._err(t,wt.endTagWithoutMatchingOpenElement)}}function fC(e,t){e._insertFakeElement(pt.BODY,j.BODY),e.insertionMode=Ze.IN_BODY,c5(e,t)}function c5(e,t){switch(t.type){case Mi.CHARACTER:o3e(e,t);break;case Mi.WHITESPACE_CHARACTER:i3e(e,t);break;case Mi.COMMENT:WK(e,t);break;case Mi.START_TAG:Rl(e,t);break;case Mi.END_TAG:u5(e,t);break;case Mi.EOF:d3e(e,t);break;default:}}function i3e(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function o3e(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function Gwn(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function jwn(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function qwn(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Bt.HTML),e.insertionMode=Ze.IN_FRAMESET)}function Ywn(e,t){e.openElements.hasInButtonScope(j.P)&&e._closePElement(),e._insertElement(t,Bt.HTML)}function Kwn(e,t){e.openElements.hasInButtonScope(j.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&s5.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Bt.HTML)}function Xwn(e,t){e.openElements.hasInButtonScope(j.P)&&e._closePElement(),e._insertElement(t,Bt.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function Jwn(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(j.P)&&e._closePElement(),e._insertElement(t,Bt.HTML),n||(e.formElement=e.openElements.current))}function Zwn(e,t){e.framesetOk=!1;const n=t.tagID;for(let r=e.openElements.stackTop;r>=0;r--){const i=e.openElements.tagIDs[r];if(n===j.LI&&i===j.LI||(n===j.DD||n===j.DT)&&(i===j.DD||i===j.DT)){e.openElements.generateImpliedEndTagsWithExclusion(i),e.openElements.popUntilTagNamePopped(i);break}if(i!==j.ADDRESS&&i!==j.DIV&&i!==j.P&&e._isSpecialElement(e.openElements.items[r],i))break}e.openElements.hasInButtonScope(j.P)&&e._closePElement(),e._insertElement(t,Bt.HTML)}function Qwn(e,t){e.openElements.hasInButtonScope(j.P)&&e._closePElement(),e._insertElement(t,Bt.HTML),e.tokenizer.state=dc.PLAINTEXT}function $wn(e,t){e.openElements.hasInScope(j.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(j.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,Bt.HTML),e.framesetOk=!1}function eAn(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(pt.A);n&&(VK(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,Bt.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function tAn(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Bt.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function nAn(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(j.NOBR)&&(VK(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Bt.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function rAn(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Bt.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function iAn(e,t){e.treeAdapter.getDocumentMode(e.document)!==cd.QUIRKS&&e.openElements.hasInButtonScope(j.P)&&e._closePElement(),e._insertElement(t,Bt.HTML),e.framesetOk=!1,e.insertionMode=Ze.IN_TABLE}function s3e(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Bt.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function a3e(e){const t=SDe(e,Lb.TYPE);return t!=null&&t.toLowerCase()===w3e}function oAn(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Bt.HTML),a3e(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function sAn(e,t){e._appendElement(t,Bt.HTML),t.ackSelfClosing=!0}function aAn(e,t){e.openElements.hasInButtonScope(j.P)&&e._closePElement(),e._appendElement(t,Bt.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function lAn(e,t){t.tagName=pt.IMG,t.tagID=j.IMG,s3e(e,t)}function cAn(e,t){e._insertElement(t,Bt.HTML),e.skipNextNewLine=!0,e.tokenizer.state=dc.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=Ze.TEXT}function uAn(e,t){e.openElements.hasInButtonScope(j.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,dc.RAWTEXT)}function dAn(e,t){e.framesetOk=!1,e._switchToTextParsing(t,dc.RAWTEXT)}function l3e(e,t){e._switchToTextParsing(t,dc.RAWTEXT)}function fAn(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Bt.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===Ze.IN_TABLE||e.insertionMode===Ze.IN_CAPTION||e.insertionMode===Ze.IN_TABLE_BODY||e.insertionMode===Ze.IN_ROW||e.insertionMode===Ze.IN_CELL?Ze.IN_SELECT_IN_TABLE:Ze.IN_SELECT}function hAn(e,t){e.openElements.currentTagId===j.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Bt.HTML)}function pAn(e,t){e.openElements.hasInScope(j.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Bt.HTML)}function mAn(e,t){e.openElements.hasInScope(j.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(j.RTC),e._insertElement(t,Bt.HTML)}function gAn(e,t){e._reconstructActiveFormattingElements(),XDe(t),zK(t),t.selfClosing?e._appendElement(t,Bt.MATHML):e._insertElement(t,Bt.MATHML),t.ackSelfClosing=!0}function yAn(e,t){e._reconstructActiveFormattingElements(),JDe(t),zK(t),t.selfClosing?e._appendElement(t,Bt.SVG):e._insertElement(t,Bt.SVG),t.ackSelfClosing=!0}function c3e(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Bt.HTML)}function Rl(e,t){switch(t.tagID){case j.I:case j.S:case j.B:case j.U:case j.EM:case j.TT:case j.BIG:case j.CODE:case j.FONT:case j.SMALL:case j.STRIKE:case j.STRONG:tAn(e,t);break;case j.A:eAn(e,t);break;case j.H1:case j.H2:case j.H3:case j.H4:case j.H5:case j.H6:Kwn(e,t);break;case j.P:case j.DL:case j.OL:case j.UL:case j.DIV:case j.DIR:case j.NAV:case j.MAIN:case j.MENU:case j.ASIDE:case j.CENTER:case j.FIGURE:case j.FOOTER:case j.HEADER:case j.HGROUP:case j.DIALOG:case j.DETAILS:case j.ADDRESS:case j.ARTICLE:case j.SEARCH:case j.SECTION:case j.SUMMARY:case j.FIELDSET:case j.BLOCKQUOTE:case j.FIGCAPTION:Ywn(e,t);break;case j.LI:case j.DD:case j.DT:Zwn(e,t);break;case j.BR:case j.IMG:case j.WBR:case j.AREA:case j.EMBED:case j.KEYGEN:s3e(e,t);break;case j.HR:aAn(e,t);break;case j.RB:case j.RTC:pAn(e,t);break;case j.RT:case j.RP:mAn(e,t);break;case j.PRE:case j.LISTING:Xwn(e,t);break;case j.XMP:uAn(e,t);break;case j.SVG:yAn(e,t);break;case j.HTML:Gwn(e,t);break;case j.BASE:case j.LINK:case j.META:case j.STYLE:case j.TITLE:case j.SCRIPT:case j.BGSOUND:case j.BASEFONT:case j.TEMPLATE:uf(e,t);break;case j.BODY:jwn(e,t);break;case j.FORM:Jwn(e,t);break;case j.NOBR:nAn(e,t);break;case j.MATH:gAn(e,t);break;case j.TABLE:iAn(e,t);break;case j.INPUT:oAn(e,t);break;case j.PARAM:case j.TRACK:case j.SOURCE:sAn(e,t);break;case j.IMAGE:lAn(e,t);break;case j.BUTTON:$wn(e,t);break;case j.APPLET:case j.OBJECT:case j.MARQUEE:rAn(e,t);break;case j.IFRAME:dAn(e,t);break;case j.SELECT:fAn(e,t);break;case j.OPTION:case j.OPTGROUP:hAn(e,t);break;case j.NOEMBED:case j.NOFRAMES:l3e(e,t);break;case j.FRAMESET:qwn(e,t);break;case j.TEXTAREA:cAn(e,t);break;case j.NOSCRIPT:e.options.scriptingEnabled?l3e(e,t):c3e(e,t);break;case j.PLAINTEXT:Qwn(e,t);break;case j.COL:case j.TH:case j.TD:case j.TR:case j.HEAD:case j.FRAME:case j.TBODY:case j.TFOOT:case j.THEAD:case j.CAPTION:case j.COLGROUP:break;default:c3e(e,t)}}function bAn(e,t){if(e.openElements.hasInScope(j.BODY)&&(e.insertionMode=Ze.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function vAn(e,t){e.openElements.hasInScope(j.BODY)&&(e.insertionMode=Ze.AFTER_BODY,b3e(e,t))}function wAn(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function AAn(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(j.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(j.FORM):n&&e.openElements.remove(n))}function xAn(e){e.openElements.hasInButtonScope(j.P)||e._insertFakeElement(pt.P,j.P),e._closePElement()}function SAn(e){e.openElements.hasInListItemScope(j.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(j.LI),e.openElements.popUntilTagNamePopped(j.LI))}function TAn(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function IAn(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function kAn(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function EAn(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(pt.BR,j.BR),e.openElements.pop(),e.framesetOk=!1}function u3e(e,t){const n=t.tagName,r=t.tagID;for(let i=e.openElements.stackTop;i>0;i--){const o=e.openElements.items[i],s=e.openElements.tagIDs[i];if(r===s&&(r!==j.UNKNOWN||e.treeAdapter.getTagName(o)===n)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.stackTop>=i&&e.openElements.shortenToLength(i);break}if(e._isSpecialElement(o,s))break}}function u5(e,t){switch(t.tagID){case j.A:case j.B:case j.I:case j.S:case j.U:case j.EM:case j.TT:case j.BIG:case j.CODE:case j.FONT:case j.NOBR:case j.SMALL:case j.STRIKE:case j.STRONG:VK(e,t);break;case j.P:xAn(e);break;case j.DL:case j.UL:case j.OL:case j.DIR:case j.DIV:case j.NAV:case j.PRE:case j.MAIN:case j.MENU:case j.ASIDE:case j.BUTTON:case j.CENTER:case j.FIGURE:case j.FOOTER:case j.HEADER:case j.HGROUP:case j.DIALOG:case j.ADDRESS:case j.ARTICLE:case j.DETAILS:case j.SEARCH:case j.SECTION:case j.SUMMARY:case j.LISTING:case j.FIELDSET:case j.BLOCKQUOTE:case j.FIGCAPTION:wAn(e,t);break;case j.LI:SAn(e);break;case j.DD:case j.DT:TAn(e,t);break;case j.H1:case j.H2:case j.H3:case j.H4:case j.H5:case j.H6:IAn(e);break;case j.BR:EAn(e);break;case j.BODY:bAn(e,t);break;case j.HTML:vAn(e,t);break;case j.FORM:AAn(e);break;case j.APPLET:case j.OBJECT:case j.MARQUEE:kAn(e,t);break;case j.TEMPLATE:Nb(e,t);break;default:u3e(e,t)}}function d3e(e,t){e.tmplInsertionModeStack.length>0?y3e(e,t):GK(e,t)}function CAn(e,t){var n;t.tagID===j.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function _An(e,t){e._err(t,wt.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function jK(e,t){if(e.openElements.currentTagId!==void 0&&KK.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=Ze.IN_TABLE_TEXT,t.type){case Mi.CHARACTER:h3e(e,t);break;case Mi.WHITESPACE_CHARACTER:f3e(e,t);break}else pC(e,t)}function PAn(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Bt.HTML),e.insertionMode=Ze.IN_CAPTION}function RAn(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Bt.HTML),e.insertionMode=Ze.IN_COLUMN_GROUP}function LAn(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(pt.COLGROUP,j.COLGROUP),e.insertionMode=Ze.IN_COLUMN_GROUP,qK(e,t)}function NAn(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Bt.HTML),e.insertionMode=Ze.IN_TABLE_BODY}function MAn(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(pt.TBODY,j.TBODY),e.insertionMode=Ze.IN_TABLE_BODY,f5(e,t)}function DAn(e,t){e.openElements.hasInTableScope(j.TABLE)&&(e.openElements.popUntilTagNamePopped(j.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function OAn(e,t){a3e(t)?e._appendElement(t,Bt.HTML):pC(e,t),t.ackSelfClosing=!0}function FAn(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,Bt.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function Fx(e,t){switch(t.tagID){case j.TD:case j.TH:case j.TR:MAn(e,t);break;case j.STYLE:case j.SCRIPT:case j.TEMPLATE:uf(e,t);break;case j.COL:LAn(e,t);break;case j.FORM:FAn(e,t);break;case j.TABLE:DAn(e,t);break;case j.TBODY:case j.TFOOT:case j.THEAD:NAn(e,t);break;case j.INPUT:OAn(e,t);break;case j.CAPTION:PAn(e,t);break;case j.COLGROUP:RAn(e,t);break;default:pC(e,t)}}function hC(e,t){switch(t.tagID){case j.TABLE:e.openElements.hasInTableScope(j.TABLE)&&(e.openElements.popUntilTagNamePopped(j.TABLE),e._resetInsertionMode());break;case j.TEMPLATE:Nb(e,t);break;case j.BODY:case j.CAPTION:case j.COL:case j.COLGROUP:case j.HTML:case j.TBODY:case j.TD:case j.TFOOT:case j.TH:case j.THEAD:case j.TR:break;default:pC(e,t)}}function pC(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,c5(e,t),e.fosterParentingEnabled=n}function f3e(e,t){e.pendingCharacterTokens.push(t)}function h3e(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function mC(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)pC(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}function BAn(e,t){const n=t.tagID;ZK.has(n)?e.openElements.hasInTableScope(j.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(j.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Ze.IN_TABLE,Fx(e,t)):Rl(e,t)}function HAn(e,t){const n=t.tagID;switch(n){case j.CAPTION:case j.TABLE:e.openElements.hasInTableScope(j.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(j.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Ze.IN_TABLE,n===j.TABLE&&hC(e,t));break;case j.BODY:case j.COL:case j.COLGROUP:case j.HTML:case j.TBODY:case j.TD:case j.TFOOT:case j.TH:case j.THEAD:case j.TR:break;default:u5(e,t)}}function qK(e,t){switch(t.tagID){case j.HTML:Rl(e,t);break;case j.COL:e._appendElement(t,Bt.HTML),t.ackSelfClosing=!0;break;case j.TEMPLATE:uf(e,t);break;default:d5(e,t)}}function zAn(e,t){switch(t.tagID){case j.COLGROUP:e.openElements.currentTagId===j.COLGROUP&&(e.openElements.pop(),e.insertionMode=Ze.IN_TABLE);break;case j.TEMPLATE:Nb(e,t);break;case j.COL:break;default:d5(e,t)}}function d5(e,t){e.openElements.currentTagId===j.COLGROUP&&(e.openElements.pop(),e.insertionMode=Ze.IN_TABLE,e._processToken(t))}function f5(e,t){switch(t.tagID){case j.TR:e.openElements.clearBackToTableBodyContext(),e._insertElement(t,Bt.HTML),e.insertionMode=Ze.IN_ROW;break;case j.TH:case j.TD:e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(pt.TR,j.TR),e.insertionMode=Ze.IN_ROW,h5(e,t);break;case j.CAPTION:case j.COL:case j.COLGROUP:case j.TBODY:case j.TFOOT:case j.THEAD:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Ze.IN_TABLE,Fx(e,t));break;default:Fx(e,t)}}function YK(e,t){const n=t.tagID;switch(t.tagID){case j.TBODY:case j.TFOOT:case j.THEAD:e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Ze.IN_TABLE);break;case j.TABLE:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Ze.IN_TABLE,hC(e,t));break;case j.BODY:case j.CAPTION:case j.COL:case j.COLGROUP:case j.HTML:case j.TD:case j.TH:case j.TR:break;default:hC(e,t)}}function h5(e,t){switch(t.tagID){case j.TH:case j.TD:e.openElements.clearBackToTableRowContext(),e._insertElement(t,Bt.HTML),e.insertionMode=Ze.IN_CELL,e.activeFormattingElements.insertMarker();break;case j.CAPTION:case j.COL:case j.COLGROUP:case j.TBODY:case j.TFOOT:case j.THEAD:case j.TR:e.openElements.hasInTableScope(j.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Ze.IN_TABLE_BODY,f5(e,t));break;default:Fx(e,t)}}function p3e(e,t){switch(t.tagID){case j.TR:e.openElements.hasInTableScope(j.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Ze.IN_TABLE_BODY);break;case j.TABLE:e.openElements.hasInTableScope(j.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Ze.IN_TABLE_BODY,YK(e,t));break;case j.TBODY:case j.TFOOT:case j.THEAD:(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(j.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Ze.IN_TABLE_BODY,YK(e,t));break;case j.BODY:case j.CAPTION:case j.COL:case j.COLGROUP:case j.HTML:case j.TD:case j.TH:break;default:hC(e,t)}}function UAn(e,t){const n=t.tagID;ZK.has(n)?(e.openElements.hasInTableScope(j.TD)||e.openElements.hasInTableScope(j.TH))&&(e._closeTableCell(),h5(e,t)):Rl(e,t)}function VAn(e,t){const n=t.tagID;switch(n){case j.TD:case j.TH:e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Ze.IN_ROW);break;case j.TABLE:case j.TBODY:case j.TFOOT:case j.THEAD:case j.TR:e.openElements.hasInTableScope(n)&&(e._closeTableCell(),p3e(e,t));break;case j.BODY:case j.CAPTION:case j.COL:case j.COLGROUP:case j.HTML:break;default:u5(e,t)}}function m3e(e,t){switch(t.tagID){case j.HTML:Rl(e,t);break;case j.OPTION:e.openElements.currentTagId===j.OPTION&&e.openElements.pop(),e._insertElement(t,Bt.HTML);break;case j.OPTGROUP:e.openElements.currentTagId===j.OPTION&&e.openElements.pop(),e.openElements.currentTagId===j.OPTGROUP&&e.openElements.pop(),e._insertElement(t,Bt.HTML);break;case j.HR:e.openElements.currentTagId===j.OPTION&&e.openElements.pop(),e.openElements.currentTagId===j.OPTGROUP&&e.openElements.pop(),e._appendElement(t,Bt.HTML),t.ackSelfClosing=!0;break;case j.INPUT:case j.KEYGEN:case j.TEXTAREA:case j.SELECT:e.openElements.hasInSelectScope(j.SELECT)&&(e.openElements.popUntilTagNamePopped(j.SELECT),e._resetInsertionMode(),t.tagID!==j.SELECT&&e._processStartTag(t));break;case j.SCRIPT:case j.TEMPLATE:uf(e,t);break;default:}}function g3e(e,t){switch(t.tagID){case j.OPTGROUP:e.openElements.stackTop>0&&e.openElements.currentTagId===j.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===j.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===j.OPTGROUP&&e.openElements.pop();break;case j.OPTION:e.openElements.currentTagId===j.OPTION&&e.openElements.pop();break;case j.SELECT:e.openElements.hasInSelectScope(j.SELECT)&&(e.openElements.popUntilTagNamePopped(j.SELECT),e._resetInsertionMode());break;case j.TEMPLATE:Nb(e,t);break;default:}}function WAn(e,t){const n=t.tagID;n===j.CAPTION||n===j.TABLE||n===j.TBODY||n===j.TFOOT||n===j.THEAD||n===j.TR||n===j.TD||n===j.TH?(e.openElements.popUntilTagNamePopped(j.SELECT),e._resetInsertionMode(),e._processStartTag(t)):m3e(e,t)}function GAn(e,t){const n=t.tagID;n===j.CAPTION||n===j.TABLE||n===j.TBODY||n===j.TFOOT||n===j.THEAD||n===j.TR||n===j.TD||n===j.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(j.SELECT),e._resetInsertionMode(),e.onEndTag(t)):g3e(e,t)}function jAn(e,t){switch(t.tagID){case j.BASE:case j.BASEFONT:case j.BGSOUND:case j.LINK:case j.META:case j.NOFRAMES:case j.SCRIPT:case j.STYLE:case j.TEMPLATE:case j.TITLE:uf(e,t);break;case j.CAPTION:case j.COLGROUP:case j.TBODY:case j.TFOOT:case j.THEAD:e.tmplInsertionModeStack[0]=Ze.IN_TABLE,e.insertionMode=Ze.IN_TABLE,Fx(e,t);break;case j.COL:e.tmplInsertionModeStack[0]=Ze.IN_COLUMN_GROUP,e.insertionMode=Ze.IN_COLUMN_GROUP,qK(e,t);break;case j.TR:e.tmplInsertionModeStack[0]=Ze.IN_TABLE_BODY,e.insertionMode=Ze.IN_TABLE_BODY,f5(e,t);break;case j.TD:case j.TH:e.tmplInsertionModeStack[0]=Ze.IN_ROW,e.insertionMode=Ze.IN_ROW,h5(e,t);break;default:e.tmplInsertionModeStack[0]=Ze.IN_BODY,e.insertionMode=Ze.IN_BODY,Rl(e,t)}}function qAn(e,t){t.tagID===j.TEMPLATE&&Nb(e,t)}function y3e(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(j.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):GK(e,t)}function YAn(e,t){t.tagID===j.HTML?Rl(e,t):p5(e,t)}function b3e(e,t){var n;if(t.tagID===j.HTML){if(e.fragmentContext||(e.insertionMode=Ze.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===j.HTML){e._setEndLocation(e.openElements.items[0],t);const r=e.openElements.items[1];r&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(r))===null||n===void 0)&&n.endTag)&&e._setEndLocation(r,t)}}else p5(e,t)}function p5(e,t){e.insertionMode=Ze.IN_BODY,c5(e,t)}function KAn(e,t){switch(t.tagID){case j.HTML:Rl(e,t);break;case j.FRAMESET:e._insertElement(t,Bt.HTML);break;case j.FRAME:e._appendElement(t,Bt.HTML),t.ackSelfClosing=!0;break;case j.NOFRAMES:uf(e,t);break;default:}}function XAn(e,t){t.tagID===j.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==j.FRAMESET&&(e.insertionMode=Ze.AFTER_FRAMESET))}function JAn(e,t){switch(t.tagID){case j.HTML:Rl(e,t);break;case j.NOFRAMES:uf(e,t);break;default:}}function ZAn(e,t){t.tagID===j.HTML&&(e.insertionMode=Ze.AFTER_AFTER_FRAMESET)}function QAn(e,t){t.tagID===j.HTML?Rl(e,t):m5(e,t)}function m5(e,t){e.insertionMode=Ze.IN_BODY,c5(e,t)}function $An(e,t){switch(t.tagID){case j.HTML:Rl(e,t);break;case j.NOFRAMES:uf(e,t);break;default:}}function exn(e,t){t.chars="�",e._insertCharacters(t)}function txn(e,t){e._insertCharacters(t),e.framesetOk=!1}function v3e(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==Bt.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function nxn(e,t){if(Awn(t))v3e(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===Bt.MATHML?XDe(t):r===Bt.SVG&&(xwn(t),JDe(t)),zK(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function rxn(e,t){if(t.tagID===j.P||t.tagID===j.BR){v3e(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const r=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(r)===Bt.HTML){e._endTagOutsideForeignContent(t);break}const i=e.treeAdapter.getTagName(r);if(i.toLowerCase()===t.tagName){t.tagName=i,e.openElements.shortenToLength(n);break}}}var w3e,A3e,x3e,Ze,S3e,KK,XK,JK,ZK,ixn=Le((()=>{MDe(),gwn(),ywn(),OK(),wwn(),r3e(),i5(),EK(),$g(),CK(),w3e="hidden",A3e=8,x3e=3,(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(Ze||(Ze={})),S3e={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},KK=new Set([j.TABLE,j.TBODY,j.TFOOT,j.THEAD,j.TR]),XK={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:jp,onParseError:null},JK=class{constructor(e,t,n=null,r=null){this.fragmentContext=n,this.scriptHandler=r,this.currentToken=null,this.stopped=!1,this.insertionMode=Ze.INITIAL,this.originalInsertionMode=Ze.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...XK,...e},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=t??this.treeAdapter.createDocument(),this.tokenizer=new NDe(this.options,this),this.activeFormattingElements=new VDe(this.treeAdapter),this.fragmentContextID=n?o5(this.treeAdapter.getTagName(n)):j.UNKNOWN,this._setContextModes(n??this.document,this.fragmentContextID),this.openElements=new UDe(this.document,this.treeAdapter,this)}static parse(e,t){const n=new this(t);return n.tokenizer.write(e,!0),n.document}static getFragmentParser(e,t){const n={...XK,...t};e!=null||(e=n.treeAdapter.createElement(pt.TEMPLATE,Bt.HTML,[]));const r=n.treeAdapter.createElement("documentmock",Bt.HTML,[]),i=new this(n,r,e);return i.fragmentContextID===j.TEMPLATE&&i.tmplInsertionModeStack.unshift(Ze.IN_TEMPLATE),i._initTokenizerForFragmentParsing(),i._insertFakeRootElement(),i._resetInsertionMode(),i._findFormInFragmentContext(),i}getFragment(){const e=this.treeAdapter.getFirstChild(this.document),t=this.treeAdapter.createDocumentFragment();return this._adoptNodes(e,t),t}_err(e,t,n){var r;if(!this.onParseError)return;const i=(r=e.location)!==null&&r!==void 0?r:S3e,o={code:t,startLine:i.startLine,startCol:i.startCol,startOffset:i.startOffset,endLine:n?i.startLine:i.endLine,endCol:n?i.startCol:i.endCol,endOffset:n?i.startOffset:i.endOffset};this.onParseError(o)}onItemPush(e,t,n){var r,i;(i=(r=this.treeAdapter).onItemPush)===null||i===void 0||i.call(r,e),n&&this.openElements.stackTop>0&&this._setContextModes(e,t)}onItemPop(e,t){var n,r;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(e,this.currentToken),(r=(n=this.treeAdapter).onItemPop)===null||r===void 0||r.call(n,e,this.openElements.current),t){let i,o;this.openElements.stackTop===0&&this.fragmentContext?(i=this.fragmentContext,o=this.fragmentContextID):{current:i,currentTagId:o}=this.openElements,this._setContextModes(i,o)}}_setContextModes(e,t){const n=e===this.document||e&&this.treeAdapter.getNamespaceURI(e)===Bt.HTML;this.currentNotInHTML=!n,this.tokenizer.inForeignNode=!n&&e!==void 0&&t!==void 0&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,Bt.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=Ze.TEXT}switchToPlaintextParsing(){this.insertionMode=Ze.TEXT,this.originalInsertionMode=Ze.IN_BODY,this.tokenizer.state=dc.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let e=this.fragmentContext;for(;e;){if(this.treeAdapter.getTagName(e)===pt.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==Bt.HTML))switch(this.fragmentContextID){case j.TITLE:case j.TEXTAREA:this.tokenizer.state=dc.RCDATA;break;case j.STYLE:case j.XMP:case j.IFRAME:case j.NOEMBED:case j.NOFRAMES:case j.NOSCRIPT:this.tokenizer.state=dc.RAWTEXT;break;case j.SCRIPT:this.tokenizer.state=dc.SCRIPT_DATA;break;case j.PLAINTEXT:this.tokenizer.state=dc.PLAINTEXT;break;default:}}_setDocumentType(e){const t=e.name||"",n=e.publicId||"",r=e.systemId||"";if(this.treeAdapter.setDocumentType(this.document,t,n,r),e.location){const i=this.treeAdapter.getChildNodes(this.document).find(o=>this.treeAdapter.isDocumentTypeNode(o));i&&this.treeAdapter.setNodeSourceCodeLocation(i,e.location)}}_attachElementToTree(e,t){if(this.options.sourceCodeLocationInfo){const n=t&&{...t,startTag:t};this.treeAdapter.setNodeSourceCodeLocation(e,n)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(e);else{const n=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(n??this.document,e)}}_appendElement(e,t){const n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location)}_insertElement(e,t){const n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location),this.openElements.push(n,e.tagID)}_insertFakeElement(e,t){const n=this.treeAdapter.createElement(e,Bt.HTML,[]);this._attachElementToTree(n,null),this.openElements.push(n,t)}_insertTemplate(e){const t=this.treeAdapter.createElement(e.tagName,Bt.HTML,e.attrs),n=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(t,n),this._attachElementToTree(t,e.location),this.openElements.push(t,e.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,null)}_insertFakeRootElement(){const e=this.treeAdapter.createElement(pt.HTML,Bt.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,j.HTML)}_appendCommentNode(e,t){const n=this.treeAdapter.createCommentNode(e.data);this.treeAdapter.appendChild(t,n),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,e.location)}_insertCharacters(e){let t,n;if(this._shouldFosterParentOnInsertion()?({parent:t,beforeElement:n}=this._findFosterParentingLocation(),n?this.treeAdapter.insertTextBefore(t,e.chars,n):this.treeAdapter.insertText(t,e.chars)):(t=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(t,e.chars)),!e.location)return;const r=this.treeAdapter.getChildNodes(t),i=r[(n?r.lastIndexOf(n):r.length)-1];if(this.treeAdapter.getNodeSourceCodeLocation(i)){const{endLine:o,endCol:s,endOffset:a}=e.location;this.treeAdapter.updateNodeSourceCodeLocation(i,{endLine:o,endCol:s,endOffset:a})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,e.location)}_adoptNodes(e,t){for(let n=this.treeAdapter.getFirstChild(e);n;n=this.treeAdapter.getFirstChild(e))this.treeAdapter.detachNode(n),this.treeAdapter.appendChild(t,n)}_setEndLocation(e,t){if(this.treeAdapter.getNodeSourceCodeLocation(e)&&t.location){const n=t.location,r=this.treeAdapter.getTagName(e),i=t.type===Mi.END_TAG&&r===t.tagName?{endTag:{...n},endLine:n.endLine,endCol:n.endCol,endOffset:n.endOffset}:{endLine:n.startLine,endCol:n.startCol,endOffset:n.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(e,i)}}shouldProcessStartTagTokenInForeignContent(e){if(!this.currentNotInHTML)return!1;let t,n;return this.openElements.stackTop===0&&this.fragmentContext?(t=this.fragmentContext,n=this.fragmentContextID):{current:t,currentTagId:n}=this.openElements,e.tagID===j.SVG&&this.treeAdapter.getTagName(t)===pt.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(t)===Bt.MATHML?!1:this.tokenizer.inForeignNode||(e.tagID===j.MGLYPH||e.tagID===j.MALIGNMARK)&&n!==void 0&&!this._isIntegrationPoint(n,t,Bt.HTML)}_processToken(e){switch(e.type){case Mi.CHARACTER:this.onCharacter(e);break;case Mi.NULL_CHARACTER:this.onNullCharacter(e);break;case Mi.COMMENT:this.onComment(e);break;case Mi.DOCTYPE:this.onDoctype(e);break;case Mi.START_TAG:this._processStartTag(e);break;case Mi.END_TAG:this.onEndTag(e);break;case Mi.EOF:this.onEof(e);break;case Mi.WHITESPACE_CHARACTER:this.onWhitespaceCharacter(e);break}}_isIntegrationPoint(e,t,n){const r=this.treeAdapter.getNamespaceURI(t),i=this.treeAdapter.getAttrList(t);return Iwn(e,r,i,n)}_reconstructActiveFormattingElements(){const e=this.activeFormattingElements.entries.length;if(e){const t=this.activeFormattingElements.entries.findIndex(r=>r.type===Sh.Marker||this.openElements.contains(r.element)),n=t===-1?e-1:t-1;for(let r=n;r>=0;r--){const i=this.activeFormattingElements.entries[r];this._insertElement(i.token,this.treeAdapter.getNamespaceURI(i.element)),i.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=Ze.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(j.P),this.openElements.popUntilTagNamePopped(j.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(e===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case j.TR:this.insertionMode=Ze.IN_ROW;return;case j.TBODY:case j.THEAD:case j.TFOOT:this.insertionMode=Ze.IN_TABLE_BODY;return;case j.CAPTION:this.insertionMode=Ze.IN_CAPTION;return;case j.COLGROUP:this.insertionMode=Ze.IN_COLUMN_GROUP;return;case j.TABLE:this.insertionMode=Ze.IN_TABLE;return;case j.BODY:this.insertionMode=Ze.IN_BODY;return;case j.FRAMESET:this.insertionMode=Ze.IN_FRAMESET;return;case j.SELECT:this._resetInsertionModeForSelect(e);return;case j.TEMPLATE:this.insertionMode=this.tmplInsertionModeStack[0];return;case j.HTML:this.insertionMode=this.headElement?Ze.AFTER_HEAD:Ze.BEFORE_HEAD;return;case j.TD:case j.TH:if(e>0){this.insertionMode=Ze.IN_CELL;return}break;case j.HEAD:if(e>0){this.insertionMode=Ze.IN_HEAD;return}break}this.insertionMode=Ze.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){const n=this.openElements.tagIDs[t];if(n===j.TEMPLATE)break;if(n===j.TABLE){this.insertionMode=Ze.IN_SELECT_IN_TABLE;return}}this.insertionMode=Ze.IN_SELECT}_isElementCausesFosterParenting(e){return KK.has(e)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let e=this.openElements.stackTop;e>=0;e--){const t=this.openElements.items[e];switch(this.openElements.tagIDs[e]){case j.TEMPLATE:if(this.treeAdapter.getNamespaceURI(t)===Bt.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break;case j.TABLE:{const n=this.treeAdapter.getParentNode(t);return n?{parent:n,beforeElement:t}:{parent:this.openElements.items[e-1],beforeElement:null}}default:}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(e){const t=this._findFosterParentingLocation();t.beforeElement?this.treeAdapter.insertBefore(t.parent,e,t.beforeElement):this.treeAdapter.appendChild(t.parent,e)}_isSpecialElement(e,t){return _De[this.treeAdapter.getNamespaceURI(e)].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){txn(this,e);return}switch(this.insertionMode){case Ze.INITIAL:aC(this,e);break;case Ze.BEFORE_HTML:lC(this,e);break;case Ze.BEFORE_HEAD:cC(this,e);break;case Ze.IN_HEAD:uC(this,e);break;case Ze.IN_HEAD_NO_SCRIPT:dC(this,e);break;case Ze.AFTER_HEAD:fC(this,e);break;case Ze.IN_BODY:case Ze.IN_CAPTION:case Ze.IN_CELL:case Ze.IN_TEMPLATE:o3e(this,e);break;case Ze.TEXT:case Ze.IN_SELECT:case Ze.IN_SELECT_IN_TABLE:this._insertCharacters(e);break;case Ze.IN_TABLE:case Ze.IN_TABLE_BODY:case Ze.IN_ROW:jK(this,e);break;case Ze.IN_TABLE_TEXT:h3e(this,e);break;case Ze.IN_COLUMN_GROUP:d5(this,e);break;case Ze.AFTER_BODY:p5(this,e);break;case Ze.AFTER_AFTER_BODY:m5(this,e);break;default:}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){exn(this,e);return}switch(this.insertionMode){case Ze.INITIAL:aC(this,e);break;case Ze.BEFORE_HTML:lC(this,e);break;case Ze.BEFORE_HEAD:cC(this,e);break;case Ze.IN_HEAD:uC(this,e);break;case Ze.IN_HEAD_NO_SCRIPT:dC(this,e);break;case Ze.AFTER_HEAD:fC(this,e);break;case Ze.TEXT:this._insertCharacters(e);break;case Ze.IN_TABLE:case Ze.IN_TABLE_BODY:case Ze.IN_ROW:jK(this,e);break;case Ze.IN_COLUMN_GROUP:d5(this,e);break;case Ze.AFTER_BODY:p5(this,e);break;case Ze.AFTER_AFTER_BODY:m5(this,e);break;default:}}onComment(e){if(this.skipNextNewLine=!1,this.currentNotInHTML){WK(this,e);return}switch(this.insertionMode){case Ze.INITIAL:case Ze.BEFORE_HTML:case Ze.BEFORE_HEAD:case Ze.IN_HEAD:case Ze.IN_HEAD_NO_SCRIPT:case Ze.AFTER_HEAD:case Ze.IN_BODY:case Ze.IN_TABLE:case Ze.IN_CAPTION:case Ze.IN_COLUMN_GROUP:case Ze.IN_TABLE_BODY:case Ze.IN_ROW:case Ze.IN_CELL:case Ze.IN_SELECT:case Ze.IN_SELECT_IN_TABLE:case Ze.IN_TEMPLATE:case Ze.IN_FRAMESET:case Ze.AFTER_FRAMESET:WK(this,e);break;case Ze.IN_TABLE_TEXT:mC(this,e);break;case Ze.AFTER_BODY:Lwn(this,e);break;case Ze.AFTER_AFTER_BODY:case Ze.AFTER_AFTER_FRAMESET:Nwn(this,e);break;default:}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case Ze.INITIAL:Mwn(this,e);break;case Ze.BEFORE_HEAD:case Ze.IN_HEAD:case Ze.IN_HEAD_NO_SCRIPT:case Ze.AFTER_HEAD:this._err(e,wt.misplacedDoctype);break;case Ze.IN_TABLE_TEXT:mC(this,e);break;default:}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,wt.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?nxn(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case Ze.INITIAL:aC(this,e);break;case Ze.BEFORE_HTML:Dwn(this,e);break;case Ze.BEFORE_HEAD:Fwn(this,e);break;case Ze.IN_HEAD:uf(this,e);break;case Ze.IN_HEAD_NO_SCRIPT:zwn(this,e);break;case Ze.AFTER_HEAD:Vwn(this,e);break;case Ze.IN_BODY:Rl(this,e);break;case Ze.IN_TABLE:Fx(this,e);break;case Ze.IN_TABLE_TEXT:mC(this,e);break;case Ze.IN_CAPTION:BAn(this,e);break;case Ze.IN_COLUMN_GROUP:qK(this,e);break;case Ze.IN_TABLE_BODY:f5(this,e);break;case Ze.IN_ROW:h5(this,e);break;case Ze.IN_CELL:UAn(this,e);break;case Ze.IN_SELECT:m3e(this,e);break;case Ze.IN_SELECT_IN_TABLE:WAn(this,e);break;case Ze.IN_TEMPLATE:jAn(this,e);break;case Ze.AFTER_BODY:YAn(this,e);break;case Ze.IN_FRAMESET:KAn(this,e);break;case Ze.AFTER_FRAMESET:JAn(this,e);break;case Ze.AFTER_AFTER_BODY:QAn(this,e);break;case Ze.AFTER_AFTER_FRAMESET:$An(this,e);break;default:}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?rxn(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case Ze.INITIAL:aC(this,e);break;case Ze.BEFORE_HTML:Own(this,e);break;case Ze.BEFORE_HEAD:Bwn(this,e);break;case Ze.IN_HEAD:Hwn(this,e);break;case Ze.IN_HEAD_NO_SCRIPT:Uwn(this,e);break;case Ze.AFTER_HEAD:Wwn(this,e);break;case Ze.IN_BODY:u5(this,e);break;case Ze.TEXT:CAn(this,e);break;case Ze.IN_TABLE:hC(this,e);break;case Ze.IN_TABLE_TEXT:mC(this,e);break;case Ze.IN_CAPTION:HAn(this,e);break;case Ze.IN_COLUMN_GROUP:zAn(this,e);break;case Ze.IN_TABLE_BODY:YK(this,e);break;case Ze.IN_ROW:p3e(this,e);break;case Ze.IN_CELL:VAn(this,e);break;case Ze.IN_SELECT:g3e(this,e);break;case Ze.IN_SELECT_IN_TABLE:GAn(this,e);break;case Ze.IN_TEMPLATE:qAn(this,e);break;case Ze.AFTER_BODY:b3e(this,e);break;case Ze.IN_FRAMESET:XAn(this,e);break;case Ze.AFTER_FRAMESET:ZAn(this,e);break;case Ze.AFTER_AFTER_BODY:m5(this,e);break;default:}}onEof(e){switch(this.insertionMode){case Ze.INITIAL:aC(this,e);break;case Ze.BEFORE_HTML:lC(this,e);break;case Ze.BEFORE_HEAD:cC(this,e);break;case Ze.IN_HEAD:uC(this,e);break;case Ze.IN_HEAD_NO_SCRIPT:dC(this,e);break;case Ze.AFTER_HEAD:fC(this,e);break;case Ze.IN_BODY:case Ze.IN_TABLE:case Ze.IN_CAPTION:case Ze.IN_COLUMN_GROUP:case Ze.IN_TABLE_BODY:case Ze.IN_ROW:case Ze.IN_CELL:case Ze.IN_SELECT:case Ze.IN_SELECT_IN_TABLE:d3e(this,e);break;case Ze.TEXT:_An(this,e);break;case Ze.IN_TABLE_TEXT:mC(this,e);break;case Ze.IN_TEMPLATE:y3e(this,e);break;case Ze.AFTER_BODY:case Ze.IN_FRAMESET:case Ze.AFTER_FRAMESET:case Ze.AFTER_AFTER_BODY:case Ze.AFTER_AFTER_FRAMESET:GK(this,e);break;default:}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===Ne.LINE_FEED)){if(e.chars.length===1)return;e.chars=e.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(e);return}switch(this.insertionMode){case Ze.IN_HEAD:case Ze.IN_HEAD_NO_SCRIPT:case Ze.AFTER_HEAD:case Ze.TEXT:case Ze.IN_COLUMN_GROUP:case Ze.IN_SELECT:case Ze.IN_SELECT_IN_TABLE:case Ze.IN_FRAMESET:case Ze.AFTER_FRAMESET:this._insertCharacters(e);break;case Ze.IN_BODY:case Ze.IN_CAPTION:case Ze.IN_CELL:case Ze.IN_TEMPLATE:case Ze.AFTER_BODY:case Ze.AFTER_AFTER_BODY:case Ze.AFTER_AFTER_FRAMESET:i3e(this,e);break;case Ze.IN_TABLE:case Ze.IN_TABLE_BODY:case Ze.IN_ROW:jK(this,e);break;case Ze.IN_TABLE_TEXT:f3e(this,e);break;default:}}},ZK=new Set([j.CAPTION,j.COL,j.COLGROUP,j.TBODY,j.TD,j.TFOOT,j.TH,j.THEAD,j.TR])})),oxn,sxn=Le((()=>{$g(),OK(),oxn=new Set([pt.AREA,pt.BASE,pt.BASEFONT,pt.BGSOUND,pt.BR,pt.COL,pt.EMBED,pt.FRAME,pt.HR,pt.IMG,pt.INPUT,pt.KEYGEN,pt.LINK,pt.META,pt.PARAM,pt.SOURCE,pt.TRACK,pt.WBR])}));function axn(e,t){return JK.parse(e,t)}function lxn(e,t,n){typeof e=="string"&&(n=t,t=e,e=null);const r=JK.getFragmentParser(e,n);return r.tokenizer.write(t,!0),r.getFragment()}var cxn=Le((()=>{ixn(),OK(),sxn(),i5(),r3e(),$g(),CK(),MDe()})),T3e,uxn=Le((()=>{T3e={abandonedHeadElementChild:{reason:"Unexpected metadata element after head",description:"Unexpected element after head. Expected the element before `</head>`",url:!1},abruptClosingOfEmptyComment:{reason:"Unexpected abruptly closed empty comment",description:"Unexpected `>` or `->`. Expected `-->` to close comments"},abruptDoctypePublicIdentifier:{reason:"Unexpected abruptly closed public identifier",description:"Unexpected `>`. Expected a closing `\"` or `'` after the public identifier"},abruptDoctypeSystemIdentifier:{reason:"Unexpected abruptly closed system identifier",description:"Unexpected `>`. Expected a closing `\"` or `'` after the identifier identifier"},absenceOfDigitsInNumericCharacterReference:{reason:"Unexpected non-digit at start of numeric character reference",description:"Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references"},cdataInHtmlContent:{reason:"Unexpected CDATA section in HTML",description:"Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead"},characterReferenceOutsideUnicodeRange:{reason:"Unexpected too big numeric character reference",description:"Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)"},closingOfElementWithOpenChildElements:{reason:"Unexpected closing tag with open child elements",description:"Unexpectedly closing tag. Expected other tags to be closed first",url:!1},controlCharacterInInputStream:{reason:"Unexpected control character",description:"Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace"},controlCharacterReference:{reason:"Unexpected control character reference",description:"Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace"},disallowedContentInNoscriptInHead:{reason:"Disallowed content inside `<noscript>` in `<head>`",description:"Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`",url:!1},duplicateAttribute:{reason:"Unexpected duplicate attribute",description:"Unexpectedly double attribute. Expected attributes to occur only once"},endTagWithAttributes:{reason:"Unexpected attribute on closing tag",description:"Unexpected attribute. Expected `>` instead"},endTagWithTrailingSolidus:{reason:"Unexpected slash at end of closing tag",description:"Unexpected `%c-1`. Expected `>` instead"},endTagWithoutMatchingOpenElement:{reason:"Unexpected unopened end tag",description:"Unexpected end tag. Expected no end tag or another end tag",url:!1},eofBeforeTagName:{reason:"Unexpected end of file",description:"Unexpected end of file. Expected tag name instead"},eofInCdata:{reason:"Unexpected end of file in CDATA",description:"Unexpected end of file. Expected `]]>` to close the CDATA"},eofInComment:{reason:"Unexpected end of file in comment",description:"Unexpected end of file. Expected `-->` to close the comment"},eofInDoctype:{reason:"Unexpected end of file in doctype",description:"Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)"},eofInElementThatCanContainOnlyText:{reason:"Unexpected end of file in element that can only contain text",description:"Unexpected end of file. Expected text or a closing tag",url:!1},eofInScriptHtmlCommentLikeText:{reason:"Unexpected end of file in comment inside script",description:"Unexpected end of file. Expected `-->` to close the comment"},eofInTag:{reason:"Unexpected end of file in tag",description:"Unexpected end of file. Expected `>` to close the tag"},incorrectlyClosedComment:{reason:"Incorrectly closed comment",description:"Unexpected `%c-1`. Expected `-->` to close the comment"},incorrectlyOpenedComment:{reason:"Incorrectly opened comment",description:"Unexpected `%c`. Expected `<!--` to open the comment"},invalidCharacterSequenceAfterDoctypeName:{reason:"Invalid sequence after doctype name",description:"Unexpected sequence at `%c`. Expected `public` or `system`"},invalidFirstCharacterOfTagName:{reason:"Invalid first character in tag name",description:"Unexpected `%c`. Expected an ASCII letter instead"},misplacedDoctype:{reason:"Misplaced doctype",description:"Unexpected doctype. Expected doctype before head",url:!1},misplacedStartTagForHeadElement:{reason:"Misplaced `<head>` start tag",description:"Unexpected start tag `<head>`. Expected `<head>` directly after doctype",url:!1},missingAttributeValue:{reason:"Missing attribute value",description:"Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead"},missingDoctype:{reason:"Missing doctype before other content",description:"Expected a `<!doctype html>` before anything else",url:!1},missingDoctypeName:{reason:"Missing doctype name",description:"Unexpected doctype end at `%c`. Expected `html` instead"},missingDoctypePublicIdentifier:{reason:"Missing public identifier in doctype",description:"Unexpected `%c`. Expected identifier for `public` instead"},missingDoctypeSystemIdentifier:{reason:"Missing system identifier in doctype",description:'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'},missingEndTagName:{reason:"Missing name in end tag",description:"Unexpected `%c`. Expected an ASCII letter instead"},missingQuoteBeforeDoctypePublicIdentifier:{reason:"Missing quote before public identifier in doctype",description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingQuoteBeforeDoctypeSystemIdentifier:{reason:"Missing quote before system identifier in doctype",description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingSemicolonAfterCharacterReference:{reason:"Missing semicolon after character reference",description:"Unexpected `%c`. Expected `;` instead"},missingWhitespaceAfterDoctypePublicKeyword:{reason:"Missing whitespace after public identifier in doctype",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceAfterDoctypeSystemKeyword:{reason:"Missing whitespace after system identifier in doctype",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBeforeDoctypeName:{reason:"Missing whitespace before doctype name",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenAttributes:{reason:"Missing whitespace between attributes",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:{reason:"Missing whitespace between public and system identifiers in doctype",description:"Unexpected `%c`. Expected ASCII whitespace instead"},nestedComment:{reason:"Unexpected nested comment",description:"Unexpected `<!--`. Expected `-->`"},nestedNoscriptInHead:{reason:"Unexpected nested `<noscript>` in `<head>`",description:"Unexpected `<noscript>`. Expected a closing tag or a meta element",url:!1},nonConformingDoctype:{reason:"Unexpected non-conforming doctype declaration",description:'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',url:!1},nonVoidHtmlElementStartTagWithTrailingSolidus:{reason:"Unexpected trailing slash on start tag of non-void element",description:"Unexpected `/`. Expected `>` instead"},noncharacterCharacterReference:{reason:"Unexpected noncharacter code point referenced by character reference",description:"Unexpected code point. Do not use noncharacters in HTML"},noncharacterInInputStream:{reason:"Unexpected noncharacter character",description:"Unexpected code point `%x`. Do not use noncharacters in HTML"},nullCharacterReference:{reason:"Unexpected NULL character referenced by character reference",description:"Unexpected code point. Do not use NULL characters in HTML"},openElementsLeftAfterEof:{reason:"Unexpected end of file",description:"Unexpected end of file. Expected closing tag instead",url:!1},surrogateCharacterReference:{reason:"Unexpected surrogate character referenced by character reference",description:"Unexpected code point. Do not use lone surrogate characters in HTML"},surrogateInInputStream:{reason:"Unexpected surrogate character",description:"Unexpected code point `%x`. Do not use lone surrogate characters in HTML"},unexpectedCharacterAfterDoctypeSystemIdentifier:{reason:"Invalid character after system identifier in doctype",description:"Unexpected character at `%c`. Expected `>`"},unexpectedCharacterInAttributeName:{reason:"Unexpected character in attribute name",description:"Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter"},unexpectedCharacterInUnquotedAttributeValue:{reason:"Unexpected character in unquoted attribute value",description:"Unexpected `%c`. Quote the attribute value to include it"},unexpectedEqualsSignBeforeAttributeName:{reason:"Unexpected equals sign before attribute name",description:"Unexpected `%c`. Add an attribute name before it"},unexpectedNullCharacter:{reason:"Unexpected NULL character",description:"Unexpected code point `%x`. Do not use NULL characters in HTML"},unexpectedQuestionMarkInsteadOfTagName:{reason:"Unexpected question mark instead of tag name",description:"Unexpected `%c`. Expected an ASCII letter instead"},unexpectedSolidusInTag:{reason:"Unexpected slash in tag",description:"Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value"},unknownNamedCharacterReference:{reason:"Unexpected unknown named character reference",description:"Unexpected character reference. Expected known named character references"}}}));function dxn(e,t){const n=t||P3e,r=n.onerror,i=e instanceof AL?e:new AL(e),o=n.fragment?lxn:axn,s=String(i);return Kvn(o(s,{sourceCodeLocationInfo:!0,onParseError:n.onerror?a:null,scriptingEnabled:!1}),{file:i,space:n.space,verbose:n.verbose});function a(l){const c=l.code,u=fxn(c),d=n[u],f=d??!0,h=typeof f=="number"?f:f?1:0;if(h){const m=T3e[u],g=new El(p(m.reason),{place:{start:{line:l.startLine,column:l.startCol,offset:l.startOffset},end:{line:l.endLine,column:l.endCol,offset:l.endOffset}},ruleId:c,source:"hast-util-from-html"});i.path&&(g.file=i.path,g.name=i.path+":"+g.name),g.fatal=_3e[h],g.note=p(m.description),g.url=m.url===!1?void 0:I3e+c,r(g)}function p(m){return m.replace(E3e,g).replace(C3e,y);function g(v,b,w){const x=(w?Number.parseInt(w,10):0)*(b==="-"?-1:1);return pxn(s.charAt(l.startOffset+x))}function y(){return mxn(s.charCodeAt(l.startOffset))}}}}function fxn(e){return e.replace(k3e,hxn)}function hxn(e){return e.charAt(1).toUpperCase()}function pxn(e){return e==="`"?"` ` `":e}function mxn(e){return"0x"+e.toString(16).toUpperCase()}var I3e,k3e,E3e,C3e,_3e,P3e,gxn=Le((()=>{Vy(),Qvn(),cxn(),Qge(),Xge(),uxn(),I3e="https://html.spec.whatwg.org/multipage/parsing.html#parse-error-",k3e=/-[a-z]/g,E3e=/%c(?:([-+])(\d+))?/g,C3e=/%x/g,_3e={2:!0,1:!1,0:null},P3e={}})),yxn=Le((()=>{gxn()}));function bxn(e){const t=this,{emitParseErrors:n,...r}={...t.data("settings"),...e};t.parser=i;function i(o,s){return dxn(o,{...r,onerror:n?function(a){s.path&&(a.name=s.path+":"+a.name,a.file=s.path),s.messages.push(a)}:void 0})}}var vxn=Le((()=>{yxn()})),wxn=vs({default:()=>bxn},1),Axn=Le((()=>{vxn()})),xxn,Sxn,Txn,Ixn,kxn,Exn,Cxn,_xn,Pxn,Rxn,R3e=Le((()=>{xxn=-1,Sxn=0,Txn=1,Ixn=2,kxn=3,Exn=4,Cxn=5,_xn=6,Pxn=7,Rxn=8})),QK,L3e,$K,Lxn=Le((()=>{R3e(),QK=typeof self=="object"?self:globalThis,L3e=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,s]=t[i];switch(o){case 0:case-1:return n(s,i);case 1:{const a=n([],i);for(const l of s)a.push(r(l));return a}case 2:{const a=n({},i);for(const[l,c]of s)a[r(l)]=r(c);return a}case 3:return n(new Date(s),i);case 4:{const{source:a,flags:l}=s;return n(new RegExp(a,l),i)}case 5:{const a=n(new Map,i);for(const[l,c]of s)a.set(r(l),r(c));return a}case 6:{const a=n(new Set,i);for(const l of s)a.add(r(l));return a}case 7:{const{name:a,message:l}=s;return n(new QK[a](l),i)}case 8:return n(BigInt(s),i);case"BigInt":return n(Object(BigInt(s)),i);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:a}=new Uint8Array(s);return n(new DataView(a),s)}}return n(new QK[o](s),i)};return r},$K=e=>L3e(new Map,e)(0)})),Mb,N3e,M3e,Bx,gC,D3e,eX,Nxn=Le((()=>{R3e(),Mb="",{toString:N3e}={},{keys:M3e}=Object,Bx=e=>{const t=typeof e;if(t!=="object"||!e)return[0,t];const n=N3e.call(e).slice(8,-1);switch(n){case"Array":return[1,Mb];case"Object":return[2,Mb];case"Date":return[3,Mb];case"RegExp":return[4,Mb];case"Map":return[5,Mb];case"Set":return[6,Mb];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},gC=([e,t])=>e===0&&(t==="function"||t==="symbol"),D3e=(e,t,n,r)=>{const i=(s,a)=>{const l=r.push(s)-1;return n.set(a,l),l},o=s=>{if(n.has(s))return n.get(s);let[a,l]=Bx(s);switch(a){case 0:{let u=s;switch(l){case"bigint":a=8,u=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);u=null;break;case"undefined":return i([-1],s)}return i([a,u],s)}case 1:{if(l){let f=s;return l==="DataView"?f=new Uint8Array(s.buffer):l==="ArrayBuffer"&&(f=new Uint8Array(s)),i([l,[...f]],s)}const u=[],d=i([a,u],s);for(const f of s)u.push(o(f));return d}case 2:{if(l)switch(l){case"BigInt":return i([l,s.toString()],s);case"Boolean":case"Number":case"String":return i([l,s.valueOf()],s)}if(t&&"toJSON"in s)return o(s.toJSON());const u=[],d=i([a,u],s);for(const f of M3e(s))(e||!gC(Bx(s[f])))&&u.push([o(f),o(s[f])]);return d}case 3:return i([a,s.toISOString()],s);case 4:{const{source:u,flags:d}=s;return i([a,{source:u,flags:d}],s)}case 5:{const u=[],d=i([a,u],s);for(const[f,h]of s)(e||!(gC(Bx(f))||gC(Bx(h))))&&u.push([o(f),o(h)]);return d}case 6:{const u=[],d=i([a,u],s);for(const f of s)(e||!gC(Bx(f)))&&u.push(o(f));return d}}const{message:c}=s;return i([a,{name:l,message:c}],s)};return o},eX=(e,{json:t,lossy:n}={})=>{const r=[];return D3e(!(t||n),!!t,new Map,r)(e),r}})),tX,O3e=Le((()=>{Lxn(),Nxn(),tX=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?$K(eX(e,t)):structuredClone(e):(e,t)=>$K(eX(e,t))}));function Mxn(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=ud(e[n]);return nX(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function Dxn(e){return nX(t);function t(n){return n.tagName===e}}function nX(e){return t;function t(n,r,i){return!!(F3e(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Oxn(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function F3e(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}var g5,ud,Fxn=Le((()=>{g5=(function(e,t,n,r,i){const o=ud(t);if(n!=null&&(typeof n!="number"||n<0||n===Number.POSITIVE_INFINITY))throw new Error("Expected positive finite `index`");if(r!=null&&(!r.type||!r.children))throw new Error("Expected valid `parent`");if(n==null!=(r==null))throw new Error("Expected both `index` and `parent`");return F3e(e)?o.call(i,e,n,r):!1}),ud=(function(e){if(e==null)return Oxn;if(typeof e=="string")return Dxn(e);if(typeof e=="object")return Mxn(e);if(typeof e=="function")return nX(e);throw new Error("Expected function, string, or array as `test`")})})),y5=Le((()=>{Fxn()})),rX,Bxn=Le((()=>{y5(),rX=ud(function(e){return e.tagName==="audio"||e.tagName==="canvas"||e.tagName==="embed"||e.tagName==="iframe"||e.tagName==="img"||e.tagName==="math"||e.tagName==="object"||e.tagName==="picture"||e.tagName==="svg"||e.tagName==="video"})})),B3e=Le((()=>{Bxn()}));function H3e(e){return typeof e=="object"?e.type==="text"?z3e(e.value):!1:z3e(e)}function z3e(e){return e.replace(U3e,"")===""}var U3e,Hxn=Le((()=>{U3e=/[ \t\n\f\r]/g})),V3e=Le((()=>{Hxn()})),W3e,zxn=Le((()=>{W3e=["address","article","aside","blockquote","body","br","caption","center","col","colgroup","dd","dialog","dir","div","dl","dt","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","legend","li","li","listing","main","menu","nav","ol","optgroup","option","p","plaintext","pre","section","summary","table","tbody","td","td","tfoot","th","th","thead","tr","ul","wbr","xmp"]})),G3e,Uxn=Le((()=>{G3e=["button","input","select","textarea"]})),j3e,Vxn=Le((()=>{j3e=["area","base","basefont","dialog","datalist","head","link","meta","noembed","noframes","param","rp","script","source","style","template","track","title"]}));function Wxn(e,t){q3e(e,{collapse:Jxn((t||Z3e).newlines?Kxn:Xxn),whitespace:"normal"})}function q3e(e,t){if("children"in e){const n={...t};return(e.type==="root"||X3e(e))&&(n.before=!0,n.after=!0),n.whitespace=Zxn(e,t),jxn(e,n)}if(e.type==="text"){if(t.whitespace==="normal")return Gxn(e,t);t.whitespace==="nowrap"&&(e.value=t.collapse(e.value))}return{ignore:b5(e),stripAtStart:!1,remove:!1}}function Gxn(e,t){const n=t.collapse(e.value),r={ignore:!1,stripAtStart:!1,remove:!1};let i=0,o=n.length;return t.before&&J3e(n.charAt(0))&&i++,i!==o&&J3e(n.charAt(o-1))&&(t.after?o--:r.stripAtStart=!0),i===o?r.remove=!0:e.value=n.slice(i,o),r}function jxn(e,t){let n=t.before;const r=t.after,i=e.children;let o=i.length,s=-1;for(;++s<o;){const a=q3e(i[s],{...t,after:Y3e(i,s,r),before:n});a.remove?(i.splice(s,1),s--,o--):a.ignore||(n=a.stripAtStart),K3e(i[s])&&(n=!1)}return{ignore:!1,stripAtStart:!!(n||r),remove:!1}}function Y3e(e,t,n){for(;++t<e.length;){const r=e[t];let i=qxn(r);if(i===void 0&&"children"in r&&!Yxn(r)&&(i=Y3e(r.children,-1)),typeof i=="boolean")return i}return n}function qxn(e){if(e.type==="element"){if(K3e(e))return!1;if(X3e(e))return!0}else if(e.type==="text"){if(!H3e(e))return!1}else if(!b5(e))return!1}function K3e(e){return rX(e)||g5(e,G3e)}function X3e(e){return g5(e,W3e)}function Yxn(e){return!!(e.type==="element"&&e.properties.hidden)||b5(e)||g5(e,j3e)}function J3e(e){return e===" "||e===`
|
|
420
420
|
`}function Kxn(e){const t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function Xxn(){return" "}function Jxn(e){return t;function t(n){return String(n).replace(/[\t\n\v\f\r ]+/g,e)}}function Zxn(e,t){if("tagName"in e&&e.properties)switch(e.tagName){case"listing":case"plaintext":case"script":case"style":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return e.properties.wrap?"pre-wrap":"pre";case"td":case"th":return e.properties.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap";default:}return t.whitespace}var Z3e,b5,Qxn=Le((()=>{B3e(),y5(),V3e(),mk(),zxn(),Uxn(),Vxn(),Z3e={},b5=Wy(["comment","doctype"])})),$xn=Le((()=>{Qxn()}));function eSn(e){return function(t){Wxn(t,e)}}var tSn=Le((()=>{$xn()})),nSn=Le((()=>{tSn()}));function Q3e(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function rSn(e){const t=e5e(e),n=$3e(e);if(t&&n)return{start:t,end:n}}var $3e,e5e,iSn=Le((()=>{$3e=Q3e("end"),e5e=Q3e("start")})),oSn=Le((()=>{iSn()}));function sSn(e,t){const n=t.properties||{},r=e.all(t),i={type:"link",url:e.resolve(String(n.href||"")||null),title:n.title?String(n.title):null,children:r};return e.patch(t,i),i}var aSn=Le((()=>{}));function lSn(e,t){e.baseFound||(e.frozenBaseUrl=String(t.properties&&t.properties.href||"")||void 0,e.baseFound=!0)}var cSn=Le((()=>{}));function uSn(e,t){const n={type:"blockquote",children:e.toFlow(e.all(t))};return e.patch(t,n),n}var dSn=Le((()=>{}));function fSn(e,t){const n={type:"break"};return e.patch(t,n),n}var hSn=Le((()=>{})),iX,pSn=Le((()=>{mk(),iX=(function(e,t,n){const r=Wy(n);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]})})),mSn=Le((()=>{pSn()}));function yC(e,t){const n=t||{},r="children"in e?e.children:[],i=cX(e),o=r5e(e,{whitespace:n.whitespace||"normal",breakBefore:!1,breakAfter:!1}),s=[];(e.type==="text"||e.type==="comment")&&s.push(...n5e(e,{whitespace:o,breakBefore:!0,breakAfter:!0}));let a=-1;for(;++a<r.length;)s.push(...t5e(r[a],e,{whitespace:o,breakBefore:a?void 0:i,breakAfter:a<r.length-1?v5(r[a+1]):i}));const l=[];let c;for(a=-1;++a<s.length;){const u=s[a];typeof u=="number"?c!==void 0&&u>c&&(c=u):u&&(c!==void 0&&c>-1&&l.push(`
|
|
421
421
|
`.repeat(c)||" "),c=-1,l.push(u))}return l.join("")}function t5e(e,t,n){return e.type==="element"?gSn(e,t,n):e.type==="text"?n.whitespace==="normal"?n5e(e,n):ySn(e):[]}function gSn(e,t,n){const r=r5e(e,n),i=e.children||[];let o=-1,s=[];if(o5e(e))return s;let a,l;for(v5(e)||lX(e)&&iX(t,e,lX)?l=`
|
|
422
|
-
`:i5e(e)?(a=2,l=2):cX(e)&&(a=1,l=1);++o<i.length;)s=s.concat(t5e(i[o],e,{whitespace:r,breakBefore:o?void 0:a,breakAfter:o<i.length-1?v5(i[o+1]):l}));return aX(e)&&iX(t,e,aX)&&s.push(" "),a&&s.unshift(a),l&&s.push(l),s}function n5e(e,t){const n=String(e.value),r=[],i=[];let o=0;for(;o<=n.length;){oX.lastIndex=o;const l=oX.exec(n),c=l&&"index"in l?l.index:n.length;r.push(bSn(n.slice(o,c).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),o===0?t.breakBefore:!0,c===n.length?t.breakAfter:!0)),o=c+1}let s=-1,a;for(;++s<r.length;)r[s].charCodeAt(r[s].length-1)===8203||s<r.length-1&&r[s+1].charCodeAt(0)===8203?(i.push(r[s]),a=void 0):r[s]?(typeof a=="number"&&i.push(a),i.push(r[s]),a=0):(s===0||s===r.length-1)&&i.push(0);return i}function ySn(e){return[String(e.value)]}function bSn(e,t,n){const r=[];let i=0,o;for(;i<e.length;){sX.lastIndex=i;const s=sX.exec(e);o=s?s.index:e.length,!i&&!o&&s&&!t&&r.push(""),i!==o&&r.push(e.slice(i,o)),i=s?o+s[0].length:o}return i!==o&&!n&&r.push(""),r.join(" ")}function r5e(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap";default:}}return t.whitespace}function vSn(e){return!!(e.properties||{}).hidden}function wSn(e){return e.tagName==="td"||e.tagName==="th"}function ASn(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var oX,sX,v5,aX,i5e,lX,o5e,cX,xSn=Le((()=>{mSn(),y5(),oX=/\n/g,sX=/[\t ]+/g,v5=ud("br"),aX=ud(wSn),i5e=ud("p"),lX=ud("tr"),o5e=ud(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",vSn,ASn]),cX=ud(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"])})),bC=Le((()=>{xSn()}));function SSn(e){const t=String(e);let n=t.length;for(;n>0;){const r=t.codePointAt(n-1);if(r!==void 0&&(r===10||r===13))n--;else break}return t.slice(0,n)}var TSn=Le((()=>{}));function w5(e,t){const n=t.children;let r=-1,i,o;if(t.tagName==="pre")for(;++r<n.length;){const a=n[r];if(a.type==="element"&&a.tagName==="code"&&a.properties&&a.properties.className&&Array.isArray(a.properties.className)){i=a.properties.className;break}}if(i){for(r=-1;++r<i.length;)if(String(i[r]).slice(0,9)===s5e){o=String(i[r]).slice(9);break}}const s={type:"code",lang:o||null,meta:null,value:SSn(yC(t))};return e.patch(t,s),s}var s5e,ISn=Le((()=>{bC(),TSn(),s5e="language-"}));function kSn(e,t){const n={type:"html",value:"<!--"+t.value+"-->"};return e.patch(t,n),n}var ESn=Le((()=>{}));function uX(e,t){const n={type:"delete",children:e.all(t)};return e.patch(t,n),n}var CSn=Le((()=>{}));function dX(e){let t=-1;if(e.length>1){for(;++t<e.length;)if(e[t].spread)return!0}return!1}var a5e=Le((()=>{}));function _Sn(e,t){const n=[],r=[];let i=-1;for(;++i<t.children.length;){const a=t.children[i];a.type==="element"&&a.tagName==="div"?n.push(...a.children):n.push(a)}let o={definitions:[],titles:[]};for(i=-1;++i<n.length;){const a=n[i];if(a.type==="element"&&a.tagName==="dt"){const l=n[i-1];l&&l.type==="element"&&l.tagName==="dd"&&(r.push(o),o={definitions:[],titles:[]}),o.titles.push(a)}else o.definitions.push(a)}r.push(o),i=-1;const s=[];for(;++i<r.length;){const a=[...l5e(e,r[i].titles),...l5e(e,r[i].definitions)];a.length>0&&s.push({type:"listItem",spread:a.length>1,checked:null,children:a})}if(s.length>0){const a={type:"list",ordered:!1,start:null,spread:dX(s),children:s};return e.patch(t,a),a}}function l5e(e,t){const n=e.all({type:"root",children:t}),r=e.toSpecificContent(n,PSn);return r.length===0?[]:r.length===1?r[0].children:[{type:"list",ordered:!1,start:null,spread:dX(r),children:r}]}function PSn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var RSn=Le((()=>{a5e()}));function A5(e,t){const n={type:"emphasis",children:e.all(t)};return e.patch(t,n),n}var LSn=Le((()=>{}));function fX(e){let t=0,n=e.length;for(;t<n&&e[t].type==="break";)t++;for(;n>t&&e[n-1].type==="break";)n--;return t===0&&n===e.length?e:e.slice(t,n)}var hX=Le((()=>{}));function Hx(e,t){const n={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:fX(e.all(t))};return e.patch(t,n),n}var NSn=Le((()=>{hX()}));function MSn(e,t){const n={type:"thematicBreak"};return e.patch(t,n),n}var DSn=Le((()=>{}));function OSn(e,t){const n=t.properties||{},r=String(n.src||""),i=String(n.title||"");if(r&&i){const o={type:"link",title:null,url:e.resolve(r),children:[{type:"text",value:i}]};return e.patch(t,o),o}}var FSn=Le((()=>{}));function c5e(e,t){const n=t.properties||{},r={type:"image",url:e.resolve(String(n.src||"")||null),title:n.title?String(n.title):null,alt:n.alt?String(n.alt):""};return e.patch(t,r),r}var BSn=Le((()=>{}));function vC(e,t){const n={type:"inlineCode",value:yC(t)};return e.patch(t,n),n}var HSn=Le((()=>{bC()}));function u5e(e,t){const n=[],r=[],i=t||e.properties||{},o=d5e(e),s=Math.min(Number.parseInt(String(i.size),10),0)||(i.multiple?4:1);let a=-1;for(;++a<o.length;){const u=o[a];u&&u.properties&&u.properties.selected&&n.push(u)}const l=n.length>0?n:o,c=Math.min(l.length,s);for(a=-1;++a<c;){const u=l[a],d=u.properties||{},f=yC(u),h=f||String(d.label||""),p=String(d.value||"")||f;r.push([p,h===p?void 0:h])}return r}function d5e(e){const t=[];let n=-1;for(;++n<e.children.length;){const r=e.children[n];"children"in r&&Array.isArray(r.children)&&t.push(...d5e(r)),r.type==="element"&&r.tagName==="option"&&(!r.properties||!r.properties.disabled)&&t.push(r)}return t}var f5e=Le((()=>{bC()}));function zSn(e,t){const n=t.properties||{},r=String(n.value||n.placeholder||"");if(n.disabled||n.type==="hidden"||n.type==="file")return;if(n.type==="checkbox"||n.type==="radio"){const l={type:"text",value:n.checked?e.options.checked||h5e:e.options.unchecked||p5e};return e.patch(t,l),l}if(n.type==="image"){const l=n.alt||r;if(l){const c={type:"image",url:e.resolve(String(n.src||"")||null),title:String(n.title||"")||null,alt:String(l)};return e.patch(t,c),c}return}let i=[];if(r)i=[[r,void 0]];else if(n.type!=="button"&&n.type!=="file"&&n.type!=="password"&&n.type!=="reset"&&n.type!=="submit"&&n.list){const l=String(n.list),c=e.elementById.get(l);c&&c.tagName==="datalist"&&(i=u5e(c,n))}if(i.length===0)return;if(n.type==="password"&&(i[0]=["•".repeat(i[0][0].length),void 0]),n.type==="email"||n.type==="url"){const l=[];let c=-1;for(;++c<i.length;){const u=e.resolve(i[c][0]),d={type:"link",title:null,url:n.type==="email"?"mailto:"+u:u,children:[{type:"text",value:i[c][1]||u}]};l.push(d),c!==i.length-1&&l.push({type:"text",value:", "})}return l}const o=[];let s=-1;for(;++s<i.length;)o.push(i[s][1]?i[s][1]+" ("+i[s][0]+")":i[s][0]);const a={type:"text",value:o.join(", ")};return e.patch(t,a),a}var h5e,p5e,USn=Le((()=>{f5e(),h5e="[x]",p5e="[ ]"}));function VSn(e,t){const n=e.type==="element"&&m5e.call(e.properties,t)&&e.properties[t];return n!=null&&n!==!1}var m5e,WSn=Le((()=>{m5e={}.hasOwnProperty})),GSn=Le((()=>{WSn()}));function jSn(e){if(e.type!=="element"||e.tagName!=="link")return!1;if(e.properties.itemProp)return!0;const t=e.properties.rel;let n=-1;if(!Array.isArray(t)||t.length===0)return!1;for(;++n<t.length;)if(!g5e.has(String(t[n])))return!1;return!0}var g5e,qSn=Le((()=>{g5e=new Set(["pingback","prefetch","stylesheet"])})),YSn=Le((()=>{qSn()}));function y5e(e){return!!(e.type==="text"||b5e(e)||rX(e)||jSn(e)||v5e(e)&&VSn(e,"itemProp"))}var b5e,v5e,KSn=Le((()=>{B3e(),GSn(),YSn(),y5(),b5e=ud(["a","abbr","area","b","bdi","bdo","br","button","cite","code","data","datalist","del","dfn","em","i","input","ins","kbd","keygen","label","map","mark","meter","noscript","output","progress","q","ruby","s","samp","script","select","small","span","strong","sub","sup","template","textarea","time","u","var","wbr"]),v5e=ud("meta")})),w5e=Le((()=>{KSn()}));function pX(e,t){const{rest:n,checkbox:r}=x5e(t),i=r?!!r.properties.checked:null,o={type:"listItem",spread:A5e(n),checked:i,children:e.toFlow(e.all(n))};return e.patch(t,o),o}function A5e(e){let t=-1,n=!1;for(;++t<e.children.length;){const r=e.children[t];if(r.type==="element"){if(y5e(r))continue;if(r.tagName==="p"||n||A5e(r))return!0;n=!0}}return!1}function x5e(e){const t=e.children[0];if(t&&t.type==="element"&&t.tagName==="input"&&t.properties&&(t.properties.type==="checkbox"||t.properties.type==="radio"))return{checkbox:t,rest:{...e,children:e.children.slice(1)}};if(t&&t.type==="element"&&t.tagName==="p"){const{checkbox:n,rest:r}=x5e(t);if(n)return{checkbox:n,rest:{...e,children:[r,...e.children.slice(1)]}}}return{checkbox:void 0,rest:e}}var XSn=Le((()=>{w5e()}));function mX(e,t){const n=t.tagName==="ol",r=e.toSpecificContent(e.all(t),JSn);let i=null;n&&(i=t.properties&&t.properties.start?Number.parseInt(String(t.properties.start),10):1);const o={type:"list",ordered:n,start:i,spread:dX(r),children:r};return e.patch(t,o),o}function JSn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var ZSn=Le((()=>{a5e()}));function x5(e){let t=-1;for(;++t<e.length;){const n=e[t];if(!I5e(n)||"children"in n&&x5(n.children))return!0}return!1}function S5e(e){return T5e(e,t,function(n){return n});function t(n){return n.every(function(r){return r.type==="text"?H3e(r.value):!1})?[]:[{type:"paragraph",children:fX(n)}]}}function QSn(e){return T5e(e.children,t,n);function t(r){const i=gX(e);return i.children=r,[i]}function n(r){if("children"in r&&"children"in e){const i=gX(e),o=gX(r);return i.children=r.children,o.children.push(i),o}return{...r}}}function T5e(e,t,n){const r=$Sn(e),i=[];let o=[],s=-1;for(;++s<r.length;){const a=r[s];I5e(a)?o.push(a):(o.length>0&&(i.push(...t(o)),o=[]),i.push(n(a)))}return o.length>0&&(i.push(...t(o)),o=[]),i}function $Sn(e){const t=[];let n=-1;for(;++n<e.length;){const r=e[n];(r.type==="delete"||r.type==="link")&&x5(r.children)?t.push(...QSn(r)):t.push(r)}return t}function I5e(e){const t=e.data&&e.data.hName;return t?y5e({type:"element",tagName:t,properties:{},children:[]}):uU(e)}function gX(e){return tX({...e,children:[]})}var yX=Le((()=>{O3e(),w5e(),V3e(),Dye(),hX()}));function k5e(e,t){const n=t.properties||{},r=t.tagName==="video"?String(n.poster||""):"";let i=String(n.src||""),o=-1,s=!1,a=e.all(t);if(yk({type:"root",children:a},function(u){if(u.type==="link")return s=!0,!1}),s||x5(a))return a;for(;!i&&++o<t.children.length;){const u=t.children[o];u.type==="element"&&u.tagName==="source"&&u.properties&&(i=String(u.properties.src||""))}if(r){const u={type:"image",title:null,url:e.resolve(r),alt:IL(a)};e.patch(t,u),a=[u]}const l=a,c={type:"link",title:n.title?String(n.title):null,url:e.resolve(i),children:l};return e.patch(t,c),c}var eTn=Le((()=>{kL(),HL(),yX()}));function E5e(e,t){const n=fX(e.all(t));if(n.length>0){const r={type:"paragraph",children:n};return e.patch(t,r),r}}var tTn=Le((()=>{hX()}));function nTn(e,t){const n=e.options.quotes||C5e;e.qNesting++;const r=e.all(t);e.qNesting--;const i=n[e.qNesting%n.length],o=r[0],s=r[r.length-1],a=i.charAt(0),l=i.length>1?i.charAt(1):i;return o&&o.type==="text"?o.value=a+o.value:r.unshift({type:"text",value:a}),s&&s.type==="text"?s.value+=l:r.push({type:"text",value:l}),r}var C5e,rTn=Le((()=>{C5e=['"']}));function iTn(e,t){let n=e.all(t);(e.options.document||x5(n))&&(n=S5e(n));const r={type:"root",children:n};return e.patch(t,r),r}var oTn=Le((()=>{yX()}));function sTn(e,t){const n=u5e(t);let r=-1;const i=[];for(;++r<n.length;){const o=n[r];i.push(o[1]?o[1]+" ("+o[0]+")":o[0])}if(i.length>0){const o={type:"text",value:i.join(", ")};return e.patch(t,o),o}}var aTn=Le((()=>{f5e()}));function _5e(e,t){const n={type:"strong",children:e.all(t)};return e.patch(t,n),n}var lTn=Le((()=>{}));function P5e(e,t){const n={type:"tableCell",children:e.all(t)};if(e.patch(t,n),t.properties){const r=t.properties.rowSpan,i=t.properties.colSpan;if(r||i){const o=n.data||(n.data={});r&&(o.hastUtilToMdastTemporaryRowSpan=r),i&&(o.hastUtilToMdastTemporaryColSpan=i)}}return n}var cTn=Le((()=>{}));function uTn(e,t){const n={type:"tableRow",children:e.toSpecificContent(e.all(t),dTn)};return e.patch(t,n),n}function dTn(){return{type:"tableCell",children:[]}}var fTn=Le((()=>{}));function hTn(e,t){if(e.inTable){const c={type:"text",value:yC(t)};return e.patch(t,c),c}e.inTable=!0;const{align:n,headless:r}=pTn(t),i=e.toSpecificContent(e.all(t),R5e);r&&i.unshift(R5e());let o=-1;for(;++o<i.length;){const c=i[o];c.children=e.toSpecificContent(c.children,mTn)}let s=1;for(o=-1;++o<i.length;){const c=i[o].children;let u=-1;for(;++u<c.length;){const d=c[u];if(d.data){const f=d.data,h=Number.parseInt(String(f.hastUtilToMdastTemporaryColSpan),10)||1,p=Number.parseInt(String(f.hastUtilToMdastTemporaryRowSpan),10)||1;if(h>1||p>1){let m=o-1;for(;++m<o+p;){let g=u-1;for(;++g<u+h&&i[m];){const y=[];(m!==o||g!==u)&&y.push({type:"tableCell",children:[]}),i[m].children.splice(g,0,...y)}}}"hastUtilToMdastTemporaryColSpan"in d.data&&delete d.data.hastUtilToMdastTemporaryColSpan,"hastUtilToMdastTemporaryRowSpan"in d.data&&delete d.data.hastUtilToMdastTemporaryRowSpan,Object.keys(d.data).length===0&&delete d.data}}c.length>s&&(s=c.length)}for(o=-1;++o<i.length;){const c=i[o].children;let u=c.length-1;for(;++u<s;)c.push({type:"tableCell",children:[]})}let a=n.length-1;for(;++a<s;)n.push(null);e.inTable=!1;const l={type:"table",align:n,children:i};return e.patch(t,l),l}function pTn(e){const t={align:[null],headless:!0};let n=0,r=0;return yk(e,function(i){if(i.type==="element"){if(i.tagName==="table"&&e!==i)return sye;if((i.tagName==="th"||i.tagName==="td")&&i.properties){if(!t.align[r]){const o=String(i.properties.align||"")||null;(o==="center"||o==="left"||o==="right"||o===null)&&(t.align[r]=o)}t.headless&&n<2&&i.tagName==="th"&&(t.headless=!1),r++}else i.tagName==="thead"?t.headless=!1:i.tagName==="tr"&&(n++,r=0)}}),t}function mTn(){return{type:"tableCell",children:[]}}function R5e(){return{type:"tableRow",children:[]}}var gTn=Le((()=>{bC(),HL()}));function yTn(e,t){const n={type:"text",value:t.value};return e.patch(t,n),n}var bTn=Le((()=>{}));function vTn(e,t){const n={type:"text",value:yC(t)};return e.patch(t,n),n}var wTn=Le((()=>{bC()}));function ATn(e,t){const n={type:"text",value:""};return e.patch(t,n),n}var xTn=Le((()=>{}));function ai(e,t){return e.all(t)}function $s(e,t){return e.toFlow(e.all(t))}function li(){}var L5e,N5e,STn=Le((()=>{aSn(),cSn(),dSn(),hSn(),ISn(),ESn(),CSn(),RSn(),LSn(),NSn(),DSn(),FSn(),BSn(),HSn(),USn(),XSn(),ZSn(),eTn(),tTn(),rTn(),oTn(),aTn(),lTn(),cTn(),fTn(),gTn(),bTn(),wTn(),xTn(),L5e={comment:kSn,doctype:li,root:iTn,text:yTn},N5e={applet:li,area:li,basefont:li,bgsound:li,caption:li,col:li,colgroup:li,command:li,content:li,datalist:li,dialog:li,element:li,embed:li,frame:li,frameset:li,isindex:li,keygen:li,link:li,math:li,menu:li,menuitem:li,meta:li,nextid:li,noembed:li,noframes:li,optgroup:li,option:li,param:li,script:li,shadow:li,source:li,spacer:li,style:li,svg:li,template:li,title:li,track:li,abbr:ai,acronym:ai,bdi:ai,bdo:ai,big:ai,blink:ai,button:ai,canvas:ai,cite:ai,data:ai,details:ai,dfn:ai,font:ai,ins:ai,label:ai,map:ai,marquee:ai,meter:ai,nobr:ai,noscript:ai,object:ai,output:ai,progress:ai,rb:ai,rbc:ai,rp:ai,rt:ai,rtc:ai,ruby:ai,slot:ai,small:ai,span:ai,sup:ai,sub:ai,tbody:ai,tfoot:ai,thead:ai,time:ai,address:$s,article:$s,aside:$s,body:$s,center:$s,div:$s,fieldset:$s,figcaption:$s,figure:$s,form:$s,footer:$s,header:$s,hgroup:$s,html:$s,legend:$s,main:$s,multicol:$s,nav:$s,picture:$s,section:$s,a:sSn,audio:k5e,b:_5e,base:lSn,blockquote:uSn,br:fSn,code:vC,dir:mX,dl:_Sn,dt:pX,dd:pX,del:uX,em:A5,h1:Hx,h2:Hx,h3:Hx,h4:Hx,h5:Hx,h6:Hx,hr:MSn,i:A5,iframe:OSn,img:c5e,image:c5e,input:zSn,kbd:vC,li:pX,listing:w5,mark:A5,ol:mX,p:E5e,plaintext:w5,pre:w5,q:nTn,s:uX,samp:vC,select:sTn,strike:uX,strong:_5e,summary:E5e,table:hTn,td:P5e,textarea:vTn,th:P5e,tr:uTn,tt:vC,u:A5,ul:mX,var:vC,video:k5e,wbr:ATn,xmp:w5}}));function TTn(e){return{all:ITn,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...N5e,...e.handlers},inTable:!1,nodeHandlers:{...L5e,...e.nodeHandlers},one:kTn,options:e,patch:ETn,qNesting:0,resolve:CTn,toFlow:_Tn,toSpecificContent:PTn}}function ITn(e){const t=e.children||[],n=[];let r=-1;for(;++r<t.length;){const i=t[r],o=this.one(i,e);Array.isArray(o)?n.push(...o):o&&n.push(o)}return n}function kTn(e,t){if(e.type==="element"){if(e.properties&&e.properties.dataMdast==="ignore")return;if(bX.call(this.handlers,e.tagName))return this.handlers[e.tagName](this,e,t)||void 0}else if(bX.call(this.nodeHandlers,e.type))return this.nodeHandlers[e.type](this,e,t)||void 0;if("value"in e&&typeof e.value=="string"){const n={type:"text",value:e.value};return this.patch(e,n),n}if("children"in e)return this.all(e)}function ETn(e,t){e.position&&(t.position=rSn(e))}function CTn(e){const t=this.frozenBaseUrl;return e==null?"":t?String(new URL(e,t)):e}function _Tn(e){return S5e(e)}function PTn(e,t){const n=t(),r=[];let i=[],o=-1;for(;++o<e.length;){const a=e[o];if(s(a))i.length>0&&(a.children.unshift(...i),i=[]),r.push(a);else{const l=a;i.push(l)}}if(i.length>0){let a=r[r.length-1];a||(a=t(),r.push(a)),a.children.push(...i),i=[]}return r;function s(a){return a.type===n.type}}var bX,RTn=Le((()=>{oSn(),STn(),yX(),bX={}.hasOwnProperty}));function M5e(e,t){const n=tX(e),r=t||D5e,i=eSn({newlines:r.newlines===!0}),o=TTn(r);let s;i(n),yk(n,function(l){if(l&&l.type==="element"&&l.properties){const c=String(l.properties.id||"")||void 0;c&&!o.elementById.has(c)&&o.elementById.set(c,l)}});const a=o.one(n,void 0);return a?Array.isArray(a)?s={type:"root",children:a}:s=a:s={type:"root",children:[]},yk(s,function(l,c,u){if(l.type==="text"&&c!==void 0&&u){const d=u.children[c-1];if(d&&d.type===l.type)return d.value+=l.value,u.children.splice(c,1),d.position&&l.position&&(d.position.end=l.position.end),c-1;if(l.value=l.value.replace(/[\t ]*(\r?\n|\r)[\t ]*/,"$1"),u&&(u.type==="heading"||u.type==="paragraph"||u.type==="root")&&(c||(l.value=l.value.replace(/^[\t ]+/,"")),c===u.children.length-1&&(l.value=l.value.replace(/[\t ]+$/,""))),!l.value)return u.children.splice(c,1),c}}),s}var D5e,LTn=Le((()=>{O3e(),nSn(),HL(),RTn(),D5e={}})),NTn=Le((()=>{LTn()}));function MTn(e,t){return e&&"run"in e?async function(n,r){const i=M5e(n,{...vX,...t});await e.run(i,r)}:function(n){return M5e(n,{...vX,...e})}}var vX,DTn=Le((()=>{NTn(),vX={document:!0}})),OTn=vs({default:()=>MTn},1),FTn=Le((()=>{DTn()})),BTn="1.34.0-next.6",wX=96,HTn=50,zTn=20,O5e=e=>{const t=e,n=t?.config,r=t?.constructor;if(!n||typeof n!="object"||typeof r!="function")return e;try{return new r(n)}catch{return e}};function UTn(e){const t=(e.attrs?.colwidth??[]).reduce((o,s)=>o+(s||0),0),n=e.attrs?.cellMargins,r=n?.left??0,i=n?.right??0;return Math.max(t-r-i,0)}var qp=class bm extends vE{#e;#t=null;#i=!1;#n="initialized";#r=null;#o=null;get currentTotalPages(){if(this.presentationEditor){const t=this.presentationEditor.getPages();return t.length>0?t.length:void 0}}#l=null;#c=!1;constructor(t){super(),this.extensionStorage={},this.presentationEditor=null,this.isFocused=!1,this.fontsImported=[],this.options={element:null,selector:null,isHeadless:!1,document:null,mockDocument:null,mockWindow:null,content:"",user:null,users:[],media:{},mediaFiles:{},fonts:{},documentMode:"editing",mode:"docx",role:"editor",colors:[],converter:null,fileSource:null,initialState:null,documentId:null,extensions:[],editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,isCommentsEnabled:!1,isNewFile:!1,scale:1,viewOptions:{layout:"print"},annotations:!1,isInternal:!1,externalExtensions:[],isChildEditor:!1,numbering:{},isHeaderOrFooter:!1,lastSelection:null,suppressDefaultDocxStyles:!1,jsonOverride:null,loadFromSchema:!1,fragment:null,skipViewCreation:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:c})=>{throw c},onTrackedChangesUpdate:()=>null,onCommentsUpdate:()=>null,onCommentsLoaded:()=>null,onCommentClicked:()=>null,onCommentLocationsUpdate:()=>null,onPointerDown:()=>null,onPointerUp:()=>null,onRightClick:()=>null,onDocumentLocked:()=>null,onFirstRender:()=>null,onCollaborationReady:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onFontsResolved:null,handleImageUpload:null,customUpdatedFiles:{},isHeaderFooterChanged:!1,isCustomXmlChanged:!1,ydoc:null,collaborationProvider:null,collaborationIsReady:!1,shouldLoadComments:!1,replacedFile:!1,focusTarget:null,permissionResolver:null,parentEditor:null,licenseKey:void 0,telemetry:{enabled:!0}};const n={...t},r=QA(),i=!!n.isHeadless,o=!!(n.element||n.selector),s=n.document??n.mockDocument??(r?document:null),a=!!(n.html||n.markdown)||(n.mode==="text"||n.mode==="html")&&typeof n.content=="string";if(!s&&a)throw new Error("[super-editor] HTML/Markdown import requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");if(!r&&o&&!i)throw new Error("[super-editor] Cannot mount an editor without a DOM. Provide DOM globals (e.g. via JSDOM) or pass { isHeadless: true }.");!r&&!i&&(n.isHeadless=!0),n.isHeadless&&(n.element=null,n.selector=null),this.#_(n),this.setOptions(n),this.#t=n.renderer??(r?new J_e:null),this.#s();const{setHighContrastMode:l}=Op();if(this.setHighContrastMode=l,n.deferDocumentLoad===!0)this.#N(),this.#n="initialized";else{const c={docx:()=>this.#C(),text:()=>this.#k(),html:()=>this.#k(),default:()=>{console.log("Not implemented.")}};(c[this.options.mode]??c.default)(),this.#n="ready"}}get docChanged(){return this.options.isHeaderFooterChanged||this.options.isCustomXmlChanged||!this.options.initialState.doc.eq(this.state.doc)}#u(t){this.#t?.initContainerElement?.(t)}#d(){return QA()&&!this.options.isHeadless}#f(){return this.options.document??this.options.mockDocument??(QA()?document:null)}#a(){setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#w()}#s(){const{telemetry:t,licenseKey:n}=this.options;if(typeof process<"u"&&process.env?.VITEST||this.options.mode==="text"||this.options.isHeaderOrFooter||this.options.isChildEditor||!t?.enabled)return;const r=n!==void 0?n:t.licenseKey??"community-and-eval-agplv3";try{this.#l=new nJe({enabled:!0,endpoint:t.endpoint,licenseKey:r,metadata:t.metadata}),console.debug("[super-editor] Telemetry: enabled")}catch{}}#w(){this.getDocumentIdentifier().then(t=>{if(!(!this.#l||this.#c))try{const n=this.converter?.getDocumentCreatedTimestamp?.()||null;this.#l.trackDocumentOpen(t,n),this.#c=!0}catch{}})}#y(...t){if(!t.includes(this.#n))throw new t_e(`Invalid operation: editor is in '${this.#n}' state, expected one of: ${t.join(", ")}`)}async#x(t,n,r,i){this.#n=t;try{const o=await i();return this.#n=n,o}catch(o){throw this.#n=r,o}}#N(){this.options.extensions?.length||(this.options.extensions=this.options.mode==="docx"?iD():mb()),this.#P(),this.#T(),this.#H(),this.#S()}#S(){this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("trackedChangesUpdate",this.options.onTrackedChangesUpdate),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("commentsUpdate",this.options.onCommentsUpdate),this.on("locked",this.options.onDocumentLocked),this.on("collaborationReady",this.#le.bind(this)),this.on("comment-positions",this.options.onCommentLocationsUpdate),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("fonts-resolved",this.options.onFontsResolved),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick)}async#g(t,n){try{const r=n?.mode??this.options.mode??"docx",i=n?.isNewFile,o={...this.options,mode:r,isCommentsEnabled:n?.isCommentsEnabled??this.options.isCommentsEnabled,suppressDefaultDocxStyles:n?.suppressDefaultDocxStyles??this.options.suppressDefaultDocxStyles,documentMode:n?.documentMode??this.options.documentMode??"editing",html:n?.html,markdown:n?.markdown,jsonOverride:n?.json??null},s=n?.password?{password:n.password}:void 0;if(typeof t=="string")if(typeof process<"u"&&process.versions?.node){const l=e9().readFileSync(t),[c,u,d,f,h]=await bm.loadXmlData(l,!0,s);o.content=c,o.mediaFiles=d,o.fonts=f,o.fileSource=h??l,o.isNewFile=i??!1,this.#o=h?null:t}else{const l=await fetch(t);if(!l.ok)throw console.debug("[SuperDoc] Fetch failed:",l.status,l.statusText),new Error(`Fetch failed: ${l.status} ${l.statusText}`);const c=await l.blob(),[u,d,f,h,p]=await bm.loadXmlData(c,!1,s);o.content=u,o.mediaFiles=f,o.fonts=h,o.fileSource=p??c,o.isNewFile=i??!1,this.#o=t.split("/").pop()||null}else if(t!=null&&typeof t=="object"){const l=typeof Buffer<"u"&&(Buffer.isBuffer(t)||t instanceof Buffer),c=typeof Blob<"u"&&t instanceof Blob,u=t instanceof ArrayBuffer,d=typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer;if(l||c||u||d){const[f,h,p,m,g]=await bm.loadXmlData(t,l,s);o.content=f,o.mediaFiles=p,o.fonts=m,o.fileSource=g??t,o.isNewFile=i??!1,this.#o=null}else{const[f,h,p,m,g]=await bm.loadXmlData(t,!1,s);o.content=f,o.mediaFiles=p,o.fonts=m,o.fileSource=g??t,o.isNewFile=i??!1,this.#o=null}}else if(r==="docx"&&!n?.content&&!n?.html&&!n?.markdown){const{content:l,mediaFiles:c,fonts:u,fileSource:d}=await this.#G();o.content=l,o.mediaFiles={...c,...n?.mediaFiles??{}},o.fonts={...u,...n?.fonts??{}},o.fileSource=d,o.isNewFile=i??!0,this.#o=null}else o.content=n?.content??[],o.mediaFiles=n?.mediaFiles??{},o.fonts=n?.fonts??{},o.fileSource=null,o.isNewFile=i??!n?.content,this.#o=null;this.setOptions(o),this.#O(),J3(this),this.#h(),this.#te();const a=this.#d();if(a&&(this.#u(this.options),this.#Q()),this.#J({includePlugins:!a}),!a){const l=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#Y(l)}a&&(this.mount(this.options.element),this.#se()),a||this.#a(),a&&(this.initDefaultStyles(),this.#X()),(this.options.markdown||this.options.html||this.options.loadFromSchema||this.options.jsonOverride||this.options.mode==="html"||this.options.mode==="text")&&this.migrateListsToV2(),this.setDocumentMode(this.options.documentMode,"init"),this.#v(),this.initializeCollaborationData(),!this.options.ydoc&&!this.options.isChildEditor&&this.#$(),a&&(this.#V(),this.#E())}catch(r){if(r instanceof $o)throw console.debug("[SuperDoc] Document load error:",r.message),r;const i=r instanceof Error?r:new Error(String(r));throw console.debug("[SuperDoc] Document load error:",i.message),new i_e(`Failed to load document: ${i.message}`,i)}}#b(){this.unmount(),this.destroyHeaderFooterEditors(),this.converter=void 0,this.storage.image&&(this.storage.image.media={});const t=Tp(this);t&&(t.state={...Hle},t.initialized=!1,t.editableBaseline=null),this.#o=null,this.options.initialState=null,this.options.content="",this.options.fileSource=null,this._state=void 0}#h(){const t=Tp(this);t&&(t.state=Jy(this.converter?Qd(this.converter):null),t.initialized=!0)}#v(){const t=Tp(this);t?.initialized&&this.emit("protectionChanged",{editor:this,state:t.state,source:"init"})}#C(){this.#P(),this.#T(),this.#H(),this.#O(),J3(this),this.#h(),this.#te(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#d();if(this.#J({includePlugins:!t}),!t){const n=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#Y(n)}t&&(this.#u(this.options),this.#Q(),this.mount(this.options.element),this.#se()),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("trackedChangesUpdate",this.options.onTrackedChangesUpdate),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("commentsUpdate",this.options.onCommentsUpdate),this.on("locked",this.options.onDocumentLocked),this.on("collaborationReady",this.#le.bind(this)),this.on("comment-positions",this.options.onCommentLocationsUpdate),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("fonts-resolved",this.options.onFontsResolved),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#a(),this.initializeCollaborationData(),t&&(this.initDefaultStyles(),this.#X()),(this.options.markdown||this.options.html||this.options.loadFromSchema||this.options.jsonOverride||this.options.mode==="html"||this.options.mode==="text")&&this.migrateListsToV2(),this.setDocumentMode(this.options.documentMode,"init"),this.#v(),!this.options.ydoc&&!this.options.isChildEditor&&this.#$(),t&&(this.#V(),this.#E())}#k(){(!this.options.extensions||!this.options.extensions.length)&&(this.options.extensions=mb()),this.#P(),this.#T(),this.#H(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#d();this.#J({includePlugins:!t}),t&&(this.#u(this.options),this.mount(this.options.element),this.#se()),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("locked",this.options.onDocumentLocked),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#a()}mount(t){this.#re(t),setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#w()}unmount(){this.#t?this.#t.destroy():this.view&&this.view.destroy(),this.view=void 0}#A({editor:t,event:n}){this.toolbar?.setActiveEditor?.(t),this.options.onFocus?.({editor:t,event:n})}setToolbar(t){this.toolbar=t}#_(t){t.isHeadless&&(typeof navigator>"u"&&(global.navigator={platform:"node",userAgent:"Node.js"}),t.mockDocument&&(console.warn("[super-editor] `mockDocument` is deprecated and will be removed in a future version. Use `document` instead (e.g., `new Editor({ document: jsdomDocument })`). See https://docs.superdoc.dev/guide/headless for migration guidance."),global.document=t.mockDocument),t.mockWindow&&(console.warn("[super-editor] `mockWindow` is deprecated and will be removed in a future version. Prefer passing `document` only. Global window assignment is no longer required for headless mode."),global.window=t.mockWindow))}isWebLayout(){return this.options.viewOptions?.layout==="web"}focus(){this.view?.focus()}get state(){return this._state}get lifecycleState(){return this.#n}get sourcePath(){return this.#o}setState(t){this._state=t,this.view&&!this.view.isDestroyed&&this.view.updateState(t)}get storage(){return this.extensionStorage}get commands(){return this.#e?.commands}get doc(){return this.#y("ready","saving"),this.#r||(this.#r=uct(fvn(this))),this.#r}#m(){const t=this.options.headerFooterType;return t==="header"||t==="footer"?t:"body"}captureCurrentSelectionHandle(t){this.#y("ready","saving");const n=VMe(this);return jxe(this,n,t??this.#m())}captureEffectiveSelectionHandle(t){this.#y("ready","saving");const n=WMe(this);return jxe(this,n,t??this.#m())}resolveSelectionHandle(t){this.#y("ready","saving");const n=S6t(t);return n?pK(t._owner,n):null}releaseSelectionHandle(t){this.#y("ready","saving"),T6t(t)}getCurrentSelectionRange(){return this.#y("ready","saving"),gvn(this)}getEffectiveSelectionRange(){return this.#y("ready","saving"),yvn(this)}get helpers(){return this.extensionService.helpers}get isEditable(){return!!(this.options.editable&&this.view&&this.view.editable)}get isDestroyed(){return!!(this.#i||this.view?.isDestroyed)}get element(){return this.options.element}get users(){return this.options.users}chain(){return this.#e.chain()}can(){return this.#e.can()}setDocumentMode(t,n){if(this.options.isHeaderOrFooter||this.options.isChildEditor)return;let r=t?.toLowerCase()||"editing";if(!this.extensionService||!this.state)return;const i=this.view?.dom||this.options.element?.querySelector?.(".ProseMirror");if(this.options.role==="viewer"&&(r="viewing"),this.options.role==="suggester"&&r==="editing"&&(r="suggesting"),r==="viewing"){this.commands.toggleTrackChangesShowOriginal?.();const o=vbe(this.state);o&&this.view?.dispatch(this.state.tr.setSelection(o)),this.setEditable(!1,!1),this.setOptions({documentMode:"viewing"}),i&&i.classList.add("view-mode")}else r==="suggesting"?(this.commands.disableTrackChangesShowOriginal?.(),this.commands.enableTrackChanges?.(),this.setOptions({documentMode:"suggesting"}),this.setEditable(!0,!1),i&&i.classList.remove("view-mode")):r==="editing"&&(this.commands.disableTrackChangesShowOriginal?.(),this.commands.disableTrackChanges?.(),this.setEditable(!0,!1),this.setOptions({documentMode:"editing"}),i&&i.classList.remove("view-mode"));aA(this),this.emit("documentModeChange",{editor:this,documentMode:r})}blur(){this.view?.dom?.blur()}hasFocus(){return this.view?this.view.hasFocus():!1}coordsAtPos(t){return this.presentationEditor?this.presentationEditor.coordsAtPos(t):this.view?this.view.coordsAtPos(t):null}getElementAtPos(t,n={}){if(this.presentationEditor)return this.presentationEditor.getElementAtPos(t,n);if(!this.view||!Number.isFinite(t))return null;const r=this.view.state.doc.content.size,i=Math.max(0,Math.min(t,r));try{const{node:o}=this.view.domAtPos(i);return o&&o.nodeType===1?o:o&&o.nodeType===3?o.parentElement:o?.parentElement??null}catch{return null}}posAtCoords(t){if(typeof this.presentationEditor?.hitTest=="function"){const n=t,r=n?.clientX??n?.left??n?.x??null,i=n?.clientY??n?.top??n?.y??null;if(Number.isFinite(r)&&Number.isFinite(i)){const o=this.presentationEditor.hitTest(r,i);if(o)return{pos:o.pos,inside:o.pos}}}return this.view?this.view.posAtCoords(t):null}#E(){this.#t?.registerCopyHandler?.(this)}async generateCollaborationUpdate(){return await wFt(this)}initializeCollaborationData(){!this.options.isNewFile||!this.options.collaborationProvider||gA(this.options.collaborationProvider,()=>{this.#R()})}replaceContent(t){this.setOptions({content:t}),this.#O(),this.initDefaultStyles(),this.#O(),J3(this),this.#te();const n=this.#z(),r=this.state.tr.replaceWith(0,this.state.doc.content.size,n);r.setMeta("replaceContent",!0),this.#Y(r)}#D(t={}){const n=this.state.doc?.attrs??{},r=this.schema?.topNodeType?.spec?.attrs??{},i=new Set([...Object.keys(r),...Object.keys(n),...Object.keys(t)]);if(i.size===0)return;const o=(l,c)=>l===c||JSON.stringify(l)===JSON.stringify(c),s=this.state.tr.setMeta("addToHistory",!1);let a=!1;for(const l of i){const c=Object.prototype.hasOwnProperty.call(t,l)?t[l]:r[l]?.default;o(n[l],c)||(s.setDocAttribute(l,c),a=!0)}a&&this.#Y(s)}#R(){if(!this.options.isNewFile)return;this.options.isNewFile=!1;const t=this.#z(),n=JSON.parse(JSON.stringify(t.attrs?.bodySectPr??null)),r=this.state.tr.replaceWith(0,this.state.doc.content.size,t).setMeta("addToHistory",!1);this.#Y(r);const i=this.options.ydoc;i&&i.getMap("meta").set("bodySectPr",n),this.#D(t.attrs??{}),setTimeout(()=>{this.#$()},50)}setOptions(t={}){const n=this.options??{},r={...n,...t},i=Object.getOwnPropertyDescriptors(n);for(const[o,s]of Object.entries(i))s.enumerable||Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(r,o,s);this.options=r,(this.options.isNewFile||!this.options.ydoc)&&this.options.isCommentsEnabled&&(this.options.shouldLoadComments=!0),!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t=!0,n=!0){this.setOptions({editable:t}),this.view&&(this.view.setProps({}),!t&&this.view.dom&&this.view.dom.blur()),n&&this.state&&this.emit("update",{editor:this,transaction:this.state.tr})}registerPlugin(t,n){if(this.isDestroyed||!this.state?.plugins)return;const r=typeof n=="function"?n(t,[...this.state.plugins]):[...this.state.plugins,t];this._state=this.state.reconfigure({plugins:r}),this.view?.updateState(this._state)}#I(t){const n=t.key;return typeof n?.key=="string"?n.key:""}unregisterPlugin(t){if(this.isDestroyed)return;const n=typeof t=="string"?`${t}$`:t?.key??"";this._state=this.state.reconfigure({plugins:this.state.plugins.filter(r=>!this.#I(r).startsWith(n))}),this.view?.updateState(this._state)}attachCollaboration({ydoc:t,collaborationProvider:n}){if(this.isDestroyed)throw new Error("[super-editor] Cannot attach collaboration to a destroyed editor");if(this.options.ydoc)throw new Error("[super-editor] Editor already has collaboration attached");if(this.options.isHeadless)throw new Error("[super-editor] attachCollaboration is not supported in headless mode");const r=this.options.collaborationProvider,i=this.options.shouldLoadComments,o=this.options.collaborationIsReady,s=this._state,a=()=>{wSe(this),this.options.ydoc=void 0,this.options.collaborationProvider=r,this.options.shouldLoadComments=i,this.options.collaborationIsReady=o,this._state=s,this.view?.updateState(s)};this.options.ydoc=t,this.options.collaborationProvider=n,this.options.shouldLoadComments=!1;let l;try{l=[...this.extensionService.plugins]}catch(c){throw a(),c}try{this._state=this.state.reconfigure({plugins:l}),this.view?.updateState(this._state)}catch(c){throw a(),c}}#P(){const t=["extension","node","mark"],n=[yZt,uZt,bZt,fZt,vZt,wZt],r=this.options.externalExtensions||[],i=[...n,...this.options.extensions].filter(s=>{const a=typeof s?.type=="string"?s.type:void 0;return a?t.includes(a):!1}).map(s=>O5e(s)),o=r.map(s=>O5e(s));this.extensionService=xZt.create(i,o,this)}#T(){this.#e=ime.create({editor:this})}#O(){this.options.converter?this.converter=this.options.converter:this.converter=new nd({docx:this.options.content,media:this.options.mediaFiles,fonts:this.options.fonts,debug:!0,fileSource:this.options.fileSource,documentId:this.options.documentId,mockWindow:this.options.mockWindow??null,mockDocument:this.options.mockDocument??null,isNewFile:this.options.isNewFile??!1,trackedChangesOptions:this.options.trackedChanges??null})}async#G(){const t=await gse(P$t),n=typeof process<"u"&&!!process.versions?.node&&typeof Buffer<"u",r=new Uint8Array(t);let i;if(n)i=Buffer.from(r);else if(typeof Blob<"u")i=new Blob([r]);else throw new Error("Blob is not available to create blank DOCX");const[o,s,a,l]=await bm.loadXmlData(i,n);return{content:o,mediaFiles:a,fonts:l,fileSource:i}}async#j(){if(Array.isArray(this.options.content))return this.options.content;const t=await this.#G();return this.options.content=t.content,this.options.mediaFiles={...t.mediaFiles,...this.options.mediaFiles??{}},this.options.fonts={...t.fonts,...this.options.fonts??{}},t.content}#te(){if(this.options.isChildEditor)return;if(!this.options.ydoc){this.storage.image.media=this.options.mediaFiles;return}const t=this.options.ydoc.getMap("media");this.options.isNewFile?(Object.entries(this.options.mediaFiles).forEach(([n,r])=>{t.set(n,r)}),this.storage.image.media=this.options.mediaFiles):this.storage.image.media=Object.fromEntries(t.entries())}#Q(){this.#t?.initFonts?.(this)}async#X(){if(!(!this.options.onFontsResolved||typeof this.options.onFontsResolved!="function")&&!this.options.isHeadless)try{const t=this.converter.getDocumentFonts(),n={documentFonts:t,unsupportedFonts:this.#ne(t)};this.emit("fonts-resolved",n)}catch{console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts")}}#ne(t){return t.filter(n=>{const r=PQt(n),i=this.fontsImported.includes(n);return!r&&!i})}static async loadXmlData(t,n=!1,r){if(!t)return;const i=new Bj;return[await i.getDocxData(t,n,{password:r?.password}),i.media,i.mediaFiles,i.fonts,i.decryptedFileData]}static getDocumentVersion(t){return nd.getStoredSuperdocVersion(t)}static setDocumentVersion(t,n){const r=nd.setStoredSuperdocVersion(t,n);return typeof r=="string"?r:n}static getDocumentGuid(t){return nd.extractDocumentGuid(t)}static updateDocumentVersion(t,n){return console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead"),bm.setDocumentVersion(t,n)}async getSchemaSummaryJSON(){if(!this.schema)throw new Error("Schema is not initialized.");const t=this.converter?.getSuperdocVersion?.()||"current",n=new Set((this.extensionService?.extensions||[]).filter(i=>!!i?.config?.excludeFromSummaryJSON).map(i=>i.name)),r=r$t(this.schema,t);return n.size?{...r,nodes:r.nodes.filter(i=>!n.has(i.name)),marks:r.marks.filter(i=>!n.has(i.name))}:r}validateJSON(t){if(!this.schema)throw new Error("Schema is not initialized.");try{return Array.isArray(t)?t.map(n=>this.schema.nodeFromJSON(n)):this.schema.nodeFromJSON(t)}catch(n){const r=n instanceof Error?n.message:String(n),i=new Error(`Invalid document for current schema: ${r}`);throw n instanceof Error&&(i.cause=n),i}}#H(){this.schema=this.extensionService.schema}#z(){let t;try{const{mode:n,content:r,fragment:i,loadFromSchema:o}=this.options,s=this.#f(),a=l=>typeof l=="object"&&l!==null&&!Array.isArray(l);n==="docx"?o&&a(r)?(t=this.schema.nodeFromJSON(r),t=this.#ie(t)):(t=che(this.converter,this.schema,this),t=this.#ie(t),this.options.markdown?t=kU(this.options.markdown,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.html?t=ak(this.options.html,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.jsonOverride&&(t=this.schema.nodeFromJSON(this.options.jsonOverride)),i&&(t=Mvt(i,this.schema))):(n==="text"||n==="html")&&(o&&a(r)?t=this.schema.nodeFromJSON(r):typeof r=="string"?t=ak(r,this,{document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):t=this.schema.topNodeType.createAndFill())}catch(n){console.error(n);const r=n instanceof Error?n:new Error(String(n));this.emit("contentError",{editor:this,error:r})}return t}#J({includePlugins:t=!1}={}){if(this._state)return;const n=this.#z(),r={schema:this.schema};this.options.ydoc||(r.doc=n);let i=ER.create(r);t&&(i=i.reconfigure({plugins:[...this.extensionService.plugins]})),this.options.initialState=i,this._state=i}#se(){const t=this.state.reconfigure({plugins:[...this.extensionService.plugins]});this._state=t,this.view?.updateState(t)}#re(t){if(this._state||this.#J(),!this.#t){if(!QA())throw new Error("[super-editor] Cannot create an editor view without a renderer.");this.#t=new J_e}this.view=this.#t.attach({element:t,editorProps:this.options.editorProps,dispatchTransaction:this.#Y.bind(this),state:this.state,handleClick:this.#K.bind(this)}),this.createNodeViews()}createNodeViews(){this.options.skipViewCreation||typeof this.view?.setProps!="function"||this.view.setProps({nodeViews:this.extensionService.nodeViews})}getMaxContentSize(){if(!this.converter)return{};let t=0;const{$head:n}=this.state.selection;for(let p=n.depth;p>0;p--){const m=n.node(p);if(m.type.name==="tableCell"||m.type.name==="tableHeader"){t=UTn(m);break}}if(this.isWebLayout())return t>0?{width:t,height:1/0}:{};const{pageSize:r={},pageMargins:i={}}=this.converter.pageStyles??{},{width:o,height:s}=r;if(!o||!s)return{};const a=p=>(i?.[p]??0)*wX,l=a("top"),c=a("bottom"),u=a("left"),d=a("right"),f=s*wX-l-c-HTn,h=o*wX-u-d-zTn;return t>0?{width:t,height:f}:{width:h,height:f}}updateEditorStyles(t,n){this.#t?.updateEditorStyles?.(this,t,n)}initDefaultStyles(t=this.element){this.options.isHeadless||this.options.suppressDefaultDocxStyles||this.#t?.initDefaultStyles?.(this,t)}initMobileStyles(t){this.#t?.initMobileStyles?.(this,t)}#le({editor:t,ydoc:n}){if(this.options.collaborationIsReady||this.isDestroyed||!this.converter||!this.state)return;console.debug("🔗 [super-editor] Collaboration ready"),this.#B(),this.options.ydoc&&this.migrateListsToV2(),this.options.onCollaborationReady({editor:t,ydoc:n}),this.options.collaborationIsReady=!0,this.options.initialState=this.state;const{tr:r}=this.state;r.setMeta("collaborationReady",!0),this.#Y(r),this.options.isNewFile||this.#$()}#$(){if(!this.options.isCommentsEnabled||!this.options.shouldLoadComments||!this.converter)return;const t=this.options.replacedFile;this.emit("commentsLoaded",{editor:this,replacedFile:t,comments:this.converter.comments||[]}),this.options.replacedFile=!1,!this.options.isHeadless&&setTimeout(()=>{const n=this.state;if(!n)return;const r=n.tr.setMeta(Qi,{type:"force"});this.#Y(r)},50)}#Y(t){if(this.isDestroyed)return;const n=this.view?.dom?.ownerDocument?.defaultView?.performance??globalThis.performance,r=()=>n?.now?n.now():Date.now(),i=r(),o=this.state;let s,a=t,l=t;const c=a.getMeta("forceTrackChanges")===!0;try{const p=Zi.getState(o)?.isTrackChangesActive??!1,m=a.getMeta("skipTrackChanges")===!0,g=(p||c)&&!m;if(g&&c&&!this.options.user)throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");a=g?$ke({tr:a,state:o,user:this.options.user,replacements:this.options.trackedChanges?.replacements==="independent"?"independent":"paired"}):a;const{state:y,transactions:v}=o.applyTransaction(a);s=y,l=v.find(b=>b.docChanged)??a}catch(p){if(c)throw p;s=o.apply(a),console.log(p)}const u=!o.selection.eq(s.selection);this._state=s,this.view&&this.view.updateState(s);const d=r();this.emit("transaction",{editor:this,transaction:a,duration:d-i}),u&&this.emit("selectionUpdate",{editor:this,transaction:a});const f=a.getMeta("focus");f&&this.emit("focus",{editor:this,event:f.event,transaction:a});const h=a.getMeta("blur");h&&this.emit("blur",{editor:this,event:h.event,transaction:a}),l.docChanged&&(t.docChanged&&this.converter&&(this.converter.documentGuid||(this.converter.promoteToGuid(),console.debug("Document modified - assigned GUID:",this.converter.documentGuid)),this.converter.documentModified=!0),this.emit("update",{editor:this,transaction:l}))}dispatch(t){this.#Y(t)}async getDocumentIdentifier(){return await this.converter?.getDocumentIdentifier()||null}getDocumentGuid(){return this.converter?.documentGuid||null}isDocumentModified(){return this.converter?.documentModified||!1}getDocumentId(){return console.warn("getDocumentId is deprecated, use getDocumentGuid instead"),this.getDocumentGuid()}getAttributes(t){return cn.getAttributes(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,i=typeof t=="string"?n:t;return dhe(this.state,r,i)}getJSON(){const t=this.state.doc.toJSON();try{const n=t,r=n.attrs,i=this.converter;i&&i.bodySectPr&&(n.attrs=r||{},n.attrs.bodySectPr=i.bodySectPr)}catch{}return t}getMetadata(){return{documentGuid:this.converter?.documentGuid||null,isModified:this.isDocumentModified(),version:this.converter?.getSuperdocVersion()||null}}getHTML({unflattenLists:t=!1}={}){const n=this.#f();if(!n)throw new Error("[super-editor] getHTML() requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");const r=n.createElement("div"),i=Hf.fromSchema(this.schema).serializeFragment(this.state.doc.content,{document:n});r.appendChild(i);let o=r.innerHTML;return t&&(o=Age(o,n)),o}async getMarkdown(){const t=this.#f();if(!t)throw new Error("[super-editor] getMarkdown() requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");const n=globalThis,r=n.document===void 0,i=r?{document:n.document,window:n.window,navigatorDescriptor:Object.getOwnPropertyDescriptor(globalThis,"navigator")}:null;r&&(n.document=t,!n.window&&t.defaultView&&(n.window=t.defaultView),!n.navigator&&t.defaultView?.navigator&&(n.navigator=t.defaultView.navigator));try{const[{unified:o},{default:s},{default:a},{default:l},{default:c}]=await Promise.all([Promise.resolve().then(()=>(zz(),Lxt)),Promise.resolve().then(()=>(Axn(),wxn)),Promise.resolve().then(()=>(FTn(),OTn)),Promise.resolve().then(()=>(C1e(),Wtn)),Promise.resolve().then(()=>(AU(),xCt))]),u=this.getHTML(),d=o().use(s,{fragment:!0}).use(a).use(c).use(l,{bullet:"-",fences:!0}).processSync(u);return String(d)}finally{i&&(i.document===void 0?delete n.document:n.document=i.document,i.window===void 0?delete n.window:n.window=i.window,i.navigatorDescriptor?Object.defineProperty(globalThis,"navigator",i.navigatorDescriptor):delete n.navigator)}}getDocumentVersion(){return this.converter?.getSuperdocVersion()||null}createChildEditor(t){return OQt(this,t)}getPageStyles(){return this.converter?.pageStyles||{}}updatePageStyle({pageMargins:t}){if(!this.converter)return;let n=!1;if(t&&(this.converter.pageStyles.pageMargins=t,this.initDefaultStyles(),n=!0),n&&this.view&&!ob()){const r=this.view.state.tr;r.setMeta("forceUpdatePagination",!0),this.#Y(r),this.emit("pageStyleUpdate",{pageMargins:t,pageStyles:this.converter.pageStyles})}}#K(t,n){if(this.setOptions({lastSelection:null}),this.options.isHeaderOrFooter)return _Qt(t,n)}#ie(t){const n=ER.create({schema:this.schema,doc:t}),{tr:r,doc:i}=n;return t4t(i,r,this.schema,this.converter),n.apply(r).doc}migrateListsToV2(){return this.options.isHeaderOrFooter?[]:RQt(this)}#L(t=[]){const n=this.state.doc,r=new E7(n);return e4t(n,r,this.schema,t),r.doc.toJSON()}getUpdatedJson(){return this.#L()}async exportDocx({isFinalDoc:t=!1,commentsType:n="external",exportJsonOnly:r=!1,exportXmlOnly:i=!1,comments:o,getUpdatedDocs:s=!1,fieldsHighlightColor:a=null,compression:l}={}){try{J5t(eb(this));const c=(o??this.converter.comments??[]).map(K=>{const X=Array.isArray(K.elements)&&K.elements.length?K.elements:void 0;return{...K,commentJSON:K.commentJSON??X}}),u=this.#L(c),d=await this.converter.exportToDocx(u,this.schema,this.storage.image.media,t,n,c,this,r,a);if(this.#fe(),i||r)return d;const f=this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]),h=this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]),p=!!this.converter.convertedXml["word/settings.xml"]?.elements?.length,m=p?this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"]?.elements?.[0]):null,g=this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]),y=this.converter.convertedXml["word/footnotes.xml"],v=y?.elements?.[0]?this.converter.schemaToXml(y.elements[0]):null,b=this.converter.convertedXml["word/_rels/footnotes.xml.rels"],w=b?.elements?.[0]?this.converter.schemaToXml(b.elements[0]):null,x=this.converter.convertedXml["word/endnotes.xml"],A=x?.elements?.[0]?this.converter.schemaToXml(x.elements[0]):null,T=this.converter.convertedXml["word/_rels/endnotes.xml.rels"],I=T?.elements?.[0]?this.converter.schemaToXml(T.elements[0]):null,P=this.converter.convertedXml["word/_rels/settings.xml.rels"],C=P?.elements?.[0]?this.converter.schemaToXml(P.elements[0]):null,R=this.converter.addedMedia,k={};Object.entries(this.converter.convertedXml).forEach(([K,X])=>{if(K.includes("header")||K.includes("footer")){const ee=X,be=this.converter.schemaToXml(ee.elements?.[0]);k[K]=String(be.replace(/\[\[sdspace\]\]/g,""))}});const L=this.converter.convertedXml["word/numbering.xml"],_=L?.elements?.[0]?this.converter.schemaToXml(L.elements[0]):null,O=this.converter.convertedXml["docProps/app.xml"],F=O?.elements?.[0]?this.converter.schemaToXml(O.elements[0]):null,B=this.converter.convertedXml["docProps/core.xml"],U=B?.elements?.[0]?this.converter.schemaToXml(B.elements[0]):null,M={...this.options.customUpdatedFiles,"word/document.xml":String(d),"docProps/custom.xml":String(f),"word/_rels/document.xml.rels":String(g),..._?{"word/numbering.xml":String(_)}:{},"word/styles.xml":String(h),...k,...F?{"docProps/app.xml":String(F)}:{},...U?{"docProps/core.xml":String(U)}:{}};if(p){let K=String(m);C?M["word/_rels/settings.xml.rels"]=String(C):/<\w+:attachedTemplate\b/i.test(K)&&(K=K.replace(/<\w+:attachedTemplate\b[^>]*\/?>/gi,"")),M["word/settings.xml"]=K}v&&(M["word/footnotes.xml"]=String(v)),w&&(M["word/_rels/footnotes.xml.rels"]=String(w)),A&&(M["word/endnotes.xml"]=String(A)),I&&(M["word/_rels/endnotes.xml.rels"]=String(I));const z=cV.map(K=>`word/${K}`);for(const K of z){const X=this.converter.convertedXml[K];X?.elements?.[0]?M[K]=String(this.converter.schemaToXml(X.elements[0])):M[K]=null}const Z=typeof this.converter.getBibliographyPartExportPaths=="function"?this.converter.getBibliographyPartExportPaths():[];for(const K of Z){const X=this.converter.convertedXml[K];X?.elements?.[0]&&(M[K]=String(this.converter.schemaToXml(X.elements[0])))}for(const K of Object.keys(this.converter.convertedXml)){if(!K.startsWith("customXml/")||!K.endsWith(".xml")&&!K.endsWith(".rels")||Object.prototype.hasOwnProperty.call(M,K))continue;const X=this.converter.convertedXml[K];X?.elements?.[0]&&(M[K]=String(this.converter.schemaToXml(X.elements[0])))}const Q=this.converter.removedCustomXmlPaths;if(Q instanceof Set)for(const K of Q)M[K]=null;const W=new Bj;if(s){M["[Content_Types].xml"]=await W.updateContentTypes({files:this.options.content},R,!0,M,this.options.fonts);const K=this.options.content,{contentTypesXml:X,relsXml:ee}=y_e({baseFiles:Array.isArray(K)||K&&typeof K=="object"?K:null,updatedDocs:M});return M["[Content_Types].xml"]=X,M["_rels/.rels"]=ee,M}const he=!this.options.fileSource&&!Array.isArray(this.options.content)?await this.#j():this.options.content;return await W.updateZip({docx:he,updatedDocs:M,originalDocxFile:this.options.fileSource,media:R,fonts:this.options.fonts,isHeadless:this.options.isHeadless,compression:l})}catch(c){const u=c instanceof Error?c:new Error(String(c));this.emit("exception",{error:u,editor:this}),console.error(u)}}#pe(){if(this.options.ydoc)try{console.debug("🔗 [super-editor] Ending collaboration"),this.options.collaborationProvider?.disconnect?.(),this.options.ydoc.destroy()}catch(t){const n=t instanceof Error?t:new Error(String(t));this.emit("exception",{error:n,editor:this}),console.error(n)}}async open(t,n){this.#y("initialized","closed"),await this.#x("documentLoading","ready","closed",async()=>{await this.#g(t,n)}),this.emit("documentOpen",{editor:this,sourcePath:this.#o})}static async open(t,n){const r={mode:"docx",isHeadless:!(n?.element!=null||n?.selector!=null),...n},{html:i,markdown:o,json:s,isCommentsEnabled:a,suppressDefaultDocxStyles:l,documentMode:c,content:u,mediaFiles:d,fonts:f,isNewFile:h,password:p,...m}=r,g={mode:r.mode,html:i,markdown:o,json:s,isCommentsEnabled:a,suppressDefaultDocxStyles:l,documentMode:c,content:u,mediaFiles:d,fonts:f,isNewFile:h,password:p},y=new bm({...m,deferDocumentLoad:!0});return await y.open(t,g),y}close(){this.#n==="closed"||this.#n==="initialized"||this.#n!=="destroyed"&&(this.#y("ready"),this.emit("documentClose",{editor:this}),this.#b(),this.#r=null,this.#n="closed")}async save(t){if(this.#y("ready"),!this.#o)throw new n_e("No source path. Use saveTo(path) or exportDocument() instead.");await this.#x("saving","ready","ready",async()=>{const n=await this.exportDocument(t);await this.#xe(this.#o,n)})}async saveTo(t,n){this.#y("ready"),await this.#x("saving","ready","ready",async()=>{const r=await this.exportDocument(n);await this.#xe(t,r),this.#o=t})}async exportDocument(t){return this.#y("ready","saving"),await this.exportDocx({isFinalDoc:t?.isFinalDoc,commentsType:t?.commentsType,comments:t?.comments,fieldsHighlightColor:t?.fieldsHighlightColor,compression:t?.compression})}async#xe(t,n){const r=typeof globalThis<"u"&&typeof globalThis.process<"u"&&globalThis.process.versions?.node!=null,i=typeof Buffer<"u"&&typeof Buffer.isBuffer=="function";if(r||i)try{const o=e9(),s=Buffer.isBuffer(n)?n:Buffer.from(await n.arrayBuffer());o.writeFileSync(t,s);return}catch{}if(typeof window<"u"&&"showSaveFilePicker"in window){const o=await(await window.showSaveFilePicker({suggestedName:t.split("/").pop()||"document.docx",types:[{description:"Word Document",accept:{"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"]}}]})).createWritable();await o.write(n),await o.close();return}throw new r_e("File System Access API not available. Use exportDocument() to get the document data and handle the download manually.")}destroy(){this.#n==="ready"&&this.close(),this.#n!=="destroyed"&&(this.#i=!0,this.emit("destroy"),this.unmount(),this.destroyHeaderFooterEditors(),this.#pe(),this.removeAllListeners(),this.extensionService=void 0,this.schema=void 0,this.#e=void 0,this.#r=null,this.#n="destroyed")}destroyHeaderFooterEditors(){try{const t=this.converter?.headerEditors??[],n=this.converter?.footerEditors??[];if(!t.length&&!n.length)return;const r=[...t,...n].filter(Boolean);for(const i of r)i?.editor?.destroy?.();t.length&&(t.length=0),n.length&&(n.length=0)}catch(t){const n=t instanceof Error?t:new Error(String(t));this.emit("exception",{error:n,editor:this}),console.error(n)}}static checkIfMigrationsNeeded(){const t=version??"initial",n=s_e(t)||[];return console.debug("[checkVersionMigrations] Migrations needed:",t,n.length),n.length>0}processCollaborationMigrations(){if(console.debug("[checkVersionMigrations] Current editor version",BTn),!this.options.ydoc)return;let t=this.options.ydoc.getMap("meta").get("version");t||(t="initial"),console.debug("[checkVersionMigrations] Document version",t);const n=s_e(t)||[],r=this.state.plugins.find(o=>this.#I(o).startsWith("y-sync"));if(!r)return this.options.ydoc;let i=!1;for(const o of n)if(console.debug("🏃♂️ Running migration",o.name),o(this))i=!0;else throw new Error("Migration failed at "+o.name);if(i)return(r?.getState(this.state)).doc}async replaceFile(t,n){this.setOptions({annotations:!0});const[r,i,o,s,a]=await bm.loadXmlData(t,!1,n);if(this.setOptions({fileSource:a??(t instanceof ArrayBuffer?new Blob([t]):t),content:r,media:i,mediaFiles:o,fonts:s,isNewFile:!0}),this.options.shouldLoadComments=!0,this.options.replacedFile=!0,this.#O(),J3(this),this.#te(),this.initDefaultStyles(),this.options.ydoc&&this.options.collaborationProvider){const l=this.options.ydoc,c=this.options.collaborationProvider,u=()=>{this.options.fragment=null,this.#R(),eM(this,l,{replaceExisting:!0});const f=this.options.mediaFiles??{},h=l.getMap("media");for(const p of h.keys())p in f||h.delete(p);Object.entries(f).forEach(([p,m])=>{h.set(p,m)})},d=1e4;await new Promise((f,h)=>{let p,m=!1;const g=gA(c,()=>{if(!m){m=!0,clearTimeout(p);try{u(),f()}catch(y){h(y)}}});m||(p=setTimeout(()=>{m=!0,g(),h(new Error(`replaceFile(): collaboration provider did not sync within ${d}ms. The provider exposes on/off but never emitted sync(true) or synced.`))},d))})}else this.#R();this.options.ydoc||this.#$(),this.emit("documentReplaced",{editor:this})}getInternalXmlFile(t,n="json"){return this.converter.convertedXml[t]?n==="json"?this.converter.convertedXml[t].elements[0]||null:this.converter.schemaToXml(this.converter.convertedXml[t].elements[0]):(console.warn("Cannot find file in docx"),null)}updateInternalXmlFile(t,n){if(typeof n=="string")this.options.customUpdatedFiles[t]=String(n);else{const r=this.converter.schemaToXml(n);this.options.customUpdatedFiles[t]=String(r)}this.options.isCustomXmlChanged=!0}getNodesOfType(t){const{findChildren:n}=PU;return n(this.state.doc,r=>r.type.name===t)}replaceNodeWithHTML(t,n){const{tr:r}=this.state;if(!t||!n)return;const i=t.pos,o=i+t.node.nodeSize,s=ak(n,this);r.replaceWith(i,o,s),this.dispatch(r)}prepareForAnnotations(t=[]){const{tr:n}=this.state,r=EM.processTables({state:this.state,tr:n,annotationValues:t});this.dispatch(r)}async migrateParagraphFields(t=[]){return!Array.isArray(t)||!t.length?t:await DQt(t,this)}annotate(t=[],n=[],r=!1){const{state:i,schema:o}=this;let s=i.tr;if(s=EM.processTables({state:this.state,tr:s,annotationValues:t}),s=EM.annotateDocument({tr:s,schema:o,annotationValues:t,hiddenFieldIds:n,removeEmptyFields:r,editor:this}),s.docChanged){const a=s.scrollIntoView();this.dispatch(a)}}previewAnnotations(t=[],n=[]){this.originalState=this.state,this.annotate(t,n)}closePreview(){this.originalState&&(this.view?this.view.updateState(this.originalState):this._state=this.originalState)}#B(){this.options.isHeaderOrFooter||this.options.isChildEditor||new G_e({editor:this,dryRun:!1,debug:!1}).validateActiveDocument()}#fe(){this.options.isHeaderOrFooter||this.options.isChildEditor||new G_e({editor:this,dryRun:!1,debug:!1}).validateDocumentExport()}#V(){this.#t?.initDevTools?.(this)}},t0=(e,t)=>({css:`var(${e}, ${t})`,fallback:t}),n0={EXT:t0("--sd-comments-highlight-external","#B1124B40"),EXT_ACTIVE:t0("--sd-comments-highlight-external-active","#B1124B66"),EXT_FADED:t0("--sd-comments-highlight-external-faded","#B1124B20"),INT:t0("--sd-comments-highlight-internal","#07838340"),INT_ACTIVE:t0("--sd-comments-highlight-internal-active","#07838366"),INT_FADED:t0("--sd-comments-highlight-internal-faded","#07838320"),EXT_NESTED_BDR:t0("--sd-comments-highlight-external-nested-border","#B1124B99"),INT_NESTED_BDR:t0("--sd-comments-highlight-internal-nested-border","#07838399")},S5="track-change-focused",F5e=".superdoc-comment-highlight",VTn="[data-track-change-id]";function B5e(e){return e?e.split(",").filter(Boolean):[]}function WTn(e){const t=new Map;if(!e)return t;for(const n of e.split(",")){const r=n.indexOf("=");r>0&&t.set(n.slice(0,r),n.slice(r+1))}return t}function H5e(e,t,n,r){e.style[t]="",e.style[t]=n,e.style[t]||(e.style[t]=r)}function AX(e,t){H5e(e,"backgroundColor",t.css,t.fallback)}function GTn(e,t){H5e(e,"boxShadow",`inset 1px 0 0 ${t.css}, inset -1px 0 0 ${t.css}`,`inset 1px 0 0 ${t.fallback}, inset -1px 0 0 ${t.fallback}`)}var jTn=class{#e=null;#t=null;setContainer(e){this.#t=e}getActiveCommentId(){return this.#e}setActiveComment(e){return this.#e===e?!1:(this.#e=e,!0)}apply(){const e=this.#t;e&&(this.#i(e),this.#r(e))}destroy(){const e=this.#t;if(!e)return;const t=e.querySelectorAll(F5e);for(let r=0;r<t.length;r++){const i=t[r];i.style.backgroundColor="",i.style.boxShadow=""}const n=e.querySelectorAll(`.${S5}`);for(let r=0;r<n.length;r++)n[r].classList.remove(S5)}#i(e){const t=this.#e,n=e.querySelectorAll(F5e);for(let r=0;r<n.length;r++){const i=n[r],o=B5e(i.dataset.commentIds);if(o.length===0)continue;const s=new Set(B5e(i.dataset.commentInternalIds)),a=s.has(o[0]),l=i.classList.contains("highlighted")&&(i.classList.contains("track-insert-dec")||i.classList.contains("track-delete-dec"));if(t==null){l?i.style.backgroundColor="":AX(i,a?n0.INT:n0.EXT),i.style.boxShadow="";continue}const c=this.#n(t,o,i.dataset.commentImportedIds);if(c!=null){const u=s.has(c);l?i.style.backgroundColor="":AX(i,u?n0.INT_ACTIVE:n0.EXT_ACTIVE),o.length>1?GTn(i,u?n0.INT_NESTED_BDR:n0.EXT_NESTED_BDR):i.style.boxShadow=""}else l?i.style.backgroundColor="":AX(i,a?n0.INT_FADED:n0.EXT_FADED),i.style.boxShadow=""}}#n(e,t,n){if(t.includes(e))return e;if(n){const r=WTn(n).get(e);if(r&&t.includes(r))return r}return null}#r(e){const t=this.#e,n=e.querySelectorAll(VTn);for(let r=0;r<n.length;r++){const i=n[r];t&&i.dataset.trackChangeId===t?i.classList.add(S5):i.classList.remove(S5)}}},qTn=[Zi,Qi,jk,Eg,PA,KM],YTn=new Set([...qTn]),KTn=["placeholder","tabPlugin","dropcapPlugin","ImagePosition","ImageRegistration","search","yjs-cursor"],xX=`
|
|
422
|
+
`:i5e(e)?(a=2,l=2):cX(e)&&(a=1,l=1);++o<i.length;)s=s.concat(t5e(i[o],e,{whitespace:r,breakBefore:o?void 0:a,breakAfter:o<i.length-1?v5(i[o+1]):l}));return aX(e)&&iX(t,e,aX)&&s.push(" "),a&&s.unshift(a),l&&s.push(l),s}function n5e(e,t){const n=String(e.value),r=[],i=[];let o=0;for(;o<=n.length;){oX.lastIndex=o;const l=oX.exec(n),c=l&&"index"in l?l.index:n.length;r.push(bSn(n.slice(o,c).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),o===0?t.breakBefore:!0,c===n.length?t.breakAfter:!0)),o=c+1}let s=-1,a;for(;++s<r.length;)r[s].charCodeAt(r[s].length-1)===8203||s<r.length-1&&r[s+1].charCodeAt(0)===8203?(i.push(r[s]),a=void 0):r[s]?(typeof a=="number"&&i.push(a),i.push(r[s]),a=0):(s===0||s===r.length-1)&&i.push(0);return i}function ySn(e){return[String(e.value)]}function bSn(e,t,n){const r=[];let i=0,o;for(;i<e.length;){sX.lastIndex=i;const s=sX.exec(e);o=s?s.index:e.length,!i&&!o&&s&&!t&&r.push(""),i!==o&&r.push(e.slice(i,o)),i=s?o+s[0].length:o}return i!==o&&!n&&r.push(""),r.join(" ")}function r5e(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap";default:}}return t.whitespace}function vSn(e){return!!(e.properties||{}).hidden}function wSn(e){return e.tagName==="td"||e.tagName==="th"}function ASn(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var oX,sX,v5,aX,i5e,lX,o5e,cX,xSn=Le((()=>{mSn(),y5(),oX=/\n/g,sX=/[\t ]+/g,v5=ud("br"),aX=ud(wSn),i5e=ud("p"),lX=ud("tr"),o5e=ud(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",vSn,ASn]),cX=ud(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"])})),bC=Le((()=>{xSn()}));function SSn(e){const t=String(e);let n=t.length;for(;n>0;){const r=t.codePointAt(n-1);if(r!==void 0&&(r===10||r===13))n--;else break}return t.slice(0,n)}var TSn=Le((()=>{}));function w5(e,t){const n=t.children;let r=-1,i,o;if(t.tagName==="pre")for(;++r<n.length;){const a=n[r];if(a.type==="element"&&a.tagName==="code"&&a.properties&&a.properties.className&&Array.isArray(a.properties.className)){i=a.properties.className;break}}if(i){for(r=-1;++r<i.length;)if(String(i[r]).slice(0,9)===s5e){o=String(i[r]).slice(9);break}}const s={type:"code",lang:o||null,meta:null,value:SSn(yC(t))};return e.patch(t,s),s}var s5e,ISn=Le((()=>{bC(),TSn(),s5e="language-"}));function kSn(e,t){const n={type:"html",value:"<!--"+t.value+"-->"};return e.patch(t,n),n}var ESn=Le((()=>{}));function uX(e,t){const n={type:"delete",children:e.all(t)};return e.patch(t,n),n}var CSn=Le((()=>{}));function dX(e){let t=-1;if(e.length>1){for(;++t<e.length;)if(e[t].spread)return!0}return!1}var a5e=Le((()=>{}));function _Sn(e,t){const n=[],r=[];let i=-1;for(;++i<t.children.length;){const a=t.children[i];a.type==="element"&&a.tagName==="div"?n.push(...a.children):n.push(a)}let o={definitions:[],titles:[]};for(i=-1;++i<n.length;){const a=n[i];if(a.type==="element"&&a.tagName==="dt"){const l=n[i-1];l&&l.type==="element"&&l.tagName==="dd"&&(r.push(o),o={definitions:[],titles:[]}),o.titles.push(a)}else o.definitions.push(a)}r.push(o),i=-1;const s=[];for(;++i<r.length;){const a=[...l5e(e,r[i].titles),...l5e(e,r[i].definitions)];a.length>0&&s.push({type:"listItem",spread:a.length>1,checked:null,children:a})}if(s.length>0){const a={type:"list",ordered:!1,start:null,spread:dX(s),children:s};return e.patch(t,a),a}}function l5e(e,t){const n=e.all({type:"root",children:t}),r=e.toSpecificContent(n,PSn);return r.length===0?[]:r.length===1?r[0].children:[{type:"list",ordered:!1,start:null,spread:dX(r),children:r}]}function PSn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var RSn=Le((()=>{a5e()}));function A5(e,t){const n={type:"emphasis",children:e.all(t)};return e.patch(t,n),n}var LSn=Le((()=>{}));function fX(e){let t=0,n=e.length;for(;t<n&&e[t].type==="break";)t++;for(;n>t&&e[n-1].type==="break";)n--;return t===0&&n===e.length?e:e.slice(t,n)}var hX=Le((()=>{}));function Hx(e,t){const n={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:fX(e.all(t))};return e.patch(t,n),n}var NSn=Le((()=>{hX()}));function MSn(e,t){const n={type:"thematicBreak"};return e.patch(t,n),n}var DSn=Le((()=>{}));function OSn(e,t){const n=t.properties||{},r=String(n.src||""),i=String(n.title||"");if(r&&i){const o={type:"link",title:null,url:e.resolve(r),children:[{type:"text",value:i}]};return e.patch(t,o),o}}var FSn=Le((()=>{}));function c5e(e,t){const n=t.properties||{},r={type:"image",url:e.resolve(String(n.src||"")||null),title:n.title?String(n.title):null,alt:n.alt?String(n.alt):""};return e.patch(t,r),r}var BSn=Le((()=>{}));function vC(e,t){const n={type:"inlineCode",value:yC(t)};return e.patch(t,n),n}var HSn=Le((()=>{bC()}));function u5e(e,t){const n=[],r=[],i=t||e.properties||{},o=d5e(e),s=Math.min(Number.parseInt(String(i.size),10),0)||(i.multiple?4:1);let a=-1;for(;++a<o.length;){const u=o[a];u&&u.properties&&u.properties.selected&&n.push(u)}const l=n.length>0?n:o,c=Math.min(l.length,s);for(a=-1;++a<c;){const u=l[a],d=u.properties||{},f=yC(u),h=f||String(d.label||""),p=String(d.value||"")||f;r.push([p,h===p?void 0:h])}return r}function d5e(e){const t=[];let n=-1;for(;++n<e.children.length;){const r=e.children[n];"children"in r&&Array.isArray(r.children)&&t.push(...d5e(r)),r.type==="element"&&r.tagName==="option"&&(!r.properties||!r.properties.disabled)&&t.push(r)}return t}var f5e=Le((()=>{bC()}));function zSn(e,t){const n=t.properties||{},r=String(n.value||n.placeholder||"");if(n.disabled||n.type==="hidden"||n.type==="file")return;if(n.type==="checkbox"||n.type==="radio"){const l={type:"text",value:n.checked?e.options.checked||h5e:e.options.unchecked||p5e};return e.patch(t,l),l}if(n.type==="image"){const l=n.alt||r;if(l){const c={type:"image",url:e.resolve(String(n.src||"")||null),title:String(n.title||"")||null,alt:String(l)};return e.patch(t,c),c}return}let i=[];if(r)i=[[r,void 0]];else if(n.type!=="button"&&n.type!=="file"&&n.type!=="password"&&n.type!=="reset"&&n.type!=="submit"&&n.list){const l=String(n.list),c=e.elementById.get(l);c&&c.tagName==="datalist"&&(i=u5e(c,n))}if(i.length===0)return;if(n.type==="password"&&(i[0]=["•".repeat(i[0][0].length),void 0]),n.type==="email"||n.type==="url"){const l=[];let c=-1;for(;++c<i.length;){const u=e.resolve(i[c][0]),d={type:"link",title:null,url:n.type==="email"?"mailto:"+u:u,children:[{type:"text",value:i[c][1]||u}]};l.push(d),c!==i.length-1&&l.push({type:"text",value:", "})}return l}const o=[];let s=-1;for(;++s<i.length;)o.push(i[s][1]?i[s][1]+" ("+i[s][0]+")":i[s][0]);const a={type:"text",value:o.join(", ")};return e.patch(t,a),a}var h5e,p5e,USn=Le((()=>{f5e(),h5e="[x]",p5e="[ ]"}));function VSn(e,t){const n=e.type==="element"&&m5e.call(e.properties,t)&&e.properties[t];return n!=null&&n!==!1}var m5e,WSn=Le((()=>{m5e={}.hasOwnProperty})),GSn=Le((()=>{WSn()}));function jSn(e){if(e.type!=="element"||e.tagName!=="link")return!1;if(e.properties.itemProp)return!0;const t=e.properties.rel;let n=-1;if(!Array.isArray(t)||t.length===0)return!1;for(;++n<t.length;)if(!g5e.has(String(t[n])))return!1;return!0}var g5e,qSn=Le((()=>{g5e=new Set(["pingback","prefetch","stylesheet"])})),YSn=Le((()=>{qSn()}));function y5e(e){return!!(e.type==="text"||b5e(e)||rX(e)||jSn(e)||v5e(e)&&VSn(e,"itemProp"))}var b5e,v5e,KSn=Le((()=>{B3e(),GSn(),YSn(),y5(),b5e=ud(["a","abbr","area","b","bdi","bdo","br","button","cite","code","data","datalist","del","dfn","em","i","input","ins","kbd","keygen","label","map","mark","meter","noscript","output","progress","q","ruby","s","samp","script","select","small","span","strong","sub","sup","template","textarea","time","u","var","wbr"]),v5e=ud("meta")})),w5e=Le((()=>{KSn()}));function pX(e,t){const{rest:n,checkbox:r}=x5e(t),i=r?!!r.properties.checked:null,o={type:"listItem",spread:A5e(n),checked:i,children:e.toFlow(e.all(n))};return e.patch(t,o),o}function A5e(e){let t=-1,n=!1;for(;++t<e.children.length;){const r=e.children[t];if(r.type==="element"){if(y5e(r))continue;if(r.tagName==="p"||n||A5e(r))return!0;n=!0}}return!1}function x5e(e){const t=e.children[0];if(t&&t.type==="element"&&t.tagName==="input"&&t.properties&&(t.properties.type==="checkbox"||t.properties.type==="radio"))return{checkbox:t,rest:{...e,children:e.children.slice(1)}};if(t&&t.type==="element"&&t.tagName==="p"){const{checkbox:n,rest:r}=x5e(t);if(n)return{checkbox:n,rest:{...e,children:[r,...e.children.slice(1)]}}}return{checkbox:void 0,rest:e}}var XSn=Le((()=>{w5e()}));function mX(e,t){const n=t.tagName==="ol",r=e.toSpecificContent(e.all(t),JSn);let i=null;n&&(i=t.properties&&t.properties.start?Number.parseInt(String(t.properties.start),10):1);const o={type:"list",ordered:n,start:i,spread:dX(r),children:r};return e.patch(t,o),o}function JSn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var ZSn=Le((()=>{a5e()}));function x5(e){let t=-1;for(;++t<e.length;){const n=e[t];if(!I5e(n)||"children"in n&&x5(n.children))return!0}return!1}function S5e(e){return T5e(e,t,function(n){return n});function t(n){return n.every(function(r){return r.type==="text"?H3e(r.value):!1})?[]:[{type:"paragraph",children:fX(n)}]}}function QSn(e){return T5e(e.children,t,n);function t(r){const i=gX(e);return i.children=r,[i]}function n(r){if("children"in r&&"children"in e){const i=gX(e),o=gX(r);return i.children=r.children,o.children.push(i),o}return{...r}}}function T5e(e,t,n){const r=$Sn(e),i=[];let o=[],s=-1;for(;++s<r.length;){const a=r[s];I5e(a)?o.push(a):(o.length>0&&(i.push(...t(o)),o=[]),i.push(n(a)))}return o.length>0&&(i.push(...t(o)),o=[]),i}function $Sn(e){const t=[];let n=-1;for(;++n<e.length;){const r=e[n];(r.type==="delete"||r.type==="link")&&x5(r.children)?t.push(...QSn(r)):t.push(r)}return t}function I5e(e){const t=e.data&&e.data.hName;return t?y5e({type:"element",tagName:t,properties:{},children:[]}):uU(e)}function gX(e){return tX({...e,children:[]})}var yX=Le((()=>{O3e(),w5e(),V3e(),Dye(),hX()}));function k5e(e,t){const n=t.properties||{},r=t.tagName==="video"?String(n.poster||""):"";let i=String(n.src||""),o=-1,s=!1,a=e.all(t);if(yk({type:"root",children:a},function(u){if(u.type==="link")return s=!0,!1}),s||x5(a))return a;for(;!i&&++o<t.children.length;){const u=t.children[o];u.type==="element"&&u.tagName==="source"&&u.properties&&(i=String(u.properties.src||""))}if(r){const u={type:"image",title:null,url:e.resolve(r),alt:IL(a)};e.patch(t,u),a=[u]}const l=a,c={type:"link",title:n.title?String(n.title):null,url:e.resolve(i),children:l};return e.patch(t,c),c}var eTn=Le((()=>{kL(),HL(),yX()}));function E5e(e,t){const n=fX(e.all(t));if(n.length>0){const r={type:"paragraph",children:n};return e.patch(t,r),r}}var tTn=Le((()=>{hX()}));function nTn(e,t){const n=e.options.quotes||C5e;e.qNesting++;const r=e.all(t);e.qNesting--;const i=n[e.qNesting%n.length],o=r[0],s=r[r.length-1],a=i.charAt(0),l=i.length>1?i.charAt(1):i;return o&&o.type==="text"?o.value=a+o.value:r.unshift({type:"text",value:a}),s&&s.type==="text"?s.value+=l:r.push({type:"text",value:l}),r}var C5e,rTn=Le((()=>{C5e=['"']}));function iTn(e,t){let n=e.all(t);(e.options.document||x5(n))&&(n=S5e(n));const r={type:"root",children:n};return e.patch(t,r),r}var oTn=Le((()=>{yX()}));function sTn(e,t){const n=u5e(t);let r=-1;const i=[];for(;++r<n.length;){const o=n[r];i.push(o[1]?o[1]+" ("+o[0]+")":o[0])}if(i.length>0){const o={type:"text",value:i.join(", ")};return e.patch(t,o),o}}var aTn=Le((()=>{f5e()}));function _5e(e,t){const n={type:"strong",children:e.all(t)};return e.patch(t,n),n}var lTn=Le((()=>{}));function P5e(e,t){const n={type:"tableCell",children:e.all(t)};if(e.patch(t,n),t.properties){const r=t.properties.rowSpan,i=t.properties.colSpan;if(r||i){const o=n.data||(n.data={});r&&(o.hastUtilToMdastTemporaryRowSpan=r),i&&(o.hastUtilToMdastTemporaryColSpan=i)}}return n}var cTn=Le((()=>{}));function uTn(e,t){const n={type:"tableRow",children:e.toSpecificContent(e.all(t),dTn)};return e.patch(t,n),n}function dTn(){return{type:"tableCell",children:[]}}var fTn=Le((()=>{}));function hTn(e,t){if(e.inTable){const c={type:"text",value:yC(t)};return e.patch(t,c),c}e.inTable=!0;const{align:n,headless:r}=pTn(t),i=e.toSpecificContent(e.all(t),R5e);r&&i.unshift(R5e());let o=-1;for(;++o<i.length;){const c=i[o];c.children=e.toSpecificContent(c.children,mTn)}let s=1;for(o=-1;++o<i.length;){const c=i[o].children;let u=-1;for(;++u<c.length;){const d=c[u];if(d.data){const f=d.data,h=Number.parseInt(String(f.hastUtilToMdastTemporaryColSpan),10)||1,p=Number.parseInt(String(f.hastUtilToMdastTemporaryRowSpan),10)||1;if(h>1||p>1){let m=o-1;for(;++m<o+p;){let g=u-1;for(;++g<u+h&&i[m];){const y=[];(m!==o||g!==u)&&y.push({type:"tableCell",children:[]}),i[m].children.splice(g,0,...y)}}}"hastUtilToMdastTemporaryColSpan"in d.data&&delete d.data.hastUtilToMdastTemporaryColSpan,"hastUtilToMdastTemporaryRowSpan"in d.data&&delete d.data.hastUtilToMdastTemporaryRowSpan,Object.keys(d.data).length===0&&delete d.data}}c.length>s&&(s=c.length)}for(o=-1;++o<i.length;){const c=i[o].children;let u=c.length-1;for(;++u<s;)c.push({type:"tableCell",children:[]})}let a=n.length-1;for(;++a<s;)n.push(null);e.inTable=!1;const l={type:"table",align:n,children:i};return e.patch(t,l),l}function pTn(e){const t={align:[null],headless:!0};let n=0,r=0;return yk(e,function(i){if(i.type==="element"){if(i.tagName==="table"&&e!==i)return sye;if((i.tagName==="th"||i.tagName==="td")&&i.properties){if(!t.align[r]){const o=String(i.properties.align||"")||null;(o==="center"||o==="left"||o==="right"||o===null)&&(t.align[r]=o)}t.headless&&n<2&&i.tagName==="th"&&(t.headless=!1),r++}else i.tagName==="thead"?t.headless=!1:i.tagName==="tr"&&(n++,r=0)}}),t}function mTn(){return{type:"tableCell",children:[]}}function R5e(){return{type:"tableRow",children:[]}}var gTn=Le((()=>{bC(),HL()}));function yTn(e,t){const n={type:"text",value:t.value};return e.patch(t,n),n}var bTn=Le((()=>{}));function vTn(e,t){const n={type:"text",value:yC(t)};return e.patch(t,n),n}var wTn=Le((()=>{bC()}));function ATn(e,t){const n={type:"text",value:""};return e.patch(t,n),n}var xTn=Le((()=>{}));function ai(e,t){return e.all(t)}function $s(e,t){return e.toFlow(e.all(t))}function li(){}var L5e,N5e,STn=Le((()=>{aSn(),cSn(),dSn(),hSn(),ISn(),ESn(),CSn(),RSn(),LSn(),NSn(),DSn(),FSn(),BSn(),HSn(),USn(),XSn(),ZSn(),eTn(),tTn(),rTn(),oTn(),aTn(),lTn(),cTn(),fTn(),gTn(),bTn(),wTn(),xTn(),L5e={comment:kSn,doctype:li,root:iTn,text:yTn},N5e={applet:li,area:li,basefont:li,bgsound:li,caption:li,col:li,colgroup:li,command:li,content:li,datalist:li,dialog:li,element:li,embed:li,frame:li,frameset:li,isindex:li,keygen:li,link:li,math:li,menu:li,menuitem:li,meta:li,nextid:li,noembed:li,noframes:li,optgroup:li,option:li,param:li,script:li,shadow:li,source:li,spacer:li,style:li,svg:li,template:li,title:li,track:li,abbr:ai,acronym:ai,bdi:ai,bdo:ai,big:ai,blink:ai,button:ai,canvas:ai,cite:ai,data:ai,details:ai,dfn:ai,font:ai,ins:ai,label:ai,map:ai,marquee:ai,meter:ai,nobr:ai,noscript:ai,object:ai,output:ai,progress:ai,rb:ai,rbc:ai,rp:ai,rt:ai,rtc:ai,ruby:ai,slot:ai,small:ai,span:ai,sup:ai,sub:ai,tbody:ai,tfoot:ai,thead:ai,time:ai,address:$s,article:$s,aside:$s,body:$s,center:$s,div:$s,fieldset:$s,figcaption:$s,figure:$s,form:$s,footer:$s,header:$s,hgroup:$s,html:$s,legend:$s,main:$s,multicol:$s,nav:$s,picture:$s,section:$s,a:sSn,audio:k5e,b:_5e,base:lSn,blockquote:uSn,br:fSn,code:vC,dir:mX,dl:_Sn,dt:pX,dd:pX,del:uX,em:A5,h1:Hx,h2:Hx,h3:Hx,h4:Hx,h5:Hx,h6:Hx,hr:MSn,i:A5,iframe:OSn,img:c5e,image:c5e,input:zSn,kbd:vC,li:pX,listing:w5,mark:A5,ol:mX,p:E5e,plaintext:w5,pre:w5,q:nTn,s:uX,samp:vC,select:sTn,strike:uX,strong:_5e,summary:E5e,table:hTn,td:P5e,textarea:vTn,th:P5e,tr:uTn,tt:vC,u:A5,ul:mX,var:vC,video:k5e,wbr:ATn,xmp:w5}}));function TTn(e){return{all:ITn,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...N5e,...e.handlers},inTable:!1,nodeHandlers:{...L5e,...e.nodeHandlers},one:kTn,options:e,patch:ETn,qNesting:0,resolve:CTn,toFlow:_Tn,toSpecificContent:PTn}}function ITn(e){const t=e.children||[],n=[];let r=-1;for(;++r<t.length;){const i=t[r],o=this.one(i,e);Array.isArray(o)?n.push(...o):o&&n.push(o)}return n}function kTn(e,t){if(e.type==="element"){if(e.properties&&e.properties.dataMdast==="ignore")return;if(bX.call(this.handlers,e.tagName))return this.handlers[e.tagName](this,e,t)||void 0}else if(bX.call(this.nodeHandlers,e.type))return this.nodeHandlers[e.type](this,e,t)||void 0;if("value"in e&&typeof e.value=="string"){const n={type:"text",value:e.value};return this.patch(e,n),n}if("children"in e)return this.all(e)}function ETn(e,t){e.position&&(t.position=rSn(e))}function CTn(e){const t=this.frozenBaseUrl;return e==null?"":t?String(new URL(e,t)):e}function _Tn(e){return S5e(e)}function PTn(e,t){const n=t(),r=[];let i=[],o=-1;for(;++o<e.length;){const a=e[o];if(s(a))i.length>0&&(a.children.unshift(...i),i=[]),r.push(a);else{const l=a;i.push(l)}}if(i.length>0){let a=r[r.length-1];a||(a=t(),r.push(a)),a.children.push(...i),i=[]}return r;function s(a){return a.type===n.type}}var bX,RTn=Le((()=>{oSn(),STn(),yX(),bX={}.hasOwnProperty}));function M5e(e,t){const n=tX(e),r=t||D5e,i=eSn({newlines:r.newlines===!0}),o=TTn(r);let s;i(n),yk(n,function(l){if(l&&l.type==="element"&&l.properties){const c=String(l.properties.id||"")||void 0;c&&!o.elementById.has(c)&&o.elementById.set(c,l)}});const a=o.one(n,void 0);return a?Array.isArray(a)?s={type:"root",children:a}:s=a:s={type:"root",children:[]},yk(s,function(l,c,u){if(l.type==="text"&&c!==void 0&&u){const d=u.children[c-1];if(d&&d.type===l.type)return d.value+=l.value,u.children.splice(c,1),d.position&&l.position&&(d.position.end=l.position.end),c-1;if(l.value=l.value.replace(/[\t ]*(\r?\n|\r)[\t ]*/,"$1"),u&&(u.type==="heading"||u.type==="paragraph"||u.type==="root")&&(c||(l.value=l.value.replace(/^[\t ]+/,"")),c===u.children.length-1&&(l.value=l.value.replace(/[\t ]+$/,""))),!l.value)return u.children.splice(c,1),c}}),s}var D5e,LTn=Le((()=>{O3e(),nSn(),HL(),RTn(),D5e={}})),NTn=Le((()=>{LTn()}));function MTn(e,t){return e&&"run"in e?async function(n,r){const i=M5e(n,{...vX,...t});await e.run(i,r)}:function(n){return M5e(n,{...vX,...e})}}var vX,DTn=Le((()=>{NTn(),vX={document:!0}})),OTn=vs({default:()=>MTn},1),FTn=Le((()=>{DTn()})),BTn="1.34.0-next.7",wX=96,HTn=50,zTn=20,O5e=e=>{const t=e,n=t?.config,r=t?.constructor;if(!n||typeof n!="object"||typeof r!="function")return e;try{return new r(n)}catch{return e}};function UTn(e){const t=(e.attrs?.colwidth??[]).reduce((o,s)=>o+(s||0),0),n=e.attrs?.cellMargins,r=n?.left??0,i=n?.right??0;return Math.max(t-r-i,0)}var qp=class bm extends vE{#e;#t=null;#i=!1;#n="initialized";#r=null;#o=null;get currentTotalPages(){if(this.presentationEditor){const t=this.presentationEditor.getPages();return t.length>0?t.length:void 0}}#l=null;#c=!1;constructor(t){super(),this.extensionStorage={},this.presentationEditor=null,this.isFocused=!1,this.fontsImported=[],this.options={element:null,selector:null,isHeadless:!1,document:null,mockDocument:null,mockWindow:null,content:"",user:null,users:[],media:{},mediaFiles:{},fonts:{},documentMode:"editing",mode:"docx",role:"editor",colors:[],converter:null,fileSource:null,initialState:null,documentId:null,extensions:[],editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,isCommentsEnabled:!1,isNewFile:!1,scale:1,viewOptions:{layout:"print"},annotations:!1,isInternal:!1,externalExtensions:[],isChildEditor:!1,numbering:{},isHeaderOrFooter:!1,lastSelection:null,suppressDefaultDocxStyles:!1,jsonOverride:null,loadFromSchema:!1,fragment:null,skipViewCreation:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:c})=>{throw c},onTrackedChangesUpdate:()=>null,onCommentsUpdate:()=>null,onCommentsLoaded:()=>null,onCommentClicked:()=>null,onCommentLocationsUpdate:()=>null,onPointerDown:()=>null,onPointerUp:()=>null,onRightClick:()=>null,onDocumentLocked:()=>null,onFirstRender:()=>null,onCollaborationReady:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onFontsResolved:null,handleImageUpload:null,customUpdatedFiles:{},isHeaderFooterChanged:!1,isCustomXmlChanged:!1,ydoc:null,collaborationProvider:null,collaborationIsReady:!1,shouldLoadComments:!1,replacedFile:!1,focusTarget:null,permissionResolver:null,parentEditor:null,licenseKey:void 0,telemetry:{enabled:!0}};const n={...t},r=QA(),i=!!n.isHeadless,o=!!(n.element||n.selector),s=n.document??n.mockDocument??(r?document:null),a=!!(n.html||n.markdown)||(n.mode==="text"||n.mode==="html")&&typeof n.content=="string";if(!s&&a)throw new Error("[super-editor] HTML/Markdown import requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");if(!r&&o&&!i)throw new Error("[super-editor] Cannot mount an editor without a DOM. Provide DOM globals (e.g. via JSDOM) or pass { isHeadless: true }.");!r&&!i&&(n.isHeadless=!0),n.isHeadless&&(n.element=null,n.selector=null),this.#_(n),this.setOptions(n),this.#t=n.renderer??(r?new J_e:null),this.#s();const{setHighContrastMode:l}=Op();if(this.setHighContrastMode=l,n.deferDocumentLoad===!0)this.#N(),this.#n="initialized";else{const c={docx:()=>this.#C(),text:()=>this.#k(),html:()=>this.#k(),default:()=>{console.log("Not implemented.")}};(c[this.options.mode]??c.default)(),this.#n="ready"}}get docChanged(){return this.options.isHeaderFooterChanged||this.options.isCustomXmlChanged||!this.options.initialState.doc.eq(this.state.doc)}#u(t){this.#t?.initContainerElement?.(t)}#d(){return QA()&&!this.options.isHeadless}#f(){return this.options.document??this.options.mockDocument??(QA()?document:null)}#a(){setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#w()}#s(){const{telemetry:t,licenseKey:n}=this.options;if(typeof process<"u"&&process.env?.VITEST||this.options.mode==="text"||this.options.isHeaderOrFooter||this.options.isChildEditor||!t?.enabled)return;const r=n!==void 0?n:t.licenseKey??"community-and-eval-agplv3";try{this.#l=new nJe({enabled:!0,endpoint:t.endpoint,licenseKey:r,metadata:t.metadata}),console.debug("[super-editor] Telemetry: enabled")}catch{}}#w(){this.getDocumentIdentifier().then(t=>{if(!(!this.#l||this.#c))try{const n=this.converter?.getDocumentCreatedTimestamp?.()||null;this.#l.trackDocumentOpen(t,n),this.#c=!0}catch{}})}#y(...t){if(!t.includes(this.#n))throw new t_e(`Invalid operation: editor is in '${this.#n}' state, expected one of: ${t.join(", ")}`)}async#x(t,n,r,i){this.#n=t;try{const o=await i();return this.#n=n,o}catch(o){throw this.#n=r,o}}#N(){this.options.extensions?.length||(this.options.extensions=this.options.mode==="docx"?iD():mb()),this.#P(),this.#T(),this.#H(),this.#S()}#S(){this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("trackedChangesUpdate",this.options.onTrackedChangesUpdate),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("commentsUpdate",this.options.onCommentsUpdate),this.on("locked",this.options.onDocumentLocked),this.on("collaborationReady",this.#le.bind(this)),this.on("comment-positions",this.options.onCommentLocationsUpdate),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("fonts-resolved",this.options.onFontsResolved),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick)}async#g(t,n){try{const r=n?.mode??this.options.mode??"docx",i=n?.isNewFile,o={...this.options,mode:r,isCommentsEnabled:n?.isCommentsEnabled??this.options.isCommentsEnabled,suppressDefaultDocxStyles:n?.suppressDefaultDocxStyles??this.options.suppressDefaultDocxStyles,documentMode:n?.documentMode??this.options.documentMode??"editing",html:n?.html,markdown:n?.markdown,jsonOverride:n?.json??null},s=n?.password?{password:n.password}:void 0;if(typeof t=="string")if(typeof process<"u"&&process.versions?.node){const l=e9().readFileSync(t),[c,u,d,f,h]=await bm.loadXmlData(l,!0,s);o.content=c,o.mediaFiles=d,o.fonts=f,o.fileSource=h??l,o.isNewFile=i??!1,this.#o=h?null:t}else{const l=await fetch(t);if(!l.ok)throw console.debug("[SuperDoc] Fetch failed:",l.status,l.statusText),new Error(`Fetch failed: ${l.status} ${l.statusText}`);const c=await l.blob(),[u,d,f,h,p]=await bm.loadXmlData(c,!1,s);o.content=u,o.mediaFiles=f,o.fonts=h,o.fileSource=p??c,o.isNewFile=i??!1,this.#o=t.split("/").pop()||null}else if(t!=null&&typeof t=="object"){const l=typeof Buffer<"u"&&(Buffer.isBuffer(t)||t instanceof Buffer),c=typeof Blob<"u"&&t instanceof Blob,u=t instanceof ArrayBuffer,d=typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer;if(l||c||u||d){const[f,h,p,m,g]=await bm.loadXmlData(t,l,s);o.content=f,o.mediaFiles=p,o.fonts=m,o.fileSource=g??t,o.isNewFile=i??!1,this.#o=null}else{const[f,h,p,m,g]=await bm.loadXmlData(t,!1,s);o.content=f,o.mediaFiles=p,o.fonts=m,o.fileSource=g??t,o.isNewFile=i??!1,this.#o=null}}else if(r==="docx"&&!n?.content&&!n?.html&&!n?.markdown){const{content:l,mediaFiles:c,fonts:u,fileSource:d}=await this.#G();o.content=l,o.mediaFiles={...c,...n?.mediaFiles??{}},o.fonts={...u,...n?.fonts??{}},o.fileSource=d,o.isNewFile=i??!0,this.#o=null}else o.content=n?.content??[],o.mediaFiles=n?.mediaFiles??{},o.fonts=n?.fonts??{},o.fileSource=null,o.isNewFile=i??!n?.content,this.#o=null;this.setOptions(o),this.#O(),J3(this),this.#h(),this.#te();const a=this.#d();if(a&&(this.#u(this.options),this.#Q()),this.#J({includePlugins:!a}),!a){const l=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#Y(l)}a&&(this.mount(this.options.element),this.#se()),a||this.#a(),a&&(this.initDefaultStyles(),this.#X()),(this.options.markdown||this.options.html||this.options.loadFromSchema||this.options.jsonOverride||this.options.mode==="html"||this.options.mode==="text")&&this.migrateListsToV2(),this.setDocumentMode(this.options.documentMode,"init"),this.#v(),this.initializeCollaborationData(),!this.options.ydoc&&!this.options.isChildEditor&&this.#$(),a&&(this.#V(),this.#E())}catch(r){if(r instanceof $o)throw console.debug("[SuperDoc] Document load error:",r.message),r;const i=r instanceof Error?r:new Error(String(r));throw console.debug("[SuperDoc] Document load error:",i.message),new i_e(`Failed to load document: ${i.message}`,i)}}#b(){this.unmount(),this.destroyHeaderFooterEditors(),this.converter=void 0,this.storage.image&&(this.storage.image.media={});const t=Tp(this);t&&(t.state={...Hle},t.initialized=!1,t.editableBaseline=null),this.#o=null,this.options.initialState=null,this.options.content="",this.options.fileSource=null,this._state=void 0}#h(){const t=Tp(this);t&&(t.state=Jy(this.converter?Qd(this.converter):null),t.initialized=!0)}#v(){const t=Tp(this);t?.initialized&&this.emit("protectionChanged",{editor:this,state:t.state,source:"init"})}#C(){this.#P(),this.#T(),this.#H(),this.#O(),J3(this),this.#h(),this.#te(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#d();if(this.#J({includePlugins:!t}),!t){const n=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#Y(n)}t&&(this.#u(this.options),this.#Q(),this.mount(this.options.element),this.#se()),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("trackedChangesUpdate",this.options.onTrackedChangesUpdate),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("commentsUpdate",this.options.onCommentsUpdate),this.on("locked",this.options.onDocumentLocked),this.on("collaborationReady",this.#le.bind(this)),this.on("comment-positions",this.options.onCommentLocationsUpdate),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("fonts-resolved",this.options.onFontsResolved),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#a(),this.initializeCollaborationData(),t&&(this.initDefaultStyles(),this.#X()),(this.options.markdown||this.options.html||this.options.loadFromSchema||this.options.jsonOverride||this.options.mode==="html"||this.options.mode==="text")&&this.migrateListsToV2(),this.setDocumentMode(this.options.documentMode,"init"),this.#v(),!this.options.ydoc&&!this.options.isChildEditor&&this.#$(),t&&(this.#V(),this.#E())}#k(){(!this.options.extensions||!this.options.extensions.length)&&(this.options.extensions=mb()),this.#P(),this.#T(),this.#H(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#d();this.#J({includePlugins:!t}),t&&(this.#u(this.options),this.mount(this.options.element),this.#se()),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("locked",this.options.onDocumentLocked),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#a()}mount(t){this.#re(t),setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#w()}unmount(){this.#t?this.#t.destroy():this.view&&this.view.destroy(),this.view=void 0}#A({editor:t,event:n}){this.toolbar?.setActiveEditor?.(t),this.options.onFocus?.({editor:t,event:n})}setToolbar(t){this.toolbar=t}#_(t){t.isHeadless&&(typeof navigator>"u"&&(global.navigator={platform:"node",userAgent:"Node.js"}),t.mockDocument&&(console.warn("[super-editor] `mockDocument` is deprecated and will be removed in a future version. Use `document` instead (e.g., `new Editor({ document: jsdomDocument })`). See https://docs.superdoc.dev/guide/headless for migration guidance."),global.document=t.mockDocument),t.mockWindow&&(console.warn("[super-editor] `mockWindow` is deprecated and will be removed in a future version. Prefer passing `document` only. Global window assignment is no longer required for headless mode."),global.window=t.mockWindow))}isWebLayout(){return this.options.viewOptions?.layout==="web"}focus(){this.view?.focus()}get state(){return this._state}get lifecycleState(){return this.#n}get sourcePath(){return this.#o}setState(t){this._state=t,this.view&&!this.view.isDestroyed&&this.view.updateState(t)}get storage(){return this.extensionStorage}get commands(){return this.#e?.commands}get doc(){return this.#y("ready","saving"),this.#r||(this.#r=uct(fvn(this))),this.#r}#m(){const t=this.options.headerFooterType;return t==="header"||t==="footer"?t:"body"}captureCurrentSelectionHandle(t){this.#y("ready","saving");const n=VMe(this);return jxe(this,n,t??this.#m())}captureEffectiveSelectionHandle(t){this.#y("ready","saving");const n=WMe(this);return jxe(this,n,t??this.#m())}resolveSelectionHandle(t){this.#y("ready","saving");const n=S6t(t);return n?pK(t._owner,n):null}releaseSelectionHandle(t){this.#y("ready","saving"),T6t(t)}getCurrentSelectionRange(){return this.#y("ready","saving"),gvn(this)}getEffectiveSelectionRange(){return this.#y("ready","saving"),yvn(this)}get helpers(){return this.extensionService.helpers}get isEditable(){return!!(this.options.editable&&this.view&&this.view.editable)}get isDestroyed(){return!!(this.#i||this.view?.isDestroyed)}get element(){return this.options.element}get users(){return this.options.users}chain(){return this.#e.chain()}can(){return this.#e.can()}setDocumentMode(t,n){if(this.options.isHeaderOrFooter||this.options.isChildEditor)return;let r=t?.toLowerCase()||"editing";if(!this.extensionService||!this.state)return;const i=this.view?.dom||this.options.element?.querySelector?.(".ProseMirror");if(this.options.role==="viewer"&&(r="viewing"),this.options.role==="suggester"&&r==="editing"&&(r="suggesting"),r==="viewing"){this.commands.toggleTrackChangesShowOriginal?.();const o=vbe(this.state);o&&this.view?.dispatch(this.state.tr.setSelection(o)),this.setEditable(!1,!1),this.setOptions({documentMode:"viewing"}),i&&i.classList.add("view-mode")}else r==="suggesting"?(this.commands.disableTrackChangesShowOriginal?.(),this.commands.enableTrackChanges?.(),this.setOptions({documentMode:"suggesting"}),this.setEditable(!0,!1),i&&i.classList.remove("view-mode")):r==="editing"&&(this.commands.disableTrackChangesShowOriginal?.(),this.commands.disableTrackChanges?.(),this.setEditable(!0,!1),this.setOptions({documentMode:"editing"}),i&&i.classList.remove("view-mode"));aA(this),this.emit("documentModeChange",{editor:this,documentMode:r})}blur(){this.view?.dom?.blur()}hasFocus(){return this.view?this.view.hasFocus():!1}coordsAtPos(t){return this.presentationEditor?this.presentationEditor.coordsAtPos(t):this.view?this.view.coordsAtPos(t):null}getElementAtPos(t,n={}){if(this.presentationEditor)return this.presentationEditor.getElementAtPos(t,n);if(!this.view||!Number.isFinite(t))return null;const r=this.view.state.doc.content.size,i=Math.max(0,Math.min(t,r));try{const{node:o}=this.view.domAtPos(i);return o&&o.nodeType===1?o:o&&o.nodeType===3?o.parentElement:o?.parentElement??null}catch{return null}}posAtCoords(t){if(typeof this.presentationEditor?.hitTest=="function"){const n=t,r=n?.clientX??n?.left??n?.x??null,i=n?.clientY??n?.top??n?.y??null;if(Number.isFinite(r)&&Number.isFinite(i)){const o=this.presentationEditor.hitTest(r,i);if(o)return{pos:o.pos,inside:o.pos}}}return this.view?this.view.posAtCoords(t):null}#E(){this.#t?.registerCopyHandler?.(this)}async generateCollaborationUpdate(){return await wFt(this)}initializeCollaborationData(){!this.options.isNewFile||!this.options.collaborationProvider||gA(this.options.collaborationProvider,()=>{this.#R()})}replaceContent(t){this.setOptions({content:t}),this.#O(),this.initDefaultStyles(),this.#O(),J3(this),this.#te();const n=this.#z(),r=this.state.tr.replaceWith(0,this.state.doc.content.size,n);r.setMeta("replaceContent",!0),this.#Y(r)}#D(t={}){const n=this.state.doc?.attrs??{},r=this.schema?.topNodeType?.spec?.attrs??{},i=new Set([...Object.keys(r),...Object.keys(n),...Object.keys(t)]);if(i.size===0)return;const o=(l,c)=>l===c||JSON.stringify(l)===JSON.stringify(c),s=this.state.tr.setMeta("addToHistory",!1);let a=!1;for(const l of i){const c=Object.prototype.hasOwnProperty.call(t,l)?t[l]:r[l]?.default;o(n[l],c)||(s.setDocAttribute(l,c),a=!0)}a&&this.#Y(s)}#R(){if(!this.options.isNewFile)return;this.options.isNewFile=!1;const t=this.#z(),n=JSON.parse(JSON.stringify(t.attrs?.bodySectPr??null)),r=this.state.tr.replaceWith(0,this.state.doc.content.size,t).setMeta("addToHistory",!1);this.#Y(r);const i=this.options.ydoc;i&&i.getMap("meta").set("bodySectPr",n),this.#D(t.attrs??{}),setTimeout(()=>{this.#$()},50)}setOptions(t={}){const n=this.options??{},r={...n,...t},i=Object.getOwnPropertyDescriptors(n);for(const[o,s]of Object.entries(i))s.enumerable||Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(r,o,s);this.options=r,(this.options.isNewFile||!this.options.ydoc)&&this.options.isCommentsEnabled&&(this.options.shouldLoadComments=!0),!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t=!0,n=!0){this.setOptions({editable:t}),this.view&&(this.view.setProps({}),!t&&this.view.dom&&this.view.dom.blur()),n&&this.state&&this.emit("update",{editor:this,transaction:this.state.tr})}registerPlugin(t,n){if(this.isDestroyed||!this.state?.plugins)return;const r=typeof n=="function"?n(t,[...this.state.plugins]):[...this.state.plugins,t];this._state=this.state.reconfigure({plugins:r}),this.view?.updateState(this._state)}#I(t){const n=t.key;return typeof n?.key=="string"?n.key:""}unregisterPlugin(t){if(this.isDestroyed)return;const n=typeof t=="string"?`${t}$`:t?.key??"";this._state=this.state.reconfigure({plugins:this.state.plugins.filter(r=>!this.#I(r).startsWith(n))}),this.view?.updateState(this._state)}attachCollaboration({ydoc:t,collaborationProvider:n}){if(this.isDestroyed)throw new Error("[super-editor] Cannot attach collaboration to a destroyed editor");if(this.options.ydoc)throw new Error("[super-editor] Editor already has collaboration attached");if(this.options.isHeadless)throw new Error("[super-editor] attachCollaboration is not supported in headless mode");const r=this.options.collaborationProvider,i=this.options.shouldLoadComments,o=this.options.collaborationIsReady,s=this._state,a=()=>{wSe(this),this.options.ydoc=void 0,this.options.collaborationProvider=r,this.options.shouldLoadComments=i,this.options.collaborationIsReady=o,this._state=s,this.view?.updateState(s)};this.options.ydoc=t,this.options.collaborationProvider=n,this.options.shouldLoadComments=!1;let l;try{l=[...this.extensionService.plugins]}catch(c){throw a(),c}try{this._state=this.state.reconfigure({plugins:l}),this.view?.updateState(this._state)}catch(c){throw a(),c}}#P(){const t=["extension","node","mark"],n=[yZt,uZt,bZt,fZt,vZt,wZt],r=this.options.externalExtensions||[],i=[...n,...this.options.extensions].filter(s=>{const a=typeof s?.type=="string"?s.type:void 0;return a?t.includes(a):!1}).map(s=>O5e(s)),o=r.map(s=>O5e(s));this.extensionService=xZt.create(i,o,this)}#T(){this.#e=ime.create({editor:this})}#O(){this.options.converter?this.converter=this.options.converter:this.converter=new nd({docx:this.options.content,media:this.options.mediaFiles,fonts:this.options.fonts,debug:!0,fileSource:this.options.fileSource,documentId:this.options.documentId,mockWindow:this.options.mockWindow??null,mockDocument:this.options.mockDocument??null,isNewFile:this.options.isNewFile??!1,trackedChangesOptions:this.options.trackedChanges??null})}async#G(){const t=await gse(P$t),n=typeof process<"u"&&!!process.versions?.node&&typeof Buffer<"u",r=new Uint8Array(t);let i;if(n)i=Buffer.from(r);else if(typeof Blob<"u")i=new Blob([r]);else throw new Error("Blob is not available to create blank DOCX");const[o,s,a,l]=await bm.loadXmlData(i,n);return{content:o,mediaFiles:a,fonts:l,fileSource:i}}async#j(){if(Array.isArray(this.options.content))return this.options.content;const t=await this.#G();return this.options.content=t.content,this.options.mediaFiles={...t.mediaFiles,...this.options.mediaFiles??{}},this.options.fonts={...t.fonts,...this.options.fonts??{}},t.content}#te(){if(this.options.isChildEditor)return;if(!this.options.ydoc){this.storage.image.media=this.options.mediaFiles;return}const t=this.options.ydoc.getMap("media");this.options.isNewFile?(Object.entries(this.options.mediaFiles).forEach(([n,r])=>{t.set(n,r)}),this.storage.image.media=this.options.mediaFiles):this.storage.image.media=Object.fromEntries(t.entries())}#Q(){this.#t?.initFonts?.(this)}async#X(){if(!(!this.options.onFontsResolved||typeof this.options.onFontsResolved!="function")&&!this.options.isHeadless)try{const t=this.converter.getDocumentFonts(),n={documentFonts:t,unsupportedFonts:this.#ne(t)};this.emit("fonts-resolved",n)}catch{console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts")}}#ne(t){return t.filter(n=>{const r=PQt(n),i=this.fontsImported.includes(n);return!r&&!i})}static async loadXmlData(t,n=!1,r){if(!t)return;const i=new Bj;return[await i.getDocxData(t,n,{password:r?.password}),i.media,i.mediaFiles,i.fonts,i.decryptedFileData]}static getDocumentVersion(t){return nd.getStoredSuperdocVersion(t)}static setDocumentVersion(t,n){const r=nd.setStoredSuperdocVersion(t,n);return typeof r=="string"?r:n}static getDocumentGuid(t){return nd.extractDocumentGuid(t)}static updateDocumentVersion(t,n){return console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead"),bm.setDocumentVersion(t,n)}async getSchemaSummaryJSON(){if(!this.schema)throw new Error("Schema is not initialized.");const t=this.converter?.getSuperdocVersion?.()||"current",n=new Set((this.extensionService?.extensions||[]).filter(i=>!!i?.config?.excludeFromSummaryJSON).map(i=>i.name)),r=r$t(this.schema,t);return n.size?{...r,nodes:r.nodes.filter(i=>!n.has(i.name)),marks:r.marks.filter(i=>!n.has(i.name))}:r}validateJSON(t){if(!this.schema)throw new Error("Schema is not initialized.");try{return Array.isArray(t)?t.map(n=>this.schema.nodeFromJSON(n)):this.schema.nodeFromJSON(t)}catch(n){const r=n instanceof Error?n.message:String(n),i=new Error(`Invalid document for current schema: ${r}`);throw n instanceof Error&&(i.cause=n),i}}#H(){this.schema=this.extensionService.schema}#z(){let t;try{const{mode:n,content:r,fragment:i,loadFromSchema:o}=this.options,s=this.#f(),a=l=>typeof l=="object"&&l!==null&&!Array.isArray(l);n==="docx"?o&&a(r)?(t=this.schema.nodeFromJSON(r),t=this.#ie(t)):(t=che(this.converter,this.schema,this),t=this.#ie(t),this.options.markdown?t=kU(this.options.markdown,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.html?t=ak(this.options.html,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.jsonOverride&&(t=this.schema.nodeFromJSON(this.options.jsonOverride)),i&&(t=Mvt(i,this.schema))):(n==="text"||n==="html")&&(o&&a(r)?t=this.schema.nodeFromJSON(r):typeof r=="string"?t=ak(r,this,{document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):t=this.schema.topNodeType.createAndFill())}catch(n){console.error(n);const r=n instanceof Error?n:new Error(String(n));this.emit("contentError",{editor:this,error:r})}return t}#J({includePlugins:t=!1}={}){if(this._state)return;const n=this.#z(),r={schema:this.schema};this.options.ydoc||(r.doc=n);let i=ER.create(r);t&&(i=i.reconfigure({plugins:[...this.extensionService.plugins]})),this.options.initialState=i,this._state=i}#se(){const t=this.state.reconfigure({plugins:[...this.extensionService.plugins]});this._state=t,this.view?.updateState(t)}#re(t){if(this._state||this.#J(),!this.#t){if(!QA())throw new Error("[super-editor] Cannot create an editor view without a renderer.");this.#t=new J_e}this.view=this.#t.attach({element:t,editorProps:this.options.editorProps,dispatchTransaction:this.#Y.bind(this),state:this.state,handleClick:this.#K.bind(this)}),this.createNodeViews()}createNodeViews(){this.options.skipViewCreation||typeof this.view?.setProps!="function"||this.view.setProps({nodeViews:this.extensionService.nodeViews})}getMaxContentSize(){if(!this.converter)return{};let t=0;const{$head:n}=this.state.selection;for(let p=n.depth;p>0;p--){const m=n.node(p);if(m.type.name==="tableCell"||m.type.name==="tableHeader"){t=UTn(m);break}}if(this.isWebLayout())return t>0?{width:t,height:1/0}:{};const{pageSize:r={},pageMargins:i={}}=this.converter.pageStyles??{},{width:o,height:s}=r;if(!o||!s)return{};const a=p=>(i?.[p]??0)*wX,l=a("top"),c=a("bottom"),u=a("left"),d=a("right"),f=s*wX-l-c-HTn,h=o*wX-u-d-zTn;return t>0?{width:t,height:f}:{width:h,height:f}}updateEditorStyles(t,n){this.#t?.updateEditorStyles?.(this,t,n)}initDefaultStyles(t=this.element){this.options.isHeadless||this.options.suppressDefaultDocxStyles||this.#t?.initDefaultStyles?.(this,t)}initMobileStyles(t){this.#t?.initMobileStyles?.(this,t)}#le({editor:t,ydoc:n}){if(this.options.collaborationIsReady||this.isDestroyed||!this.converter||!this.state)return;console.debug("🔗 [super-editor] Collaboration ready"),this.#B(),this.options.ydoc&&this.migrateListsToV2(),this.options.onCollaborationReady({editor:t,ydoc:n}),this.options.collaborationIsReady=!0,this.options.initialState=this.state;const{tr:r}=this.state;r.setMeta("collaborationReady",!0),this.#Y(r),this.options.isNewFile||this.#$()}#$(){if(!this.options.isCommentsEnabled||!this.options.shouldLoadComments||!this.converter)return;const t=this.options.replacedFile;this.emit("commentsLoaded",{editor:this,replacedFile:t,comments:this.converter.comments||[]}),this.options.replacedFile=!1,!this.options.isHeadless&&setTimeout(()=>{const n=this.state;if(!n)return;const r=n.tr.setMeta(Qi,{type:"force"});this.#Y(r)},50)}#Y(t){if(this.isDestroyed)return;const n=this.view?.dom?.ownerDocument?.defaultView?.performance??globalThis.performance,r=()=>n?.now?n.now():Date.now(),i=r(),o=this.state;let s,a=t,l=t;const c=a.getMeta("forceTrackChanges")===!0;try{const p=Zi.getState(o)?.isTrackChangesActive??!1,m=a.getMeta("skipTrackChanges")===!0,g=(p||c)&&!m;if(g&&c&&!this.options.user)throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");a=g?$ke({tr:a,state:o,user:this.options.user,replacements:this.options.trackedChanges?.replacements==="independent"?"independent":"paired"}):a;const{state:y,transactions:v}=o.applyTransaction(a);s=y,l=v.find(b=>b.docChanged)??a}catch(p){if(c)throw p;s=o.apply(a),console.log(p)}const u=!o.selection.eq(s.selection);this._state=s,this.view&&this.view.updateState(s);const d=r();this.emit("transaction",{editor:this,transaction:a,duration:d-i}),u&&this.emit("selectionUpdate",{editor:this,transaction:a});const f=a.getMeta("focus");f&&this.emit("focus",{editor:this,event:f.event,transaction:a});const h=a.getMeta("blur");h&&this.emit("blur",{editor:this,event:h.event,transaction:a}),l.docChanged&&(t.docChanged&&this.converter&&(this.converter.documentGuid||(this.converter.promoteToGuid(),console.debug("Document modified - assigned GUID:",this.converter.documentGuid)),this.converter.documentModified=!0),this.emit("update",{editor:this,transaction:l}))}dispatch(t){this.#Y(t)}async getDocumentIdentifier(){return await this.converter?.getDocumentIdentifier()||null}getDocumentGuid(){return this.converter?.documentGuid||null}isDocumentModified(){return this.converter?.documentModified||!1}getDocumentId(){return console.warn("getDocumentId is deprecated, use getDocumentGuid instead"),this.getDocumentGuid()}getAttributes(t){return cn.getAttributes(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,i=typeof t=="string"?n:t;return dhe(this.state,r,i)}getJSON(){const t=this.state.doc.toJSON();try{const n=t,r=n.attrs,i=this.converter;i&&i.bodySectPr&&(n.attrs=r||{},n.attrs.bodySectPr=i.bodySectPr)}catch{}return t}getMetadata(){return{documentGuid:this.converter?.documentGuid||null,isModified:this.isDocumentModified(),version:this.converter?.getSuperdocVersion()||null}}getHTML({unflattenLists:t=!1}={}){const n=this.#f();if(!n)throw new Error("[super-editor] getHTML() requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");const r=n.createElement("div"),i=Hf.fromSchema(this.schema).serializeFragment(this.state.doc.content,{document:n});r.appendChild(i);let o=r.innerHTML;return t&&(o=Age(o,n)),o}async getMarkdown(){const t=this.#f();if(!t)throw new Error("[super-editor] getMarkdown() requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");const n=globalThis,r=n.document===void 0,i=r?{document:n.document,window:n.window,navigatorDescriptor:Object.getOwnPropertyDescriptor(globalThis,"navigator")}:null;r&&(n.document=t,!n.window&&t.defaultView&&(n.window=t.defaultView),!n.navigator&&t.defaultView?.navigator&&(n.navigator=t.defaultView.navigator));try{const[{unified:o},{default:s},{default:a},{default:l},{default:c}]=await Promise.all([Promise.resolve().then(()=>(zz(),Lxt)),Promise.resolve().then(()=>(Axn(),wxn)),Promise.resolve().then(()=>(FTn(),OTn)),Promise.resolve().then(()=>(C1e(),Wtn)),Promise.resolve().then(()=>(AU(),xCt))]),u=this.getHTML(),d=o().use(s,{fragment:!0}).use(a).use(c).use(l,{bullet:"-",fences:!0}).processSync(u);return String(d)}finally{i&&(i.document===void 0?delete n.document:n.document=i.document,i.window===void 0?delete n.window:n.window=i.window,i.navigatorDescriptor?Object.defineProperty(globalThis,"navigator",i.navigatorDescriptor):delete n.navigator)}}getDocumentVersion(){return this.converter?.getSuperdocVersion()||null}createChildEditor(t){return OQt(this,t)}getPageStyles(){return this.converter?.pageStyles||{}}updatePageStyle({pageMargins:t}){if(!this.converter)return;let n=!1;if(t&&(this.converter.pageStyles.pageMargins=t,this.initDefaultStyles(),n=!0),n&&this.view&&!ob()){const r=this.view.state.tr;r.setMeta("forceUpdatePagination",!0),this.#Y(r),this.emit("pageStyleUpdate",{pageMargins:t,pageStyles:this.converter.pageStyles})}}#K(t,n){if(this.setOptions({lastSelection:null}),this.options.isHeaderOrFooter)return _Qt(t,n)}#ie(t){const n=ER.create({schema:this.schema,doc:t}),{tr:r,doc:i}=n;return t4t(i,r,this.schema,this.converter),n.apply(r).doc}migrateListsToV2(){return this.options.isHeaderOrFooter?[]:RQt(this)}#L(t=[]){const n=this.state.doc,r=new E7(n);return e4t(n,r,this.schema,t),r.doc.toJSON()}getUpdatedJson(){return this.#L()}async exportDocx({isFinalDoc:t=!1,commentsType:n="external",exportJsonOnly:r=!1,exportXmlOnly:i=!1,comments:o,getUpdatedDocs:s=!1,fieldsHighlightColor:a=null,compression:l}={}){try{J5t(eb(this));const c=(o??this.converter.comments??[]).map(K=>{const X=Array.isArray(K.elements)&&K.elements.length?K.elements:void 0;return{...K,commentJSON:K.commentJSON??X}}),u=this.#L(c),d=await this.converter.exportToDocx(u,this.schema,this.storage.image.media,t,n,c,this,r,a);if(this.#fe(),i||r)return d;const f=this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]),h=this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]),p=!!this.converter.convertedXml["word/settings.xml"]?.elements?.length,m=p?this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"]?.elements?.[0]):null,g=this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]),y=this.converter.convertedXml["word/footnotes.xml"],v=y?.elements?.[0]?this.converter.schemaToXml(y.elements[0]):null,b=this.converter.convertedXml["word/_rels/footnotes.xml.rels"],w=b?.elements?.[0]?this.converter.schemaToXml(b.elements[0]):null,x=this.converter.convertedXml["word/endnotes.xml"],A=x?.elements?.[0]?this.converter.schemaToXml(x.elements[0]):null,T=this.converter.convertedXml["word/_rels/endnotes.xml.rels"],I=T?.elements?.[0]?this.converter.schemaToXml(T.elements[0]):null,P=this.converter.convertedXml["word/_rels/settings.xml.rels"],C=P?.elements?.[0]?this.converter.schemaToXml(P.elements[0]):null,R=this.converter.addedMedia,k={};Object.entries(this.converter.convertedXml).forEach(([K,X])=>{if(K.includes("header")||K.includes("footer")){const ee=X,be=this.converter.schemaToXml(ee.elements?.[0]);k[K]=String(be.replace(/\[\[sdspace\]\]/g,""))}});const L=this.converter.convertedXml["word/numbering.xml"],_=L?.elements?.[0]?this.converter.schemaToXml(L.elements[0]):null,O=this.converter.convertedXml["docProps/app.xml"],F=O?.elements?.[0]?this.converter.schemaToXml(O.elements[0]):null,B=this.converter.convertedXml["docProps/core.xml"],U=B?.elements?.[0]?this.converter.schemaToXml(B.elements[0]):null,M={...this.options.customUpdatedFiles,"word/document.xml":String(d),"docProps/custom.xml":String(f),"word/_rels/document.xml.rels":String(g),..._?{"word/numbering.xml":String(_)}:{},"word/styles.xml":String(h),...k,...F?{"docProps/app.xml":String(F)}:{},...U?{"docProps/core.xml":String(U)}:{}};if(p){let K=String(m);C?M["word/_rels/settings.xml.rels"]=String(C):/<\w+:attachedTemplate\b/i.test(K)&&(K=K.replace(/<\w+:attachedTemplate\b[^>]*\/?>/gi,"")),M["word/settings.xml"]=K}v&&(M["word/footnotes.xml"]=String(v)),w&&(M["word/_rels/footnotes.xml.rels"]=String(w)),A&&(M["word/endnotes.xml"]=String(A)),I&&(M["word/_rels/endnotes.xml.rels"]=String(I));const z=cV.map(K=>`word/${K}`);for(const K of z){const X=this.converter.convertedXml[K];X?.elements?.[0]?M[K]=String(this.converter.schemaToXml(X.elements[0])):M[K]=null}const Z=typeof this.converter.getBibliographyPartExportPaths=="function"?this.converter.getBibliographyPartExportPaths():[];for(const K of Z){const X=this.converter.convertedXml[K];X?.elements?.[0]&&(M[K]=String(this.converter.schemaToXml(X.elements[0])))}for(const K of Object.keys(this.converter.convertedXml)){if(!K.startsWith("customXml/")||!K.endsWith(".xml")&&!K.endsWith(".rels")||Object.prototype.hasOwnProperty.call(M,K))continue;const X=this.converter.convertedXml[K];X?.elements?.[0]&&(M[K]=String(this.converter.schemaToXml(X.elements[0])))}const Q=this.converter.removedCustomXmlPaths;if(Q instanceof Set)for(const K of Q)M[K]=null;const W=new Bj;if(s){M["[Content_Types].xml"]=await W.updateContentTypes({files:this.options.content},R,!0,M,this.options.fonts);const K=this.options.content,{contentTypesXml:X,relsXml:ee}=y_e({baseFiles:Array.isArray(K)||K&&typeof K=="object"?K:null,updatedDocs:M});return M["[Content_Types].xml"]=X,M["_rels/.rels"]=ee,M}const he=!this.options.fileSource&&!Array.isArray(this.options.content)?await this.#j():this.options.content;return await W.updateZip({docx:he,updatedDocs:M,originalDocxFile:this.options.fileSource,media:R,fonts:this.options.fonts,isHeadless:this.options.isHeadless,compression:l})}catch(c){const u=c instanceof Error?c:new Error(String(c));this.emit("exception",{error:u,editor:this}),console.error(u)}}#pe(){if(this.options.ydoc)try{console.debug("🔗 [super-editor] Ending collaboration"),this.options.collaborationProvider?.disconnect?.(),this.options.ydoc.destroy()}catch(t){const n=t instanceof Error?t:new Error(String(t));this.emit("exception",{error:n,editor:this}),console.error(n)}}async open(t,n){this.#y("initialized","closed"),await this.#x("documentLoading","ready","closed",async()=>{await this.#g(t,n)}),this.emit("documentOpen",{editor:this,sourcePath:this.#o})}static async open(t,n){const r={mode:"docx",isHeadless:!(n?.element!=null||n?.selector!=null),...n},{html:i,markdown:o,json:s,isCommentsEnabled:a,suppressDefaultDocxStyles:l,documentMode:c,content:u,mediaFiles:d,fonts:f,isNewFile:h,password:p,...m}=r,g={mode:r.mode,html:i,markdown:o,json:s,isCommentsEnabled:a,suppressDefaultDocxStyles:l,documentMode:c,content:u,mediaFiles:d,fonts:f,isNewFile:h,password:p},y=new bm({...m,deferDocumentLoad:!0});return await y.open(t,g),y}close(){this.#n==="closed"||this.#n==="initialized"||this.#n!=="destroyed"&&(this.#y("ready"),this.emit("documentClose",{editor:this}),this.#b(),this.#r=null,this.#n="closed")}async save(t){if(this.#y("ready"),!this.#o)throw new n_e("No source path. Use saveTo(path) or exportDocument() instead.");await this.#x("saving","ready","ready",async()=>{const n=await this.exportDocument(t);await this.#xe(this.#o,n)})}async saveTo(t,n){this.#y("ready"),await this.#x("saving","ready","ready",async()=>{const r=await this.exportDocument(n);await this.#xe(t,r),this.#o=t})}async exportDocument(t){return this.#y("ready","saving"),await this.exportDocx({isFinalDoc:t?.isFinalDoc,commentsType:t?.commentsType,comments:t?.comments,fieldsHighlightColor:t?.fieldsHighlightColor,compression:t?.compression})}async#xe(t,n){const r=typeof globalThis<"u"&&typeof globalThis.process<"u"&&globalThis.process.versions?.node!=null,i=typeof Buffer<"u"&&typeof Buffer.isBuffer=="function";if(r||i)try{const o=e9(),s=Buffer.isBuffer(n)?n:Buffer.from(await n.arrayBuffer());o.writeFileSync(t,s);return}catch{}if(typeof window<"u"&&"showSaveFilePicker"in window){const o=await(await window.showSaveFilePicker({suggestedName:t.split("/").pop()||"document.docx",types:[{description:"Word Document",accept:{"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"]}}]})).createWritable();await o.write(n),await o.close();return}throw new r_e("File System Access API not available. Use exportDocument() to get the document data and handle the download manually.")}destroy(){this.#n==="ready"&&this.close(),this.#n!=="destroyed"&&(this.#i=!0,this.emit("destroy"),this.unmount(),this.destroyHeaderFooterEditors(),this.#pe(),this.removeAllListeners(),this.extensionService=void 0,this.schema=void 0,this.#e=void 0,this.#r=null,this.#n="destroyed")}destroyHeaderFooterEditors(){try{const t=this.converter?.headerEditors??[],n=this.converter?.footerEditors??[];if(!t.length&&!n.length)return;const r=[...t,...n].filter(Boolean);for(const i of r)i?.editor?.destroy?.();t.length&&(t.length=0),n.length&&(n.length=0)}catch(t){const n=t instanceof Error?t:new Error(String(t));this.emit("exception",{error:n,editor:this}),console.error(n)}}static checkIfMigrationsNeeded(){const t=version??"initial",n=s_e(t)||[];return console.debug("[checkVersionMigrations] Migrations needed:",t,n.length),n.length>0}processCollaborationMigrations(){if(console.debug("[checkVersionMigrations] Current editor version",BTn),!this.options.ydoc)return;let t=this.options.ydoc.getMap("meta").get("version");t||(t="initial"),console.debug("[checkVersionMigrations] Document version",t);const n=s_e(t)||[],r=this.state.plugins.find(o=>this.#I(o).startsWith("y-sync"));if(!r)return this.options.ydoc;let i=!1;for(const o of n)if(console.debug("🏃♂️ Running migration",o.name),o(this))i=!0;else throw new Error("Migration failed at "+o.name);if(i)return(r?.getState(this.state)).doc}async replaceFile(t,n){this.setOptions({annotations:!0});const[r,i,o,s,a]=await bm.loadXmlData(t,!1,n);if(this.setOptions({fileSource:a??(t instanceof ArrayBuffer?new Blob([t]):t),content:r,media:i,mediaFiles:o,fonts:s,isNewFile:!0}),this.options.shouldLoadComments=!0,this.options.replacedFile=!0,this.#O(),J3(this),this.#te(),this.initDefaultStyles(),this.options.ydoc&&this.options.collaborationProvider){const l=this.options.ydoc,c=this.options.collaborationProvider,u=()=>{this.options.fragment=null,this.#R(),eM(this,l,{replaceExisting:!0});const f=this.options.mediaFiles??{},h=l.getMap("media");for(const p of h.keys())p in f||h.delete(p);Object.entries(f).forEach(([p,m])=>{h.set(p,m)})},d=1e4;await new Promise((f,h)=>{let p,m=!1;const g=gA(c,()=>{if(!m){m=!0,clearTimeout(p);try{u(),f()}catch(y){h(y)}}});m||(p=setTimeout(()=>{m=!0,g(),h(new Error(`replaceFile(): collaboration provider did not sync within ${d}ms. The provider exposes on/off but never emitted sync(true) or synced.`))},d))})}else this.#R();this.options.ydoc||this.#$(),this.emit("documentReplaced",{editor:this})}getInternalXmlFile(t,n="json"){return this.converter.convertedXml[t]?n==="json"?this.converter.convertedXml[t].elements[0]||null:this.converter.schemaToXml(this.converter.convertedXml[t].elements[0]):(console.warn("Cannot find file in docx"),null)}updateInternalXmlFile(t,n){if(typeof n=="string")this.options.customUpdatedFiles[t]=String(n);else{const r=this.converter.schemaToXml(n);this.options.customUpdatedFiles[t]=String(r)}this.options.isCustomXmlChanged=!0}getNodesOfType(t){const{findChildren:n}=PU;return n(this.state.doc,r=>r.type.name===t)}replaceNodeWithHTML(t,n){const{tr:r}=this.state;if(!t||!n)return;const i=t.pos,o=i+t.node.nodeSize,s=ak(n,this);r.replaceWith(i,o,s),this.dispatch(r)}prepareForAnnotations(t=[]){const{tr:n}=this.state,r=EM.processTables({state:this.state,tr:n,annotationValues:t});this.dispatch(r)}async migrateParagraphFields(t=[]){return!Array.isArray(t)||!t.length?t:await DQt(t,this)}annotate(t=[],n=[],r=!1){const{state:i,schema:o}=this;let s=i.tr;if(s=EM.processTables({state:this.state,tr:s,annotationValues:t}),s=EM.annotateDocument({tr:s,schema:o,annotationValues:t,hiddenFieldIds:n,removeEmptyFields:r,editor:this}),s.docChanged){const a=s.scrollIntoView();this.dispatch(a)}}previewAnnotations(t=[],n=[]){this.originalState=this.state,this.annotate(t,n)}closePreview(){this.originalState&&(this.view?this.view.updateState(this.originalState):this._state=this.originalState)}#B(){this.options.isHeaderOrFooter||this.options.isChildEditor||new G_e({editor:this,dryRun:!1,debug:!1}).validateActiveDocument()}#fe(){this.options.isHeaderOrFooter||this.options.isChildEditor||new G_e({editor:this,dryRun:!1,debug:!1}).validateDocumentExport()}#V(){this.#t?.initDevTools?.(this)}},t0=(e,t)=>({css:`var(${e}, ${t})`,fallback:t}),n0={EXT:t0("--sd-comments-highlight-external","#B1124B40"),EXT_ACTIVE:t0("--sd-comments-highlight-external-active","#B1124B66"),EXT_FADED:t0("--sd-comments-highlight-external-faded","#B1124B20"),INT:t0("--sd-comments-highlight-internal","#07838340"),INT_ACTIVE:t0("--sd-comments-highlight-internal-active","#07838366"),INT_FADED:t0("--sd-comments-highlight-internal-faded","#07838320"),EXT_NESTED_BDR:t0("--sd-comments-highlight-external-nested-border","#B1124B99"),INT_NESTED_BDR:t0("--sd-comments-highlight-internal-nested-border","#07838399")},S5="track-change-focused",F5e=".superdoc-comment-highlight",VTn="[data-track-change-id]";function B5e(e){return e?e.split(",").filter(Boolean):[]}function WTn(e){const t=new Map;if(!e)return t;for(const n of e.split(",")){const r=n.indexOf("=");r>0&&t.set(n.slice(0,r),n.slice(r+1))}return t}function H5e(e,t,n,r){e.style[t]="",e.style[t]=n,e.style[t]||(e.style[t]=r)}function AX(e,t){H5e(e,"backgroundColor",t.css,t.fallback)}function GTn(e,t){H5e(e,"boxShadow",`inset 1px 0 0 ${t.css}, inset -1px 0 0 ${t.css}`,`inset 1px 0 0 ${t.fallback}, inset -1px 0 0 ${t.fallback}`)}var jTn=class{#e=null;#t=null;setContainer(e){this.#t=e}getActiveCommentId(){return this.#e}setActiveComment(e){return this.#e===e?!1:(this.#e=e,!0)}apply(){const e=this.#t;e&&(this.#i(e),this.#r(e))}destroy(){const e=this.#t;if(!e)return;const t=e.querySelectorAll(F5e);for(let r=0;r<t.length;r++){const i=t[r];i.style.backgroundColor="",i.style.boxShadow=""}const n=e.querySelectorAll(`.${S5}`);for(let r=0;r<n.length;r++)n[r].classList.remove(S5)}#i(e){const t=this.#e,n=e.querySelectorAll(F5e);for(let r=0;r<n.length;r++){const i=n[r],o=B5e(i.dataset.commentIds);if(o.length===0)continue;const s=new Set(B5e(i.dataset.commentInternalIds)),a=s.has(o[0]),l=i.classList.contains("highlighted")&&(i.classList.contains("track-insert-dec")||i.classList.contains("track-delete-dec"));if(t==null){l?i.style.backgroundColor="":AX(i,a?n0.INT:n0.EXT),i.style.boxShadow="";continue}const c=this.#n(t,o,i.dataset.commentImportedIds);if(c!=null){const u=s.has(c);l?i.style.backgroundColor="":AX(i,u?n0.INT_ACTIVE:n0.EXT_ACTIVE),o.length>1?GTn(i,u?n0.INT_NESTED_BDR:n0.EXT_NESTED_BDR):i.style.boxShadow=""}else l?i.style.backgroundColor="":AX(i,a?n0.INT_FADED:n0.EXT_FADED),i.style.boxShadow=""}}#n(e,t,n){if(t.includes(e))return e;if(n){const r=WTn(n).get(e);if(r&&t.includes(r))return r}return null}#r(e){const t=this.#e,n=e.querySelectorAll(VTn);for(let r=0;r<n.length;r++){const i=n[r];t&&i.dataset.trackChangeId===t?i.classList.add(S5):i.classList.remove(S5)}}},qTn=[Zi,Qi,jk,Eg,PA,KM],YTn=new Set([...qTn]),KTn=["placeholder","tabPlugin","dropcapPlugin","ImagePosition","ImageRegistration","search","yjs-cursor"],xX=`
|
|
423
423
|
`,SX=`
|
|
424
424
|
`;function XTn(e,t,n,r){const i=e.content.size;if(t<=0)return 0;if(t>=e.textBetween(0,i,n,r).length)return i;let o=0,s=i;for(;o<s;){const a=Math.floor((o+s)/2);e.textBetween(0,a,n,r).length<t?o=a+1:s=a}return o}function z5e(e,t,n){if(!t)return null;const r=e.content.size,i=e.textBetween(0,r,xX,SX),o=[];let s=0;for(;;){const f=i.indexOf(t,s);if(f===-1)break;o.push(f),s=f+1}if(o.length===0)return null;const a=f=>XTn(e,f,xX,SX),l=o[0];let c;n==null?c=l:c=o.reduce((f,h)=>{const p=a(h);return Math.abs(p-n)<Math.abs(f.bestPos-n)?{best:h,bestPos:p}:f},{best:l,bestPos:a(l)}).best;const u=a(c),d=a(c+t.length);return u<d?{from:u,to:d}:null}function JTn(e,t,n){if(!n.text)return null;const r=z5e(e,n.text,n.from);return!r||r.from<0||r.to<=r.from||r.to>t?null:r}function U5e(e,t,n){const r=[];for(const i of n){const o=JTn(e,t,i);o&&r.push({...i,from:o.from,to:o.to})}return r}function V5e(e){if(e.length===0)return null;let t=e[0].from,n=e[0].to;for(let r=1;r<e.length;r++)e[r].from<t&&(t=e[r].from),e[r].to>n&&(n=e[r].to);return{from:t,to:n}}function ZTn(e,t,n,r){if(e.length===0||!t?.length)return e;const i=U5e(n,r,t);if(i.length===0)return e;const o=V5e(e),s=V5e(i);return!o||!s?e:o.from>=s.from&&o.to<=s.to&&s.to-s.from>o.to-o.from?i:e}var QTn=class Uee{#e=new WeakMap;#t=[];#i=[];#n=new Map;#r=!1;#o=new Map;#l=!1;#c=!1;#u=0;#d=new Map;#f=new Map;sync(t,n,r){this.#s(t);const i=t.doc.content.size,o=r?.restoreEmptyDecorations!==!1;o||(this.#l=!0);const s=this.#t.length>0?this.#x(t,n,i,o):new Map;return this.#r=this.#t.length>0,this.#R(s,n,i)}recordTransaction(t){this.#c=!!t?.docChanged,t?.docChanged&&(this.#u+=1,this.#d.set(this.#u,t.mapping))}hasChanges(t){if(this.#s(t),this.#t.length===0)return this.#r;for(const n of this.#t)if(this.#A(n,t)!==this.#n.get(n))return!0;return!1}hasCurrentRanges(t){if(this.#s(t),this.#t.length===0)return!1;const n=t.doc.content.size;for(const r of this.#t){const i=this.#A(r,t);if(i!==Nn.empty)for(const o of i.find(0,n)){if(!this.#_(o))continue;const s=this.#m(o);if((s.classes.length>0||s.dataEntries.length>0||s.styleEntries.length>0)&&!(o.from>=o.to))return!0}}return!1}collectDecorationRanges(t){this.#s(t);const n=[],r=t.doc.content.size;for(const i of this.#t){const{ranges:o,decorationSet:s}=this.#S(i,t,r),a=this.#o.get(i),l=!this.#l&&a&&a.length>0,{effectiveRanges:c,rangesToStore:u}=this.#g(o,a,t.doc,r,l,this.#c);this.#b(i,u.length>0?[...u]:[]),this.#n.set(i,s),n.push(...c)}return this.#a(),n}#a(){this.#l&&(this.#l=!1)}destroy(){this.#t=[],this.#i=[],this.#n.clear(),this.#o.clear(),this.#f.clear(),this.#r=!1,this.#l=!1,this.#c=!1,this.#u=0,this.#d.clear()}#s(t){if(t.plugins===this.#i)return;this.#i=t.plugins,this.#t=t.plugins.filter(r=>!(!r.props.decorations||this.#w(r)||this.#y(r)));const n=new Set(this.#t);for(const r of this.#n.keys())n.has(r)||this.#n.delete(r);for(const r of this.#o.keys())n.has(r)||this.#o.delete(r);for(const r of this.#f.keys())n.has(r)||this.#f.delete(r);this.#C()}#w(t){const n=t.spec?.key;return n!=null&&YTn.has(n)}#y(t){const n=t.key??"";return KTn.some(r=>n===r||n.startsWith(`${r}$`))}#x(t,n,r,i){const o=new Map;for(const s of this.#t){const{ranges:a,decorationSet:l}=this.#S(s,t,r),c=this.#o.get(s),{effectiveRanges:u,rangesToStore:d}=this.#g(a,c,t.doc,r,i,this.#c);if(a.length>0||u.length>0){this.#N(o,n,u),this.#b(s,d.length>0?[...d]:[]),this.#n.set(s,l);continue}if(!i){this.#b(s,[]),this.#n.set(s,l);continue}this.#b(s,[]),this.#n.set(s,l)}return o}#N(t,n,r){for(const i of r){const o=n.findEntriesInRange(i.from,i.to);for(const s of o){const a=this.#D(t,s.el);for(const l of i.classes)a.classes.add(l);for(const[l,c]of Object.entries(i.dataAttrs))a.dataAttrs.set(l,c);if(i.style)for(const[l,c]of Uee.#E(i.style))a.styleProps.set(l,c)}}}#S(t,n,r){const i=this.#A(t,n),o=this.#n.get(t),s=this.#k(t,i,o,n.doc,r);if(s)return{ranges:s,decorationSet:i};const a=[];if(i!==Nn.empty){const l=i.find(0,r);for(const c of l){if(!this.#_(c))continue;const u=this.#m(c);if(u.classes.length===0&&u.dataEntries.length===0&&u.styleEntries.length===0||c.from>=c.to)continue;const d={};for(const[p,m]of u.dataEntries)d[p]=m;const f=u.styleEntries.length>0?u.styleEntries.map(([p,m])=>`${p}: ${m}`).join("; "):null,h=typeof n.doc.textBetween=="function"?n.doc.textBetween(c.from,c.to,xX,SX):void 0;a.push({from:c.from,to:c.to,classes:u.classes,style:f,dataAttrs:d,...h?{text:h}:{}})}}return{ranges:a,decorationSet:i}}#g(t,n,r,i,o,s){let a=t;a.length===0&&o&&n?.length&&(a=U5e(r,i,n));const l=s&&o&&n?.length?ZTn(a,n,r,i):a,c=s&&l!==a;return{effectiveRanges:l,rangesToStore:t.length>0?c?l:t:l}}#b(t,n){this.#o.set(t,n),this.#f.set(t,this.#u),this.#C()}#h(t){if(t>=this.#u)return[];const n=[];for(let r=t+1;r<=this.#u;r+=1){const i=this.#d.get(r);if(!i)return[];n.push(i)}return n}#v(t,n,r){let i=t;for(const o of r)i=o.map(i,n);return i}#C(){if(this.#d.size===0)return;let t=this.#u;for(const n of this.#f.values())n<t&&(t=n);for(const n of this.#d.keys())n<=t&&this.#d.delete(n)}#k(t,n,r,i,o){if(!r||r!==n)return null;const s=this.#o.get(t);if(!s?.length)return null;const a=this.#f.get(t)??-1;if(a===this.#u)return s;const l=this.#h(a);if(l.length===0)return null;const c=[];for(const u of s){if(u.text){const h=z5e(i,u.text,u.from);if(h&&h.from>=0&&h.to>h.from&&h.to<=o){c.push({from:h.from,to:h.to,classes:u.classes,style:u.style,dataAttrs:u.dataAttrs,text:u.text});continue}}const d=this.#v(u.from,-1,l),f=this.#v(u.to,1,l);d<0||f<=d||f>o||c.push({from:d,to:f,classes:u.classes,style:u.style,dataAttrs:u.dataAttrs,text:u.text})}return c.length===0?null:c}#A(t,n){try{const r=t.props.decorations?.call(t,n);return r instanceof Nn?r:Nn.empty}catch{return Nn.empty}}#_(t){return t.inline===!0}#m(t){const n=t.type?.attrs??{},r=typeof n.class=="string"?n.class.split(/\s+/).filter(o=>o.length>0):[],i=[];for(const[o,s]of Object.entries(n))o==="class"||o==="style"||o.startsWith("data-")&&typeof s=="string"&&i.push([o,s]);return{classes:r,dataEntries:i,styleEntries:typeof n.style=="string"?Uee.#E(n.style):[]}}static#E(t){if(!t.trim())return[];const n=document.createElement("span");n.style.cssText=t;const r=[];for(let i=0;i<n.style.length;i++){const o=n.style.item(i),s=n.style.getPropertyValue(o);o&&s&&r.push([o,s])}return r}#D(t,n){let r=t.get(n);return r||(r={classes:new Set,dataAttrs:new Map,styleProps:new Map},t.set(n,r)),r}#R(t,n,r){let i=!1;for(const[s,a]of t){const l=this.#e.get(s);l?this.#G(s,l,a)&&(i=!0):(this.#I(s,a),i=!0)}const o=r>0?n.findEntriesInRange(0,r):[];for(const s of o){if(t.has(s.el))continue;const a=this.#e.get(s.el);a&&(this.#j(s.el,a),i=!0)}return i}#I(t,n){const r={classes:new Set,dataAttrs:new Map,styleProps:new Map,priorClasses:new Set,priorDataAttrs:new Map,priorStyleProps:new Map};for(const i of n.classes)t.classList.contains(i)&&r.priorClasses.add(i),t.classList.add(i),r.classes.add(i);for(const[i,o]of n.dataAttrs){const s=t.getAttribute(i);s!==null&&r.priorDataAttrs.set(i,s),t.setAttribute(i,o),r.dataAttrs.set(i,o)}for(const[i,o]of n.styleProps){const s=t.style.getPropertyValue(i);s&&r.priorStyleProps.set(i,s),t.style.setProperty(i,o),r.styleProps.set(i,o)}this.#e.set(t,r)}#P(t,n,r){const i=n.classes.has(r),o=t.classList.contains(r);return i&&o?!1:(!i&&o&&n.priorClasses.add(r),t.classList.add(r),n.classes.add(r),!0)}#T(t,n,r,i){const o=n.dataAttrs.get(r),s=t.getAttribute(r);return o===i&&s===i?!1:(!n.dataAttrs.has(r)&&s!==null&&n.priorDataAttrs.set(r,s),t.setAttribute(r,i),n.dataAttrs.set(r,i),!0)}#O(t,n,r,i){const o=n.styleProps.get(r),s=t.style.getPropertyValue(r);return o===i&&s===i?!1:(!n.styleProps.has(r)&&s&&n.priorStyleProps.set(r,s),t.style.setProperty(r,i),n.styleProps.set(r,i),!0)}#G(t,n,r){let i=!1;for(const o of r.classes)this.#P(t,n,o)&&(i=!0);for(const o of n.classes)r.classes.has(o)||(n.priorClasses.has(o)||t.classList.remove(o),n.priorClasses.delete(o),n.classes.delete(o),i=!0);for(const[o,s]of r.dataAttrs)this.#T(t,n,o,s)&&(i=!0);for(const o of n.dataAttrs.keys())if(!r.dataAttrs.has(o)){const s=n.priorDataAttrs.get(o);s!=null?t.setAttribute(o,s):t.removeAttribute(o),n.priorDataAttrs.delete(o),n.dataAttrs.delete(o),i=!0}for(const[o,s]of r.styleProps)this.#O(t,n,o,s)&&(i=!0);for(const o of n.styleProps.keys())if(!r.styleProps.has(o)){const s=n.priorStyleProps.get(o);s?t.style.setProperty(o,s):t.style.removeProperty(o),n.priorStyleProps.delete(o),n.styleProps.delete(o),i=!0}return n.classes.size===0&&n.dataAttrs.size===0&&n.styleProps.size===0&&this.#e.delete(t),i}#j(t,n){for(const r of n.classes)n.priorClasses.has(r)||t.classList.remove(r);for(const r of n.dataAttrs.keys()){const i=n.priorDataAttrs.get(r);i!=null?t.setAttribute(r,i):t.removeAttribute(r)}for(const r of n.styleProps.keys()){const i=n.priorStyleProps.get(r);i?t.style.setProperty(r,i):t.style.removeProperty(r)}this.#e.delete(t)}},TX="interactionEpoch",IX="displayLabelSource",kX={CANONICAL:"canonical",DERIVED:"derived"};function $Tn(e,t){const n=e.dataset[ol.DISPLAY_LABEL],r=e.dataset[IX];if(n!==void 0&&r!==kX.DERIVED)return{source:kX.CANONICAL,value:n};const i=t?.textContent?.trim()??"";return i.length===0?null:{source:kX.DERIVED,value:i}}var eIn=class{#e=null;setContainer(e){this.#e=e}apply(e){if(!this.#e)return;const t=String(e),n=this.#e.querySelectorAll(JM());for(let r=0;r<n.length;r+=1){const i=n[r];if(i.dataset[TX]===t)continue;i.dataset[TX]=t,i.draggable=!0,i.dataset[ol.DRAGGABLE]="true";const o=$Tn(i,i.querySelector(`.${nn.ANNOTATION_CONTENT}`));o!==null&&(i.dataset[ol.DISPLAY_LABEL]=o.value,i.dataset[IX]=o.source);const s=i.dataset[ol.TYPE];s&&(i.dataset[ol.VARIANT]=s),this.#t(i)}}clear(){if(!this.#e)return;const e=this.#e.querySelectorAll(JM());for(let t=0;t<e.length;t+=1){const n=e[t];n.removeAttribute("draggable"),delete n.dataset[ol.DRAGGABLE],delete n.dataset[ol.DISPLAY_LABEL],delete n.dataset[ol.VARIANT],delete n.dataset[TX],delete n.dataset[IX],n.querySelector(`.${nn.ANNOTATION_CARET_ANCHOR}`)?.remove()}}#t(e){if(e.querySelector(`.${nn.ANNOTATION_CARET_ANCHOR}`))return;const t=e.dataset[ol.PM_END],n=e.dataset[ol.LAYOUT_EPOCH];if(t==null)return;const r=this.#e?.ownerDocument;if(!r)return;const i=r.createElement("span");i.dataset[ol.PM_START]=t,i.dataset[ol.PM_END]=t,i.dataset[ol.LAYOUT_EPOCH]=n??"",i.classList.add(nn.ANNOTATION_CARET_ANCHOR),i.style.position="absolute",i.style.left="100%",i.style.top="0",i.style.width="0",i.style.height="1em",i.style.overflow="hidden",i.style.pointerEvents="none",i.style.userSelect="none",i.style.opacity="0",i.textContent="",e.style.position||(e.style.position="relative"),e.appendChild(i)}},EX="imageInteractionEpoch";function W5e(e){return e&&e.trim().length>0?e:null}function G5e(e){const t=[],n=new Set,r=i=>{!i||n.has(i)||(n.add(i),t.push(i))};for(const i of Array.from(e.querySelectorAll(`.${nn.IMAGE_FRAGMENT}`)))!i.hasAttribute("data-image-metadata")&&i.querySelector?.("[data-image-metadata]")==null||r(i);for(const i of Array.from(e.querySelectorAll(`.${nn.INLINE_IMAGE_CLIP_WRAPPER}`)))i.querySelector?.("[data-image-metadata]")!=null&&r(i);for(const i of Array.from(e.querySelectorAll(`.${nn.INLINE_IMAGE}`)))i.hasAttribute("data-image-metadata")&&i.closest(`.${nn.INLINE_IMAGE_CLIP_WRAPPER}`)==null&&r(i);return t}function tIn(e){const t=e.dataset[ol.DISPLAY_LABEL];if(t)return t;const n=e.tagName==="IMG"?e:e.querySelector("img"),r=n?.getAttribute("alt")?.trim();if(r)return r;const i=n?.getAttribute("title")?.trim();return i||(e.getAttribute("data-block-id")??e.getAttribute("data-sd-block-id")??"Image")}function nIn(e){return e.classList.contains(nn.IMAGE_FRAGMENT)?"block":"inline"}var rIn=class{#e=null;setContainer(e){this.#e=e}apply(e){if(!this.#e)return;const t=String(e);for(const n of G5e(this.#e)){if(n.dataset[EX]===t)continue;const r=W5e(n.dataset.pmStart),i=W5e(n.dataset.pmEnd);!r||!i||(n.dataset[EX]=t,n.draggable=!0,n.dataset.dragSourceKind="existingImage",n.dataset.imageKind=nIn(n),n.dataset.nodeType="image",n.dataset.displayLabel=tIn(n),n.dataset.pmStart=r,n.dataset.pmEnd=i)}}clear(){if(this.#e)for(const e of G5e(this.#e))e.removeAttribute("draggable"),delete e.dataset.dragSourceKind,delete e.dataset.imageKind,delete e.dataset.nodeType,delete e.dataset.displayLabel,delete e.dataset[EX]}},j5e=".superdoc-structured-content__label",q5e=`.${nn.INLINE_SDT_WRAPPER}__label`,CX="structuredContentInteractionEpoch",iIn=class{#e=null;setContainer(e){this.#e=e}apply(e){if(!this.#e)return;const t=Array.from(this.#e.querySelectorAll(`${j5e}, ${q5e}`));for(const n of t){if(n.dataset[CX]===String(e))continue;const r=n.closest(`.${nn.BLOCK_SDT}, .${nn.INLINE_SDT_WRAPPER}`);if(!r?.dataset.sdtId||!r.dataset.pmStart||!r.dataset.pmEnd)continue;const i=r.dataset.lockMode??"unlocked";if(i!=="unlocked"){n.draggable=!1;continue}const o=r.dataset.sdtScope??(r.classList.contains(nn.BLOCK_SDT)?"block":"inline"),s=n.textContent?.trim()||"Structured content";n.dataset[CX]=String(e),n.draggable=!0,n.dataset.dragSourceKind="structuredContent",n.dataset.sdtId=r.dataset.sdtId,n.dataset.pmStart=r.dataset.pmStart,n.dataset.pmEnd=r.dataset.pmEnd,n.dataset.sdtScope=o,n.dataset.lockMode=i,n.dataset[ol.DISPLAY_LABEL]=s,n.dataset.nodeType=o==="block"?"structuredContentBlock":"structuredContent"}}clear(){if(!this.#e)return;const e=Array.from(this.#e.querySelectorAll(`${j5e}, ${q5e}`));for(const t of e)t.removeAttribute("draggable"),delete t.dataset.dragSourceKind,delete t.dataset.sdtId,delete t.dataset.pmStart,delete t.dataset.pmEnd,delete t.dataset.sdtScope,delete t.dataset.lockMode,delete t.dataset.nodeType,delete t.dataset[ol.DISPLAY_LABEL],delete t.dataset[CX]}};const sl={SPELLING:"sd-proofing-spelling",GRAMMAR:"sd-proofing-grammar",STYLE:"sd-proofing-style",DATA_ATTR:"data-sd-proofing",SPLIT_ATTR:"data-sd-proofing-split"};function Y5e(e){switch(e){case"spelling":return sl.SPELLING;case"grammar":return sl.GRAMMAR;case"style":return sl.STYLE}}var K5e=new WeakMap;function oIn(e,t,n,r){const i=new Set;i.add(e),i.add(t);for(const a of r){const l=Math.max(a.pmFrom,e),c=Math.min(a.pmTo,t);l>e&&i.add(l),c<t&&i.add(c)}const o=Array.from(i).sort((a,l)=>a-l),s=[];for(let a=0;a<o.length-1;a+=1){const l=o[a],c=o[a+1],u=l-e,d=c-e;if(d<=u||u>=n.length)continue;const f=Math.min(d,n.length);let h=null;for(const p of r)if(p.pmFrom<=l&&p.pmTo>=c){h=Y5e(p.kind);break}s.push({textStart:u,textEnd:f,pmStart:l,pmEnd:c,proofingClass:h})}return s}function sIn(e,t,n){const r=e.parentNode;if(!r)return[];const i=e.ownerDocument,o=[];for(const l of t){const c=n.slice(l.textStart,l.textEnd);if(c.length===0)continue;const u=i.createElement("span");for(let d=0;d<e.attributes.length;d+=1){const f=e.attributes[d];u.setAttribute(f.name,f.value)}u.setAttribute("data-pm-start",String(l.pmStart)),u.setAttribute("data-pm-end",String(l.pmEnd)),l.proofingClass&&(u.classList.add(l.proofingClass),u.setAttribute("aria-invalid","spelling")),u.setAttribute(sl.SPLIT_ATTR,""),u.setAttribute(sl.DATA_ATTR,""),u.textContent="",u.appendChild(i.createTextNode(c)),K5e.set(u,e),o.push(u)}e.style.display="none",e.setAttribute(sl.DATA_ATTR,"original");const s=e.getAttribute("data-pm-start"),a=e.getAttribute("data-pm-end");s&&e.setAttribute("data-sd-orig-pm-start",s),a&&e.setAttribute("data-sd-orig-pm-end",a),e.removeAttribute("data-pm-start"),e.removeAttribute("data-pm-end");for(const l of o)r.insertBefore(l,e);return o}function aIn(e){const t=Array.from(e.querySelectorAll(`[${sl.SPLIT_ATTR}]`));if(t.length===0)return!1;const n=new Map;for(const o of t){const s=K5e.get(o);if(!s)continue;const a=n.get(s);a?a.push(o):n.set(s,[o])}for(const[o,s]of n){const a=o.parentNode;if(a){X5e(o);for(const l of s)a.removeChild(l)}}const r=Array.from(e.querySelectorAll(`[${sl.SPLIT_ATTR}]`));for(const o of r)o.parentNode?.removeChild(o);const i=Array.from(e.querySelectorAll(`[${sl.DATA_ATTR}="original"]`));for(const o of i)X5e(o);return!0}function X5e(e){e.style.display="",e.style.cssText||e.removeAttribute("style"),e.removeAttribute(sl.DATA_ATTR);const t=e.getAttribute("data-sd-orig-pm-start"),n=e.getAttribute("data-sd-orig-pm-end");t&&(e.setAttribute("data-pm-start",t),e.removeAttribute("data-sd-orig-pm-start")),n&&(e.setAttribute("data-pm-end",n),e.removeAttribute("data-sd-orig-pm-end"))}function lIn(e,t){const n=_X(e);if(t.length===0)return n;const r=[...t].sort((s,a)=>s.pmFrom-a.pmFrom),i=Array.from(e.querySelectorAll("[data-pm-start][data-pm-end]"));let o=!1;for(const s of i){const a=Number.parseInt(s.getAttribute("data-pm-start")??"",10),l=Number.parseInt(s.getAttribute("data-pm-end")??"",10);if(Number.isNaN(a)||Number.isNaN(l)||l<=a||!cIn(s))continue;const c=uIn(r,a,l);if(c.length===0)continue;const u=s.textContent??"";if(u.length===0)continue;if(dIn(a,l,c)){s.classList.add(Y5e(c[0].kind)),s.setAttribute(sl.DATA_ATTR,""),s.setAttribute("aria-invalid","spelling"),o=!0;continue}const d=oIn(a,l,u,c);if(d.length>1){sIn(s,d,u),o=!0;continue}d.length===1&&d[0].proofingClass&&(s.classList.add(d[0].proofingClass),s.setAttribute(sl.DATA_ATTR,""),s.setAttribute("aria-invalid","spelling"),o=!0)}return o||n}function _X(e){let t=!1;const n=aIn(e),r=Array.from(e.querySelectorAll(`[${sl.DATA_ATTR}]`));for(const i of r)i.classList.remove(sl.SPELLING,sl.GRAMMAR,sl.STYLE),i.removeAttribute(sl.DATA_ATTR),i.removeAttribute("aria-invalid"),t=!0;return t||n}function cIn(e){const t=e.childNodes;if(t.length===0)return!1;for(let n=0;n<t.length;n+=1)if(t[n].nodeType===Node.ELEMENT_NODE)return!1;return!0}function uIn(e,t,n){const r=[];for(const i of e){if(i.pmFrom>=n)break;i.pmTo>t&&r.push(i)}return r}function dIn(e,t,n){return n.some(r=>r.pmFrom<=e&&r.pmTo>=t)}var fIn=class{#e=null;setContainer(e){this.#e=e}applyAnnotations(e){const t=this.#e;return t?!e||e.length===0?_X(t):lIn(t,e):!1}clear(){const e=this.#e;return e?_X(e):!1}},hIn=class{#e;#t;#i;#n;#r;#o;constructor(e={}){this.#e=e.fieldAnnotationLayer??new eIn,this.#t=e.imageLayer??new rIn,this.#i=e.structuredContentLayer??new iIn,this.#n=e.commentHighlightDecorator??new jTn,this.#r=e.decorationBridge??new QTn,this.#o=e.proofingDecorator??new fIn}setContainer(e){this.#e.setContainer(e),this.#t.setContainer(e),this.#i.setContainer(e),this.#n.setContainer(e),this.#o.setContainer(e)}setActiveComment(e){return this.#n.setActiveComment(e)}recordDecorationTransaction(e){this.#r.recordTransaction(e)}hasDecorationChanges(e){return this.#r.hasChanges(e)}hasCurrentDecorationRanges(e){return this.#r.hasCurrentRanges(e)}collectDecorationRanges(e){return this.#r.collectDecorationRanges(e)}syncDecorations(e,t,n){return e?this.#r.sync(e,t,n):!1}applyCommentHighlights(){this.#n.apply()}syncInlineStyleLayers(e,t){return this.applyCommentHighlights(),this.syncDecorations(e,t)}applyProofingAnnotations(e,t){const n=this.#o.applyAnnotations(e);return n&&t(),n}refreshAfterPaint(e){this.#e.apply(e.layoutEpoch),e.rebuildDomPositionIndex(),this.#t.apply(e.layoutEpoch),this.#i.apply(e.layoutEpoch),this.syncInlineStyleLayers(e.editorState,e.domPositionIndex),this.applyProofingAnnotations(e.proofingAnnotations,e.rebuildDomPositionIndex),e.reapplyStructuredContentHover?.()}destroy(){this.#o.clear(),this.#e.clear(),this.#t.clear(),this.#i.clear(),this.#n.destroy(),this.#r.destroy()}},pIn=class{#e=new Map;addIssue(e){const t=this.#e.get(e.segmentId);t?t.push(e):this.#e.set(e.segmentId,[e])}remapIssues(e,t,n){for(const r of e){const i=this.#e.get(r);if(!i)continue;const o=[];for(const s of i){const a=t.mapResult(s.pmFrom,-1),l=t.mapResult(s.pmTo,1);a.deleted||l.deleted||a.pos>=l.pos||(s.pmFrom=a.pos,s.pmTo=l.pos,s.state="mapped",s.recheckId=n,o.push(s))}o.length>0?this.#e.set(r,o):this.#e.delete(r)}}replaceBatchResults(e,t,n){for(const r of t){const i=this.#e.get(r);if(!i)continue;const o=i.filter(s=>s.recheckId===null||!e.has(s.recheckId));o.length>0?this.#e.set(r,o):this.#e.delete(r)}for(const r of n)this.addIssue(r)}removeBySegmentIds(e){for(const t of e)this.#e.delete(t)}removeOrphanedSegments(e){for(const t of this.#e.keys())e.has(t)||this.#e.delete(t)}clear(){this.#e.clear()}getAllIssues(){const e=[];for(const t of this.#e.values())e.push(...t);return e}getDisplayIssues(e){const t=new Set(e.map(r=>r.normalize("NFC").toLowerCase())),n=[];for(const r of this.#e.values())for(const i of r)i.kind==="spelling"&&(mIn(i,t)||n.push(i));return n}getActiveRecheckIds(){const e=new Set;for(const t of this.#e.values())for(const n of t)n.state==="mapped"&&n.recheckId!==null&&e.add(n.recheckId);return e}get isEmpty(){return this.#e.size===0}get size(){let e=0;for(const t of this.#e.values())e+=t.length;return e}};function mIn(e,t){if(t.size===0)return!1;const n=e.word??e.message;if(!n)return!1;const r=n.normalize("NFC").toLowerCase();return t.has(r)}function gIn(e,t){const n=yIn(e);if(n)return n;const r=bIn(e);return r||t}function yIn(e){let t=null;return e.descendants(n=>{if(t)return!1;if(n.type.name==="run"){const r=n.attrs.runProperties;if(r?.lang?.val)return t=r.lang.val,!1}return!0}),t}function bIn(e){return e.attrs.paragraphProperties?.lang?.val??null}function J5e(e,t,n){const r=[],i=new Map,o=new Map;return vIn(e,(s,a,l)=>{const{text:c,slices:u}=AIn(s,a);if(c.length===0)return;const d=IIn(s,a),f=gIn(s,t??null),h=n?.(a);r.push({id:d,text:c,language:f,metadata:{blockId:s.attrs.sdBlockId,pageIndex:h,surface:l}}),i.set(d,{segmentId:d,slices:u}),o.set(d,a)}),{segments:r,offsetMaps:i,segmentPositions:o}}function vIn(e,t){e.descendants((n,r)=>{const i=n.type.name;return i==="header"||i==="footer"?!1:i==="paragraph"?(t(n,r,wIn(e,r)?"table-cell":"body"),!1):!0})}function wIn(e,t){const n=e.resolve(t);for(let r=n.depth;r>0;r--){const i=n.node(r);if(i.type.name==="tableCell"||i.type.name==="tableHeader")return!0}return!1}function AIn(e,t){const n=[],r=[];let i=0;const o=t+1;return e.forEach((l,c)=>{s(l,o+c)}),{text:n.join(""),slices:r};function s(l,c){const u=l.type.name;if(u==="run"){const d=l.attrs.runProperties;if(d?.vanish===!0){a();return}if(d?.noProof===!0){a();return}const f=c+1;l.forEach((h,p)=>{s(h,f+p)});return}if(l.isText&&l.text){if(xIn(l))return;const d=l.text,f=c,h=c+d.length;r.push({textStart:i,textEnd:i+d.length,pmFrom:f,pmTo:h}),n.push(d),i+=d.length;return}if(TIn(u)){a();return}if(l.childCount>0){const d=c+1;l.forEach((f,h)=>{s(f,d+h)})}}function a(){n.length>0&&!n[n.length-1].endsWith(" ")&&(n.push(" "),i+=1)}}function xIn(e){return e.marks?.some(t=>t.type.name==="trackDelete")??!1}var SIn=new Set(["fieldAnnotation","image","equation","hardBreak","lineBreak","tab","footnoteReference","symbol"]);function TIn(e){return SIn.has(e)}function IIn(e,t){const n=e.attrs.sdBlockId;return n?`blk-${n}`:`pos-${t}`}function kIn(e,t){const n=Z5e(e.start,t),r=Z5e(e.end,t);return n===null||r===null||n>=r?null:{...e,pmFrom:n,pmTo:r}}function Z5e(e,t){for(const n of t)if(e>=n.textStart&&e<=n.textEnd){const r=e-n.textStart;return n.pmFrom+r}for(const n of t)if(n.textStart>=e)return n.pmFrom;if(t.length>0){const n=t[t.length-1];if(e>=n.textEnd)return n.pmTo}return null}function EIn(e,t,n){if(n.length===0)return new Set;const r=new Set,i=e.map(o=>({id:o.id,pos:t.get(o.id)??-1})).filter(o=>o.pos>=0).sort((o,s)=>o.pos-s.pos);for(const o of n)for(let s=0;s<i.length;s++){const a=i[s],l=i[s+1]?.pos??1/0;a.pos<o.to&&l>o.from&&r.add(a.id),a.pos<=o.from&&l>=o.from&&s>0&&r.add(i[s-1].id)}return r}function Q5e(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function CIn(e,t){const n=t.getVisiblePageIndices();if(!n||n.length===0)return e;const r=new Set(n),i=[],o=[];for(const s of e){const a=s.metadata.pageIndex;a!==void 0&&r.has(a)?i.push(s):o.push(s)}return[...i,...o]}function _In(e){const t=e.filter(o=>o.kind==="spelling");if(t.length===0)return[];const n=[...t].sort((o,s)=>o.pmFrom-s.pmFrom||o.pmTo-s.pmTo),r=[];let i=null;for(const o of n){if(!i){i={pmFrom:o.pmFrom,pmTo:o.pmTo,kind:"spelling",issue:o};continue}o.pmFrom<=i.pmTo?i.pmTo=Math.max(i.pmTo,o.pmTo):(r.push(i),i={pmFrom:o.pmFrom,pmTo:o.pmTo,kind:"spelling",issue:o})}return i&&r.push(i),r}function PIn(e,t){let n=0,r=e.length-1;for(;n<=r;){const i=n+r>>>1,o=e[i];if(t<o.pmFrom)r=i-1;else if(t>=o.pmTo)n=i+1;else return o}return null}var RIn=500,LIn=2e3,NIn=1e4,MIn=2,DIn=20,OIn=5,$5e=class{#e;#t=null;#i=null;#n="disabled";#r=new pIn;#o=new Map;#l=new Map;#c=null;#u=new Set;#d=0;#f=0;#a=!1;#s=[];#w=0;#y=!1;#x=0;#N=null;#S=null;#g=null;#b=null;#h=[];constructor(e={}){this.onResultsChanged=null,this.#e={enabled:e.enabled??!1,debounceMs:e.debounceMs??RIn,maxSuggestions:e.maxSuggestions??OIn,visibleFirst:e.visibleFirst??!0,allowIgnoreWord:e.allowIgnoreWord??!0,defaultLanguage:e.defaultLanguage??null,ignoredWords:e.ignoredWords??[],timeoutMs:e.timeoutMs??NIn,maxConcurrentRequests:e.maxConcurrentRequests??MIn,maxSegmentsPerBatch:e.maxSegmentsPerBatch??DIn,onProofingError:e.onProofingError??null,onStatusChange:e.onStatusChange??null},e.provider&&(this.#t=e.provider),this.#e.enabled&&this.#t&&this.#T("idle")}get status(){return this.#n}get isEnabled(){return this.#e.enabled&&this.#t!==null}get config(){return this.#e}setVisibilitySource(e){this.#N=e}setDocumentId(e){this.#S=e}setPageResolver(e){this.#g=e}setComposing(e){this.#y=e,!e&&this.#h.length>0&&this.isEnabled&&this.#C(this.#h)}getPaintSlices(e){if(!this.isEnabled)return[];const t=_In(this.#r.getDisplayIssues(this.#e.ignoredWords));return e?t.filter(n=>n.pmTo<=e.from||n.pmFrom>=e.to):t}getIssueAtPosition(e,t){return PIn(this.getPaintSlices(t),e)?.issue??null}updateConfig(e,t){const n=this.#e.enabled,r=this.#t,i=e.provider!==void 0||e.defaultLanguage!==void 0;if(e.debounceMs!==void 0&&(this.#e.debounceMs=e.debounceMs),e.maxSuggestions!==void 0&&(this.#e.maxSuggestions=e.maxSuggestions),e.visibleFirst!==void 0&&(this.#e.visibleFirst=e.visibleFirst),e.allowIgnoreWord!==void 0&&(this.#e.allowIgnoreWord=e.allowIgnoreWord),e.timeoutMs!==void 0&&(this.#e.timeoutMs=e.timeoutMs),e.maxConcurrentRequests!==void 0&&(this.#e.maxConcurrentRequests=e.maxConcurrentRequests),e.maxSegmentsPerBatch!==void 0&&(this.#e.maxSegmentsPerBatch=e.maxSegmentsPerBatch),e.onProofingError!==void 0&&(this.#e.onProofingError=e.onProofingError??null),e.onStatusChange!==void 0&&(this.#e.onStatusChange=e.onStatusChange??null),e.defaultLanguage!==void 0&&(this.#e.defaultLanguage=e.defaultLanguage??null),e.ignoredWords!==void 0&&(this.#e.ignoredWords=e.ignoredWords??[],this.onResultsChanged?.()),e.provider!==void 0&&(r&&r!==e.provider&&r.dispose?.(),this.#t=e.provider??null,this.#i=null),e.enabled!==void 0){if(this.#e.enabled=e.enabled,!e.enabled){this.#P(),this.#r.clear(),this.#l.clear(),this.#o.clear(),this.#T("disabled"),this.onResultsChanged?.();return}if(e.enabled&&!n&&t){this.#T("idle"),this.#v(t);return}}i&&this.isEnabled&&t&&(this.#P(),this.#f++,this.#r.clear(),this.#l.clear(),this.onResultsChanged?.(),this.#v(t))}onDocumentChanged(e,t,n){if(!this.isEnabled)return;this.#f++,this.#b=e;const{segments:r,offsetMaps:i,segmentPositions:o}=J5e(e,this.#e.defaultLanguage,this.#g??void 0);this.#h=r,this.#o=i;const s=EIn(r,o,t);for(const a of s)this.#l.delete(a);if(s.size>0){const a=this.#w++;this.#r.remapIssues(s,n,a),this.#r.removeOrphanedSegments(new Set(r.map(l=>l.id)))}this.#C(r)}runInitialCheck(e){this.isEnabled&&this.#v(e)}ignoreWord(e){const t=e.normalize("NFC").toLowerCase();this.#e.ignoredWords.includes(t)||(this.#e.ignoredWords=[...this.#e.ignoredWords,t],this.onResultsChanged?.())}removeIgnoredWord(e){const t=e.normalize("NFC").toLowerCase();this.#e.ignoredWords=this.#e.ignoredWords.filter(n=>n!==t),this.onResultsChanged?.()}dispose(){this.#a=!0,this.#P(),this.#r.clear(),this.#o.clear(),this.#l.clear(),this.#b=null,this.#h=[],this.#s=[],this.#t?.dispose?.(),this.#t=null,this.#T("disabled")}#v(e){this.#b=e;const{segments:t,offsetMaps:n}=J5e(e,this.#e.defaultLanguage,this.#g??void 0);this.#h=t,this.#o=n,this.#l.clear(),this.#r.clear(),this.#C(t)}#C(e){if(this.#y)return;this.#c!==null&&clearTimeout(this.#c);const t=Date.now()-this.#x;this.#x>0&&t>=LIn?this.#k(e):this.#c=setTimeout(()=>{this.#c=null,this.#k(e)},this.#e.debounceMs)}#k(e){this.#x=Date.now(),this.#A(e)}async#A(e){if(this.#a||!this.#t)return;if(!this.#i&&this.#t.getCapabilities)try{this.#i=await this.#t.getCapabilities()}catch{}const t=e.filter(s=>{const a=Q5e(s.text);return this.#l.get(s.id)!==a});if(t.length===0){this.#T("idle");return}const n=this.#r.getActiveRecheckIds(),r=this.#e.visibleFirst&&this.#N?CIn(t,this.#N):t,i=this.#I(r),o=this.#f;this.#s=[];for(let s=0;s<i.length;s++){if(this.#a||o!==this.#f)return;if(this.#d>=this.#e.maxConcurrentRequests){for(let a=s;a<i.length;a++)this.#s.push(...i[a]);break}this.#_(i[s],o,n)}}async#_(e,t,n){if(!this.#t||this.#a)return;const r=new AbortController;this.#u.add(r),this.#d++,this.#T("checking");const i=setTimeout(()=>r.abort(),this.#e.timeoutMs),o={documentId:this.#S,defaultLanguage:this.#e.defaultLanguage,maxSuggestions:this.#e.maxSuggestions,segments:e,signal:r.signal};try{const s=await this.#t.check(o);if(clearTimeout(i),!this.#u.delete(r))return;if(this.#d--,t!==this.#f||this.#a){this.#E();return}const a=new Set(e.map(u=>u.id)),l=new Map(e.map(u=>[u.id,u])),c=[];for(const u of s.issues){if(!this.#D(u,a,l))continue;const d=this.#o.get(u.segmentId);if(!d)continue;const f=kIn(u,d.slices);if(!f)continue;const h=l.get(u.segmentId),p={...f,state:"confirmed",recheckId:null};h&&(p.word=h.text.slice(u.start,u.end)),c.push(p)}this.#r.replaceBatchResults(n,a,c);for(const u of e)this.#l.set(u.id,Q5e(u.text));this.#T(this.#d>0?"checking":"idle"),this.onResultsChanged?.(),this.#m(t,n)}catch(s){if(clearTimeout(i),!this.#u.delete(r)||(this.#d--,this.#a))return;if(t!==this.#f){this.#E();return}const a=r.signal.aborted,l={kind:a?"timeout":"provider-error",message:a?"Provider request timed out":String(s),segmentIds:e.map(c=>c.id),cause:s};this.#e.onProofingError?.(l),this.#T(this.#d>0?"checking":"degraded"),this.#m(t,n)}}#m(e,t){if(this.#a||e!==this.#f||this.#s.length===0||this.#d>=this.#e.maxConcurrentRequests)return;const n=this.#s.splice(0,this.#e.maxSegmentsPerBatch);n.length>0&&this.#_(n,e,t)}#E(){this.#a||this.#s.length===0||this.#m(this.#f,this.#r.getActiveRecheckIds())}#D(e,t,n){if(!t.has(e.segmentId))return this.#R(`Unknown segmentId: ${e.segmentId}`,[e.segmentId]),!1;const r=n.get(e.segmentId);return r?e.start<0||e.end<=e.start||e.end>r.text.length?(this.#R(`Invalid offsets [${e.start}, ${e.end}) for segment "${e.segmentId}" (length ${r.text.length})`,[e.segmentId]),!1):!0:!1}#R(e,t){this.#e.onProofingError?.({kind:"validation-error",message:e,segmentIds:t})}#I(e){const t=[];for(let n=0;n<e.length;n+=this.#e.maxSegmentsPerBatch)t.push(e.slice(n,n+this.#e.maxSegmentsPerBatch));return t}#P(){this.#c!==null&&(clearTimeout(this.#c),this.#c=null);for(const e of this.#u)e.abort();this.#u.clear(),this.#d=0,this.#s=[]}#T(e){this.#n!==e&&(this.#n=e,this.#e.onStatusChange?.(e))}};const FIn=Object.freeze({swiss:"Arial, sans-serif",roman:"Times New Roman, serif",modern:"Courier New, monospace",script:"cursive",decorative:"fantasy",system:"system-ui",auto:"sans-serif"}),eOe="sans-serif";var BIn=new Set(["cambria","cambria math","times","times new roman","georgia","garamond","palatino","palatino linotype","book antiqua","baskerville","cochin","hoefler text","minion pro","didot","bodoni mt","constantia"]),HIn=e=>!e||typeof e!="string"?"":e.trim().replace(/^["']|["']$/g,"").toLowerCase(),zIn=e=>BIn.has(HIn(e))?"serif":eOe,UIn=e=>(e||"").split(",").map(t=>t.trim()).filter(Boolean),VIn=(e,t)=>{if(!e.includes('"')&&!e.includes("'"))return e.split(t).map(s=>s.trim()).filter(Boolean);const n=[];let r="",i=!1,o=null;for(const s of e)!i&&(s==='"'||s==="'")?(i=!0,o=s,r+=s):i&&s===o?(i=!1,o=null,r+=s):!i&&s===t?(r.trim()&&n.push(r.trim()),r=""):r+=s;return r.trim()&&n.push(r.trim()),n};function WIn(e){return e?FIn[e.toLowerCase()]||"sans-serif":eOe}function r0(e,t={}){if(!e||typeof e!="string")return e;let n=e.trim();if(!n||n.includes(","))return n;n.includes(";")&&(n=VIn(n,";").join(", "));const{fallback:r,wordFamily:i}=t,o=UIn(r??(i?WIn(i):void 0)??zIn(n));if(o.length===0)return n;const s=n.toLowerCase();return o.some(a=>a.toLowerCase()===s)?o.join(", "):[n,...o].join(", ")}var tOe=20,Db=500,i0=5e3,Ll=["#4472C4","#ED7D31","#A5A5A5","#FFC000","#5B9BD5","#70AD47"],o0="#595959",wC="#E0E0E0",AC="#333",T5="#666",yu="Calibri, Arial, sans-serif",GIn="#f8f9fa",jIn="#dee2e6",nOe="#6c757d",Lr="http://www.w3.org/2000/svg",Hn={top:30,right:20,bottom:50,left:60},bu=5;function qIn(e,t,n){const r=e.createElement("div");return r.classList.add("superdoc-chart"),r.style.width="100%",r.style.height="100%",r.style.position="relative",!t||!t.series?.length?Nl(e,r,"No chart data"):t.chartType==="barChart"?akn(e,r,t,n):t.chartType==="lineChart"||t.chartType==="stockChart"?bOe(e,r,t,n):t.chartType==="areaChart"?rkn(e,r,t,n):t.chartType==="scatterChart"?QIn(e,r,t,n):t.chartType==="bubbleChart"?$In(e,r,t,n):t.chartType==="radarChart"?tkn(e,r,t,n):t.chartType==="pieChart"?yOe(e,r,t,n):t.chartType==="doughnutChart"?okn(e,r,t,n):t.chartType==="ofPieChart"?yOe(e,r,t,n):Nl(e,r,`Chart: ${t.chartType}`)}function Nl(e,t,n){t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.background=GIn,t.style.border=`1px solid ${jIn}`,t.style.borderRadius="4px",t.style.color=nOe,t.style.fontSize="13px",t.style.fontFamily=yu;const r=e.createElement("span");r.textContent="📊 ",t.appendChild(r);const i=e.createElement("span");return i.textContent=n,t.appendChild(i),t}function I5(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:Number.isInteger(e)?String(e):e.toFixed(1)}function zx(e){let t=!1,n=e.series;return n.length>tOe&&(n=n.slice(0,tOe),t=!0),n=n.map(r=>r.values.length<=Db&&r.categories.length<=Db?r:(t=!0,{name:r.name,categories:r.categories.slice(0,Db),values:r.values.slice(0,Db),...r.xValues&&{xValues:r.xValues.slice(0,Db)},...r.bubbleSizes&&{bubbleSizes:r.bubbleSizes.slice(0,Db)}})),{series:n,truncated:t}}function YIn(e,t,n){const r=Math.max(1,e-Hn.left-Hn.right),i=Math.max(1,t-Hn.top-Hn.bottom),o=n.flatMap(m=>m.values),s=Math.max(0,...o),a=Math.min(0,...o),l=Math.max(1,s-a),c=n[0]?.categories??[],u=Math.max(1,c.length),d=n.length,f=r/u,h=Math.max(1,f*.1),p=f-h*2;return{plotWidth:r,plotHeight:i,groupWidth:f,barWidth:Math.max(1,p/d),barGap:h,baselineY:Hn.top+i*(s/l),valueRange:l,minValue:a,maxValue:s}}function KIn(e,t,n,r){const{groupWidth:i,barGap:o,barWidth:s,baselineY:a,valueRange:l,plotHeight:c}=r;for(let u=0;u<n.length;u++){const d=n[u],f=Ll[u%Ll.length];for(let h=0;h<d.values.length;h++){const p=d.values[h],m=Math.abs(p/l)*c,g=Hn.left+h*i+o+u*s,y=p>=0?a-m:a,v=e.createElementNS(Lr,"rect");v.setAttribute("x",String(g)),v.setAttribute("y",String(y)),v.setAttribute("width",String(s)),v.setAttribute("height",String(Math.max(.5,m))),v.setAttribute("fill",f),t.appendChild(v)}}}function XIn(e,t,n){const{plotWidth:r,plotHeight:i,baselineY:o}=n,s=e.createElementNS(Lr,"line");s.setAttribute("x1",String(Hn.left)),s.setAttribute("y1",String(Hn.top)),s.setAttribute("x2",String(Hn.left)),s.setAttribute("y2",String(Hn.top+i)),s.setAttribute("stroke",o0),s.setAttribute("stroke-width","1"),t.appendChild(s);const a=e.createElementNS(Lr,"line");a.setAttribute("x1",String(Hn.left)),a.setAttribute("y1",String(o)),a.setAttribute("x2",String(Hn.left+r)),a.setAttribute("y2",String(o)),a.setAttribute("stroke",o0),a.setAttribute("stroke-width","1"),t.appendChild(a)}function JIn(e,t,n,r,i){const{groupWidth:o,plotHeight:s}=r,a=Math.max(1,n.length),l=Math.max(8,Math.min(12,i/a/5));for(let c=0;c<n.length;c++){const u=Hn.left+c*o+o/2,d=e.createElementNS(Lr,"text");d.setAttribute("x",String(u)),d.setAttribute("y",String(Hn.top+s+16)),d.setAttribute("text-anchor","middle"),d.setAttribute("font-size",String(l)),d.setAttribute("fill",AC),d.setAttribute("font-family",yu),d.textContent=n[c]??"",t.appendChild(d)}}function ZIn(e,t,n,r){const{plotWidth:i,plotHeight:o,valueRange:s,minValue:a}=n,l=s/bu,c=Math.max(8,Math.min(11,r/30));for(let u=0;u<=bu;u++){const d=a+l*u,f=Hn.top+o-o*(d-a)/s,h=e.createElementNS(Lr,"text");if(h.setAttribute("x",String(Hn.left-6)),h.setAttribute("y",String(f+3)),h.setAttribute("text-anchor","end"),h.setAttribute("font-size",String(c)),h.setAttribute("fill",T5),h.setAttribute("font-family",yu),h.textContent=I5(d),t.appendChild(h),u>0&&u<bu){const p=e.createElementNS(Lr,"line");p.setAttribute("x1",String(Hn.left)),p.setAttribute("y1",String(f)),p.setAttribute("x2",String(Hn.left+i)),p.setAttribute("y2",String(f)),p.setAttribute("stroke",wC),p.setAttribute("stroke-width","0.5"),t.appendChild(p)}}}function Ux(e,t,n,r){const i=r-12;let o=Hn.left;for(let s=0;s<n.length;s++){const a=n[s],l=Ll[s%Ll.length],c=e.createElementNS(Lr,"rect");c.setAttribute("x",String(o)),c.setAttribute("y",String(i-8)),c.setAttribute("width","10"),c.setAttribute("height","10"),c.setAttribute("fill",l),t.appendChild(c);const u=e.createElementNS(Lr,"text");u.setAttribute("x",String(o+14)),u.setAttribute("y",String(i)),u.setAttribute("font-size","10"),u.setAttribute("fill",AC),u.setAttribute("font-family",yu),u.textContent=a.name,t.appendChild(u),o+=14+a.name.length*6+16}}function s0(e,t,n){const r=e.createElementNS(Lr,"text");r.setAttribute("x",String(n-8)),r.setAttribute("y","14"),r.setAttribute("text-anchor","end"),r.setAttribute("font-size","10"),r.setAttribute("fill",nOe),r.setAttribute("font-family",yu),r.textContent="Data truncated for display",t.appendChild(r)}function rOe(e,t,n,r=!1){const i=Math.max(1,e-Hn.left-Hn.right),o=Math.max(1,t-Hn.top-Hn.bottom),s=n.flatMap(p=>p.values).filter(p=>Number.isFinite(p));let a=s.length?Math.min(...s):0,l=s.length?Math.max(...s):1;r&&(a=Math.min(0,a),l=Math.max(0,l)),l===a&&(a-=1,l+=1);const c=Math.max(1,l-a),u=(0-a)/c,d=Math.max(0,Math.min(1,u)),f=Hn.top+o-o*d,h=Math.max(1,n[0]?.categories?.length??n[0]?.values?.length??1);return{plotWidth:i,plotHeight:o,minValue:a,maxValue:l,valueRange:c,baselineY:f,categoryCount:h}}function Vx(e,t){return e.categoryCount<=1?Hn.left+e.plotWidth/2:Hn.left+e.plotWidth*t/(e.categoryCount-1)}function PX(e,t){return Hn.top+e.plotHeight-(t-e.minValue)/e.valueRange*e.plotHeight}function iOe(e,t,n){const r=e.createElementNS(Lr,"line");r.setAttribute("x1",String(Hn.left)),r.setAttribute("y1",String(Hn.top)),r.setAttribute("x2",String(Hn.left)),r.setAttribute("y2",String(Hn.top+n.plotHeight)),r.setAttribute("stroke",o0),r.setAttribute("stroke-width","1"),t.appendChild(r);const i=e.createElementNS(Lr,"line");i.setAttribute("x1",String(Hn.left)),i.setAttribute("y1",String(n.baselineY)),i.setAttribute("x2",String(Hn.left+n.plotWidth)),i.setAttribute("y2",String(n.baselineY)),i.setAttribute("stroke",o0),i.setAttribute("stroke-width","1"),t.appendChild(i)}function oOe(e,t,n,r,i){const o=n.length?n:Array.from({length:r.categoryCount},(l,c)=>String(c+1)),s=Math.max(1,o.length),a=Math.max(8,Math.min(12,i/s/4));for(let l=0;l<o.length;l++){const c=e.createElementNS(Lr,"text");c.setAttribute("x",String(Vx(r,l))),c.setAttribute("y",String(Hn.top+r.plotHeight+16)),c.setAttribute("text-anchor","middle"),c.setAttribute("font-size",String(a)),c.setAttribute("fill",AC),c.setAttribute("font-family",yu),c.textContent=o[l]??"",t.appendChild(c)}}function sOe(e,t,n,r){const i=n.valueRange/bu,o=Math.max(8,Math.min(11,r/30));for(let s=0;s<=bu;s++){const a=n.minValue+i*s,l=Hn.top+n.plotHeight-n.plotHeight*(a-n.minValue)/n.valueRange,c=e.createElementNS(Lr,"text");if(c.setAttribute("x",String(Hn.left-6)),c.setAttribute("y",String(l+3)),c.setAttribute("text-anchor","end"),c.setAttribute("font-size",String(o)),c.setAttribute("fill",T5),c.setAttribute("font-family",yu),c.textContent=I5(a),t.appendChild(c),s>0&&s<bu){const u=e.createElementNS(Lr,"line");u.setAttribute("x1",String(Hn.left)),u.setAttribute("y1",String(l)),u.setAttribute("x2",String(Hn.left+n.plotWidth)),u.setAttribute("y2",String(l)),u.setAttribute("stroke",wC),u.setAttribute("stroke-width","0.5"),t.appendChild(u)}}}function aOe(e){const t=e.values,n=e.xValues?.length?e.xValues:t.map((s,a)=>a+1),r=e.bubbleSizes??[],i=Math.min(n.length,t.length),o=[];for(let s=0;s<i;s++){const a=n[s],l=t[s];if(!Number.isFinite(a)||!Number.isFinite(l))continue;const c=r[s];o.push({x:a,y:l,...Number.isFinite(c)?{size:c}:{}})}return o}function lOe(e,t,n,r=!1){const i=Math.max(1,e-Hn.left-Hn.right),o=Math.max(1,t-Hn.top-Hn.bottom);let s=n.length?Math.min(...n.map(g=>g.x)):0,a=n.length?Math.max(...n.map(g=>g.x)):1,l=n.length?Math.min(...n.map(g=>g.y)):0,c=n.length?Math.max(...n.map(g=>g.y)):1;r&&(s=Math.min(0,s),a=Math.max(0,a),l=Math.min(0,l),c=Math.max(0,c)),a===s&&(s-=1,a+=1),c===l&&(l-=1,c+=1);const u=Math.max(1,a-s),d=Math.max(1,c-l),f=Math.max(0,Math.min(1,(0-s)/u)),h=Math.max(0,Math.min(1,(0-l)/d)),p=Hn.left+i*f,m=Hn.top+o-o*h;return{plotWidth:i,plotHeight:o,minX:s,maxX:a,xRange:u,minY:l,maxY:c,yRange:d,axisX:p,axisY:m}}function cOe(e,t){return Hn.left+(t-e.minX)/e.xRange*e.plotWidth}function uOe(e,t){return Hn.top+e.plotHeight-(t-e.minY)/e.yRange*e.plotHeight}function dOe(e,t,n){const r=e.createElementNS(Lr,"line");r.setAttribute("x1",String(n.axisX)),r.setAttribute("y1",String(Hn.top)),r.setAttribute("x2",String(n.axisX)),r.setAttribute("y2",String(Hn.top+n.plotHeight)),r.setAttribute("stroke",o0),r.setAttribute("stroke-width","1"),t.appendChild(r);const i=e.createElementNS(Lr,"line");i.setAttribute("x1",String(Hn.left)),i.setAttribute("y1",String(n.axisY)),i.setAttribute("x2",String(Hn.left+n.plotWidth)),i.setAttribute("y2",String(n.axisY)),i.setAttribute("stroke",o0),i.setAttribute("stroke-width","1"),t.appendChild(i)}function fOe(e,t,n,r){const i=Math.max(8,Math.min(11,r/30));for(let o=0;o<=bu;o++){const s=o/bu,a=n.minY+n.yRange*s,l=Hn.top+n.plotHeight-n.plotHeight*s,c=e.createElementNS(Lr,"text");if(c.setAttribute("x",String(Hn.left-6)),c.setAttribute("y",String(l+3)),c.setAttribute("text-anchor","end"),c.setAttribute("font-size",String(i)),c.setAttribute("fill",T5),c.setAttribute("font-family",yu),c.textContent=I5(a),t.appendChild(c),o>0&&o<bu){const h=e.createElementNS(Lr,"line");h.setAttribute("x1",String(Hn.left)),h.setAttribute("y1",String(l)),h.setAttribute("x2",String(Hn.left+n.plotWidth)),h.setAttribute("y2",String(l)),h.setAttribute("stroke",wC),h.setAttribute("stroke-width","0.5"),t.appendChild(h)}const u=n.minX+n.xRange*s,d=Hn.left+n.plotWidth*s,f=e.createElementNS(Lr,"text");f.setAttribute("x",String(d)),f.setAttribute("y",String(Hn.top+n.plotHeight+16)),f.setAttribute("text-anchor","middle"),f.setAttribute("font-size",String(i)),f.setAttribute("fill",T5),f.setAttribute("font-family",yu),f.textContent=I5(u),t.appendChild(f)}}function hOe(e,t){const n=e.reduce((a,l)=>a+l.length,0),r=2,i=(bu+1)*2,o=Math.max(0,bu-1),s=t?e.length*2:0;return n+r+i+o+s}function QIn(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=zx(n),l=s.map(aOe),c=l.flat();if(c.length===0)return Nl(e,t,"No chart data");const u=n.legendPosition!==void 0,d=hOe(l,u);if(d>i0)return Nl(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=lOe(i,o,c,!1),h=e.createElementNS(Lr,"svg");h.setAttribute("viewBox",`0 0 ${i} ${o}`),h.setAttribute("width","100%"),h.setAttribute("height","100%"),h.style.display="block",dOe(e,h,f),fOe(e,h,f,o);for(let p=0;p<l.length;p++){const m=l[p],g=Ll[p%Ll.length];for(const y of m){const v=e.createElementNS(Lr,"circle");v.setAttribute("cx",String(cOe(f,y.x))),v.setAttribute("cy",String(uOe(f,y.y))),v.setAttribute("r","3"),v.setAttribute("fill",g),v.setAttribute("fill-opacity","0.85"),h.appendChild(v)}}return u&&Ux(e,h,s,o),a&&s0(e,h,i),t.appendChild(h),t}function $In(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=zx(n),l=s.map(aOe),c=l.flat();if(c.length===0)return Nl(e,t,"No chart data");const u=n.legendPosition!==void 0,d=hOe(l,u);if(d>i0)return Nl(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=lOe(i,o,c,!1),h=c.map(g=>g.size).filter(g=>g!=null&&g>0),p=h.length?Math.max(...h):1,m=e.createElementNS(Lr,"svg");m.setAttribute("viewBox",`0 0 ${i} ${o}`),m.setAttribute("width","100%"),m.setAttribute("height","100%"),m.style.display="block",dOe(e,m,f),fOe(e,m,f,o);for(let g=0;g<l.length;g++){const y=l[g],v=Ll[g%Ll.length];for(const b of y){const w=b.size&&b.size>0?b.size:p*.5,x=p>0?4+w/p*10:6,A=e.createElementNS(Lr,"circle");A.setAttribute("cx",String(cOe(f,b.x))),A.setAttribute("cy",String(uOe(f,b.y))),A.setAttribute("r",String(Math.max(2,x))),A.setAttribute("fill",v),A.setAttribute("fill-opacity","0.45"),A.setAttribute("stroke",v),A.setAttribute("stroke-width","1"),m.appendChild(A)}}return u&&Ux(e,m,s,o),a&&s0(e,m,i),t.appendChild(m),t}function ekn(e,t,n){const r=4+t,i=t,o=e.reduce((a,l)=>a+1+Math.min(t,l.values.length),0),s=n?e.length*2:0;return r+i+o+s}function tkn(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=zx(n),l=s[0]?.categories??[],c=Math.max(3,l.length,...s.map(A=>A.values.length)),u=n.legendPosition!==void 0,d=ekn(s,c,u);if(d>i0)return Nl(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=s.flatMap(A=>A.values).filter(A=>Number.isFinite(A)),h=f.length?Math.max(...f):1,p=f.length?Math.min(...f):0,m=Math.max(1,h-Math.min(0,p)),g=e.createElementNS(Lr,"svg");g.setAttribute("viewBox",`0 0 ${i} ${o}`),g.setAttribute("width","100%"),g.setAttribute("height","100%"),g.style.display="block";const y=u?34:10,v=Math.max(10,Math.min(i-60,o-y-60)/2),b=i/2,w=Hn.top+(o-Hn.top-y)/2,x=4;for(let A=1;A<=x;A++){const T=v*A/x,I=[];for(let C=0;C<c;C++){const R=-Math.PI/2+C*Math.PI*2/c;I.push(`${b+T*Math.cos(R)},${w+T*Math.sin(R)}`)}const P=e.createElementNS(Lr,"polygon");P.setAttribute("points",I.join(" ")),P.setAttribute("fill","none"),P.setAttribute("stroke",wC),P.setAttribute("stroke-width","0.8"),g.appendChild(P)}for(let A=0;A<c;A++){const T=-Math.PI/2+A*Math.PI*2/c,I=b+v*Math.cos(T),P=w+v*Math.sin(T),C=e.createElementNS(Lr,"line");C.setAttribute("x1",String(b)),C.setAttribute("y1",String(w)),C.setAttribute("x2",String(I)),C.setAttribute("y2",String(P)),C.setAttribute("stroke",wC),C.setAttribute("stroke-width","0.8"),g.appendChild(C);const R=v+14,k=b+R*Math.cos(T),L=w+R*Math.sin(T),_=e.createElementNS(Lr,"text");_.setAttribute("x",String(k)),_.setAttribute("y",String(L)),_.setAttribute("font-size","10"),_.setAttribute("fill",AC),_.setAttribute("font-family",yu),_.setAttribute("text-anchor",Math.abs(Math.cos(T))<.2?"middle":Math.cos(T)>0?"start":"end"),_.textContent=l[A]??`Category ${A+1}`,g.appendChild(_)}for(let A=0;A<s.length;A++){const T=s[A],I=Ll[A%Ll.length],P=[],C=[],R=Math.min(c,T.values.length);for(let k=0;k<R;k++){const L=T.values[k]??0,_=Math.max(0,(L-Math.min(0,p))/m)*v,O=-Math.PI/2+k*Math.PI*2/c,F=b+_*Math.cos(O),B=w+_*Math.sin(O);P.push(`${F},${B}`),C.push({x:F,y:B})}if(P.length>0){const k=e.createElementNS(Lr,"polygon");k.setAttribute("points",P.join(" ")),k.setAttribute("fill",I),k.setAttribute("fill-opacity","0.18"),k.setAttribute("stroke",I),k.setAttribute("stroke-width","1.8"),g.appendChild(k)}for(const k of C){const L=e.createElementNS(Lr,"circle");L.setAttribute("cx",String(k.x)),L.setAttribute("cy",String(k.y)),L.setAttribute("r","2.5"),L.setAttribute("fill",I),g.appendChild(L)}}return u&&Ux(e,g,s,o),a&&s0(e,g,i),t.appendChild(g),t}function pOe(e,t,n,r){const i=e.reduce((d,f)=>d+f.values.length,0),o=e.length,s=r?i:0,a=2,l=(bu+1)*2,c=t.length,u=n?e.length*2:0;return o+s+a+l+c+u}function mOe(e){let t=!1;const n=Math.min(e.values.length,Db);e.values.length>n&&(t=!0);const r=[];for(let i=0;i<n;i++){const o=Number(e.values[i]),s=Number.isFinite(o)&&o>0?o:0;r.push({label:e.categories[i]??`Category ${i+1}`,value:s,color:Ll[i%Ll.length]})}return{slices:r,truncated:t}}function nkn(e,t,n,r,i,o){const s=n.reduce((l,c)=>l+c.value,0);if(s<=0)return;let a=-Math.PI/2;for(const l of n){if(l.value<=0)continue;const c=l.value/s*Math.PI*2;if(c>=Math.PI*2-1e-4){const y=e.createElementNS(Lr,"circle");y.setAttribute("cx",String(r)),y.setAttribute("cy",String(i)),y.setAttribute("r",String(o)),y.setAttribute("fill",l.color),y.setAttribute("stroke","#fff"),y.setAttribute("stroke-width",String(Math.max(1,o*.01))),t.appendChild(y);break}const u=a+c,d=r+o*Math.cos(a),f=i+o*Math.sin(a),h=r+o*Math.cos(u),p=i+o*Math.sin(u),m=c>Math.PI?1:0,g=e.createElementNS(Lr,"path");g.setAttribute("d",`M ${r} ${i} L ${d} ${f} A ${o} ${o} 0 ${m} 1 ${h} ${p} Z`),g.setAttribute("fill",l.color),g.setAttribute("stroke","#fff"),g.setAttribute("stroke-width",String(Math.max(1,o*.01))),t.appendChild(g),a=u}}function gOe(e,t,n,r,i){const o=n.reduce((l,c)=>l+14+c.label.length*6+16,0);let s=Math.max(10,(r-o)/2);const a=i-14;for(const l of n){const c=e.createElementNS(Lr,"rect");c.setAttribute("x",String(s)),c.setAttribute("y",String(a-8)),c.setAttribute("width","10"),c.setAttribute("height","10"),c.setAttribute("fill",l.color),t.appendChild(c);const u=e.createElementNS(Lr,"text");u.setAttribute("x",String(s+14)),u.setAttribute("y",String(a)),u.setAttribute("font-size","10"),u.setAttribute("fill",AC),u.setAttribute("font-family",yu),u.textContent=l.label,t.appendChild(u),s+=14+l.label.length*6+16}}function yOe(e,t,n,r){const i=n.series[0];if(!i)return Nl(e,t,"No chart data");const{slices:o,truncated:s}=mOe(i);if(o.reduce((w,x)=>w+x.value,0)<=0)return Nl(e,t,"No chart data");if(o.length*3>i0)return Nl(e,t,"Chart too large");const{width:a,height:l}=r,c=n.legendPosition!==void 0,u=i.name?.trim()||"",d=u.length>0,f=d?34:10,h=c?40:10,p=Math.max(1,a-20),m=Math.max(1,l-f-h),g=a/2,y=f+m/2,v=Math.max(8,Math.min(p,m)*.45),b=e.createElementNS(Lr,"svg");if(b.setAttribute("viewBox",`0 0 ${a} ${l}`),b.setAttribute("width","100%"),b.setAttribute("height","100%"),b.style.display="block",d){const w=e.createElementNS(Lr,"text");w.setAttribute("x",String(g)),w.setAttribute("y","24"),w.setAttribute("text-anchor","middle"),w.setAttribute("font-size",String(Math.max(12,Math.min(22,a/18)))),w.setAttribute("fill",o0),w.setAttribute("font-family",yu),w.textContent=u,b.appendChild(w)}return nkn(e,b,o,g,y,v),c&&gOe(e,b,o,a,l),s&&s0(e,b,a),t.appendChild(b),t}function bOe(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=zx(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=pOe(s,l,c,!0);if(u>i0)return Nl(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=rOe(i,o,s,!1),f=e.createElementNS(Lr,"svg");f.setAttribute("viewBox",`0 0 ${i} ${o}`),f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.style.display="block",iOe(e,f,d),sOe(e,f,d,o),oOe(e,f,l,d,i);for(let h=0;h<s.length;h++){const p=s[h],m=Ll[h%Ll.length],g=[];for(let v=0;v<p.values.length;v++){const b=Vx(d,v),w=PX(d,p.values[v]??0);g.push(`${b},${w}`)}if(g.length===0)continue;const y=e.createElementNS(Lr,"polyline");y.setAttribute("points",g.join(" ")),y.setAttribute("fill","none"),y.setAttribute("stroke",m),y.setAttribute("stroke-width","2"),f.appendChild(y);for(let v=0;v<p.values.length;v++){const b=e.createElementNS(Lr,"circle");b.setAttribute("cx",String(Vx(d,v))),b.setAttribute("cy",String(PX(d,p.values[v]??0))),b.setAttribute("r","2.5"),b.setAttribute("fill",m),f.appendChild(b)}}return c&&Ux(e,f,s,o),a&&s0(e,f,i),t.appendChild(f),t}function rkn(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=zx(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=pOe(s,l,c,!1)+s.length;if(u>i0)return Nl(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=rOe(i,o,s,!0),f=e.createElementNS(Lr,"svg");f.setAttribute("viewBox",`0 0 ${i} ${o}`),f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.style.display="block",iOe(e,f,d),sOe(e,f,d,o),oOe(e,f,l,d,i);for(let h=0;h<s.length;h++){const p=s[h];if(p.values.length===0)continue;const m=Ll[h%Ll.length],g=[`M ${Vx(d,0)} ${d.baselineY}`];for(let b=0;b<p.values.length;b++)g.push(`L ${Vx(d,b)} ${PX(d,p.values[b]??0)}`);const y=Vx(d,Math.max(0,p.values.length-1));g.push(`L ${y} ${d.baselineY} Z`);const v=e.createElementNS(Lr,"path");v.setAttribute("d",g.join(" ")),v.setAttribute("fill",m),v.setAttribute("fill-opacity","0.35"),v.setAttribute("stroke",m),v.setAttribute("stroke-width","1.5"),f.appendChild(v)}return c&&Ux(e,f,s,o),a&&s0(e,f,i),t.appendChild(f),t}function ikn(e,t,n,r,i,o,s){const a=n.reduce((c,u)=>c+u.value,0);if(a<=0)return;let l=-Math.PI/2;for(const c of n){if(c.value<=0)continue;const u=c.value/a*Math.PI*2;if(u>=Math.PI*2-1e-4){const A=e.createElementNS(Lr,"circle");A.setAttribute("cx",String(r)),A.setAttribute("cy",String(i)),A.setAttribute("r",String((o+s)/2)),A.setAttribute("fill","none"),A.setAttribute("stroke",c.color),A.setAttribute("stroke-width",String(Math.max(1,o-s))),t.appendChild(A);break}const d=l+u,f=r+o*Math.cos(l),h=i+o*Math.sin(l),p=r+o*Math.cos(d),m=i+o*Math.sin(d),g=r+s*Math.cos(l),y=i+s*Math.sin(l),v=r+s*Math.cos(d),b=i+s*Math.sin(d),w=u>Math.PI?1:0,x=e.createElementNS(Lr,"path");x.setAttribute("d",`M ${f} ${h} A ${o} ${o} 0 ${w} 1 ${p} ${m} L ${v} ${b} A ${s} ${s} 0 ${w} 0 ${g} ${y} Z`),x.setAttribute("fill",c.color),x.setAttribute("stroke","#fff"),x.setAttribute("stroke-width","1"),t.appendChild(x),l=d}}function okn(e,t,n,r){const i=n.series[0];if(!i)return Nl(e,t,"No chart data");const{slices:o,truncated:s}=mOe(i);if(o.reduce((x,A)=>x+A.value,0)<=0)return Nl(e,t,"No chart data");if(o.length*3>i0)return Nl(e,t,"Chart too large");const{width:a,height:l}=r,c=n.legendPosition!==void 0,u=i.name?.trim()||"",d=u.length>0,f=d?34:10,h=c?40:10,p=Math.max(1,a-20),m=Math.max(1,l-f-h),g=a/2,y=f+m/2,v=Math.max(8,Math.min(p,m)*.45),b=Math.max(2,v*.58),w=e.createElementNS(Lr,"svg");if(w.setAttribute("viewBox",`0 0 ${a} ${l}`),w.setAttribute("width","100%"),w.setAttribute("height","100%"),w.style.display="block",d){const x=e.createElementNS(Lr,"text");x.setAttribute("x",String(g)),x.setAttribute("y","24"),x.setAttribute("text-anchor","middle"),x.setAttribute("font-size",String(Math.max(12,Math.min(22,a/18)))),x.setAttribute("fill",o0),x.setAttribute("font-family",yu),x.textContent=u,w.appendChild(x)}return ikn(e,w,o,g,y,v,b),c&&gOe(e,w,o,a,l),s&&s0(e,w,a),t.appendChild(w),t}function skn(e,t,n){const r=e.reduce((l,c)=>l+c.values.length,0),i=2,o=t.length,s=(bu+1)*2,a=n?e.length*2:0;return r+i+o+s+a}function akn(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=zx(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=skn(s,l,c);if(u>i0)return Nl(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=e.createElementNS(Lr,"svg");d.setAttribute("viewBox",`0 0 ${i} ${o}`),d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.style.display="block";const f=YIn(i,o,s);return KIn(e,d,s,f),XIn(e,d,f),JIn(e,d,l,f,i),ZIn(e,d,f,o),c&&Ux(e,d,s,o),a&&s0(e,d,i),t.appendChild(d),t}const xC=e=>{const t=[];return e.style!==void 0&&t.push(`s:${e.style}`),e.width!==void 0&&t.push(`w:${e.width}`),e.color!==void 0&&t.push(`c:${e.color}`),e.space!==void 0&&t.push(`sp:${e.space}`),t.join(",")},vOe=e=>{const t=[];return e.top&&t.push(`t:[${xC(e.top)}]`),e.right&&t.push(`r:[${xC(e.right)}]`),e.bottom&&t.push(`b:[${xC(e.bottom)}]`),e.left&&t.push(`l:[${xC(e.left)}]`),e.between&&t.push(`bw:[${xC(e.between)}]`),t.join(";")};var wOe=()=>(typeof process<"u"&&typeof process.env<"u",!1),lkn=class{constructor(){this.stats={totalSpans:0,validSpans:0,missingPmStart:0,missingPmEnd:0,missingBoth:0}}record(e,t){this.stats.totalSpans++,e&&t?this.stats.validSpans++:!e&&!t?this.stats.missingBoth++:e?this.stats.missingPmEnd++:this.stats.missingPmStart++}getStats(){return{...this.stats}}reset(){this.stats={totalSpans:0,validSpans:0,missingPmStart:0,missingPmEnd:0,missingBoth:0}}getCoveragePercent(){return this.stats.totalSpans===0?100:this.stats.validSpans/this.stats.totalSpans*100}logSummary(){if(!wOe())return;const e=this.getCoveragePercent(),t=this.stats;e<100&&console.warn("[PmPositionValidation] PM position coverage:",{coverage:`${e.toFixed(1)}%`,totalSpans:t.totalSpans,validSpans:t.validSpans,missingPmStart:t.missingPmStart,missingPmEnd:t.missingPmEnd,missingBoth:t.missingBoth})}};const AOe=new lkn;function RX(e,t){const n=e.pmStart!=null,r=e.pmEnd!=null;if(AOe.record(n,r),!!wOe()&&(!n||!r)){const i=e.text?e.text.substring(0,20)+(e.text.length>20?"...":""):"(no text)";console.warn(`[PmPositionValidation] Missing PM positions in ${t}:`,{hasPmStart:n,hasPmEnd:r,textPreview:i,fallback:"Will use PM DOM coordinates for cursor positioning"})}}function xOe(e,t){const n=e.pmStart!=null,r=e.pmEnd!=null;AOe.record(n,r)}var k5=96,SOe=25,a0=k5/8;function ckn(e){const t=e.ppi??k5,n=e.heightPx??SOe,{pageSize:r,pageMargins:i}=e;if(!Number.isFinite(t)||t<=0)throw new Error(`Invalid PPI: ${t}. Must be a positive finite number.`);if(!Number.isFinite(r.width)||r.width<=0)throw new Error(`Invalid page width: ${r.width}. Must be a positive finite number.`);if(!Number.isFinite(r.height)||r.height<=0)throw new Error(`Invalid page height: ${r.height}. Must be a positive finite number.`);if(!Number.isFinite(i.left)||i.left<0)throw new Error(`Invalid left margin: ${i.left}. Must be a non-negative finite number.`);if(!Number.isFinite(i.right)||i.right<0)throw new Error(`Invalid right margin: ${i.right}. Must be a non-negative finite number.`);if(i.left+i.right>=r.width)throw new Error(`Invalid margins: left (${i.left}) + right (${i.right}) must be less than page width (${r.width}).`);const o=r.width*t,s=[];let a=0;for(let l=0;l<r.width;l++){const c=r.width-l;s.push({size:"main",height:"20%",label:l,x:a}),a+=a0;for(let u=0;u<3;u++)s.push({size:"eighth",height:"10%",x:a}),a+=a0;if(s.push({size:"half",height:"40%",x:a}),a+=a0,c<=.5)break;for(let u=0;u<3;u++)s.push({size:"eighth",height:"10%",x:a}),a+=a0}return{widthPx:o,heightPx:n,ticks:s,leftMarginPx:i.left*t,rightMarginPx:o-i.right*t,pageWidthInches:r.width}}function ukn(e,t,n,r=k5){return t==="left"?e/r:(n-e)/r}function dkn(e,t,n,r,i=200){if(!Number.isFinite(e))throw new Error(`Invalid handleX: ${e}. Must be a finite number.`);if(!Number.isFinite(n))throw new Error(`Invalid otherHandleX: ${n}. Must be a finite number.`);if(!Number.isFinite(r))throw new Error(`Invalid pageWidthPx: ${r}. Must be a finite number.`);if(!Number.isFinite(i))throw new Error(`Invalid minContentWidthPx: ${i}. Must be a finite number.`);if(t==="left"){const s=n-i;return Math.max(0,Math.min(s,e))}else{const o=n+i;return Math.max(o,Math.min(r,e))}}function fkn(e){const t=e.ppi??k5,n=e.heightPx??SOe,{pageWidthPx:r,leftMarginPx:i,rightMarginPx:o}=e;if(!Number.isFinite(t)||t<=0)throw new Error(`Invalid PPI: ${t}. Must be a positive finite number.`);if(!Number.isFinite(r)||r<=0)throw new Error(`Invalid page width: ${r}px. Must be a positive finite number.`);if(!Number.isFinite(e.pageHeightPx)||e.pageHeightPx<=0)throw new Error(`Invalid page height: ${e.pageHeightPx}px. Must be a positive finite number.`);if(!Number.isFinite(i)||i<0)throw new Error(`Invalid left margin: ${i}px. Must be a non-negative finite number.`);if(!Number.isFinite(o)||o<0)throw new Error(`Invalid right margin: ${o}px. Must be a non-negative finite number.`);if(i+o>=r)throw new Error(`Invalid margins: left (${i}px) + right (${o}px) must be less than page width (${r}px).`);const s=r/t,a=[];let l=0;for(let c=0;c<s;c++){const u=s-c;a.push({size:"main",height:"20%",label:c,x:l}),l+=a0;for(let d=0;d<3;d++)a.push({size:"eighth",height:"10%",x:l}),l+=a0;if(a.push({size:"half",height:"40%",x:l}),l+=a0,u<=.5)break;for(let d=0;d<3;d++)a.push({size:"eighth",height:"10%",x:l}),l+=a0}return{widthPx:r,heightPx:n,ticks:a,leftMarginPx:i,rightMarginPx:r-o,pageWidthInches:s}}const ds={ruler:"superdoc-ruler",tick:"superdoc-ruler-tick",tickMain:"superdoc-ruler-tick--main",tickHalf:"superdoc-ruler-tick--half",tickEighth:"superdoc-ruler-tick--eighth",label:"superdoc-ruler-label",handle:"superdoc-ruler-handle",handleLeft:"superdoc-ruler-handle--left",handleRight:"superdoc-ruler-handle--right",indicator:"superdoc-ruler-indicator"};function hkn(e){const{definition:t,doc:n,interactive:r=!1}=e;(!Number.isFinite(t.widthPx)||t.widthPx<=0)&&(console.warn(`[createRulerElement] Invalid ruler width: ${t.widthPx}px. Using minimum width of 1px.`),t.widthPx=Math.max(1,t.widthPx||1)),(!t.ticks||t.ticks.length===0)&&console.warn("[createRulerElement] Ruler definition has no ticks. Ruler will be empty.");const i=n.createElement("div");i.className=ds.ruler,i.style.cssText=`
|
|
425
425
|
position: relative;
|
|
@@ -1291,7 +1291,7 @@ or
|
|
|
1291
1291
|
bash: npm install skia-canvas
|
|
1292
1292
|
js: import "konva/skia-backend";
|
|
1293
1293
|
`,xHe=()=>{if(typeof document>"u")throw new Error(LHn)},gf=class BWe{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new BWe(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const n=this.m;return{x:n[0]*t.x+n[2]*t.y+n[4],y:n[1]*t.x+n[3]*t.y+n[5]}}translate(t,n){return this.m[4]+=this.m[0]*t+this.m[2]*n,this.m[5]+=this.m[1]*t+this.m[3]*n,this}scale(t,n){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=n,this.m[3]*=n,this}rotate(t){const n=Math.cos(t),r=Math.sin(t),i=this.m[0]*n+this.m[2]*r,o=this.m[1]*n+this.m[3]*r,s=this.m[0]*-r+this.m[2]*n,a=this.m[1]*-r+this.m[3]*n;return this.m[0]=i,this.m[1]=o,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,n){const r=this.m[0]+this.m[2]*n,i=this.m[1]+this.m[3]*n,o=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=r,this.m[1]=i,this.m[2]=o,this.m[3]=s,this}multiply(t){const n=this.m[0]*t.m[0]+this.m[2]*t.m[1],r=this.m[1]*t.m[0]+this.m[3]*t.m[1],i=this.m[0]*t.m[2]+this.m[2]*t.m[3],o=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=o,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),n=this.m[3]*t,r=-this.m[1]*t,i=-this.m[2]*t,o=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=o,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],n=this.m[1],r=this.m[2],i=this.m[3],o=this.m[4],s=this.m[5],a=t*i-n*r,l={x:o,y:s,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(t!=0||n!=0){const c=Math.sqrt(t*t+n*n);l.rotation=n>0?Math.acos(t/c):-Math.acos(t/c),l.scaleX=c,l.scaleY=a/c,l.skewX=(t*r+n*i)/a,l.skewY=0}else if(r!=0||i!=0){const c=Math.sqrt(r*r+i*i);l.rotation=Math.PI/2-(i>0?Math.acos(-r/c):-Math.acos(r/c)),l.scaleX=a/c,l.scaleY=c,l.skewX=0,l.skewY=(t*r+n*i)/a}return l.rotation=lt._getRotation(l.rotation),l}},NHn="[object Array]",MHn="[object Number]",DHn="[object String]",OHn="[object Boolean]",FHn=Math.PI/180,BHn=180/Math.PI,w2="#",HHn="",zHn="0",UHn="Konva warning: ",SHe="Konva error: ",VHn="rgb(",BQ={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},WHn=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,o6=[],A2=null,GHn=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)};const lt={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===NHn},_isNumber(e){return Object.prototype.toString.call(e)===MHn&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===DHn},_isBoolean(e){return Object.prototype.toString.call(e)===OHn},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!="string")return!1;const t=e[0];return t==="#"||t==="."||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){o6.push(e),o6.length===1&&GHn(function(){const t=o6;o6=[],t.forEach(function(n){n()})})},createCanvasElement(){xHe();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return xHe(),document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){const n=lt.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(w2,HHn);const t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=zHn+e;return w2+e},isCanvasFarblingActive(){if(A2!==null)return A2;if(typeof document>"u")return A2=!1,!1;const e=this.createCanvasElement();e.width=10,e.height=10;const t=e.getContext("2d",{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle="#282828",t.fillRect(0,0,10,10);const n=t.getImageData(0,0,10,10).data;let r=!1;for(let i=0;i<100;i++)if(n[i*4]!==40||n[i*4+1]!==40||n[i*4+2]!==40||n[i*4+3]!==255){r=!0;break}return A2=r,this.releaseCanvas(e),A2},getHitColor(){const e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,n){return this.isCanvasFarblingActive()&&(e=Math.round(e/5)*5,t=Math.round(t/5)*5,n=Math.round(n/5)*5),w2+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return w2+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let t;return e in BQ?(t=BQ[e],{r:t[0],g:t[1],b:t[2]}):e[0]===w2?this._hexToRgb(e.substring(1)):e.substr(0,4)===VHn?(t=WHn.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA(e){return e=e||"black",lt._namedColorToRBA(e)||lt._hex3ColorToRGBA(e)||lt._hex4ColorToRGBA(e)||lt._hex6ColorToRGBA(e)||lt._hex8ColorToRGBA(e)||lt._rgbColorToRGBA(e)||lt._rgbaColorToRGBA(e)||lt._hslColorToRGBA(e)},_namedColorToRBA(e){const t=BQ[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(e.indexOf("rgb(")===0){e=e.match(/rgb\(([^)]+)\)/)[1];const t=e.split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf("rgba(")===0){e=e.match(/rgba\(([^)]+)\)/)[1];const t=e.split(/ *, */).map((n,r)=>n.slice(-1)==="%"?r===3?parseInt(n)/100:parseInt(n)/100*255:Number(n));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if(e[0]==="#"&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]==="#"&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]==="#"&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]==="#"&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,i=Number(n[1])/100,o=Number(n[2])/100;let s,a,l;if(i===0)return l=o*255,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};o<.5?s=o*(1+i):s=o+i-o*i;const c=2*o-s,u=[0,0,0];for(let d=0;d<3;d++)a=r+1/3*-(d-1),a<0&&a++,a>1&&a--,6*a<1?l=c+(s-c)*6*a:2*a<1?l=s:3*a<2?l=c+(s-c)*(2/3-a)*6:l=c,u[d]=l*255;return{r:Math.round(u[0]),g:Math.round(u[1]),b:Math.round(u[2]),a:1}}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){const t={};for(const n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray(e){return e.slice(0)},degToRad(e){return e*FHn},radToDeg(e){return e*BHn},_degToRad(e){return lt.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),lt.degToRad(e)},_radToDeg(e){return lt.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),lt.radToDeg(e)},_getRotation(e){return on.angleDeg?lt.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(SHe+e)},error(e){console.error(SHe+e)},warn(e){on.showWarnings&&console.warn(UHn+e)},each(e,t){for(const n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e<n},_getProjectionToSegment(e,t,n,r,i,o){let s,a,l;const c=(e-n)*(e-n)+(t-r)*(t-r);if(c==0)s=e,a=t,l=(i-n)*(i-n)+(o-r)*(o-r);else{const u=((i-e)*(n-e)+(o-t)*(r-t))/c;u<0?(s=e,a=t,l=(e-i)*(e-i)+(t-o)*(t-o)):u>1?(s=n,a=r,l=(n-i)*(n-i)+(r-o)*(r-o)):(s=e+u*(n-e),a=t+u*(r-t),l=(s-i)*(s-i)+(a-o)*(a-o))}return[s,a,l]},_getProjectionToLine(e,t,n){const r=lt.cloneObject(e);let i=Number.MAX_VALUE;return t.forEach(function(o,s){if(!n&&s===t.length-1)return;const a=t[(s+1)%t.length],l=lt._getProjectionToSegment(o.x,o.y,a.x,a.y,e.x,e.y),c=l[0],u=l[1],d=l[2];d<i&&(r.x=c,r.y=u,i=d)}),r},_prepareArrayForTween(e,t,n){const r=[],i=[];if(e.length>t.length){const s=t;t=e,e=s}for(let s=0;s<e.length;s+=2)r.push({x:e[s],y:e[s+1]});for(let s=0;s<t.length;s+=2)i.push({x:t[s],y:t[s+1]});const o=[];return i.forEach(function(s){const a=lt._getProjectionToLine(s,r,n);o.push(a.x),o.push(a.y)}),o},_prepareToStringify(e){let t;e.visitedByCircularReferenceRemoval=!0;for(const n in e)if(e.hasOwnProperty(n)&&e[n]&&typeof e[n]=="object"){if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||lt._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(lt._prepareToStringify(e[n])===null)if(t.configurable)delete e[n];else return null}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(const n in t)e[n]=t[n];return e},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId||999},releaseCanvas(...e){on.releaseCanvasOnDestroy&&e.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(e,t,n,r){let i=t<0?t:0,o=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let s=0,a=0,l=0,c=0;typeof r=="number"?s=a=l=c=Math.min(r,t/2,n/2):(s=Math.min(r[0]||0,t/2,n/2),a=Math.min(r[1]||0,t/2,n/2),c=Math.min(r[2]||0,t/2,n/2),l=Math.min(r[3]||0,t/2,n/2)),e.moveTo(i+s,o),e.lineTo(i+t-a,o),e.arc(i+t-a,o+a,a,Math.PI*3/2,0,!1),e.lineTo(i+t,o+n-c),e.arc(i+t-c,o+n-c,c,0,Math.PI/2,!1),e.lineTo(i+l,o+n),e.arc(i+l,o+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(i,o+s),e.arc(i+s,o+s,s,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,i){r=Math.abs(r);for(let o=0;o<n;o++){const s=t[(o-1+n)%n],a=t[o],l=t[(o+1)%n],c={x:a.x-s.x,y:a.y-s.y},u={x:l.x-a.x,y:l.y-a.y},d=Math.hypot(c.x,c.y),f=Math.hypot(u.x,u.y);let h;typeof i=="number"?h=i:h=o<i.length?i[o]:0,h=r*Math.cos(Math.PI/n)*Math.min(1,h/r*2);const p={x:c.x/d,y:c.y/d},m={x:u.x/f,y:u.y/f},g={x:a.x-p.x*h,y:a.y-p.y*h},y={x:a.x+m.x*h,y:a.y+m.y*h};o===0?e.moveTo(g.x,g.y):e.lineTo(g.x,g.y),e.arcTo(a.x,a.y,y.x,y.y,h)}}};function jHn(e){const t=[],n=e.length,r=lt;for(let i=0;i<n;i++){let o=e[i];r._isNumber(o)?o=Math.round(o*1e3)/1e3:r._isString(o)||(o=o+""),t.push(o)}return t}var THe=",",qHn="(",YHn=")",KHn="([",XHn="])",JHn=";",ZHn="()",QHn="=",IHe=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],$Hn=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],ezn=100,s6=null;function kHe(){if(s6!==null)return s6;try{const e=lt.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:(s6=!1,!1)}catch{return s6=!1,!1}}var a6=class{constructor(e){this.canvas=e,on.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){let n=this.traceArr,r=n.length,i="",o,s,a,l;for(o=0;o<r;o++)s=n[o],a=s.method,a?(l=s.args,i+=a,e?i+=ZHn:lt._isArray(l[0])?i+=KHn+l.join(THe)+XHn:(t&&(l=l.map(c=>typeof c=="number"?Math.floor(c):c)),i+=qHn+l.join(THe)+YHn)):(i+=s.property,e||(i+=QHn+s.val)),i+=JHn;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=ezn&&t.shift()}reset(){const e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){const t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){const t=e.getAbsoluteOpacity();t!==1&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}_applyMiterLimit(e){const t=e.attrs.miterLimit;t!=null&&this.setAttr("miterLimit",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,i,o){this._context.arc(e,t,n,r,i,o)}arcTo(e,t,n,r,i){this._context.arcTo(e,t,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,i,o){this._context.bezierCurveTo(e,t,n,r,i,o)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){const n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,i,o){return this._context.createRadialGradient(e,t,n,r,i,o)}drawImage(e,t,n,r,i,o,s,a,l){const c=arguments,u=this._context;c.length===3?u.drawImage(e,t,n):c.length===5?u.drawImage(e,t,n,r,i):c.length===9&&u.drawImage(e,t,n,r,i,o,s,a,l)}ellipse(e,t,n,r,i,o,s,a){this._context.ellipse(e,t,n,r,i,o,s,a)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,i){this._context.roundRect(e,t,n,r,i)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,i,o){this._context.setTransform(e,t,n,r,i,o)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,i,o){this._context.transform(e,t,n,r,i,o)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=IHe.length,n=this.setAttr,r,i;const o=function(s){let a=e[s],l;e[s]=function(){return i=jHn(Array.prototype.slice.call(arguments,0)),l=a.apply(e,arguments),e._trace({method:s,args:i}),l}};for(r=0;r<t;r++)o(IHe[r]);e.setAttr=function(){n.apply(e,arguments);const s=arguments[0];let a=arguments[1];(s==="shadowOffsetX"||s==="shadowOffsetY"||s==="shadowBlur")&&(a=a/this.canvas.getPixelRatio()),e._trace({property:s,val:a})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||t==="source-over"||this.setAttr("globalCompositeOperation",t)}};$Hn.forEach(function(e){Object.defineProperty(a6.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var tzn=class extends a6{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:t})}_fillColor(e){const t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){const t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&n==="color"){this._fillColor(e);return}const r=e.getFillPatternImage();if(r&&n==="pattern"){this._fillPattern(e);return}const i=e.getFillLinearGradientColorStops();if(i&&n==="linear-gradient"){this._fillLinearGradient(e);return}const o=e.getFillRadialGradientColorStops();if(o&&n==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):i?this._fillLinearGradient(e):o&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),i=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let o=0;o<r.length;o+=2)i.addColorStop(r[o],r[o+1]);this.setAttr("strokeStyle",i)}}_stroke(e){const t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();const r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,r;const i=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",o=(n=e.getShadowBlur())!==null&&n!==void 0?n:5,s=(r=e.getShadowOffset())!==null&&r!==void 0?r:{x:0,y:0},a=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),c=a.x*l,u=a.y*l;this.setAttr("shadowColor",i),this.setAttr("shadowBlur",o*Math.min(Math.abs(c),Math.abs(u))),this.setAttr("shadowOffsetX",s.x*c),this.setAttr("shadowOffsetY",s.y*u)}},nzn=class extends a6{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const t=e.getStrokeScaleEnabled();if(!t){this.save();const i=this.getCanvas().getPixelRatio();this.setTransform(i,0,0,i,0,0)}this._applyLineCap(e);const n=e.hitStrokeWidth(),r=n==="auto"?e.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),t||this.restore()}}},l6;function rzn(){if(l6)return l6;const e=lt.createCanvasElement(),t=e.getContext("2d");return l6=(function(){return(on._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),lt.releaseCanvas(e),l6}var HQ=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1,this.pixelRatio=(e||{}).pixelRatio||on.pixelRatio||rzn(),this._canvas=lt.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){const t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(r){return lt.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}},A0=class extends HQ{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new tzn(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},zQ=class extends HQ{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new nzn(this),this.setSize(e.width,e.height)}};const Di={get isDragging(){let e=!1;return Di._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return Di._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];Di._dragElements.forEach((n,r)=>{const{node:i}=n,o=i.getStage();o.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=lt._getFirstPointerId(e));const s=o._changedPointerPositions.find(a=>a.id===n.pointerId);if(s){if(n.dragStatus!=="dragging"){const a=i.dragDistance();if(Math.max(Math.abs(s.x-n.startPointerPos.x),Math.abs(s.y-n.startPointerPos.y))<a||(i.startDrag({evt:e}),!i.isDragging()))return}i._setDragPosition(e,n),t.push(i)}}),t.forEach(n=>{n.getStage()&&n.fire("dragmove",{type:"dragmove",target:n,evt:e},!0)})},_endDragBefore(e){const t=[];Di._dragElements.forEach(n=>{const{node:r}=n,i=r.getStage();if(e&&i.setPointersPositions(e),!i._changedPointerPositions.find(s=>s.id===n.pointerId))return;(n.dragStatus==="dragging"||n.dragStatus==="stopped")&&(Di.justDragged=!0,on._mouseListenClick=!1,on._touchListenClick=!1,on._pointerListenClick=!1,n.dragStatus="stopped");const o=n.node.getLayer()||n.node instanceof on.Stage&&n.node;o&&t.indexOf(o)===-1&&t.push(o)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){Di._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&Di._dragElements.delete(n)})}};on.isBrowser&&(window.addEventListener("mouseup",Di._endDragBefore,!0),window.addEventListener("touchend",Di._endDragBefore,!0),window.addEventListener("touchcancel",Di._endDragBefore,!0),window.addEventListener("mousemove",Di._drag),window.addEventListener("touchmove",Di._drag),window.addEventListener("mouseup",Di._endDragAfter,!1),window.addEventListener("touchend",Di._endDragAfter,!1),window.addEventListener("touchcancel",Di._endDragAfter,!1));function x0(e){return lt._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||lt._isBoolean(e)?e:Object.prototype.toString.call(e)}function EHe(e){return e>255?255:e<0?0:Math.round(e)}function Zt(){if(on.isUnminified)return function(e,t){return lt._isNumber(e)||lt.warn(x0(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function c6(e){if(on.isUnminified)return function(t,n){let r=lt._isNumber(t),i=lt._isArray(t)&&t.length==e;return!r&&!i&<.warn(x0(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function UQ(){if(on.isUnminified)return function(e,t){return lt._isNumber(e)||e==="auto"||lt.warn(x0(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Qb(){if(on.isUnminified)return function(e,t){return lt._isString(e)||lt.warn(x0(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function CHe(){if(on.isUnminified)return function(e,t){const n=lt._isString(e),r=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return n||r||lt.warn(x0(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function izn(){if(on.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(lt._isArray(e)?e.forEach(function(r){lt._isNumber(r)||lt.warn('"'+t+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):lt.warn(x0(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function yf(){if(on.isUnminified)return function(e,t){return e===!0||e===!1||lt.warn(x0(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function ozn(e){if(on.isUnminified)return function(t,n){return t==null||lt.isObject(t)||lt.warn(x0(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var x2="get",S2="set";const qe={addGetterSetter(e,t,n,r,i){qe.addGetter(e,t,n),qe.addSetter(e,t,r,i),qe.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=x2+lt._capitalize(t);e.prototype[r]=e.prototype[r]||function(){const i=this.attrs[t];return i===void 0?n:i}},addSetter(e,t,n,r){const i=S2+lt._capitalize(t);e.prototype[i]||qe.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const i=S2+lt._capitalize(t);e.prototype[i]=function(o){return n&&o!==void 0&&o!==null&&(o=n.call(this,o,t)),this._setAttr(t,o),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,i){const o=n.length,s=lt._capitalize,a=x2+s(t),l=S2+s(t);e.prototype[a]=function(){const u={};for(let d=0;d<o;d++){const f=n[d];u[f]=this.getAttr(t+s(f))}return u};const c=ozn(n);e.prototype[l]=function(u){const d=this.attrs[t];r&&(u=r.call(this,u,t)),c&&c.call(this,u,t);for(const f in u)u.hasOwnProperty(f)&&this._setAttr(t+s(f),u[f]);return u||n.forEach(f=>{this._setAttr(t+s(f),void 0)}),this._fireChangeEvent(t,d,u),i&&i.call(this),this},qe.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=lt._capitalize(t),r=S2+n,i=x2+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()}},addDeprecatedGetterSetter(e,t,n,r){lt.error("Adding deprecated "+t);const i=x2+lt._capitalize(t),o=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[i]=function(){lt.error(o);const s=this.attrs[t];return s===void 0?n:s},qe.addSetter(e,t,r,function(){lt.error(o)}),qe.addOverloadedGetterSetter(e,t)},backCompat(e,t){lt.each(t,function(n,r){const i=e.prototype[r],o=x2+lt._capitalize(n),s=S2+lt._capitalize(n);function a(){i.apply(this,arguments),lt.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}e.prototype[n]=a,e.prototype[o]=a,e.prototype[s]=a})},afterSetFilter(){this._filterUpToDate=!1}};function szn(e){const t=/(\w+)\(([^)]+)\)/g;let n;for(;(n=t.exec(e))!==null;){const[,r,i]=n;switch(r){case"blur":{const o=parseFloat(i.replace("px",""));return function(s){this.blurRadius(o*.5);const a=on.Filters;a&&a.Blur&&a.Blur.call(this,s)}}case"brightness":{const o=i.includes("%")?parseFloat(i)/100:parseFloat(i);return function(s){this.brightness(o);const a=on.Filters;a&&a.Brightness&&a.Brightness.call(this,s)}}case"contrast":{const o=parseFloat(i);return function(s){const a=100*(Math.sqrt(o)-1);this.contrast(a);const l=on.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(o){const s=on.Filters;s&&s.Grayscale&&s.Grayscale.call(this,o)};case"sepia":return function(o){const s=on.Filters;s&&s.Sepia&&s.Sepia.call(this,o)};case"invert":return function(o){const s=on.Filters;s&&s.Invert&&s.Invert.call(this,o)};default:lt.warn(`CSS filter "${r}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var u6="absoluteOpacity",_He="allEventListeners",nm="absoluteTransform",PHe="absoluteScale",$b="canvas",azn="Change",lzn="children",czn="konva",VQ="listening",uzn="mouseenter",dzn="mouseleave",fzn="pointerenter",hzn="pointerleave",pzn="touchenter",mzn="touchleave",RHe="set",LHe="Shape",d6=" ",NHe="stage",S0="transform",gzn="Stage",WQ="visible",yzn=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(d6),bzn=1,sn=class h_{constructor(t){this._id=bzn++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){(t===S0||t===nm)&&this._cache.get(t)?this._cache.get(t).dirty=!0:t?this._cache.delete(t):this._cache.clear()}_getCache(t,n){let r=this._cache.get(t);return(r===void 0||(t===S0||t===nm)&&r.dirty===!0)&&(r=n.call(this),this._cache.set(t,r)),r}_calculate(t,n,r){if(!this._attachedDepsListeners.get(t)){const i=n.map(o=>o+"Change.konva").join(d6);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get($b)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===nm&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has($b)){const{scene:t,filter:n,hit:r}=this._cache.get($b);lt.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete($b)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const n=t||{};let r={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let i=Math.ceil(n.width||r.width),o=Math.ceil(n.height||r.height),s=n.pixelRatio,a=n.x===void 0?Math.floor(r.x):n.x,l=n.y===void 0?Math.floor(r.y):n.y,c=n.offset||0,u=n.drawBorder||!1,d=n.hitCanvasPixelRatio||1;if(!i||!o){lt.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const f=Math.abs(Math.round(r.x)-a)>.5?1:0,h=Math.abs(Math.round(r.y)-l)>.5?1:0;i+=c*2+f,o+=c*2+h,a-=c,l-=c;const p=new A0({pixelRatio:s,width:i,height:o}),m=new A0({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),g=new zQ({pixelRatio:d,width:i,height:o}),y=p.getContext(),v=g.getContext(),b=new A0({width:p.width/p.pixelRatio+Math.abs(a),height:p.height/p.pixelRatio+Math.abs(l),pixelRatio:p.pixelRatio}),w=b.getContext();return g.isCache=!0,p.isCache=!0,this._cache.delete($b),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(p.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),y.save(),v.save(),w.save(),y.translate(-a,-l),v.translate(-a,-l),w.translate(-a,-l),b.x=a,b.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(u6),this._clearSelfAndDescendantCache(PHe),this.drawScene(p,this,b),this.drawHit(g,this),this._isUnderCache=!1,y.restore(),v.restore(),u&&(y.save(),y.beginPath(),y.rect(0,0,i,o),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),lt.releaseCanvas(b._canvas),this._cache.set($b,{scene:p,filter:m,hit:g,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has($b)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,n){const r=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let i=1/0,o=1/0,s=-1/0,a=-1/0;const l=this.getAbsoluteTransform(n);return r.forEach(function(c){const u=l.point(c);i===void 0&&(i=s=u.x,o=a=u.y),i=Math.min(i,u.x),o=Math.min(o,u.y),s=Math.max(s,u.x),a=Math.max(a,u.y)}),{x:i,y:o,width:s-i,height:a-o}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();t.translate(n.x,n.y);const r=this._getCachedSceneCanvas(),i=r.pixelRatio;t.drawImage(r._canvas,0,0,r.width/i,r.height/i),t.restore()}_drawCachedHitCanvas(t){const n=this._getCanvasCache(),r=n.hit;t.save(),t.translate(n.x,n.y),t.drawImage(r._canvas,0,0,r.width/r.pixelRatio,r.height/r.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t=this.filters(),n=this._getCanvasCache(),r=n.scene,i=n.filter,o=i.getContext(),s,a,l,c;if(!t||t.length===0)return r;if(this._filterUpToDate)return i;let u=!0;for(let f=0;f<t.length;f++)if(typeof t[f]=="string"&&kHe(),typeof t[f]!="string"||!kHe()){u=!1;break}const d=r.pixelRatio;if(i.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio),u){const f=t.join(" ");return o.save(),o.setAttr("filter",f),o.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),o.restore(),this._filterUpToDate=!0,i}try{for(s=t.length,o.clear(),o.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),a=o.getImageData(0,0,i.getWidth(),i.getHeight()),l=0;l<s;l++)c=t[l],typeof c=="string"&&(c=szn(c)),c.call(this,a),o.putImageData(a,0,0)}catch(f){lt.error("Unable to apply filter. "+f.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,i}on(...t){const n=t[0],r=t[1];if(t[2],this._cache&&this._cache.delete(_He),t.length===3)return this._delegate.apply(this,t);const i=n.split(d6);for(let o=0;o<i.length;o++){const s=i[o].split("."),a=s[0],l=s[1]||"";this.eventListeners[a]||(this.eventListeners[a]=[]),this.eventListeners[a].push({name:l,handler:r})}return this}off(t,n){let r=(t||"").split(d6),i=r.length,o,s,a,l,c,u;if(this._cache&&this._cache.delete(_He),!t)for(s in this.eventListeners)this._off(s);for(o=0;o<i;o++)if(a=r[o],l=a.split("."),c=l[0],u=l[1],c)this.eventListeners[c]&&this._off(c,u,n);else for(s in this.eventListeners)this._off(s,u,n);return this}dispatchEvent(t){const n={target:this,type:t.type,evt:t};return this.fire(t.type,n),this}addEventListener(t,n){return this.on(t,function(r){n.call(this,r.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,n,r){const i=this;return this.on(t,function(o){const s=o.target.findAncestors(n,!0,i);for(let a=0;a<s.length;a++)o=lt.cloneObject(o),o.currentTarget=s[a],r.call(s[a],o)}),this}remove(){return this.isDragging()&&this.stopDrag(),Di._dragElements.delete(this._id),Di._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&Di._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(nm),this._clearSelfAndDescendantCache(u6),this._clearSelfAndDescendantCache(PHe),this._clearSelfAndDescendantCache(NHe),this._clearSelfAndDescendantCache(WQ),this._clearSelfAndDescendantCache(VQ)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const n="get"+lt._capitalize(t);return lt._isFunction(this[n])?this[n]():this.attrs[t]}getAncestors(){let t=this.getParent(),n=[];for(;t;)n.push(t),t=t.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let n,r;if(!t)return this;for(n in t)n!==lzn&&(r=RHe+lt._capitalize(n),lt._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache(VQ,this._isListening)}_isListening(t){if(!this.listening())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isListening(t):!0}isVisible(){return this._getCache(WQ,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isVisible(t):!0}shouldDrawHit(t,n=!1){if(t)return this._isVisible(t)&&this._isListening(t);const r=this.getLayer();let i=!1;Di._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(i=!0)});const o=!n&&!on.hitOnDragEnabled&&(i||on.isTransforming());return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t=this.getDepth(),n=this,r=0,i,o,s,a;function l(u){for(i=[],o=u.length,s=0;s<o;s++)a=u[s],r++,a.nodeType!==LHe&&(i=i.concat(a.getChildren().slice())),a._id===n._id&&(s=o);i.length>0&&i[0].getDepth()<=t&&l(i)}const c=this.getStage();return n.nodeType!==gzn&&c&&l(c.getChildren()),r}getDepth(){let t=0,n=this.parent;for(;n;)t++,n=n.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(S0),this._clearSelfAndDescendantCache(nm)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const n=t.getPointerPosition();if(!n)return null;const r=this.getAbsoluteTransform().copy();return r.invert(),r.point(n)}getAbsolutePosition(t){let n=!1,r=this.parent;for(;r;){if(r.isCached()){n=!0;break}r=r.parent}n&&!t&&(t=!0);const i=this.getAbsoluteTransform(t).getMatrix(),o=new gf,s=this.offset();return o.m=i.slice(),o.translate(s.x,s.y),o.getTranslation()}setAbsolutePosition(t){const{x:n,y:r,...i}=this._clearTransform();this.attrs.x=n,this.attrs.y=r,this._clearCache(S0);const o=this._getAbsoluteTransform().copy();return o.invert(),o.translate(t.x,t.y),t={x:this.attrs.x+o.getTranslation().x,y:this.attrs.y+o.getTranslation().y},this._setTransform(i),this.setPosition({x:t.x,y:t.y}),this._clearCache(S0),this._clearSelfAndDescendantCache(nm),this}_setTransform(t){let n;for(n in t)this.attrs[n]=t[n]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let n=t.x,r=t.y,i=this.x(),o=this.y();return n!==void 0&&(i+=n),r!==void 0&&(o+=r),this.setPosition({x:i,y:o}),this}_eachAncestorReverse(t,n){let r=[],i=this.getParent(),o,s;if(!(n&&n._id===this._id)){for(r.unshift(this);i&&(!n||i._id!==n._id);)r.unshift(i),i=i.parent;for(o=r.length,s=0;s<o;s++)t(r[s])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return lt.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return lt.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return lt.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return lt.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(t){if(!this.parent)return lt.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&<.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(u6,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const n=this.getParent();return n&&!n._isUnderCache&&(t*=n.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t=this.getAttrs(),n,r,i,o,s;const a={attrs:{},className:this.getClassName()};for(n in t)r=t[n],s=lt.isObject(r)&&!lt._isPlainObject(r)&&!lt._isArray(r),!s&&(i=typeof this[n]=="function"&&this[n],delete t[n],o=i?i.call(this):null,t[n]=r,o!==r&&(a.attrs[n]=r));return lt._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,n,r){const i=[];n&&this._isMatch(t)&&i.push(this);let o=this.parent;for(;o;){if(o===r)return i;o._isMatch(t)&&i.push(o),o=o.parent}return i}isAncestorOf(t){return!1}findAncestor(t,n,r){return this.findAncestors(t,n,r)[0]}_isMatch(t){if(!t)return!1;if(typeof t=="function")return t(this);let n=t.replace(/ /g,"").split(","),r=n.length,i,o;for(i=0;i<r;i++)if(o=n[i],lt.isValidSelector(o)||(lt.warn('Selector "'+o+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),lt.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),lt.warn("Konva is awesome, right?")),o.charAt(0)==="#"){if(this.id()===o.slice(1))return!0}else if(o.charAt(0)==="."){if(this.hasName(o.slice(1)))return!0}else if(this.className===o||this.nodeType===o)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(NHe,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,n={},r){return n.target=n.target||this,r?this._fireAndBubble(t,n):this._fire(t,n),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(nm,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new gf,this._eachAncestorReverse(function(r){const i=r.transformsEnabled();i==="all"?n.multiply(r.getTransform()):i==="position"&&n.translate(r.x()-r.offsetX(),r.y()-r.offsetY())},t),n;{n=this._cache.get(nm)||new gf,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();const r=this.transformsEnabled();if(r==="all")n.multiply(this.getTransform());else if(r==="position"){const i=this.attrs.x||0,o=this.attrs.y||0,s=this.attrs.offsetX||0,a=this.attrs.offsetY||0;n.translate(i-s,o-a)}return n.dirty=!1,n}}getAbsoluteScale(t){let n=this;for(;n;)n._isUnderCache&&(t=n),n=n.getParent();const r=this.getAbsoluteTransform(t).decompose();return{x:r.scaleX,y:r.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(S0,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(S0)||new gf;r.reset();const i=this.x(),o=this.y(),s=on.getAngle(this.rotation()),a=(t=this.attrs.scaleX)!==null&&t!==void 0?t:1,l=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,c=this.attrs.skewX||0,u=this.attrs.skewY||0,d=this.attrs.offsetX||0,f=this.attrs.offsetY||0;return(i!==0||o!==0)&&r.translate(i,o),s!==0&&r.rotate(s),(c!==0||u!==0)&&r.skew(c,u),(a!==1||l!==1)&&r.scale(a,l),(d!==0||f!==0)&&r.translate(-1*d,-1*f),r.dirty=!1,r}clone(t){let n=lt.cloneObject(this.attrs),r,i,o,s,a;for(r in t)n[r]=t[r];const l=new this.constructor(n);for(r in this.eventListeners)for(i=this.eventListeners[r],o=i.length,s=0;s<o;s++)a=i[s],a.name.indexOf(czn)<0&&(l.eventListeners[r]||(l.eventListeners[r]=[]),l.eventListeners[r].push(a));return l}_toKonvaCanvas(t){t=t||{};const n=this.getClientRect(),r=this.getStage(),i=t.x!==void 0?t.x:Math.floor(n.x),o=t.y!==void 0?t.y:Math.floor(n.y),s=t.pixelRatio||1,a=new A0({width:t.width||Math.ceil(n.width)||(r?r.width():0),height:t.height||Math.ceil(n.height)||(r?r.height():0),pixelRatio:s}),l=a.getContext(),c=new A0({width:a.width/a.pixelRatio+Math.abs(i),height:a.height/a.pixelRatio+Math.abs(o),pixelRatio:a.pixelRatio});return t.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(i||o)&&l.translate(-1*i,-1*o),this.drawScene(a,void 0,c),l.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){t=t||{};const n=t.mimeType||null,r=t.quality||null,i=this._toKonvaCanvas(t).toDataURL(n,r);return t.callback&&t.callback(i),i}toImage(t){return new Promise((n,r)=>{try{const i=t?.callback;i&&delete t.callback,lt._urlToImage(this.toDataURL(t),function(o){n(o),i?.(o)})}catch(i){r(i)}})}toBlob(t){return new Promise((n,r)=>{try{const i=t?.callback;i&&delete t.callback,this.toCanvas(t).toBlob(o=>{n(o),i?.(o)},t?.mimeType,t?.quality)}catch(i){r(i)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():on.dragDistance}_off(t,n,r){let i=this.eventListeners[t],o,s,a;for(o=0;o<i.length;o++)if(s=i[o].name,a=i[o].handler,(s!=="konva"||n==="konva")&&(!n||s===n)&&(!r||r===a)){if(i.splice(o,1),i.length===0){delete this.eventListeners[t];break}o--}}_fireChangeEvent(t,n,r){this._fire(t+azn,{oldVal:n,newVal:r})}addName(t){if(!this.hasName(t)){const n=this.name(),r=n?n+" "+t:t;this.name(r)}return this}hasName(t){if(!t)return!1;const n=this.name();return n?(n||"").split(/\s/g).indexOf(t)!==-1:!1}removeName(t){const n=(this.name()||"").split(/\s/g),r=n.indexOf(t);return r!==-1&&(n.splice(r,1),this.name(n.join(" "))),this}setAttr(t,n){const r=this[RHe+lt._capitalize(t)];return lt._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(on.autoDrawEnabled){const t=this.getLayer()||this.getStage();t?.batchDraw()}}_setAttr(t,n){const r=this.attrs[t];r===n&&!lt.isObject(n)||(n==null?delete this.attrs[t]:this.attrs[t]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(t,r,n),this._requestDraw())}_setComponentAttr(t,n,r){let i;r!==void 0&&(i=this.attrs[t],i||(this.attrs[t]=this.getAttr(t)),this.attrs[t][n]=r,this._fireChangeEvent(t,i,r))}_fireAndBubble(t,n,r){n&&this.nodeType===LHe&&(n.target=this);const i=[uzn,dzn,fzn,hzn,pzn,mzn];if(!(i.indexOf(t)!==-1&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r))){this._fire(t,n);const o=i.indexOf(t)!==-1&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!o&&(r&&r.parent?this._fireAndBubble.call(this.parent,t,n,r):this._fireAndBubble.call(this.parent,t,n))}}_getProtoListeners(t){var n,r;const{nodeType:i}=this,o=h_.protoListenerMap.get(i)||{};let s=o?.[t];if(s===void 0){s=[];let a=Object.getPrototypeOf(this);for(;a;){const l=(r=(n=a.eventListeners)===null||n===void 0?void 0:n[t])!==null&&r!==void 0?r:[];s.push(...l),a=Object.getPrototypeOf(a)}o[t]=s,h_.protoListenerMap.set(i,o)}return s}_fire(t,n){n=n||{},n.currentTarget=this,n.type=t;const r=this._getProtoListeners(t);if(r){const o=r.slice();for(let s=0;s<o.length;s++)o[s].handler.call(this,n)}const i=this.eventListeners[t];if(i){const o=i.slice(),s=o.length;for(let l=0;l<o.length;l++)o[l].handler.call(this,n);const a=this.eventListeners[t];if(a)for(let l=s;l<a.length;l++)a[l].handler.call(this,n)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const n=t?t.pointerId:void 0,r=this.getStage(),i=this.getAbsolutePosition();if(!r)return;const o=r._getPointerById(n)||r._changedPointerPositions[0]||i;Di._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-i.x,y:o.y-i.y},dragStatus:"ready",pointerId:n,startEvent:t})}startDrag(t,n=!0){Di._dragElements.has(this._id)||this._createDragElement(t);const r=Di._dragElements.get(this._id);r.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:r.startEvent&&r.startEvent.evt||t&&t.evt},n)}_setDragPosition(t,n){const r=this.getStage()._getPointerById(n.pointerId);if(!r)return;let i={x:r.x-n.offset.x,y:r.y-n.offset.y};const o=this.dragBoundFunc();if(o!==void 0){const s=o.call(this,i,t);s?i=s:lt.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==i.x||this._lastPos.y!==i.y)&&(this.setAbsolutePosition(i),this._requestDraw()),this._lastPos=i}stopDrag(t){const n=Di._dragElements.get(this._id);n&&(n.dragStatus="stopped"),Di._endDragBefore(t),Di._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Di._dragElements.get(this._id);return t?t.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(t.evt.button===void 0||on.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;Di._dragElements.forEach(r=>{this.isAncestorOf(r.node)&&(n=!0)}),n||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=Di._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&Di._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const n=this.getStage();if(!n)return!1;const r={x:-t.x,y:-t.y,width:n.width()+2*t.x,height:n.height()+2*t.y};return lt.haveIntersection(r,this.getClientRect())}static create(t,n){return lt._isString(t)&&(t=JSON.parse(t)),this._createNode(t,n)}static _createNode(t,n){let r=h_.prototype.getClassName.call(t),i=t.children,o,s,a;n&&(t.attrs.container=n),on[r]||(lt.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=on[r];if(o=new l(t.attrs),i)for(s=i.length,a=0;a<s;a++)o.add(h_._createNode(i[a]));return o}};sn.protoListenerMap=new Map,sn.prototype.nodeType="Node",sn.prototype._attrsAffectingSize=[],sn.prototype.eventListeners={},sn.prototype.on(yzn,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(S0),this._clearSelfAndDescendantCache(nm)}),sn.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(WQ)}),sn.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(VQ)}),sn.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(u6)});var Eo=qe.addGetterSetter;Eo(sn,"zIndex"),Eo(sn,"absolutePosition"),Eo(sn,"position"),Eo(sn,"x",0,Zt()),Eo(sn,"y",0,Zt()),Eo(sn,"globalCompositeOperation","source-over",Qb()),Eo(sn,"opacity",1,Zt()),Eo(sn,"name","",Qb()),Eo(sn,"id","",Qb()),Eo(sn,"rotation",0,Zt()),qe.addComponentsGetterSetter(sn,"scale",["x","y"]),Eo(sn,"scaleX",1,Zt()),Eo(sn,"scaleY",1,Zt()),qe.addComponentsGetterSetter(sn,"skew",["x","y"]),Eo(sn,"skewX",0,Zt()),Eo(sn,"skewY",0,Zt()),qe.addComponentsGetterSetter(sn,"offset",["x","y"]),Eo(sn,"offsetX",0,Zt()),Eo(sn,"offsetY",0,Zt()),Eo(sn,"dragDistance",void 0,Zt()),Eo(sn,"width",0,Zt()),Eo(sn,"height",0,Zt()),Eo(sn,"listening",!0,yf()),Eo(sn,"preventDefault",!0,yf()),Eo(sn,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),Eo(sn,"visible",!0,yf()),Eo(sn,"transformsEnabled","all",Qb()),Eo(sn,"size"),Eo(sn,"dragBoundFunc"),Eo(sn,"draggable",!1,yf()),qe.backCompat(sn,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Su=class extends sn{constructor(){super(...arguments),this.children=[]}getChildren(e){const t=this.children||[];return e?t.filter(e):t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let n=0;n<e.length;n++)this.add(e[n]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){const t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){const n=[];return this._descendants(r=>{const i=r._isMatch(e);return i&&n.push(r),!!(i&&t)}),n}_descendants(e){let t=!1;const n=this.getChildren();for(const r of n){if(t=e(r),t)return!0;if(r.hasChildren()&&(t=r._descendants(e),t))return!0}return!1}toObject(){const e=sn.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){const t=sn.prototype.clone.call(this,e);return this.getChildren().forEach(function(n){t.add(n.clone())}),t}getAllIntersections(e){const t=[];return this.find("Shape").forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(n){n._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,n){t.index=n}),this._requestDraw()}drawScene(e,t,n){const r=this.getLayer(),i=e||r&&r.getCanvas(),o=i&&i.getContext(),s=this._getCanvasCache(),a=s&&s.scene,l=i&&i.isCache;if(!this.isVisible()&&!l)return this;if(a){o.save();const c=this.getAbsoluteTransform(t).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(o),o.restore()}else this._drawChildren("drawScene",i,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;const n=this.getLayer(),r=e||n&&n.hitCanvas,i=r&&r.getContext(),o=this._getCanvasCache();if(o&&o.hit){i.save();const s=this.getAbsoluteTransform(t).getMatrix();i.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(i),i.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n,r){var i;const o=t&&t.getContext(),s=this.clipWidth(),a=this.clipHeight(),l=this.clipFunc(),c=typeof s=="number"&&typeof a=="number"||l,u=n===this;if(c){o.save();const f=this.getAbsoluteTransform(n);let h=f.getMatrix();o.transform(h[0],h[1],h[2],h[3],h[4],h[5]),o.beginPath();let p;if(l)p=l.call(this,o,this);else{const m=this.clipX(),g=this.clipY();o.rect(m||0,g||0,s,a)}o.clip.apply(o,p),h=f.copy().invert().getMatrix(),o.transform(h[0],h[1],h[2],h[3],h[4],h[5])}const d=!u&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";d&&(o.save(),o._applyGlobalCompositeOperation(this)),(i=this.children)===null||i===void 0||i.forEach(function(f){f[e](t,n,r)}),d&&o.restore(),c&&o.restore()}getClientRect(e={}){var t;const n=e.skipTransform,r=e.relativeTo;let i,o,s,a,l={x:1/0,y:1/0,width:0,height:0};const c=this;(t=this.children)===null||t===void 0||t.forEach(function(f){if(!f.visible())return;const h=f.getClientRect({relativeTo:c,skipShadow:e.skipShadow,skipStroke:e.skipStroke});h.width===0&&h.height===0||(i===void 0?(i=h.x,o=h.y,s=h.x+h.width,a=h.y+h.height):(i=Math.min(i,h.x),o=Math.min(o,h.y),s=Math.max(s,h.x+h.width),a=Math.max(a,h.y+h.height)))});const u=this.find("Shape");let d=!1;for(let f=0;f<u.length;f++)if(u[f]._isVisible(this)){d=!0;break}return d&&i!==void 0?l={x:i,y:o,width:s-i,height:a-o}:l={x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,r)}};qe.addComponentsGetterSetter(Su,"clip",["x","y","width","height"]),qe.addGetterSetter(Su,"clipX",void 0,Zt()),qe.addGetterSetter(Su,"clipY",void 0,Zt()),qe.addGetterSetter(Su,"clipWidth",void 0,Zt()),qe.addGetterSetter(Su,"clipHeight",void 0,Zt()),qe.addGetterSetter(Su,"clipFunc");var T2=new Map,MHe=on._global.PointerEvent!==void 0;function GQ(e){return T2.get(e)}function jQ(e){return{evt:e,pointerId:e.pointerId}}function DHe(e,t){return T2.get(e)===t}function OHe(e,t){I2(e),t.getStage()&&(T2.set(e,t),MHe&&t._fire("gotpointercapture",jQ(new PointerEvent("gotpointercapture"))))}function I2(e,t){const n=T2.get(e);if(!n)return;const r=n.getStage();r&&r.content,T2.delete(e),MHe&&n._fire("lostpointercapture",jQ(new PointerEvent("lostpointercapture")))}var vzn="Stage",wzn="string",FHe="px",Azn="mouseout",BHe="mouseleave",HHe="mouseover",zHe="mouseenter",UHe="mousemove",VHe="mousedown",WHe="mouseup",k2="pointermove",E2="pointerdown",kS="pointerup",C2="pointercancel",xzn="lostpointercapture",f6="pointerout",_2="pointerleave",h6="pointerover",p6="pointerenter",qQ="contextmenu",GHe="touchstart",jHe="touchend",qHe="touchmove",YHe="touchcancel",YQ="wheel",Szn=5,Tzn=[[zHe,"_pointerenter"],[VHe,"_pointerdown"],[UHe,"_pointermove"],[WHe,"_pointerup"],[BHe,"_pointerleave"],[GHe,"_pointerdown"],[qHe,"_pointermove"],[jHe,"_pointerup"],[YHe,"_pointercancel"],[HHe,"_pointerover"],[YQ,"_wheel"],[qQ,"_contextmenu"],[E2,"_pointerdown"],[k2,"_pointermove"],[kS,"_pointerup"],[C2,"_pointercancel"],[_2,"_pointerleave"],[xzn,"_lostpointercapture"]],KQ={mouse:{[f6]:Azn,[_2]:BHe,[h6]:HHe,[p6]:zHe,[k2]:UHe,[E2]:VHe,[kS]:WHe,[C2]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[f6]:"touchout",[_2]:"touchleave",[h6]:"touchover",[p6]:"touchenter",[k2]:qHe,[E2]:GHe,[kS]:jHe,[C2]:YHe,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[f6]:f6,[_2]:_2,[h6]:h6,[p6]:p6,[k2]:k2,[E2]:E2,[kS]:kS,[C2]:C2,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},P2=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",ES=e=>{const t=P2(e);if(t==="pointer")return on.pointerEventsEnabled&&KQ.pointer;if(t==="touch")return KQ.touch;if(t==="mouse")return KQ.mouse};function KHe(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&<.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var Izn="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";const R2=[];var m6=class extends Su{constructor(e){super(KHe(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),R2.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{KHe(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||lt.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===wzn){let t;if(e.charAt(0)==="."){const n=e.slice(1);e=document.getElementsByClassName(n)[0]}else e.charAt(0)!=="#"?t=e:t=e.slice(1),e=document.getElementById(t);if(!e)throw"Can not find container in document with id "+t}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),Su.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&<._isInDocument(e)&&this.container().removeChild(e);const t=R2.indexOf(this);return t>-1&&R2.splice(t,1),lt.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(lt.warn(Izn),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();const t=new A0({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(i){if(!i.isVisible())return;const o=i._toKonvaCanvas(e);n.drawImage(o._canvas,e.x,e.y,o.getWidth()/o.getPixelRatio(),o.getHeight()/o.getPixelRatio())}),t}getIntersection(e){if(!e)return null;const t=this.children,n=t.length-1;for(let r=n;r>=0;r--){const i=t[r].getIntersection(e);if(i)return i}return null}_resizeDOM(){const e=this.width(),t=this.height();this.content&&(this.content.style.width=e+FHe,this.content.style.height=t+FHe),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(e);const n=this.children.length;return n>Szn&<.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),on.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return DHe(e,this)}setPointerCapture(e){OHe(e,this)}releaseCapture(e){I2(e,this)}getLayers(){return this.children}_bindContentEvents(){on.isBrowser&&Tzn.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=ES(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=ES(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=ES(e.type),n=P2(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),i=!(on.isDragging()||on.isTransforming())||on.hitOnDragEnabled;r&&i?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):i&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){const t=ES(e.type),n=P2(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{const o=this.getIntersection(i);if(Di.justDragged=!1,on["_"+n+"ListenClick"]=!0,!o||!o.isListening()){this[n+"ClickStartShape"]=void 0;return}on.capturePointerEventsEnabled&&o.setPointerCapture(i.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;const s=e.type.indexOf("touch")>=0;o.preventDefault()&&e.cancelable&&s&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){const t=ES(e.type),n=P2(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(on.isDragging()&&Di.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(on.isDragging()||on.isTransforming())||on.hitOnDragEnabled))return;const i={};let o=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=GQ(a.id)||this.getIntersection(a),c=a.id,u={evt:e,pointerId:c},d=s!==l;if(d&&s&&(s._fireAndBubble(t.pointerout,{...u},l),s._fireAndBubble(t.pointerleave,{...u},l)),l){if(i[l._id])return;i[l._id]=!0}l&&l.isListening()?(o=!0,d&&(l._fireAndBubble(t.pointerover,{...u},s),l._fireAndBubble(t.pointerenter,{...u},s),this[n+"targetShape"]=l),l._fireAndBubble(t.pointermove,{...u})):s&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:c}),this[n+"targetShape"]=null)}),o||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=ES(e.type),n=P2(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],i=this[n+"ClickEndShape"],o={};let s=!1;this._changedPointerPositions.forEach(a=>{const l=GQ(a.id)||this.getIntersection(a);if(l){if(l.releaseCapture(a.id),o[l._id])return;o[l._id]=!0}const c=a.id,u={evt:e,pointerId:c};let d=!1;on["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):Di.justDragged||(on["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){on["_"+n+"InDblClickWindow"]=!1},on.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...u}),on["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,{...u}),d&&i&&i===l&&l._fireAndBubble(t.pointerdblclick,{...u}))):(this[n+"ClickEndShape"]=null,s||(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s=!0),on["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:c}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:c}))}),s||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),on["_"+n+"ListenClick"]=!1,e.cancelable&&n!=="touch"&&n!=="pointer"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(qQ,{evt:e}):this._fire(qQ,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(YQ,{evt:e}):this._fire(YQ,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=GQ(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(kS,jQ(e)),I2(e.pointerId)}_lostpointercapture(e){I2(e.pointerId)}setPointersPositions(e){const t=this._getContentPosition();let n=null,r=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,i=>{this._pointerPositions.push({id:i.identifier,x:(i.clientX-t.left)/t.scaleX,y:(i.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,i=>{this._changedPointerPositions.push({id:i.identifier,x:(i.clientX-t.left)/t.scaleX,y:(i.clientY-t.top)/t.scaleY})})):(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:lt._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:lt._getFirstPointerId(e)}])}_setPointerPosition(e){lt.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new A0({width:this.width(),height:this.height()}),this.bufferHitCanvas=new zQ({pixelRatio:1,width:this.width(),height:this.height()}),!on.isBrowser)return;const e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}cache(){return lt.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};m6.prototype.nodeType=vzn,ms(m6),qe.addGetterSetter(m6,"container"),on.isBrowser&&document.addEventListener("visibilitychange",()=>{R2.forEach(e=>{e.batchDraw()})});var XHe="hasShadow",JHe="shadowRGBA",ZHe="patternImage",QHe="linearGradient",$He="radialGradient",g6;function XQ(){return g6||(g6=lt.createCanvasElement().getContext("2d"),g6)}const L2={};function kzn(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function Ezn(e){e.stroke()}function Czn(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function _zn(e){e.stroke()}function Pzn(){this._clearCache(XHe)}function Rzn(){this._clearCache(JHe)}function Lzn(){this._clearCache(ZHe)}function Nzn(){this._clearCache(QHe)}function Mzn(){this._clearCache($He)}var Gt=class extends sn{constructor(e){super(e);let t,n=0;for(;t=lt.getHitColor(),!(t&&!(t in L2));)if(n++,n>=1e4){lt.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),t=lt.getRandomColor();break}this.colorKey=t,L2[t]=this}getContext(){return lt.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return lt.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(XHe,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(ZHe,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=XQ().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new gf;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(on.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),r=typeof DOMMatrix>"u"?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(QHe,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=XQ(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let o=0;o<e.length;o+=2)i.addColorStop(e[o],e[o+1]);return i}}_getRadialGradient(){return this._getCache($He,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=XQ(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),i=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let o=0;o<e.length;o+=2)i.addColorStop(e[o],e[o+1]);return i}}getShadowRGBA(){return this._getCache(JHe,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const e=lt.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){const t=this.getStage();if(!t)return!1;const n=t.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return sn.prototype.destroy.call(this),delete L2[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!(!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0)||t))return!1;const n=e||this.hasFill(),r=this.hasStroke(),i=this.getAbsoluteOpacity()!==1;if(n&&r&&i)return!0;const o=this.hasShadow(),s=this.shadowForStrokeEnabled();return!!(n&&r&&o&&s)}setStrokeHitEnabled(e){lt.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){const e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,n=this.getParent();for(;n;){if(n.isCached()){t=!0;break}n=n.getParent()}const r=e.skipTransform,i=e.relativeTo||t&&this.getStage()||void 0,o=this.getSelfRect(),s=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=o.width+s,l=o.height+s,c=!e.skipShadow&&this.hasShadow(),u=c?this.shadowOffsetX():0,d=c?this.shadowOffsetY():0,f=a+Math.abs(u),h=l+Math.abs(d),p=c&&this.shadowBlur()||0,m={width:f+p*2,height:h+p*2,x:-(s/2+p)+Math.min(u,0)+o.x,y:-(s/2+p)+Math.min(d,0)+o.y};return r?m:this._transformedRect(m,i)}drawScene(e,t,n){const r=this.getLayer(),i=(e||r.getCanvas()).getContext(),o=this._getCanvasCache(),s=this.getSceneFunc(),a=this.hasShadow();let l;const c=t===this;if(!this.isVisible()&&!c)return this;if(o){i.save();const u=this.getAbsoluteTransform(t).getMatrix();return i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(i),i.restore(),this}if(!s)return this;if(i.save(),this._useBufferCanvas()){l=this.getStage();const u=n||l.bufferCanvas,d=u.getContext();n?(d.save(),d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,u.width,u.height),d.restore()):d.clear(),d.save(),d._applyLineJoin(this),d._applyMiterLimit(this);const f=this.getAbsoluteTransform(t).getMatrix();d.transform(f[0],f[1],f[2],f[3],f[4],f[5]),s.call(this,d,this),d.restore();const h=u.pixelRatio;a&&i._applyShadow(this),c||(i._applyOpacity(this),i._applyGlobalCompositeOperation(this)),i.drawImage(u._canvas,u.x||0,u.y||0,u.width/h,u.height/h)}else{if(i._applyLineJoin(this),i._applyMiterLimit(this),!c){const u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),i._applyOpacity(this),i._applyGlobalCompositeOperation(this)}a&&i._applyShadow(this),s.call(this,i,this)}return i.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;const r=this.getLayer(),i=e||r.hitCanvas,o=i&&i.getContext(),s=this.hitFunc()||this.sceneFunc(),a=this._getCanvasCache(),l=a&&a.hit;if(this.colorKey||lt.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){o.save();const c=this.getAbsoluteTransform(t).getMatrix();return o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!s)return this;if(o.save(),o._applyLineJoin(this),o._applyMiterLimit(this),this!==t){const c=this.getAbsoluteTransform(t).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return s.call(this,o,this),o.restore(),this}drawHitFromCache(e=0){const t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,i=r.getContext(),o=r.getWidth(),s=r.getHeight();i.clear(),i.drawImage(n._canvas,0,0,o,s);try{const a=i.getImageData(0,0,o,s),l=a.data,c=l.length,u=lt._hexToRgb(this.colorKey);for(let d=0;d<c;d+=4)l[d+3]>e?(l[d]=u.r,l[d+1]=u.g,l[d+2]=u.b,l[d+3]=255):l[d+3]=0;i.putImageData(a,0,0)}catch(a){lt.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(e){return DHe(e,this)}setPointerCapture(e){OHe(e,this)}releaseCapture(e){I2(e,this)}};Gt.prototype._fillFunc=kzn,Gt.prototype._strokeFunc=Ezn,Gt.prototype._fillFuncHit=Czn,Gt.prototype._strokeFuncHit=_zn,Gt.prototype._centroid=!1,Gt.prototype.nodeType="Shape",ms(Gt),Gt.prototype.eventListeners={},Gt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Pzn),Gt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Rzn),Gt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",Lzn),Gt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",Nzn),Gt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",Mzn),qe.addGetterSetter(Gt,"stroke",void 0,CHe()),qe.addGetterSetter(Gt,"strokeWidth",2,Zt()),qe.addGetterSetter(Gt,"fillAfterStrokeEnabled",!1),qe.addGetterSetter(Gt,"hitStrokeWidth","auto",UQ()),qe.addGetterSetter(Gt,"strokeHitEnabled",!0,yf()),qe.addGetterSetter(Gt,"perfectDrawEnabled",!0,yf()),qe.addGetterSetter(Gt,"shadowForStrokeEnabled",!0,yf()),qe.addGetterSetter(Gt,"lineJoin"),qe.addGetterSetter(Gt,"lineCap"),qe.addGetterSetter(Gt,"miterLimit"),qe.addGetterSetter(Gt,"sceneFunc"),qe.addGetterSetter(Gt,"hitFunc"),qe.addGetterSetter(Gt,"dash"),qe.addGetterSetter(Gt,"dashOffset",0,Zt()),qe.addGetterSetter(Gt,"shadowColor",void 0,Qb()),qe.addGetterSetter(Gt,"shadowBlur",0,Zt()),qe.addGetterSetter(Gt,"shadowOpacity",1,Zt()),qe.addComponentsGetterSetter(Gt,"shadowOffset",["x","y"]),qe.addGetterSetter(Gt,"shadowOffsetX",0,Zt()),qe.addGetterSetter(Gt,"shadowOffsetY",0,Zt()),qe.addGetterSetter(Gt,"fillPatternImage"),qe.addGetterSetter(Gt,"fill",void 0,CHe()),qe.addGetterSetter(Gt,"fillPatternX",0,Zt()),qe.addGetterSetter(Gt,"fillPatternY",0,Zt()),qe.addGetterSetter(Gt,"fillLinearGradientColorStops"),qe.addGetterSetter(Gt,"strokeLinearGradientColorStops"),qe.addGetterSetter(Gt,"fillRadialGradientStartRadius",0),qe.addGetterSetter(Gt,"fillRadialGradientEndRadius",0),qe.addGetterSetter(Gt,"fillRadialGradientColorStops"),qe.addGetterSetter(Gt,"fillPatternRepeat","repeat"),qe.addGetterSetter(Gt,"fillEnabled",!0),qe.addGetterSetter(Gt,"strokeEnabled",!0),qe.addGetterSetter(Gt,"shadowEnabled",!0),qe.addGetterSetter(Gt,"dashEnabled",!0),qe.addGetterSetter(Gt,"strokeScaleEnabled",!0),qe.addGetterSetter(Gt,"fillPriority","color"),qe.addComponentsGetterSetter(Gt,"fillPatternOffset",["x","y"]),qe.addGetterSetter(Gt,"fillPatternOffsetX",0,Zt()),qe.addGetterSetter(Gt,"fillPatternOffsetY",0,Zt()),qe.addComponentsGetterSetter(Gt,"fillPatternScale",["x","y"]),qe.addGetterSetter(Gt,"fillPatternScaleX",1,Zt()),qe.addGetterSetter(Gt,"fillPatternScaleY",1,Zt()),qe.addComponentsGetterSetter(Gt,"fillLinearGradientStartPoint",["x","y"]),qe.addComponentsGetterSetter(Gt,"strokeLinearGradientStartPoint",["x","y"]),qe.addGetterSetter(Gt,"fillLinearGradientStartPointX",0),qe.addGetterSetter(Gt,"strokeLinearGradientStartPointX",0),qe.addGetterSetter(Gt,"fillLinearGradientStartPointY",0),qe.addGetterSetter(Gt,"strokeLinearGradientStartPointY",0),qe.addComponentsGetterSetter(Gt,"fillLinearGradientEndPoint",["x","y"]),qe.addComponentsGetterSetter(Gt,"strokeLinearGradientEndPoint",["x","y"]),qe.addGetterSetter(Gt,"fillLinearGradientEndPointX",0),qe.addGetterSetter(Gt,"strokeLinearGradientEndPointX",0),qe.addGetterSetter(Gt,"fillLinearGradientEndPointY",0),qe.addGetterSetter(Gt,"strokeLinearGradientEndPointY",0),qe.addComponentsGetterSetter(Gt,"fillRadialGradientStartPoint",["x","y"]),qe.addGetterSetter(Gt,"fillRadialGradientStartPointX",0),qe.addGetterSetter(Gt,"fillRadialGradientStartPointY",0),qe.addComponentsGetterSetter(Gt,"fillRadialGradientEndPoint",["x","y"]),qe.addGetterSetter(Gt,"fillRadialGradientEndPointX",0),qe.addGetterSetter(Gt,"fillRadialGradientEndPointY",0),qe.addGetterSetter(Gt,"fillPatternRotation",0),qe.addGetterSetter(Gt,"fillRule",void 0,Qb()),qe.backCompat(Gt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var Dzn="beforeDraw",Ozn="draw",eze=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Fzn=eze.length,ev=class extends Su{constructor(e){super(e),this.canvas=new A0,this.hitCanvas=new zQ({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){sn.prototype.moveToTop.call(this);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!sn.prototype.moveUp.call(this))return!1;const e=this.getStage();return!e||!e.content?!1:(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(sn.prototype.moveDown.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(sn.prototype.moveToBottom.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return sn.prototype.remove.call(this),e&&e.parentNode&<._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&<.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),sn.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){lt.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){lt.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,lt.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,n=!1;for(;;){for(let r=0;r<Fzn;r++){const i=eze[r],o=this._getIntersection({x:e.x+i.x*t,y:e.y+i.y*t}),s=o.shape;if(s)return s;if(n=!!o.antialiased,!o.antialiased)break}if(n)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(r===255){const i=L2[lt.getHitColorKey(n[0],n[1],n[2])];return i?{shape:i}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,t,n){const r=this.getLayer(),i=e||r&&r.getCanvas();return this._fire(Dzn,{node:this}),this.clearBeforeDraw()&&i.getContext().clear(),Su.prototype.drawScene.call(this,i,t,n),this._fire(Ozn,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Su.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){lt.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return lt.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return lt.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};ev.prototype.nodeType="Layer",ms(ev),qe.addGetterSetter(ev,"imageSmoothingEnabled",!0),qe.addGetterSetter(ev,"clearBeforeDraw",!0),qe.addGetterSetter(ev,"hitGraphEnabled",!0,yf());var JQ=class extends ev{constructor(e){super(e),this.listening(!1),lt.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};JQ.prototype.nodeType="FastLayer",ms(JQ);var CS=class extends Su{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&<.throw("You may only add groups and shapes to groups.")}};CS.prototype.nodeType="Group",ms(CS);var ZQ=(function(){return Zb.performance&&Zb.performance.now?function(){return Zb.performance.now()}:function(){return new Date().getTime()}})(),_S=class XS{constructor(t,n){this.id=XS.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:ZQ(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(t){let n=[];return t&&(n=Array.isArray(t)?t:[t]),this.layers=n,this}getLayers(){return this.layers}addLayer(t){const n=this.layers,r=n.length;for(let i=0;i<r;i++)if(n[i]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=XS.animations,n=t.length;for(let r=0;r<n;r++)if(t[r].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=ZQ(),XS._addAnimation(this),this}stop(){return XS._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const n=t.id,r=this.animations,i=r.length;for(let o=0;o<i;o++)if(r[o].id===n){this.animations.splice(o,1);break}}static _runFrames(){const t={},n=this.animations;for(let r=0;r<n.length;r++){const i=n[r],o=i.layers,s=i.func;i._updateFrameObject(ZQ());const a=o.length;let l;if(s?l=s.call(i,i.frame)!==!1:l=!0,!!l)for(let c=0;c<a;c++){const u=o[c];u._id!==void 0&&(t[u._id]=u)}}for(const r in t)t.hasOwnProperty(r)&&t[r].batchDraw()}static _animationLoop(){const t=XS;t.animations.length?(t._runFrames(),lt.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,lt.requestAnimFrame(this._animationLoop))}};_S.animations=[],_S.animIdCounter=0,_S.animRunning=!1;var Bzn={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Hzn=1,tze=2,nze=3,rze=["fill","stroke","shadowColor"],zzn=0,Uzn=class{constructor(e,t,n,r,i,o,s){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=s,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(e){const t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=tze,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=nze,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const e=this.getTimer()-this._startTime;this.state===tze?this.setTime(e):this.state===nze&&this.setTime(this.duration-e)}pause(){this.state=Hzn,this.fire("onPause")}getTimer(){return new Date().getTime()}},y6=class Cs{constructor(t){const n=this,r=t.node,i=r._id,o=t.easing||N2.Linear,s=!!t.yoyo;let a,l;typeof t.duration>"u"?a=.3:t.duration===0?a=.001:a=t.duration,this.node=r,this._id=zzn++;const c=r.getLayer()||(r instanceof on.Stage?r.getLayers():null);c||lt.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new _S(function(){n.tween.onEnterFrame()},c),this.tween=new Uzn(l,function(u){n._tweenFunc(u)},o,0,1,a*1e3,s),this._addListeners(),Cs.attrs[i]||(Cs.attrs[i]={}),Cs.attrs[i][this._id]||(Cs.attrs[i][this._id]={}),Cs.tweens[i]||(Cs.tweens[i]={});for(l in t)Bzn[l]===void 0&&this._addAttr(l,t[l]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){const r=this.node,i=r._id;let o,s,a,l,c;const u=Cs.tweens[i][t];u&&delete Cs.attrs[i][u][t];let d=r.getAttr(t);if(lt._isArray(n))if(o=[],s=Math.max(n.length,d.length),t==="points"&&n.length!==d.length&&(n.length>d.length?(l=d,d=lt._prepareArrayForTween(d,n,r.closed())):(a=n,n=lt._prepareArrayForTween(n,d,r.closed()))),t.indexOf("fill")===0)for(let f=0;f<s;f++)if(f%2===0)o.push(n[f]-d[f]);else{const h=lt.colorToRGBA(d[f]);c=lt.colorToRGBA(n[f]),d[f]=h,o.push({r:c.r-h.r,g:c.g-h.g,b:c.b-h.b,a:c.a-h.a})}else for(let f=0;f<s;f++)o.push(n[f]-d[f]);else rze.indexOf(t)!==-1?(d=lt.colorToRGBA(d),c=lt.colorToRGBA(n),o={r:c.r-d.r,g:c.g-d.g,b:c.b-d.b,a:c.a-d.a}):o=n-d;Cs.attrs[i][this._id][t]={start:d,diff:o,end:n,trueEnd:a,trueStart:l},Cs.tweens[i][t]=this._id}_tweenFunc(t){const n=this.node,r=Cs.attrs[n._id][this._id];let i,o,s,a,l,c,u,d;for(i in r){if(o=r[i],s=o.start,a=o.diff,d=o.end,lt._isArray(s))if(l=[],u=Math.max(s.length,d.length),i.indexOf("fill")===0)for(c=0;c<u;c++)c%2===0?l.push((s[c]||0)+a[c]*t):l.push("rgba("+Math.round(s[c].r+a[c].r*t)+","+Math.round(s[c].g+a[c].g*t)+","+Math.round(s[c].b+a[c].b*t)+","+(s[c].a+a[c].a*t)+")");else for(c=0;c<u;c++)l.push((s[c]||0)+a[c]*t);else rze.indexOf(i)!==-1?l="rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":l=s+a*t;n.setAttr(i,l)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,n=Cs.attrs[t._id][this._id];n.points&&n.points.trueEnd&&t.setAttr("points",n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,n=Cs.attrs[t._id][this._id];n.points&&n.points.trueStart&&t.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(t*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,n=this._id,r=Cs.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const i in r)delete Cs.tweens[t][i];delete Cs.attrs[t][n],Cs.tweens[t]&&(Object.keys(Cs.tweens[t]).length===0&&delete Cs.tweens[t],Object.keys(Cs.attrs[t]).length===0&&delete Cs.attrs[t])}};y6.attrs={},y6.tweens={},sn.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new y6(e).play()};const N2={BackEaseIn(e,t,n,r){return n*(e/=r)*e*((1.70158+1)*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*((1.70158+1)*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let i=1.70158;return(e/=r/2)<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},ElasticEaseIn(e,t,n,r,i,o){let s=0;return e===0?t:(e/=r)===1?t+n:(o||(o=r*.3),!i||i<Math.abs(n)?(i=n,s=o/4):s=o/(2*Math.PI)*Math.asin(n/i),-(i*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/o))+t)},ElasticEaseOut(e,t,n,r,i,o){let s=0;return e===0?t:(e/=r)===1?t+n:(o||(o=r*.3),!i||i<Math.abs(n)?(i=n,s=o/4):s=o/(2*Math.PI)*Math.asin(n/i),i*Math.pow(2,-10*e)*Math.sin((e*r-s)*(2*Math.PI)/o)+n+t)},ElasticEaseInOut(e,t,n,r,i,o){let s=0;return e===0?t:(e/=r/2)===2?t+n:(o||(o=r*(.3*1.5)),!i||i<Math.abs(n)?(i=n,s=o/4):s=o/(2*Math.PI)*Math.asin(n/i),e<1?-.5*(i*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/o))+t:i*Math.pow(2,-10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/o)*.5+n+t)},BounceEaseOut(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},BounceEaseIn(e,t,n,r){return n-N2.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?N2.BounceEaseIn(e*2,0,n,r)*.5+t:N2.BounceEaseOut(e*2-r,0,n,r)*.5+n*.5+t},EaseIn(e,t,n,r){return n*(e/=r)*e+t},EaseOut(e,t,n,r){return-n*(e/=r)*(e-2)+t},EaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,n,r){return n*(e/=r)*e*e*e*e+t},StrongEaseOut(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,n,r){return n*e/r+t}},ize=lt._assign(on,{Util:lt,Transform:gf,Node:sn,Container:Su,Stage:m6,stages:R2,Layer:ev,FastLayer:JQ,Group:CS,DD:Di,Shape:Gt,shapes:L2,Animation:_S,Tween:y6,Easings:N2,Context:a6,Canvas:HQ});var rm=class extends Gt{_sceneFunc(e){const t=on.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=on.getAngle(n?360-this.angle():this.angle()),i=Math.cos(Math.min(r,Math.PI)),o=1,s=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),a=Math.sin(Math.min(r,Math.PI/2)),l=i*(i>0?e:t),c=o*(o>0?t:e),u=s*(s>0?e:t),d=a*(a>0?t:e);return{x:l,y:n?-1*d:u,width:c-l,height:d-u}}};rm.prototype._centroid=!0,rm.prototype.className="Arc",rm.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],ms(rm),qe.addGetterSetter(rm,"innerRadius",0,Zt()),qe.addGetterSetter(rm,"outerRadius",0,Zt()),qe.addGetterSetter(rm,"angle",0,Zt()),qe.addGetterSetter(rm,"clockwise",!1,yf());function QQ(e,t,n,r,i,o,s){const a=Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2)),l=Math.sqrt(Math.pow(i-n,2)+Math.pow(o-r,2)),c=s*a/(a+l),u=s*l/(a+l);return[n-c*(i-e),r-c*(o-t),n+u*(i-e),r+u*(o-t)]}function oze(e,t){const n=e.length,r=[];for(let i=2;i<n-2;i+=2){const o=QQ(e[i-2],e[i-1],e[i],e[i+1],e[i+2],e[i+3],t);isNaN(o[0])||(r.push(o[0]),r.push(o[1]),r.push(e[i]),r.push(e[i+1]),r.push(o[2]),r.push(o[3]))}return r}function Vzn(e){const t=[[e[0],e[2],e[4],e[6]],[e[1],e[3],e[5],e[7]]],n=[];for(const r of t){const i=-3*r[0]+9*r[1]-9*r[2]+3*r[3];if(i!==0){const o=6*r[0]-12*r[1]+6*r[2],s=-3*r[0]+3*r[1],a=o*o-4*i*s;if(a>=0){const l=Math.sqrt(a);n.push((-o+l)/(2*i)),n.push((-o-l)/(2*i))}}}return n.filter(r=>r>0&&r<1).flatMap(r=>t.map(i=>{const o=1-r;return o*o*o*i[0]+3*o*o*r*i[1]+3*o*r*r*i[2]+r*r*r*i[3]}))}var im=class extends Gt{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){const t=this.points(),n=t.length,r=this.tension(),i=this.closed(),o=this.bezier();if(!n)return;let s=0;if(e.beginPath(),e.moveTo(t[0],t[1]),r!==0&&n>4){const a=this.getTensionPoints(),l=a.length;for(s=i?0:4,i||e.quadraticCurveTo(a[0],a[1],a[2],a[3]);s<l-2;)e.bezierCurveTo(a[s++],a[s++],a[s++],a[s++],a[s++],a[s++]);i||e.quadraticCurveTo(a[l-2],a[l-1],t[n-2],t[n-1])}else if(o)for(s=2;s<n;)e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);else for(s=2;s<n;s+=2)e.lineTo(t[s],t[s+1]);i?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():oze(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=QQ(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),i=QQ(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),o=oze(e,n);return[r[2],r[3]].concat(o).concat([i[0],i[1],e[t-2],e[t-1],i[2],i[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.bezier()?e=[e[0],e[1],...Vzn(this.points()),e[e.length-2],e[e.length-1]]:e=this.points();let t=e[0],n=e[0],r=e[1],i=e[1],o,s;for(let a=0;a<e.length/2;a++)o=e[a*2],s=e[a*2+1],t=Math.min(t,o),n=Math.max(n,o),r=Math.min(r,s),i=Math.max(i,s);return{x:t,y:r,width:n-t,height:i-r}}};im.prototype.className="Line",im.prototype._attrsAffectingSize=["points","bezier","tension"],ms(im),qe.addGetterSetter(im,"closed",!1),qe.addGetterSetter(im,"bezier",!1),qe.addGetterSetter(im,"tension",0,Zt()),qe.addGetterSetter(im,"points",[],izn());const Wzn=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],Gzn=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],jzn=[[1],[1,1],[1,2,1],[1,3,3,1]],sze=(e,t,n)=>{let r,i;const s=n/2;r=0;for(let a=0;a<20;a++)i=s*Wzn[20][a]+s,r+=Gzn[20][a]*qzn(e,t,i);return s*r},aze=(e,t,n)=>{n===void 0&&(n=1);const r=e[0]-2*e[1]+e[2],i=t[0]-2*t[1]+t[2],o=2*e[1]-2*e[0],s=2*t[1]-2*t[0],a=4*(r*r+i*i),l=4*(r*o+i*s),c=o*o+s*s;if(a===0)return n*Math.sqrt(Math.pow(e[2]-e[0],2)+Math.pow(t[2]-t[0],2));const u=l/(2*a),d=c/a,f=n+u,h=d-u*u,p=f*f+h>0?Math.sqrt(f*f+h):0,m=u*u+h>0?Math.sqrt(u*u+h):0,g=u+Math.sqrt(u*u+h)!==0?h*Math.log(Math.abs((f+p)/(u+m))):0;return Math.sqrt(a)/2*(f*p-u*m+g)};function qzn(e,t,n){const r=$Q(1,n,e),i=$Q(1,n,t),o=r*r+i*i;return Math.sqrt(o)}var $Q=(e,t,n)=>{const r=n.length-1;let i,o;if(r===0)return 0;if(e===0){o=0;for(let s=0;s<=r;s++)o+=jzn[r][s]*Math.pow(1-t,r-s)*Math.pow(t,s)*n[s];return o}else{i=new Array(r);for(let s=0;s<r;s++)i[s]=r*(n[s+1]-n[s]);return $Q(e-1,t,i)}};const lze=(e,t,n)=>{let r=1,i=e/t,o=(e-n(i))/t,s=0;for(;r>.001;){const a=n(i+o),l=Math.abs(e-a)/t;if(l<r)r=l,i+=o;else{const c=n(i-o),u=Math.abs(e-c)/t;u<r?(r=u,i-=o):o/=2}if(s++,s>500)break}return i};var yd=class Yc extends Gt{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Yc.parsePathData(this.data()),this.pathLength=Yc.getPathLength(this.dataArray)}_sceneFunc(t){const n=this.dataArray;t.beginPath();let r=!1;for(let i=0;i<n.length;i++){const o=n[i].command,s=n[i].points;switch(o){case"L":t.lineTo(s[0],s[1]);break;case"M":t.moveTo(s[0],s[1]);break;case"C":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"Q":t.quadraticCurveTo(s[0],s[1],s[2],s[3]);break;case"A":const a=s[0],l=s[1],c=s[2],u=s[3],d=s[4],f=s[5],h=s[6],p=s[7],m=c>u?c:u,g=c>u?1:c/u,y=c>u?u/c:1;t.translate(a,l),t.rotate(h),t.scale(g,y),t.arc(0,0,m,d,d+f,1-p),t.scale(1/g,1/y),t.rotate(-h),t.translate(-a,-l);break;case"z":r=!0,t.closePath();break}}!r&&!this.hasFill()?t.strokeShape(this):t.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(l){if(l.command==="A"){const c=l.points[4],u=l.points[5],d=l.points[4]+u;let f=Math.PI/180;if(Math.abs(c-d)<f&&(f=Math.abs(c-d)),u<0)for(let h=c-f;h>d;h-=f){const p=Yc.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],h,0);t.push(p.x,p.y)}else for(let h=c+f;h<d;h+=f){const p=Yc.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],h,0);t.push(p.x,p.y)}}else if(l.command==="C")for(let c=0;c<=1;c+=.01){const u=Yc.getPointOnCubicBezier(c,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);t.push(u.x,u.y)}else t=t.concat(l.points)});let n=t[0],r=t[0],i=t[1],o=t[1],s,a;for(let l=0;l<t.length/2;l++)s=t[l*2],a=t[l*2+1],isNaN(s)||(n=Math.min(n,s),r=Math.max(r,s)),isNaN(a)||(i=Math.min(i,a),o=Math.max(o,a));return{x:n,y:i,width:r-n,height:o-i}}getLength(){return this.pathLength}getPointAtLength(t){return Yc.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,n,r,i){return Math.sqrt((r-t)*(r-t)+(i-n)*(i-n))}static getPathLength(t){let n=0;for(let r=0;r<t.length;++r)n+=t[r].pathLength;return n}static getPointAtLengthOfDataArray(t,n){let r,i=0,o=n.length;if(!o)return null;for(;i<o&&t>n[i].pathLength;)t-=n[i].pathLength,++i;if(i===o)return r=n[i-1].points.slice(-2),{x:r[0],y:r[1]};if(t<.01)return n[i].command==="M"?(r=n[i].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[i].start.x,y:n[i].start.y};const s=n[i],a=s.points;switch(s.command){case"L":return Yc.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return Yc.getPointOnCubicBezier(lze(t,Yc.getPathLength(n),m=>sze([s.start.x,a[0],a[2],a[4]],[s.start.y,a[1],a[3],a[5]],m)),s.start.x,s.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return Yc.getPointOnQuadraticBezier(lze(t,Yc.getPathLength(n),m=>aze([s.start.x,a[0],a[2]],[s.start.y,a[1],a[3]],m)),s.start.x,s.start.y,a[0],a[1],a[2],a[3]);case"A":const l=a[0],c=a[1],u=a[2],d=a[3],f=a[5],h=a[6];let p=a[4];return p+=f*t/s.pathLength,Yc.getPointOnEllipticalArc(l,c,u,d,p,h)}return null}static getPointOnLine(t,n,r,i,o,s,a){s=s??n,a=a??r;const l=this.getLineLength(n,r,i,o);if(l<1e-10)return{x:n,y:r};if(i===n)return{x:s,y:a+(o>r?t:-t)};const c=(o-r)/(i-n),u=Math.sqrt(t*t/(1+c*c))*(i<n?-1:1),d=c*u;if(Math.abs(a-r-c*(s-n))<1e-10)return{x:s+u,y:a+d};const f=((s-n)*(i-n)+(a-r)*(o-r))/(l*l),h=n+f*(i-n),p=r+f*(o-r),m=this.getLineLength(s,a,h,p),g=Math.sqrt(t*t-m*m),y=Math.sqrt(g*g/(1+c*c))*(i<n?-1:1),v=c*y;return{x:h+y,y:p+v}}static getPointOnCubicBezier(t,n,r,i,o,s,a,l,c){function u(p){return p*p*p}function d(p){return 3*p*p*(1-p)}function f(p){return 3*p*(1-p)*(1-p)}function h(p){return(1-p)*(1-p)*(1-p)}return{x:l*u(t)+s*d(t)+i*f(t)+n*h(t),y:c*u(t)+a*d(t)+o*f(t)+r*h(t)}}static getPointOnQuadraticBezier(t,n,r,i,o,s,a){function l(d){return d*d}function c(d){return 2*d*(1-d)}function u(d){return(1-d)*(1-d)}return{x:s*l(t)+i*c(t)+n*u(t),y:a*l(t)+o*c(t)+r*u(t)}}static getPointOnEllipticalArc(t,n,r,i,o,s){const a=Math.cos(s),l=Math.sin(s),c={x:r*Math.cos(o),y:i*Math.sin(o)};return{x:t+(c.x*a-c.y*l),y:n+(c.x*l+c.y*a)}}static parsePathData(t){if(!t)return[];let n=t;const r=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(let d=0;d<r.length;d++)n=n.replace(new RegExp(r[d],"g"),"|"+r[d]);const i=n.split("|"),o=[],s=[];let a=0,l=0;const c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let u;for(let d=1;d<i.length;d++){let f=i[d],h=f.charAt(0);for(f=f.slice(1),s.length=0;u=c.exec(f);)s.push(u[0]);let p=[],m=h==="A"||h==="a"?0:-1;for(let g=0,y=s.length;g<y;g++){const v=s[g];if(v==="00"){p.push(0,0),m>=0&&(m+=2,m>=7&&(m-=7));continue}if(m>=0){if(m===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(v)){p.push(parseInt(v[0],10)),p.push(parseInt(v[1],10)),p.push(parseFloat(v.slice(2))),m+=3,m>=7&&(m-=7);continue}if(v==="11"||v==="10"||v==="01"){p.push(parseInt(v[0],10)),p.push(parseInt(v[1],10)),m+=2,m>=7&&(m-=7);continue}if(v==="0"||v==="1"){p.push(parseInt(v,10)),m+=1,m>=7&&(m-=7);continue}}else if(m===4){if(/^[01]\d+(?:\.\d+)?$/.test(v)){p.push(parseInt(v[0],10)),p.push(parseFloat(v.slice(1))),m+=2,m>=7&&(m-=7);continue}if(v==="0"||v==="1"){p.push(parseInt(v,10)),m+=1,m>=7&&(m-=7);continue}}const b=parseFloat(v);isNaN(b)?p.push(0):p.push(b),m+=1,m>=7&&(m-=7)}else{const b=parseFloat(v);isNaN(b)?p.push(0):p.push(b)}}for(;p.length>0&&!isNaN(p[0]);){let g="",y=[];const v=a,b=l;let w,x,A,T,I,P,C,R,k,L;switch(h){case"l":a+=p.shift(),l+=p.shift(),g="L",y.push(a,l);break;case"L":a=p.shift(),l=p.shift(),y.push(a,l);break;case"m":const _=p.shift(),O=p.shift();if(a+=_,l+=O,g="M",o.length>2&&o[o.length-1].command==="z"){for(let F=o.length-2;F>=0;F--)if(o[F].command==="M"){a=o[F].points[0]+_,l=o[F].points[1]+O;break}}y.push(a,l),h="l";break;case"M":a=p.shift(),l=p.shift(),g="M",y.push(a,l),h="L";break;case"h":a+=p.shift(),g="L",y.push(a,l);break;case"H":a=p.shift(),g="L",y.push(a,l);break;case"v":l+=p.shift(),g="L",y.push(a,l);break;case"V":l=p.shift(),g="L",y.push(a,l);break;case"C":y.push(p.shift(),p.shift(),p.shift(),p.shift()),a=p.shift(),l=p.shift(),y.push(a,l);break;case"c":y.push(a+p.shift(),l+p.shift(),a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),g="C",y.push(a,l);break;case"S":x=a,A=l,w=o[o.length-1],w.command==="C"&&(x=a+(a-w.points[2]),A=l+(l-w.points[3])),y.push(x,A,p.shift(),p.shift()),a=p.shift(),l=p.shift(),g="C",y.push(a,l);break;case"s":x=a,A=l,w=o[o.length-1],w.command==="C"&&(x=a+(a-w.points[2]),A=l+(l-w.points[3])),y.push(x,A,a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),g="C",y.push(a,l);break;case"Q":y.push(p.shift(),p.shift()),a=p.shift(),l=p.shift(),y.push(a,l);break;case"q":y.push(a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),g="Q",y.push(a,l);break;case"T":x=a,A=l,w=o[o.length-1],w.command==="Q"&&(x=a+(a-w.points[0]),A=l+(l-w.points[1])),a=p.shift(),l=p.shift(),g="Q",y.push(x,A,a,l);break;case"t":x=a,A=l,w=o[o.length-1],w.command==="Q"&&(x=a+(a-w.points[0]),A=l+(l-w.points[1])),a+=p.shift(),l+=p.shift(),g="Q",y.push(x,A,a,l);break;case"A":T=p.shift(),I=p.shift(),P=p.shift(),C=p.shift(),R=p.shift(),k=a,L=l,a=p.shift(),l=p.shift(),g="A",y=this.convertEndpointToCenterParameterization(k,L,a,l,C,R,T,I,P);break;case"a":T=p.shift(),I=p.shift(),P=p.shift(),C=p.shift(),R=p.shift(),k=a,L=l,a+=p.shift(),l+=p.shift(),g="A",y=this.convertEndpointToCenterParameterization(k,L,a,l,C,R,T,I,P);break}o.push({command:g||h,points:y,start:{x:v,y:b},pathLength:this.calcLength(v,b,g||h,y)})}(h==="z"||h==="Z")&&o.push({command:"z",points:[],start:void 0,pathLength:0})}return o}static calcLength(t,n,r,i){let o,s,a,l;const c=Yc;switch(r){case"L":return c.getLineLength(t,n,i[0],i[1]);case"C":return sze([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case"Q":return aze([t,i[0],i[2]],[n,i[1],i[3]],1);case"A":o=0;const u=i[4],d=i[5],f=i[4]+d;let h=Math.PI/180;if(Math.abs(u-f)<h&&(h=Math.abs(u-f)),s=c.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],u,0),d<0)for(l=u-h;l>f;l-=h)a=c.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],l,0),o+=c.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(l=u+h;l<f;l+=h)a=c.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],l,0),o+=c.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=c.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],f,0),o+=c.getLineLength(s.x,s.y,a.x,a.y),o}return 0}static convertEndpointToCenterParameterization(t,n,r,i,o,s,a,l,c){const u=c*(Math.PI/180),d=Math.cos(u)*(t-r)/2+Math.sin(u)*(n-i)/2,f=-1*Math.sin(u)*(t-r)/2+Math.cos(u)*(n-i)/2,h=d*d/(a*a)+f*f/(l*l);h>1&&(a*=Math.sqrt(h),l*=Math.sqrt(h));let p=Math.sqrt((a*a*(l*l)-a*a*(f*f)-l*l*(d*d))/(a*a*(f*f)+l*l*(d*d)));o===s&&(p*=-1),isNaN(p)&&(p=0);const m=p*a*f/l,g=p*-l*d/a,y=(t+r)/2+Math.cos(u)*m-Math.sin(u)*g,v=(n+i)/2+Math.sin(u)*m+Math.cos(u)*g,b=function(C){return Math.sqrt(C[0]*C[0]+C[1]*C[1])},w=function(C,R){return(C[0]*R[0]+C[1]*R[1])/(b(C)*b(R))},x=function(C,R){return(C[0]*R[1]<C[1]*R[0]?-1:1)*Math.acos(w(C,R))},A=x([1,0],[(d-m)/a,(f-g)/l]),T=[(d-m)/a,(f-g)/l],I=[(-1*d-m)/a,(-1*f-g)/l];let P=x(T,I);return w(T,I)<=-1&&(P=Math.PI),w(T,I)>=1&&(P=0),s===0&&P>0&&(P=P-2*Math.PI),s===1&&P<0&&(P=P+2*Math.PI),[y,v,a,l,A,P,u,s]}};yd.prototype.className="Path",yd.prototype._attrsAffectingSize=["data"],ms(yd),qe.addGetterSetter(yd,"data");var tv=class extends im{_sceneFunc(e){super._sceneFunc(e);const t=Math.PI*2,n=this.points();let r=n;const i=this.tension()!==0&&n.length>4;i&&(r=this.getTensionPoints());const o=this.pointerLength(),s=n.length;let a,l;if(i){const d=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[s-2],n[s-1]],f=yd.calcLength(r[r.length-4],r[r.length-3],"C",d),h=yd.getPointOnQuadraticBezier(Math.min(1,1-o/f),d[0],d[1],d[2],d[3],d[4],d[5]);a=n[s-2]-h.x,l=n[s-1]-h.y}else a=n[s-2]-n[s-4],l=n[s-1]-n[s-3];const c=(Math.atan2(l,a)+t)%t,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[s-2],n[s-1]),e.rotate(c),e.moveTo(0,0),e.lineTo(-o,u/2),e.lineTo(-o,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),i?(a=(r[0]+r[2])/2-n[0],l=(r[1]+r[3])/2-n[1]):(a=n[2]-n[0],l=n[3]-n[1]),e.rotate((Math.atan2(-l,-a)+t)%t),e.moveTo(0,0),e.lineTo(-o,u/2),e.lineTo(-o,-u/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){const t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}};tv.prototype.className="Arrow",ms(tv),qe.addGetterSetter(tv,"pointerLength",10,Zt()),qe.addGetterSetter(tv,"pointerWidth",10,Zt()),qe.addGetterSetter(tv,"pointerAtBeginning",!1),qe.addGetterSetter(tv,"pointerAtEnding",!0);var PS=class extends Gt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};PS.prototype._centroid=!0,PS.prototype.className="Circle",PS.prototype._attrsAffectingSize=["radius"],ms(PS),qe.addGetterSetter(PS,"radius",0,Zt());var T0=class extends Gt{_sceneFunc(e){const t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};T0.prototype.className="Ellipse",T0.prototype._centroid=!0,T0.prototype._attrsAffectingSize=["radiusX","radiusY"],ms(T0),qe.addComponentsGetterSetter(T0,"radius",["x","y"]),qe.addGetterSetter(T0,"radiusX",0,Zt()),qe.addGetterSetter(T0,"radiusY",0,Zt());var bf=class HWe extends Gt{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",n=>{this._removeImageLoad(n.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&t.readyState===4||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),n=this.hasShadow();return t&&n?!0:super._useBufferCanvas(!0)}_sceneFunc(t){const n=this.getWidth(),r=this.getHeight(),i=this.cornerRadius(),o=this.attrs.image;let s;if(o){const a=this.attrs.cropWidth,l=this.attrs.cropHeight;a&&l?s=[o,this.cropX(),this.cropY(),a,l,0,0,n,r]:s=[o,0,0,n,r]}(this.hasFill()||this.hasStroke()||i)&&(t.beginPath(),i?lt.drawRoundedRectPath(t,n,r,i):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)),o&&(i&&t.clip(),t.drawImage.apply(t,s))}_hitFunc(t){const n=this.width(),r=this.height(),i=this.cornerRadius();t.beginPath(),i?lt.drawRoundedRectPath(t,n,r,i):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,n,r;return(r=(t=this.attrs.width)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.width)!==null&&r!==void 0?r:0}getHeight(){var t,n,r;return(r=(t=this.attrs.height)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.height)!==null&&r!==void 0?r:0}static fromURL(t,n,r=null){const i=lt.createImageElement();i.onload=function(){n(new HWe({image:i}))},i.onerror=r,i.crossOrigin="Anonymous",i.src=t}};bf.prototype.className="Image",bf.prototype._attrsAffectingSize=["image"],ms(bf),qe.addGetterSetter(bf,"cornerRadius",0,c6(4)),qe.addGetterSetter(bf,"image"),qe.addComponentsGetterSetter(bf,"crop",["x","y","width","height"]),qe.addGetterSetter(bf,"cropX",0,Zt()),qe.addGetterSetter(bf,"cropY",0,Zt()),qe.addGetterSetter(bf,"cropWidth",0,Zt()),qe.addGetterSetter(bf,"cropHeight",0,Zt());var cze=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Yzn="Change.konva",Kzn="none",e$="up",t$="right",n$="down",r$="left",Xzn=cze.length,i$=class extends CS{constructor(e){super(e),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){let t=this,n;const r=function(){t._sync()};for(n=0;n<Xzn;n++)e.on(cze[n]+Yzn,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,i,o,s,a,l;if(e&&t){switch(n=e.width(),r=e.height(),i=t.pointerDirection(),o=t.pointerWidth(),l=t.pointerHeight(),s=0,a=0,i){case e$:s=n/2,a=-1*l;break;case t$:s=n+o,a=r/2;break;case n$:s=n/2,a=r+l;break;case r$:s=-1*o,a=r/2;break}t.setAttrs({x:-1*s,y:-1*a,width:n,height:r}),e.setAttrs({x:-1*s,y:-1*a})}}};i$.prototype.className="Label",ms(i$);var nv=class extends Gt{_sceneFunc(e){const t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),o=this.pointerHeight(),s=this.cornerRadius();let a=0,l=0,c=0,u=0;typeof s=="number"?a=l=c=u=Math.min(s,t/2,n/2):(a=Math.min(s[0]||0,t/2,n/2),l=Math.min(s[1]||0,t/2,n/2),u=Math.min(s[2]||0,t/2,n/2),c=Math.min(s[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(a,0),r===e$&&(e.lineTo((t-i)/2,0),e.lineTo(t/2,-1*o),e.lineTo((t+i)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,Math.PI*3/2,0,!1),r===t$&&(e.lineTo(t,(n-o)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+o)/2)),e.lineTo(t,n-u),e.arc(t-u,n-u,u,0,Math.PI/2,!1),r===n$&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+o),e.lineTo((t-i)/2,n)),e.lineTo(c,n),e.arc(c,n-c,c,Math.PI/2,Math.PI,!1),r===r$&&(e.lineTo(0,(n+o)/2),e.lineTo(-1*i,n/2),e.lineTo(0,(n-o)/2)),e.lineTo(0,a),e.arc(a,a,a,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),i=this.pointerDirection(),o=this.width(),s=this.height();return i===e$?(t-=r,s+=r):i===n$?s+=r:i===r$?(e-=n*1.5,o+=n):i===t$&&(o+=n*1.5),{x:e,y:t,width:o,height:s}}};nv.prototype.className="Tag",ms(nv),qe.addGetterSetter(nv,"pointerDirection",Kzn),qe.addGetterSetter(nv,"pointerWidth",0,Zt()),qe.addGetterSetter(nv,"pointerHeight",0,Zt()),qe.addGetterSetter(nv,"cornerRadius",0,c6(4));var M2=class extends Gt{_sceneFunc(e){const t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?lt.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};M2.prototype.className="Rect",ms(M2),qe.addGetterSetter(M2,"cornerRadius",0,c6(4));var I0=class extends Gt{_sceneFunc(e){const t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(e.beginPath(),i)lt.drawRoundedPolygonPath(e,t,r,n,i);else{e.moveTo(t[0].x,t[0].y);for(let o=1;o<t.length;o++)e.lineTo(t[o].x,t[o].y)}e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();let t=e[0].x,n=e[0].x,r=e[0].y,i=e[0].y;return e.forEach(o=>{t=Math.min(t,o.x),n=Math.max(n,o.x),r=Math.min(r,o.y),i=Math.max(i,o.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};I0.prototype.className="RegularPolygon",I0.prototype._centroid=!0,I0.prototype._attrsAffectingSize=["radius"],ms(I0),qe.addGetterSetter(I0,"radius",0,Zt()),qe.addGetterSetter(I0,"sides",0,Zt()),qe.addGetterSetter(I0,"cornerRadius",0,c6(4));var uze=Math.PI*2,rv=class extends Gt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,uze,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),uze,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};rv.prototype.className="Ring",rv.prototype._centroid=!0,rv.prototype._attrsAffectingSize=["innerRadius","outerRadius"],ms(rv),qe.addGetterSetter(rv,"innerRadius",0,Zt()),qe.addGetterSetter(rv,"outerRadius",0,Zt());var Ph=class extends Gt{constructor(e){super(e),this._updated=!0,this.anim=new _S(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],o=this.frameOffsets(),s=i[r+0],a=i[r+1],l=i[r+2],c=i[r+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,c),e.closePath(),e.fillStrokeShape(this)),u)if(o){const d=o[t],f=n*2;e.drawImage(u,s,a,l,c,d[f+0],d[f+1],l,c)}else e.drawImage(u,s,a,l,c,0,0,l,c)}_hitFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],o=this.frameOffsets(),s=i[r+2],a=i[r+3];if(e.beginPath(),o){const l=o[t],c=n*2;e.rect(l[c+0],l[c+1],s,a)}else e.rect(0,0,s,a);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}};Ph.prototype.className="Sprite",ms(Ph),qe.addGetterSetter(Ph,"animation"),qe.addGetterSetter(Ph,"animations"),qe.addGetterSetter(Ph,"frameOffsets"),qe.addGetterSetter(Ph,"image"),qe.addGetterSetter(Ph,"frameIndex",0,Zt()),qe.addGetterSetter(Ph,"frameRate",17,Zt()),qe.backCompat(Ph,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var k0=class extends Gt{_sceneFunc(e){const t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let i=1;i<r*2;i++){const o=i%2===0?n:t,s=o*Math.sin(i*Math.PI/r),a=-1*o*Math.cos(i*Math.PI/r);e.lineTo(s,a)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};k0.prototype.className="Star",k0.prototype._centroid=!0,k0.prototype._attrsAffectingSize=["innerRadius","outerRadius"],ms(k0),qe.addGetterSetter(k0,"numPoints",5,Zt()),qe.addGetterSetter(k0,"innerRadius",0,Zt()),qe.addGetterSetter(k0,"outerRadius",0,Zt());function E0(e){return[...e].reduce((t,n,r,i)=>{if(/\p{Emoji}/u.test(n)){const o=i[r+1];o&&/\p{Emoji_Modifier}|\u200D/u.test(o)?(t.push(n+o),i[r+1]=""):t.push(n)}else/\p{Regional_Indicator}{2}/u.test(n+(i[r+1]||""))?t.push(n+i[r+1]):r>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(n)?t[t.length-1]+=n:n&&t.push(n);return t},[])}var RS="auto",Jzn="center",dze="inherit",D2="justify",Zzn="Change.konva",fze="2d",hze="-",pze="left",Qzn="text",$zn="Text",eUn="top",tUn="bottom",mze="middle",gze="normal",nUn="px ",b6=" ",rUn="right",yze="rtl",iUn="word",oUn="char",bze="none",o$="…",vze=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],sUn=vze.length,O2=null;function aUn(){if(O2!==null)return O2;O2=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(fze);if(t){t.globalAlpha=0,t.shadowColor="black",t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle="black",t.font="10px Arial",t.fillText("X",0,10);const n=t.getImageData(0,0,10,10).data;for(let r=3;r<n.length;r+=4)if(n[r]>0){O2=!0;break}}}catch{}return O2}function lUn(e){return e.split(",").map(t=>{t=t.trim();const n=t.indexOf(" ")>=0,r=t.indexOf('"')>=0||t.indexOf("'")>=0;return n&&!r&&(t=`"${t}"`),t}).join(", ")}var v6;function s$(){return v6||(v6=lt.createCanvasElement().getContext(fze),v6)}function cUn(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function uUn(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function dUn(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var Vo=class extends Gt{constructor(e){super(dUn(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<sUn;t++)this.on(vze[t]+Zzn,this._setTextData);this._setTextData()}_sceneFunc(e){var t,n;const r=this.textArr,i=r.length;if(!this.text())return;let o=this.padding(),s=this.fontSize(),a=this.lineHeight()*s,l=this.verticalAlign(),c=this.direction(),u=0,d=this.align(),f=this.getWidth(),h=this.letterSpacing(),p=this.charRenderFunc(),m=this.fill(),g=this.textDecoration(),y=this.underlineOffset(),v=g.indexOf("underline")!==-1,b=g.indexOf("line-through")!==-1,w;c=c===dze?e.direction:c;let x=a/2,A=mze;if(!on.legacyTextRendering){const T=this.measureSize("M");A="alphabetic",x=(((t=T.fontBoundingBoxAscent)!==null&&t!==void 0?t:T.actualBoundingBoxAscent)-((n=T.fontBoundingBoxDescent)!==null&&n!==void 0?n:T.actualBoundingBoxDescent))/2+a/2}for(c===yze&&e.setAttr("direction",c),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",A),e.setAttr("textAlign",pze),l===mze?u=(this.getHeight()-i*a-o*2)/2:l===tUn&&(u=this.getHeight()-i*a-o*2),e.translate(o,u+o),w=0;w<i;w++){let T=0,I=0;const P=r[w],C=P.text,R=P.width,k=P.lastInParagraph;if(e.save(),d===rUn?T+=f-R-o*2:d===Jzn&&(T+=(f-R-o*2)/2),v){e.save(),e.beginPath();const _=y??(on.legacyTextRendering?Math.round(s/2):Math.round(s/4)),O=T,F=x+I+_;e.moveTo(O,F);const B=d===D2&&!k?f-o*2:R;e.lineTo(O+Math.round(B),F),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||m,e.stroke(),e.restore()}const L=T;if(c!==yze&&(h!==0||d===D2||p)){const _=C.split(" ").length-1,O=E0(C);for(let F=0;F<O.length;F++){const B=O[F];if(B===" "&&!k&&d===D2&&(T+=(f-o*2-R)/_),this._partialTextX=T,this._partialTextY=x+I,this._partialText=B,p){e.save();const U=r.slice(0,w).reduce((M,z)=>M+E0(z.text).length,0);p({char:B,index:F+U,x:T,y:x+I,lineIndex:w,column:F,isLastInLine:k,width:this.measureSize(B).width,context:e})}e.fillStrokeShape(this),p&&e.restore(),T+=this.measureSize(B).width+h}}else h!==0&&e.setAttr("letterSpacing",`${h}px`),this._partialTextX=T,this._partialTextY=x+I,this._partialText=C,e.fillStrokeShape(this);if(b){e.save(),e.beginPath();const _=on.legacyTextRendering?0:-Math.round(s/4),O=L;e.moveTo(O,x+I+_);const F=d===D2&&!k?f-o*2:R;e.lineTo(O+Math.round(F),x+I+_),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||m,e.stroke(),e.restore()}e.restore(),i>1&&(x+=a)}}_hitFunc(e){const t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){const t=lt._isString(e)?e:e==null?"":e+"";return this._setAttr(Qzn,t),this}getWidth(){return this.attrs.width===RS||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===RS||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return lt.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n,r,i,o,s,a,l,c,u,d;let f=s$(),h=this.fontSize(),p;f.save(),f.font=this._getContextFont(),p=f.measureText(e),f.restore();const m=h/100;return{actualBoundingBoxAscent:(t=p.actualBoundingBoxAscent)!==null&&t!==void 0?t:71.58203125*m,actualBoundingBoxDescent:(n=p.actualBoundingBoxDescent)!==null&&n!==void 0?n:0,actualBoundingBoxLeft:(r=p.actualBoundingBoxLeft)!==null&&r!==void 0?r:-7.421875*m,actualBoundingBoxRight:(i=p.actualBoundingBoxRight)!==null&&i!==void 0?i:75.732421875*m,alphabeticBaseline:(o=p.alphabeticBaseline)!==null&&o!==void 0?o:0,emHeightAscent:(s=p.emHeightAscent)!==null&&s!==void 0?s:100*m,emHeightDescent:(a=p.emHeightDescent)!==null&&a!==void 0?a:-20*m,fontBoundingBoxAscent:(l=p.fontBoundingBoxAscent)!==null&&l!==void 0?l:91*m,fontBoundingBoxDescent:(c=p.fontBoundingBoxDescent)!==null&&c!==void 0?c:21*m,hangingBaseline:(u=p.hangingBaseline)!==null&&u!==void 0?u:72.80000305175781*m,ideographicBaseline:(d=p.ideographicBaseline)!==null&&d!==void 0?d:-21*m,width:p.width,height:h}}_getContextFont(){return this.fontStyle()+b6+this.fontVariant()+b6+(this.fontSize()+nUn)+lUn(this.fontFamily())}_addTextLine(e){this.align()===D2&&(e=e.trim());const t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){const t=this.letterSpacing(),n=e.length;return s$().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
|
|
1294
|
-
`),t=+this.fontSize(),n=0,r=this.lineHeight()*t,i=this.attrs.width,o=this.attrs.height,s=i!==RS&&i!==void 0,a=o!==RS&&o!==void 0,l=this.padding(),c=i-l*2,u=o-l*2,d=0,f=this.wrap(),h=f!==oUn&&f!==bze,p=this.ellipsis();this.textArr=[],s$().font=this._getContextFont();const m=p?this._getTextWidth(o$):0;for(let g=0,y=e.length;g<y;++g){let v=e[g],b=this._getTextWidth(v);if(s&&b>c)for(;v.length>0;){let w=0,x=E0(v).length,A="",T=0;for(;w<x;){const I=w+x>>>1,P=E0(v).slice(0,I+1).join(""),C=this._getTextWidth(P);(p&&a&&d+r>u?C+m:C)<=c?(w=I+1,A=P,T=C):x=I}if(A){if(h){const I=E0(v),P=E0(A),C=I[P.length],R=C===b6||C===hze;let k;if(R&&T<=c)k=P.length;else{const L=P.lastIndexOf(b6),_=P.lastIndexOf(hze);k=Math.max(L,_)+1}k>0&&(w=k,A=I.slice(0,w).join(""),T=this._getTextWidth(A))}if(A=A.trimRight(),this._addTextLine(A),n=Math.max(n,T),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(v=E0(v).slice(w).join("").trimLeft(),v.length>0&&(b=this._getTextWidth(v),b<=c)){this._addTextLine(v),d+=r,n=Math.max(n,b);break}}else break}else this._addTextLine(v),d+=r,n=Math.max(n,b),this._shouldHandleEllipsis(d)&&g<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+r>u)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==RS&&r!==void 0,o=r-this.padding()*2;return this.wrap()===bze||i&&e+n>o}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==RS&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];!i||!r||(t&&(this._getTextWidth(i.text+o$)<n||(i.text=i.text.slice(0,i.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+o$))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&aUn()?!0:super._useBufferCanvas()}};Vo.prototype._fillFunc=cUn,Vo.prototype._strokeFunc=uUn,Vo.prototype.className=$zn,Vo.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],ms(Vo),qe.overWriteSetter(Vo,"width",UQ()),qe.overWriteSetter(Vo,"height",UQ()),qe.addGetterSetter(Vo,"direction",dze),qe.addGetterSetter(Vo,"fontFamily","Arial"),qe.addGetterSetter(Vo,"fontSize",12,Zt()),qe.addGetterSetter(Vo,"fontStyle",gze),qe.addGetterSetter(Vo,"fontVariant",gze),qe.addGetterSetter(Vo,"padding",0,Zt()),qe.addGetterSetter(Vo,"align",pze),qe.addGetterSetter(Vo,"verticalAlign",eUn),qe.addGetterSetter(Vo,"lineHeight",1,Zt()),qe.addGetterSetter(Vo,"wrap",iUn),qe.addGetterSetter(Vo,"ellipsis",!1,yf()),qe.addGetterSetter(Vo,"letterSpacing",0,Zt()),qe.addGetterSetter(Vo,"text","",Qb()),qe.addGetterSetter(Vo,"textDecoration",""),qe.addGetterSetter(Vo,"underlineOffset",void 0,Zt()),qe.addGetterSetter(Vo,"charRenderFunc",void 0);var fUn="",wze="normal";function Aze(e){e.fillText(this.partialText,0,0)}function xze(e){e.strokeText(this.partialText,0,0)}var ga=class extends Gt{constructor(e){super(e),this.dummyCanvas=lt.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return yd.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:yd.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=yd.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();const t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,o=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;o&&e.beginPath();for(let a=0;a<i.length;a++){e.save();const l=i[a].p0;e.translate(l.x,l.y),e.rotate(i[a].rotation),this.partialText=i[a].text,e.fillStrokeShape(this),o&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(i[a].width,r/2+1)),e.restore()}if(o&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<i.length;a++){e.save();const l=i[a].p0;e.translate(l.x,l.y),e.rotate(i[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(i[a].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();const t=this.glyphInfo;if(t.length>=1){const n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){const r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return lt.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Vo.prototype.setText.call(this,e)}_getContextFont(){return Vo.prototype._getContextFont.call(this)}_getTextSize(e){const t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();const n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const e=E0(this.text()),t=[];let n=0;for(let f=0;f<e.length;f++)t.push({char:e[f],width:this._getTextSize(e[f]).width}),n+=t[f].width;const{width:r,height:i}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=i,this.glyphInfo=[],!this.attrs.data)return null;const o=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),c=Math.max(this.textWidth+((this.attrs.text||"").length-1)*o,0);let u=0;s==="center"&&(u=Math.max(0,this.pathLength/2-c/2)),s==="right"&&(u=Math.max(0,this.pathLength-c));let d=u;for(let f=0;f<t.length;f++){const h=this._getPointAtLength(d);if(!h)return;const p=t[f].char;let m=t[f].width+o;if(p===" "&&s==="justify"){const A=this.text().split(" ").length-1;m+=(this.pathLength-c)/A}const g=d+m,y=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=l?this.pathLength:g);if(!y)return;const v=yd.getLineLength(h.x,h.y,y.x,y.y);let b=0;if(a)try{b=a(t[f-1].char,p)*this.fontSize()}catch{b=0}h.x+=b,y.x+=b,this.textWidth+=b;const w=yd.getPointOnLine(b+v/2,h.x,h.y,y.x,y.y),x=Math.atan2(y.y-h.y,y.x-h.x);this.glyphInfo.push({transposeX:w.x,transposeY:w.y,text:e[f],rotation:x,p0:h,p1:y,width:v}),d+=m}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,i=e[1]||0,o,s;for(let l=0;l<e.length/2;l++)o=e[l*2],s=e[l*2+1],t=Math.min(t,o),n=Math.max(n,o),r=Math.min(r,s),i=Math.max(i,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:i-r+a}}destroy(){return lt.releaseCanvas(this.dummyCanvas),super.destroy()}};ga.prototype._fillFunc=Aze,ga.prototype._strokeFunc=xze,ga.prototype._fillFuncHit=Aze,ga.prototype._strokeFuncHit=xze,ga.prototype.className="TextPath",ga.prototype._attrsAffectingSize=["text","fontSize","data"],ms(ga),qe.addGetterSetter(ga,"data"),qe.addGetterSetter(ga,"fontFamily","Arial"),qe.addGetterSetter(ga,"fontSize",12,Zt()),qe.addGetterSetter(ga,"fontStyle",wze),qe.addGetterSetter(ga,"align","left"),qe.addGetterSetter(ga,"letterSpacing",0,Zt()),qe.addGetterSetter(ga,"textBaseline","middle"),qe.addGetterSetter(ga,"fontVariant",wze),qe.addGetterSetter(ga,"text",fUn),qe.addGetterSetter(ga,"textDecoration",""),qe.addGetterSetter(ga,"kerningFunc",void 0);var Sze="tr-konva",hUn=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${Sze}`).join(" "),Tze="nodesRect",pUn=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],mUn={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},gUn="ontouchstart"in on._global;function yUn(e,t,n){if(e==="rotater")return n;t+=lt.degToRad(mUn[e]||0);const r=(lt.radToDeg(t)%360+360)%360;return lt._inRange(r,337.5,360)||lt._inRange(r,0,22.5)?"ns-resize":lt._inRange(r,22.5,67.5)?"nesw-resize":lt._inRange(r,67.5,112.5)?"ew-resize":lt._inRange(r,112.5,157.5)?"nwse-resize":lt._inRange(r,157.5,202.5)?"ns-resize":lt._inRange(r,202.5,247.5)?"nesw-resize":lt._inRange(r,247.5,292.5)?"ew-resize":lt._inRange(r,292.5,337.5)?"nwse-resize":(lt.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var w6=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],Ize=1e8;function bUn(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function kze(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function vUn(e,t){return kze(e,t,bUn(e))}function wUn(e,t,n){let r=t;for(let i=0;i<e.length;i++){const o=on.getAngle(e[i]),s=Math.abs(o-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=o)}return r}var a$=0,yi=class extends CS{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(hUn,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return lt.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Sze+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(lt.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0),e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const n=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(t._attrsAffectingSize.length){const r=t._attrsAffectingSize.map(i=>i+"Change."+this._getEventNamespace()).join(" ");t.on(r,n)}t.on(pUn.map(r=>r+`.${this._getEventNamespace()}`).join(" "),n),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,n),this._proxyDrag(t)}),this._resetTransformCache(),this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;const r=e.getAbsolutePosition(),i=r.x-t.x,o=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+i,y:a.y+o}),s.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Tze),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(Tze,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=e.getAbsoluteScale(n),o=e.getAbsolutePosition(n),s=r.x*i.x-e.offsetX()*i.x,a=r.y*i.y-e.offsetY()*i.y,l=(on.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return kze({x:o.x+s*Math.cos(l)+a*Math.sin(-l),y:o.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*i.x,height:r.height*i.y,rotation:l},-on.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-Ize,y:-Ize,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),c=[{x:l.x,y:l.y},{x:l.x+l.width,y:l.y},{x:l.x+l.width,y:l.y+l.height},{x:l.x,y:l.y+l.height}],u=a.getAbsoluteTransform();c.forEach(function(d){const f=u.point(d);e.push(f)})});const t=new gf;t.rotate(-on.getAngle(this.rotation()));let n=1/0,r=1/0,i=-1/0,o=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=i=l.x,r=o=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),i=Math.max(i,l.x),o=Math.max(o,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:i-n,height:o-r,rotation:on.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),w6.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new M2({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:gUn?10:"auto"}),n=this;t.on("mousedown touchstart",function(r){n._handleMouseDown(r)}),t.on("dragstart",r=>{t.stopDrag(),r.cancelBubble=!0}),t.on("dragend",r=>{r.cancelBubble=!0}),t.on("mouseenter",()=>{const r=yUn(e,on.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){const e=new Gt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),i=r.padding(),o=n.width(),s=n.height();if(t.beginPath(),t.rect(-i,-i,o+i*2,s+i*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),c=lt.degToRad(a),u=Math.sin(c),d=-Math.cos(c),f=o/2,h=s/2;let p=1/0;d<0?p=Math.min(p,-h/d):d>0&&(p=Math.min(p,(s-h)/d)),u<0?p=Math.min(p,-f/u):u>0&&(p=Math.min(p,(o-f)/u));const m=f+u*p,g=h+d*p,y=lt._sign(s),v=m+u*l*y,b=g+d*l*y;t.moveTo(m,g),t.lineTo(v,b)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const o=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},a$++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(a=>{a._fire("transformstart",{evt:e.evt,target:a})})}_handleMouseMove(e){let t,n,r;const i=this.findOne("."+this._movingAnchorName),o=i.getStage();o.setPointersPositions(e);const s=o.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),i.setAbsolutePosition(a);const c=i.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if(this._movingAnchorName==="rotater"){const y=this._getNodeRect();t=i.x()-y.width/2,n=-i.y()+y.height/2;const v=on.getAngle(this.rotateAnchorAngle());let b=Math.atan2(-n,t)+Math.PI/2-v;y.height<0&&(b-=Math.PI);const w=on.getAngle(this.rotation())+b,x=on.getAngle(this.rotationSnapTolerance()),A=vUn(y,wUn(this.rotationSnaps(),w,x)-y.rotation);this._fitNodesInto(A,e);return}const u=this.shiftBehavior();let d;u==="inverted"?d=this.keepRatio()&&!e.shiftKey:u==="none"?d=this.keepRatio():d=this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(y.x-i.x(),2)+Math.pow(y.y-i.y(),2));const v=this.findOne(".top-left").x()>y.x?-1:1,b=this.findOne(".top-left").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-left").x(y.x-t),this.findOne(".top-left").y(y.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(i.y());else if(this._movingAnchorName==="top-right"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(i.x()-y.x,2)+Math.pow(y.y-i.y(),2));const v=this.findOne(".top-right").x()<y.x?-1:1,b=this.findOne(".top-right").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-n)}var h=i.position();this.findOne(".top-left").y(h.y),this.findOne(".bottom-right").x(h.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(i.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(i.x());else if(this._movingAnchorName==="bottom-left"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(y.x-i.x(),2)+Math.pow(i.y()-y.y,2));const v=y.x<i.x()?-1:1,b=i.y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,i.x(y.x-t),i.y(y.y+n)}h=i.position(),this.findOne(".top-left").x(h.x),this.findOne(".bottom-right").y(h.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(i.y());else if(this._movingAnchorName==="bottom-right"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(i.x()-y.x,2)+Math.pow(i.y()-y.y,2));const v=this.findOne(".bottom-right").x()<y.x?-1:1,b=this.findOne(".bottom-right").y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".bottom-right").x(y.x+t),this.findOne(".bottom-right").y(y.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){const y=this.findOne(".top-left"),v=this.findOne(".bottom-right"),b=y.x(),w=y.y(),x=this.getWidth()-v.x(),A=this.getHeight()-v.y();v.move({x:-b,y:-w}),y.move({x,y:A})}const p=this.findOne(".top-left").getAbsolutePosition();t=p.x,n=p.y;const m=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),g=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:m,height:g,rotation:on.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();a$--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var i;r._fire("transformend",{evt:e,target:r}),(i=r.getLayer())===null||i===void 0||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(lt._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(lt._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const i=new gf;if(i.rotate(on.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const d=i.point({x:-this.padding()*2,y:0});e.x+=d.x,e.y+=d.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const d=i.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const d=i.point({x:0,y:-this.padding()*2});e.x+=d.x,e.y+=d.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const d=i.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const d=this.boundBoxFunc()(n,e);d?e=d:lt.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,s=new gf;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/o,n.height/o);const a=new gf,l=e.width/o,c=e.height/o;this.flipEnabled()===!1?(a.translate(e.x,e.y),a.rotate(e.rotation),a.translate(e.width<0?e.width:0,e.height<0?e.height:0),a.scale(Math.abs(l),Math.abs(c))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,c));const u=a.multiply(s.invert());this._nodes.forEach(d=>{var f;if(!d.getStage())return;const h=d.getParent().getAbsoluteTransform(),p=d.getTransform().copy();p.translate(d.offsetX(),d.offsetY());const m=new gf;m.multiply(h.copy().invert()).multiply(u).multiply(h).multiply(p);const g=m.decompose();d.setAttrs(g),(f=d.getLayer())===null||f===void 0||f.batchDraw()}),this.rotation(lt._getRotation(e.rotation)),this._nodes.forEach(d=>{this._fire("transform",{evt:t,target:d}),d._fire("transform",{evt:t,target:d})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;const t=this._getNodeRect();this.rotation(lt._getRotation(t.rotation));const n=t.width,r=t.height,i=this.enabledAnchors(),o=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(x=>{x.setAttrs({width:a,height:a,offsetX:a/2,offsetY:a/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:a/2+s,offsetY:a/2+s,visible:o&&i.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:o&&i.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:o&&i.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:o&&i.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:o&&i.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:o&&i.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:o&&i.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:o&&i.indexOf("bottom-right")>=0});const c=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=lt.degToRad(c),f=Math.sin(d),h=-Math.cos(d),p=n/2,m=r/2;let g=1/0;h<0?g=Math.min(g,-m/h):h>0&&(g=Math.min(g,(r-m)/h)),f<0?g=Math.min(g,-p/f):f>0&&(g=Math.min(g,(n-p)/f));const y=p+f*g,v=m+h*g,b=lt._sign(r);this._batchChangeChild(".rotater",{x:y+f*u*b,y:v+h*u*b-s*h,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(x=>x.draggable()),x:0,y:0});const w=this.anchorStyleFunc();w&&l.forEach(x=>{w(x)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),CS.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(lt.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return sn.prototype.toObject.call(this)}clone(e){return sn.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};yi.isTransforming=()=>a$>0;function AUn(e){return e instanceof Array||lt.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){w6.indexOf(t)===-1&<.warn("Unknown anchor name: "+t+". Available names are: "+w6.join(", "))}),e||[]}yi.prototype.className="Transformer",ms(yi),qe.addGetterSetter(yi,"enabledAnchors",w6,AUn),qe.addGetterSetter(yi,"flipEnabled",!0,yf()),qe.addGetterSetter(yi,"resizeEnabled",!0),qe.addGetterSetter(yi,"anchorSize",10,Zt()),qe.addGetterSetter(yi,"rotateEnabled",!0),qe.addGetterSetter(yi,"rotateLineVisible",!0),qe.addGetterSetter(yi,"rotationSnaps",[]),qe.addGetterSetter(yi,"rotateAnchorOffset",50,Zt()),qe.addGetterSetter(yi,"rotateAnchorAngle",0,Zt()),qe.addGetterSetter(yi,"rotateAnchorCursor","crosshair"),qe.addGetterSetter(yi,"rotationSnapTolerance",5,Zt()),qe.addGetterSetter(yi,"borderEnabled",!0),qe.addGetterSetter(yi,"anchorStroke","rgb(0, 161, 255)"),qe.addGetterSetter(yi,"anchorStrokeWidth",1,Zt()),qe.addGetterSetter(yi,"anchorFill","white"),qe.addGetterSetter(yi,"anchorCornerRadius",0,Zt()),qe.addGetterSetter(yi,"borderStroke","rgb(0, 161, 255)"),qe.addGetterSetter(yi,"borderStrokeWidth",1,Zt()),qe.addGetterSetter(yi,"borderDash"),qe.addGetterSetter(yi,"keepRatio",!0),qe.addGetterSetter(yi,"shiftBehavior","default"),qe.addGetterSetter(yi,"centeredScaling",!1),qe.addGetterSetter(yi,"ignoreStroke",!1),qe.addGetterSetter(yi,"padding",0,Zt()),qe.addGetterSetter(yi,"nodes"),qe.addGetterSetter(yi,"node"),qe.addGetterSetter(yi,"boundBoxFunc"),qe.addGetterSetter(yi,"anchorDragBoundFunc"),qe.addGetterSetter(yi,"anchorStyleFunc"),qe.addGetterSetter(yi,"shouldOverdrawWholeArea",!1),qe.addGetterSetter(yi,"useSingleNodeRotation",!0),qe.backCompat(yi,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var om=class extends Gt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,on.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};om.prototype.className="Wedge",om.prototype._centroid=!0,om.prototype._attrsAffectingSize=["radius"],ms(om),qe.addGetterSetter(om,"radius",0,Zt()),qe.addGetterSetter(om,"angle",0,Zt()),qe.addGetterSetter(om,"clockwise",!1),qe.backCompat(om,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function Eze(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var xUn=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],SUn=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function TUn(e,t){const n=e.data,r=e.width,i=e.height;let o,s,a,l,c,u,d,f,h,p,m,g,y,v,b,w,x,A,T,I;const P=t+t+1,C=r-1,R=i-1,k=t+1,L=k*(k+1)/2,_=new Eze,O=xUn[t],F=SUn[t];let B=null,U=_,M=null,z=null;for(let Z=1;Z<P;Z++)U=U.next=new Eze,Z===k&&(B=U);U.next=_,a=s=0;for(let Z=0;Z<i;Z++){g=y=v=b=l=c=u=d=0,f=k*(w=n[s]),h=k*(x=n[s+1]),p=k*(A=n[s+2]),m=k*(T=n[s+3]),l+=L*w,c+=L*x,u+=L*A,d+=L*T,U=_;for(let Q=0;Q<k;Q++)U.r=w,U.g=x,U.b=A,U.a=T,U=U.next;for(let Q=1;Q<k;Q++)o=s+((C<Q?C:Q)<<2),l+=(U.r=w=n[o])*(I=k-Q),c+=(U.g=x=n[o+1])*I,u+=(U.b=A=n[o+2])*I,d+=(U.a=T=n[o+3])*I,g+=w,y+=x,v+=A,b+=T,U=U.next;M=_,z=B;for(let Q=0;Q<r;Q++)n[s+3]=T=d*O>>F,T!==0?(T=255/T,n[s]=(l*O>>F)*T,n[s+1]=(c*O>>F)*T,n[s+2]=(u*O>>F)*T):n[s]=n[s+1]=n[s+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,o=a+((o=Q+t+1)<C?o:C)<<2,g+=M.r=n[o],y+=M.g=n[o+1],v+=M.b=n[o+2],b+=M.a=n[o+3],l+=g,c+=y,u+=v,d+=b,M=M.next,f+=w=z.r,h+=x=z.g,p+=A=z.b,m+=T=z.a,g-=w,y-=x,v-=A,b-=T,z=z.next,s+=4;a+=r}for(let Z=0;Z<r;Z++){y=v=b=g=c=u=d=l=0,s=Z<<2,f=k*(w=n[s]),h=k*(x=n[s+1]),p=k*(A=n[s+2]),m=k*(T=n[s+3]),l+=L*w,c+=L*x,u+=L*A,d+=L*T,U=_;for(let W=0;W<k;W++)U.r=w,U.g=x,U.b=A,U.a=T,U=U.next;let Q=r;for(let W=1;W<=t;W++)s=Q+Z<<2,l+=(U.r=w=n[s])*(I=k-W),c+=(U.g=x=n[s+1])*I,u+=(U.b=A=n[s+2])*I,d+=(U.a=T=n[s+3])*I,g+=w,y+=x,v+=A,b+=T,U=U.next,W<R&&(Q+=r);s=Z,M=_,z=B;for(let W=0;W<i;W++)o=s<<2,n[o+3]=T=d*O>>F,T>0?(T=255/T,n[o]=(l*O>>F)*T,n[o+1]=(c*O>>F)*T,n[o+2]=(u*O>>F)*T):n[o]=n[o+1]=n[o+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,o=Z+((o=W+k)<R?o:R)*r<<2,l+=g+=M.r=n[o],c+=y+=M.g=n[o+1],u+=v+=M.b=n[o+2],d+=b+=M.a=n[o+3],M=M.next,f+=w=z.r,h+=x=z.g,p+=A=z.b,m+=T=z.a,g-=w,y-=x,v-=A,b-=T,z=z.next,s+=r}}const IUn=function(t){const n=Math.round(this.blurRadius());n>0&&TUn(t,n)};qe.addGetterSetter(sn,"blurRadius",0,Zt(),qe.afterSetFilter);const kUn=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let i=0;i<r;i+=4)n[i]+=t,n[i+1]+=t,n[i+2]+=t};qe.addGetterSetter(sn,"brightness",0,Zt(),qe.afterSetFilter);const EUn=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let i=0;i<r;i+=4)n[i]=Math.min(255,n[i]*t),n[i+1]=Math.min(255,n[i+1]*t),n[i+2]=Math.min(255,n[i+2]*t)},CUn=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let i=150,o=150,s=150;for(let a=0;a<r;a+=4)i=n[a],o=n[a+1],s=n[a+2],i/=255,i-=.5,i*=t,i+=.5,i*=255,o/=255,o-=.5,o*=t,o+=.5,o*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,i=i<0?0:i>255?255:i,o=o<0?0:o>255?255:o,s=s<0?0:s>255?255:s,n[a]=i,n[a+1]=o,n[a+2]=s};qe.addGetterSetter(sn,"contrast",0,Zt(),qe.afterSetFilter);const _Un=function(e){var t,n,r,i,o,s,a,l,c;const u=e.data,d=e.width,f=e.height,h=Math.min(1,Math.max(0,(n=(t=this.embossStrength)===null||t===void 0?void 0:t.call(this))!==null&&n!==void 0?n:.5)),p=Math.min(1,Math.max(0,(i=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&i!==void 0?i:.5)),m=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(o=this.embossDirection)===null||o===void 0?void 0:o.call(this))!==null&&s!==void 0?s:"top-left"])!==null&&a!==void 0?a:315,g=!!((c=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&c!==void 0&&c),y=h*10,v=p*255,b=m*Math.PI/180,w=Math.cos(b),x=Math.sin(b),A=128/1020*y,T=new Uint8ClampedArray(u),I=new Float32Array(d*f);for(let L=0,_=0;_<u.length;_+=4,L++)I[L]=.2126*T[_]+.7152*T[_+1]+.0722*T[_+2];const P=[-1,0,1,-2,0,2,-1,0,1],C=[-1,-2,-1,0,0,0,1,2,1],R=[-d-1,-d,-d+1,-1,0,1,d-1,d,d+1],k=L=>L<0?0:L>255?255:L;for(let L=1;L<f-1;L++)for(let _=1;_<d-1;_++){const O=L*d+_;let F=0,B=0;F+=I[O+R[0]]*P[0],B+=I[O+R[0]]*C[0],F+=I[O+R[1]]*P[1],B+=I[O+R[1]]*C[1],F+=I[O+R[2]]*P[2],B+=I[O+R[2]]*C[2],F+=I[O+R[3]]*P[3],B+=I[O+R[3]]*C[3],F+=I[O+R[5]]*P[5],B+=I[O+R[5]]*C[5],F+=I[O+R[6]]*P[6],B+=I[O+R[6]]*C[6],F+=I[O+R[7]]*P[7],B+=I[O+R[7]]*C[7],F+=I[O+R[8]]*P[8],B+=I[O+R[8]]*C[8];const U=k(v+(w*F+x*B)*A),M=O*4;if(g){const z=U-v;u[M]=k(T[M]+z),u[M+1]=k(T[M+1]+z),u[M+2]=k(T[M+2]+z),u[M+3]=T[M+3]}else u[M]=u[M+1]=u[M+2]=U,u[M+3]=T[M+3]}for(let L=0;L<d;L++){let _=L*4,O=((f-1)*d+L)*4;u[_]=T[_],u[_+1]=T[_+1],u[_+2]=T[_+2],u[_+3]=T[_+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}for(let L=1;L<f-1;L++){let _=L*d*4,O=(L*d+(d-1))*4;u[_]=T[_],u[_+1]=T[_+1],u[_+2]=T[_+2],u[_+3]=T[_+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}return e};qe.addGetterSetter(sn,"embossStrength",.5,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"embossWhiteLevel",.5,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"embossDirection","top-left",void 0,qe.afterSetFilter),qe.addGetterSetter(sn,"embossBlend",!1,void 0,qe.afterSetFilter);function l$(e,t,n,r,i){const o=n-t,s=i-r;if(o===0)return r+s/2;if(s===0)return r;let a=(e-t)/o;return a=s*a+r,a}const PUn=function(e){const t=e.data,n=t.length;let r=t[0],i=r,o,s=t[1],a=s,l,c=t[2],u=c,d;const f=this.enhance();if(f===0)return;for(let b=0;b<n;b+=4)o=t[b+0],o<r?r=o:o>i&&(i=o),l=t[b+1],l<s?s=l:l>a&&(a=l),d=t[b+2],d<c?c=d:d>u&&(u=d);i===r&&(i=255,r=0),a===s&&(a=255,s=0),u===c&&(u=255,c=0);let h,p,m,g,y,v;if(f>0)h=i+f*(255-i),p=r-f*(r-0),m=a+f*(255-a),g=s-f*(s-0),y=u+f*(255-u),v=c-f*(c-0);else{const b=(i+r)*.5;h=i+f*(i-b),p=r+f*(r-b);const w=(a+s)*.5;m=a+f*(a-w),g=s+f*(s-w);const x=(u+c)*.5;y=u+f*(u-x),v=c+f*(c-x)}for(let b=0;b<n;b+=4)t[b+0]=l$(t[b+0],r,i,p,h),t[b+1]=l$(t[b+1],s,a,g,m),t[b+2]=l$(t[b+2],c,u,v,y)};qe.addGetterSetter(sn,"enhance",0,Zt(),qe.afterSetFilter);const RUn=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const i=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=i,t[r+1]=i,t[r+2]=i}};qe.addGetterSetter(sn,"hue",0,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"saturation",0,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"luminance",0,Zt(),qe.afterSetFilter);const LUn=function(e){const t=e.data,n=t.length,r=1,i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*i*Math.cos(o*Math.PI/180),l=r*i*Math.sin(o*Math.PI/180),c=.299*r+.701*a+.167*l,u=.587*r-.587*a+.33*l,d=.114*r-.114*a-.497*l,f=.299*r-.299*a-.328*l,h=.587*r+.413*a+.035*l,p=.114*r-.114*a+.293*l,m=.299*r-.3*a+1.25*l,g=.587*r-.586*a-1.05*l,y=.114*r+.886*a-.2*l;let v,b,w,x;for(let A=0;A<n;A+=4)v=t[A+0],b=t[A+1],w=t[A+2],x=t[A+3],t[A+0]=c*v+u*b+d*w+s,t[A+1]=f*v+h*b+p*w+s,t[A+2]=m*v+g*b+y*w+s,t[A+3]=x},NUn=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s=r*i*Math.cos(o*Math.PI/180),a=r*i*Math.sin(o*Math.PI/180),l=.299*r+.701*s+.167*a,c=.587*r-.587*s+.33*a,u=.114*r-.114*s-.497*a,d=.299*r-.299*s-.328*a,f=.587*r+.413*s+.035*a,h=.114*r-.114*s+.293*a,p=.299*r-.3*s+1.25*a,m=.587*r-.586*s-1.05*a,g=.114*r+.886*s-.2*a;for(let y=0;y<n;y+=4){const v=t[y+0],b=t[y+1],w=t[y+2],x=t[y+3];t[y+0]=l*v+c*b+u*w,t[y+1]=d*v+f*b+h*w,t[y+2]=p*v+m*b+g*w,t[y+3]=x}};qe.addGetterSetter(sn,"hue",0,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"saturation",0,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"value",0,Zt(),qe.afterSetFilter);const MUn=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4)t[r]=255-t[r],t[r+1]=255-t[r+1],t[r+2]=255-t[r+2]};var DUn=function(e,t,n){const r=e.data,i=t.data,o=e.width,s=e.height,a=n.polarCenterX||o/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=o-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=o,m=360/p*Math.PI/180;for(let g=0;g<p;g+=1){const y=Math.sin(g*m),v=Math.cos(g*m);for(let b=0;b<h;b+=1){u=Math.floor(a+c*b/h*v),d=Math.floor(l+c*b/h*y);let w=(d*o+u)*4;const x=r[w+0],A=r[w+1],T=r[w+2],I=r[w+3];w=(g+b*o)*4,i[w+0]=x,i[w+1]=A,i[w+2]=T,i[w+3]=I}}},OUn=function(e,t,n){const r=e.data,i=t.data,o=e.width,s=e.height,a=n.polarCenterX||o/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=o-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=o,m=n.polarRotation||0;let g,y;for(u=0;u<o;u+=1)for(d=0;d<s;d+=1){const v=u-a,b=d-l,w=Math.sqrt(v*v+b*b)*h/c;let x=(Math.atan2(b,v)*180/Math.PI+360+m)%360;x=x*p/360,g=Math.floor(x),y=Math.floor(w);let A=(y*o+g)*4;const T=r[A+0],I=r[A+1],P=r[A+2],C=r[A+3];A=(d*o+u)*4,i[A+0]=T,i[A+1]=I,i[A+2]=P,i[A+3]=C}};const FUn=function(e){const t=e.width,n=e.height;let r,i,o,s,a,l,c,u,d,f,h=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),m=Math.floor(t*(p%360)/360);if(h<1)return;const g=lt.createCanvasElement();g.width=t,g.height=n;const y=g.getContext("2d").getImageData(0,0,t,n);lt.releaseCanvas(g),DUn(e,y,{polarCenterX:t/2,polarCenterY:n/2});let v=t/Math.pow(2,h);for(;v<=8;)v=v*2,h-=1;v=Math.ceil(v);let b=v,w=0,x=b,A=1;for(m+v>t&&(w=b,x=0,A=-1),i=0;i<n;i+=1)for(r=w;r!==x;r+=A)o=Math.round(r+m)%t,d=(t*i+o)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*i+r)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;for(i=0;i<n;i+=1)for(b=Math.floor(v),s=0;s<h;s+=1){for(r=0;r<b+1;r+=1)d=(t*i+r)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*i+b*2-r-1)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;b*=2}OUn(y,e,{polarRotation:0})};qe.addGetterSetter(sn,"kaleidoscopePower",2,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"kaleidoscopeAngle",0,Zt(),qe.afterSetFilter);function A6(e,t,n){let r=(n*e.width+t)*4;const i=[];return i.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),i}function F2(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function BUn(e){const t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function HUn(e,t){const n=A6(e,0,0),r=A6(e,e.width-1,0),i=A6(e,0,e.height-1),o=A6(e,e.width-1,e.height-1),s=t||10;if(F2(n,r)<s&&F2(r,o)<s&&F2(o,i)<s&&F2(i,n)<s){const a=BUn([r,n,o,i]),l=[];for(let c=0;c<e.width*e.height;c++)l[c]=F2(a,[e.data[c*4],e.data[c*4+1],e.data[c*4+2]])<s?0:255;return l}}function zUn(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function UUn(e,t,n){const r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u===2040?255:0}return s}function VUn(e,t,n){const r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u>=1020?255:0}return s}function WUn(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u}return s}const GUn=function(e){let t=HUn(e,this.threshold());return t&&(t=UUn(t,e.width,e.height),t=VUn(t,e.width,e.height),t=WUn(t,e.width,e.height),zUn(e,t)),e};qe.addGetterSetter(sn,"threshold",0,Zt(),qe.afterSetFilter);const jUn=function(e){const t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let o=0;o<r;o+=4)n[o+0]+=i-2*i*Math.random(),n[o+1]+=i-2*i*Math.random(),n[o+2]+=i-2*i*Math.random()};qe.addGetterSetter(sn,"noise",.2,Zt(),qe.afterSetFilter);const qUn=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,i=Math.ceil(n/t),o=Math.ceil(r/t),s=e.data;if(t<=0){lt.error("pixelSize value can not be <= 0");return}for(let a=0;a<i;a+=1)for(let l=0;l<o;l+=1){let c=0,u=0,d=0,f=0;const h=a*t,p=h+t,m=l*t,g=m+t;let y=0;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const w=(n*b+v)*4;c+=s[w+0],u+=s[w+1],d+=s[w+2],f+=s[w+3],y+=1}c=c/y,u=u/y,d=d/y,f=f/y;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const w=(n*b+v)*4;s[w+0]=c,s[w+1]=u,s[w+2]=d,s[w+3]=f}}};qe.addGetterSetter(sn,"pixelSize",8,Zt(),qe.afterSetFilter);const YUn=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let o=0;o<r;o+=1)n[o]=Math.floor(n[o]/i)*i};qe.addGetterSetter(sn,"levels",.5,Zt(),qe.afterSetFilter);const KUn=function(e){const t=e.data,n=t.length,r=this.red(),i=this.green(),o=this.blue();for(let s=0;s<n;s+=4){const a=(.34*t[s]+.5*t[s+1]+.16*t[s+2])/255;t[s]=a*r,t[s+1]=a*i,t[s+2]=a*o,t[s+3]=t[s+3]}};qe.addGetterSetter(sn,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(sn,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(sn,"blue",0,EHe,qe.afterSetFilter);const XUn=function(e){const t=e.data,n=t.length,r=this.red(),i=this.green(),o=this.blue(),s=this.alpha();for(let a=0;a<n;a+=4){const l=1-s;t[a]=r*s+t[a]*l,t[a+1]=i*s+t[a+1]*l,t[a+2]=o*s+t[a+2]*l}};qe.addGetterSetter(sn,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(sn,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(sn,"blue",0,EHe,qe.afterSetFilter),qe.addGetterSetter(sn,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const JUn=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const i=t[r+0],o=t[r+1],s=t[r+2];t[r+0]=Math.min(255,i*.393+o*.769+s*.189),t[r+1]=Math.min(255,i*.349+o*.686+s*.168),t[r+2]=Math.min(255,i*.272+o*.534+s*.131)}},ZUn=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const i=n[r],o=n[r+1],s=n[r+2];.2126*i+.7152*o+.0722*s>=128&&(n[r]=255-i,n[r+1]=255-o,n[r+2]=255-s)}return e},QUn=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let i=0;i<r;i+=1)n[i]=n[i]<t?0:255};qe.addGetterSetter(sn,"threshold",.5,Zt(),qe.afterSetFilter);var $Un=ize.Util._assign(ize,{Arc:rm,Arrow:tv,Circle:PS,Ellipse:T0,Image:bf,Label:i$,Tag:nv,Line:im,Path:yd,Rect:M2,RegularPolygon:I0,Ring:rv,Sprite:Ph,Star:k0,Text:Vo,TextPath:ga,Transformer:yi,Wedge:om,Filters:{Blur:IUn,Brightness:EUn,Brighten:kUn,Contrast:CUn,Emboss:_Un,Enhance:PUn,Grayscale:RUn,HSL:LUn,HSV:NUn,Invert:MUn,Kaleidoscope:FUn,Mask:GUn,Noise:jUn,Pixelate:qUn,Posterize:YUn,RGB:KUn,RGBA:XUn,Sepia:JUn,Solarize:ZUn,Threshold:QUn}});$t();var eVn=["dialog","floating"],Cze=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function tVn(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!eVn.includes(e.mode))throw new Error(`SurfaceManager: mode must be "dialog" or "floating", got "${e.mode}".`);const t="kind"in e&&e.kind!=null,n="component"in e&&e.component!=null,r="render"in e&&typeof e.render=="function";if(n&&r)throw new Error('SurfaceManager: request cannot provide both "component" and "render". Use one or the other.');if(!t&&!n&&!r)throw new Error('SurfaceManager: request must provide "kind" (intent-based) or "component"/"render" (direct-render).');if(e.mode==="floating"&&e.floating?.placement!=null&&!Cze.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${Cze.join(", ")}, got "${e.floating.placement}".`)}var nVn=class{activeDialog=Pu(null);activeFloating=Pu(null);#e=!1;#t=1;#i;constructor({getModuleConfig:e}){this.#i=e}open(e){if(this.#e)return this.#u(e);tVn(e);const t=this.#l(e),{component:n,props:r,render:i}=this.#c(t);let o,s=!1;const a=new Promise(h=>{o=p=>s?!1:(s=!0,h(p),!0)});let l;const c=h=>{o({status:"submitted",data:h})&&this.#r(l)},u=h=>{o({status:"closed",reason:h})&&this.#r(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:i,resolve:c,close:u,settle:h=>o(h),get settled(){return s}};const d=t.mode==="dialog"?"activeDialog":"activeFloating",f=this[d].value;return f&&!f.settled&&f.settle({status:"replaced",replacedBy:t.id}),this[d].value=l,{id:t.id,mode:t.mode,close:h=>this.#n(l,h),result:a}}close(e,t){if(e!=null){const i=this.#o(e);i&&this.#n(i,t);return}const n=this.activeDialog.value;if(n&&!n.settled){this.#n(n,t);return}const r=this.activeFloating.value;r&&!r.settled&&this.#n(r,t)}settleAll(e){for(const t of[this.activeDialog,this.activeFloating]){const n=t.value;n&&!n.settled&&n.settle(e),t.value=null}}destroy(){this.#e=!0,this.settleAll({status:"destroyed"})}#n(e,t){e.settled||(e.settle({status:"closed",reason:t}),this.#r(e))}#r(e){const t=e.mode==="dialog"?this.activeDialog:this.activeFloating;t.value===e&&(t.value=null)}#o(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#l(e){const t=e.id??`surface-${this.#t++}`,n=this.#i()??{},r=e.mode==="dialog"?n.dialog:n.floating,i=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,o=e.mode==="floating"?{placement:r?.placement??"top-right",width:r?.width,maxWidth:r?.maxWidth,maxHeight:r?.maxHeight,autoFocus:r?.autoFocus??!0,closeOnOutsidePointerDown:r?.closeOnOutsidePointerDown??!1,...e.floating}:e.floating;return{...e,id:t,closeOnEscape:e.closeOnEscape??r?.closeOnEscape??!0,closeOnBackdrop:e.mode==="dialog"?e.closeOnBackdrop??r?.closeOnBackdrop??!0:!1,dialog:i,floating:o}}#c(e){if("component"in e&&e.component!=null)return{component:e.component,props:e.props};if("render"in e&&typeof e.render=="function")return{render:e.render};const t=this.#i()?.resolver;if(typeof t=="function"){const n=t(e);if(n!=null){if(n.type==="none")throw new Error(`SurfaceManager: resolver explicitly suppressed surface for kind "${e.kind}".`);if(n.type==="custom")return{component:n.component,props:n.props};if(n.type==="external")return{render:n.render}}}throw new Error(`SurfaceManager: no renderer resolved for kind "${e.kind}". Provide a resolver via modules.surfaces.resolver, or use a direct-render request.`)}#u(e){return{id:e?.id??`surface-${this.#t++}`,mode:e?.mode??"dialog",close:()=>{},result:Promise.resolve({status:"destroyed"})}}},rVn="https://docs.superdoc.dev/guides/migration/document-api",_ze=new Set;function iVn(e,t){_ze.has(e)||(_ze.add(e),console.warn(t))}var oVn={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},Pze=Symbol.for("superdoc:rawEditor"),Rze=new WeakMap;function Lze(e){return!e||e[Pze]?e:new Proxy(e,{get(t,n){if(n===Pze)return t;const r=oVn[n];r&&iVn(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${rVn}`);const i=Reflect.get(t,n,t);if(typeof i=="function"){let o=Rze.get(t);return o||(o=new Map,Rze.set(t,o)),o.has(n)||o.set(n,i.bind(t)),o.get(n)}return i}})}var Nze=["review","original","final","off"],sVn=["paired","independent"],Mze=Symbol.for("@superdoc/trackChanges:normalized"),Dze=new Set;function Oze(e,t){Dze.has(e)||(Dze.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function Fze(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function aVn(e,t,n){return typeof e=="string"&&Nze.includes(e)?e:typeof t=="string"&&Nze.includes(t)?t:n}function lVn(e){return typeof e=="string"&&sVn.includes(e)?e:null}function B2(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function cVn(e){const t=e[Mze]===!0;B2(e.modules)||(e.modules={});const n=B2(e.modules.trackChanges),r=B2(e.trackChanges),i=B2(e.layoutEngineOptions?.trackedChanges);t||(r&&Oze("config.trackChanges","config.modules.trackChanges"),i&&Oze("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const o=Fze(n?.visible,r?.visible,!1),s=Fze(n?.enabled,i?.enabled,!0),a=lVn(n?.replacements)??"paired",l=e.documentMode==="viewing"?o?"review":"original":"review",c=aVn(n?.mode,i?.mode,l),u={visible:o,mode:c,enabled:s,replacements:a};return e.modules.trackChanges=u,e.trackChanges={visible:o},B2(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:c,enabled:s},Object.defineProperty(e,Mze,{value:!0,writable:!0,configurable:!0,enumerable:!1}),u}$t();var c$=Object.freeze({name:"Default SuperDoc user",email:null}),uVn=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]);function aer(e){return e}var x6=class extends fF.default{static allowedTypes=[xc,WT,L1];#e=!1;#t=!1;#i=null;#n=null;#r;version;users;ydoc;provider;whiteboard;colors=[];superdocStore;commentsStore;highContrastModeStore;app;pinia;readyEditors=0;pendingCollaborationSaves=0;config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0};constructor(e){if(super(),!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#o(e,t)}async#o(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),cVn(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated");const i=this.config.user;if(!i||typeof i!="object"?this.config.user={...c$}:(this.config.user={...c$,...i},this.config.user.name||(this.config.user.name=c$.name)),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.colors=$Xe(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="1.34.0-next.6",this.#A("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||yn(),this.colors=this.config.colors??[],this.#d(),this.#r=new nVn({getModuleConfig:()=>this.config.modules?.surfaces}),await this.#s(this.config.modules),this.#e){this.#T();return}this.config.cspNonce&&this.#u(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null,this.#n=document.createElement("div"),this.#n.style.display="contents",t.appendChild(this.#n),this.#a(),this.#c(),this.#_(),this.#l()}#l(){this.#f(),this.readyEditors=0,this.app.mount(this.#n)}#c(){const e=(this.config.modules?.whiteboard??{}).enabled??!1;this.whiteboard=new _Hn({Renderer:$Un,superdoc:this,enabled:e}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.superdocStore.documents.filter(e=>e.type===xc).length}get state(){return{documents:this.superdocStore.documents,users:this.users}}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#u(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#d(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,i=!!e&&e instanceof Blob&&!(e instanceof File),o=this.config.documents&&this.config.documents?.length;if(t&&o&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const s=y2(this.config.document);this.config.documents=[{id:yn(),...s}]}else if(n)this.config.documents=[{id:yn(),type:xc,url:this.config.document,name:"document.docx"}];else if(r){const s=y2(this.config.document);this.config.documents=[{id:yn(),...s}]}else if(i){const s=y2(this.config.document);this.config.documents=[{id:yn(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=y2(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||yn()}}))}#f(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:i}=wHn({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#r),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=i,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const o=this.config.modules.comments;this.commentsStore.init(o||{}),this.isCollaborative&&t6(this),this.#I()}#a(){this.on("editorBeforeCreate",this.config.onEditorBeforeCreate),this.on("editorCreate",this.config.onEditorCreate),this.on("editorDestroy",this.config.onEditorDestroy),this.on("ready",this.config.onReady),this.on("comments-update",this.config.onCommentsUpdate),this.on("awareness-update",this.config.onAwarenessUpdate),this.on("locked",this.config.onLocked),this.on("pdf:document-ready",this.config.onPdfDocumentReady),this.on("sidebar-toggle",this.config.onSidebarToggle),this.on("collaboration-ready",this.config.onCollaborationReady),this.on("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.on("exception",this.config.onException),this.on("list-definitions-change",this.config.onListDefinitionsChange),this.on("pagination-update",this.config.onPaginationUpdate),this.config.onFontsResolved&&this.on("fonts-resolved",this.config.onFontsResolved)}async#s({collaboration:e,comments:t={}}={}){if(!e)return this.config.documents;const{ydoc:n,provider:r}=e;if(n&&r)return(!this.config.documents||this.config.documents.length===0)&&(this.config.documents=[{id:yn(),type:xc,name:"document.docx"}]),this.#w(n,r),t6(this),this.config.documents;this.isCollaborative=!0,e.providerType==="hocuspocus"&&(this.config.socket=new Aoe({url:e.url}));const i=z8n(this);if(t.useInternalExternalComments&&!t.suppressInternalExternalComments){const{ydoc:o,provider:s}=H8n(this);this.ydoc=no(o),this.provider=no(s)}else this.ydoc=no(i[0].ydoc),this.provider=no(i[0].provider);return t6(this),i}#w(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=no(e),this.provider=no(t),this.#x(),this._cleanupAwareness=O8n(t,this,this.config.user),this.config.documents.forEach(n=>{n.ydoc=e,n.provider=t,n.role=this.config.role})}#y(){typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#x(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:uVn,n=e.email||e.name||"";let r=5381;for(let i=0;i<n.length;i++)r=(r<<5)+r^n.charCodeAt(i);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration({ydoc:e,provider:t}){this.#C({ydoc:e,provider:t}),this.#t=!0;try{const n=this.#k();await this.#v(t),this.#N(),AFt(n,e),THn(e,this.commentsStore.commentsList),IHn(e,{isLocked:this.isLocked,lockedBy:this.lockedBy}),this.config.modules.collaboration={ydoc:e,provider:t},this.#w(e,t),this.#S(e,t);const r=this.#g();try{r.attachCollaboration({ydoc:e,collaborationProvider:t})}catch(i){throw this.#b(),i}if(await this.#h(r),this.#e)return;t6(this)}finally{this.#i=null,this.#t=!1}}#N(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#S(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const i=mi(r);i.ydoc&&typeof i.ydoc=="object"&&"value"in i.ydoc&&(i.ydoc.value=e),i.provider&&typeof i.provider=="object"&&"value"in i.provider&&(i.provider.value=t)}}#g(){const e=this.superdocStore?.documents;if(!e?.length)throw new Error("SuperDoc: no store documents available for upgrade");const t=e[0].getPresentationEditor?.()||e[0].getEditor?.();if(!t?.attachCollaboration)throw new Error("SuperDoc: editor does not support attachCollaboration");return t}#b(){this.#y(),this.#S(null,null)}#h(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let i=!1;const o=()=>{i||(i=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{o(),console.warn("[SuperDoc] collaborationReady did not fire within 10 s after collaboration attach. Continuing — collaboration is active but cursor/presence setup may be delayed."),r(void 0)},1e4),a=()=>{o(),r(void 0)};this.#i=()=>{o(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(o(),r(void 0))})}#v(e){return new Promise((n,r)=>{let i,o=!1,s=()=>{};const a=()=>{o=!0,clearTimeout(i),s()};s=gA(e,()=>{o||(a(),n())}),o||(i=setTimeout(()=>{a(),r(new Error("SuperDoc: collaboration provider did not sync within 10000 ms. The provider exposes on/off but never emitted sync(true) or synced."))},1e4)),this.#i=()=>{o||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#C({ydoc:e,provider:t}){if(this.#e)throw new Error("SuperDoc: cannot upgrade a destroyed instance");if(this.#t)throw new Error("SuperDoc: upgrade already in progress");if(this.isCollaborative)throw new Error("SuperDoc: instance is already collaborative");if(!e||!t)throw new Error("SuperDoc: upgradeToCollaboration() requires both ydoc and provider");const n=this.config,r=n.documents.filter(i=>i.type===xc);if(r.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(r.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(n.documents.length!==r.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances")}#k(){const e=this.config.documents.find(n=>n.type===xc),t=this.superdocStore.documents.find(n=>n.id===e.id)?.getEditor?.();if(!t)throw new Error("SuperDoc: source editor not yet created — wait for the ready event before upgrading");return t}addSharedUser(e){this.users.some(t=>t.email===e.email)||this.users.push(e)}removeSharedUser(e){this.users=this.users.filter(t=>t.email!==e)}onContentError({error:e,editor:t}){const{documentId:n}=t.options,r=this.superdocStore.documents.find(i=>i.id===n);this.config.onContentError?.({error:e,editor:t,documentId:r.id,file:r.data})}broadcastPdfDocumentReady(){this.emit("pdf:document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(e){this.emit("editorBeforeCreate",{editor:Lze(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.emit("editorCreate",{editor:Lze(e)})}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#A(...e){(console.debug?console.debug:console.log)("🦋 🦸♀️ [superdoc]",...e)}setActiveEditor(e){this.activeEditor=e,this.toolbar&&(this.activeEditor.toolbar=this.toolbar,this.toolbar.setActiveEditor(e))}toggleRuler(){this.config.rulers=!this.config.rulers,this.superdocStore.documents.forEach(e=>{e.rulers=this.config.rulers})}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:i=null}={}){if(!e)return!1;let o=r??i?.comment??null;const s=i?.commentId||i?.id;if(!o&&s&&this.commentsStore?.getComment){const a=this.commentsStore.getComment(s);o=a?.getValues?a.getValues():a}return Kb(e,t,n,{superdoc:this,currentUser:this.config.user,comment:o??null,trackedChange:i??null})}#_(){const e=this.config.modules?.toolbar||{};this.toolbarElement=this.config.modules?.toolbar?.selector||this.config.toolbar,this.toolbar=null;const t=[...e.excludeItems||[]];(!this.config.rulers||this.config.viewOptions?.layout==="web")&&t.push("ruler"),this.toolbar=new e_e({selector:this.toolbarElement||null,isDev:this.isDev||!1,toolbarGroups:this.config.modules?.toolbar?.groups||this.config.toolbarGroups,role:this.config.role,icons:this.config.modules?.toolbar?.icons||this.config.toolbarIcons,texts:this.config.modules?.toolbar?.texts||this.config.toolbarTexts,fonts:this.config.modules?.toolbar?.fonts||null,hideButtons:this.config.modules?.toolbar?.hideButtons??!0,responsiveToContainer:this.config.modules?.toolbar?.responsiveToContainer??!1,documentMode:this.config.documentMode,superdoc:this,aiApiKey:this.config.modules?.ai?.apiKey,aiEndpoint:this.config.modules?.ai?.endpoint,uiDisplayFallbackFont:this.config.uiDisplayFallbackFont,...e,excludeItems:t}),this.toolbar.on("exception",this.config.onException),this.once("editorCreate",()=>this.toolbar?.updateToolbarState())}addCommentsList(e){!this.config?.modules?.comments||this.config.role==="viewer"||(e&&(this.config.modules.comments.element=e),this.commentsList=new P4n(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}))}scrollToComment(e,t={}){if(!this.config?.modules?.comments||!e||typeof e!="string")return!1;const n=this.element||document,r=globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/"/g,'\\"'),i=n.querySelector(`[data-comment-ids*="${r}"]`);if(!i)return!1;const{behavior:o="smooth",block:s="start"}=t??{};return i.scrollIntoView({behavior:o,block:s}),this.commentsStore?.setActiveComment?.(this,e),!0}async navigateTo(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getPresentationEditor?.();return n?.navigateTo?n.navigateTo(e):!1}async scrollToElement(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getPresentationEditor?.();return n?.scrollToElement?n.scrollToElement(e):!1}setDisableContextMenu(e=!0){const t=!!e;this.config.disableContextMenu!==t&&(this.config.disableContextMenu=t,this.superdocStore?.documents?.forEach(n=>{const r=n.getPresentationEditor?.();r?.setContextMenuDisabled&&r.setContextMenuDisabled(t);const i=n.getEditor?.();i?.setOptions&&i.setOptions({disableContextMenu:t})}))}setShowBookmarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showBookmarks!==t&&(n.showBookmarks=t,this.superdocStore?.documents?.forEach(r=>{r.getPresentationEditor?.()?.setShowBookmarks?.(t)}))}setShowFormattingMarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showFormattingMarks!==t&&(n.showFormattingMarks=t,this.superdocStore?.documents?.forEach(r=>{r.getPresentationEditor?.()?.setShowFormattingMarks?.(t)}),this.emit("formatting-marks-change",{showFormattingMarks:t,superdoc:this}),this.toolbar?.updateToolbarState?.())}toggleFormattingMarks(){const e=!!this.config.layoutEngineOptions?.showFormattingMarks;this.setShowFormattingMarks(!e)}setDocumentMode(e){if(!e)return;e=e.toLowerCase(),this.config.documentMode=e,this.#I();const t={viewing:()=>this.#R(),editing:()=>this.#E(),suggesting:()=>this.#D()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#m(e,t){const n=typeof e.getPresentationEditor=="function"?e.getPresentationEditor():null;if(n){n.setDocumentMode(t);return}const r=typeof e.getEditor=="function"?e.getEditor():null;r&&r.setDocumentMode(t)}setTrackedChangesPreferences(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{const r=typeof n.getPresentationEditor=="function"?n.getPresentationEditor():null;r?.setTrackedChangesOverrides&&r.setTrackedChangesOverrides(t)})}#E(){if(this.config.role!=="editor")return this.#D();if(this.superdocStore.documents.length>0){const e=this.superdocStore.documents[0]?.getEditor();e&&this.setActiveEditor(e)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),this.superdocStore.documents.forEach(e=>{e.restoreComments(),this.#m(e,"editing")})}#D(){if(!["editor","suggester"].includes(this.config.role))return this.#R();if(this.superdocStore.documents.length>0){const e=this.superdocStore.documents[0]?.getEditor();e&&this.setActiveEditor(e)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),this.superdocStore.documents.forEach(e=>{e.restoreComments(),this.#m(e,"suggesting")})}#R(){this.toolbar&&(this.toolbar.activeEditor=null);const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0;this.setTrackedChangesPreferences(t?{mode:"review",enabled:!0}:{mode:"original",enabled:!0}),!e&&!t&&this.commentsStore?.clearEditorCommentPositions?.(),this.superdocStore.documents.forEach(n=>{e||t?n.restoreComments():n.removeComments(),this.#m(n,"viewing")})}#I(){const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0,n=this.config.documentMode==="viewing",r=e||t;this.commentsStore?.setViewingVisibility&&this.commentsStore.setViewingVisibility({documentMode:this.config.documentMode,commentsVisible:e,trackChangesVisible:t});const i=this.superdocStore?.documents;Array.isArray(i)&&i.length>0&&i.forEach(o=>{const s=typeof o.getPresentationEditor=="function"?o.getPresentationEditor():null;s?.setViewingCommentOptions&&s.setViewingCommentOptions({emitCommentPositionsInViewing:n&&r,enableCommentsInViewing:n&&e})})}search(e){return this.activeEditor?.commands.search(e,{searchModel:"visible"})}goToSearchResult(e){return this.activeEditor?.commands.goToSearchResult(e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}this.superdocStore&&(this.superdocStore.activeZoom=e),this.emit("zoomChange",{zoom:e})}setLocked(e=!0){this.config.documents.forEach(t=>{const n=t.ydoc,r=n.getMap("meta");n.transact(()=>{r.set("locked",e),r.set("lockedBy",this.user)})})}getHTML(e={}){const t=[];return this.superdocStore.documents.forEach(n=>{const r=n.getEditor();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t){this.isLocked=e,this.lockedBy=t,this.#A("🦋 [superdoc] Locking superdoc:",e,t,`
|
|
1294
|
+
`),t=+this.fontSize(),n=0,r=this.lineHeight()*t,i=this.attrs.width,o=this.attrs.height,s=i!==RS&&i!==void 0,a=o!==RS&&o!==void 0,l=this.padding(),c=i-l*2,u=o-l*2,d=0,f=this.wrap(),h=f!==oUn&&f!==bze,p=this.ellipsis();this.textArr=[],s$().font=this._getContextFont();const m=p?this._getTextWidth(o$):0;for(let g=0,y=e.length;g<y;++g){let v=e[g],b=this._getTextWidth(v);if(s&&b>c)for(;v.length>0;){let w=0,x=E0(v).length,A="",T=0;for(;w<x;){const I=w+x>>>1,P=E0(v).slice(0,I+1).join(""),C=this._getTextWidth(P);(p&&a&&d+r>u?C+m:C)<=c?(w=I+1,A=P,T=C):x=I}if(A){if(h){const I=E0(v),P=E0(A),C=I[P.length],R=C===b6||C===hze;let k;if(R&&T<=c)k=P.length;else{const L=P.lastIndexOf(b6),_=P.lastIndexOf(hze);k=Math.max(L,_)+1}k>0&&(w=k,A=I.slice(0,w).join(""),T=this._getTextWidth(A))}if(A=A.trimRight(),this._addTextLine(A),n=Math.max(n,T),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(v=E0(v).slice(w).join("").trimLeft(),v.length>0&&(b=this._getTextWidth(v),b<=c)){this._addTextLine(v),d+=r,n=Math.max(n,b);break}}else break}else this._addTextLine(v),d+=r,n=Math.max(n,b),this._shouldHandleEllipsis(d)&&g<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+r>u)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==RS&&r!==void 0,o=r-this.padding()*2;return this.wrap()===bze||i&&e+n>o}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==RS&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];!i||!r||(t&&(this._getTextWidth(i.text+o$)<n||(i.text=i.text.slice(0,i.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+o$))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&aUn()?!0:super._useBufferCanvas()}};Vo.prototype._fillFunc=cUn,Vo.prototype._strokeFunc=uUn,Vo.prototype.className=$zn,Vo.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],ms(Vo),qe.overWriteSetter(Vo,"width",UQ()),qe.overWriteSetter(Vo,"height",UQ()),qe.addGetterSetter(Vo,"direction",dze),qe.addGetterSetter(Vo,"fontFamily","Arial"),qe.addGetterSetter(Vo,"fontSize",12,Zt()),qe.addGetterSetter(Vo,"fontStyle",gze),qe.addGetterSetter(Vo,"fontVariant",gze),qe.addGetterSetter(Vo,"padding",0,Zt()),qe.addGetterSetter(Vo,"align",pze),qe.addGetterSetter(Vo,"verticalAlign",eUn),qe.addGetterSetter(Vo,"lineHeight",1,Zt()),qe.addGetterSetter(Vo,"wrap",iUn),qe.addGetterSetter(Vo,"ellipsis",!1,yf()),qe.addGetterSetter(Vo,"letterSpacing",0,Zt()),qe.addGetterSetter(Vo,"text","",Qb()),qe.addGetterSetter(Vo,"textDecoration",""),qe.addGetterSetter(Vo,"underlineOffset",void 0,Zt()),qe.addGetterSetter(Vo,"charRenderFunc",void 0);var fUn="",wze="normal";function Aze(e){e.fillText(this.partialText,0,0)}function xze(e){e.strokeText(this.partialText,0,0)}var ga=class extends Gt{constructor(e){super(e),this.dummyCanvas=lt.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return yd.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:yd.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=yd.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();const t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,o=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;o&&e.beginPath();for(let a=0;a<i.length;a++){e.save();const l=i[a].p0;e.translate(l.x,l.y),e.rotate(i[a].rotation),this.partialText=i[a].text,e.fillStrokeShape(this),o&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(i[a].width,r/2+1)),e.restore()}if(o&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<i.length;a++){e.save();const l=i[a].p0;e.translate(l.x,l.y),e.rotate(i[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(i[a].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();const t=this.glyphInfo;if(t.length>=1){const n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){const r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return lt.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Vo.prototype.setText.call(this,e)}_getContextFont(){return Vo.prototype._getContextFont.call(this)}_getTextSize(e){const t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();const n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const e=E0(this.text()),t=[];let n=0;for(let f=0;f<e.length;f++)t.push({char:e[f],width:this._getTextSize(e[f]).width}),n+=t[f].width;const{width:r,height:i}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=i,this.glyphInfo=[],!this.attrs.data)return null;const o=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),c=Math.max(this.textWidth+((this.attrs.text||"").length-1)*o,0);let u=0;s==="center"&&(u=Math.max(0,this.pathLength/2-c/2)),s==="right"&&(u=Math.max(0,this.pathLength-c));let d=u;for(let f=0;f<t.length;f++){const h=this._getPointAtLength(d);if(!h)return;const p=t[f].char;let m=t[f].width+o;if(p===" "&&s==="justify"){const A=this.text().split(" ").length-1;m+=(this.pathLength-c)/A}const g=d+m,y=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=l?this.pathLength:g);if(!y)return;const v=yd.getLineLength(h.x,h.y,y.x,y.y);let b=0;if(a)try{b=a(t[f-1].char,p)*this.fontSize()}catch{b=0}h.x+=b,y.x+=b,this.textWidth+=b;const w=yd.getPointOnLine(b+v/2,h.x,h.y,y.x,y.y),x=Math.atan2(y.y-h.y,y.x-h.x);this.glyphInfo.push({transposeX:w.x,transposeY:w.y,text:e[f],rotation:x,p0:h,p1:y,width:v}),d+=m}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,i=e[1]||0,o,s;for(let l=0;l<e.length/2;l++)o=e[l*2],s=e[l*2+1],t=Math.min(t,o),n=Math.max(n,o),r=Math.min(r,s),i=Math.max(i,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:i-r+a}}destroy(){return lt.releaseCanvas(this.dummyCanvas),super.destroy()}};ga.prototype._fillFunc=Aze,ga.prototype._strokeFunc=xze,ga.prototype._fillFuncHit=Aze,ga.prototype._strokeFuncHit=xze,ga.prototype.className="TextPath",ga.prototype._attrsAffectingSize=["text","fontSize","data"],ms(ga),qe.addGetterSetter(ga,"data"),qe.addGetterSetter(ga,"fontFamily","Arial"),qe.addGetterSetter(ga,"fontSize",12,Zt()),qe.addGetterSetter(ga,"fontStyle",wze),qe.addGetterSetter(ga,"align","left"),qe.addGetterSetter(ga,"letterSpacing",0,Zt()),qe.addGetterSetter(ga,"textBaseline","middle"),qe.addGetterSetter(ga,"fontVariant",wze),qe.addGetterSetter(ga,"text",fUn),qe.addGetterSetter(ga,"textDecoration",""),qe.addGetterSetter(ga,"kerningFunc",void 0);var Sze="tr-konva",hUn=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${Sze}`).join(" "),Tze="nodesRect",pUn=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],mUn={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},gUn="ontouchstart"in on._global;function yUn(e,t,n){if(e==="rotater")return n;t+=lt.degToRad(mUn[e]||0);const r=(lt.radToDeg(t)%360+360)%360;return lt._inRange(r,337.5,360)||lt._inRange(r,0,22.5)?"ns-resize":lt._inRange(r,22.5,67.5)?"nesw-resize":lt._inRange(r,67.5,112.5)?"ew-resize":lt._inRange(r,112.5,157.5)?"nwse-resize":lt._inRange(r,157.5,202.5)?"ns-resize":lt._inRange(r,202.5,247.5)?"nesw-resize":lt._inRange(r,247.5,292.5)?"ew-resize":lt._inRange(r,292.5,337.5)?"nwse-resize":(lt.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var w6=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],Ize=1e8;function bUn(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function kze(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function vUn(e,t){return kze(e,t,bUn(e))}function wUn(e,t,n){let r=t;for(let i=0;i<e.length;i++){const o=on.getAngle(e[i]),s=Math.abs(o-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=o)}return r}var a$=0,yi=class extends CS{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(hUn,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return lt.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Sze+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(lt.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0),e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const n=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(t._attrsAffectingSize.length){const r=t._attrsAffectingSize.map(i=>i+"Change."+this._getEventNamespace()).join(" ");t.on(r,n)}t.on(pUn.map(r=>r+`.${this._getEventNamespace()}`).join(" "),n),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,n),this._proxyDrag(t)}),this._resetTransformCache(),this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;const r=e.getAbsolutePosition(),i=r.x-t.x,o=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+i,y:a.y+o}),s.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Tze),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(Tze,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=e.getAbsoluteScale(n),o=e.getAbsolutePosition(n),s=r.x*i.x-e.offsetX()*i.x,a=r.y*i.y-e.offsetY()*i.y,l=(on.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return kze({x:o.x+s*Math.cos(l)+a*Math.sin(-l),y:o.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*i.x,height:r.height*i.y,rotation:l},-on.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-Ize,y:-Ize,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),c=[{x:l.x,y:l.y},{x:l.x+l.width,y:l.y},{x:l.x+l.width,y:l.y+l.height},{x:l.x,y:l.y+l.height}],u=a.getAbsoluteTransform();c.forEach(function(d){const f=u.point(d);e.push(f)})});const t=new gf;t.rotate(-on.getAngle(this.rotation()));let n=1/0,r=1/0,i=-1/0,o=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=i=l.x,r=o=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),i=Math.max(i,l.x),o=Math.max(o,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:i-n,height:o-r,rotation:on.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),w6.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new M2({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:gUn?10:"auto"}),n=this;t.on("mousedown touchstart",function(r){n._handleMouseDown(r)}),t.on("dragstart",r=>{t.stopDrag(),r.cancelBubble=!0}),t.on("dragend",r=>{r.cancelBubble=!0}),t.on("mouseenter",()=>{const r=yUn(e,on.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){const e=new Gt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),i=r.padding(),o=n.width(),s=n.height();if(t.beginPath(),t.rect(-i,-i,o+i*2,s+i*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),c=lt.degToRad(a),u=Math.sin(c),d=-Math.cos(c),f=o/2,h=s/2;let p=1/0;d<0?p=Math.min(p,-h/d):d>0&&(p=Math.min(p,(s-h)/d)),u<0?p=Math.min(p,-f/u):u>0&&(p=Math.min(p,(o-f)/u));const m=f+u*p,g=h+d*p,y=lt._sign(s),v=m+u*l*y,b=g+d*l*y;t.moveTo(m,g),t.lineTo(v,b)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const o=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},a$++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(a=>{a._fire("transformstart",{evt:e.evt,target:a})})}_handleMouseMove(e){let t,n,r;const i=this.findOne("."+this._movingAnchorName),o=i.getStage();o.setPointersPositions(e);const s=o.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),i.setAbsolutePosition(a);const c=i.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if(this._movingAnchorName==="rotater"){const y=this._getNodeRect();t=i.x()-y.width/2,n=-i.y()+y.height/2;const v=on.getAngle(this.rotateAnchorAngle());let b=Math.atan2(-n,t)+Math.PI/2-v;y.height<0&&(b-=Math.PI);const w=on.getAngle(this.rotation())+b,x=on.getAngle(this.rotationSnapTolerance()),A=vUn(y,wUn(this.rotationSnaps(),w,x)-y.rotation);this._fitNodesInto(A,e);return}const u=this.shiftBehavior();let d;u==="inverted"?d=this.keepRatio()&&!e.shiftKey:u==="none"?d=this.keepRatio():d=this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(y.x-i.x(),2)+Math.pow(y.y-i.y(),2));const v=this.findOne(".top-left").x()>y.x?-1:1,b=this.findOne(".top-left").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-left").x(y.x-t),this.findOne(".top-left").y(y.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(i.y());else if(this._movingAnchorName==="top-right"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(i.x()-y.x,2)+Math.pow(y.y-i.y(),2));const v=this.findOne(".top-right").x()<y.x?-1:1,b=this.findOne(".top-right").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-n)}var h=i.position();this.findOne(".top-left").y(h.y),this.findOne(".bottom-right").x(h.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(i.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(i.x());else if(this._movingAnchorName==="bottom-left"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(y.x-i.x(),2)+Math.pow(i.y()-y.y,2));const v=y.x<i.x()?-1:1,b=i.y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,i.x(y.x-t),i.y(y.y+n)}h=i.position(),this.findOne(".top-left").x(h.x),this.findOne(".bottom-right").y(h.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(i.y());else if(this._movingAnchorName==="bottom-right"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(i.x()-y.x,2)+Math.pow(i.y()-y.y,2));const v=this.findOne(".bottom-right").x()<y.x?-1:1,b=this.findOne(".bottom-right").y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".bottom-right").x(y.x+t),this.findOne(".bottom-right").y(y.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){const y=this.findOne(".top-left"),v=this.findOne(".bottom-right"),b=y.x(),w=y.y(),x=this.getWidth()-v.x(),A=this.getHeight()-v.y();v.move({x:-b,y:-w}),y.move({x,y:A})}const p=this.findOne(".top-left").getAbsolutePosition();t=p.x,n=p.y;const m=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),g=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:m,height:g,rotation:on.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();a$--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var i;r._fire("transformend",{evt:e,target:r}),(i=r.getLayer())===null||i===void 0||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(lt._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(lt._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const i=new gf;if(i.rotate(on.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const d=i.point({x:-this.padding()*2,y:0});e.x+=d.x,e.y+=d.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const d=i.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const d=i.point({x:0,y:-this.padding()*2});e.x+=d.x,e.y+=d.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const d=i.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const d=this.boundBoxFunc()(n,e);d?e=d:lt.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,s=new gf;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/o,n.height/o);const a=new gf,l=e.width/o,c=e.height/o;this.flipEnabled()===!1?(a.translate(e.x,e.y),a.rotate(e.rotation),a.translate(e.width<0?e.width:0,e.height<0?e.height:0),a.scale(Math.abs(l),Math.abs(c))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,c));const u=a.multiply(s.invert());this._nodes.forEach(d=>{var f;if(!d.getStage())return;const h=d.getParent().getAbsoluteTransform(),p=d.getTransform().copy();p.translate(d.offsetX(),d.offsetY());const m=new gf;m.multiply(h.copy().invert()).multiply(u).multiply(h).multiply(p);const g=m.decompose();d.setAttrs(g),(f=d.getLayer())===null||f===void 0||f.batchDraw()}),this.rotation(lt._getRotation(e.rotation)),this._nodes.forEach(d=>{this._fire("transform",{evt:t,target:d}),d._fire("transform",{evt:t,target:d})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;const t=this._getNodeRect();this.rotation(lt._getRotation(t.rotation));const n=t.width,r=t.height,i=this.enabledAnchors(),o=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(x=>{x.setAttrs({width:a,height:a,offsetX:a/2,offsetY:a/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:a/2+s,offsetY:a/2+s,visible:o&&i.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:o&&i.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:o&&i.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:o&&i.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:o&&i.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:o&&i.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:o&&i.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:o&&i.indexOf("bottom-right")>=0});const c=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=lt.degToRad(c),f=Math.sin(d),h=-Math.cos(d),p=n/2,m=r/2;let g=1/0;h<0?g=Math.min(g,-m/h):h>0&&(g=Math.min(g,(r-m)/h)),f<0?g=Math.min(g,-p/f):f>0&&(g=Math.min(g,(n-p)/f));const y=p+f*g,v=m+h*g,b=lt._sign(r);this._batchChangeChild(".rotater",{x:y+f*u*b,y:v+h*u*b-s*h,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(x=>x.draggable()),x:0,y:0});const w=this.anchorStyleFunc();w&&l.forEach(x=>{w(x)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),CS.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(lt.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return sn.prototype.toObject.call(this)}clone(e){return sn.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};yi.isTransforming=()=>a$>0;function AUn(e){return e instanceof Array||lt.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){w6.indexOf(t)===-1&<.warn("Unknown anchor name: "+t+". Available names are: "+w6.join(", "))}),e||[]}yi.prototype.className="Transformer",ms(yi),qe.addGetterSetter(yi,"enabledAnchors",w6,AUn),qe.addGetterSetter(yi,"flipEnabled",!0,yf()),qe.addGetterSetter(yi,"resizeEnabled",!0),qe.addGetterSetter(yi,"anchorSize",10,Zt()),qe.addGetterSetter(yi,"rotateEnabled",!0),qe.addGetterSetter(yi,"rotateLineVisible",!0),qe.addGetterSetter(yi,"rotationSnaps",[]),qe.addGetterSetter(yi,"rotateAnchorOffset",50,Zt()),qe.addGetterSetter(yi,"rotateAnchorAngle",0,Zt()),qe.addGetterSetter(yi,"rotateAnchorCursor","crosshair"),qe.addGetterSetter(yi,"rotationSnapTolerance",5,Zt()),qe.addGetterSetter(yi,"borderEnabled",!0),qe.addGetterSetter(yi,"anchorStroke","rgb(0, 161, 255)"),qe.addGetterSetter(yi,"anchorStrokeWidth",1,Zt()),qe.addGetterSetter(yi,"anchorFill","white"),qe.addGetterSetter(yi,"anchorCornerRadius",0,Zt()),qe.addGetterSetter(yi,"borderStroke","rgb(0, 161, 255)"),qe.addGetterSetter(yi,"borderStrokeWidth",1,Zt()),qe.addGetterSetter(yi,"borderDash"),qe.addGetterSetter(yi,"keepRatio",!0),qe.addGetterSetter(yi,"shiftBehavior","default"),qe.addGetterSetter(yi,"centeredScaling",!1),qe.addGetterSetter(yi,"ignoreStroke",!1),qe.addGetterSetter(yi,"padding",0,Zt()),qe.addGetterSetter(yi,"nodes"),qe.addGetterSetter(yi,"node"),qe.addGetterSetter(yi,"boundBoxFunc"),qe.addGetterSetter(yi,"anchorDragBoundFunc"),qe.addGetterSetter(yi,"anchorStyleFunc"),qe.addGetterSetter(yi,"shouldOverdrawWholeArea",!1),qe.addGetterSetter(yi,"useSingleNodeRotation",!0),qe.backCompat(yi,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var om=class extends Gt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,on.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};om.prototype.className="Wedge",om.prototype._centroid=!0,om.prototype._attrsAffectingSize=["radius"],ms(om),qe.addGetterSetter(om,"radius",0,Zt()),qe.addGetterSetter(om,"angle",0,Zt()),qe.addGetterSetter(om,"clockwise",!1),qe.backCompat(om,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function Eze(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var xUn=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],SUn=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function TUn(e,t){const n=e.data,r=e.width,i=e.height;let o,s,a,l,c,u,d,f,h,p,m,g,y,v,b,w,x,A,T,I;const P=t+t+1,C=r-1,R=i-1,k=t+1,L=k*(k+1)/2,_=new Eze,O=xUn[t],F=SUn[t];let B=null,U=_,M=null,z=null;for(let Z=1;Z<P;Z++)U=U.next=new Eze,Z===k&&(B=U);U.next=_,a=s=0;for(let Z=0;Z<i;Z++){g=y=v=b=l=c=u=d=0,f=k*(w=n[s]),h=k*(x=n[s+1]),p=k*(A=n[s+2]),m=k*(T=n[s+3]),l+=L*w,c+=L*x,u+=L*A,d+=L*T,U=_;for(let Q=0;Q<k;Q++)U.r=w,U.g=x,U.b=A,U.a=T,U=U.next;for(let Q=1;Q<k;Q++)o=s+((C<Q?C:Q)<<2),l+=(U.r=w=n[o])*(I=k-Q),c+=(U.g=x=n[o+1])*I,u+=(U.b=A=n[o+2])*I,d+=(U.a=T=n[o+3])*I,g+=w,y+=x,v+=A,b+=T,U=U.next;M=_,z=B;for(let Q=0;Q<r;Q++)n[s+3]=T=d*O>>F,T!==0?(T=255/T,n[s]=(l*O>>F)*T,n[s+1]=(c*O>>F)*T,n[s+2]=(u*O>>F)*T):n[s]=n[s+1]=n[s+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,o=a+((o=Q+t+1)<C?o:C)<<2,g+=M.r=n[o],y+=M.g=n[o+1],v+=M.b=n[o+2],b+=M.a=n[o+3],l+=g,c+=y,u+=v,d+=b,M=M.next,f+=w=z.r,h+=x=z.g,p+=A=z.b,m+=T=z.a,g-=w,y-=x,v-=A,b-=T,z=z.next,s+=4;a+=r}for(let Z=0;Z<r;Z++){y=v=b=g=c=u=d=l=0,s=Z<<2,f=k*(w=n[s]),h=k*(x=n[s+1]),p=k*(A=n[s+2]),m=k*(T=n[s+3]),l+=L*w,c+=L*x,u+=L*A,d+=L*T,U=_;for(let W=0;W<k;W++)U.r=w,U.g=x,U.b=A,U.a=T,U=U.next;let Q=r;for(let W=1;W<=t;W++)s=Q+Z<<2,l+=(U.r=w=n[s])*(I=k-W),c+=(U.g=x=n[s+1])*I,u+=(U.b=A=n[s+2])*I,d+=(U.a=T=n[s+3])*I,g+=w,y+=x,v+=A,b+=T,U=U.next,W<R&&(Q+=r);s=Z,M=_,z=B;for(let W=0;W<i;W++)o=s<<2,n[o+3]=T=d*O>>F,T>0?(T=255/T,n[o]=(l*O>>F)*T,n[o+1]=(c*O>>F)*T,n[o+2]=(u*O>>F)*T):n[o]=n[o+1]=n[o+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,o=Z+((o=W+k)<R?o:R)*r<<2,l+=g+=M.r=n[o],c+=y+=M.g=n[o+1],u+=v+=M.b=n[o+2],d+=b+=M.a=n[o+3],M=M.next,f+=w=z.r,h+=x=z.g,p+=A=z.b,m+=T=z.a,g-=w,y-=x,v-=A,b-=T,z=z.next,s+=r}}const IUn=function(t){const n=Math.round(this.blurRadius());n>0&&TUn(t,n)};qe.addGetterSetter(sn,"blurRadius",0,Zt(),qe.afterSetFilter);const kUn=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let i=0;i<r;i+=4)n[i]+=t,n[i+1]+=t,n[i+2]+=t};qe.addGetterSetter(sn,"brightness",0,Zt(),qe.afterSetFilter);const EUn=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let i=0;i<r;i+=4)n[i]=Math.min(255,n[i]*t),n[i+1]=Math.min(255,n[i+1]*t),n[i+2]=Math.min(255,n[i+2]*t)},CUn=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let i=150,o=150,s=150;for(let a=0;a<r;a+=4)i=n[a],o=n[a+1],s=n[a+2],i/=255,i-=.5,i*=t,i+=.5,i*=255,o/=255,o-=.5,o*=t,o+=.5,o*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,i=i<0?0:i>255?255:i,o=o<0?0:o>255?255:o,s=s<0?0:s>255?255:s,n[a]=i,n[a+1]=o,n[a+2]=s};qe.addGetterSetter(sn,"contrast",0,Zt(),qe.afterSetFilter);const _Un=function(e){var t,n,r,i,o,s,a,l,c;const u=e.data,d=e.width,f=e.height,h=Math.min(1,Math.max(0,(n=(t=this.embossStrength)===null||t===void 0?void 0:t.call(this))!==null&&n!==void 0?n:.5)),p=Math.min(1,Math.max(0,(i=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&i!==void 0?i:.5)),m=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(o=this.embossDirection)===null||o===void 0?void 0:o.call(this))!==null&&s!==void 0?s:"top-left"])!==null&&a!==void 0?a:315,g=!!((c=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&c!==void 0&&c),y=h*10,v=p*255,b=m*Math.PI/180,w=Math.cos(b),x=Math.sin(b),A=128/1020*y,T=new Uint8ClampedArray(u),I=new Float32Array(d*f);for(let L=0,_=0;_<u.length;_+=4,L++)I[L]=.2126*T[_]+.7152*T[_+1]+.0722*T[_+2];const P=[-1,0,1,-2,0,2,-1,0,1],C=[-1,-2,-1,0,0,0,1,2,1],R=[-d-1,-d,-d+1,-1,0,1,d-1,d,d+1],k=L=>L<0?0:L>255?255:L;for(let L=1;L<f-1;L++)for(let _=1;_<d-1;_++){const O=L*d+_;let F=0,B=0;F+=I[O+R[0]]*P[0],B+=I[O+R[0]]*C[0],F+=I[O+R[1]]*P[1],B+=I[O+R[1]]*C[1],F+=I[O+R[2]]*P[2],B+=I[O+R[2]]*C[2],F+=I[O+R[3]]*P[3],B+=I[O+R[3]]*C[3],F+=I[O+R[5]]*P[5],B+=I[O+R[5]]*C[5],F+=I[O+R[6]]*P[6],B+=I[O+R[6]]*C[6],F+=I[O+R[7]]*P[7],B+=I[O+R[7]]*C[7],F+=I[O+R[8]]*P[8],B+=I[O+R[8]]*C[8];const U=k(v+(w*F+x*B)*A),M=O*4;if(g){const z=U-v;u[M]=k(T[M]+z),u[M+1]=k(T[M+1]+z),u[M+2]=k(T[M+2]+z),u[M+3]=T[M+3]}else u[M]=u[M+1]=u[M+2]=U,u[M+3]=T[M+3]}for(let L=0;L<d;L++){let _=L*4,O=((f-1)*d+L)*4;u[_]=T[_],u[_+1]=T[_+1],u[_+2]=T[_+2],u[_+3]=T[_+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}for(let L=1;L<f-1;L++){let _=L*d*4,O=(L*d+(d-1))*4;u[_]=T[_],u[_+1]=T[_+1],u[_+2]=T[_+2],u[_+3]=T[_+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}return e};qe.addGetterSetter(sn,"embossStrength",.5,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"embossWhiteLevel",.5,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"embossDirection","top-left",void 0,qe.afterSetFilter),qe.addGetterSetter(sn,"embossBlend",!1,void 0,qe.afterSetFilter);function l$(e,t,n,r,i){const o=n-t,s=i-r;if(o===0)return r+s/2;if(s===0)return r;let a=(e-t)/o;return a=s*a+r,a}const PUn=function(e){const t=e.data,n=t.length;let r=t[0],i=r,o,s=t[1],a=s,l,c=t[2],u=c,d;const f=this.enhance();if(f===0)return;for(let b=0;b<n;b+=4)o=t[b+0],o<r?r=o:o>i&&(i=o),l=t[b+1],l<s?s=l:l>a&&(a=l),d=t[b+2],d<c?c=d:d>u&&(u=d);i===r&&(i=255,r=0),a===s&&(a=255,s=0),u===c&&(u=255,c=0);let h,p,m,g,y,v;if(f>0)h=i+f*(255-i),p=r-f*(r-0),m=a+f*(255-a),g=s-f*(s-0),y=u+f*(255-u),v=c-f*(c-0);else{const b=(i+r)*.5;h=i+f*(i-b),p=r+f*(r-b);const w=(a+s)*.5;m=a+f*(a-w),g=s+f*(s-w);const x=(u+c)*.5;y=u+f*(u-x),v=c+f*(c-x)}for(let b=0;b<n;b+=4)t[b+0]=l$(t[b+0],r,i,p,h),t[b+1]=l$(t[b+1],s,a,g,m),t[b+2]=l$(t[b+2],c,u,v,y)};qe.addGetterSetter(sn,"enhance",0,Zt(),qe.afterSetFilter);const RUn=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const i=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=i,t[r+1]=i,t[r+2]=i}};qe.addGetterSetter(sn,"hue",0,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"saturation",0,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"luminance",0,Zt(),qe.afterSetFilter);const LUn=function(e){const t=e.data,n=t.length,r=1,i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*i*Math.cos(o*Math.PI/180),l=r*i*Math.sin(o*Math.PI/180),c=.299*r+.701*a+.167*l,u=.587*r-.587*a+.33*l,d=.114*r-.114*a-.497*l,f=.299*r-.299*a-.328*l,h=.587*r+.413*a+.035*l,p=.114*r-.114*a+.293*l,m=.299*r-.3*a+1.25*l,g=.587*r-.586*a-1.05*l,y=.114*r+.886*a-.2*l;let v,b,w,x;for(let A=0;A<n;A+=4)v=t[A+0],b=t[A+1],w=t[A+2],x=t[A+3],t[A+0]=c*v+u*b+d*w+s,t[A+1]=f*v+h*b+p*w+s,t[A+2]=m*v+g*b+y*w+s,t[A+3]=x},NUn=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s=r*i*Math.cos(o*Math.PI/180),a=r*i*Math.sin(o*Math.PI/180),l=.299*r+.701*s+.167*a,c=.587*r-.587*s+.33*a,u=.114*r-.114*s-.497*a,d=.299*r-.299*s-.328*a,f=.587*r+.413*s+.035*a,h=.114*r-.114*s+.293*a,p=.299*r-.3*s+1.25*a,m=.587*r-.586*s-1.05*a,g=.114*r+.886*s-.2*a;for(let y=0;y<n;y+=4){const v=t[y+0],b=t[y+1],w=t[y+2],x=t[y+3];t[y+0]=l*v+c*b+u*w,t[y+1]=d*v+f*b+h*w,t[y+2]=p*v+m*b+g*w,t[y+3]=x}};qe.addGetterSetter(sn,"hue",0,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"saturation",0,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"value",0,Zt(),qe.afterSetFilter);const MUn=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4)t[r]=255-t[r],t[r+1]=255-t[r+1],t[r+2]=255-t[r+2]};var DUn=function(e,t,n){const r=e.data,i=t.data,o=e.width,s=e.height,a=n.polarCenterX||o/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=o-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=o,m=360/p*Math.PI/180;for(let g=0;g<p;g+=1){const y=Math.sin(g*m),v=Math.cos(g*m);for(let b=0;b<h;b+=1){u=Math.floor(a+c*b/h*v),d=Math.floor(l+c*b/h*y);let w=(d*o+u)*4;const x=r[w+0],A=r[w+1],T=r[w+2],I=r[w+3];w=(g+b*o)*4,i[w+0]=x,i[w+1]=A,i[w+2]=T,i[w+3]=I}}},OUn=function(e,t,n){const r=e.data,i=t.data,o=e.width,s=e.height,a=n.polarCenterX||o/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=o-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=o,m=n.polarRotation||0;let g,y;for(u=0;u<o;u+=1)for(d=0;d<s;d+=1){const v=u-a,b=d-l,w=Math.sqrt(v*v+b*b)*h/c;let x=(Math.atan2(b,v)*180/Math.PI+360+m)%360;x=x*p/360,g=Math.floor(x),y=Math.floor(w);let A=(y*o+g)*4;const T=r[A+0],I=r[A+1],P=r[A+2],C=r[A+3];A=(d*o+u)*4,i[A+0]=T,i[A+1]=I,i[A+2]=P,i[A+3]=C}};const FUn=function(e){const t=e.width,n=e.height;let r,i,o,s,a,l,c,u,d,f,h=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),m=Math.floor(t*(p%360)/360);if(h<1)return;const g=lt.createCanvasElement();g.width=t,g.height=n;const y=g.getContext("2d").getImageData(0,0,t,n);lt.releaseCanvas(g),DUn(e,y,{polarCenterX:t/2,polarCenterY:n/2});let v=t/Math.pow(2,h);for(;v<=8;)v=v*2,h-=1;v=Math.ceil(v);let b=v,w=0,x=b,A=1;for(m+v>t&&(w=b,x=0,A=-1),i=0;i<n;i+=1)for(r=w;r!==x;r+=A)o=Math.round(r+m)%t,d=(t*i+o)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*i+r)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;for(i=0;i<n;i+=1)for(b=Math.floor(v),s=0;s<h;s+=1){for(r=0;r<b+1;r+=1)d=(t*i+r)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*i+b*2-r-1)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;b*=2}OUn(y,e,{polarRotation:0})};qe.addGetterSetter(sn,"kaleidoscopePower",2,Zt(),qe.afterSetFilter),qe.addGetterSetter(sn,"kaleidoscopeAngle",0,Zt(),qe.afterSetFilter);function A6(e,t,n){let r=(n*e.width+t)*4;const i=[];return i.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),i}function F2(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function BUn(e){const t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function HUn(e,t){const n=A6(e,0,0),r=A6(e,e.width-1,0),i=A6(e,0,e.height-1),o=A6(e,e.width-1,e.height-1),s=t||10;if(F2(n,r)<s&&F2(r,o)<s&&F2(o,i)<s&&F2(i,n)<s){const a=BUn([r,n,o,i]),l=[];for(let c=0;c<e.width*e.height;c++)l[c]=F2(a,[e.data[c*4],e.data[c*4+1],e.data[c*4+2]])<s?0:255;return l}}function zUn(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function UUn(e,t,n){const r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u===2040?255:0}return s}function VUn(e,t,n){const r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u>=1020?255:0}return s}function WUn(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u}return s}const GUn=function(e){let t=HUn(e,this.threshold());return t&&(t=UUn(t,e.width,e.height),t=VUn(t,e.width,e.height),t=WUn(t,e.width,e.height),zUn(e,t)),e};qe.addGetterSetter(sn,"threshold",0,Zt(),qe.afterSetFilter);const jUn=function(e){const t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let o=0;o<r;o+=4)n[o+0]+=i-2*i*Math.random(),n[o+1]+=i-2*i*Math.random(),n[o+2]+=i-2*i*Math.random()};qe.addGetterSetter(sn,"noise",.2,Zt(),qe.afterSetFilter);const qUn=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,i=Math.ceil(n/t),o=Math.ceil(r/t),s=e.data;if(t<=0){lt.error("pixelSize value can not be <= 0");return}for(let a=0;a<i;a+=1)for(let l=0;l<o;l+=1){let c=0,u=0,d=0,f=0;const h=a*t,p=h+t,m=l*t,g=m+t;let y=0;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const w=(n*b+v)*4;c+=s[w+0],u+=s[w+1],d+=s[w+2],f+=s[w+3],y+=1}c=c/y,u=u/y,d=d/y,f=f/y;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const w=(n*b+v)*4;s[w+0]=c,s[w+1]=u,s[w+2]=d,s[w+3]=f}}};qe.addGetterSetter(sn,"pixelSize",8,Zt(),qe.afterSetFilter);const YUn=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let o=0;o<r;o+=1)n[o]=Math.floor(n[o]/i)*i};qe.addGetterSetter(sn,"levels",.5,Zt(),qe.afterSetFilter);const KUn=function(e){const t=e.data,n=t.length,r=this.red(),i=this.green(),o=this.blue();for(let s=0;s<n;s+=4){const a=(.34*t[s]+.5*t[s+1]+.16*t[s+2])/255;t[s]=a*r,t[s+1]=a*i,t[s+2]=a*o,t[s+3]=t[s+3]}};qe.addGetterSetter(sn,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(sn,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(sn,"blue",0,EHe,qe.afterSetFilter);const XUn=function(e){const t=e.data,n=t.length,r=this.red(),i=this.green(),o=this.blue(),s=this.alpha();for(let a=0;a<n;a+=4){const l=1-s;t[a]=r*s+t[a]*l,t[a+1]=i*s+t[a+1]*l,t[a+2]=o*s+t[a+2]*l}};qe.addGetterSetter(sn,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(sn,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(sn,"blue",0,EHe,qe.afterSetFilter),qe.addGetterSetter(sn,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const JUn=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const i=t[r+0],o=t[r+1],s=t[r+2];t[r+0]=Math.min(255,i*.393+o*.769+s*.189),t[r+1]=Math.min(255,i*.349+o*.686+s*.168),t[r+2]=Math.min(255,i*.272+o*.534+s*.131)}},ZUn=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const i=n[r],o=n[r+1],s=n[r+2];.2126*i+.7152*o+.0722*s>=128&&(n[r]=255-i,n[r+1]=255-o,n[r+2]=255-s)}return e},QUn=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let i=0;i<r;i+=1)n[i]=n[i]<t?0:255};qe.addGetterSetter(sn,"threshold",.5,Zt(),qe.afterSetFilter);var $Un=ize.Util._assign(ize,{Arc:rm,Arrow:tv,Circle:PS,Ellipse:T0,Image:bf,Label:i$,Tag:nv,Line:im,Path:yd,Rect:M2,RegularPolygon:I0,Ring:rv,Sprite:Ph,Star:k0,Text:Vo,TextPath:ga,Transformer:yi,Wedge:om,Filters:{Blur:IUn,Brightness:EUn,Brighten:kUn,Contrast:CUn,Emboss:_Un,Enhance:PUn,Grayscale:RUn,HSL:LUn,HSV:NUn,Invert:MUn,Kaleidoscope:FUn,Mask:GUn,Noise:jUn,Pixelate:qUn,Posterize:YUn,RGB:KUn,RGBA:XUn,Sepia:JUn,Solarize:ZUn,Threshold:QUn}});$t();var eVn=["dialog","floating"],Cze=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function tVn(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!eVn.includes(e.mode))throw new Error(`SurfaceManager: mode must be "dialog" or "floating", got "${e.mode}".`);const t="kind"in e&&e.kind!=null,n="component"in e&&e.component!=null,r="render"in e&&typeof e.render=="function";if(n&&r)throw new Error('SurfaceManager: request cannot provide both "component" and "render". Use one or the other.');if(!t&&!n&&!r)throw new Error('SurfaceManager: request must provide "kind" (intent-based) or "component"/"render" (direct-render).');if(e.mode==="floating"&&e.floating?.placement!=null&&!Cze.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${Cze.join(", ")}, got "${e.floating.placement}".`)}var nVn=class{activeDialog=Pu(null);activeFloating=Pu(null);#e=!1;#t=1;#i;constructor({getModuleConfig:e}){this.#i=e}open(e){if(this.#e)return this.#u(e);tVn(e);const t=this.#l(e),{component:n,props:r,render:i}=this.#c(t);let o,s=!1;const a=new Promise(h=>{o=p=>s?!1:(s=!0,h(p),!0)});let l;const c=h=>{o({status:"submitted",data:h})&&this.#r(l)},u=h=>{o({status:"closed",reason:h})&&this.#r(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:i,resolve:c,close:u,settle:h=>o(h),get settled(){return s}};const d=t.mode==="dialog"?"activeDialog":"activeFloating",f=this[d].value;return f&&!f.settled&&f.settle({status:"replaced",replacedBy:t.id}),this[d].value=l,{id:t.id,mode:t.mode,close:h=>this.#n(l,h),result:a}}close(e,t){if(e!=null){const i=this.#o(e);i&&this.#n(i,t);return}const n=this.activeDialog.value;if(n&&!n.settled){this.#n(n,t);return}const r=this.activeFloating.value;r&&!r.settled&&this.#n(r,t)}settleAll(e){for(const t of[this.activeDialog,this.activeFloating]){const n=t.value;n&&!n.settled&&n.settle(e),t.value=null}}destroy(){this.#e=!0,this.settleAll({status:"destroyed"})}#n(e,t){e.settled||(e.settle({status:"closed",reason:t}),this.#r(e))}#r(e){const t=e.mode==="dialog"?this.activeDialog:this.activeFloating;t.value===e&&(t.value=null)}#o(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#l(e){const t=e.id??`surface-${this.#t++}`,n=this.#i()??{},r=e.mode==="dialog"?n.dialog:n.floating,i=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,o=e.mode==="floating"?{placement:r?.placement??"top-right",width:r?.width,maxWidth:r?.maxWidth,maxHeight:r?.maxHeight,autoFocus:r?.autoFocus??!0,closeOnOutsidePointerDown:r?.closeOnOutsidePointerDown??!1,...e.floating}:e.floating;return{...e,id:t,closeOnEscape:e.closeOnEscape??r?.closeOnEscape??!0,closeOnBackdrop:e.mode==="dialog"?e.closeOnBackdrop??r?.closeOnBackdrop??!0:!1,dialog:i,floating:o}}#c(e){if("component"in e&&e.component!=null)return{component:e.component,props:e.props};if("render"in e&&typeof e.render=="function")return{render:e.render};const t=this.#i()?.resolver;if(typeof t=="function"){const n=t(e);if(n!=null){if(n.type==="none")throw new Error(`SurfaceManager: resolver explicitly suppressed surface for kind "${e.kind}".`);if(n.type==="custom")return{component:n.component,props:n.props};if(n.type==="external")return{render:n.render}}}throw new Error(`SurfaceManager: no renderer resolved for kind "${e.kind}". Provide a resolver via modules.surfaces.resolver, or use a direct-render request.`)}#u(e){return{id:e?.id??`surface-${this.#t++}`,mode:e?.mode??"dialog",close:()=>{},result:Promise.resolve({status:"destroyed"})}}},rVn="https://docs.superdoc.dev/guides/migration/document-api",_ze=new Set;function iVn(e,t){_ze.has(e)||(_ze.add(e),console.warn(t))}var oVn={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},Pze=Symbol.for("superdoc:rawEditor"),Rze=new WeakMap;function Lze(e){return!e||e[Pze]?e:new Proxy(e,{get(t,n){if(n===Pze)return t;const r=oVn[n];r&&iVn(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${rVn}`);const i=Reflect.get(t,n,t);if(typeof i=="function"){let o=Rze.get(t);return o||(o=new Map,Rze.set(t,o)),o.has(n)||o.set(n,i.bind(t)),o.get(n)}return i}})}var Nze=["review","original","final","off"],sVn=["paired","independent"],Mze=Symbol.for("@superdoc/trackChanges:normalized"),Dze=new Set;function Oze(e,t){Dze.has(e)||(Dze.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function Fze(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function aVn(e,t,n){return typeof e=="string"&&Nze.includes(e)?e:typeof t=="string"&&Nze.includes(t)?t:n}function lVn(e){return typeof e=="string"&&sVn.includes(e)?e:null}function B2(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function cVn(e){const t=e[Mze]===!0;B2(e.modules)||(e.modules={});const n=B2(e.modules.trackChanges),r=B2(e.trackChanges),i=B2(e.layoutEngineOptions?.trackedChanges);t||(r&&Oze("config.trackChanges","config.modules.trackChanges"),i&&Oze("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const o=Fze(n?.visible,r?.visible,!1),s=Fze(n?.enabled,i?.enabled,!0),a=lVn(n?.replacements)??"paired",l=e.documentMode==="viewing"?o?"review":"original":"review",c=aVn(n?.mode,i?.mode,l),u={visible:o,mode:c,enabled:s,replacements:a};return e.modules.trackChanges=u,e.trackChanges={visible:o},B2(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:c,enabled:s},Object.defineProperty(e,Mze,{value:!0,writable:!0,configurable:!0,enumerable:!1}),u}$t();var c$=Object.freeze({name:"Default SuperDoc user",email:null}),uVn=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]);function aer(e){return e}var x6=class extends fF.default{static allowedTypes=[xc,WT,L1];#e=!1;#t=!1;#i=null;#n=null;#r;version;users;ydoc;provider;whiteboard;colors=[];superdocStore;commentsStore;highContrastModeStore;app;pinia;readyEditors=0;pendingCollaborationSaves=0;config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0};constructor(e){if(super(),!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#o(e,t)}async#o(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),cVn(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated");const i=this.config.user;if(!i||typeof i!="object"?this.config.user={...c$}:(this.config.user={...c$,...i},this.config.user.name||(this.config.user.name=c$.name)),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.colors=$Xe(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="1.34.0-next.7",this.#A("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||yn(),this.colors=this.config.colors??[],this.#d(),this.#r=new nVn({getModuleConfig:()=>this.config.modules?.surfaces}),await this.#s(this.config.modules),this.#e){this.#T();return}this.config.cspNonce&&this.#u(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null,this.#n=document.createElement("div"),this.#n.style.display="contents",t.appendChild(this.#n),this.#a(),this.#c(),this.#_(),this.#l()}#l(){this.#f(),this.readyEditors=0,this.app.mount(this.#n)}#c(){const e=(this.config.modules?.whiteboard??{}).enabled??!1;this.whiteboard=new _Hn({Renderer:$Un,superdoc:this,enabled:e}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.superdocStore.documents.filter(e=>e.type===xc).length}get state(){return{documents:this.superdocStore.documents,users:this.users}}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#u(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#d(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,i=!!e&&e instanceof Blob&&!(e instanceof File),o=this.config.documents&&this.config.documents?.length;if(t&&o&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const s=y2(this.config.document);this.config.documents=[{id:yn(),...s}]}else if(n)this.config.documents=[{id:yn(),type:xc,url:this.config.document,name:"document.docx"}];else if(r){const s=y2(this.config.document);this.config.documents=[{id:yn(),...s}]}else if(i){const s=y2(this.config.document);this.config.documents=[{id:yn(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=y2(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||yn()}}))}#f(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:i}=wHn({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#r),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=i,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const o=this.config.modules.comments;this.commentsStore.init(o||{}),this.isCollaborative&&t6(this),this.#I()}#a(){this.on("editorBeforeCreate",this.config.onEditorBeforeCreate),this.on("editorCreate",this.config.onEditorCreate),this.on("editorDestroy",this.config.onEditorDestroy),this.on("ready",this.config.onReady),this.on("comments-update",this.config.onCommentsUpdate),this.on("awareness-update",this.config.onAwarenessUpdate),this.on("locked",this.config.onLocked),this.on("pdf:document-ready",this.config.onPdfDocumentReady),this.on("sidebar-toggle",this.config.onSidebarToggle),this.on("collaboration-ready",this.config.onCollaborationReady),this.on("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.on("exception",this.config.onException),this.on("list-definitions-change",this.config.onListDefinitionsChange),this.on("pagination-update",this.config.onPaginationUpdate),this.config.onFontsResolved&&this.on("fonts-resolved",this.config.onFontsResolved)}async#s({collaboration:e,comments:t={}}={}){if(!e)return this.config.documents;const{ydoc:n,provider:r}=e;if(n&&r)return(!this.config.documents||this.config.documents.length===0)&&(this.config.documents=[{id:yn(),type:xc,name:"document.docx"}]),this.#w(n,r),t6(this),this.config.documents;this.isCollaborative=!0,e.providerType==="hocuspocus"&&(this.config.socket=new Aoe({url:e.url}));const i=z8n(this);if(t.useInternalExternalComments&&!t.suppressInternalExternalComments){const{ydoc:o,provider:s}=H8n(this);this.ydoc=no(o),this.provider=no(s)}else this.ydoc=no(i[0].ydoc),this.provider=no(i[0].provider);return t6(this),i}#w(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=no(e),this.provider=no(t),this.#x(),this._cleanupAwareness=O8n(t,this,this.config.user),this.config.documents.forEach(n=>{n.ydoc=e,n.provider=t,n.role=this.config.role})}#y(){typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#x(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:uVn,n=e.email||e.name||"";let r=5381;for(let i=0;i<n.length;i++)r=(r<<5)+r^n.charCodeAt(i);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration({ydoc:e,provider:t}){this.#C({ydoc:e,provider:t}),this.#t=!0;try{const n=this.#k();await this.#v(t),this.#N(),AFt(n,e),THn(e,this.commentsStore.commentsList),IHn(e,{isLocked:this.isLocked,lockedBy:this.lockedBy}),this.config.modules.collaboration={ydoc:e,provider:t},this.#w(e,t),this.#S(e,t);const r=this.#g();try{r.attachCollaboration({ydoc:e,collaborationProvider:t})}catch(i){throw this.#b(),i}if(await this.#h(r),this.#e)return;t6(this)}finally{this.#i=null,this.#t=!1}}#N(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#S(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const i=mi(r);i.ydoc&&typeof i.ydoc=="object"&&"value"in i.ydoc&&(i.ydoc.value=e),i.provider&&typeof i.provider=="object"&&"value"in i.provider&&(i.provider.value=t)}}#g(){const e=this.superdocStore?.documents;if(!e?.length)throw new Error("SuperDoc: no store documents available for upgrade");const t=e[0].getPresentationEditor?.()||e[0].getEditor?.();if(!t?.attachCollaboration)throw new Error("SuperDoc: editor does not support attachCollaboration");return t}#b(){this.#y(),this.#S(null,null)}#h(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let i=!1;const o=()=>{i||(i=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{o(),console.warn("[SuperDoc] collaborationReady did not fire within 10 s after collaboration attach. Continuing — collaboration is active but cursor/presence setup may be delayed."),r(void 0)},1e4),a=()=>{o(),r(void 0)};this.#i=()=>{o(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(o(),r(void 0))})}#v(e){return new Promise((n,r)=>{let i,o=!1,s=()=>{};const a=()=>{o=!0,clearTimeout(i),s()};s=gA(e,()=>{o||(a(),n())}),o||(i=setTimeout(()=>{a(),r(new Error("SuperDoc: collaboration provider did not sync within 10000 ms. The provider exposes on/off but never emitted sync(true) or synced."))},1e4)),this.#i=()=>{o||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#C({ydoc:e,provider:t}){if(this.#e)throw new Error("SuperDoc: cannot upgrade a destroyed instance");if(this.#t)throw new Error("SuperDoc: upgrade already in progress");if(this.isCollaborative)throw new Error("SuperDoc: instance is already collaborative");if(!e||!t)throw new Error("SuperDoc: upgradeToCollaboration() requires both ydoc and provider");const n=this.config,r=n.documents.filter(i=>i.type===xc);if(r.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(r.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(n.documents.length!==r.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances")}#k(){const e=this.config.documents.find(n=>n.type===xc),t=this.superdocStore.documents.find(n=>n.id===e.id)?.getEditor?.();if(!t)throw new Error("SuperDoc: source editor not yet created — wait for the ready event before upgrading");return t}addSharedUser(e){this.users.some(t=>t.email===e.email)||this.users.push(e)}removeSharedUser(e){this.users=this.users.filter(t=>t.email!==e)}onContentError({error:e,editor:t}){const{documentId:n}=t.options,r=this.superdocStore.documents.find(i=>i.id===n);this.config.onContentError?.({error:e,editor:t,documentId:r.id,file:r.data})}broadcastPdfDocumentReady(){this.emit("pdf:document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(e){this.emit("editorBeforeCreate",{editor:Lze(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.emit("editorCreate",{editor:Lze(e)})}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#A(...e){(console.debug?console.debug:console.log)("🦋 🦸♀️ [superdoc]",...e)}setActiveEditor(e){this.activeEditor=e,this.toolbar&&(this.activeEditor.toolbar=this.toolbar,this.toolbar.setActiveEditor(e))}toggleRuler(){this.config.rulers=!this.config.rulers,this.superdocStore.documents.forEach(e=>{e.rulers=this.config.rulers})}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:i=null}={}){if(!e)return!1;let o=r??i?.comment??null;const s=i?.commentId||i?.id;if(!o&&s&&this.commentsStore?.getComment){const a=this.commentsStore.getComment(s);o=a?.getValues?a.getValues():a}return Kb(e,t,n,{superdoc:this,currentUser:this.config.user,comment:o??null,trackedChange:i??null})}#_(){const e=this.config.modules?.toolbar||{};this.toolbarElement=this.config.modules?.toolbar?.selector||this.config.toolbar,this.toolbar=null;const t=[...e.excludeItems||[]];(!this.config.rulers||this.config.viewOptions?.layout==="web")&&t.push("ruler"),this.toolbar=new e_e({selector:this.toolbarElement||null,isDev:this.isDev||!1,toolbarGroups:this.config.modules?.toolbar?.groups||this.config.toolbarGroups,role:this.config.role,icons:this.config.modules?.toolbar?.icons||this.config.toolbarIcons,texts:this.config.modules?.toolbar?.texts||this.config.toolbarTexts,fonts:this.config.modules?.toolbar?.fonts||null,hideButtons:this.config.modules?.toolbar?.hideButtons??!0,responsiveToContainer:this.config.modules?.toolbar?.responsiveToContainer??!1,documentMode:this.config.documentMode,superdoc:this,aiApiKey:this.config.modules?.ai?.apiKey,aiEndpoint:this.config.modules?.ai?.endpoint,uiDisplayFallbackFont:this.config.uiDisplayFallbackFont,...e,excludeItems:t}),this.toolbar.on("exception",this.config.onException),this.once("editorCreate",()=>this.toolbar?.updateToolbarState())}addCommentsList(e){!this.config?.modules?.comments||this.config.role==="viewer"||(e&&(this.config.modules.comments.element=e),this.commentsList=new P4n(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}))}scrollToComment(e,t={}){if(!this.config?.modules?.comments||!e||typeof e!="string")return!1;const n=this.element||document,r=globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/"/g,'\\"'),i=n.querySelector(`[data-comment-ids*="${r}"]`);if(!i)return!1;const{behavior:o="smooth",block:s="start"}=t??{};return i.scrollIntoView({behavior:o,block:s}),this.commentsStore?.setActiveComment?.(this,e),!0}async navigateTo(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getPresentationEditor?.();return n?.navigateTo?n.navigateTo(e):!1}async scrollToElement(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getPresentationEditor?.();return n?.scrollToElement?n.scrollToElement(e):!1}setDisableContextMenu(e=!0){const t=!!e;this.config.disableContextMenu!==t&&(this.config.disableContextMenu=t,this.superdocStore?.documents?.forEach(n=>{const r=n.getPresentationEditor?.();r?.setContextMenuDisabled&&r.setContextMenuDisabled(t);const i=n.getEditor?.();i?.setOptions&&i.setOptions({disableContextMenu:t})}))}setShowBookmarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showBookmarks!==t&&(n.showBookmarks=t,this.superdocStore?.documents?.forEach(r=>{r.getPresentationEditor?.()?.setShowBookmarks?.(t)}))}setShowFormattingMarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showFormattingMarks!==t&&(n.showFormattingMarks=t,this.superdocStore?.documents?.forEach(r=>{r.getPresentationEditor?.()?.setShowFormattingMarks?.(t)}),this.emit("formatting-marks-change",{showFormattingMarks:t,superdoc:this}),this.toolbar?.updateToolbarState?.())}toggleFormattingMarks(){const e=!!this.config.layoutEngineOptions?.showFormattingMarks;this.setShowFormattingMarks(!e)}setDocumentMode(e){if(!e)return;e=e.toLowerCase(),this.config.documentMode=e,this.#I();const t={viewing:()=>this.#R(),editing:()=>this.#E(),suggesting:()=>this.#D()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#m(e,t){const n=typeof e.getPresentationEditor=="function"?e.getPresentationEditor():null;if(n){n.setDocumentMode(t);return}const r=typeof e.getEditor=="function"?e.getEditor():null;r&&r.setDocumentMode(t)}setTrackedChangesPreferences(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{const r=typeof n.getPresentationEditor=="function"?n.getPresentationEditor():null;r?.setTrackedChangesOverrides&&r.setTrackedChangesOverrides(t)})}#E(){if(this.config.role!=="editor")return this.#D();if(this.superdocStore.documents.length>0){const e=this.superdocStore.documents[0]?.getEditor();e&&this.setActiveEditor(e)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),this.superdocStore.documents.forEach(e=>{e.restoreComments(),this.#m(e,"editing")})}#D(){if(!["editor","suggester"].includes(this.config.role))return this.#R();if(this.superdocStore.documents.length>0){const e=this.superdocStore.documents[0]?.getEditor();e&&this.setActiveEditor(e)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),this.superdocStore.documents.forEach(e=>{e.restoreComments(),this.#m(e,"suggesting")})}#R(){this.toolbar&&(this.toolbar.activeEditor=null);const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0;this.setTrackedChangesPreferences(t?{mode:"review",enabled:!0}:{mode:"original",enabled:!0}),!e&&!t&&this.commentsStore?.clearEditorCommentPositions?.(),this.superdocStore.documents.forEach(n=>{e||t?n.restoreComments():n.removeComments(),this.#m(n,"viewing")})}#I(){const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0,n=this.config.documentMode==="viewing",r=e||t;this.commentsStore?.setViewingVisibility&&this.commentsStore.setViewingVisibility({documentMode:this.config.documentMode,commentsVisible:e,trackChangesVisible:t});const i=this.superdocStore?.documents;Array.isArray(i)&&i.length>0&&i.forEach(o=>{const s=typeof o.getPresentationEditor=="function"?o.getPresentationEditor():null;s?.setViewingCommentOptions&&s.setViewingCommentOptions({emitCommentPositionsInViewing:n&&r,enableCommentsInViewing:n&&e})})}search(e){return this.activeEditor?.commands.search(e,{searchModel:"visible"})}goToSearchResult(e){return this.activeEditor?.commands.goToSearchResult(e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}this.superdocStore&&(this.superdocStore.activeZoom=e),this.emit("zoomChange",{zoom:e})}setLocked(e=!0){this.config.documents.forEach(t=>{const n=t.ydoc,r=n.getMap("meta");n.transact(()=>{r.set("locked",e),r.set("lockedBy",this.user)})})}getHTML(e={}){const t=[];return this.superdocStore.documents.forEach(n=>{const r=n.getEditor();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t){this.isLocked=e,this.lockedBy=t,this.#A("🦋 [superdoc] Locking superdoc:",e,t,`
|
|
1295
1295
|
|
|
1296
1296
|
|
|
1297
1297
|
`),this.emit("locked",{isLocked:e,lockedBy:t})}async export({exportType:e=["docx"],commentsType:t="external",exportedName:n,additionalFiles:r=[],additionalFileNames:i=[],isFinalDoc:o=!1,triggerDownload:s=!0,fieldsHighlightColor:a=null}={}){const l=vHe(n||this.config.title),c=await this.exportEditorsToDOCX({commentsType:t,isFinalDoc:o,fieldsHighlightColor:a}),u=[...r],d=[...i];if(e.includes("docx")&&c.forEach(h=>{u.push(h),d.push(`${l}.docx`)}),u.length===1)return s?bHe(u[0],l,e[0]):u[0];const f=await L4e(u,d);return s?bHe(f,l,"zip"):f}async exportEditorsToDOCX({commentsType:e,isFinalDoc:t,fieldsHighlightColor:n}={}){let r;const i=this.config?.modules?.comments!==!1;e==="clean"?r=[]:i&&this.commentsStore&&typeof this.commentsStore.translateCommentsForExport=="function"&&(r=this.commentsStore.translateCommentsForExport(),Array.isArray(r)||(r=[]));const o=this.superdocStore.documents.map(async s=>{if(!s||s.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const a=typeof s.getEditor=="function"?s.getEditor():null,l=()=>!s.data||s.data.type&&s.data.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?null:s.data;if(!a)return l();try{const c=await a.exportDocx({isFinalDoc:t,comments:r,commentsType:e,fieldsHighlightColor:n});if(c)return c}catch(c){this.emit("exception",{error:c,document:s})}return l()});return(await Promise.all(o)).filter(Boolean)}async#P(){return this.#A("🦋 [superdoc] Triggering collaboration saves"),new Promise(e=>{this.superdocStore.documents.forEach((t,n)=>{if(this.#A(`Before reset - Doc ${n}: pending = ${this.pendingCollaborationSaves}`),this.pendingCollaborationSaves=0,t.ydoc){this.pendingCollaborationSaves++,this.#A(`After increment - Doc ${n}: pending = ${this.pendingCollaborationSaves}`);const r=t.ydoc.getMap("meta");r.observe(i=>{i.changes.keys.has("immediate-save-finished")&&(this.pendingCollaborationSaves--,this.pendingCollaborationSaves<=0&&e())}),r.set("immediate-save",!0)}}),this.#A(`FINAL pending = ${this.pendingCollaborationSaves}, but we have ${this.superdocStore.documents.filter(t=>t.ydoc).length} docs!`)})}async save(){const e=[this.#P()];this.#A("🦋 [superdoc] Saving superdoc");const t=await Promise.all(e);return this.#A("🦋 [superdoc] Save complete:",t),t}#T(){typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null);const e=this.config;e.socket?.cancelWebsocketRetry?.(),e.socket?.disconnect(),e.socket?.destroy(),this.ydoc?.destroy(),this.provider?.disconnect?.(),this.provider?.destroy?.(),e.documents.forEach(t=>{t.provider?.disconnect?.(),t.provider?.destroy?.(),t.ydoc?.destroy()})}openSurface(e){return this.#r.open(e)}closeSurface(e){this.#r.close(e)}destroy(){this.#e=!0,this.#i&&(this.#i(),this.#i=null),this.#r&&this.#r.destroy(),this.toolbar?.destroy(),this.app&&(this.#A("[superdoc] Unmounting app"),this.superdocStore.reset(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc),this.#T(),this.#n&&(this.#n.remove(),this.#n=null)}focus(){this.activeEditor?this.activeEditor.focus():this.superdocStore.documents.find(e=>{const t=e.getEditor();t&&t.focus()})}setHighContrastMode(e){this.activeEditor&&(this.activeEditor.setHighContrastMode?.(e),this.highContrastModeStore.setHighContrastMode(e))}};const dVn=async(e={})=>{const{editor:t,extensions:n,mode:r="docx"}=e;if(t)return t.getSchemaSummaryJSON();const i=new qp({extensions:Array.isArray(n)&&n.length?n:r==="docx"?iD():mb(),mode:r,isHeadless:!0,deferDocumentLoad:!0,telemetry:{enabled:!1}});try{return await i.getSchemaSummaryJSON()}finally{typeof i.destroy=="function"&&i.destroy()}};var fVn={action:"--sd-ui-action",actionHover:"--sd-ui-action-hover",actionText:"--sd-ui-action-text",bg:"--sd-ui-bg",hoverBg:"--sd-ui-hover-bg",activeBg:"--sd-ui-active-bg",disabledBg:"--sd-ui-disabled-bg",text:"--sd-ui-text",textMuted:"--sd-ui-text-muted",textDisabled:"--sd-ui-text-disabled",border:"--sd-ui-border"},hVn=0;function Bze(e){const{name:t,font:n,radius:r,shadow:i,colors:o,vars:s}=e,a=`sd-theme-${(t?t.replace(/[^a-zA-Z0-9-_]/g,"-"):null)||`custom-${++hVn}`}`,l=[];if(o)for(const[c,u]of Object.entries(o)){if(u==null)continue;const d=fVn[c];d&&l.push(` ${d}: ${u};`)}if(n!=null&&l.push(` --sd-ui-font-family: ${n};`),r!=null&&l.push(` --sd-ui-radius: ${r};`),i!=null&&l.push(` --sd-ui-shadow: ${i};`),s)for(const[c,u]of Object.entries(s))u!=null&&l.push(` ${c}: ${u};`);return{className:a,css:l.length>0?`.${a} {
|