@inkeep/open-knowledge 0.9.0-beta.7 → 0.9.0-beta.9
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/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +5 -5
- package/dist/constants-BjD_BYYz.mjs +2 -0
- package/dist/{dist-qfNwHap3.mjs → dist-CLfdEBRX.mjs} +27 -27
- package/dist/{dist-BrGmF_uy.mjs → dist-DyDRRPim.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/init-C-2cmfwx.mjs +1 -0
- package/dist/{init--sZ9G3mR.mjs → init-J_VHVClE.mjs} +4 -4
- package/dist/loader-C-ETO4P0.mjs +1 -0
- package/dist/{loader-n719Lx4L.mjs → loader-zoQ6_fEN.mjs} +2 -2
- package/dist/preview-B65450Tr.mjs +1 -0
- package/dist/{preview-D7mJ_l8c.mjs → preview-BQ3cl-Jv.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-D9oMZP0Q.js → ActivityModeContent-Bm0U64-P.js} +1 -1
- package/dist/public/assets/{DocumentContext-3_9FOxXe.js → DocumentContext-CgD8AejB.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-CYRlwMBM.js → SettingsDialogBody-D8T0NRov.js} +1 -1
- package/dist/public/assets/{SourceEditor-FiumNAzD.js → SourceEditor-CpS1HdDh.js} +1 -1
- package/dist/public/assets/config-validation-events-BTvynJE_.js +12 -0
- package/dist/public/assets/{index-MNZNqKCl.js → index-CMf0n3_r.js} +5 -5
- package/dist/public/assets/{typing-burst-detector-DyKUJgdU.js → typing-burst-detector-CnVF7lj5.js} +1 -1
- package/dist/public/index.html +4 -4
- package/dist/{repair-launch-json-C1RTZGRE.mjs → repair-launch-json-Cg9Flhvz.mjs} +2 -2
- package/dist/{repair-mcp-configs-Dnz0Nf3w.mjs → repair-mcp-configs-DPbmwafy.mjs} +2 -2
- package/dist/repair-skills-BTnOQYjh.mjs +1 -0
- package/dist/{repair-skills-TOO7tEqO.mjs → repair-skills-DLW4WwX2.mjs} +2 -2
- package/dist/{src-Cw8njPpT.mjs → src-gZrvadmI.mjs} +2 -2
- package/dist/start-CBqTQyuX.mjs +1 -0
- package/dist/{start-Dn3gv1sh.mjs → start-DMU7bXi5.mjs} +2 -2
- package/dist/{write-project-skill-Cb9Cuf8k.mjs → write-project-skill-BtPZMXBR.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-BpFjnS4c.mjs +0 -2
- package/dist/init-cl59p9H4.mjs +0 -1
- package/dist/loader-BbB7wnzI.mjs +0 -1
- package/dist/preview-DEizQVu6.mjs +0 -1
- package/dist/public/assets/config-validation-events-tR_2m1Bt.js +0 -12
- package/dist/repair-skills-DPC766QE.mjs +0 -1
- package/dist/start-BgM96Ckj.mjs +0 -1
|
@@ -3,7 +3,7 @@ import{o as e,t}from"./chunk-CFjPhJqf.js";import{t as n}from"./preload-helper-2e
|
|
|
3
3
|
`)}},qf=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[rf]?af(e,t):gu(e)?pu(e,e=>mu(t,t=>qf(e,t))):of(e)?ff(e,(e,n)=>qf(e,t[n])):!1,Jf=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),qf(t,n)}equals(e){return this.constructor===e.constructor&&yf(this.shape,e.shape)}[Gf](){return!0}[rf](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ed()}get nullable(){return Dp(this,Hp)}get optional(){return new ap(this)}cast(e){return Kp(e,this),e}expect(e){return Kp(e,this),e}},Yf=class extends Jf{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let 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?`Check failed`:`Constructor match failed`),n}},Xf=(e,t=null)=>new Yf(e,t);Xf(Yf);var Zf=class extends Jf{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Qf=e=>new Zf(e);Xf(Zf);var $f=class extends Jf{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},ep=(...e)=>new $f(e),tp=Xf($f),np=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),rp=e=>{if(Lp.check(e))return[np(e)];if(tp.check(e))return e.shape.map(e=>e+``);if(Ip.check(e))return[`[+-]?\\d+.?\\d*`];if(Rp.check(e))return[`.*`];if(Op.check(e))return e.shape.map(rp).flat(1);Dd()};Xf(class extends Jf{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(rp).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var ip=Symbol(`optional`),ap=class extends Jf{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[ip](){return!0}},op=Xf(ap),sp=class extends Jf{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new sp,Xf(sp);var cp=class e extends Jf{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):ff(this.shape,(n,r)=>{let i=this._isPartial&&!pf(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},lp=e=>new cp(e),up=Xf(cp),dp=Qf(e=>e!=null&&(e.constructor===Object||e.constructor==null)),fp=class extends Jf{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&ff(e,(n,r)=>{let 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)})}},pp=(e,t)=>new fp(e,t),mp=Xf(fp),hp=class extends Jf{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&ff(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},gp=(...e)=>new hp(e);Xf(hp);var _p=class extends Jf{constructor(e){super(),this.shape=e.length===1?e[0]:new Ep(e)}check(e,t){let n=gu(e)&&pu(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},vp=(...e)=>new _p(e),yp=Xf(_p),bp=Qf(e=>gu(e)),xp=class extends Jf{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},Sp=(e,t=null)=>new xp(e,t);Xf(xp);var Cp=Sp(Jf),wp=Xf(class extends Jf{constructor(e){super(),this.len=e.length-1,this.args=gp(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),Tp=Qf(e=>typeof e==`function`);Xf(class extends Jf{constructor(e){super(),this.shape=e}check(e,t){let n=pu(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Ep=class extends Jf{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=mu(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},Dp=(...e)=>e.findIndex(e=>Op.check(e))>=0?Dp(...e.map(e=>Gp(e)).map(e=>Op.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Ep(e),Op=Xf(Ep),kp=()=>!0,Ap=Qf(kp),jp=Xf(Zf,e=>e.shape===kp),Mp=Qf(e=>typeof e==`bigint`),Np=Qf(e=>e===Mp),Pp=Qf(e=>typeof e==`symbol`);Qf(e=>e===Pp);var Fp=Qf(e=>typeof e==`number`),Ip=Qf(e=>e===Fp),Lp=Qf(e=>typeof e==`string`),Rp=Qf(e=>e===Lp),zp=Qf(e=>typeof e==`boolean`),Bp=Qf(e=>e===zp),Vp=ep(void 0);Xf($f,e=>e.shape.length===1&&e.shape[0]===void 0),ep(void 0);var Hp=ep(null),Up=Xf($f,e=>e.shape.length===1&&e.shape[0]===null);Xf(Uint8Array),Xf(Yf,e=>e.shape===Uint8Array);var Wp=Dp(Fp,Lp,Hp,Vp,Mp,zp,Pp);(()=>{let e=vp(Ap),t=pp(Lp,Ap),n=Dp(Fp,Lp,Hp,zp,e,t);return e.shape=n,t.shape.values=n,n})();var Gp=e=>{if(Cp.check(e))return e;if(dp.check(e)){let t={};for(let n in e)t[n]=Gp(e[n]);return lp(t)}else if(bp.check(e))return Dp(...e.map(Gp));else if(Wp.check(e))return ep(e);else if(Tp.check(e))return Xf(e);Dd()},Kp=kf?()=>{}:(e,t)=>{let n=new Kf;if(!t.check(e,n))throw Td(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},qp=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Gp(e),h:t}),this}else(e){return this.if(Ap,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Td(`Unhandled pattern`)}}},Jp=(e=>new qp(e))(Ap).if(Ip,(e,t)=>zf(t,Ru,Lu)).if(Rp,(e,t)=>Uf(t)).if(Bp,(e,t)=>Rf(t)).if(Np,(e,t)=>BigInt(zf(t,Ru,Lu))).if(Op,(e,t)=>Yp(t,Wf(t,e.shape))).if(up,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(op.check(i)){if(Rf(t))continue;i=i.shape}n[r]=Jp(i,t)}return n}).if(yp,(e,t)=>{let n=[],r=Bf(t,0,42);for(let i=0;i<r;i++)n.push(Yp(t,e.shape));return n}).if(tp,(e,t)=>Wf(t,e.shape)).if(Up,(e,t)=>null).if(wp,(e,t)=>{let n=Yp(t,e.res);return()=>n}).if(jp,(e,t)=>Yp(t,Wf(t,[Fp,Lp,Hp,Vp,Mp,zp,vp(Fp),pp(Dp(`a`,`b`,`c`),Fp)]))).if(mp,(e,t)=>{let n={},r=zf(t,0,3);for(let i=0;i<r;i++){let r=Yp(t,e.shape.keys);n[r]=Yp(t,e.shape.values)}return n}).done(),Yp=(e,t)=>Jp(Gp(t),e),Xp=typeof document<`u`?document:{},Zp=e=>Xp.createElement(e),Qp=()=>Xp.createDocumentFragment();Qf(e=>e.nodeType===um);var $p=e=>Xp.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var em=(e,t)=>(Lf(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),tm=e=>{let t=Qp();for(let n=0;n<e.length;n++)om(t,e[n]);return t},nm=(e,t)=>(om(e,tm(t)),e),rm=(e,t=[],n=[])=>nm(em(Zp(e),t),n);Qf(e=>e.nodeType===sm);var im=$p;Qf(e=>e.nodeType===cm);var am=e=>su(e,(e,t)=>`${t}:${e};`).join(``),om=(e,t)=>e.appendChild(t),sm=Xp.ELEMENT_NODE,cm=Xp.TEXT_NODE;Xp.CDATA_SECTION_NODE,Xp.COMMENT_NODE;var lm=Xp.DOCUMENT_NODE;Xp.DOCUMENT_TYPE_NODE;var um=Xp.DOCUMENT_FRAGMENT_NODE;Qf(e=>e.nodeType===lm);var dm=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),fm=(e,t)=>new dm(setTimeout(t,e)),pm=Symbol,mm=pm(),hm=pm(),gm=pm(),_m=pm(),vm=pm(),ym=pm(),bm=pm(),xm=pm(),Sm=pm(),Cm=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Qd();var wm={[mm]:If(`font-weight`,`bold`),[hm]:If(`font-weight`,`normal`),[gm]:If(`color`,`blue`),[vm]:If(`color`,`green`),[_m]:If(`color`,`grey`),[ym]:If(`color`,`red`),[bm]:If(`color`,`purple`),[xm]:If(`color`,`orange`),[Sm]:If(`color`,`black`)},Tm=Af?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=iu(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=wm[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=am(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:Cm,Em=(...e)=>{console.log(...Tm(e)),Om.forEach(t=>t.print(e))},Dm=(...e)=>{console.warn(...Tm(e)),e.unshift(xm),Om.forEach(t=>t.print(e))},Om=lu(),km=e=>({[Symbol.iterator](){return this},next:e}),Am=(e,t)=>km(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),jm=(e,t)=>km(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Mm=class{constructor(e,t){this.clock=e,this.len=t}},Nm=class{constructor(){this.clients=new Map}},Pm=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])$h(e,i,o.clock,o.len,n)}}),Fm=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=yu((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},Im=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Fm(n,t.clock)!==null},Lm=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new Mm(r.clock,Su(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Rm=e=>{let t=new Nm;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)du(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Lm(t),t},zm=(e,t,n,r)=>{ou(e.clients,t,()=>[]).push(new Mm(n,r))},Bm=()=>new Nm,Vm=e=>{let t=Bm();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new Mm(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Hm=(e,t)=>{ad(e.restEncoder,t.clients.size),fu(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),ad(e.restEncoder,t);let r=n.length;ad(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Um=e=>{let t=new Nm,n=Id(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=Id(e.restDecoder),r=Id(e.restDecoder);if(r>0){let i=ou(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new Mm(e.readDsClock(),e.readDsLen()))}}return t},Wm=(e,t,n)=>{let r=new Nm,i=Id(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=Id(e.restDecoder),a=Id(e.restDecoder),o=n.clients.get(i)||[],s=Gh(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&zm(r,i,s,a-s);let e=qh(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,gv(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,gv(t,c,a-c.id.clock)),c.delete(t))}else zm(r,i,n,a-n)}}if(r.clients.size>0){let e=new eh;return ad(e.restEncoder,0),Hm(e,r),e.toUint8Array()}return null},Gm=Jd,Km=class e extends _u{constructor({guid:e=Zd(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Gm(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Uh,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=$d(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>$d(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&sg(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(fu(this.subdocs).map(e=>e.guid))}transact(e,t=null){return sg(this,e,t)}get(e,t=Lg){let n=ou(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==Lg&&r!==t)if(r===Lg){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,i_)}getText(e=``){return this.get(e,T_)}getMap(e=``){return this.get(e,s_)}getXmlElement(e=``){return this.get(e,A_)}getXmlFragment(e=``){return this.get(e,O_)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,fu(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,sg(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},qm=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Id(this.restDecoder)}readDsLen(){return Id(this.restDecoder)}},Jm=class extends qm{readLeftID(){return Th(Id(this.restDecoder),Id(this.restDecoder))}readRightID(){return Th(Id(this.restDecoder),Id(this.restDecoder))}readClient(){return Id(this.restDecoder)}readInfo(){return Fd(this.restDecoder)}readString(){return Rd(this.restDecoder)}readParentInfo(){return Id(this.restDecoder)===1}readTypeRef(){return Id(this.restDecoder)}readLen(){return Id(this.restDecoder)}readAny(){return Vd(this.restDecoder)}readBuf(){return Nf(Pd(this.restDecoder))}readJSON(){return JSON.parse(Rd(this.restDecoder))}readKey(){return Rd(this.restDecoder)}},Ym=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Id(this.restDecoder),this.dsCurrVal}readDsLen(){let e=Id(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Xm=class extends Ym{constructor(e){super(e),this.keys=[],Id(e),this.keyClockDecoder=new Wd(Pd(e)),this.clientDecoder=new Ud(Pd(e)),this.leftClockDecoder=new Wd(Pd(e)),this.rightClockDecoder=new Wd(Pd(e)),this.infoDecoder=new Hd(Pd(e),Fd),this.stringDecoder=new Gd(Pd(e)),this.parentInfoDecoder=new Hd(Pd(e),Fd),this.typeRefDecoder=new Ud(Pd(e)),this.lenDecoder=new Ud(Pd(e))}readLeftID(){return new Ch(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ch(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 Vd(this.restDecoder)}readBuf(){return Pd(this.restDecoder)}readJSON(){return Vd(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Zm=class{constructor(){this.restEncoder=Qu()}toUint8Array(){return td(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ad(this.restEncoder,e)}writeDsLen(e){ad(this.restEncoder,e)}},Qm=class extends Zm{writeLeftID(e){ad(this.restEncoder,e.client),ad(this.restEncoder,e.clock)}writeRightID(e){ad(this.restEncoder,e.client),ad(this.restEncoder,e.clock)}writeClient(e){ad(this.restEncoder,e)}writeInfo(e){id(this.restEncoder,e)}writeString(e){ld(this.restEncoder,e)}writeParentInfo(e){ad(this.restEncoder,+!!e)}writeTypeRef(e){ad(this.restEncoder,e)}writeLen(e){ad(this.restEncoder,e)}writeAny(e){vd(this.restEncoder,e)}writeBuf(e){dd(this.restEncoder,e)}writeJSON(e){ld(this.restEncoder,JSON.stringify(e))}writeKey(e){ld(this.restEncoder,e)}},$m=class{constructor(){this.restEncoder=Qu(),this.dsCurrVal=0}toUint8Array(){return td(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,ad(this.restEncoder,t)}writeDsLen(e){e===0&&Dd(),ad(this.restEncoder,e-1),this.dsCurrVal+=e}},eh=class extends $m{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Cd,this.clientEncoder=new xd,this.leftClockEncoder=new Cd,this.rightClockEncoder=new Cd,this.infoEncoder=new yd(id),this.stringEncoder=new wd,this.parentInfoEncoder=new yd(id),this.typeRefEncoder=new xd,this.lenEncoder=new xd}toUint8Array(){let e=Qu();return ad(e,0),dd(e,this.keyClockEncoder.toUint8Array()),dd(e,this.clientEncoder.toUint8Array()),dd(e,this.leftClockEncoder.toUint8Array()),dd(e,this.rightClockEncoder.toUint8Array()),dd(e,td(this.infoEncoder)),dd(e,this.stringEncoder.toUint8Array()),dd(e,td(this.parentInfoEncoder)),dd(e,this.typeRefEncoder.toUint8Array()),dd(e,this.lenEncoder.toUint8Array()),ud(e,td(this.restEncoder)),td(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)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){vd(this.restEncoder,e)}writeBuf(e){dd(this.restEncoder,e)}writeJSON(e){vd(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},th=(e,t,n,r)=>{r=Su(r,t[0].id.clock);let i=qh(t,r);ad(e.restEncoder,t.length-i),e.writeClient(n),ad(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},nh=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{Gh(t,n)>e&&r.set(n,e)}),Wh(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),ad(e.restEncoder,r.size),fu(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{th(e,t.clients.get(n),n,r)})},rh=(e,t)=>{let n=iu(),r=Id(e.restDecoder);for(let i=0;i<r;i++){let r=Id(e.restDecoder),i=Array(r),a=e.readClient(),o=Id(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new z_(Th(a,o),t),o+=t;break}case 10:{let t=Id(e.restDecoder);i[n]=new Cv(Th(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new yv(Th(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,bv(e,r));i[n]=c,o+=c.length}}}}return n},ih=(e,t,n)=>{let r=[],i=fu(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new Uh,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==Cv){let i=ou(d,u.id.client,()=>Gh(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,Gh(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new eh;return nh(e,s,new Map),ad(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},ah=(e,t)=>nh(e,t.doc.store,t.beforeState),oh=(e,t,n,r=new Xm(e))=>sg(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=ih(e,i,rh(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<Gh(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=_g([o.update,a.update])}}else i.pendingStructs=a;let s=Wm(r,e,i);if(i.pendingDs){let t=new Xm(jd(i.pendingDs));Id(t.restDecoder);let n=Wm(t,e,i);s&&n?i.pendingDs=_g([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,sh(e.doc,t)}},n,!1),sh=(e,t,n,r=Xm)=>{let i=jd(t);oh(i,e,n,new r(i))},ch=(e,t,n)=>sh(e,t,n,Jm),lh=(e,t,n=new Map)=>{nh(e,t.store,n),Hm(e,Vm(t.store))},uh=(e,t=new Uint8Array([0]),n=new eh)=>{lh(n,e,ph(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(vg(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Qm)return hg(r.map((e,t)=>t===0?e:Cg(e)));if(n.constructor===eh)return _g(r)}return r[0]},dh=(e,t)=>uh(e,t,new Qm),fh=e=>{let t=new Map,n=Id(e.restDecoder);for(let r=0;r<n;r++){let n=Id(e.restDecoder),r=Id(e.restDecoder);t.set(n,r)}return t},ph=e=>fh(new qm(jd(e))),mh=(e,t)=>(ad(e.restEncoder,t.size),fu(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{ad(e.restEncoder,t),ad(e.restEncoder,n)}),e),hh=(e,t)=>mh(e,Wh(t.store)),gh=(e,t=new $m)=>(e instanceof Map?mh(t,e):hh(t,e),t.toUint8Array()),_h=e=>gh(e,new Zm),vh=class{constructor(){this.l=[]}},yh=()=>new vh,bh=(e,t)=>e.l.push(t),xh=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},Sh=(e,t,n)=>_f(e.l,[t,n]),Ch=class{constructor(e,t){this.client=e,this.clock=t}},wh=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Th=(e,t)=>new Ch(e,t),Eh=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw Dd()},Dh=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Oh=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},kh=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},Ah=e=>new Oh(e.type==null?null:Th(e.type.client,e.type.clock),e.tname??null,e.item==null?null:Th(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),jh=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Mh=(e,t,n=0)=>new jh(e,t,n),Nh=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Eh(e):r=Th(e._item.id.client,e._item.id.clock),new Oh(r,i,t,n)},Ph=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Nh(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Nh(e,Th(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Nh(e,r.lastId,n);r=r.right}return Nh(e,null,n)},Fh=(e,t)=>{let n=Jh(e,t);return{item:n,diff:t.clock-n.id.clock}},Ih=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(Gh(r,i.client)<=i.clock)return null;let e=n?mv(r,i):Fh(r,i),t=e.item;if(!(t instanceof yv))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(Gh(r,a.client)<=a.clock)return null;let{item:e}=n?mv(r,a):{item:Jh(r,a)};if(e instanceof yv&&e.content instanceof fv)c=e.content.type;else return null}else throw Dd();l=s>=0?c._length:0}return Mh(c,l,e.assoc)},Lh=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&wh(e.item,t.item)&&wh(e.type,t.type)&&e.assoc===t.assoc,Rh=class{constructor(e,t){this.ds=e,this.sv=t}},zh=(e,t)=>new Rh(e,t);zh(Bm(),new Map);var Bh=e=>zh(Vm(e.store),Wh(e.store)),Vh=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Im(t.ds,e.id),Hh=(e,t)=>{let n=ou(e.meta,Hh,lu),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<Gh(r,n)&&Xh(e,Th(n,t))}),Pm(e,t.ds,e=>{}),n.add(t))},Uh=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Wh=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},Gh=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Kh=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw Dd()}n.push(t)},qh=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=yu(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=yu((n+r)/2)}throw Dd()},Jh=(e,t)=>{let n=e.clients.get(t.client);return n[qh(n,t.clock)]},Yh=(e,t,n)=>{let r=qh(t,n),i=t[r];return i.id.clock<n&&i instanceof yv?(t.splice(r+1,0,gv(e,i,n-i.id.clock)),r+1):r},Xh=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Yh(e,n,t.clock)]},Zh=(e,t,n)=>{let r=t.clients.get(n.client),i=qh(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==z_&&r.splice(i+1,0,gv(e,a,n.clock-a.id.clock+1)),a},Qh=(e,t,n)=>{let r=e.clients.get(t.id.client);r[qh(r,t.id.clock)]=n},$h=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Yh(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Yh(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},eg=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Nm,this.beforeState=Wh(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}},tg=(e,t)=>t.deleteSet.clients.size===0&&!cu(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Lm(t.deleteSet),ah(e,t),Hm(e,t.deleteSet),!0),ng=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&ou(e.changed,t,lu).add(n)},rg=(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 yv&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},ig=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=qh(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof yv&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},ag=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=xu(r.length-1,1+qh(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+rg(r,e)}})},og=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Lm(a),n.afterState=Wh(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{Sh(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&S_(n)})}),_f(e,[])}finally{r.gc&&ig(a,i,r.gcFilter),ag(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=Su(qh(e,r),1);for(let t=e.length-1;t>=n;)t-=1+rg(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=qh(r,n);a+1<r.length&&rg(r,a+1)>1||a>0&&rg(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Em(xm,mm,`[yjs] `,hm,ym,`Changed the client-id because another client seems to be using it.`),r.clientID=Gm()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Qm;tg(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new eh;tg(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):og(e,t+1)}}},sg=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new eg(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&og(i,0)}}return o},cg=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},lg=(e,t,n)=>{Pm(e,n.deletions,n=>{n instanceof yv&&t.scope.some(t=>t===e.doc||Dh(t,n))&&hv(n,!1)})},ug=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;sg(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;Pm(n,o.insertions,e=>{if(e instanceof yv){if(e.redone!==null){let{item:t,diff:i}=mv(r,e.id);i>0&&(t=Xh(n,Th(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||Dh(t,e))&&c.push(e)}}),Pm(n,o.deletions,e=>{e instanceof yv&&a.some(t=>t===n.doc||Dh(t,e))&&!Im(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=vv(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},dg=class extends _u{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=gu(e)?e[0].doc:e instanceof Km?e:e.doc}={}){super(),this.scope=[],this.doc=o,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=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new Nm;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&zm(i,n,r,a)});let a=Qd(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=Rm([t.deletions,e.deleteSet]),t.insertions=Rm([t.insertions,i])}else r.push(new cg(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),Pm(e,e.deleteSet,t=>{t instanceof yv&&this.scope.some(n=>n===e.doc||Dh(n,t))&&hv(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=gu(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof Lg?e.doc!==this.doc:e!==this.doc)&&Dm(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}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(e=>lg(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>lg(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=ug(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=ug(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*fg(e){let t=Id(e.restDecoder);for(let n=0;n<t;n++){let t=Id(e.restDecoder),n=e.readClient(),r=Id(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=Id(e.restDecoder);yield new Cv(Th(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new yv(Th(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,bv(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new z_(Th(n,r),t),r+=t}}}}var pg=class{constructor(e,t){this.gen=fg(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===Cv);return this.curr}},mg=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},hg=e=>_g(e,Jm,Qm),gg=(e,t)=>{if(e.constructor===z_){let{client:n,clock:r}=e.id;return new z_(Th(n,r+t),e.length-t)}else if(e.constructor===Cv){let{client:n,clock:r}=e.id;return new Cv(Th(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new yv(Th(r,i+t),null,Th(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},_g=(e,t=Xm,n=eh)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(jd(e))),i=r.map(e=>new pg(e,!0)),a=null,o=new n,s=new mg(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Cv?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)bg(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===Cv)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{bg(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Cv(Th(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===Cv?a.struct.length-=t:n=gg(n,t)),a.struct.mergeWith(n)||(bg(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Cv;n=e.next())bg(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(bg(s,a.struct,a.offset),a=null),xg(s),Hm(o,Rm(r.map(e=>Um(e)))),o.toUint8Array()},vg=(e,t,n=Xm,r=eh)=>{let i=ph(t),a=new r,o=new mg(a),s=new n(jd(e)),c=new pg(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Cv){c.next();continue}if(e.id.clock+e.length>n)for(bg(o,e,Su(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)bg(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return xg(o),Hm(a,Um(s)),a.toUint8Array()},yg=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:td(e.encoder.restEncoder)}),e.encoder.restEncoder=Qu(),e.written=0)},bg=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&yg(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),ad(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},xg=e=>{yg(e);let t=e.encoder.restEncoder;ad(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];ad(t,r.written),ud(t,r.restEncoder)}},Sg=(e,t,n,r)=>{let i=new n(jd(e)),a=new pg(i,!1),o=new r,s=new mg(o);for(let e=a.curr;e!==null;e=a.next())bg(s,t(e),0);return xg(s),Hm(o,Um(i)),o.toUint8Array()},Cg=e=>Sg(e,vf,Xm,Qm),wg=`You must not compute changes after the event-handler fired.`,Tg=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||=Eg(this.currentTarget,this.target)}deletes(e){return Im(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Td(wg);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=uu(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=uu(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=uu(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),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 Td(wg);let t=this.target,n=lu(),r=lu(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},Eg=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},Dg=()=>{Dm(`Invalid access: Add Yjs type to a document before reading data.`)},Og=80,kg=0,Ag=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=kg++}},jg=e=>{e.timestamp=kg++},Mg=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=kg++},Ng=(e,t,n)=>{if(e.length>=Og){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Mg(r,t,n),r}else{let r=new Ag(t,n);return e.push(r),r}},Pg=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>bu(t-e.index)<bu(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,jg(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&&bu(n.index-i)<r.parent.length/Og?(Mg(n,r,i),n):Ng(e._searchMarker,r,i)},Fg=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=Su(t,i.index+n))}},Ig=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;ou(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Sh(r._eH,n,t)},Lg=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=yh(),this._dEH=yh(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ed()}clone(){throw Ed()}_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){bh(this._eH,e)}observeDeep(e){bh(this._dEH,e)}unobserve(e){xh(this._eH,e)}unobserveDeep(e){xh(this._dEH,e)}toJSON(){}},Rg=(e,t,n)=>{e.doc??Dg(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},zg=e=>{e.doc??Dg();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},Bg=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Vh(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},Vg=(e,t)=>{let n=0,r=e._start;for(e.doc??Dg();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},Hg=(e,t)=>{let n=[];return Vg(e,(r,i)=>{n.push(t(r,i,e))}),n},Ug=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}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},Wg=(e,t)=>{e.doc??Dg();let n=Pg(e,t),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}},Gg=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new yv(Th(o,Gh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ev(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new yv(Th(o,Gh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new B_(new Uint8Array(n))),i.integrate(e,0);break;case Km:i=new yv(Th(o,Gh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new G_(n)),i.integrate(e,0);break;default:if(n instanceof Lg)i=new yv(Th(o,Gh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new fv(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Kg=()=>Td(`Length exceeded!`),qg=(e,t,n,r)=>{if(n>t._length)throw Kg();if(n===0)return t._searchMarker&&Fg(t._searchMarker,n,r.length),Gg(e,t,null,r);let i=n,a=Pg(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&Xh(e,Th(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Fg(t._searchMarker,i,r.length),Gg(e,t,o,r)},Jg=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return Gg(e,t,r,n)},Yg=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=Pg(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&Xh(e,Th(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&Xh(e,Th(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Kg();t._searchMarker&&Fg(t._searchMarker,i,-a+r)},Xg=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Zg=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new ev([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new ev([r]);break;case Uint8Array:s=new B_(r);break;case Km:s=new G_(r);break;default:if(r instanceof Lg)s=new fv(r);else throw Error(`Unexpected content type`)}new yv(Th(o,Gh(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Qg=(e,t)=>{e.doc??Dg();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},$g=e=>{let t={};return e.doc??Dg(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},e_=(e,t)=>{e.doc??Dg();let n=e._map.get(t);return n!==void 0&&!n.deleted},t_=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&Vh(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},n_=e=>(e.doc??Dg(),Am(e._map.entries(),e=>!e[1].deleted)),r_=class extends Tg{},i_=class e extends Lg{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Lg?e.clone():e)),t}get length(){return this.doc??Dg(),this._length}_callObserver(e,t){super._callObserver(e,t),Ig(this,e,new r_(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):sg(this.doc,n=>{qg(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):sg(this.doc,t=>{Jg(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):sg(this.doc,n=>{Yg(n,this,e,t)})}get(e){return Wg(this,e)}toArray(){return zg(this)}slice(e=0,t=this.length){return Rg(this,e,t)}toJSON(){return this.map(e=>e instanceof Lg?e.toJSON():e)}map(e){return Hg(this,e)}forEach(e){Vg(this,e)}[Symbol.iterator](){return Ug(this)}_write(e){e.writeTypeRef(av)}},a_=e=>new i_,o_=class extends Tg{constructor(e,t,n){super(e,t),this.keysChanged=n}},s_=class e extends Lg{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof Lg?e.clone():e)}),t}_callObserver(e,t){Ig(this,e,new o_(this,e,t))}toJSON(){this.doc??Dg();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof Lg?r.toJSON():r}}),e}get size(){return[...n_(this)].length}keys(){return jm(n_(this),e=>e[0])}values(){return jm(n_(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return jm(n_(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Dg(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):sg(this.doc,t=>{Xg(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):sg(this.doc,n=>{Zg(n,this,e,t)}),t}get(e){return Qg(this,e)}has(e){return e_(this,e)}clear(){this.doc===null?this._prelimContent.clear():sg(this.doc,e=>{this.forEach(function(t,n,r){Xg(e,r,n)})})}_write(e){e.writeTypeRef(ov)}},c_=e=>new s_,l_=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&mf(e,t),u_=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&Dd(),this.right.content.constructor){case Y_:this.right.deleted||m_(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},d_=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case Y_:t.right.deleted||m_(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&Xh(e,Th(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},f_=(e,t,n,r)=>{let i=new Map,a=r?Pg(t,n):null;return a?d_(e,new u_(a.p.left,a.p,a.index,i),n-a.index):d_(e,new u_(null,t._start,0,i),n)},p_=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Y_&&l_(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new yv(Th(a,Gh(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new Y_(o,r));l.integrate(e,0),n.right=l,n.forward()})},m_=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},h_=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===Y_&&l_(t[e.right.content.key]??null,e.right.content.value));)e.forward()},g_=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!l_(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new yv(Th(a,Gh(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new Y_(s,c)),n.right.integrate(e,0),n.forward()}}return o},__=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;h_(n,i);let s=g_(e,t,n,i),c=r.constructor===String?new nv(r):r instanceof Lg?new fv(r):new q_(r),{left:l,right:u,index:d}=n;t._searchMarker&&Fg(t._searchMarker,n.index,c.getLength()),u=new yv(Th(o,Gh(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),p_(e,t,n,s)},v_=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;h_(n,i);let s=g_(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===Y_));){if(!n.right.deleted)switch(n.right.content.constructor){case Y_:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(l_(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&Xh(e,Th(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
4
4
|
`;n.right=new yv(Th(o,Gh(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new nv(i)),n.right.integrate(e,0),n.forward()}p_(e,t,n,s)},y_=(e,t,n,r,i)=>{let a=t,o=iu();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===Y_){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case Y_:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&m_(i,n);break}}}t=t.right}return s},b_=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Y_){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},x_=e=>{let t=0;return sg(e.doc,n=>{let r=e._start,i=e._start,a=iu(),o=au(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Y_:m_(o,i.content);break;default:t+=y_(n,r,i,a,o),a=au(o),r=i;break}i=i.right}}),t},S_=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&$h(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===Y_&&e.constructor!==z_&&t.add(e.parent)})}sg(n,n=>{Pm(e,e.deleteSet,e=>{if(e instanceof z_||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===Y_?t.add(r):b_(n,e)});for(let e of t)x_(e)})},C_=(e,t,n)=>{let r=n,i=au(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case fv:case q_:case nv:n<t.right.length&&Xh(e,Th(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&y_(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&Fg(o._searchMarker,t.index,-r+n),t},w_=class extends Tg{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}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){let e=this.target.doc,t=[];sg(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},df(o)||(e.attributes=sf({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case fv:case q_:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case nv:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case Y_:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(l_(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),l_(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;l_(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(l_(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),m_(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},T_=class e extends Lg{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Dg(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new w_(this,e,t);Ig(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Dg();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===nv&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):sg(this.doc,n=>{let r=new u_(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
5
5
|
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&__(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&C_(n,r,a.delete):v_(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??Dg();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(Vh(s,e)||t!==void 0&&Vh(s,t))switch(s.content.constructor){case nv:{let r=i.get(`ychange`);e!==void 0&&!Vh(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!Vh(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case fv:case q_:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case Y_:Vh(s,e)&&(c(),m_(i,s.content));break}s=s.right}c()};return e||t?sg(a,n=>{e&&Hh(n,e),t&&Hh(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):sg(r,r=>{let i=f_(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),__(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):sg(r,r=>{let i=f_(r,this,e,!n);__(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):sg(n,n=>{C_(n,f_(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):sg(r,r=>{let i=f_(r,this,e,!1);i.right!==null&&v_(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):sg(this.doc,t=>{Xg(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):sg(this.doc,n=>{Zg(n,this,e,t)})}getAttribute(e){return Qg(this,e)}getAttributes(){return $g(this)}_write(e){e.writeTypeRef(sv)}},E_=e=>new T_,D_=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Dg()}[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===A_||t.constructor===O_)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null: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})}},O_=class e extends Lg{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Lg?e.clone():e)),t}get length(){return this.doc??Dg(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new D_(this,e)}querySelector(e){e=e.toUpperCase();let t=new D_(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),fu(new D_(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Ig(this,e,new M_(this,t,e))}toString(){return Hg(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),Vg(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):sg(this.doc,n=>{qg(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)sg(this.doc,n=>{let r=e&&e instanceof Lg?e._item:e;Gg(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw Td(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):sg(this.doc,n=>{Yg(n,this,e,t)})}toArray(){return zg(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Wg(this,e)}slice(e=0,t=this.length){return Rg(this,e,t)}forEach(e){Vg(this,e)}_write(e){e.writeTypeRef(lv)}},k_=e=>new O_,A_=class e extends O_{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return lf(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof Lg?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):sg(this.doc,t=>{Xg(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):sg(this.doc,n=>{Zg(n,this,e,t)})}getAttribute(e){return Qg(this,e)}hasAttribute(e){return e_(this,e)}getAttributes(e){return e?t_(this,e):$g(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return Vg(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(cv),e.writeKey(this.nodeName)}},j_=e=>new A_(e.readKey()),M_=class extends Tg{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},N_=class e extends s_{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(uv),e.writeKey(this.hookName)}},P_=e=>new N_(e.readKey()),F_=class e extends T_{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(dv)}},I_=e=>new F_,L_=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ed()}mergeWith(e){return!1}write(e,t,n){throw Ed()}integrate(e,t){throw Ed()}},R_=0,z_=class extends L_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Kh(e.doc.store,this)}write(e,t){e.writeInfo(R_),e.writeLen(this.length-t)}getMissing(e,t){return null}},B_=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Ed()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},V_=e=>new B_(e.readBuf()),H_=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){zm(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},U_=e=>new H_(e.readLen()),W_=(e,t)=>new Km({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),G_=class e{constructor(e){e._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=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(W_(this.doc.guid,this.opts))}splice(e){throw Ed()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},K_=e=>new G_(W_(e.readString(),e.readAny())),q_=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Ed()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},J_=e=>new q_(e.readJSON()),Y_=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Ed()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},X_=e=>new Y_(e.readKey(),e.readJSON()),Z_=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},Q_=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new Z_(n)},$_=Df(`node_env`)===`development`,ev=class e{constructor(e){this.arr=e,$_&&gf(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},tv=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new ev(n)},nv=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let 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(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},rv=e=>new nv(e.readString()),iv=[a_,c_,E_,j_,k_,P_,I_],av=0,ov=1,sv=2,cv=3,lv=4,uv=5,dv=6,fv=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Ed()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},pv=e=>new fv(iv[e.readTypeRef()](e)),mv=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Th(n.client,n.clock+r)),i=Jh(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof yv);return{item:i,diff:r}},hv=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},gv=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new yv(Th(r,i+n),t,Th(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=Th(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},_v=(e,t)=>mu(e,e=>Im(e.deletions,t)),vv=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Xh(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||vv(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Xh(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Xh(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Xh(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||Im(r,d.right.id)||_v(a.undoStack,d.right.id)||_v(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Xh(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=Th(c,Gh(s,c)),h=new yv(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,hv(h,!0),h.integrate(e,0),h},yv=class e extends L_{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Gh(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Gh(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Ch&&this.id.client!==this.parent.client&&this.parent.clock>=Gh(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Zh(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Xh(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===z_||this.right&&this.right.constructor===z_)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Ch){let e=Jh(n,this.parent);e.constructor===z_?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Zh(e,e.doc.store,Th(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),wh(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(wh(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Jh(e.doc.store,n.origin)))r.has(Jh(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Kh(e.doc.store,this),this.content.integrate(e,this),ng(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new z_(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:Th(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&wh(e.origin,this.lastId)&&this.right===e&&wh(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),zm(e.deleteSet,this.id.client,this.id.clock,this.length),ng(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw Dd();this.content.gc(e),t?Qh(e,this,new z_(this.id,this.length)):this.content=new H_(this.length)}write(e,t){let n=t>0?Th(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=Eh(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===Ch?(e.writeParentInfo(!1),e.writeLeftID(t)):Dd();i!==null&&e.writeString(i)}this.content.write(e,t)}},bv=(e,t)=>xv[t&31](e),xv=[()=>{Dd()},U_,Q_,V_,rv,J_,X_,pv,tv,K_,()=>{Dd()}],Sv=10,Cv=class extends L_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){Dd()}write(e,t){e.writeInfo(Sv),ad(e.restEncoder,this.length-t)}getMissing(e,t){return null}},wv=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Tv=`__ $YJS$ __`;wv[Tv]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),wv[Tv]=!0;var Ev=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},Dv=/[\uD800-\uDBFF]/,Ov=/[\uDC00-\uDFFF]/,kv=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&Dv.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&Ov.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},Av=(e,t)=>e>>>t|e<<32-t,jv=e=>Av(e,2)^Av(e,13)^Av(e,22),Mv=e=>Av(e,6)^Av(e,11)^Av(e,25),Nv=e=>Av(e,7)^Av(e,18)^e>>>3,Pv=e=>Av(e,17)^Av(e,19)^e>>>10,Fv=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Iv=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Lv=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Iv),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=Pv(t[e-2])+t[e-7]+Nv(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+Mv(o)+(o&s^~o&c)+Fv[e]+t[e]>>>0,d=jv(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/Iu,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},Rv=e=>new Lv().digest(e),zv=new G(`y-sync`),Bv=new G(`y-undo`),Vv=new G(`yjs-cursor`),Hv=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},Uv=e=>Mf(Hv(Rv(Pf(e)))),Wv=()=>({mapping:new Map,isOMark:new Map}),Gv=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!Im(t.ds,e.id),Kv=[{light:`#ecd44433`,dark:`#ecd444`}],qv=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=lu();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Yd(t))}return e.get(n)},Jv=(e,{colors:t=Kv,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new Qv(e,a),c=new ln({props:{editable:e=>{let t=zv.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:zv,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(zv);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&fm(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=Bv.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},zv)})}},destroy:()=>{s.destroy()}})});return c},Yv=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new dn(e.doc));else if(t.type===`node`){let r=Dy(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Xv(e,r))}else{let r=Dy(n.doc,n.type,t.anchor,n.mapping),i=Dy(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(xe.between(e.doc.resolve(r),e.doc.resolve(i)))}},Xv=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?Ke.create(e.doc,t):xe.near(n)},Zv=(e,t)=>({type:t.selection.jsonID,anchor:Ty(t.selection.anchor,e.type,e.mapping),head:Ty(t.selection.head,e.type,e.mapping)}),Qv=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Ev(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Zv(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Sf&&this._domSelectionInView===null&&(fm(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=Xp.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=zh(Bm(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(zv,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>ey(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new u(oe.from(e),0,0));t.setMeta(zv,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>ey(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new u(oe.from(t),0,0));if(e){let t=xu(Su(e.anchor,0),n.doc.content.size),r=xu(Su(e.head,0),n.doc.content.size);n.setSelection(xe.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(zv,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Bh(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&Dd(),r=new Km({gc:!1}),sh(r,t),t=Bh(r),sh(r,e),e=Bh(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[qh(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{Pm(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:qv(n.colorMapping,n.colors,r)}},s=Bg(i,new Rh(t.ds,e.sv)).map(n=>!n._item.deleted||Gv(n._item,e)||Gv(n._item,t)?ey(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new u(oe.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(zv,{isChangeOrigin:!0}))},zv)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=zv.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);Pm(t,t.deleteSet,e=>{if(e.constructor===yv){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>$v(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new u(oe.from(n),0,0));Yv(r,this.beforeTransactionSelection,this),r=r.setMeta(zv,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof dg}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{vy(this.doc,this.type,e,this),this.beforeTransactionSelection=Zv(this,this.prosemirrorView.state)},zv)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},$v=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof A_)return ey(e,t,n,r,i,a);throw Ed()}return o},ey=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof A_){let s=$v(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof T_&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=ty(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):Bg(e,new Rh(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(Gv(e._item,r)?Gv(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch(r){console.warn(`[y-prosemirror] schema.node(`+e.nodeName+`) threw:`,String(r&&r.message||r));let i=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};if(t.nodes[e.nodeName]&&t.nodes[e.nodeName].spec&&t.nodes[e.nodeName].spec.inline)i.inline++;else if(i.block++,t.nodes.rawMdxFallback)try{let i=t.node(`rawMdxFallback`,{reason:String(r&&r.message||r)},[t.text(e.nodeName)]);return n.mapping.set(e,i),i}catch(e){console.warn(`[y-prosemirror] rawMdxFallback substitution also failed:`,String(e&&e.message||e))}return n.mapping.delete(e),null}},ty=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,gy(n.attributes,t)))}}catch(e){console.warn(`[y-prosemirror] schema.text() threw:`,String(e&&e.message||e));let t=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};return t.inline++,null}return o},ny=(e,t)=>{let n=new F_,r=e.map(e=>({insert:e.text,attributes:_y(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},ry=(e,t)=>{let n=new A_(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,sy(e).map(e=>iy(e,t))),t.mapping.set(n,e),n},iy=(e,t)=>e instanceof Array?ny(e,t):ry(e,t),ay=e=>typeof e==`object`&&!!e,oy=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||ay(o)&&ay(s)&&oy(o,s)}return r},sy=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},cy=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&cf(e.attributes||{}).length===t[n].marks.length&&ff(e.attributes,(e,r)=>{let i=hy(r),a=t[n].marks;return a.find(e=>e.type.name===i)?oy(e,a.find(e=>e.type.name===i)?.attrs):!1}))},ly=(e,t)=>{if(e instanceof A_&&!(t instanceof Array)&&yy(e,t)){let n=sy(t);return e._length===n.length&&oy(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>ly(e,n[t]))}return e instanceof F_&&t instanceof Array&&cy(e,t)},uy=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),dy=(e,t,n)=>{let r=e.toArray(),i=sy(t),a=i.length,o=r.length,s=xu(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(uy(n.mapping.get(e),t))u=!0;else if(!ly(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(uy(n.mapping.get(e),t))u=!0;else if(!ly(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},fy=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof nv?t+=n.content.str:n.content instanceof Y_&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},py=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=fy(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,_y(e.marks,n))})),{insert:o,remove:s,index:c}=kv(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},my=/(.*)(--[a-zA-Z0-9+/=]{8})$/,hy=e=>my.exec(e)?.[1]??e,gy=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(hy(r),e[r]));return n},_y=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=ou(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${Uv(e.toJSON())}`:e.type.name]=e.attrs}}),n},vy=(e,t,n,r)=>{if(t instanceof A_&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof A_){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=sy(n),a=i.length,o=t.toArray(),s=o.length,c=xu(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!uy(r.mapping.get(e),t))if(ly(e,t))r.mapping.set(e,t);else break}for(;u+l+1<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!uy(r.mapping.get(e),t))if(ly(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof F_&&c instanceof Array)cy(n,c)||py(n,c,r),l+=1;else{let i=n instanceof A_&&yy(n,c),a=d instanceof A_&&yy(d,f);if(i&&a){let e=dy(n,c,r),t=dy(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(vy(e,n,c,r),l+=1):a?(vy(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[iy(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof F_?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(iy(i[t],r));t.insert(l,e)}},zv)},yy=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,by=null,xy=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=zv.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){let e=this.view.state.tr;e.setMeta(this.key,this.value),this.view.dispatch(e)}}},Sy=class e{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){let t=by;by=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new xy(t,r,e))})}),new e(n)}},Cy=(e=Sy.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){let r=e.getFirst();try{r.apply()}catch(r){if(r instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||fm(0,()=>Cy(e,!0));return}throw r}n=!1,e.dequeueFirst()}},wy=(e,t,n)=>{by||(by=new Map,fm(0,Cy)),ou(by,e,iu).set(t,n)},Ty=(e,t,n)=>{if(e===0)return Ph(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof F_){if(r._length>=e)return Ph(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new Oh(r._item===null?null:r._item.id,r._item===null?Eh(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new Oh(r._item===null?null:r._item.id,r._item===null?Eh(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw Dd();if(e===0&&r.constructor!==F_&&r!==t)return Ey(r._item.parent,r._item)}return Ph(t,t._length,-1)},Ey=(e,t)=>{let n=null,r=null;return e._item===null?r=Eh(e):n=Th(e._item.id.client,e._item.id.clock),new Oh(n,r,t.id)},Dy=(e,t,n,r)=>{let i=Ih(n,e);if(i===null||i.type!==t&&!Dh(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===F_)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof F_?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof F_?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},Oy=(e,t)=>{let n=Wv(),r=e.toArray().map(e=>ey(e,t,n)).filter(e=>e!==null);return{doc:t.topNodeType.create(null,oe.fromArray(r)),meta:n,mapping:n.mapping}},ky=(e,t,n)=>e!==t,Ay=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(``),i=document.createTextNode(``);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},jy=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),My=/^#[0-9a-fA-F]{6}$/,Ny=(e,t,n,r,i)=>{let a=zv.getState(e);if(a==null||a.doc==null||a.binding==null)return Be.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?Be.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:My.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=Dy(o,a.type,Ah(t.cursor.anchor),a.binding.mapping),u=Dy(o,a.type,Ah(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=Su(e.doc.content.size-1,0);l=xu(l,t),u=xu(u,t),s.push(ut.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=xu(l,u),o=Su(l,u);s.push(ut.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),Be.create(e.doc,s))},Py=(e,{awarenessStateFilter:t=ky,cursorBuilder:n=Ay,selectionBuilder:r=jy,getSelection:i=e=>e.selection}={},a=`cursor`)=>new ln({key:Vv,state:{init(i,a){return Ny(a,e,t,n,r)},apply(i,a,o,s){let c=zv.getState(s),l=i.getMeta(Vv);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?Ny(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>Vv.getState(e)},view:t=>{let n=()=>{t.docView&&wy(t,Vv,{awarenessUpdated:!0})},r=()=>{let n=zv.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=Ty(o.anchor,n.type,n.binding.mapping),c=Ty(o.head,n.type,n.binding.mapping);(r.cursor==null||!Lh(Ah(r.cursor.anchor),s)||!Lh(Ah(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&Dy(n.doc,n.type,Ah(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),Fy=e=>{let t=Bv.getState(e).undoManager;if(t!=null)return t.undo(),!0},Iy=e=>{let t=Bv.getState(e).undoManager;if(t!=null)return t.redo(),!0},Ly=new Set([`paragraph`]),Ry=(e,t)=>!(e instanceof yv)||!(e.content instanceof fv)||!(e.content.type instanceof T_||e.content.type instanceof A_&&t.has(e.content.type.nodeName))||e.content.type._length===0,zy=({protectedNodes:e=Ly,trackedOrigins:t=[],undoManager:n=null}={})=>new ln({key:Bv,state:{init:(r,i)=>{let a=zv.getState(i),o=n||new dg(a.type,{trackedOrigins:new Set([zv].concat(t)),deleteFilter:t=>Ry(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=zv.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:Zv(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=zv.getState(e.state),n=Bv.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,Bv.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}});function By(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=Mt(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function Vy(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
|
|
6
|
-
`);return/\s/.test(n)}):!1}var Hy=new G(`suggestion`);function Uy({pluginKey:e=Hy,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=By,shouldShow:g,shouldResetDismissed:_}){let v,y=p?.(),b=r&&!i,x=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},S=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,C=({match:e,dismissedRange:n,state:r,transaction:i})=>_?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:b})?!1:b?e.range.from===n.from:e.range.from===n.from&&!Vy(i);function w(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>d({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:S(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let T=new ln({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,g=p||u&&h,_=h||u,b=m||u&&h;if(!g&&!_&&!b)return;let x=b&&!g?c:l,C=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);v={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:C,clientRect:S(e,C)},g&&((r=y?.onBeforeStart)==null||r.call(y,v)),_&&((i=y?.onBeforeUpdate)==null||i.call(y,v)),(_||g)&&(v.items=await f({editor:t,query:x.query})),b&&((a=y?.onExit)==null||a.call(y,v)),_&&((o=y?.onUpdate)==null||o.call(y,v)),g&&((s=y?.onStart)==null||s.call(y,v))},destroy:()=>{var e;v&&((e=y?.onExit)==null||e.call(y,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:_,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(_||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:u,range:e.range,isActive:c.active})&&(!g||g({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!C({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=T.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=T.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),w(t,e),!0}return(y?.onKeyDown)?.call(y,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=T.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),Be.create(e.doc,[ut.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return T}var Wy=Uy;function Gy(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function Ky(e){if(e.kind===`create`){let t=e.value;return z._({id:`XPqe3B`,values:{tagValue:t}})}let t=z._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return z._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function qy(e){let t=(0,J.c)(38),{items:n,query:r,selectedIndex:a,onSelect:s,onHover:c,loading:l,error:u}=e,d=l===void 0?!1:l,f=u===void 0?null:u,{_:p}=i(),m=(0,Y.useRef)(null),h=(0,Y.useId)(),g=a>=0&&a<n.length?`${h}-option-${a}`:void 0,_,v;t[0]===a?(_=t[1],v=t[2]):(_=()=>{let e=m.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(a);t&&t.scrollIntoView({block:`nearest`})},v=[a],t[0]=a,t[1]=_,t[2]=v),(0,Y.useEffect)(_,v);let y=Jy;if(d){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:y,children:(0,X.jsx)(o,{id:`a_u4ck`})}),t[4]=n):n=t[4],n}if(n.length===0){let e;if(t[5]!==p||t[6]!==f||t[7]!==r){let n=r.trim();e=f??p(n?{id:`9R7pRC`,values:{trimmed:n}}:{id:`KRJ6xh`}),t[5]=p,t[6]=f,t[7]=r,t[8]=e}else e=t[8];let n=e,i;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[9]=i):i=t[9];let a;return t[10]===n?a=t[11]:(a=(0,X.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:y,children:n}),t[10]=n,t[11]=a),a}let b=a>=0&&a<n.length?n[a]:null,x;t[12]===p?x=t[13]:(x=p({id:`SCoBBH`}),t[12]=p,t[13]=x);let S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[14]=S):S=t[14];let C;t[15]===b?C=t[16]:(C=b?Ky(b):``,t[15]=b,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[17]=C,t[18]=w);let T;t[19]===f?T=t[20]:(T=f&&(0,X.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:f}),t[19]=f,t[20]=T);let E;if(t[21]!==n||t[22]!==h||t[23]!==c||t[24]!==s||t[25]!==a){let e;t[27]!==h||t[28]!==c||t[29]!==s||t[30]!==a?(e=(e,t)=>{let n=t===a,r=Gy(e),i=e.kind===`create`;return(0,X.jsxs)(`button`,{id:`${h}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":i?`tag-suggestion-create`:`tag-suggestion-tag-${e.value}`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),s(e)},onPointerMove:c?()=>c(t):void 0,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,X.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),i?(0,X.jsx)(`span`,{className:`shrink-0 rounded-sm bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`,children:(0,X.jsx)(o,{id:`isRobC`})}):(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[27]=h,t[28]=c,t[29]=s,t[30]=a,t[31]=e):e=t[31],E=n.map(e),t[21]=n,t[22]=h,t[23]=c,t[24]=s,t[25]=a,t[26]=E}else E=t[26];let D;return t[32]!==g||t[33]!==E||t[34]!==x||t[35]!==w||t[36]!==T?(D=(0,X.jsxs)(`div`,{ref:m,role:`listbox`,"aria-label":x,"aria-activedescendant":g,tabIndex:-1,onMouseDown:y,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:S,children:[w,T,E]}),t[32]=g,t[33]=E,t[34]=x,t[35]=w,t[36]=T,t[37]=D):D=t[37],D}function Jy(e){return e.preventDefault()}var Yy=new WeakMap;function Xy(e,t){Yy.set(e,t)}function Zy(e){return Yy.get(e)??!1}function Qy(e,t){let n=document.createElement(`div`);n.style.position=`fixed`,n.style.zIndex=`50`,n.style.visibility=`hidden`,document.body.appendChild(n);let r={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},i=!1,a=!1,o=()=>{n.isConnected&&(n.style.removeProperty(`--suggestion-menu-max-height`),we(r,n,{placement:`bottom-start`,middleware:[zt(4),Oe(),ee({padding:8}),Pe({apply({availableHeight:e}){n.isConnected&&n.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(e,window.innerHeight*.4)}px`)}})]}).then(({x:e,y:t})=>{n.isConnected&&(n.style.left=`${e}px`,n.style.top=`${t}px`,i&&!a&&(n.style.removeProperty(`visibility`),a=!0))}).catch(e=>{n.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:n,doPosition:o,startAutoUpdate:()=>k(r,n,o),reveal:()=>{a||(i=!0,o())}}}function $y(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var eb=new G(`tagSuggestion`),tb=8,nb=/^[a-zA-Z][\w/-]*$/;async function rb(){let e=await fetch(`/api/tags`);if(!e.ok)throw Error(`/api/tags responded with ${e.status}`);let t=await e.json();return Array.isArray(t.tags)?t.tags:[]}function ib(e,t){let n=t.trim(),r=n.toLowerCase(),i=n===``?e.slice():e.filter(e=>e.name.toLowerCase().includes(r));return i.sort((e,t)=>{let n=+!e.name.toLowerCase().startsWith(r),i=+!t.name.toLowerCase().startsWith(r);return n===i?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:n-i}),i}function ab(e,t){let n=ib(e,t).slice(0,tb).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&nb.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function ob(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``).match(/(^|[\s])#([a-zA-Z][\w/-]*)?$/);if(!n)return null;let r=n[2]??``,i=t.start(),a=n[1].length;return{range:{from:i+((n.index??0)+a),to:t.pos},query:r,text:`#${r}`}}function sb(e){let t=[],n=!1,r=null,i=null;return Wy({editor:e,pluginKey:eb,char:`#`,allowedPrefixes:null,findSuggestionMatch:ob,allow:({editor:e})=>!Zy(e),items:async({query:e})=>{if(!n){r||=rb();try{t=await r,i=null}catch(e){console.error(`[tag-suggestion] Failed to fetch tags:`,e),i=`Failed to load tags. Press Escape and type # again to retry, or continue typing to create a new tag.`,t=[]}finally{n=!0,r=null}}return ab(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!nb.test(r))return;e.chain().focus().deleteRange(t).insertContent({type:`tag`,attrs:{value:r}}).insertContent(` `).run()}catch(e){console.error(`[tag-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,a=null,o=0,s={popup:null,stopAutoUpdate:null},c=null,l=null,u=e=>{a?.command(e)},d=e=>{o!==e&&(o=e,p(null))};function f(e,t,r){let a=t===null?!n:t;return{items:e.items,query:e.query??``,selectedIndex:o,onSelect:r,onHover:d,loading:a,error:i}}let p=t=>{!e||!a||e.updateProps(f(a,t,u))};return{onBeforeStart(t){a=t,o=0;let n=Qy(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new Zl(qy,{props:f(t,!0,u),editor:t.editor}),n.popup.appendChild(e.element),s.stopAutoUpdate=n.startAutoUpdate()},onStart(e){a=e,o=0,p(null),l?.()},onUpdate(e){a=e,o=Math.min(o,Math.max(0,e.items.length-1)),p(null),c?.()},onKeyDown({event:e}){if(!a)return!1;let t=a.items;if(e.key===`ArrowDown`)return t.length===0?!1:(o=(o+1)%t.length,p(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(o=(o-1+t.length)%t.length,p(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[o];if(e)return a.command(e),!0;let n=(a.query??``).trim();return n&&nb.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){$y(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var cb=1,lb=.9,ub=.8,db=.17,fb=.1,pb=.999,mb=.9999,hb=.99,gb=/[\\\/_+.#"@\[\(\{&]/,_b=/[\\\/_+.#"@\[\(\{&]/g,vb=/[\s-]/,yb=/[\s-]/g;function bb(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?cb:hb;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=bb(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=cb:gb.test(e.charAt(l-1))?(d*=ub,p=e.slice(i,l-1).match(_b),p&&i>0&&(d*=pb**+p.length)):vb.test(e.charAt(l-1))?(d*=lb,m=e.slice(i,l-1).match(yb),m&&i>0&&(d*=pb**+m.length)):(d*=db,i>0&&(d*=pb**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=mb)),(d<fb&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=bb(e,t,n,r,l+1,a+2,o),f*fb>d&&(d=f*fb)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function xb(e){return e.toLowerCase().replace(yb,` `)}function Sb(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,bb(e,t,xb(e),xb(t),0,0,{})}var Cb=`[cmdk-group=""]`,wb=`[cmdk-group-items=""]`,Tb=`[cmdk-group-heading=""]`,Eb=`[cmdk-item=""]`,Db=`${Eb}:not([aria-disabled="true"])`,Ob=`cmdk-item-select`,kb=`data-value`,Ab=(e,t,n)=>Sb(e,t,n),jb=Y.createContext(void 0),Mb=()=>Y.useContext(jb),Nb=Y.createContext(void 0),Pb=()=>Y.useContext(Nb),Fb=Y.createContext(void 0),Ib=Y.forwardRef((e,t)=>{let n=Xb(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Xb(()=>new Set),i=Xb(()=>new Map),a=Xb(()=>new Map),o=Xb(()=>new Set),s=Jb(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Mn(),y=Mn(),b=Mn(),x=Y.useRef(null),S=$b();Yb(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Yb(()=>{S(6,k)},[]);let C=Y.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Y.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Ab;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(wb);t?t.appendChild(e.parentElement===t?e:e.closest(`${wb} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${wb} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Cb}[${kb}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(kb);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Cb)?.querySelector(Tb))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Eb}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Db)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(kb))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(kb))}function P(e){let t=A()?.closest(Cb),n;for(;t&&!n;)t=e>0?Kb(t,Cb):qb(t,Cb),n=t?.querySelector(Db);n?C.setState(`value`,n.getAttribute(kb)):N(e)}let F=()=>M(j().length-1),ee=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},I=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Y.createElement(On.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ee(e);break;case`ArrowDown`:ee(e);break;case`p`:case`k`:g&&e.ctrlKey&&I(e);break;case`ArrowUp`:I(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Ob);t.dispatchEvent(e)}}}}},Y.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:nx},c),tx(e,e=>Y.createElement(Nb.Provider,{value:C},Y.createElement(jb.Provider,{value:w},e))))}),Lb=Y.forwardRef((e,t)=>{let n=Mn(),r=Y.useRef(null),i=Y.useContext(Fb),a=Mb(),o=Jb(e),s=o.current?.forceMount??i?.forceMount;Yb(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Qb(n,r,[e.value,e.children,r],e.keywords),l=Pb(),u=Zb(e=>e.value&&e.value===c.current),d=Zb(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Y.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Ob,f),()=>t.removeEventListener(Ob,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Y.createElement(On.div,{ref:Ln(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Rb=Y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Mn(),s=Y.useRef(null),c=Y.useRef(null),l=Mn(),u=Mb(),d=Zb(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);Yb(()=>u.group(o),[]),Qb(o,s,[e.value,e.heading,c]);let f=Y.useMemo(()=>({id:o,forceMount:i}),[i]);return Y.createElement(On.div,{ref:Ln(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Y.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),tx(e,e=>Y.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Y.createElement(Fb.Provider,{value:f},e))))}),zb=Y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Y.useRef(null),a=Zb(e=>!e.search);return!n&&!a?null:Y.createElement(On.div,{ref:Ln(i,t),...r,"cmdk-separator":``,role:`separator`})}),Bb=Y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Pb(),o=Zb(e=>e.search),s=Zb(e=>e.selectedItemId),c=Mb();return Y.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Y.createElement(On.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Vb=Y.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Y.useRef(null),o=Y.useRef(null),s=Zb(e=>e.selectedItemId),c=Mb();return Y.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Y.createElement(On.div,{ref:Ln(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},tx(e,e=>Y.createElement(`div`,{ref:Ln(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Hb=Y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Y.createElement(Xn,{open:n,onOpenChange:r},Y.createElement(Hn,{container:o},Y.createElement(Vn,{"cmdk-overlay":``,className:i}),Y.createElement(er,{"aria-label":e.label,"cmdk-dialog":``,className:a},Y.createElement(Ib,{ref:t,...s}))))}),Ub=Y.forwardRef((e,t)=>Zb(e=>e.filtered.count===0)?Y.createElement(On.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Wb=Y.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Y.createElement(On.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},tx(e,e=>Y.createElement(`div`,{"aria-hidden":!0},e)))}),Gb=Object.assign(Ib,{List:Vb,Item:Lb,Input:Bb,Group:Rb,Separator:zb,Dialog:Hb,Empty:Ub,Loading:Wb});function Kb(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function qb(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Jb(e){let t=Y.useRef(e);return Yb(()=>{t.current=e}),t}var Yb=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function Xb(e){let t=Y.useRef();return t.current===void 0&&(t.current=e()),t}function Zb(e){let t=Pb(),n=()=>e(t.snapshot());return Y.useSyncExternalStore(t.subscribe,n,n)}function Qb(e,t,n,r=[]){let i=Y.useRef(),a=Mb();return Yb(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(kb,s),i.current=s}),i}var $b=()=>{let[e,t]=Y.useState(),n=Xb(()=>new Map);return Yb(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function ex(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function tx({asChild:e,children:t},n){return e&&Y.isValidElement(t)?Y.cloneElement(ex(t),{ref:t.ref},n(t.props.children)):n(t)}var nx={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function rx(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Gb,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ix(e){let t=(0,J.c)(34),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({title:o,description:s,children:n,className:r,showCloseButton:c,commandProps:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?`Command Palette`:o,u=s===void 0?`Search for a command to run`:s,d=c===void 0?!0:c,f;t[8]===i?f=t[9]:(f=i??{},t[8]=i,t[9]=f);let p,m;t[10]===f?(p=t[11],m=t[12]):({className:p,...m}=f,t[10]=f,t[11]=p,t[12]=m);let h;t[13]===r?h=t[14]:(h=yn(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[13]=r,t[14]=h);let g;t[15]===l?g=t[16]:(g=(0,X.jsx)(Bn,{className:`sr-only`,children:l}),t[15]=l,t[16]=g);let _;t[17]===u?_=t[18]:(_=(0,X.jsx)(zn,{className:`sr-only`,children:u}),t[17]=u,t[18]=_);let v;t[19]===p?v=t[20]:(v=yn(`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,p),t[19]=p,t[20]=v);let y;t[21]!==n||t[22]!==m||t[23]!==v?(y=(0,X.jsx)(rx,{className:v,...m,children:n}),t[21]=n,t[22]=m,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==y?(b=(0,X.jsxs)(Gn,{className:h,showCloseButton:d,children:[g,_,y]}),t[25]=d,t[26]=h,t[27]=g,t[28]=_,t[29]=y,t[30]=b):b=t[30];let x;return t[31]!==a||t[32]!==b?(x=(0,X.jsx)($n,{...a,children:b}),t[31]=a,t[32]=b,t[33]=x):x=t[33],x}function ax(e){let t=(0,J.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(Oa,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=yn(`flex w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a?(o=(0,X.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-2 border-b px-3`,children:[i,(0,X.jsx)(Gb.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function ox(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Gb.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function sx(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(Gb.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function cx(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-mono [&_[cmdk-group-heading]]:uppercase **:[[cmdk-group-heading]]:tracking-wider`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Gb.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function lx(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Gb.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ux(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`ml-auto text-muted-foreground text-xs tracking-widest`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`span`,{"data-slot":`command-shortcut`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function dx(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}if(e.ok)return r!==void 0&&console.warn(`[parse-server-response] 2xx response with non-JSON body:`,r instanceof Error?r.message:String(r)),{ok:!0,body:r===void 0?n:null};if(r!==void 0){let t=r instanceof Error?r.message:String(r);return{ok:!1,title:`Server error (HTTP ${e.status}): ${t}`}}return{ok:!1,title:l(n)??t}}function fx(e,t,n,r){let i=e.safeParse(t);return i.success?i.data:(console.warn(`[parse-server-response] schema drift:`,n,`bodyShape=`,typeof t==`object`&&t?Object.keys(t):typeof t,`issues=`,i.error.issues),r)}var px=new Map,mx=null;function hx(){return Sc(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function gx(){if(mx!==null)return;let e=Math.max(50,Math.floor(hx()/2));mx=setTimeout(()=>{mx=null,_x(Date.now()),px.size>0&&gx()},e)}function _x(e){let t=hx();for(let[n,r]of px)e-r.emittedAt>=t&&(px.delete(n),Z.count(`ok/sidebar/prewarm`,{hit:!1}))}function vx(e,t,n=Date.now()){px.has(e)&&Z.count(`ok/sidebar/prewarm`,{hit:!1}),px.set(e,{poolEventId:t,emittedAt:n}),gx()}function yx(e,t,n=Date.now()){let r=px.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=hx()?!1:(px.delete(e),Z(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),Z.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}E({event:ue(`ok-branch-switched-clear-failed`),branch:F(),docName:F(),reason:F()});async function bx(e,t){let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}function xx(e){let t=!1;return()=>{t?e():t=!0}}function Sx(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Cx(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=Wt.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&bx(e,i.data.currentBranch),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Sx(n)}catch{}e.observeDiskAckBatch(t)}}async function wx(e){let t;try{t=await fetch(`/api/config`,{signal:e,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return{status:`error`,code:`network`}}if(t.status===404||t.status===501)return{status:`absent`};if(!t.ok)return{status:`error`,code:t.status};let n;try{n=await t.json()}catch{return{status:`error`,code:`invalid-body`}}if(typeof n!=`object`||!n||Array.isArray(n))return{status:`error`,code:`invalid-body`};let r=n;return{status:`ok`,config:{collabUrl:typeof r.collabUrl==`string`?r.collabUrl:null,previewUrl:typeof r.previewUrl==`string`?r.previewUrl:null,port:typeof r.port==`number`?r.port:0}}}function Tx(e){return Nx(e,nn)}function Ex(e){return Nx(e,ct)}function Dx(e){return Nx(e,Yt)}function Ox(e){return Nx(e,Et)}function kx(e){return Nx(e,$e)}function Ax(e){let t=Nx(e,rt);if(!t)return null;try{return{docName:t.docName,sv:jx(t.sv)}}catch{return null}}function jx(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Mx(e,t){let n=Ex(e);if(n){t.onServerInfo?.(n);return}let r=Dx(e);if(r){t.onBranchSwitched?.(r);return}let i=Ax(e);if(i){t.onDiskAck?.(i);return}let a=Tx(e);if(a){t.onDerivedView?.(a);return}let o=Ox(e);if(o){t.onConfigValidationRejected?.(o);return}let s=kx(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function Nx(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function Px(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function Fx(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function Ix(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var Lx=2e3,Rx=15e3;function zx(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??Lx,r=e.maxDelayMs??Rx,i=e.log??{info:console.info,warn:console.warn},a=new AbortController,o=null,s=n,c=0,l=!1,u=!1,d=null,f=e.now(),p=async()=>{c+=1;let n=null;try{let t=await e.fetchConfig(a.signal);t.status===`absent`?(n=e.fallbackUrl(),d=null):t.status===`ok`&&t.config.collabUrl!==null?(n=t.config.collabUrl,d=null):t.status===`ok`?(u||(u=!0,i.info(`[collab-url] ok ui responded but server.lock has no port yet — retrying`)),d={kind:`null-collab`}):t.status===`error`&&(i.warn(`[collab-url] /api/config error (${t.code}) — retrying in ${s}ms`),d={kind:`error`,code:t.code})}catch(e){if(e.name===`AbortError`)return;d={kind:`error`,code:`network`}}if(!l){if(n!==null){e.onStateChange({collabUrl:n,attempts:c,terminal:!1,lastError:null});return}if(e.now()-f>=t){e.onStateChange({collabUrl:null,attempts:c,terminal:!0,lastError:d});return}e.onStateChange({collabUrl:null,attempts:c,terminal:!1,lastError:d}),o=e.setTimeout(()=>{p()},s),s=Math.min(s*2,r)}};return p(),{cancel:()=>{l=!0,a.abort(),o!==null&&(e.clearTimeout(o),o=null)}}}function Bx(){let e=(0,J.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Y.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Y.useRef)(i),[o,s]=(0,Y.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=Fx(window);if(t){r(Ix(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(Ix(t))});return()=>{n()}}let n=zx({fetchConfig:wx,fallbackUrl:Px,now:Date.now,setTimeout:Wx,clearTimeout:Ux,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,Y.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(Hx),s(Vx)},e[5]=u):u=e[5];let d=u,f;return e[6]===n?f=e[7]:(f={...n,retry:d},e[6]=n,e[7]=f),f}function Vx(e){return e+1}function Hx(e){return{...e,terminal:!1,lastError:null}}function Ux(e){return globalThis.clearTimeout(e)}function Wx(e,t){return globalThis.setTimeout(e,t)}var Gx=new Map,Kx=new Set;function qx(){for(let e of Kx)e()}function Jx(e,t){Gx.set(e,t),qx()}function Yx(e,t){Gx.get(e)===t&&(Gx.delete(e),qx())}function Xx(e){return Gx.get(e)??null}function Zx(e){return Kx.add(e),()=>Kx.delete(e)}var Qx=new Map;function $x(e){return Qx.get(e)}function eS(e,t){Qx.set(e,t)}function tS(e){Qx.delete(e)}var nS=`open-knowledge-app`,rS=new Map,iS=new Set,aS=1024,oS=1024;function sS(){return cr.getTracer(nS)}function cS(e,t,n){if(iS.has(e))return null;let r=rS.get(e);if(r)return r;if(rS.size>=oS){let e=rS.keys().next().value;if(e!==void 0){let t=rS.get(e);rS.delete(e);try{t?.span.end()}catch(e){console.warn(`[otel-spans] eviction span.end failed:`,e instanceof Error?e:String(e))}}}let i={span:sS().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return rS.set(e,i),i}function lS(e,t,n,r,i){try{let a=cS(e,n,r),o=a?cr.setSpan(lr.active(),a.span):lr.active();sS().startSpan(t,{attributes:{"mount.id":e,...n},startTime:r},o).end(i??Date.now())}catch(e){console.warn(`[otel-spans] emitColdMountChild failed:`,e instanceof Error?e:String(e))}}function uS(e,t){try{let n=rS.get(e);if(n&&(rS.delete(e),n.span.end(t??Date.now())),!iS.has(e)){if(iS.size>=aS){let e=iS.values().next().value;e!==void 0&&iS.delete(e)}iS.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var dS=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function fS(){return Sc(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function pS(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function mS(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;Z(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var hS=new Map,gS=new Set;function _S(e){gS.add(e);for(let[t,n]of hS)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{gS.delete(e)}}function vS(e,t){for(let n of gS)try{n(e,t.mountId)}catch{}}var yS=!1;function bS(){typeof document>`u`||document.visibilityState===`visible`&&CS(Date.now())}function xS(){yS||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,bS),yS=!0)}function SS(){yS&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,bS),yS=!1))}function CS(e){let t=fS();for(let[n,r]of hS)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(mS(r,n,e),vS(n,r))}function wS(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=hS.get(t);if(a)return a.promise;let o=new AbortController,s=Date.now(),c=()=>{},l=()=>{},u=new Promise((e,t)=>{c=e,l=t}),d={promise:u,rejectFn:l,controller:o,mountId:n,createdAt:s,settled:!1,resolved:!1,preMountEditor:null,stalledHandle:null,stalledMarkEmitted:!1};return d.stalledHandle=setTimeout(()=>{d.settled||(mS(d,t,Date.now()),vS(t,d))},fS()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,pS(d),d.preMountEditor&&=(OS(t,d.preMountEditor,`aborted`),null),hS.delete(t),hS.size===0&&SS(),Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new dS(t)),uS(d.mountId))}),hS.set(t,d),xS(),Z(`ok/mount/create`,{docName:t,mountId:d.mountId}),kS({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(OS(t,d.preMountEditor,`backstop`),null),d.settled){Z(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,pS(d);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`}),l(n),uS(d.mountId)}),u}function TS(e){return hS.get(e)?.resolved===!0}function ES(e){return hS.get(e)?.controller??null}function DS(e){let t=hS.get(e);t&&(t.settled=!0,pS(t),t.preMountEditor&&=(OS(e,t.preMountEditor,`aborted`),null),hS.delete(e),hS.size===0&&SS(),Z(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),uS(t.mountId),t.controller.abort())}function OS(e,t,n){let r=AS(t);try{t.destroy()}catch(t){Z(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function kS(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(uC(t)!==void 0){let e=JS({docName:t,container:s,factory:()=>{throw Error(`mount-promise: V2 cache contract violation — factory invoked on HIT for "${t}"`)}});i.settled=!0,i.resolved=!0,pS(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,pS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`}),o(n),uS(i.mountId);return}if(i.preMountEditor=c.editor,await scheduler.yield(),i.controller.signal.aborted){i.preMountEditor=null;return}try{c.editor.mount(s)}catch(e){OS(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,pS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`}),o(n),uS(i.mountId);return}let l;try{l=JS({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){OS(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,pS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`}),o(n),uS(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,pS(i);let u=Date.now()-i.createdAt;Z(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),Z.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();lS(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),uS(i.mountId,d)}function AS(e){try{let t=e.state;return Bv.getState(t)?.undoManager??null}catch(e){return Z(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var jS=Sc(`MAX_CACHE`,10),MS=Sc(`VIEW_COUNT_CACHE_THRESHOLD`,50),NS=Sc(`BYTES_CACHE_THRESHOLD`,8e6);function PS(e){return!(e.viewCount>0&&e.viewCount>=MS||e.bytes>NS)}var FS=new Map,IS=new Map,LS=new Map;function RS(e,t){if(LS.size>=jS){let e=LS.keys().next().value;e!==void 0&&LS.delete(e)}LS.set(e,t),Z(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function zS(e){return LS.get(e)??null}function BS(e){if(!LS.has(e))return;let t=LS.get(e)??null;LS.delete(e),Z(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function VS(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return Z(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function HS(e){try{let t=e.state.selection;return t instanceof xe?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof Ke?{type:`node`,from:t.from}:null}catch(e){return Z(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function US(e){for(let t of e)try{let e=uC(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){Z(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}RS(t.toDocName,{html:e.editor.getHTML(),scrollTop:VS(),selection:HS(e.editor)})}else Z(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){Z(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var WS=[],GS=[],KS=new Set;function qS(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,e}function JS(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!PS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:$x(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=FS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:$x(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),nC(a,n),a.activeMountKey=t,iC(WS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:$x(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:$x(t),kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:$x(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;FS.size>=jS;){let e=aC(WS,t);if(!e)break;XS(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return FS.set(t,s),iC(WS,t),Z(`ok/cache/miss`,{docName:t,mountId:$x(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:$x(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function YS(e){let t=e.activeMountKey;if(e.__uncached){t&&DS(t);let n=AS(e.editor);try{e.editor.destroy()}catch(e){Z(`ok/cache/park-destroy-failed`,{docName:t??``,kind:`tiptap`,message:e instanceof Error?e.message:String(e)})}n&&(n.restore=void 0),e.activeMountKey=null;return}let n=eC(e.editor);if(n){e.hadFocus=tC(n.dom),e.scrollTop=(n.scrollDOM??n.dom.parentElement??n.dom).scrollTop??0;let t=n.dom.parentElement;t&&t.removeChild(n.dom),e.parkingNode||=qS(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function XS(e){DS(e);let t=FS.get(e);if(!t)return!1;let n=AS(t.editor);try{t.editor.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}FS.delete(e);let r=WS.indexOf(e);return r!==-1&&WS.splice(r,1),Z(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function ZS(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!PS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:$x(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=IS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:$x(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),rC(a,n),a.activeMountKey=t,iC(GS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:$x(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:$x(t),kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:$x(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;IS.size>=jS;){let e=aC(GS,t);if(!e)break;$S(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return IS.set(t,s),iC(GS,t),Z(`ok/cache/miss`,{docName:t,mountId:$x(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:$x(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function QS(e){if(e.__uncached){try{e.view.destroy()}catch(t){Z(`ok/cache/park-destroy-failed`,{docName:e.activeMountKey??``,kind:`cm`,message:t instanceof Error?t.message:String(t)})}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=tC(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=qS(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function $S(e){let t=IS.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}IS.delete(e);let n=GS.indexOf(e);return n!==-1&&GS.splice(n,1),Z(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function eC(e){return e.editorView??null}function tC(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function nC(e,t){let n=eC(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function rC(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function iC(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function aC(e,t){for(let n of e)if(n!==t&&!KS.has(n))return n;Z(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:KS.size});for(let n of e)if(n!==t)return n;return null}function oC(e){let t=KS,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=cC(e);if(t)try{t.disconnect(),Z(`ok/cache/disconnect`,{docName:e})}catch(t){Z(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=cC(e);if(!n)continue;let r=t=>{Z(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>Z(`ok/cache/connect`,{docName:e}),e=>r(e)):Z(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}KS=n}var sC=null;function cC(e){let t=FS.get(e);if(t)return t.provider;let n=IS.get(e);if(n)return n.provider;if(sC){let t=sC.entries.get(e);if(t)return t.provider}return null}function lC(e){sC=e;let t=e.onEvict(e=>{XS(e),$S(e)});return()=>{t(),sC===e&&(sC=null)}}function uC(e){return FS.get(e)}var dC=`ok-editor-tabs-v1:`,fC=`\0folder:`,pC=`\0asset:`,mC=`\0doc-tab:`;function hC(e){let t=e.lastIndexOf(mC);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function gC(e){return hC(e).baseTabId}function _C(e){if(typeof e!=`string`||e.length===0)return!1;let t=gC(e);return t.startsWith(fC)?t.length>8:t.startsWith(pC)?t.length>7:!0}function vC(e){return e}function yC(e,t){return`${gC(e)}${mC}${t}`}function bC(e,t){return xC(e,vC(t))}function xC(e,t){let n=AC(e,2**53-1),r=gC(t);if(!n.includes(r))return r;let i=1,a;do a=yC(r,i),i++;while(n.includes(a));return a}function SC(e,t){let n=gC(t);return AC(e,2**53-1).find(e=>gC(e)===n)??null}function CC(e,t){return gC(e)===gC(t)}function wC(e){return`${fC}${e}`}function TC(e){return`${pC}${e}`}function EC(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function DC(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return vC(e.docName);case`folder`:return wC(e.folderPath);case`missing`:return vC(e.target);case`asset`:return TC(e.assetPath)}}function OC(e){let t=gC(e);return t.startsWith(fC)?{kind:`folder`,folderPath:t.slice(8)}:t.startsWith(pC)?{kind:`asset`,assetPath:t.slice(7)}:{kind:`doc`,docName:t}}function kC(e){let t=OC(e);return t.kind===`doc`?t.docName:null}function AC(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(_C(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function jC(e,t){let n=new Set(AC(t,2**53-1));return AC(e,2**53-1).filter(e=>n.has(e))}function MC(e,t,n){if(t<=0)return[];let r=new Set(AC(n,2**53-1)),i=AC(e,2**53-1);if(r.size===0&&i.length<=t)return i;let a=[],o=0;for(let e=i.length-1;e>=0;e--){let n=i[e];if(r.has(n)){a.push(n);continue}o>=t||(o++,a.push(n))}return a.reverse()}function NC(e,t,n){let r=jC(e,n);return!AC(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function PC(e,t){return AC(e,2**53-1).filter(e=>e!==t)}function FC(e,t){let n=new Set(AC(t,2**53-1));return AC(e,2**53-1).filter(e=>!n.has(e))}function IC(e,t,n){let r=AC(e,2**53-1),i=jC(t,r),a=r.indexOf(n);if(a<0)return i;let o=i.includes(n),s=a<i.length;return o===s?i:s?NC(i,n,r):PC(i,n)}function LC(e,t,n,r=[]){let i=MC(e,n,r);return!_C(t)||i.includes(t)?i:MC([...i,t],n,r)}function RC(e,t,n,r,i=[]){let a=MC(e,r,i);if(!_C(n))return a;if(!t||t===n)return LC(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return LC(o,n,r,i);let c=[...o];return c[s]=n,MC(c,r,i)}function zC(e,t,n){return BC(e,vC(t),n)}function BC(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=MC(e,i,a),s=gC(t);if(r&&o.includes(r)&&gC(r)===s)return{tabs:o,activeTabId:r};if(n!==`replace-active`)return{tabs:LC(o,s,i,a),activeTabId:s};let c=SC(o,s);if(c)return{tabs:o,activeTabId:c};let l=xC(o,s);return{tabs:RC(o,r,l,i,a),activeTabId:l}}function VC(e,t){return e.filter(e=>e!==t)}function HC(e,t,n){let r=AC(t,2**53-1),i=new Set(r),a=new Set(n),o=new Set,s=[];for(let t of e)o.has(t)||!i.has(t)&&!a.has(t)||(o.add(t),s.push(t));for(let e of[...r,...n])o.has(e)||(o.add(e),s.push(e));return s}function UC(e,{pages:t,folderPaths:n,assetPaths:r,keepMissingDocName:i=null}){return AC(e,2**53-1).filter(e=>{let a=OC(e);return a.kind===`folder`?n.has(a.folderPath):a.kind===`asset`?r.has(a.assetPath):t.has(a.docName)||a.docName===i})}function WC(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return AC(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=e=>qC(KC(e,r),a),c=[],l=new Set;for(let t of e){let{instanceSuffix:e}=hC(t),a=OC(t),u=`${a.kind===`doc`?o.get(a.docName)??gC(t):a.kind===`folder`?wC(KC(a.folderPath,r)):TC(s(a.assetPath))}${e}`;if(!l.has(u)&&(l.add(u),c.push(u),i.length===0&&c.length>=n))break}return i.length===0?c:MC(c,n,i.map(e=>{let t=OC(e);return t.kind===`doc`?o.get(t.docName)??e:t.kind===`folder`?wC(KC(t.folderPath,r)):TC(s(t.assetPath))}))}function GC(e,t,n=[],r=[]){return WC(e,t,2**53-1,n,[],r)}function KC(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function qC(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function JC(e,t,n){if(t!==n)return t;let r=e.indexOf(n);return r<0?e[0]??null:e[r+1]??e[r-1]??null}function YC(e,t,n){if(!t)return null;let r=new Set(n);if(!r.has(t))return t;let i=e.indexOf(t);if(i<0)return e.find(e=>!r.has(e))??null;for(let t=i+1;t<e.length;t++)if(!r.has(e[t]))return e[t];for(let t=i-1;t>=0;t--)if(!r.has(e[t]))return e[t];return null}function XC(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=AC(n.openTabs,2**53-1),i=jC(n.pinnedTabIds,r),a=i.length===0?AC(n.openTabs,t):MC(r,t,i),o=jC(n.pinnedTabIds,a),s=typeof n.activeTabId==`string`&&a.includes(n.activeTabId)?n.activeTabId:typeof n.activeDocName==`string`&&a.includes(n.activeDocName)?n.activeDocName:null,c=s?OC(s):null;return{openTabs:a,pinnedTabIds:o,activeDocName:c?.kind===`doc`?c.docName:null,activeTabId:s,updatedAt:typeof n.updatedAt==`string`?n.updatedAt:null}}function ZC(e,t,n=[],r=()=>new Date){let i=AC(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?OC(a):null;return{openTabs:i,pinnedTabIds:jC(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function QC(e){return`${dC}${e}`}function $C(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?XC(JSON.parse(r),n):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}catch(e){return console.warn(`[editor-tabs] failed to read local tab session:`,e),{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}}function ew(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch(e){console.warn(`[editor-tabs] failed to write local tab session:`,e)}}var tw=Math.floor,nw=(e,t)=>e<t?e:t,rw=(e,t)=>e>t?e:t;Number.isNaN;var iw=128,aw=1<<17,ow=1<<18,sw=1<<19,cw=1<<20,lw=1<<21,uw=1<<22,dw=1<<23,fw=1<<24,pw=1<<25,mw=1<<26,hw=1<<27,gw=1<<28,_w=1<<29,vw=1<<30,yw=127;aw-1,ow-1,sw-1,cw-1,lw-1,uw-1,dw-1,fw-1,pw-1,mw-1,hw-1,gw-1,_w-1,vw-1;var bw=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var xw=String.fromCharCode;String.fromCodePoint,xw(65535);var Sw=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Cw=typeof TextEncoder<`u`?new TextEncoder:null,ww=Cw?e=>Cw.encode(e):Sw,Tw=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Tw&&Tw.decode(new Uint8Array).length===1&&(Tw=null);var Ew=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Dw=(e,t)=>{for(;t>yw;)Ew(e,iw|yw&t),t=tw(t/128);Ew(e,yw&t)},Ow=new Uint8Array(3e4),kw=Ow.length/3,Aw=Cw&&Cw.encodeInto?(e,t)=>{if(t.length<kw){let n=Cw.encodeInto(t,Ow).written||0;Dw(e,n);for(let t=0;t<n;t++)Ew(e,Ow[t])}else Mw(e,ww(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Dw(e,r);for(let t=0;t<r;t++)Ew(e,n.codePointAt(t))},jw=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=nw(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(rw(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Mw=(e,t)=>{Dw(e,t.byteLength),jw(e,t)},Nw=e=>Error(e),Pw=Nw(`Unexpected end of array`),Fw=Nw(`Integer out of Range`),Iw=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Lw=e=>Iw(e,zw(e)),Rw=e=>e.arr[e.pos++],zw=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&yw)*n,n*=128,r<iw)return t;if(t>bw)throw Fw}throw Pw},Bw=Tw?e=>Tw.decode(Lw(e)):e=>{let t=zw(e);if(t===0)return``;{let n=String.fromCodePoint(Rw(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Rw(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Vw=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),Hw=(e,t)=>{Dw(e,Vw.Token),Aw(e,t)},Uw=(e,t,n,r)=>{switch(zw(e)){case Vw.Token:t();break;case Vw.PermissionDenied:n(Bw(e));break;case Vw.Authenticated:r(Bw(e));break;default:}},Ww=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),Gw=`\0`;function Kw(e,t){return e+Gw+t}function qw(e){let t=e.indexOf(Gw);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Jw=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function Yw(e){return 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 Xw(e){return new Promise(t=>setTimeout(t,e))}function Zw(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function Qw(e,t){let n=Yw(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Zw;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await Xw(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await Xw(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await Xw(e)}return a()}var $w=Math.floor,eT=(e,t)=>e<t?e:t,tT=(e,t)=>e>t?e:t;Number.isNaN;var nT=64,rT=128,iT=1<<17,aT=1<<18,oT=1<<19,sT=1<<20,cT=1<<21,lT=1<<22,uT=1<<23,dT=1<<24,fT=1<<25,pT=1<<26,mT=1<<27,hT=1<<28,gT=1<<29,_T=1<<30,vT=63,yT=127;iT-1,aT-1,oT-1,sT-1,cT-1,lT-1,uT-1,dT-1,fT-1,pT-1,mT-1,hT-1,gT-1,_T-1;var bT=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var xT=()=>new Set,ST=Array.from;Array.isArray;var CT=String.fromCharCode;String.fromCodePoint,CT(65535);var wT=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},TT=typeof TextEncoder<`u`?new TextEncoder:null,ET=TT?e=>TT.encode(e):wT,DT=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});DT&&DT.decode(new Uint8Array).length===1&&(DT=null);var OT=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},kT=()=>new OT,AT=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},jT=e=>{let t=new Uint8Array(AT(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},MT=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},NT=(e,t)=>{for(;t>yT;)MT(e,rT|yT&t),t=$w(t/128);MT(e,yT&t)},PT=new Uint8Array(3e4),FT=PT.length/3,IT=TT&&TT.encodeInto?(e,t)=>{if(t.length<FT){let n=TT.encodeInto(t,PT).written||0;NT(e,n);for(let t=0;t<n;t++)MT(e,PT[t])}else RT(e,ET(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;NT(e,r);for(let t=0;t<r;t++)MT(e,n.codePointAt(t))},LT=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=eT(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(tT(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},RT=(e,t)=>{NT(e,t.byteLength),LT(e,t)},zT=e=>Error(e),BT=zT(`Unexpected end of array`),VT=zT(`Integer out of Range`),HT=class{constructor(e){this.arr=e,this.pos=0}},UT=e=>new HT(e),WT=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},GT=e=>WT(e,qT(e)),KT=e=>e.arr[e.pos++],qT=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&yT)*n,n*=128,r<rT)return t;if(t>bT)throw VT}throw BT},JT=e=>{let t=e.arr[e.pos++],n=t&vT,r=64,i=(t&nT)>0?-1:1;if((t&rT)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&yT)*r,r*=128,t<rT)return i*n;if(n>bT)throw VT}throw BT},YT=DT?e=>DT.decode(GT(e)):e=>{let t=qT(e);if(t===0)return``;{let n=String.fromCodePoint(KT(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(KT(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},XT=e=>{let t=e.pos,n=YT(e);return e.pos=t,n},ZT=Date.now,QT=()=>new Map,$T=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},eE=class{constructor(){this._observers=QT()}on(e,t){$T(this._observers,e,xT).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return ST((this._observers.get(e)||QT()).values()).forEach(e=>e(...t))}destroy(){this._observers=QT()}},tE=Symbol(`Equality`),nE=Object.keys,rE=e=>nE(e).length,iE=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),aE=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[tE]!=null)return e[tE](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!aE(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(rE(e)!==rE(t))return!1;for(let n in e)if(!iE(e,n)||!aE(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!aE(e[n],t[n]))return!1;break;default:return!1}return!0},oE=3e4,sE=class extends eE{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=ZT();this.getLocalState()!==null&&oE/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&oE<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&cE(this,t,`timeout`)},$w(oE/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){let 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:ZT()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),aE(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},cE=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:ZT()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},lE=(e,t,n=e.states)=>{let r=t.length,i=kT();NT(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;NT(i,r),NT(i,s),IT(i,JSON.stringify(o))}return jT(i)},uE=(e,t,n)=>{let r=UT(t),i=ZT(),a=[],o=[],s=[],c=[],l=qT(r);for(let t=0;t<l;t++){let t=qT(r),n=qT(r),l=JSON.parse(YT(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(aE(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},dE=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},fE=class{constructor(e){this.data=e,this.encoder=kT(),this.decoder=UT(new Uint8Array(this.data))}peekVarString(){return XT(this.decoder)}readVarUint(){return qT(this.decoder)}readVarString(){return YT(this.decoder)}readVarUint8Array(){return GT(this.decoder)}writeVarUint(e){return NT(this.encoder,e)}writeVarString(e){return IT(this.encoder,e)}writeVarUint8Array(e){return RT(this.encoder,e)}length(){return AT(this.encoder)}},pE=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[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),mE=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),hE=class{constructor(){this.encoder=kT()}get(e){return e.encoder}toUint8Array(){return jT(this.encoder)}},gE=class extends hE{constructor(...e){super(...e),this.type=pE.CLOSE,this.description=`Ask the server to close the connection`}get(e){return IT(this.encoder,e.documentName),NT(this.encoder,this.type),this.encoder}},_E=class e extends dE{static{this.DEDUPLICATABLE_TYPES=new Set([pE.Awareness,pE.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,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,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=mE.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,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(`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),this.shouldConnect&&this.connect()}async onOpen(e){this.status=mE.Connected,this.emit(`status`,{status:mE.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===mE.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===mE.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(gE,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===mE.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:Qw(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,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{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;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=mE.Connecting,this.emit(`status`,{status:mE.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=ZT();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===pE.Ping){this.sendPong();return}let n=new fE(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=kT();NT(e,pE.Pong),this.send(jT(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=mE.Connected,this.emit(`status`,{status:mE.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===mE.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=ZT()-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(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=UT(e);return{documentName:YT(t),messageType:qT(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===Jw.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=mE.Disconnected,this.emit(`status`,{status:mE.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},vE=0,yE=1,bE=2,xE=(e,t)=>{NT(e,vE),RT(e,_h(t))},SE=(e,t,n)=>{NT(e,yE),RT(e,dh(t,n))},CE=(e,t,n)=>SE(t,n,GT(e)),wE=(e,t,n,r)=>{try{ch(t,GT(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},TE=(e,t)=>{NT(e,bE),RT(e,t)},EE=wE,DE=(e,t,n,r,i)=>{let a=qT(e);switch(a){case vE:CE(e,t,n);break;case yE:wE(e,n,r,i);break;case bE:EE(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},OE=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case pE.Sync:this.applySyncMessage(e,t);break;case pE.Awareness:this.applyAwarenessMessage(e);break;case pE.Auth:this.applyAuthMessage(e);break;case pE.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case pE.Stateless:e.receiveStateless(YT(n.decoder));break;case pE.SyncStatus:this.applySyncStatusMessage(e,JT(n.decoder)===1);break;case pE.CLOSE:let i={code:1e3,reason:YT(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(hE,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(pE.Sync);let r=DE(n.decoder,n.encoder,e.document,e);t&&r===yE&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;uE(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Uw(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(pE.Awareness),t.writeVarUint8Array(lE(e.awareness,Array.from(e.awareness.getStates().keys())))}},kE=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return jT(this.encoder)}send(e){e?.send(this.create())}},AE=`4.0.0-rc.1`,jE=class extends hE{constructor(...e){super(...e),this.type=pE.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return IT(this.encoder,e.documentName),NT(this.encoder,this.type),Hw(this.encoder,e.token),IT(this.encoder,AE),this.encoder}},ME=class extends hE{constructor(...e){super(...e),this.type=pE.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);IT(this.encoder,e.documentName),NT(this.encoder,this.type);let t;return t=e.states===void 0?lE(e.awareness,e.clients):lE(e.awareness,e.clients,e.states),RT(this.encoder,t),this.encoder}},NE=class extends hE{constructor(...e){super(...e),this.type=pE.Stateless,this.description=`A stateless message`}get(e){return IT(this.encoder,e.documentName),NT(this.encoder,this.type),IT(this.encoder,e.payload??``),this.encoder}},PE=class extends hE{constructor(...e){super(...e),this.type=pE.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return IT(this.encoder,e.documentName),NT(this.encoder,this.type),xE(this.encoder,e.document),this.encoder}},FE=class extends hE{constructor(...e){super(...e),this.type=pE.Sync,this.description=`A document update`}get(e){return IT(this.encoder,e.documentName),NT(this.encoder,this.type),TE(this.encoder,e.update),this.encoder}},IE=class extends Error{constructor(...e){super(...e),this.code=1001}},LE=class extends dE{get effectiveName(){return this.configuration.sessionAwareness?Kw(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Km,this.configuration.awareness=e.awareness===void 0?new sE(this.document):e.awareness,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(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:Ww(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Ww(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.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new _E(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(PE,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&cE(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(NE,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(jE,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(FE,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(ME,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(PE,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(ME,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new kE(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new fE(e.data),{documentName:n}=qw(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new fE(e.data)}),new OE(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&cE(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(cE(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.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),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(`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.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),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(`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.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new IE(`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)}},RE=e=>$d((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),zE=(e,t)=>$d((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Td(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),BE=e=>RE(indexedDB.deleteDatabase(e)),VE=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),HE=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>$E(r,e))},UE=(e,t)=>RE(e.count(t)),WE=(e,t)=>RE(e.get(t)),GE=(e,t)=>RE(e.delete(t)),KE=(e,t,n)=>RE(e.put(t,n)),qE=(e,t)=>RE(e.add(t)),JE=(e,t,n)=>RE(e.getAll(t,n)),YE=(e,t,n)=>{let r=null;return QE(e,t,e=>(r=e,!1),n).then(()=>r)},XE=(e,t=null)=>YE(e,t,`prev`),ZE=(e,t)=>$d((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),QE=(e,t,n,r=`next`)=>ZE(e.openKeyCursor(t,r),e=>n(e.key)),$E=(e,t)=>e.objectStore(t),eD=(e,t)=>IDBKeyRange.upperBound(e,t),tD=(e,t)=>IDBKeyRange.lowerBound(e,t),nD=`custom`,rD=`updates`,iD=(e,t=()=>{},n=()=>{})=>{let[r]=HE(e.db,[rD]);return JE(r,tD(e._dbref,!1)).then(i=>{e._destroyed||(t(r),sg(e.doc,()=>{i.forEach(t=>ch(e.doc,t))},e,!1),n(r))}).then(()=>XE(r).then(t=>{e._dbref=t+1})).then(()=>UE(r).then(t=>{e._dbsize=t})).then(()=>r)},aD=(e,t=!0)=>iD(e).then(n=>{(t||e._dbsize>=500)&&qE(n,dh(e.doc)).then(()=>GE(n,eD(e._dbref,!0))).then(()=>UE(n).then(t=>{e._dbsize=t}))}),oD=class extends vu{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=zE(e,e=>VE(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=$d(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,iD(this,async e=>{await UE(e)>0&&qE(e,dh(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=HE(this.db,[rD]);qE(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{aD(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{BE(this.name)})}get(e){return this._db.then(t=>{let[n]=HE(t,[nD],`readonly`);return WE(n,e)})}set(e,t){return this._db.then(n=>{let[r]=HE(n,[nD]);return KE(r,t,e)})}del(e){return this._db.then(t=>{let[n]=HE(t,[nD]);return GE(n,e)})}};function sD(){return!0}var cD=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`;let i=sD()?0:performance.now();this._idb=new oD(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!sD()){let e=performance.now();Z(`ok/pool/idb-whensynced`,{docName:n,durationMs:Math.round((e-i)*1e3)/1e3},{startTime:i,duration:e-i})}return this})}get synced(){return this._idb.synced}async destroy(){let e=sD()?0:performance.now();try{await this._idb.destroy()}finally{if(!sD()){let t=performance.now();Z(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async clearData(){let e=sD()?0:performance.now();try{await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e}))}})}finally{if(!sD()){let t=performance.now();Z(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function lD(e){return new cD(e)}function uD(e){return _h(e)}function dD(e,t){return t===null?dh(e):dh(e,t)}function fD(e,t){if(e===null)return t;if(t===null)return e;let n=ph(e),r=ph(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return _h(i)}function pD(e){let t={};if(ur.inject(lr.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,r=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&r.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${r.join(`&`)}`}var mD=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new ln({key:e||new G(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),hD=W.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[mD({key:new G(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function gD(e,t){let{state:n,view:r}=e;if(!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount!==0||!Ke.isSelectable(o))return!1;try{let t=Ke.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Pt(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function _D(e){let{state:t,view:n}=e;if(!(t.selection instanceof xe)||!t.selection.empty||!n.endOfTextblock(`up`))return!1;let r=t.selection.$head,i=-1;for(let e=r.depth-1;e>=1;e--)if(r.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;for(let e=r.depth;e>i;e--)if(r.index(e-1)!==0)return!1;let a=r.before(i);try{let n=t.doc.resolve(a),r=_.findFrom(n,-1,!0);return!r||!(r instanceof xe)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Pt(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}var vD=W.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof Ke){let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=xe.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof xe?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(gD(e,`up`)||_D(e))return!0;let{state:t}=e;if(!(t.selection instanceof Ke))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=Ke.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Pt(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowDown:({editor:e})=>{if(gD(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof Ke))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=Ke.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Pt(`down`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`down`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowLeft:({editor:e})=>gD(e,`left`),ArrowRight:({editor:e})=>gD(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof xe)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let s=t.tr,c=n.before(n.depth),l=n.after(n.depth);s.delete(c,l);let u=o-(l-c),d=t.schema.nodes.paragraph.create();s.insert(u,d);let f=u+1;return s.setSelection(xe.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),yD={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},bD=/[A-Za-z0-9_]/;function xD(e){return e!==void 0&&bD.test(e)}function SD(e,t,n){return!xD(e[t-1])&&!xD(e[n])}function CD(e,t,n){if(t.length===0)return[];let r=n.caseSensitive?e:e.toLocaleLowerCase(),i=n.caseSensitive?t:t.toLocaleLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let t=r.indexOf(i,o);if(t===-1)break;let s=t+i.length;(!n.wholeWord||SD(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function wD(e,t,n){if(t.length===0)return[];let r=[];return e.descendants((e,i)=>{if(!(!e.isText||typeof e.text!=`string`))for(let a of CD(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var TD=new G(`findReplace`);function ED(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function DD(e,t,n,r){let i=wD(e.doc,t,n);return{query:t,options:n,activeIndex:ED(r,i.length),matches:i}}function OD(e,t,n){return t<=0?0:(ED(e,t)+n+t)%t}function kD(e,t,n){if(e.length===0)return 0;let r=t+n,i=e.findIndex(e=>e.from>=r);return i===-1?0:i}function AD(e,t,n){if(t.matches.length===0)return null;let r=e.tr;for(let e of[...t.matches].reverse())r.insertText(n,e.from,e.to);let i=wD(r.doc,t.query,t.options),a=ED(0,i.length),o=i[a];return r.setMeta(TD,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(xe.create(r.doc,o.from,o.to)),r.scrollIntoView()}function jD(e,t){let n=TD.getState(e)?.matches[t];return n?e.tr.setMeta(TD,{type:`setActiveIndex`,activeIndex:t}).setSelection(xe.create(e.doc,n.from,n.to)).scrollIntoView():null}function MD(e){return TD.getState(e)??yD}function ND(){return new ln({key:TD,state:{init:()=>yD,apply(e,t,n,r){let i=e.getMeta(TD);if(i?.type===`clear`)return yD;let a=t.query,o=t.options,s=t.activeIndex;if(i?.type===`setQuery`)a=i.query,o={...o,...i.options},s=i.activeIndex??0;else if(i?.type===`setOptions`)o={...o,...i.options},s=i.activeIndex??s;else if(i?.type===`setActiveIndex`)s=i.activeIndex;else if(!e.docChanged)return t;return a.length===0?{query:a,options:o,activeIndex:0,matches:[]}:DD(r,a,o,s)}},props:{decorations(e){let t=TD.getState(e);return!t||t.matches.length===0?null:Be.create(e.doc,t.matches.map((e,n)=>ut.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var PD=W.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(TD,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(TD,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(TD,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=MD(e),r=jD(e,OD(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=MD(e),r=jD(e,OD(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=MD(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=wD(a.doc,r.query,r.options),s=kD(o,i.from,e.length),c=o[s];return a.setMeta(TD,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(xe.create(a.doc,c.from,c.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=MD(t);if(!n)return!1;let i=AD(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(TD,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[ND()]}}),FD=new WeakMap;function ID(e,t){if(t===null){FD.delete(e);return}FD.set(e,t)}function LD(e){return FD.get(e)??null}function RD(e){return`pagesBySlug`in e}function zD(e){return RD(e)?e.pages:e}function BD(e,t){return RD(e)?e.assetPaths??new Set:t??new Set}function VD(e,t){let n=De(e);if(n){if(RD(t))return t.pagesBySlug.get(n);for(let e of t)if(De(e)===n)return e}}function HD(e,t){if(e.includes(`/`))return;let n=De(e);if(!n)return;if(RD(t))return t.pagesByBasename?.get(n);let r;for(let e of t){let t=e.lastIndexOf(`/`);De(t===-1?e:e.slice(t+1))===n&&(r===void 0||e.localeCompare(r)<0)&&(r=e)}return r}function UD(e){let t=e.trim();if(!t)return null;let n=De(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function WD(e){let t=e.trim();if(!t)return[];let n=De(t);return n.length>0&&n!==t?[n]:[]}function GD(e,t){let n=e.trim();if(!n)return;let r=zD(t);if(r.has(n))return n;let i=VD(n,t);if(i)return i;for(let e of WD(n))if(r.has(e))return e;return KD(n,r)||HD(n,t)}function KD(e,t){let n=`${e}/index`;if(t.has(n))return n;let r=e.lastIndexOf(`/`),i=r===-1?e:e.slice(r+1),a=i?`${e}/${i}`:null;if(a&&t.has(a))return a}function qD(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function JD(e,t){let n=qD(e);if(!n)return null;if(t.has(n))return n;let r=n.toLowerCase();for(let e of t)if(e.toLowerCase()===r)return e;if(n.includes(`/`))return null;let i=[...t].filter(e=>{let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()===r});return i.length===0?null:i.sort((e,t)=>e.localeCompare(t))[0]??null}function YD(e,t,n){let r=e.trim();if(!r)return!1;if(JD(r,BD(t,n)))return!0;let i=zD(t);return i.has(r)||WD(r).some(e=>i.has(e))||VD(r,t)!==void 0||KD(r,i)?!0:HD(r,t)!==void 0}var XD=class extends Error{status;instance;constructor(e,t={}){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`HttpResponseParseError`,this.status=t.status,this.instance=t.instance}},ZD=new G(`imageUpload`);function QD(e){let t=document.createElement(`div`);t.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`);let n=e?.name;return t.setAttribute(`aria-label`,n?z._({id:`KDuPiY`,values:{fileName:n}}):z._({id:`bGa3Fk`})),t}var $D=new ln({key:ZD,state:{init(){return{decorations:Be.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(ZD);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=ut.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return ZD.getState(e)?.decorations??Be.empty}}});function eO(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function tO(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function nO(e){return e.split(`/`).filter(e=>e!==``)}function rO(e,t){let n=eO(e),r=eO(t),i=tO(e);if(n===r)return i;let a=nO(r),o=nO(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function iO(e){return LD(e)}function aO(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t}:{src:t,controls:!0}}}}function oO(e){let t=Te(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:V.has(t)?{kind:`jsx-img`,ext:t}:tt.has(t)?{kind:`jsx-video`,ext:t}:Kt.has(t)?{kind:`jsx-audio`,ext:t}:Ct.has(t)?{kind:`jsx-file`,ext:t}:st.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function sO(e,t,n){let r=iO(t),i=r?`${r}.md`:``;if(!i){nr.error(z._({id:`z5pqI8`}));return}let a=crypto.randomUUID(),o=QD(e);t.view.dispatch(t.state.tr.setMeta(ZD,{type:`add`,id:a,pos:n,widget:o}));let s=new FormData;s.append(`file`,e),s.append(`parentDocName`,i);let c;try{c=await fetch(`/api/upload`,{method:`POST`,body:s})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),cO(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),cO(t,a);return}if(!c.ok){let e=ze.safeParse(l);if(!e.success){let n=new XD(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),cO(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),cO(t,a,e.data.title);return}let u=en.safeParse(l);if(!u.success){let e=new XD(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),cO(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=eO(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&nr.info(z._({id:`VbqhBI`,values:{assetContentPath:h}}));let g=oO(e.name),{state:_}=t,v=ZD.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(ZD,{type:`remove`,id:a}),b=rO(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),cO(t,a);return}let n={type:`jsxComponent`,attrs:{componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:{src:x,target:f,alias:null,anchor:null,size:ne(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(ZD,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,n).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(Ke.create(e.doc,n)),!0}).run();return}if(g.kind===`jsx-img`||g.kind===`jsx-video`||g.kind===`jsx-audio`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),cO(t,a);return}let e=aO(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(ZD,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,e).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(Ke.create(e.doc,n)),!0}).run();return}if(g.kind===`wikiembed`){let e=_.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),cO(t,a);return}y.insert(v,e.create({target:f,alias:null,anchor:null,resolvedSrc:x}))}else if(g.kind===`wiki-link`){let n=_.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),cO(t,a);return}let r=UD(e.name.replace(/\.(md|mdx)$/i,``));r?y.insert(v,n.create(r)):y.insert(v,_.schema.text(e.name))}else{let t=_.schema.marks.link;if(t){let n=_.schema.text(e.name,[t.create({href:b})]);y.insert(v,n)}else y.insert(v,_.schema.text(e.name))}t.view.dispatch(y)}function cO(e,t,n){e.view.dispatch(e.state.tr.setMeta(ZD,{type:`remove`,id:t})),nr.error(n??z._({id:`b3Thhd`}))}var lO=new Set;function uO(e){lO.add(e)}function dO(e){return lO.delete(e)}var fO=new G(`markIdentity`);function pO(){return{byId:new Map,counter:0}}function mO(e,t,n,r,i){let a=[];for(let e of t.byId.values()){let t=i?i.map(e.from,-1):e.from,n=i?i.map(e.to,1):e.to;n<=t||a.push({id:e.id,markType:e.markType,attrs:e.attrs,from:t,to:n})}let o=new Map,s=new Set,c=t.counter;return e.descendants((e,t)=>{if(!(!e.isInline||e.marks.length===0))for(let i of e.marks){if(!n.has(i.type.name)||r&&!r(i))continue;let l=null;for(let e of a)if(!s.has(e.id)&&e.markType===i.type.name&&hO(e.attrs,i.attrs)&&!(t<e.from||t>=e.to)){l=e.id;break}let u=l??`m${++c}`;s.add(u);let d=t,f=t+e.nodeSize,p=o.get(u);p?p.to=Math.max(p.to,f):o.set(u,{id:u,markType:i.type.name,attrs:i.attrs,from:d,to:f})}}),{byId:o,counter:c}}function hO(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i&&!(typeof n==`object`&&n&&typeof i==`object`&&i&&hO(n,i)))return!1}return!0}function gO(e,t,n,r){let i=new Set(t.byId.keys());for(let[r,i]of t.byId)e.has(r)||n?.(i);for(let t of e)i.has(t)||r?.(t);return i}function _O(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new ln({key:fO,state:{init(e,t){return mO(t.doc,pO(),a,n)},apply(e,t,r,i){return e.docChanged?mO(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=fO.getState(t.state);n&&(e=gO(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var vO=300,yO=150,bO=500,xO=class{registry=new Map;_activeNodeId=null;listeners=new Set;_snapshot={activeNodeId:null,active:null};register(e){this.registry.set(e.nodeId,e),this._activeNodeId===e.nodeId&&this.refreshSnapshot()}deregister(e){this.registry.delete(e)&&this._activeNodeId===e&&(this._activeNodeId=null,this.refreshSnapshot())}setActiveNode(e){this._activeNodeId!==e&&(e!==null&&!this.registry.has(e)||(this._activeNodeId=e,this.refreshSnapshot()))}getActiveNode(){return this._activeNodeId}getRegistration(e){return this.registry.get(e)}hasRegistration(e){return this.registry.has(e)}clear(){this.registry.clear(),this._activeNodeId=null,this.refreshSnapshot()}getSnapshot=()=>this._snapshot;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});refreshSnapshot(){let e=this._activeNodeId==null?null:this.registry.get(this._activeNodeId)??null;this._snapshot={activeNodeId:this._activeNodeId,active:e};for(let e of this.listeners)e()}};function SO(e,t){let n=e??null;for(;n&&typeof n==`object`;){let e=n.getAttribute;if(typeof e==`function`){let r=e.call(n,`data-mark-id`);if(r&&t.hasRegistration(r))return r;let i=e.call(n,`data-node-id`);if(i&&t.hasRegistration(i))return i}n=n.parentElement??null}return null}function CO(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function wO(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var TO=e=>{let t=(0,J.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,Y.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Y.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,X.jsxs)(X.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function EO(e){return e.editorView?.dom??null}function DO(e,t){let n=e;for(;n;){if(n.getAttribute?.(`data-mark-id`)===t||n.getAttribute?.(`data-node-id`)===t)return!0;n=n.parentElement}return!1}function OO(e){let{editor:t}=e,n=new xO,r=EO(t),i=!1,a=null,o=null,s=null,c=null,l=null,u=()=>{a!==null&&(clearTimeout(a),a=null),s=null},d=()=>{o!==null&&(clearTimeout(o),o=null)},f=()=>{c!==null&&(clearTimeout(c),c=null)},p=e=>{if(n.getActiveNode()===e){d();return}s===e&&a!==null||(u(),d(),s=e,a=setTimeout(()=>{a=null,s=null,n.setActiveNode(e)},vO))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!wO()&&n.setActiveNode(null)},yO))},h=null,g=!1,_=e=>{try{g=!0,e.focus({preventScroll:!0})}catch{}finally{g=!1}},v=n.subscribe(()=>{let e=n.getActiveNode();if(e!==null){if(typeof document<`u`){let t=document.activeElement;h=t&&DO(t,e)?t:null}return}if(typeof document>`u`)return;let i=h;if(h=null,i&&document.contains(i)&&typeof i.focus==`function`){_(i);return}let a=r??EO(t);a&&typeof a.focus==`function`&&_(a)}),y=e=>{let t=e;if(t.button!==2){if(t.metaKey||t.ctrlKey||t.button===1){u(),t.button===1&&t.preventDefault?.();return}if(t.pointerType===`touch`){let t=SO(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},bO);return}u()}},b=()=>{f()},x=e=>{e.pointerType===`touch`&&c!==null&&f()},S=e=>{let t=e;if(t.button===2||t.type===`click`&&t.button===1)return;let r=SO(e.target,n);if(r===null)return;if(l!==null){let e=l===r;if(l=null,e){t.preventDefault?.();return}}let i=t.metaKey||t.ctrlKey||t.button===1,a=n.getRegistration(r);if(a?.handlePrimary&&a.handlePrimary({nodeId:r,type:a.type,newTab:i})){t.preventDefault?.(),i||(u(),d(),n.getActiveNode()===r&&n.setActiveNode(null));return}i||(u(),d(),n.setActiveNode(r))},C=e=>{let t=e;if(t.key===`Escape`){n.getActiveNode()!==null&&(u(),d(),n.setActiveNode(null),t.preventDefault?.());return}if(t.key===`Tab`&&!t.shiftKey&&!t.altKey&&!t.metaKey&&!t.ctrlKey){let r=SO(e.target,n);if(r!==null&&n.getActiveNode()===r){let e=document.querySelector(`[data-ok-prop-panel]`);if(e){let n=e.querySelector(`button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(n){t.preventDefault?.(),n.focus();return}}}return}let r=t.key===`Enter`,i=t.key===` `||t.key===`Spacebar`;if(!r&&!i)return;let a=SO(e.target,n);if(a===null||i&&((e.target instanceof Element?e.target:null)?.closest(`[data-mark-id], [data-node-id]`)??null)?.getAttribute(`role`)===`link`)return;let o=n.getRegistration(a);if(t.preventDefault?.(),o?.handlePrimary&&o.handlePrimary({nodeId:a,type:o.type,newTab:!1})){u(),d(),n.getActiveNode()===a&&n.setActiveNode(null);return}n.setActiveNode(a)},w=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target;if(!(r instanceof Element))return;if(CO(r)){d();return}let i=SO(r,n);i!==null&&p(i)},T=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target,i=t.relatedTarget;if(!(r instanceof Element))return;let a=i instanceof Element?i:null,o=SO(r,n);if(o!==null){if(a&&CO(a)){d();return}if(a&&SO(a,n)===o)return;s===o&&u(),m();return}if(CO(r)){if(a&&CO(a))return;let e=n.getActiveNode();if(e!==null&&a&&SO(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=SO(t,n);r!==null&&(u(),d(),n.setActiveNode(r))},D=e=>{let t=e;if(n.getActiveNode()===null)return;let r=t.relatedTarget,i=r instanceof Element?r:null;i&&CO(i)||i&&SO(i,n)!==null||m()},O=e=>{if(n.getActiveNode()===null)return;let t=e.target;t&&(r?.contains(t)||t instanceof Element&&(t.closest(`[data-ok-interaction-layer]`)||t.closest(`[data-ok-prop-panel]`)||t.closest(`[data-ok-layer-spawned]`))||(u(),d(),n.setActiveNode(null)))},k=()=>{i||(r=EO(t),r&&(r.addEventListener(`pointerdown`,y,!0),r.addEventListener(`pointerup`,b,!0),r.addEventListener(`pointercancel`,b,!0),r.addEventListener(`pointermove`,x,!0),r.addEventListener(`click`,S,!0),r.addEventListener(`auxclick`,S,!0),r.addEventListener(`keydown`,C,!0),typeof document<`u`&&(document.addEventListener(`pointerover`,w,!0),document.addEventListener(`pointerout`,T,!0),document.addEventListener(`focusin`,E,!0),document.addEventListener(`focusout`,D,!0),document.addEventListener(`pointerdown`,O,!0)),i=!0))},A=()=>{i&&=(r?.removeEventListener(`pointerdown`,y,!0),r?.removeEventListener(`pointerup`,b,!0),r?.removeEventListener(`pointercancel`,b,!0),r?.removeEventListener(`pointermove`,x,!0),r?.removeEventListener(`click`,S,!0),r?.removeEventListener(`auxclick`,S,!0),r?.removeEventListener(`keydown`,C,!0),typeof document<`u`&&(document.removeEventListener(`pointerover`,w,!0),document.removeEventListener(`pointerout`,T,!0),document.removeEventListener(`focusin`,E,!0),document.removeEventListener(`focusout`,D,!0),document.removeEventListener(`pointerdown`,O,!0)),!1)};return k(),{register(e){n.register(e),i||k()},deregister(e){n.deregister(e)},setActiveNode(e){n.setActiveNode(e)},getActiveNode(){return n.getActiveNode()},getRegistration(e){return n.getRegistration(e)},destroy(){A(),u(),d(),f(),v(),n.clear()},store:n}}var kO=e=>{let t=(0,J.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,X.jsx)(TO,{store:n})}),t[0]=n,t[1]=r),r},AO=new WeakMap;function jO(e){let t=AO.get(e);if(t)return t;let n=OO({editor:e});return AO.set(e,n),e.on(`destroy`,()=>{n.destroy(),AO.delete(e)}),n}var MO={AppWindow:ki,ChevronRight:rr,CopyPlus:Wi,FileText:Xi,Film:$i,GitBranch:na,Image:sa,LayoutPanelTop:ua,MessageSquareWarning:ya,PanelTop:Ca,Paperclip:wa,Sigma:ja,SquarePlay:Na,Volume2:Va,Workflow:Ha,ZoomIn:Wa};function NO(e){return e&&Object.hasOwn(MO,e)?MO[e]:Ni}var PO={ChevronRight:rr};function FO(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(PO,t)?PO[t]:null}function IO(e){let t=(0,J.c)(24),n;t[0]===e.icon?n=t[1]:(n=FO(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(rr,{size:14,className:`accordion-chevron`,"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=r?(0,X.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[3]=r,t[4]=o);let s=e.title??`Accordion`,c;t[5]===s?c=t[6]:(c=(0,X.jsx)(`span`,{className:`accordion-title`,children:s}),t[5]=s,t[6]=c);let l;t[7]===e.description?l=t[8]:(l=e.description?(0,X.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[7]=e.description,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(`span`,{className:`accordion-title-group`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==u?(d=(0,X.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,o,u]}),t[12]=o,t[13]=u,t[14]=d):d=t[14];let f;t[15]===e.children?f=t[16]:(f=(0,X.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[15]=e.children,t[16]=f);let p;return t[17]!==e.defaultOpen||t[18]!==e.id||t[19]!==e.name||t[20]!==i||t[21]!==d||t[22]!==f?(p=(0,X.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[d,f]}),t[17]=e.defaultOpen,t[18]=e.id,t[19]=e.name,t[20]=i,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function LO(e){return e!==!1}function RO(e){let t=(0,J.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:m(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=LO(e.controls),t[2]=e.controls,t[3]=i);let a;return t[4]!==e.autoplay||t[5]!==e.loop||t[6]!==e.muted||t[7]!==e.preload||t[8]!==e.title||t[9]!==n||t[10]!==i?(a=(0,X.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[4]=e.autoplay,t[5]=e.loop,t[6]=e.muted,t[7]=e.preload,t[8]=e.title,t[9]=n,t[10]=i,t[11]=a):a=t[11],a}var zO={note:ca,tip:da,important:ya,warning:he,caution:xa,abstract:Vi,info:Mi,todo:ga,success:p,question:zi,failure:Bi,danger:Ua,bug:Pi,example:ea,quote:Da},BO={Info:ca,Lightbulb:da,MessageSquareWarning:ya,AlertTriangle:he,AlertOctagon:xa,ClipboardList:Vi,BookOpen:Mi,ListTodo:ga,CircleCheck:p,CircleHelp:zi,CircleX:Bi,Zap:Ua,Bug:Pi,FlaskConical:ea,Quote:Da};function VO(e,t){if(!e||!e.startsWith(`lucide:`))return zO[t];let n=e.slice(7);return Object.hasOwn(BO,n)?BO[n]:zO[t]}var HO=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function UO(e){return typeof e==`string`&&HO.has(e)?e:`note`}function WO(e){let t=(0,J.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=UO(e.type),n=VO(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,a;t[4]===e.color?a=t[5]:(a=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=a);let s=a,c;t[6]!==i||t[7]!==e.title?(c=e.title||i?(0,X.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,X.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,X.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=c):c=t[8];let l=c;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===l?i=t[10]:(i=l??(0,X.jsx)(`span`,{className:`callout-title`,children:(0,X.jsx)(o,{id:`URmyfc`})}),t[9]=l,t[10]=i);let a;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Ii,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=a):a=t[11];let c;t[12]===i?c=t[13]:(c=(0,X.jsxs)(`summary`,{className:`callout-summary`,contentEditable:!1,children:[i,a]}),t[12]=i,t[13]=c);let u;t[14]===e.children?u=t[15]:(u=(0,X.jsx)(`div`,{className:`callout-body`,children:e.children}),t[14]=e.children,t[15]=u);let d;return t[16]!==n||t[17]!==s||t[18]!==c||t[19]!==u||t[20]!==r?(d=(0,X.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:s,children:[c,u]}),t[16]=n,t[17]=s,t[18]=c,t[19]=u,t[20]=r,t[21]=d):d=t[21],d}let u;t[22]===e.children?u=t[23]:(u=(0,X.jsx)(`div`,{className:`callout-body`,children:e.children}),t[22]=e.children,t[23]=u);let d;return t[24]!==l||t[25]!==s||t[26]!==u||t[27]!==r?(d=(0,X.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:s,children:[l,u]}),t[24]=l,t[25]=s,t[26]=u,t[27]=r,t[28]=d):d=t[28],d}var GO=(0,Y.createContext)(null);function KO(e){let t=(0,J.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(GO.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function qO(){return(0,Y.use)(GO)}var JO=[{key:`tl`,dx:-1,dy:-1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--tl`},{key:`t`,dx:0,dy:-1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--t`},{key:`tr`,dx:1,dy:-1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--tr`},{key:`r`,dx:1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--r`},{key:`br`,dx:1,dy:1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--br`},{key:`b`,dx:0,dy:1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--b`},{key:`bl`,dx:-1,dy:1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--bl`},{key:`l`,dx:-1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--l`}];function YO(e){let t=(0,J.c)(7),{targetRef:n,onResize:r,onResizeEnd:a,bounds:o}=e,{_:s}=i(),c=(0,Y.useRef)(null),l;t[0]!==o?.maxHeight||t[1]!==o?.maxWidth||t[2]!==o?.minHeight||t[3]!==o?.minWidth?(l=function(e,t){let n=t===`w`?o?.minWidth??64:o?.minHeight??64,r=t===`w`?o?.maxWidth??1/0:o?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=o?.maxHeight,t[1]=o?.maxWidth,t[2]=o?.minHeight,t[3]=o?.minWidth,t[4]=l):l=t[4];let u=l,d=function(e,t){let i=n.current;if(!i)return;e.preventDefault(),e.stopPropagation();let o=i.getBoundingClientRect();c.current={handle:t,startX:e.clientX,startY:e.clientY,startWidth:o.width,startHeight:o.height,latestWidth:o.width,latestHeight:o.height,hasMoved:!1},document.body.style.setProperty(`cursor`,t.cursor),document.body.style.setProperty(`user-select`,`none`);let s=function(e){let t=c.current;if(!t)return;let n=(e.clientX-t.startX)*t.handle.dx,i=(e.clientY-t.startY)*t.handle.dy,a=t.handle.dx===0?t.startWidth:u(t.startWidth+n,`w`),o=t.handle.dy===0?t.startHeight:u(t.startHeight+i,`h`);t.latestWidth=a,t.latestHeight=o,t.hasMoved=!0,r({width:a,height:o})};function l(){let e=c.current;if(!e)return;let t={width:e.latestWidth,height:e.latestHeight},n=e.hasMoved;c.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l),n&&a?.(t)}window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},f=JO.map(e=>{let t=e.key;return(0,X.jsx)(`button`,{type:`button`,className:yn(e.className),"aria-label":s({id:`NxW-md`,values:{handleKey:t}}),tabIndex:-1,style:{cursor:e.cursor},onPointerDown:t=>d(t,e)},t)}),p;return t[5]===f?p=t[6]:(p=(0,X.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:f}),t[5]=f,t[6]=p),p}var XO=`26rem`,ZO=`Embedded content`,QO=/^https?:\/\//i;function $O(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function ek(e){return!(typeof e!=`string`||!QO.test(e)||!$O(e))}function tk(e){let t=(0,J.c)(21),{src:n,title:r,width:i,height:a}=e,o=(0,Y.useRef)(null),s=qO(),c=i||void 0,l=a||XO,u;t[0]!==c||t[1]!==l?(u={width:c,height:l},t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f,p;if(t[3]!==a||t[4]!==i?(f=()=>{let e=o.current;e&&(e.style.width=i||``,e.style.height=a||XO)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Y.useEffect)(f,p),!ek(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=QO.test(n)?`Embed only supports cross-origin URLs`:`URL must start with http:// or https://`);let r;return t[7]===e?r=t[8]:(r=(0,X.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,X.jsx)(`span`,{children:e})}),t[7]=e,t[8]=r),r}let m;t[9]===s?m=t[10]:(m=e=>{if(!s)return;let{editor:t,getPos:n}=s,r=n();if(typeof r==`number`)try{let n=t.state.doc.nodeAt(r);if(!n||n.type.name!==`jsxComponent`)return;let i={...n.attrs.props??{},width:`${Math.round(e.width)}px`,height:`${Math.round(e.height)}px`};t.view.dispatch(t.state.tr.setNodeMarkup(r,null,{...n.attrs,props:i,sourceDirty:!0}))}catch(e){let t=e;if(t instanceof RangeError)return;throw t}},t[9]=s,t[10]=m);let h=m,g=r||ZO,_;t[11]!==n||t[12]!==g?(_=(0,X.jsx)(`iframe`,{title:g,src:n,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:`no-referrer`,loading:`lazy`,className:`ok-embed-frame`}),t[11]=n,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==s||t[15]!==h?(v=s?(0,X.jsx)(YO,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[14]=s,t[15]=h,t[16]=v):v=t[16];let y;return t[17]!==d||t[18]!==_||t[19]!==v?(y=(0,X.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[_,v]}),t[17]=d,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function nk(e){if(!e)return``;let t,n=null;try{let r=new URL(e,`https://placeholder.local`);n=r.protocol,t=r.pathname}catch{t=e.split(`?`)[0]??e}if(n===`data:`||n===`blob:`)return``;let r=t.split(`/`),i=r[r.length-1]??``;try{return decodeURIComponent(i)}catch{return i}}function rk(e){let t=(0,J.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||nk(e.src)||`Untitled file`,t[0]=e.name,t[1]=e.src,t[2]=n):n=t[2];let r=n,i=e.size?.trim()?e.size:null,a;t[3]===e.src?a=t[4]:(a=e.src?m(e.src):void 0,t[3]=e.src,t[4]=a);let o=a,s;t[5]===o?s=t[6]:(s=e=>{e.stopPropagation(),e.preventDefault(),o&&window.open(o,`_blank`,`noopener,noreferrer`)},t[5]=o,t[6]=s);let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(Zi,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,X.jsx)(`span`,{className:`ok-file-name`,children:r}),t[8]=r,t[9]=u);let d;t[10]===i?d=t[11]:(d=i?(0,X.jsx)(`span`,{className:`ok-file-size`,children:i}):null,t[10]=i,t[11]=d);let f;return t[12]!==c||t[13]!==o||t[14]!==e.title||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:ik,onClick:c,children:[l,u,d]}),t[12]=c,t[13]=o,t[14]=e.title,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function ik(e){return e.stopPropagation()}function ak(){return Y.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Y.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function ok(){return Y.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Y.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function sk(e){return typeof Element>`u`?!1:e instanceof Element}var ck=(e,t)=>sk(t)&&t.tagName.toUpperCase()===e,lk=e=>ck(`DIV`,e)||ck(`SPAN`,e),uk=e=>ck(`IMG`,e),dk=e=>e.complete&&e.naturalHeight!==0,fk=e=>ck(`SVG`,e),pk=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),mk=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=pk({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},hk=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?mk({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):pk({height:e,offset:r,width:t}),gk=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,_k=e=>{if(e!==null){if(uk(e))return e.currentSrc===``?void 0:e.currentSrc;if(lk(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return gk.exec(t)?.[1]}}},vk=e=>{if(e!==null)return uk(e)?e.alt:e.getAttribute(`aria-label`)??void 0},yk=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=hk({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},bk=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},xk=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=bk({position:p,relativeNum:r-l*f}),g=bk({position:m,relativeNum:e-c*f}),_=hk({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=bk({position:a,relativeNum:r-l}),f=bk({position:u,relativeNum:e-c}),p=hk({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=hk({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},Sk=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=bk({position:p,relativeNum:a-l*f}),g=bk({position:m,relativeNum:n-c*f}),_=hk({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=bk({position:t,relativeNum:a-l}),f=bk({position:u,relativeNum:n-c}),p=hk({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=bk({position:u,relativeNum:a}),p=bk({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=bk({position:_,relativeNum:a-l*g}),b=bk({position:v,relativeNum:n-c*g}),x=hk({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},Ck=/\.svg$/i,wk=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&Ck.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&lk(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=yk({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?xk({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?Sk({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},Tk=e=>{if(e==null)return{};if(fk(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},Ek=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},Dk=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),Ok={overflow:``,width:``};function kk(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function Ak(e){e.preventDefault()}function jk(e){return Y.createElement(Mk,{...e})}var Mk=class extends Y.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Y.createRef(),this.refDialog=Y.createRef(),this.refModalContent=Y.createRef(),this.refModalImg=Y.createRef(),this.refWrap=Y.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=Ok,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(Dk),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:Tk(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:Tk(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=_k(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(uk(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:Tk(this.imgEl)})};t.decode().then(r).catch(()=>{if(dk(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||fk(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=Ok},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(dk(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(fk(e)){let r=e.cloneNode(!0);Ek(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=lk(a),j=uk(a),M=fk(a),N=vk(a),P=_k(a),F=j?a.sizes:void 0,ee=j?a.srcset:void 0,I=j?a.crossOrigin:void 0,L=h?.src!==void 0&&h.src!==``,te=this.hasImage(),ne=N!==void 0&&N!==``?`${s}: ${N}`:s,re=T===`LOADING`||T===`LOADED`,R=te?`found`:`not-found`,z=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,ie={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=te&&a!==null?wk({hasZoomImg:L,imgSrc:P,isSvg:M,isZoomed:f&&re,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let B=null;if(te){let t=j||A?Y.createElement(`img`,{alt:N,crossOrigin:I,sizes:F,src:P,srcSet:ee,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Y.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Y.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Y.createElement(u,null));B=m==null?Y.createElement(Y.Fragment,null,t,n):Y.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Y.createElement(p,{"aria-owns":te?O:void 0,"data-rmiz":``,ref:x},Y.createElement(p,{"data-rmiz-content":R,ref:_,style:ie},c),te&&Y.createElement(p,{"data-rmiz-ghost":``,style:D},Y.createElement(`button`,{"aria-label":ne,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Y.createElement(d,null))),te&&Ya.createPortal(Y.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Ak,ref:v,role:`dialog`},Y.createElement(`div`,{"data-rmiz-modal-overlay":z}),Y.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},B)),kk()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};Mk.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:ak,IconZoom:ok,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function Nk({onZoomChange:e,...t}){let[n,r]=Y.useState(!1),i=Y.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Y.createElement(jk,{...t,isZoomed:n,onZoomChange:i})}function Pk(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function Fk(e,t,n){return Pk(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function Ik(e){let t=(0,J.c)(52),n,r,a,o,s,c,l,u,d,f,p,m;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12]):({width:m,height:r,loadingTestId:d,slotTestId:f,slotClassName:c,className:n,onLoad:s,onError:o,src:l,style:u,alt:p,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m);let h=d===void 0?`image-loading-skeleton`:d,g=f===void 0?`image-slot`:f,_=p===void 0?``:p,{_:v}=i(),y=(0,Y.useRef)(null),[b,x]=(0,Y.useState)(!1),S;t[13]!==r||t[14]!==m?(S=Pk(m,r),t[13]=r,t[14]=m,t[15]=S):S=t[15];let C=S,w;t[16]!==r||t[17]!==u||t[18]!==m?(w=Fk(m,r,u),t[16]=r,t[17]=u,t[18]=m,t[19]=w):w=t[19];let T=w,E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{y.current?.complete?x(!0):x(!1)},t[20]=E):E=t[20];let D;t[21]===l?D=t[22]:(D=[l],t[21]=l,t[22]=D),(0,Y.useLayoutEffect)(E,D);let O=!C&&!b&&`aspect-[16/9] w-full max-w-full`,k;t[23]!==c||t[24]!==O?(k=yn(`relative inline-block overflow-hidden`,O,c),t[23]=c,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==v||t[27]!==b||t[28]!==h?(A=!b&&(0,X.jsx)(`span`,{"data-testid":h,role:`status`,"aria-busy":`true`,"aria-label":v({id:`N1YYa7`}),className:`absolute inset-0 animate-pulse rounded-md bg-muted motion-reduce:animate-none`}),t[26]=v,t[27]=b,t[28]=h,t[29]=A):A=t[29];let j=b?`opacity-100`:`opacity-0`,M;t[30]!==n||t[31]!==j?(M=yn(`block max-w-full transition-opacity motion-reduce:transition-none`,j,n),t[30]=n,t[31]=j,t[32]=M):M=t[32];let N;t[33]===s?N=t[34]:(N=e=>{x(!0),s?.(e)},t[33]=s,t[34]=N);let P;t[35]===o?P=t[36]:(P=e=>{x(!0),o?.(e)},t[35]=o,t[36]=P);let F;t[37]!==_||t[38]!==r||t[39]!==a||t[40]!==l||t[41]!==M||t[42]!==N||t[43]!==P||t[44]!==m?(F=(0,X.jsx)(`img`,{...a,ref:y,src:l,alt:_,width:m,height:r,className:M,onLoad:N,onError:P}),t[37]=_,t[38]=r,t[39]=a,t[40]=l,t[41]=M,t[42]=N,t[43]=P,t[44]=m,t[45]=F):F=t[45];let ee;return t[46]!==T||t[47]!==g||t[48]!==A||t[49]!==F||t[50]!==k?(ee=(0,X.jsxs)(`span`,{"data-testid":g,className:k,style:T,children:[A,F]}),t[46]=T,t[47]=g,t[48]=A,t[49]=F,t[50]=k,t[51]=ee):ee=t[51],ee}function Lk(e){return e??`lazy`}function Rk(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function zk(e){let t=(0,J.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:m(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=Rk(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=Rk(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=Lk(e.loading),t[6]=e.loading,t[7]=s);let c;return t[8]!==e.crossorigin||t[9]!==e.decoding||t[10]!==e.fetchpriority||t[11]!==e.referrerpolicy||t[12]!==e.sizes||t[13]!==e.srcset||t[14]!==e.title||t[15]!==n||t[16]!==r||t[17]!==i||t[18]!==a||t[19]!==s?(c=(0,X.jsx)(Ik,{src:n,alt:r,width:i,height:a,title:o,loading:s,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy}),t[8]=e.crossorigin,t[9]=e.decoding,t[10]=e.fetchpriority,t[11]=e.referrerpolicy,t[12]=e.sizes,t[13]=e.srcset,t[14]=e.title,t[15]=n,t[16]=r,t[17]=i,t[18]=a,t[19]=s,t[20]=c):c=t[20],c}function Bk(e){let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,X.jsx)(Nk,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,X.jsx)(zk,{...e})}),t[1]=e,t[2]=r),r}var Vk=(0,Y.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DX-tM4Fr.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,J.c)(7),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!0,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={__html:i},n[2]=i,n[3]=a);let o;return n[4]!==t.id||n[5]!==a?(o=(0,X.jsx)(`div`,{className:`math math-display`,"data-component-type":`math`,id:t.id,dangerouslySetInnerHTML:a}),n[4]=t.id,n[5]=a,n[6]=o):o=n[6],o}return{default:t}});function Hk(e){let t=(0,J.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,X.jsx)(`div`,{className:`math math-placeholder`,"data-component-type":`math`,id:e.id,children:n}),t[0]=e.id,t[1]=n,t[2]=r):r=t[2],r}function Uk(e){let t=(0,J.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,X.jsx)(Hk,{formula:n,id:e.id}),t[0]=n,t[1]=e.id,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e.id?(r=(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(Hk,{formula:n,id:e.id}),children:(0,X.jsx)(Vk,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}var Wk=null;function Gk(){return Wk||=n(()=>import(`./mermaid.core-DRx0wZe0.js`).then(e=>{let t=e.default;return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`default`,suppressErrorRendering:!0}),t}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),import.meta.url).catch(e=>{throw Wk=null,e}),Wk}function Kk(e){let t=(0,J.c)(24),n=e.chart??``,r=(0,Y.useId)(),i;if(t[0]!==r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/:/g,t[2]=e):e=t[2],i=r.replace(e,`_`),t[0]=r,t[1]=i}else i=t[1];let a=`mermaid-${i}`,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={status:`idle`,svg:``,error:``},t[3]=o):o=t[3];let[s,c]=(0,Y.useState)(o),l,u;if(t[4]!==n||t[5]!==a?(l=()=>{if(!n.trim()){c({status:`idle`,svg:``,error:``});return}let e=!1;return c(qk),Gk().then(async t=>{try{let r=await t.render(a,n);e||c({status:`ready`,svg:r.svg,error:``})}catch(t){let n=t;e||c({status:`error`,svg:``,error:n instanceof Error?n.message:String(n)})}}).catch(t=>{e||c({status:`error`,svg:``,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},u=[n,a],t[4]=n,t[5]=a,t[6]=l,t[7]=u):(l=t[6],u=t[7]),(0,Y.useEffect)(l,u),!n.trim()){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`mermaid mermaid-placeholder`,"data-component-type":`mermaid`,children:(0,X.jsx)(`span`,{className:`mermaid-empty`,children:` `})}),t[8]=e):e=t[8],e}if(s.status===`error`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(he,{className:`size-3.5 shrink-0 mt-0.5`,"aria-hidden":!0}),t[9]=e):e=t[9];let r;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(`div`,{className:`font-medium`,children:`Mermaid diagram failed to render.`}),t[10]=r):r=t[10];let i;t[11]===s.error?i=t[12]:(i=(0,X.jsxs)(`div`,{role:`alert`,className:`mermaid-error-message mb-2 flex items-start gap-2 rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive`,children:[e,(0,X.jsxs)(`div`,{className:`min-w-0`,children:[r,(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words font-mono text-[11px] opacity-90`,children:s.error})]})]}),t[11]=s.error,t[12]=i);let a;t[13]===n?a=t[14]:(a=(0,X.jsx)(`pre`,{className:`mermaid-error-source`,children:n}),t[13]=n,t[14]=a);let o;return t[15]!==s.error||t[16]!==i||t[17]!==a?(o=(0,X.jsxs)(`div`,{className:`mermaid mermaid-error`,"data-component-type":`mermaid`,title:s.error,children:[i,a]}),t[15]=s.error,t[16]=i,t[17]=a,t[18]=o):o=t[18],o}let d=`mermaid mermaid-${s.status}`,f;t[19]===s.svg?f=t[20]:(f={__html:s.svg},t[19]=s.svg,t[20]=f);let p;return t[21]!==d||t[22]!==f?(p=(0,X.jsx)(`div`,{className:d,"data-component-type":`mermaid`,dangerouslySetInnerHTML:f}),t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function qk(e){return{...e,status:`rendering`}}var Jk=null;function Yk(){return Jk||=new N({extensions:_e}),Jk}function Xk(e,t){if(e.type===`mdxJsxFlowElement`){let n=e;if(n.name===`MirrorSource`){for(let e of n.attributes??[])if(e.type===`mdxJsxAttribute`&&e.name===`id`&&typeof e.value==`string`&&e.value===t)return n}}let n=e.children;if(Array.isArray(n))for(let e of n){let n=Xk(e,t);if(n)return n}return null}function Zk(e){return cn({type:`root`,children:e.children??[]})}var Qk=new Map,$k=30,eA=150,tA=1e4;function nA(e,t){let n=`${e}|${t}`,r=Qk.get(n);if(r)return r.refcount+=1,r;let i=new Km,a=new LE({url:e,name:t,document:i}),o=new Set,s={provider:a,ySource:i.getText(`source`),refcount:1,synced:!1,subscribers:o};return a.on(`synced`,()=>{s.synced=!0;for(let e of o)e.onSynced()}),s.ySource.observe(()=>{for(let e of o)e.onUpdate()}),Qk.set(n,s),Qk.size>$k&&console.warn(`[Mirror] provider pool exceeded ${$k} entries (current=${Qk.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function rA(e,t){let n=`${e}|${t}`,r=Qk.get(n);if(r&&(--r.refcount,r.refcount<=0)){try{r.provider.destroy()}catch(e){console.warn(`[Mirror] provider.destroy() failed during release`,{src:t,err:e})}Qk.delete(n)}}function iA(e,t){let n=(0,J.c)(8),{collabUrl:r}=Bx(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Y.useState)(i),s=(0,Y.useRef)(t),c=(0,Y.useRef)(null),l,u;n[1]!==r||n[2]!==e?(l=()=>{if(!e){o({kind:`empty-props`});return}if(!r){o({kind:`loading`});return}let t=nA(r,e),n=()=>{let n=s.current;if(!n){o({kind:`empty-props`});return}let r=t.ySource.toString();if(!r){o(t.synced?{kind:`source-removed`}:{kind:`loading`});return}let i;try{i=Yk().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=Xk(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=Zk(a)}catch(t){console.warn(`[Mirror] renderMirrorSubtree failed`,{src:e,anchor:n,err:t}),o({kind:`anchor-not-found`});return}o({kind:`ready`,html:c})},i=null,a={onUpdate:()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,n()},eA)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},tA);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,rA(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Y.useEffect)(l,u);let d,f;return n[5]===t?(d=n[6],f=n[7]):(d=()=>{s.current=t,c.current?.()},f=[t],n[5]=t,n[6]=d,n[7]=f),(0,Y.useEffect)(d,f),a}function aA(e){let t=(0,J.c)(8),n=`ok-mirror-state flex items-start gap-2 rounded-md border border-dashed px-3 py-2 text-sm ${e.tone===`error`?`border-destructive/40 text-destructive`:`border-border text-muted-foreground`}`,r;t[0]===e.tone?r=t[1]:(r=e.tone===`error`?(0,X.jsx)(fa,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(ma,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),t[0]=e.tone,t[1]=r);let i;t[2]===e.children?i=t[3]:(i=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),t[2]=e.children,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,X.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function oA(e){let t=(0,J.c)(30),n=e.src??``,r=e.anchor??``,i=iA(n,r);if(i.kind===`empty-props`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(aA,{tone:`placeholder`,children:(0,X.jsx)(o,{id:`3SDfZl`,components:{0:(0,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{}),2:(0,X.jsx)(`code`,{}),3:(0,X.jsx)(`code`,{})}})}),t[0]=e):e=t[0],e}if(i.kind===`loading`){let e=n&&r?`${n}#${r}`:``,i;t[1]===e?i=t[2]:(i={mirrorRef:e},t[1]=e,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a={0:(0,X.jsx)(`code`,{})},t[3]=a):a=t[3];let s;return t[4]===i?s=t[5]:(s=(0,X.jsx)(aA,{tone:`placeholder`,children:(0,X.jsx)(o,{id:`92rbk2`,values:i,components:a})}),t[4]=i,t[5]=s),s}if(i.kind===`source-removed`){let e;t[6]===n?e=t[7]:(e={src:n},t[6]=n,t[7]=e);let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{})},t[8]=r):r=t[8];let i;return t[9]===e?i=t[10]:(i=(0,X.jsx)(aA,{tone:`error`,children:(0,X.jsx)(o,{id:`Ud0Pj9`,values:e,components:r})}),t[9]=e,t[10]=i),i}if(i.kind===`anchor-not-found`){let e=`<MirrorSource id="${r}">`,i;t[11]!==e||t[12]!==n?(i={mirrorSourceTag:e,src:n},t[11]=e,t[12]=n,t[13]=i):i=t[13];let a;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(a={0:(0,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{}),2:(0,X.jsx)(`code`,{})},t[14]=a):a=t[14];let s;return t[15]===i?s=t[16]:(s=(0,X.jsx)(aA,{tone:`error`,children:(0,X.jsx)(o,{id:`mqSwZH`,values:i,components:a})}),t[15]=i,t[16]=s),s}let a;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Gi,{className:`size-3`,"aria-hidden":`true`}),t[17]=a):a=t[17];let s;t[18]===n?s=t[19]:(s={src:n},t[18]=n,t[19]=s);let c;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(c={0:(0,X.jsx)(`code`,{className:`font-mono`})},t[20]=c):c=t[20];let l;t[21]===s?l=t[22]:(l=(0,X.jsxs)(`div`,{className:`ok-mirror-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,"aria-hidden":`true`,children:[a,(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`wQp1V3`,values:s,components:c})})]}),t[21]=s,t[22]=l);let u;t[23]===i.html?u=t[24]:(u=(0,X.jsx)(`div`,{dangerouslySetInnerHTML:{__html:i.html}}),t[23]=i.html,t[24]=u);let d;return t[25]!==r||t[26]!==n||t[27]!==l||t[28]!==u?(d=(0,X.jsxs)(`div`,{className:`ok-mirror-resolved relative -mx-3 prose-no-margin rounded-md border border-dashed border-transparent px-3 py-2 transition-colors [.jsx-component-wrapper:hover_&]:border-border/40 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/40`,"data-mirror-src":n,"data-mirror-anchor":r,children:[l,u]}),t[25]=r,t[26]=n,t[27]=l,t[28]=u,t[29]=d):d=t[29],d}function sA(e){let t=(0,J.c)(15),{_:n}=i(),r=e.id??``,a;t[0]!==n||t[1]!==r?(a=r||n({id:`12F9WL`}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let s=a,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(Wi,{className:`size-3`,"aria-hidden":`true`}),t[3]=c):c=t[3];let l;t[4]===s?l=t[5]:(l={label:s},t[4]=s,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={0:(0,X.jsx)(`code`,{className:`font-mono`})},t[6]=u):u=t[6];let d;t[7]===l?d=t[8]:(d=(0,X.jsxs)(`div`,{className:`ok-mirror-source-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,children:[c,(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`Zon_qG`,values:l,components:u})})]}),t[7]=l,t[8]=d);let f;t[9]===e.children?f=t[10]:(f=(0,X.jsx)(`div`,{children:e.children}),t[9]=e.children,t[10]=f);let p;return t[11]!==r||t[12]!==d||t[13]!==f?(p=(0,X.jsxs)(`div`,{className:`ok-mirror-source relative -mx-3 rounded-md border border-dashed border-transparent px-3 py-1 transition-colors [.jsx-component-wrapper:hover_&]:border-border/50 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/50`,"data-mirror-source-id":r,children:[d,f]}),t[11]=r,t[12]=d,t[13]=f,t[14]=p):p=t[14],p}var cA=24,lA=24,uA=12,dA=.1;function fA(e,t,n,r){if(n<=0&&(e===`fit-width`||e===`two-odd`||e===`two-even`)||r<=0&&e===`fit-height`)return 1;switch(e){case`fit-width`:return Math.max(dA,(n-cA)/t.naturalWidth);case`fit-height`:return Math.max(dA,(r-lA)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(dA,((n-cA)/2-uA)/t.naturalWidth)}}var pA=600,mA=.5,hA=3,gA=.25,_A=null;function vA(){return _A||(_A=(async()=>{let e=await n(()=>import(`./pdf-wFLJduM2.js`),__vite__mapDeps([24,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-CP44mBOj.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),_A.catch(()=>{_A=null})),_A}function yA(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function bA(e){let t=(0,J.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=yt(e.anchor);n=i===null?e.fillContainer?`100%`:`${pA}px`:`${i}px`,r=EA(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let a=r,s=(0,Y.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Y.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Y.useRef)(u),f=(0,Y.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[h,g]=(0,Y.useState)(p),[_,v]=(0,Y.useState)(!0),[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(a??1),[C,w]=(0,Y.useState)(String(a??1)),[T,E]=(0,Y.useState)(1),[D,O]=(0,Y.useState)(`fit-width`),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)(0),[F,ee]=(0,Y.useState)(0),{_:I}=i(),L=h.length,te,ne;t[7]!==I||t[8]!==e.src?(te=()=>{if(!e.src){v(!1);return}let t=m(e.src),n=!1,r=null;return v(!0),b(null),(async()=>{try{let e=await(await vA()).getDocument({url:t,isEvalSupported:!1}).promise;if(n){await e.destroy();return}r=e,f.current=e;let i=[];for(let t=1;t<=e.numPages;t++){if(n)return;let r=(await e.getPage(t)).getViewport({scale:1});i.push({pageNumber:t,naturalWidth:r.width,naturalHeight:r.height})}if(n)return;g(i)}catch(e){let t=e;if(n)return;b(t instanceof Error?t.message:I({id:`jRHdCz`})),v(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),f.current=null}},ne=[e.src,I],t[7]=I,t[8]=e.src,t[9]=te,t[10]=ne):(te=t[9],ne=t[10]),(0,Y.useEffect)(te,ne);let re,R;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{let e=s.current;if(!e)return;let t=()=>{P(e.clientWidth),ee(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},R=[],t[11]=re,t[12]=R):(re=t[11],R=t[12]),(0,Y.useEffect)(re,R);let z,ie;t[13]!==I||t[14]!==F||t[15]!==N||t[16]!==D||t[17]!==h||t[18]!==T?(z=()=>{let e=f.current;if(!e||h.length===0||N===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of h){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=fA(D,i,N,F)*T,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}t||v(!1)}catch(e){let n=e;if(t||yA(n))return;console.warn(`[Pdf] page render failed:`,n),b(n instanceof Error?n.message:I({id:`_TF8ep`})),v(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},ie=[h,D,T,N,F,I],t[13]=I,t[14]=F,t[15]=N,t[16]=D,t[17]=h,t[18]=T,t[19]=z,t[20]=ie):(z=t[19],ie=t[20]),(0,Y.useEffect)(z,ie);let B,V;t[21]!==h||t[22]!==k?(B=()=>{if(!k)return;let e=f.current;if(!e||h.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of h){if(t)return;let a=d.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let l=a.getContext(`2d`);l&&(l.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:l,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;yA(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},V=[k,h],t[21]=h,t[22]=k,t[23]=B,t[24]=V):(B=t[23],V=t[24]),(0,Y.useEffect)(B,V);let H,U;t[25]!==_||t[26]!==a?(H=()=>{if(_||!a)return;let e=s.current,t=l.current[a-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},U=[_,a],t[25]=_,t[26]=a,t[27]=H,t[28]=U):(H=t[27],U=t[28]),(0,Y.useEffect)(H,U);let ae,oe;t[29]===h?(ae=t[30],oe=t[31]):(ae=()=>{let e=s.current;if(!e||h.length===0)return;let t=!1,n=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let n=e.scrollTop,r=1;for(let t of h){let i=l.current[t.pageNumber-1];i&&i.offsetTop-e.offsetTop<=n+40&&(r=t.pageNumber)}S(r),w(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},oe=[h],t[29]=h,t[30]=ae,t[31]=oe),(0,Y.useEffect)(ae,oe);let se,ce;t[32]===j?(se=t[33],ce=t[34]):(se=()=>{if(!j)return;let e=e=>{let t=e.target,n=s.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){M(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&M(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},ce=[j],t[32]=j,t[33]=se,t[34]=ce),(0,Y.useEffect)(se,ce);let le;t[35]===L?le=t[36]:(le=e=>{let t=Math.max(1,Math.min(L||1,e));S(t),w(String(t));let n=s.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=L,t[36]=le);let ue=le,de;t[37]!==x||t[38]!==ue||t[39]!==C?(de=()=>{let e=Number.parseInt(C,10);if(Number.isNaN(e)){w(String(x));return}ue(e)},t[37]=x,t[38]=ue,t[39]=C,t[40]=de):de=t[40];let fe=de,W;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>E(wA),t[41]=W):W=t[41];let pe=W,me;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>E(CA),t[42]=me):me=t[42];let he=me,ge;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>{O(e),M(!1),E(1)},t[43]=ge):ge=t[43];let _e=ge,ve;t[44]===n?ve=t[45]:(ve={height:n},t[44]=n,t[45]=ve);let G;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>A(SA),t[46]=G):G=t[46];let ye;t[47]!==I||t[48]!==k?(ye=I(k?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=I,t[48]=k,t[49]=ye):ye=t[49];let be;t[50]===I?be=t[51]:(be=I({id:`zo3Dl7`}),t[50]=I,t[51]=be);let xe;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,X.jsx)(Sa,{size:14,"aria-hidden":`true`}),t[52]=xe):xe=t[52];let Se;t[53]!==k||t[54]!==ye||t[55]!==be?(Se=(0,X.jsx)(`button`,{type:`button`,onClick:G,"aria-label":ye,"aria-pressed":k,className:`ok-pdf-btn`,title:be,children:xe}),t[53]=k,t[54]=ye,t[55]=be,t[56]=Se):Se=t[56];let Ce=e.title??`PDF`,we;t[57]===Ce?we=t[58]:(we=(0,X.jsx)(`span`,{className:`ok-pdf-title`,children:Ce}),t[57]=Ce,t[58]=we);let Te;t[59]!==I||t[60]!==j||t[61]!==D||t[62]!==C||t[63]!==fe||t[64]!==L||t[65]!==T?(Te=L>0&&(0,X.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,X.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),fe()},children:(0,X.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:C,onChange:e=>w(e.target.value.replace(/[^0-9]/g,``)),onBlur:fe,"aria-label":I({id:`xsZhu-`})})}),(0,X.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,X.jsx)(o,{id:`1GhYxC`,values:{totalPages:L}})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:he,disabled:T<=mA,"aria-label":I({id:`FjkaiT`}),className:`ok-pdf-btn`,title:I({id:`FjkaiT`}),children:(0,X.jsx)(Ga,{size:14,"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(T*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,onClick:pe,disabled:T>=hA,"aria-label":I({id:`AWOSPo`}),className:`ok-pdf-btn`,title:I({id:`AWOSPo`}),children:(0,X.jsx)(Wa,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>M(xA),"aria-label":I({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":j,className:`ok-pdf-btn`,title:I({id:`rdU729`}),children:(0,X.jsx)(Ii,{size:14,"aria-hidden":`true`})}),j&&(0,X.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,X.jsx)(TA,{label:I({id:`vIxrEk`}),active:D===`fit-width`,onSelect:()=>_e(`fit-width`)}),(0,X.jsx)(TA,{label:I({id:`YlDuro`}),active:D===`fit-height`,onSelect:()=>_e(`fit-height`)}),(0,X.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,X.jsx)(TA,{label:I({id:`BGHHtQ`}),active:D===`single`,onSelect:()=>_e(`single`)}),(0,X.jsx)(TA,{label:I({id:`xK291b`}),active:D===`two-odd`,onSelect:()=>_e(`two-odd`)}),(0,X.jsx)(TA,{label:I({id:`NSnIUP`}),active:D===`two-even`,onSelect:()=>_e(`two-even`)})]})]})]}),t[59]=I,t[60]=j,t[61]=D,t[62]=C,t[63]=fe,t[64]=L,t[65]=T,t[66]=Te):Te=t[66];let Ee;t[67]!==Se||t[68]!==we||t[69]!==Te?(Ee=(0,X.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[Se,we,Te]}),t[67]=Se,t[68]=we,t[69]=Te,t[70]=Ee):Ee=t[70];let De;t[71]!==I||t[72]!==x||t[73]!==ue||t[74]!==h||t[75]!==k?(De=k&&(0,X.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":I({id:`nzaV6Q`}),children:h.map((e,t)=>{let{pageNumber:n}=e;return(0,X.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":x===n||void 0,onClick:()=>ue(n),"aria-label":I({id:`qioCwA`,values:{pageNumber:n}}),children:[(0,X.jsx)(`canvas`,{ref:e=>{d.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,X.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:n})]},n)})}),t[71]=I,t[72]=x,t[73]=ue,t[74]=h,t[75]=k,t[76]=De):De=t[76];let Oe;t[77]===_?Oe=t[78]:(Oe=_&&(0,X.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,X.jsx)(o,{id:`T-654M`})}),t[77]=_,t[78]=Oe);let ke;t[79]===y?ke=t[80]:(ke=y&&(0,X.jsx)(`div`,{className:`ok-pdf-error`,children:(0,X.jsx)(o,{id:`WamGNs`,values:{error:y}})}),t[79]=y,t[80]=ke);let Ae;t[81]!==I||t[82]!==L?(Ae=Array.from({length:L},(e,t)=>{let n=t+1;return(0,X.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":I({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=I,t[82]=L,t[83]=Ae):Ae=t[83];let je;t[84]!==D||t[85]!==Oe||t[86]!==ke||t[87]!==Ae?(je=(0,X.jsxs)(`div`,{className:`ok-pdf-pages`,ref:s,"data-layout":D,children:[Oe,ke,Ae]}),t[84]=D,t[85]=Oe,t[86]=ke,t[87]=Ae,t[88]=je):je=t[88];let Me;t[89]!==De||t[90]!==je?(Me=(0,X.jsxs)(`div`,{className:`ok-pdf-body`,children:[De,je]}),t[89]=De,t[90]=je,t[91]=Me):Me=t[91];let Ne;return t[92]!==ve||t[93]!==Ee||t[94]!==Me?(Ne=(0,X.jsxs)(`div`,{className:`ok-pdf`,style:ve,children:[Ee,Me]}),t[92]=ve,t[93]=Ee,t[94]=Me,t[95]=Ne):Ne=t[95],Ne}function xA(e){return!e}function SA(e){return!e}function CA(e){return Math.max(mA,+(e-gA).toFixed(2))}function wA(e){return Math.min(hA,+(e+gA).toFixed(2))}function TA(e){let t=(0,J.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,X.jsx)(tr,{size:14}),t[0]=e.active,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,X.jsx)(`span`,{className:`ok-pdf-menu-check`,"aria-hidden":`true`,children:r}),t[2]=r,t[3]=i);let a;return t[4]!==e.active||t[5]!==e.label||t[6]!==e.onSelect||t[7]!==n||t[8]!==i?(a=(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.active,className:`ok-pdf-menu-item`,"data-active":n,onClick:e.onSelect,children:[i,e.label]}),t[4]=e.active,t[5]=e.label,t[6]=e.onSelect,t[7]=n,t[8]=i,t[9]=a):a=t[9],a}function EA(e){if(!e)return null;for(let t of e.split(`&`)){let e=t.indexOf(`=`);if(!(e<0)&&t.slice(0,e)===`page`){let n=Number.parseInt(t.slice(e+1),10);if(!Number.isNaN(n)&&n>=1)return n}}return null}function DA(e){let t=(0,J.c)(10),{label:n,id:r,children:i}=e,a=(0,Y.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,X.jsx)(`section`,{className:`tab-panel`,id:s,role:`tabpanel`,"aria-labelledby":c,"data-tab-label":u,"data-tab-id":s,children:i}),t[5]=i,t[6]=s,t[7]=u,t[8]=c,t[9]=d):d=t[9],d}var OA=`[data-component-type="tabs"]`,kA=`[data-node-view-content-react] > .react-renderer`;function AA(e){let t=e.closest(OA);return t?Array.from(e.querySelectorAll(kA)).filter(e=>e.parentElement?.closest(OA)===t).map((e,t)=>{let n=e.querySelector(`[data-tab-label]`);return{index:t,label:(n?.getAttribute(`data-tab-label`))?.trim()||`Tab ${t+1}`,panelId:n?.getAttribute(`data-tab-id`)??null}}):[]}function jA(e){let t=(0,J.c)(26),{id:n,children:r}=e,[i,a]=(0,Y.useState)(0),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0];let[s,c]=(0,Y.useState)(o),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(0),f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=l.current;if(!e)return;let t=AA(e);c(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=f):f=t[1],(0,Y.useLayoutEffect)(f);let p,m;t[2]===s.length?(p=t[3],m=t[4]):(p=()=>{s.length>d.current&&s.length>0&&a(s.length-1),d.current=s.length},m=[s.length],t[2]=s.length,t[3]=p,t[4]=m),(0,Y.useLayoutEffect)(p,m);let h;t[5]===n?h=t[6]:(h=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){a(0);return}let t=l.current;if(!t)return;let r=AA(t).findIndex(t=>t.panelId===e);r<0||(a(r),queueMicrotask(()=>{t.ownerDocument.getElementById(e)?.scrollIntoView({block:`start`,behavior:`auto`})}))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},t[5]=n,t[6]=h),(0,Y.useLayoutEffect)(h);let g=s.length===0?0:Math.min(Math.max(i,0),s.length-1),_;t[7]!==s.length||t[8]!==g?(_=e=>{if(s.length===0)return;let t=null;e.key===`ArrowRight`?t=(g+1)%s.length:e.key===`ArrowLeft`?t=(g-1+s.length)%s.length:e.key===`Home`?t=0:e.key===`End`&&(t=s.length-1),t!==null&&(e.preventDefault(),a(t),(u.current?.querySelectorAll(`[role="tab"]`))?.[t]?.focus())},t[7]=s.length,t[8]=g,t[9]=_):_=t[9];let v=_,y=n?`Tabs: ${n}`:`Tabs`,b;if(t[10]!==s||t[11]!==g){let e;t[13]===g?e=t[14]:(e=e=>(0,X.jsx)(`button`,{id:e.panelId?`${e.panelId}-tab`:void 0,type:`button`,role:`tab`,className:`tabs-strip-pill`,"data-active":e.index===g,"aria-selected":e.index===g,"aria-controls":e.panelId??void 0,tabIndex:e.index===g?0:-1,onMouseDown:MA,onClick:()=>a(e.index),children:e.label},e.index),t[13]=g,t[14]=e),b=s.map(e),t[10]=s,t[11]=g,t[12]=b}else b=t[12];let x;t[15]!==v||t[16]!==y||t[17]!==b?(x=(0,X.jsx)(`div`,{ref:u,role:`tablist`,"aria-label":y,className:`tabs-strip`,contentEditable:!1,onKeyDown:v,children:b}),t[15]=v,t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]!==r||t[20]!==g?(S=(0,X.jsx)(`div`,{ref:l,className:`tabs-content`,"data-active-index":g,children:r}),t[19]=r,t[20]=g,t[21]=S):S=t[21];let C;return t[22]!==n||t[23]!==S||t[24]!==x?(C=(0,X.jsxs)(`div`,{className:`tabs`,id:n,children:[x,S]}),t[22]=n,t[23]=S,t[24]=x,t[25]=C):C=t[25],C}function MA(e){return e.preventDefault()}var NA=typeof global<`u`&&{}.toString.call(global)===`[object global]`,PA=typeof Bun<`u`,FA=typeof Deno<`u`,IA=typeof WebSocketPair==`function`&&caches?.default!==void 0,LA=NA||PA||FA||IA;function RA(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function zA(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function BA(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function VA(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function HA(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function UA(e){let t=(e||``).match(/^(?:https?:)?(?:\/\/)?([^/?]+)/),n=(t&&t[1]||``).replace(`player.`,``);for(let e of[`.videoji.hk`,`.vimeo.work`,`.videoji.cn`])if(n.endsWith(e))return n;return`vimeo.com`}function WA(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.id,n=e.url,r=t||n;if(!r)throw Error(`An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.`);if(BA(r))return`https://vimeo.com/${r}`;if(VA(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var GA=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`addEventListener`,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`removeEventListener`,a=typeof t==`string`?[t]:t;return a.forEach(t=>{e[r](t,n)}),{cancel:()=>a.forEach(t=>e[i](t,n))}};function KA(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:document;if(!e||!t||typeof t.querySelectorAll!=`function`)return null;let n=t.querySelectorAll(`iframe`);for(let t=0;t<n.length;t++)if(n[t]&&n[t].contentWindow===e)return n[t];return null}var qA=Array.prototype.indexOf!==void 0,JA=typeof window<`u`&&window.postMessage!==void 0;if(!LA&&(!qA||!JA))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var YA=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function XA(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e){if(e.WeakMap)return;var t=Object.prototype.hasOwnProperty,n=Object.defineProperty&&function(){try{return Object.defineProperty({},`x`,{value:1}).x===1}catch{}}(),r=function(e,t,r){n?Object.defineProperty(e,t,{configurable:!0,writable:!0,value:r}):e[t]=r};e.WeakMap=function(){function e(){if(this===void 0)throw TypeError(`Constructor WeakMap requires 'new'`);if(r(this,`_id`,a(`_WeakMap`)),arguments.length>0)throw TypeError(`WeakMap iterable is not supported`)}r(e.prototype,`delete`,function(e){if(n(this,`delete`),!i(e))return!1;var t=e[this._id];return t&&t[0]===e?(delete e[this._id],!0):!1}),r(e.prototype,`get`,function(e){if(n(this,`get`),i(e)){var t=e[this._id];if(t&&t[0]===e)return t[1]}}),r(e.prototype,`has`,function(e){if(n(this,`has`),!i(e))return!1;var t=e[this._id];return!!(t&&t[0]===e)}),r(e.prototype,`set`,function(e,t){if(n(this,`set`),!i(e))throw TypeError(`Invalid value used as weak map key`);var a=e[this._id];return a&&a[0]===e?(a[1]=t,this):(r(e,this._id,[e,t]),this)});function n(e,n){if(!i(e)||!t.call(e,`_id`))throw TypeError(n+` method called on incompatible receiver `+typeof e)}function a(e){return e+`_`+o()+`.`+o()}function o(){return Math.random().toString().substring(2)}return r(e,`_polyfill`,!0),e}();function i(e){return Object(e)===e}})(typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:YA);var ZA=XA(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,YA,function(){var e,t,n,r=Object.prototype.toString,i=typeof setImmediate<`u`?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},`x`,{}),e=function(e,t,n,r){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:r!==!1})}}catch{e=function(e,t,n){return e[t]=n,e}}n=function(){var e,n,r;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,a){r=new i(t,a),n?n.next=r:e=r,n=r,r=void 0},drain:function(){var r=e;for(e=n=t=void 0;r;)r.fn.call(r.self),r=r.next}}}();function a(e,r){n.add(e,r),t||=i(n.drain)}function o(e){var t,n=typeof e;return e!=null&&(n==`object`||n==`function`)&&(t=e.then),typeof t==`function`?t:!1}function s(){for(var e=0;e<this.chain.length;e++)c(this,this.state===1?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,t,n){var r,i;try{t===!1?n.reject(e.msg):(r=t===!0?e.msg:t.call(void 0,e.msg),r===n.promise?n.reject(TypeError(`Promise-chain cycle`)):(i=o(r))?i.call(r,n.resolve,n.reject):n.resolve(r))}catch(e){n.reject(e)}}function l(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=o(e))?a(function(){var r=new f(n);try{t.call(e,function(){l.apply(r,arguments)},function(){u.apply(r,arguments)})}catch(e){u.call(r,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&a(s,n))}catch(e){u.call(new f(n),e)}}}function u(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&a(s,t))}function d(e,t,n,r){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},r)})(i)}function f(e){this.def=e,this.triggered=!1}function p(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function m(e){if(typeof e!=`function`)throw TypeError(`Not a function`);if(this.__NPO__!==0)throw TypeError(`Not a promise`);this.__NPO__=1;var t=new p(this);this.then=function(e,n){var r={success:typeof e==`function`?e:!0,failure:typeof n==`function`?n:!1};return r.promise=new this.constructor(function(e,t){if(typeof e!=`function`||typeof t!=`function`)throw TypeError(`Not a function`);r.resolve=e,r.reject=t}),t.chain.push(r),t.state!==0&&a(s,t),r.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){l.call(t,e)},function(e){u.call(t,e)})}catch(e){u.call(t,e)}}var h=e({},`constructor`,m,!1);return m.prototype=h,e(h,`__NPO__`,0,!1),e(m,`resolve`,function(e){var t=this;return e&&typeof e==`object`&&e.__NPO__===1?e:new t(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);t(e)})}),e(m,`reject`,function(e){return new this(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);n(e)})}),e(m,`all`,function(e){var t=this;return r.call(e)==`[object Array]`?e.length===0?t.resolve([]):new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);var i=e.length,a=Array(i),o=0;d(t,e,function(e,t){a[e]=t,++o===i&&n(a)},r)}):t.reject(TypeError(`Not an array`))}),e(m,`race`,function(e){var t=this;return r.call(e)==`[object Array]`?new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);d(t,e,function(e,t){n(t)},r)}):t.reject(TypeError(`Not an array`))}),m})}),QA=new WeakMap;function $A(e,t,n){let r=QA.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),QA.set(e.element,r)}function ej(e,t){return(QA.get(e.element)||{})[t]||[]}function tj(e,t,n){let r=QA.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],QA.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),QA.set(e.element,r),r[t]&&r[t].length===0}function nj(e,t){let n=ej(e,t);if(n.length<1)return!1;let r=n.shift();return tj(e,t,r),r}function rj(e,t){let n=QA.get(e);QA.set(t,n),QA.delete(e)}function ij(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function aj(e,t,n){if(!e.element.contentWindow||!e.element.contentWindow.postMessage)return;let r={method:t};n!==void 0&&(r.value=n);let i=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,`$1`));i>=8&&i<10&&(r=JSON.stringify(r)),e.element.contentWindow.postMessage(r,e.origin)}function oj(e,t){t=ij(t);let n=[],r;if(t.event)t.event===`error`&&ej(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),tj(e,t.data.method,n)}),n=ej(e,`event:${t.event}`),r=t.data;else if(t.method){let i=nj(e,t.method);i&&(n.push(i),r=t.value)}n.forEach(t=>{try{if(typeof t==`function`){t.call(e,r);return}t.resolve(r)}catch{}})}var sj=`airplay.audio_tracks.audiotrack.autopause.autoplay.background.byline.cc.chapter_id.chapters.chromecast.color.colors.controls.disable_context_menu.dnt.end_time.fullscreen.height.id.initial_quality.interactive_params.keyboard.loop.maxheight.max_quality.maxwidth.min_quality.muted.play_button_position.playsinline.portrait.preload.progress_bar.quality.quality_selector.responsive.skipping_forward.speed.start_time.texttrack.thumbnail_id.title.transcript.transparent.unmute_button.url.vimeo_logo.volume.watch_full_video.width`.split(`.`);function cj(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return sj.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function lj(e,t){let{html:n}=e;if(!t)throw TypeError(`An element must be provided`);if(t.getAttribute(`data-vimeo-initialized`)!==null)return t.querySelector(`iframe`);let r=document.createElement(`div`);return r.innerHTML=n,t.appendChild(r.firstChild),t.setAttribute(`data-vimeo-initialized`,`true`),t.querySelector(`iframe`)}function uj(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((r,i)=>{if(!VA(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${UA(e)}/api/oembed.json?url=${encodeURIComponent(e)}`;for(let e in t)t.hasOwnProperty(e)&&(a+=`&${e}=${encodeURIComponent(t[e])}`);let o=`XDomainRequest`in window?new XDomainRequest:new XMLHttpRequest;o.open(`GET`,a,!0),o.onload=function(){if(o.status===404){i(Error(`“${e}” was not found.`));return}if(o.status===403){i(Error(`“${e}” is not embeddable.`));return}try{let t=JSON.parse(o.responseText);if(t.domain_status_code===403){lj(t,n),i(Error(`“${e}” is not embeddable.`));return}r(t)}catch(e){i(e)}},o.onerror=function(){let e=o.status?` (${o.status})`:``;i(Error(`There was an error fetching the embed code from Vimeo${e}.`))},o.send()})}function dj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document,t=[].slice.call(e.querySelectorAll(`[data-vimeo-id], [data-vimeo-url]`)),n=e=>{`console`in window&&console.error&&console.error(`There was an error creating an embed: ${e}`)};t.forEach(e=>{try{if(e.getAttribute(`data-vimeo-defer`)!==null)return;let t=cj(e);uj(WA(t),t,e).then(t=>lj(t,e)).catch(n)}catch(e){n(e)}})}function fj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoPlayerResizeEmbeds_||(window.VimeoPlayerResizeEmbeds_=!0,window.addEventListener(`message`,t=>{if(!VA(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?KA(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function pj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!VA(t.origin))return;let n=ij(t.data);if(!n||n.event!==`ready`)return;let r=t.source?KA(t.source,e):null;r&&HA(r.src)&&new Sj(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function mj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;if(window.VimeoCheckedUrlTimeParam)return;window.VimeoCheckedUrlTimeParam=!0;let t=e=>{`console`in window&&console.error&&console.error(`There was an error getting video Id: ${e}`)};window.addEventListener(`message`,n=>{if(!VA(n.origin))return;let r=ij(n.data);if(!r||r.event!==`ready`)return;let i=n.source?KA(n.source,e):null;if(i&&HA(i.src)){let e=new Sj(i);e.getVideoId().then(t=>{let n=RegExp(`[?&]vimeo_t_${t}=([^&#]*)`).exec(window.location.href);if(n&&n[1]){let t=decodeURI(n[1]);e.setCurrentTime(t)}}).catch(t)}})}function hj(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!VA(e.origin))return;let t=ij(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?KA(e.source):null;if(!n)return;let r=n.getAttribute(`allow`)||``;if(!r.includes(`encrypted-media`)){n.setAttribute(`allow`,`${r}; encrypted-media`);let e=new URL(n.getAttribute(`src`));e.searchParams.set(`forcereload`,`drm`),n.setAttribute(`src`,e.toString());return}}))}function gj(){let e=function(){let e,t=[[`requestFullscreen`,`exitFullscreen`,`fullscreenElement`,`fullscreenEnabled`,`fullscreenchange`,`fullscreenerror`],[`webkitRequestFullscreen`,`webkitExitFullscreen`,`webkitFullscreenElement`,`webkitFullscreenEnabled`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`webkitRequestFullScreen`,`webkitCancelFullScreen`,`webkitCurrentFullScreenElement`,`webkitCancelFullScreen`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`mozRequestFullScreen`,`mozCancelFullScreen`,`mozFullScreenElement`,`mozFullScreenEnabled`,`mozfullscreenchange`,`mozfullscreenerror`],[`msRequestFullscreen`,`msExitFullscreen`,`msFullscreenElement`,`msFullscreenEnabled`,`MSFullscreenChange`,`MSFullscreenError`]],n=0,r=t.length,i={};for(;n<r;n++)if(e=t[n],e&&e[1]in document){for(n=0;n<e.length;n++)i[t[0][n]]=e[n];return i}return!1}(),t={fullscreenchange:e.fullscreenchange,fullscreenerror:e.fullscreenerror},n={request(t){return new Promise((r,i)=>{let a=function(){n.off(`fullscreenchange`,a),r()};n.on(`fullscreenchange`,a),t||=document.documentElement;let o=t[e.requestFullscreen]();o instanceof Promise&&o.then(a).catch(i)})},exit(){return new Promise((t,r)=>{if(!n.isFullscreen){t();return}let i=function(){n.off(`fullscreenchange`,i),t()};n.on(`fullscreenchange`,i);let a=document[e.exitFullscreen]();a instanceof Promise&&a.then(i).catch(r)})},on(e,n){let r=t[e];r&&document.addEventListener(r,n)},off(e,n){let r=t[e];r&&document.removeEventListener(r,n)}};return Object.defineProperties(n,{isFullscreen:{get(){return!!document[e.fullscreenElement]}},element:{enumerable:!0,get(){return document[e.fullscreenElement]}},isEnabled:{enumerable:!0,get(){return!!document[e.fullscreenEnabled]}}}),n}var _j={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},vj=class extends EventTarget{logger;constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;super(),this.logger=r,this.init(t,e,{..._j,...n})}disconnect(){this.dispatchEvent(new Event(`disconnect`))}async init(e,t,n){if(await this.waitForTOReadyState(e,`open`),n.role===`viewer`){await this.updatePlayer(e,t,n);let r=GA(e,`change`,()=>this.updatePlayer(e,t,n)),i=this.maintainPlaybackPosition(e,t,n);this.addEventListener(`disconnect`,()=>{i.cancel(),r.cancel()})}else{await this.updateTimingObject(e,t);let n=GA(t,[`seeked`,`play`,`pause`,`ratechange`],()=>this.updateTimingObject(e,t),`on`,`off`);this.addEventListener(`disconnect`,()=>n.cancel())}}async updateTimingObject(e,t){let[n,r,i]=await Promise.all([t.getCurrentTime(),t.getPaused(),t.getPlaybackRate()]);e.update({position:n,velocity:r?0:i})}async updatePlayer(e,t,n){let{position:r,velocity:i}=e.query();typeof r==`number`&&t.setCurrentTime(r),typeof i==`number`&&(i===0?await t.getPaused()===!1&&t.pause():i>0&&(await t.getPaused()===!0&&(await t.play().catch(async e=>{e.name===`NotAllowedError`&&n.autoPlayMuted&&(await t.setMuted(!0),await t.play().catch(e=>console.error(`Couldn't play the video from TimingSrcConnector. Error:`,e)))}),this.updatePlayer(e,t,n)),await t.getPlaybackRate()!==i&&t.setPlaybackRate(i)))}maintainPlaybackPosition(e,t,n){let{allowedDrift:r,maxAllowedDrift:i,minCheckInterval:a,maxRateAdjustment:o,maxTimeToCatchUp:s}=n,c=Math.min(s,Math.max(a,i))*1e3,l=async()=>{if(e.query().velocity===0||await t.getPaused()===!0)return;let n=e.query().position-await t.getCurrentTime(),a=Math.abs(n);if(this.log(`Drift: ${n}`),a>i)await this.adjustSpeed(t,0),t.setCurrentTime(e.query().position),this.log(`Resync by currentTime`);else if(a>r){let e=a/s,r=o,i=e<r?(r-e)/2:r;await this.adjustSpeed(t,i*Math.sign(n)),this.log(`Resync by playbackRate`)}},u=setInterval(()=>l(),c);return{cancel:()=>clearInterval(u)}}log(e){this.logger?.(`TimingSrcConnector: ${e}`)}speedAdjustment=0;adjustSpeed=async(e,t)=>{if(this.speedAdjustment===t)return;let n=await e.getPlaybackRate()-this.speedAdjustment+t;this.log(`New playbackRate: ${n}`),await e.setPlaybackRate(n),this.speedAdjustment=t};waitForTOReadyState(e,t){return new Promise(n=>{let r=()=>{e.readyState===t?n():e.addEventListener(`readystatechange`,r,{once:!0})};r()})}},yj=new WeakMap,bj=new WeakMap,xj={},Sj=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn(`A jQuery object with multiple elements was passed, using the first element.`),e=e[0]),typeof document<`u`&&typeof e==`string`&&(e=document.getElementById(e)),!zA(e))throw TypeError(`You must pass either a valid element or a valid id.`);if(e.nodeName!==`IFRAME`){let t=e.querySelector(`iframe`);t&&(e=t)}if(e.nodeName===`IFRAME`&&!VA(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(yj.has(e))return yj.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new ZA((n,r)=>{if(this._onMessage=e=>{if(!VA(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=ij(e.data);if(t&&t.event===`error`&&t.data&&t.data.method===`ready`){let e=Error(t.data.message);e.name=t.data.name,r(e);return}let i=t&&t.event===`ready`,a=t&&t.method===`ping`;if(i||a){this.element.setAttribute(`data-ready`,`true`),n();return}oj(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=cj(e,t);uj(WA(n),n,e).then(t=>{let n=lj(t,e);return this.element=n,this._originalElement=e,rj(e,n),yj.set(this.element,this),t}).catch(r)}});if(bj.set(this,n),yj.set(this.element,this),this.element.nodeName===`IFRAME`&&aj(this,`ping`),xj.isEnabled){let e=()=>xj.exit();this.fullscreenchangeHandler=()=>{xj.isFullscreen?$A(this,`event:exitFullscreen`,e):tj(this,`event:exitFullscreen`,e),this.ready().then(()=>{aj(this,`fullscreenchange`,xj.isFullscreen)})},xj.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return VA(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new ZA((n,r)=>this.ready().then(()=>{$A(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),aj(this,e,t)}).catch(r))}get(e){return new ZA((t,n)=>(e=RA(e,`get`),this.ready().then(()=>{$A(this,e,{resolve:t,reject:n}),aj(this,e)}).catch(n)))}set(e,t){return new ZA((n,r)=>{if(e=RA(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{$A(this,e,{resolve:n,reject:r}),aj(this,e,t)}).catch(r)})}on(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(!t)throw TypeError(`You must pass a callback function.`);if(typeof t!=`function`)throw TypeError(`The callback must be a function.`);ej(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),$A(this,`event:${e}`,t)}off(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(t&&typeof t!=`function`)throw TypeError(`The callback must be a function.`);tj(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=bj.get(this)||new ZA((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return ZA.resolve(e)}addCuePoint(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.callMethod(`addCuePoint`,{time:e,data:t})}removeCuePoint(e){return this.callMethod(`removeCuePoint`,e)}enableTextTrack(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`enableTextTrack`,{language:e,kind:t,showing:n})}disableTextTrack(){return this.callMethod(`disableTextTrack`)}selectAudioTrack(e,t){if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`selectAudioTrack`,{language:e,kind:t})}selectDefaultAudioTrack(){return this.callMethod(`selectDefaultAudioTrack`)}pause(){return this.callMethod(`pause`)}play(){return this.callMethod(`play`)}requestFullscreen(){return xj.isEnabled?xj.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return xj.isEnabled?xj.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return xj.isEnabled?ZA.resolve(xj.isFullscreen):this.get(`fullscreen`)}requestPictureInPicture(){return this.callMethod(`requestPictureInPicture`)}exitPictureInPicture(){return this.callMethod(`exitPictureInPicture`)}getPictureInPicture(){return this.get(`pictureInPicture`)}remotePlaybackPrompt(){return this.callMethod(`remotePlaybackPrompt`)}unload(){return this.callMethod(`unload`)}destroy(){return new ZA(e=>{if(bj.delete(this),yj.delete(this.element),this._originalElement&&(yj.delete(this._originalElement),this._originalElement.removeAttribute(`data-vimeo-initialized`)),this.element&&this.element.nodeName===`IFRAME`&&this.element.parentNode&&(this.element.parentNode.parentNode&&this._originalElement&&this._originalElement!==this.element.parentNode?this.element.parentNode.parentNode.removeChild(this.element.parentNode):this.element.parentNode.removeChild(this.element)),this.element&&this.element.nodeName===`DIV`&&this.element.parentNode){this.element.removeAttribute(`data-vimeo-initialized`);let e=this.element.querySelector(`iframe`);e&&e.parentNode&&(e.parentNode.parentNode&&this._originalElement&&this._originalElement!==e.parentNode?e.parentNode.parentNode.removeChild(e.parentNode):e.parentNode.removeChild(e))}this._window.removeEventListener(`message`,this._onMessage),xj.isEnabled&&xj.off(`fullscreenchange`,this.fullscreenchangeHandler),e()})}getAutopause(){return this.get(`autopause`)}setAutopause(e){return this.set(`autopause`,e)}getBuffered(){return this.get(`buffered`)}getCameraProps(){return this.get(`cameraProps`)}setCameraProps(e){return this.set(`cameraProps`,e)}getChapters(){return this.get(`chapters`)}getCurrentChapter(){return this.get(`currentChapter`)}getColor(){return this.get(`color`)}getColors(){return ZA.all([this.get(`colorOne`),this.get(`colorTwo`),this.get(`colorThree`),this.get(`colorFour`)])}setColor(e){return this.set(`color`,e)}setColors(e){if(!Array.isArray(e))return new ZA((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new ZA(e=>e(null)),n=[e[0]?this.set(`colorOne`,e[0]):t,e[1]?this.set(`colorTwo`,e[1]):t,e[2]?this.set(`colorThree`,e[2]):t,e[3]?this.set(`colorFour`,e[3]):t];return ZA.all(n)}getCuePoints(){return this.get(`cuePoints`)}getCurrentTime(){return this.get(`currentTime`)}setCurrentTime(e){return this.set(`currentTime`,e)}getDuration(){return this.get(`duration`)}getEnded(){return this.get(`ended`)}getLoop(){return this.get(`loop`)}setLoop(e){return this.set(`loop`,e)}setMuted(e){return this.set(`muted`,e)}getMuted(){return this.get(`muted`)}getPaused(){return this.get(`paused`)}getPlaybackRate(){return this.get(`playbackRate`)}setPlaybackRate(e){return this.set(`playbackRate`,e)}getPlayed(){return this.get(`played`)}getQualities(){return this.get(`qualities`)}getQuality(){return this.get(`quality`)}setQuality(e){return this.set(`quality`,e)}getRemotePlaybackAvailability(){return this.get(`remotePlaybackAvailability`)}getRemotePlaybackState(){return this.get(`remotePlaybackState`)}getSeekable(){return this.get(`seekable`)}getSeeking(){return this.get(`seeking`)}getTextTracks(){return this.get(`textTracks`)}getAudioTracks(){return this.get(`audioTracks`)}getEnabledAudioTrack(){return this.get(`enabledAudioTrack`)}getDefaultAudioTrack(){return this.get(`defaultAudioTrack`)}getVideoEmbedCode(){return this.get(`videoEmbedCode`)}getVideoId(){return this.get(`videoId`)}getVideoTitle(){return this.get(`videoTitle`)}getVideoWidth(){return this.get(`videoWidth`)}getVideoHeight(){return this.get(`videoHeight`)}getVideoUrl(){return this.get(`videoUrl`)}getVolume(){return this.get(`volume`)}setVolume(e){return this.set(`volume`,e)}async setTimingSrc(e,t){if(!e)throw TypeError(`A Timing Object must be provided.`);await this.ready();let n=new vj(this,e,t);return aj(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>aj(this,`notifyTimingObjectDisconnect`)),n}};LA||(xj=gj(),dj(),fj(),pj(),mj(),hj());function Cj(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,wj(e,t)}function wj(e,t){return wj=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},wj(e,t)}var Tj={play:`onPlay`,playing:`onPlaying`,pause:`onPause`,ended:`onEnd`,timeupdate:`onTimeUpdate`,progress:`onProgress`,seeked:`onSeeked`,texttrackchange:`onTextTrackChange`,cuechange:`onCueChange`,cuepoint:`onCuePoint`,volumechange:`onVolumeChange`,playbackratechange:`onPlaybackRateChange`,error:`onError`,loaded:`onLoaded`},Ej=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}Cj(t,e);var n=t.prototype;return n.componentDidMount=function(){this.createPlayer()},n.componentDidUpdate=function(e){var t=this,n=Object.keys(this.props).filter(function(n){return t.props[n]!==e[n]});this.updateProps(n)},n.componentWillUnmount=function(){this.player.destroy()},n.getInitialOptions=function(){var e,t=this.props.video,n=/^https?:/i.test(t)?`url`:`id`;return e={},e[n]=t,e.width=this.props.width,e.height=this.props.height,e.autopause=this.props.autopause,e.autoplay=this.props.autoplay,e.byline=this.props.showByline,e.color=this.props.color,e.controls=this.props.controls,e.loop=this.props.loop,e.portrait=this.props.showPortrait,e.title=this.props.showTitle,e.muted=this.props.muted,e.background=this.props.background,e.responsive=this.props.responsive,e.dnt=this.props.dnt,e.speed=this.props.speed,e.keyboard=this.props.keyboard,e.pip=this.props.pip,e.playsinline=this.props.playsInline,e.quality=this.props.quality,e.texttrack=this.props.textTrack,e.transparent=this.props.transparent,e},n.updateProps=function(e){var t=this,n=this.player;e.forEach(function(e){var r=t.props[e];switch(e){case`autopause`:n.setAutopause(r);break;case`color`:n.setColor(r);break;case`loop`:n.setLoop(r);break;case`volume`:n.setVolume(r);break;case`paused`:n.getPaused().then(function(e){return r&&!e?n.pause():!r&&e?n.play():null});break;case`width`:case`height`:n.element[e]=r;break;case`video`:if(r){var i=t.props.start,a=n.loadVideo(r);typeof i==`number`&&a.then(function(){n.setCurrentTime(i)})}else n.unload();break;case`playbackRate`:n.setPlaybackRate(r);break;case`quality`:n.setQuality(r);break}})},n.createPlayer=function(){var e=this,t=this.props,n=t.start,r=t.volume,i=t.playbackRate;this.player=new Sj(this.container,this.getInitialOptions()),Object.keys(Tj).forEach(function(t){var n=Tj[t];e.player.on(t,function(t){var r=e.props[n];r&&r(t)})});var a=this.props,o=a.onError,s=a.onReady;this.player.ready().then(function(){s&&s(e.player)},function(e){if(o)o(e);else throw e}),typeof n==`number`&&this.player.setCurrentTime(n),typeof r==`number`&&this.updateProps([`volume`]),typeof i==`number`&&this.updateProps([`playbackRate`])},n.refContainer=function(e){this.container=e},n.render=function(){var e=this.props,t=e.id,n=e.className,r=e.style;return Y.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Y.Component);Ej.defaultProps={autopause:!0,autoplay:!1,showByline:!0,controls:!0,loop:!1,showPortrait:!0,showTitle:!0,muted:!1,background:!1,responsive:!1,dnt:!1,speed:!1,keyboard:!0,pip:!1,playsInline:!0,transparent:!0};var Dj={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},Oj=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Y.useState)(``);return(0,Y.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Dj[r],c=new Image;c.onload=()=>{c.width<s?a(o):a(i)},c.onerror=()=>a(o),c.src=i},[e,t,n,r]),i};function kj(e,t,n,r,i){let a={"@context":`https://schema.org`,"@type":`VideoObject`,name:i?.name||t,thumbnailUrl:[i?.thumbnailUrl||n],embedUrl:i?.embedUrl||`${r}/embed/${e}`,contentUrl:i?.contentUrl||`https://www.youtube.com/watch?v=${e}`,...i?.description&&{description:i.description},...i?.uploadDate&&{uploadDate:i.uploadDate},...i?.duration&&{duration:i.duration}};return JSON.stringify(a)}function Aj(e,t){let[n,r]=Y.useState(!1),[i,a]=Y.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Y.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Y.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Y.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?Oj(e.id,_,g,l):null,y=Y.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Y.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Y.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Y.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,X.jsxs)(X.Fragment,{children:[!e.lazyLoad&&(0,X.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,X.jsx)(X.Fragment,{children:n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:p}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,X.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:kj(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,X.jsx)(`noscript`,{children:(0,X.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,X.jsxs)(k,{onPointerOver:j,onClick:M,className:`${E} ${i?b:``}`,"data-title":c,role:!i&&!e.lazyLoad?`img`:void 0,"aria-label":i?void 0:`${c} - YouTube video preview`,style:{...!e.lazyLoad&&{backgroundImage:`url(${y})`},"--aspect-ratio":`${S/C*100}%`,...e.style||{}},children:[e.lazyLoad&&!i&&(0,X.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,X.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,X.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,X.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,X.jsx)(`iframe`,{ref:t,className:w,title:c,width:`560`,height:`315`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,src:m,referrerPolicy:e.referrerPolicy||`strict-origin-when-cross-origin`})]})]})}var jj=Y.forwardRef(Aj);function Mj(e){return e!==!1}function Nj(e,t){let n=[];return t.startSeconds!==null&&n.push(`start=${t.startSeconds}`),e.controls===!1&&n.push(`controls=0`),e.loop===!0&&n.push(`loop=1`,`playlist=${t.id}`),e.playsinline===!0&&n.push(`playsinline=1`),n.length>0?n.join(`&`):void 0}function Pj(e){if(e.width!==void 0)return{width:e.width}}function Fj(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function Ij(e){let t=(0,J.c)(23),n=(0,Y.useRef)(null),r=e.title??`Vimeo video player`,i;t[0]===r?i=t[1]:(i=e=>{let t=e;n.current=t,t.element&&(t.element.title=r)},t[0]=r,t[1]=i);let a=i,o,s;t[2]===r?(o=t[3],s=t[4]):(o=()=>{let e=n.current;e?.element&&(e.element.title=r)},s=[r],t[2]=r,t[3]=o,t[4]=s),(0,Y.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=Pj(e),t[5]=e,t[6]=c);let l=e.width===void 0,u=e.autoplay===!0,d=e.muted===!0,f=e.muted===!0?0:1,p=e.loop===!0,m=e.controls!==!1,h=e.playsinline!==!1,g;t[7]!==a||t[8]!==e.height||t[9]!==e.src||t[10]!==e.width||t[11]!==h||t[12]!==l||t[13]!==u||t[14]!==d||t[15]!==f||t[16]!==p||t[17]!==m?(g=(0,X.jsx)(Ej,{video:e.src,responsive:l,width:e.width,height:e.height,autoplay:u,muted:d,volume:f,loop:p,controls:m,playsInline:h,onReady:a}),t[7]=a,t[8]=e.height,t[9]=e.src,t[10]=e.width,t[11]=h,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=g):g=t[18];let _;return t[19]!==e.title||t[20]!==g||t[21]!==c?(_=(0,X.jsx)(`div`,{className:`ok-video ok-video-vimeo`,style:c,title:e.title,children:g}),t[19]=e.title,t[20]=g,t[21]=c,t[22]=_):_=t[22],_}function Lj(e){let t=(0,J.c)(17),n;t[0]===e.src?n=t[1]:(n=d(e.src),t[0]=e.src,t[1]=n);let r=n;if(!r)return null;let i;t[2]!==r.startRaw||t[3]!==e.autoplay||t[4]!==e.muted?(i=[],r.startRaw!==null&&i.push(`t=${r.startRaw}`),e.autoplay===!0&&i.push(`autoplay=true`),e.muted===!0&&i.push(`muted=true`),t[2]=r.startRaw,t[3]=e.autoplay,t[4]=e.muted,t[5]=i):i=t[5];let a=i.length>0?`https://www.loom.com/embed/${r.id}?${i.join(`&`)}`:`https://www.loom.com/embed/${r.id}`,o;t[6]===e?o=t[7]:(o=Pj(e),t[6]=e,t[7]=o);let s=e.title??`Loom video player`,c;t[8]!==a||t[9]!==e.height||t[10]!==e.width||t[11]!==s?(c=(0,X.jsx)(`iframe`,{className:`ok-video-loom-iframe`,src:a,title:s,width:e.width,height:e.height,allow:`autoplay; fullscreen`,referrerPolicy:`strict-origin-when-cross-origin`,allowFullScreen:!0}),t[8]=a,t[9]=e.height,t[10]=e.width,t[11]=s,t[12]=c):c=t[12];let l;return t[13]!==e.title||t[14]!==o||t[15]!==c?(l=(0,X.jsx)(`div`,{className:`ok-video ok-video-loom`,style:o,title:e.title,children:c}),t[13]=e.title,t[14]=o,t[15]=c,t[16]=l):l=t[16],l}function Rj(e){let t=(0,J.c)(29);if(e.src!==void 0&&He(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(Lj,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&ye(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,X.jsx)(Ij,{...e,src:e.src}),t[2]=e,t[3]=n),n}let n;if(t[4]!==e){n=Symbol.for(`react.early_return_sentinel`);bb0:{let r=e.src===void 0?null:U(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Pj(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:m(e.poster),t[6]=e.poster,t[7]=s);let c=(0,X.jsx)(jj,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Nj(e,r),muted:e.muted===!0,autoplay:e.autoplay===!0,alwaysLoadIframe:i,thumbnail:s,aspectWidth:a?Number(e.width):void 0,aspectHeight:a?Number(e.height):void 0,style:Fj(e)}),l;t[8]!==o||t[9]!==c?(l=(0,X.jsx)(`div`,{className:`ok-video ok-video-youtube`,style:o,children:c}),t[8]=o,t[9]=c,t[10]=l):l=t[10],n=l;break bb0}}t[4]=e,t[5]=n}else n=t[5];if(n!==Symbol.for(`react.early_return_sentinel`))return n;let r;t[11]===e.src?r=t[12]:(r=e.src===void 0?void 0:m(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=Mj(e.controls),t[13]=e.controls,t[14]=a);let o;t[15]===e.poster?o=t[16]:(o=e.poster===void 0?void 0:m(e.poster),t[15]=e.poster,t[16]=o);let s;return t[17]!==e.autoplay||t[18]!==e.height||t[19]!==e.loop||t[20]!==e.muted||t[21]!==e.playsinline||t[22]!==e.preload||t[23]!==e.title||t[24]!==e.width||t[25]!==r||t[26]!==a||t[27]!==o?(s=(0,X.jsx)(`video`,{className:`ok-video`,src:r,title:i,controls:a,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:o,preload:e.preload,width:e.width,height:e.height}),t[17]=e.autoplay,t[18]=e.height,t[19]=e.loop,t[20]=e.muted,t[21]=e.playsinline,t[22]=e.preload,t[23]=e.title,t[24]=e.width,t[25]=r,t[26]=a,t[27]=o,t[28]=s):s=t[28],s}function zj(e){let t=(0,J.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,X.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var Bj={Callout:WO,img:Bk,video:Rj,audio:RO,Pdf:bA,File:rk,Embed:tk,Accordion:IO,Tabs:jA,Tab:DA,Math:Uk,MermaidFence:Kk,Mirror:oA,MirrorSource:sA,"*":zj};function Vj(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var Hj=ie(),Uj=new Map;function Wj(e){if(e.surface===`compat`){let t=Bj[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:Vj(e.props)}}let t=Bj[e.name];return t?{Component:t,reactNodePropNames:Vj(e.props)}:null}for(let[e,t]of Hj.entries()){let n=Wj(t);n&&Uj.set(e,n)}function Gj(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function Kj(e){let t=Hj.getOrWildcard(e),n=Uj.get(t.name)??Uj.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return Gj(t,n)}function qj(){let e=[];for(let[t,n]of Hj.entries()){if(t===`*`)continue;let r=Uj.get(t);r&&e.push(Gj(n,r))}return e}var Jj=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,Yj=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,Xj={Callout:{description:{id:`322lyb`},props:{type:`note`,title:`Heads up`},children:`Callouts draw attention to key information.`},Accordion:{description:{id:`mWVJRX`},props:{title:`Click to expand`,defaultOpen:!0},children:`Hidden content goes here.`},img:{description:{id:`VUijjF`},props:{src:Jj,alt:`Sample image`}},video:{description:{id:`e1hptq`},props:{controls:!0,poster:Yj}},audio:{description:{id:`9jnjV0`},props:{controls:!0}},Math:{description:{id:`Y-Urt2`},props:{formula:`c = \\pm\\sqrt{a^2 + b^2}`}},Embed:{description:{id:`jTLWxh`},render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`https://example.com/embed`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:{id:`Fqr8BP`},render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,X.jsx)(`title`,{children:`Thumbnails`}),(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,X.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,X.jsx)(`span`,{children:`/ 12`})]}),(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,X.jsx)(`span`,{children:`100%`}),(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:{id:`z0a2EA`},render:()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,X.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,X.jsx)(`defs`,{children:(0,X.jsx)(`marker`,{id:`mermaid-preview-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,X.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,X.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,X.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,X.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,X.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:{id:`75Y1dk`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,X.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,X.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:(0,X.jsx)(o,{id:`m6YGpY`})})]})},Mirror:{description:{id:`8TLE9g`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`absolute -top-2 right-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(Ki,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`EL_YRd`,components:{0:(0,X.jsx)(`code`,{className:`font-mono`})}})})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`qNOgUu`})})]})},MirrorSource:{description:{id:`-KCZ6n`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`absolute -top-2 left-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(Wi,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`maDWIB`,components:{0:(0,X.jsx)(`code`,{className:`font-mono`})}})})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`emgiet`})})]})}};function Zj(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function Qj(e){let t=Kj(e),n=Zj(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var $j=new Set;function eM(e){$j.add(e)}function tM(e){if(typeof e==`number`)return $j.delete(e);let t=$j.values().next();return t.done?!1:($j.delete(t.value),!0)}function nM(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(eM(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function rM(e){return t=>{let n=new WeakSet;t.state.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&n.add(t)});let r=Qj(e.name);if(e.name===`Tabs`){let e=Qj(`Tab`),t=Qj(`Tab`),n=e.attrs,i=t.attrs;n.props={...n.props,label:`Tab 1`},i.props={...i.props,label:`Tab 2`},r.content=[e,t]}t.chain().focus().insertContent(r).run();let i=-1;t.state.doc.descendants((t,r)=>{if(i>=0)return!1;t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&!n.has(t)&&(i=r)}),!(i<0)&&nM(t,i,e)}}var iM=new Set([`File`,`Tab`]);function aM(){return[{name:`component-File`,label:z._({id:`J2eKUI`}),icon:Zi,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:sM,preview:{description:z._({id:`t-JXbf`}),render:()=>(0,X.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,X.jsx)(Zi,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function oM(){return[...qj().filter(e=>e.surface===`canonical`&&!iM.has(e.name)).map(e=>{let t=Xj[e.name],n=e.Component,r=t?{description:z._(t.description),render:t.render??(()=>(0,X.jsx)(n,{...t.props,children:t.children}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:NO(e.icon),category:e.category??`content`,command:rM(e),aliases:e.searchTerms,description:e.description,preview:r}}),...aM()]}function sM(e){let t=document.createElement(`input`);t.type=`file`,t.accept=`*/*`,t.style.display=`none`,t.addEventListener(`change`,()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;sO(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function cM(e,t){let n=fO.getState(e.state);if(!n)return null;for(let e of n.byId.values())if(e.markType===`link`&&e.from<=t&&t<e.to)return e.id;return null}function lM(){return[{name:`wikiLink`,label:z._({id:`mZHJju`}),icon:ma,category:`insert`,aliases:[`wiki`,`wikilink`,`[[`,`internal`,`page`,`backlink`,`cross-link`],description:"Link to another page (`[[page]]`) — opens a page picker",preview:{description:z._({id:`cqA3od`}),render:()=>(0,X.jsx)(`p`,{className:`text-sm leading-7`,children:(0,X.jsx)(o,{id:`u-9fWA`,components:{0:(0,X.jsx)(`span`,{className:`font-medium text-azure-blue underline underline-offset-2 dark:text-sky-blue`})}})})},command:e=>{e.chain().focus().insertContent(`[[`).run()}},{name:`externalLink`,label:z._({id:`0R4wMK`}),icon:Ki,category:`insert`,aliases:[`link`,`url`,`href`,`external`,`web`,`hyperlink`],description:"Link to an external URL (`https://…`)",preview:{description:z._({id:`ClDdyg`}),render:()=>(0,X.jsx)(`p`,{className:`text-sm leading-7`,children:(0,X.jsx)(o,{id:`QWT-Z9`,components:{0:(0,X.jsx)(`span`,{className:`font-medium text-azure-blue underline underline-offset-2 dark:text-sky-blue`}),1:(0,X.jsx)(`span`,{className:`text-[0.85em] opacity-60`})}})})},command:e=>{let t=e.state.selection.from;e.chain().focus().insertContent({type:`text`,text:`link`,marks:[{type:`link`,attrs:{href:`https://`}}]}).run();let n=cM(e,t);n&&(uO(n),requestAnimationFrame(()=>{jO(e).setActiveNode(n)}))}},{name:`component-Tag`,label:z._({id:`UL8A9w`}),icon:ra,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:z._({id:`5ClEAu`}),render:()=>(0,X.jsx)(`p`,{className:`text-sm leading-7`,children:(0,X.jsx)(o,{id:`KZLdgR`,components:{0:(0,X.jsx)(`a`,{className:`tag pointer-events-none`})}})})},command:e=>{e.chain().insertTag(``).run()}}]}function uM(e,t){e.chain().focus().insertContent({type:`codeBlock`,attrs:{language:`html`,meta:`preview`},content:[{type:`text`,text:t}]}).run()}var dM=`<div style="padding:20px;font-family:system-ui,sans-serif;color:var(--foreground)">
|
|
6
|
+
`);return/\s/.test(n)}):!1}var Hy=new G(`suggestion`);function Uy({pluginKey:e=Hy,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=By,shouldShow:g,shouldResetDismissed:_}){let v,y=p?.(),b=r&&!i,x=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},S=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,C=({match:e,dismissedRange:n,state:r,transaction:i})=>_?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:b})?!1:b?e.range.from===n.from:e.range.from===n.from&&!Vy(i);function w(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>d({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:S(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let T=new ln({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,g=p||u&&h,_=h||u,b=m||u&&h;if(!g&&!_&&!b)return;let x=b&&!g?c:l,C=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);v={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:C,clientRect:S(e,C)},g&&((r=y?.onBeforeStart)==null||r.call(y,v)),_&&((i=y?.onBeforeUpdate)==null||i.call(y,v)),(_||g)&&(v.items=await f({editor:t,query:x.query})),b&&((a=y?.onExit)==null||a.call(y,v)),_&&((o=y?.onUpdate)==null||o.call(y,v)),g&&((s=y?.onStart)==null||s.call(y,v))},destroy:()=>{var e;v&&((e=y?.onExit)==null||e.call(y,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:_,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(_||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:u,range:e.range,isActive:c.active})&&(!g||g({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!C({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=T.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=T.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),w(t,e),!0}return(y?.onKeyDown)?.call(y,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=T.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),Be.create(e.doc,[ut.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return T}var Wy=Uy;function Gy(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function Ky(e){if(e.kind===`create`){let t=e.value;return z._({id:`XPqe3B`,values:{tagValue:t}})}let t=z._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return z._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function qy(e){let t=(0,J.c)(38),{items:n,query:r,selectedIndex:a,onSelect:s,onHover:c,loading:l,error:u}=e,d=l===void 0?!1:l,f=u===void 0?null:u,{_:p}=i(),m=(0,Y.useRef)(null),h=(0,Y.useId)(),g=a>=0&&a<n.length?`${h}-option-${a}`:void 0,_,v;t[0]===a?(_=t[1],v=t[2]):(_=()=>{let e=m.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(a);t&&t.scrollIntoView({block:`nearest`})},v=[a],t[0]=a,t[1]=_,t[2]=v),(0,Y.useEffect)(_,v);let y=Jy;if(d){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:y,children:(0,X.jsx)(o,{id:`a_u4ck`})}),t[4]=n):n=t[4],n}if(n.length===0){let e;if(t[5]!==p||t[6]!==f||t[7]!==r){let n=r.trim();e=f??p(n?{id:`9R7pRC`,values:{trimmed:n}}:{id:`KRJ6xh`}),t[5]=p,t[6]=f,t[7]=r,t[8]=e}else e=t[8];let n=e,i;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[9]=i):i=t[9];let a;return t[10]===n?a=t[11]:(a=(0,X.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:y,children:n}),t[10]=n,t[11]=a),a}let b=a>=0&&a<n.length?n[a]:null,x;t[12]===p?x=t[13]:(x=p({id:`SCoBBH`}),t[12]=p,t[13]=x);let S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[14]=S):S=t[14];let C;t[15]===b?C=t[16]:(C=b?Ky(b):``,t[15]=b,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[17]=C,t[18]=w);let T;t[19]===f?T=t[20]:(T=f&&(0,X.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:f}),t[19]=f,t[20]=T);let E;if(t[21]!==n||t[22]!==h||t[23]!==c||t[24]!==s||t[25]!==a){let e;t[27]!==h||t[28]!==c||t[29]!==s||t[30]!==a?(e=(e,t)=>{let n=t===a,r=Gy(e),i=e.kind===`create`;return(0,X.jsxs)(`button`,{id:`${h}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":i?`tag-suggestion-create`:`tag-suggestion-tag-${e.value}`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),s(e)},onPointerMove:c?()=>c(t):void 0,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,X.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),i?(0,X.jsx)(`span`,{className:`shrink-0 rounded-sm bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`,children:(0,X.jsx)(o,{id:`isRobC`})}):(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[27]=h,t[28]=c,t[29]=s,t[30]=a,t[31]=e):e=t[31],E=n.map(e),t[21]=n,t[22]=h,t[23]=c,t[24]=s,t[25]=a,t[26]=E}else E=t[26];let D;return t[32]!==g||t[33]!==E||t[34]!==x||t[35]!==w||t[36]!==T?(D=(0,X.jsxs)(`div`,{ref:m,role:`listbox`,"aria-label":x,"aria-activedescendant":g,tabIndex:-1,onMouseDown:y,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:S,children:[w,T,E]}),t[32]=g,t[33]=E,t[34]=x,t[35]=w,t[36]=T,t[37]=D):D=t[37],D}function Jy(e){return e.preventDefault()}var Yy=new WeakMap;function Xy(e,t){Yy.set(e,t)}function Zy(e){return Yy.get(e)??!1}function Qy(e,t){let n=document.createElement(`div`);n.style.position=`fixed`,n.style.zIndex=`50`,n.style.visibility=`hidden`,document.body.appendChild(n);let r={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},i=!1,a=!1,o=()=>{n.isConnected&&(n.style.removeProperty(`--suggestion-menu-max-height`),we(r,n,{placement:`bottom-start`,middleware:[zt(4),Oe(),ee({padding:8}),Pe({apply({availableHeight:e}){n.isConnected&&n.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(e,window.innerHeight*.4)}px`)}})]}).then(({x:e,y:t})=>{n.isConnected&&(n.style.left=`${e}px`,n.style.top=`${t}px`,i&&!a&&(n.style.removeProperty(`visibility`),a=!0))}).catch(e=>{n.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:n,doPosition:o,startAutoUpdate:()=>k(r,n,o),reveal:()=>{a||(i=!0,o())}}}function $y(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var eb=new G(`tagSuggestion`),tb=8,nb=/^[a-zA-Z][\w/-]*$/;async function rb(){let e=await fetch(`/api/tags`);if(!e.ok)throw Error(`/api/tags responded with ${e.status}`);let t=await e.json();return Array.isArray(t.tags)?t.tags:[]}function ib(e,t){let n=t.trim(),r=n.toLowerCase(),i=n===``?e.slice():e.filter(e=>e.name.toLowerCase().includes(r));return i.sort((e,t)=>{let n=+!e.name.toLowerCase().startsWith(r),i=+!t.name.toLowerCase().startsWith(r);return n===i?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:n-i}),i}function ab(e,t){let n=ib(e,t).slice(0,tb).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&nb.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function ob(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``).match(/(^|[\s])#([a-zA-Z][\w/-]*)?$/);if(!n)return null;let r=n[2]??``,i=t.start(),a=n[1].length;return{range:{from:i+((n.index??0)+a),to:t.pos},query:r,text:`#${r}`}}function sb(e){let t=[],n=!1,r=null,i=null;return Wy({editor:e,pluginKey:eb,char:`#`,allowedPrefixes:null,findSuggestionMatch:ob,allow:({editor:e})=>!Zy(e),items:async({query:e})=>{if(!n){r||=rb();try{t=await r,i=null}catch(e){console.error(`[tag-suggestion] Failed to fetch tags:`,e),i=`Failed to load tags. Press Escape and type # again to retry, or continue typing to create a new tag.`,t=[]}finally{n=!0,r=null}}return ab(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!nb.test(r))return;e.chain().focus().deleteRange(t).insertContent({type:`tag`,attrs:{value:r}}).insertContent(` `).run()}catch(e){console.error(`[tag-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,a=null,o=0,s={popup:null,stopAutoUpdate:null},c=null,l=null,u=e=>{a?.command(e)},d=e=>{o!==e&&(o=e,p(null))};function f(e,t,r){let a=t===null?!n:t;return{items:e.items,query:e.query??``,selectedIndex:o,onSelect:r,onHover:d,loading:a,error:i}}let p=t=>{!e||!a||e.updateProps(f(a,t,u))};return{onBeforeStart(t){a=t,o=0;let n=Qy(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new Zl(qy,{props:f(t,!0,u),editor:t.editor}),n.popup.appendChild(e.element),s.stopAutoUpdate=n.startAutoUpdate()},onStart(e){a=e,o=0,p(null),l?.()},onUpdate(e){a=e,o=Math.min(o,Math.max(0,e.items.length-1)),p(null),c?.()},onKeyDown({event:e}){if(!a)return!1;let t=a.items;if(e.key===`ArrowDown`)return t.length===0?!1:(o=(o+1)%t.length,p(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(o=(o-1+t.length)%t.length,p(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[o];if(e)return a.command(e),!0;let n=(a.query??``).trim();return n&&nb.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){$y(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var cb=1,lb=.9,ub=.8,db=.17,fb=.1,pb=.999,mb=.9999,hb=.99,gb=/[\\\/_+.#"@\[\(\{&]/,_b=/[\\\/_+.#"@\[\(\{&]/g,vb=/[\s-]/,yb=/[\s-]/g;function bb(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?cb:hb;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=bb(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=cb:gb.test(e.charAt(l-1))?(d*=ub,p=e.slice(i,l-1).match(_b),p&&i>0&&(d*=pb**+p.length)):vb.test(e.charAt(l-1))?(d*=lb,m=e.slice(i,l-1).match(yb),m&&i>0&&(d*=pb**+m.length)):(d*=db,i>0&&(d*=pb**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=mb)),(d<fb&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=bb(e,t,n,r,l+1,a+2,o),f*fb>d&&(d=f*fb)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function xb(e){return e.toLowerCase().replace(yb,` `)}function Sb(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,bb(e,t,xb(e),xb(t),0,0,{})}var Cb=`[cmdk-group=""]`,wb=`[cmdk-group-items=""]`,Tb=`[cmdk-group-heading=""]`,Eb=`[cmdk-item=""]`,Db=`${Eb}:not([aria-disabled="true"])`,Ob=`cmdk-item-select`,kb=`data-value`,Ab=(e,t,n)=>Sb(e,t,n),jb=Y.createContext(void 0),Mb=()=>Y.useContext(jb),Nb=Y.createContext(void 0),Pb=()=>Y.useContext(Nb),Fb=Y.createContext(void 0),Ib=Y.forwardRef((e,t)=>{let n=Xb(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Xb(()=>new Set),i=Xb(()=>new Map),a=Xb(()=>new Map),o=Xb(()=>new Set),s=Jb(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Mn(),y=Mn(),b=Mn(),x=Y.useRef(null),S=$b();Yb(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Yb(()=>{S(6,k)},[]);let C=Y.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Y.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Ab;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(wb);t?t.appendChild(e.parentElement===t?e:e.closest(`${wb} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${wb} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Cb}[${kb}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(kb);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Cb)?.querySelector(Tb))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Eb}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Db)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(kb))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(kb))}function P(e){let t=A()?.closest(Cb),n;for(;t&&!n;)t=e>0?Kb(t,Cb):qb(t,Cb),n=t?.querySelector(Db);n?C.setState(`value`,n.getAttribute(kb)):N(e)}let F=()=>M(j().length-1),ee=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},I=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Y.createElement(On.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ee(e);break;case`ArrowDown`:ee(e);break;case`p`:case`k`:g&&e.ctrlKey&&I(e);break;case`ArrowUp`:I(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Ob);t.dispatchEvent(e)}}}}},Y.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:nx},c),tx(e,e=>Y.createElement(Nb.Provider,{value:C},Y.createElement(jb.Provider,{value:w},e))))}),Lb=Y.forwardRef((e,t)=>{let n=Mn(),r=Y.useRef(null),i=Y.useContext(Fb),a=Mb(),o=Jb(e),s=o.current?.forceMount??i?.forceMount;Yb(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Qb(n,r,[e.value,e.children,r],e.keywords),l=Pb(),u=Zb(e=>e.value&&e.value===c.current),d=Zb(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Y.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Ob,f),()=>t.removeEventListener(Ob,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Y.createElement(On.div,{ref:Ln(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Rb=Y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Mn(),s=Y.useRef(null),c=Y.useRef(null),l=Mn(),u=Mb(),d=Zb(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);Yb(()=>u.group(o),[]),Qb(o,s,[e.value,e.heading,c]);let f=Y.useMemo(()=>({id:o,forceMount:i}),[i]);return Y.createElement(On.div,{ref:Ln(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Y.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),tx(e,e=>Y.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Y.createElement(Fb.Provider,{value:f},e))))}),zb=Y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Y.useRef(null),a=Zb(e=>!e.search);return!n&&!a?null:Y.createElement(On.div,{ref:Ln(i,t),...r,"cmdk-separator":``,role:`separator`})}),Bb=Y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Pb(),o=Zb(e=>e.search),s=Zb(e=>e.selectedItemId),c=Mb();return Y.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Y.createElement(On.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Vb=Y.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Y.useRef(null),o=Y.useRef(null),s=Zb(e=>e.selectedItemId),c=Mb();return Y.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Y.createElement(On.div,{ref:Ln(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},tx(e,e=>Y.createElement(`div`,{ref:Ln(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Hb=Y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Y.createElement(Xn,{open:n,onOpenChange:r},Y.createElement(Hn,{container:o},Y.createElement(Vn,{"cmdk-overlay":``,className:i}),Y.createElement(er,{"aria-label":e.label,"cmdk-dialog":``,className:a},Y.createElement(Ib,{ref:t,...s}))))}),Ub=Y.forwardRef((e,t)=>Zb(e=>e.filtered.count===0)?Y.createElement(On.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Wb=Y.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Y.createElement(On.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},tx(e,e=>Y.createElement(`div`,{"aria-hidden":!0},e)))}),Gb=Object.assign(Ib,{List:Vb,Item:Lb,Input:Bb,Group:Rb,Separator:zb,Dialog:Hb,Empty:Ub,Loading:Wb});function Kb(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function qb(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Jb(e){let t=Y.useRef(e);return Yb(()=>{t.current=e}),t}var Yb=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function Xb(e){let t=Y.useRef();return t.current===void 0&&(t.current=e()),t}function Zb(e){let t=Pb(),n=()=>e(t.snapshot());return Y.useSyncExternalStore(t.subscribe,n,n)}function Qb(e,t,n,r=[]){let i=Y.useRef(),a=Mb();return Yb(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(kb,s),i.current=s}),i}var $b=()=>{let[e,t]=Y.useState(),n=Xb(()=>new Map);return Yb(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function ex(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function tx({asChild:e,children:t},n){return e&&Y.isValidElement(t)?Y.cloneElement(ex(t),{ref:t.ref},n(t.props.children)):n(t)}var nx={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function rx(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Gb,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ix(e){let t=(0,J.c)(34),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({title:o,description:s,children:n,className:r,showCloseButton:c,commandProps:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?`Command Palette`:o,u=s===void 0?`Search for a command to run`:s,d=c===void 0?!0:c,f;t[8]===i?f=t[9]:(f=i??{},t[8]=i,t[9]=f);let p,m;t[10]===f?(p=t[11],m=t[12]):({className:p,...m}=f,t[10]=f,t[11]=p,t[12]=m);let h;t[13]===r?h=t[14]:(h=yn(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[13]=r,t[14]=h);let g;t[15]===l?g=t[16]:(g=(0,X.jsx)(Bn,{className:`sr-only`,children:l}),t[15]=l,t[16]=g);let _;t[17]===u?_=t[18]:(_=(0,X.jsx)(zn,{className:`sr-only`,children:u}),t[17]=u,t[18]=_);let v;t[19]===p?v=t[20]:(v=yn(`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,p),t[19]=p,t[20]=v);let y;t[21]!==n||t[22]!==m||t[23]!==v?(y=(0,X.jsx)(rx,{className:v,...m,children:n}),t[21]=n,t[22]=m,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==y?(b=(0,X.jsxs)(Gn,{className:h,showCloseButton:d,children:[g,_,y]}),t[25]=d,t[26]=h,t[27]=g,t[28]=_,t[29]=y,t[30]=b):b=t[30];let x;return t[31]!==a||t[32]!==b?(x=(0,X.jsx)($n,{...a,children:b}),t[31]=a,t[32]=b,t[33]=x):x=t[33],x}function ax(e){let t=(0,J.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(Oa,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=yn(`flex w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a?(o=(0,X.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-2 border-b px-3`,children:[i,(0,X.jsx)(Gb.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function ox(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Gb.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function sx(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(Gb.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function cx(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-mono [&_[cmdk-group-heading]]:uppercase **:[[cmdk-group-heading]]:tracking-wider`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Gb.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function lx(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Gb.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ux(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=yn(`ml-auto text-muted-foreground text-xs tracking-widest`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`span`,{"data-slot":`command-shortcut`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function dx(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}if(e.ok)return r!==void 0&&console.warn(`[parse-server-response] 2xx response with non-JSON body:`,r instanceof Error?r.message:String(r)),{ok:!0,body:r===void 0?n:null};if(r!==void 0){let t=r instanceof Error?r.message:String(r);return{ok:!1,title:`Server error (HTTP ${e.status}): ${t}`}}return{ok:!1,title:l(n)??t}}function fx(e,t,n,r){let i=e.safeParse(t);return i.success?i.data:(console.warn(`[parse-server-response] schema drift:`,n,`bodyShape=`,typeof t==`object`&&t?Object.keys(t):typeof t,`issues=`,i.error.issues),r)}var px=new Map,mx=null;function hx(){return Sc(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function gx(){if(mx!==null)return;let e=Math.max(50,Math.floor(hx()/2));mx=setTimeout(()=>{mx=null,_x(Date.now()),px.size>0&&gx()},e)}function _x(e){let t=hx();for(let[n,r]of px)e-r.emittedAt>=t&&(px.delete(n),Z.count(`ok/sidebar/prewarm`,{hit:!1}))}function vx(e,t,n=Date.now()){px.has(e)&&Z.count(`ok/sidebar/prewarm`,{hit:!1}),px.set(e,{poolEventId:t,emittedAt:n}),gx()}function yx(e,t,n=Date.now()){let r=px.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=hx()?!1:(px.delete(e),Z(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),Z.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}E({event:ue(`ok-branch-switched-clear-failed`),branch:F(),docName:F(),reason:F()});async function bx(e,t){let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}function xx(e){let t=!1;return()=>{t?e():t=!0}}function Sx(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Cx(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=Wt.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&bx(e,i.data.currentBranch),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Sx(n)}catch{}e.observeDiskAckBatch(t)}}async function wx(e){let t;try{t=await fetch(`/api/config`,{signal:e,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return{status:`error`,code:`network`}}if(t.status===404||t.status===501)return{status:`absent`};if(!t.ok)return{status:`error`,code:t.status};let n;try{n=await t.json()}catch{return{status:`error`,code:`invalid-body`}}if(typeof n!=`object`||!n||Array.isArray(n))return{status:`error`,code:`invalid-body`};let r=n;return{status:`ok`,config:{collabUrl:typeof r.collabUrl==`string`?r.collabUrl:null,previewUrl:typeof r.previewUrl==`string`?r.previewUrl:null,port:typeof r.port==`number`?r.port:0}}}function Tx(e){return Nx(e,nn)}function Ex(e){return Nx(e,ct)}function Dx(e){return Nx(e,Yt)}function Ox(e){return Nx(e,Et)}function kx(e){return Nx(e,$e)}function Ax(e){let t=Nx(e,rt);if(!t)return null;try{return{docName:t.docName,sv:jx(t.sv)}}catch{return null}}function jx(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Mx(e,t){let n=Ex(e);if(n){t.onServerInfo?.(n);return}let r=Dx(e);if(r){t.onBranchSwitched?.(r);return}let i=Ax(e);if(i){t.onDiskAck?.(i);return}let a=Tx(e);if(a){t.onDerivedView?.(a);return}let o=Ox(e);if(o){t.onConfigValidationRejected?.(o);return}let s=kx(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function Nx(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function Px(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function Fx(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function Ix(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var Lx=2e3,Rx=15e3;function zx(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??Lx,r=e.maxDelayMs??Rx,i=e.log??{info:console.info,warn:console.warn},a=new AbortController,o=null,s=n,c=0,l=!1,u=!1,d=null,f=e.now(),p=async()=>{c+=1;let n=null;try{let t=await e.fetchConfig(a.signal);t.status===`absent`?(n=e.fallbackUrl(),d=null):t.status===`ok`&&t.config.collabUrl!==null?(n=t.config.collabUrl,d=null):t.status===`ok`?(u||(u=!0,i.info(`[collab-url] ok ui responded but server.lock has no port yet — retrying`)),d={kind:`null-collab`}):t.status===`error`&&(i.warn(`[collab-url] /api/config error (${t.code}) — retrying in ${s}ms`),d={kind:`error`,code:t.code})}catch(e){if(e.name===`AbortError`)return;d={kind:`error`,code:`network`}}if(!l){if(n!==null){e.onStateChange({collabUrl:n,attempts:c,terminal:!1,lastError:null});return}if(e.now()-f>=t){e.onStateChange({collabUrl:null,attempts:c,terminal:!0,lastError:d});return}e.onStateChange({collabUrl:null,attempts:c,terminal:!1,lastError:d}),o=e.setTimeout(()=>{p()},s),s=Math.min(s*2,r)}};return p(),{cancel:()=>{l=!0,a.abort(),o!==null&&(e.clearTimeout(o),o=null)}}}function Bx(){let e=(0,J.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Y.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Y.useRef)(i),[o,s]=(0,Y.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=Fx(window);if(t){r(Ix(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(Ix(t))});return()=>{n()}}let n=zx({fetchConfig:wx,fallbackUrl:Px,now:Date.now,setTimeout:Wx,clearTimeout:Ux,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,Y.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(Hx),s(Vx)},e[5]=u):u=e[5];let d=u,f;return e[6]===n?f=e[7]:(f={...n,retry:d},e[6]=n,e[7]=f),f}function Vx(e){return e+1}function Hx(e){return{...e,terminal:!1,lastError:null}}function Ux(e){return globalThis.clearTimeout(e)}function Wx(e,t){return globalThis.setTimeout(e,t)}var Gx=new Map,Kx=new Set;function qx(){for(let e of Kx)e()}function Jx(e,t){Gx.set(e,t),qx()}function Yx(e,t){Gx.get(e)===t&&(Gx.delete(e),qx())}function Xx(e){return Gx.get(e)??null}function Zx(e){return Kx.add(e),()=>Kx.delete(e)}var Qx=new Map;function $x(e){return Qx.get(e)}function eS(e,t){Qx.set(e,t)}function tS(e){Qx.delete(e)}var nS=`open-knowledge-app`,rS=new Map,iS=new Set,aS=1024,oS=1024;function sS(){return cr.getTracer(nS)}function cS(e,t,n){if(iS.has(e))return null;let r=rS.get(e);if(r)return r;if(rS.size>=oS){let e=rS.keys().next().value;if(e!==void 0){let t=rS.get(e);rS.delete(e);try{t?.span.end()}catch(e){console.warn(`[otel-spans] eviction span.end failed:`,e instanceof Error?e:String(e))}}}let i={span:sS().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return rS.set(e,i),i}function lS(e,t,n,r,i){try{let a=cS(e,n,r),o=a?cr.setSpan(lr.active(),a.span):lr.active();sS().startSpan(t,{attributes:{"mount.id":e,...n},startTime:r},o).end(i??Date.now())}catch(e){console.warn(`[otel-spans] emitColdMountChild failed:`,e instanceof Error?e:String(e))}}function uS(e,t){try{let n=rS.get(e);if(n&&(rS.delete(e),n.span.end(t??Date.now())),!iS.has(e)){if(iS.size>=aS){let e=iS.values().next().value;e!==void 0&&iS.delete(e)}iS.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var dS=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function fS(){return Sc(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function pS(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function mS(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;Z(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var hS=new Map,gS=new Set;function _S(e){gS.add(e);for(let[t,n]of hS)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{gS.delete(e)}}function vS(e,t){for(let n of gS)try{n(e,t.mountId)}catch{}}var yS=!1;function bS(){typeof document>`u`||document.visibilityState===`visible`&&CS(Date.now())}function xS(){yS||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,bS),yS=!0)}function SS(){yS&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,bS),yS=!1))}function CS(e){let t=fS();for(let[n,r]of hS)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(mS(r,n,e),vS(n,r))}function wS(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=hS.get(t);if(a)return a.promise;let o=new AbortController,s=Date.now(),c=()=>{},l=()=>{},u=new Promise((e,t)=>{c=e,l=t}),d={promise:u,rejectFn:l,controller:o,mountId:n,createdAt:s,settled:!1,resolved:!1,preMountEditor:null,stalledHandle:null,stalledMarkEmitted:!1};return d.stalledHandle=setTimeout(()=>{d.settled||(mS(d,t,Date.now()),vS(t,d))},fS()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,pS(d),d.preMountEditor&&=(OS(t,d.preMountEditor,`aborted`),null),hS.delete(t),hS.size===0&&SS(),Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new dS(t)),uS(d.mountId))}),hS.set(t,d),xS(),Z(`ok/mount/create`,{docName:t,mountId:d.mountId}),kS({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(OS(t,d.preMountEditor,`backstop`),null),d.settled){Z(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,pS(d);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`}),l(n),uS(d.mountId)}),u}function TS(e){return hS.get(e)?.resolved===!0}function ES(e){return hS.get(e)?.controller??null}function DS(e){let t=hS.get(e);t&&(t.settled=!0,pS(t),t.preMountEditor&&=(OS(e,t.preMountEditor,`aborted`),null),hS.delete(e),hS.size===0&&SS(),Z(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),uS(t.mountId),t.controller.abort())}function OS(e,t,n){let r=AS(t);try{t.destroy()}catch(t){Z(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function kS(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(uC(t)!==void 0){let e=JS({docName:t,container:s,factory:()=>{throw Error(`mount-promise: V2 cache contract violation — factory invoked on HIT for "${t}"`)}});i.settled=!0,i.resolved=!0,pS(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,pS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`}),o(n),uS(i.mountId);return}if(i.preMountEditor=c.editor,await scheduler.yield(),i.controller.signal.aborted){i.preMountEditor=null;return}try{c.editor.mount(s)}catch(e){OS(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,pS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`}),o(n),uS(i.mountId);return}let l;try{l=JS({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){OS(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,pS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`}),o(n),uS(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,pS(i);let u=Date.now()-i.createdAt;Z(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),Z.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();lS(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),uS(i.mountId,d)}function AS(e){try{let t=e.state;return Bv.getState(t)?.undoManager??null}catch(e){return Z(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var jS=Sc(`MAX_CACHE`,10),MS=Sc(`VIEW_COUNT_CACHE_THRESHOLD`,50),NS=Sc(`BYTES_CACHE_THRESHOLD`,8e6);function PS(e){return!(e.viewCount>0&&e.viewCount>=MS||e.bytes>NS)}var FS=new Map,IS=new Map,LS=new Map;function RS(e,t){if(LS.size>=jS){let e=LS.keys().next().value;e!==void 0&&LS.delete(e)}LS.set(e,t),Z(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function zS(e){return LS.get(e)??null}function BS(e){if(!LS.has(e))return;let t=LS.get(e)??null;LS.delete(e),Z(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function VS(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return Z(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function HS(e){try{let t=e.state.selection;return t instanceof xe?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof Ke?{type:`node`,from:t.from}:null}catch(e){return Z(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function US(e){for(let t of e)try{let e=uC(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){Z(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}RS(t.toDocName,{html:e.editor.getHTML(),scrollTop:VS(),selection:HS(e.editor)})}else Z(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){Z(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var WS=[],GS=[],KS=new Set;function qS(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,e}function JS(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!PS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:$x(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=FS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:$x(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),nC(a,n),a.activeMountKey=t,iC(WS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:$x(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:$x(t),kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:$x(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;FS.size>=jS;){let e=aC(WS,t);if(!e)break;XS(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return FS.set(t,s),iC(WS,t),Z(`ok/cache/miss`,{docName:t,mountId:$x(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:$x(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function YS(e){let t=e.activeMountKey;if(e.__uncached){t&&DS(t);let n=AS(e.editor);try{e.editor.destroy()}catch(e){Z(`ok/cache/park-destroy-failed`,{docName:t??``,kind:`tiptap`,message:e instanceof Error?e.message:String(e)})}n&&(n.restore=void 0),e.activeMountKey=null;return}let n=eC(e.editor);if(n){e.hadFocus=tC(n.dom),e.scrollTop=(n.scrollDOM??n.dom.parentElement??n.dom).scrollTop??0;let t=n.dom.parentElement;t&&t.removeChild(n.dom),e.parkingNode||=qS(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function XS(e){DS(e);let t=FS.get(e);if(!t)return!1;let n=AS(t.editor);try{t.editor.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}FS.delete(e);let r=WS.indexOf(e);return r!==-1&&WS.splice(r,1),Z(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function ZS(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!PS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:$x(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=IS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:$x(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),rC(a,n),a.activeMountKey=t,iC(GS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:$x(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:$x(t),kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:$x(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;IS.size>=jS;){let e=aC(GS,t);if(!e)break;$S(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return IS.set(t,s),iC(GS,t),Z(`ok/cache/miss`,{docName:t,mountId:$x(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:$x(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function QS(e){if(e.__uncached){try{e.view.destroy()}catch(t){Z(`ok/cache/park-destroy-failed`,{docName:e.activeMountKey??``,kind:`cm`,message:t instanceof Error?t.message:String(t)})}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=tC(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=qS(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function $S(e){let t=IS.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}IS.delete(e);let n=GS.indexOf(e);return n!==-1&&GS.splice(n,1),Z(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function eC(e){return e.editorView??null}function tC(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function nC(e,t){let n=eC(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function rC(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function iC(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function aC(e,t){for(let n of e)if(n!==t&&!KS.has(n))return n;Z(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:KS.size});for(let n of e)if(n!==t)return n;return null}function oC(e){let t=KS,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=cC(e);if(t)try{t.disconnect(),Z(`ok/cache/disconnect`,{docName:e})}catch(t){Z(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=cC(e);if(!n)continue;let r=t=>{Z(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>Z(`ok/cache/connect`,{docName:e}),e=>r(e)):Z(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}KS=n}var sC=null;function cC(e){let t=FS.get(e);if(t)return t.provider;let n=IS.get(e);if(n)return n.provider;if(sC){let t=sC.entries.get(e);if(t)return t.provider}return null}function lC(e){sC=e;let t=e.onEvict(e=>{XS(e),$S(e)});return()=>{t(),sC===e&&(sC=null)}}function uC(e){return FS.get(e)}var dC=`ok-editor-tabs-v1:`,fC=`\0folder:`,pC=`\0asset:`,mC=`\0doc-tab:`;function hC(e){let t=e.lastIndexOf(mC);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function gC(e){return hC(e).baseTabId}function _C(e){if(typeof e!=`string`||e.length===0)return!1;let t=gC(e);return t.startsWith(fC)?t.length>8:t.startsWith(pC)?t.length>7:!0}function vC(e){return e}function yC(e,t){return`${gC(e)}${mC}${t}`}function bC(e,t){return xC(e,vC(t))}function xC(e,t){let n=AC(e,2**53-1),r=gC(t);if(!n.includes(r))return r;let i=1,a;do a=yC(r,i),i++;while(n.includes(a));return a}function SC(e,t){let n=gC(t);return AC(e,2**53-1).find(e=>gC(e)===n)??null}function CC(e,t){return gC(e)===gC(t)}function wC(e){return`${fC}${e}`}function TC(e){return`${pC}${e}`}function EC(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function DC(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return vC(e.docName);case`folder`:return wC(e.folderPath);case`missing`:return vC(e.target);case`asset`:return TC(e.assetPath)}}function OC(e){let t=gC(e);return t.startsWith(fC)?{kind:`folder`,folderPath:t.slice(8)}:t.startsWith(pC)?{kind:`asset`,assetPath:t.slice(7)}:{kind:`doc`,docName:t}}function kC(e){let t=OC(e);return t.kind===`doc`?t.docName:null}function AC(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(_C(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function jC(e,t){let n=new Set(AC(t,2**53-1));return AC(e,2**53-1).filter(e=>n.has(e))}function MC(e,t,n){if(t<=0)return[];let r=new Set(AC(n,2**53-1)),i=AC(e,2**53-1);if(r.size===0&&i.length<=t)return i;let a=[],o=0;for(let e=i.length-1;e>=0;e--){let n=i[e];if(r.has(n)){a.push(n);continue}o>=t||(o++,a.push(n))}return a.reverse()}function NC(e,t,n){let r=jC(e,n);return!AC(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function PC(e,t){return AC(e,2**53-1).filter(e=>e!==t)}function FC(e,t){let n=new Set(AC(t,2**53-1));return AC(e,2**53-1).filter(e=>!n.has(e))}function IC(e,t,n){let r=AC(e,2**53-1),i=jC(t,r),a=r.indexOf(n);if(a<0)return i;let o=i.includes(n),s=a<i.length;return o===s?i:s?NC(i,n,r):PC(i,n)}function LC(e,t,n,r=[]){let i=MC(e,n,r);return!_C(t)||i.includes(t)?i:MC([...i,t],n,r)}function RC(e,t,n,r,i=[]){let a=MC(e,r,i);if(!_C(n))return a;if(!t||t===n)return LC(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return LC(o,n,r,i);let c=[...o];return c[s]=n,MC(c,r,i)}function zC(e,t,n){return BC(e,vC(t),n)}function BC(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=MC(e,i,a),s=gC(t);if(r&&o.includes(r)&&gC(r)===s)return{tabs:o,activeTabId:r};if(n!==`replace-active`)return{tabs:LC(o,s,i,a),activeTabId:s};let c=SC(o,s);if(c)return{tabs:o,activeTabId:c};let l=xC(o,s);return{tabs:RC(o,r,l,i,a),activeTabId:l}}function VC(e,t){return e.filter(e=>e!==t)}function HC(e,t,n){let r=AC(t,2**53-1),i=new Set(r),a=new Set(n),o=new Set,s=[];for(let t of e)o.has(t)||!i.has(t)&&!a.has(t)||(o.add(t),s.push(t));for(let e of[...r,...n])o.has(e)||(o.add(e),s.push(e));return s}function UC(e,{pages:t,folderPaths:n,assetPaths:r,keepMissingDocName:i=null}){return AC(e,2**53-1).filter(e=>{let a=OC(e);return a.kind===`folder`?n.has(a.folderPath):a.kind===`asset`?r.has(a.assetPath):t.has(a.docName)||a.docName===i})}function WC(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return AC(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=e=>qC(KC(e,r),a),c=[],l=new Set;for(let t of e){let{instanceSuffix:e}=hC(t),a=OC(t),u=`${a.kind===`doc`?o.get(a.docName)??gC(t):a.kind===`folder`?wC(KC(a.folderPath,r)):TC(s(a.assetPath))}${e}`;if(!l.has(u)&&(l.add(u),c.push(u),i.length===0&&c.length>=n))break}return i.length===0?c:MC(c,n,i.map(e=>{let t=OC(e);return t.kind===`doc`?o.get(t.docName)??e:t.kind===`folder`?wC(KC(t.folderPath,r)):TC(s(t.assetPath))}))}function GC(e,t,n=[],r=[]){return WC(e,t,2**53-1,n,[],r)}function KC(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function qC(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function JC(e,t,n){if(t!==n)return t;let r=e.indexOf(n);return r<0?e[0]??null:e[r+1]??e[r-1]??null}function YC(e,t,n){if(!t)return null;let r=new Set(n);if(!r.has(t))return t;let i=e.indexOf(t);if(i<0)return e.find(e=>!r.has(e))??null;for(let t=i+1;t<e.length;t++)if(!r.has(e[t]))return e[t];for(let t=i-1;t>=0;t--)if(!r.has(e[t]))return e[t];return null}function XC(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=AC(n.openTabs,2**53-1),i=jC(n.pinnedTabIds,r),a=i.length===0?AC(n.openTabs,t):MC(r,t,i),o=jC(n.pinnedTabIds,a),s=typeof n.activeTabId==`string`&&a.includes(n.activeTabId)?n.activeTabId:typeof n.activeDocName==`string`&&a.includes(n.activeDocName)?n.activeDocName:null,c=s?OC(s):null;return{openTabs:a,pinnedTabIds:o,activeDocName:c?.kind===`doc`?c.docName:null,activeTabId:s,updatedAt:typeof n.updatedAt==`string`?n.updatedAt:null}}function ZC(e,t,n=[],r=()=>new Date){let i=AC(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?OC(a):null;return{openTabs:i,pinnedTabIds:jC(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function QC(e){return`${dC}${e}`}function $C(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?XC(JSON.parse(r),n):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}catch(e){return console.warn(`[editor-tabs] failed to read local tab session:`,e),{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}}function ew(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch(e){console.warn(`[editor-tabs] failed to write local tab session:`,e)}}var tw=Math.floor,nw=(e,t)=>e<t?e:t,rw=(e,t)=>e>t?e:t;Number.isNaN;var iw=128,aw=1<<17,ow=1<<18,sw=1<<19,cw=1<<20,lw=1<<21,uw=1<<22,dw=1<<23,fw=1<<24,pw=1<<25,mw=1<<26,hw=1<<27,gw=1<<28,_w=1<<29,vw=1<<30,yw=127;aw-1,ow-1,sw-1,cw-1,lw-1,uw-1,dw-1,fw-1,pw-1,mw-1,hw-1,gw-1,_w-1,vw-1;var bw=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var xw=String.fromCharCode;String.fromCodePoint,xw(65535);var Sw=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Cw=typeof TextEncoder<`u`?new TextEncoder:null,ww=Cw?e=>Cw.encode(e):Sw,Tw=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Tw&&Tw.decode(new Uint8Array).length===1&&(Tw=null);var Ew=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Dw=(e,t)=>{for(;t>yw;)Ew(e,iw|yw&t),t=tw(t/128);Ew(e,yw&t)},Ow=new Uint8Array(3e4),kw=Ow.length/3,Aw=Cw&&Cw.encodeInto?(e,t)=>{if(t.length<kw){let n=Cw.encodeInto(t,Ow).written||0;Dw(e,n);for(let t=0;t<n;t++)Ew(e,Ow[t])}else Mw(e,ww(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Dw(e,r);for(let t=0;t<r;t++)Ew(e,n.codePointAt(t))},jw=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=nw(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(rw(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Mw=(e,t)=>{Dw(e,t.byteLength),jw(e,t)},Nw=e=>Error(e),Pw=Nw(`Unexpected end of array`),Fw=Nw(`Integer out of Range`),Iw=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Lw=e=>Iw(e,zw(e)),Rw=e=>e.arr[e.pos++],zw=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&yw)*n,n*=128,r<iw)return t;if(t>bw)throw Fw}throw Pw},Bw=Tw?e=>Tw.decode(Lw(e)):e=>{let t=zw(e);if(t===0)return``;{let n=String.fromCodePoint(Rw(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Rw(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Vw=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),Hw=(e,t)=>{Dw(e,Vw.Token),Aw(e,t)},Uw=(e,t,n,r)=>{switch(zw(e)){case Vw.Token:t();break;case Vw.PermissionDenied:n(Bw(e));break;case Vw.Authenticated:r(Bw(e));break;default:}},Ww=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),Gw=`\0`;function Kw(e,t){return e+Gw+t}function qw(e){let t=e.indexOf(Gw);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Jw=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function Yw(e){return 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 Xw(e){return new Promise(t=>setTimeout(t,e))}function Zw(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function Qw(e,t){let n=Yw(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Zw;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await Xw(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await Xw(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await Xw(e)}return a()}var $w=Math.floor,eT=(e,t)=>e<t?e:t,tT=(e,t)=>e>t?e:t;Number.isNaN;var nT=64,rT=128,iT=1<<17,aT=1<<18,oT=1<<19,sT=1<<20,cT=1<<21,lT=1<<22,uT=1<<23,dT=1<<24,fT=1<<25,pT=1<<26,mT=1<<27,hT=1<<28,gT=1<<29,_T=1<<30,vT=63,yT=127;iT-1,aT-1,oT-1,sT-1,cT-1,lT-1,uT-1,dT-1,fT-1,pT-1,mT-1,hT-1,gT-1,_T-1;var bT=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var xT=()=>new Set,ST=Array.from;Array.isArray;var CT=String.fromCharCode;String.fromCodePoint,CT(65535);var wT=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},TT=typeof TextEncoder<`u`?new TextEncoder:null,ET=TT?e=>TT.encode(e):wT,DT=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});DT&&DT.decode(new Uint8Array).length===1&&(DT=null);var OT=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},kT=()=>new OT,AT=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},jT=e=>{let t=new Uint8Array(AT(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},MT=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},NT=(e,t)=>{for(;t>yT;)MT(e,rT|yT&t),t=$w(t/128);MT(e,yT&t)},PT=new Uint8Array(3e4),FT=PT.length/3,IT=TT&&TT.encodeInto?(e,t)=>{if(t.length<FT){let n=TT.encodeInto(t,PT).written||0;NT(e,n);for(let t=0;t<n;t++)MT(e,PT[t])}else RT(e,ET(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;NT(e,r);for(let t=0;t<r;t++)MT(e,n.codePointAt(t))},LT=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=eT(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(tT(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},RT=(e,t)=>{NT(e,t.byteLength),LT(e,t)},zT=e=>Error(e),BT=zT(`Unexpected end of array`),VT=zT(`Integer out of Range`),HT=class{constructor(e){this.arr=e,this.pos=0}},UT=e=>new HT(e),WT=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},GT=e=>WT(e,qT(e)),KT=e=>e.arr[e.pos++],qT=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&yT)*n,n*=128,r<rT)return t;if(t>bT)throw VT}throw BT},JT=e=>{let t=e.arr[e.pos++],n=t&vT,r=64,i=(t&nT)>0?-1:1;if((t&rT)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&yT)*r,r*=128,t<rT)return i*n;if(n>bT)throw VT}throw BT},YT=DT?e=>DT.decode(GT(e)):e=>{let t=qT(e);if(t===0)return``;{let n=String.fromCodePoint(KT(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(KT(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},XT=e=>{let t=e.pos,n=YT(e);return e.pos=t,n},ZT=Date.now,QT=()=>new Map,$T=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},eE=class{constructor(){this._observers=QT()}on(e,t){$T(this._observers,e,xT).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return ST((this._observers.get(e)||QT()).values()).forEach(e=>e(...t))}destroy(){this._observers=QT()}},tE=Symbol(`Equality`),nE=Object.keys,rE=e=>nE(e).length,iE=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),aE=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[tE]!=null)return e[tE](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!aE(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(rE(e)!==rE(t))return!1;for(let n in e)if(!iE(e,n)||!aE(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!aE(e[n],t[n]))return!1;break;default:return!1}return!0},oE=3e4,sE=class extends eE{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=ZT();this.getLocalState()!==null&&oE/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&oE<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&cE(this,t,`timeout`)},$w(oE/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){let 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:ZT()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),aE(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},cE=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:ZT()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},lE=(e,t,n=e.states)=>{let r=t.length,i=kT();NT(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;NT(i,r),NT(i,s),IT(i,JSON.stringify(o))}return jT(i)},uE=(e,t,n)=>{let r=UT(t),i=ZT(),a=[],o=[],s=[],c=[],l=qT(r);for(let t=0;t<l;t++){let t=qT(r),n=qT(r),l=JSON.parse(YT(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(aE(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},dE=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},fE=class{constructor(e){this.data=e,this.encoder=kT(),this.decoder=UT(new Uint8Array(this.data))}peekVarString(){return XT(this.decoder)}readVarUint(){return qT(this.decoder)}readVarString(){return YT(this.decoder)}readVarUint8Array(){return GT(this.decoder)}writeVarUint(e){return NT(this.encoder,e)}writeVarString(e){return IT(this.encoder,e)}writeVarUint8Array(e){return RT(this.encoder,e)}length(){return AT(this.encoder)}},pE=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[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),mE=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),hE=class{constructor(){this.encoder=kT()}get(e){return e.encoder}toUint8Array(){return jT(this.encoder)}},gE=class extends hE{constructor(...e){super(...e),this.type=pE.CLOSE,this.description=`Ask the server to close the connection`}get(e){return IT(this.encoder,e.documentName),NT(this.encoder,this.type),this.encoder}},_E=class e extends dE{static{this.DEDUPLICATABLE_TYPES=new Set([pE.Awareness,pE.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,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,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=mE.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,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(`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),this.shouldConnect&&this.connect()}async onOpen(e){this.status=mE.Connected,this.emit(`status`,{status:mE.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===mE.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===mE.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(gE,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===mE.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:Qw(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,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{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;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=mE.Connecting,this.emit(`status`,{status:mE.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=ZT();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===pE.Ping){this.sendPong();return}let n=new fE(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=kT();NT(e,pE.Pong),this.send(jT(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=mE.Connected,this.emit(`status`,{status:mE.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===mE.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=ZT()-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(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=UT(e);return{documentName:YT(t),messageType:qT(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===Jw.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=mE.Disconnected,this.emit(`status`,{status:mE.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},vE=0,yE=1,bE=2,xE=(e,t)=>{NT(e,vE),RT(e,_h(t))},SE=(e,t,n)=>{NT(e,yE),RT(e,dh(t,n))},CE=(e,t,n)=>SE(t,n,GT(e)),wE=(e,t,n,r)=>{try{ch(t,GT(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},TE=(e,t)=>{NT(e,bE),RT(e,t)},EE=wE,DE=(e,t,n,r,i)=>{let a=qT(e);switch(a){case vE:CE(e,t,n);break;case yE:wE(e,n,r,i);break;case bE:EE(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},OE=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case pE.Sync:this.applySyncMessage(e,t);break;case pE.Awareness:this.applyAwarenessMessage(e);break;case pE.Auth:this.applyAuthMessage(e);break;case pE.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case pE.Stateless:e.receiveStateless(YT(n.decoder));break;case pE.SyncStatus:this.applySyncStatusMessage(e,JT(n.decoder)===1);break;case pE.CLOSE:let i={code:1e3,reason:YT(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(hE,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(pE.Sync);let r=DE(n.decoder,n.encoder,e.document,e);t&&r===yE&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;uE(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Uw(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(pE.Awareness),t.writeVarUint8Array(lE(e.awareness,Array.from(e.awareness.getStates().keys())))}},kE=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return jT(this.encoder)}send(e){e?.send(this.create())}},AE=`4.0.0-rc.1`,jE=class extends hE{constructor(...e){super(...e),this.type=pE.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return IT(this.encoder,e.documentName),NT(this.encoder,this.type),Hw(this.encoder,e.token),IT(this.encoder,AE),this.encoder}},ME=class extends hE{constructor(...e){super(...e),this.type=pE.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);IT(this.encoder,e.documentName),NT(this.encoder,this.type);let t;return t=e.states===void 0?lE(e.awareness,e.clients):lE(e.awareness,e.clients,e.states),RT(this.encoder,t),this.encoder}},NE=class extends hE{constructor(...e){super(...e),this.type=pE.Stateless,this.description=`A stateless message`}get(e){return IT(this.encoder,e.documentName),NT(this.encoder,this.type),IT(this.encoder,e.payload??``),this.encoder}},PE=class extends hE{constructor(...e){super(...e),this.type=pE.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return IT(this.encoder,e.documentName),NT(this.encoder,this.type),xE(this.encoder,e.document),this.encoder}},FE=class extends hE{constructor(...e){super(...e),this.type=pE.Sync,this.description=`A document update`}get(e){return IT(this.encoder,e.documentName),NT(this.encoder,this.type),TE(this.encoder,e.update),this.encoder}},IE=class extends Error{constructor(...e){super(...e),this.code=1001}},LE=class extends dE{get effectiveName(){return this.configuration.sessionAwareness?Kw(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Km,this.configuration.awareness=e.awareness===void 0?new sE(this.document):e.awareness,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(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:Ww(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Ww(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.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new _E(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(PE,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&cE(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(NE,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(jE,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(FE,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(ME,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(PE,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(ME,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new kE(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new fE(e.data),{documentName:n}=qw(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new fE(e.data)}),new OE(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&cE(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(cE(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.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),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(`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.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),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(`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.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new IE(`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)}},RE=e=>$d((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),zE=(e,t)=>$d((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Td(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),BE=e=>RE(indexedDB.deleteDatabase(e)),VE=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),HE=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>$E(r,e))},UE=(e,t)=>RE(e.count(t)),WE=(e,t)=>RE(e.get(t)),GE=(e,t)=>RE(e.delete(t)),KE=(e,t,n)=>RE(e.put(t,n)),qE=(e,t)=>RE(e.add(t)),JE=(e,t,n)=>RE(e.getAll(t,n)),YE=(e,t,n)=>{let r=null;return QE(e,t,e=>(r=e,!1),n).then(()=>r)},XE=(e,t=null)=>YE(e,t,`prev`),ZE=(e,t)=>$d((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),QE=(e,t,n,r=`next`)=>ZE(e.openKeyCursor(t,r),e=>n(e.key)),$E=(e,t)=>e.objectStore(t),eD=(e,t)=>IDBKeyRange.upperBound(e,t),tD=(e,t)=>IDBKeyRange.lowerBound(e,t),nD=`custom`,rD=`updates`,iD=(e,t=()=>{},n=()=>{})=>{let[r]=HE(e.db,[rD]);return JE(r,tD(e._dbref,!1)).then(i=>{e._destroyed||(t(r),sg(e.doc,()=>{i.forEach(t=>ch(e.doc,t))},e,!1),n(r))}).then(()=>XE(r).then(t=>{e._dbref=t+1})).then(()=>UE(r).then(t=>{e._dbsize=t})).then(()=>r)},aD=(e,t=!0)=>iD(e).then(n=>{(t||e._dbsize>=500)&&qE(n,dh(e.doc)).then(()=>GE(n,eD(e._dbref,!0))).then(()=>UE(n).then(t=>{e._dbsize=t}))}),oD=class extends vu{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=zE(e,e=>VE(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=$d(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,iD(this,async e=>{await UE(e)>0&&qE(e,dh(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=HE(this.db,[rD]);qE(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{aD(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{BE(this.name)})}get(e){return this._db.then(t=>{let[n]=HE(t,[nD],`readonly`);return WE(n,e)})}set(e,t){return this._db.then(n=>{let[r]=HE(n,[nD]);return KE(r,t,e)})}del(e){return this._db.then(t=>{let[n]=HE(t,[nD]);return GE(n,e)})}};function sD(){return!0}var cD=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`;let i=sD()?0:performance.now();this._idb=new oD(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!sD()){let e=performance.now();Z(`ok/pool/idb-whensynced`,{docName:n,durationMs:Math.round((e-i)*1e3)/1e3},{startTime:i,duration:e-i})}return this})}get synced(){return this._idb.synced}async destroy(){let e=sD()?0:performance.now();try{await this._idb.destroy()}finally{if(!sD()){let t=performance.now();Z(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async clearData(){let e=sD()?0:performance.now();try{await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e}))}})}finally{if(!sD()){let t=performance.now();Z(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function lD(e){return new cD(e)}function uD(e){return _h(e)}function dD(e,t){return t===null?dh(e):dh(e,t)}function fD(e,t){if(e===null)return t;if(t===null)return e;let n=ph(e),r=ph(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return _h(i)}function pD(e){let t={};if(ur.inject(lr.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,r=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&r.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${r.join(`&`)}`}var mD=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new ln({key:e||new G(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),hD=W.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[mD({key:new G(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function gD(e,t){let{state:n,view:r}=e;if(!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount!==0||!Ke.isSelectable(o))return!1;try{let t=Ke.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Pt(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function _D(e){let{state:t,view:n}=e;if(!(t.selection instanceof xe)||!t.selection.empty||!n.endOfTextblock(`up`))return!1;let r=t.selection.$head,i=-1;for(let e=r.depth-1;e>=1;e--)if(r.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;for(let e=r.depth;e>i;e--)if(r.index(e-1)!==0)return!1;let a=r.before(i);try{let n=t.doc.resolve(a),r=_.findFrom(n,-1,!0);return!r||!(r instanceof xe)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Pt(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}var vD=W.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof Ke){let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=xe.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof xe?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(gD(e,`up`)||_D(e))return!0;let{state:t}=e;if(!(t.selection instanceof Ke))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=Ke.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Pt(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowDown:({editor:e})=>{if(gD(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof Ke))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=Ke.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Pt(`down`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`down`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowLeft:({editor:e})=>gD(e,`left`),ArrowRight:({editor:e})=>gD(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof xe)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let s=t.tr,c=n.before(n.depth),l=n.after(n.depth);s.delete(c,l);let u=o-(l-c),d=t.schema.nodes.paragraph.create();s.insert(u,d);let f=u+1;return s.setSelection(xe.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),yD={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},bD=/[A-Za-z0-9_]/;function xD(e){return e!==void 0&&bD.test(e)}function SD(e,t,n){return!xD(e[t-1])&&!xD(e[n])}function CD(e,t,n){if(t.length===0)return[];let r=n.caseSensitive?e:e.toLocaleLowerCase(),i=n.caseSensitive?t:t.toLocaleLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let t=r.indexOf(i,o);if(t===-1)break;let s=t+i.length;(!n.wholeWord||SD(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function wD(e,t,n){if(t.length===0)return[];let r=[];return e.descendants((e,i)=>{if(!(!e.isText||typeof e.text!=`string`))for(let a of CD(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var TD=new G(`findReplace`);function ED(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function DD(e,t,n,r){let i=wD(e.doc,t,n);return{query:t,options:n,activeIndex:ED(r,i.length),matches:i}}function OD(e,t,n){return t<=0?0:(ED(e,t)+n+t)%t}function kD(e,t,n){if(e.length===0)return 0;let r=t+n,i=e.findIndex(e=>e.from>=r);return i===-1?0:i}function AD(e,t,n){if(t.matches.length===0)return null;let r=e.tr;for(let e of[...t.matches].reverse())r.insertText(n,e.from,e.to);let i=wD(r.doc,t.query,t.options),a=ED(0,i.length),o=i[a];return r.setMeta(TD,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(xe.create(r.doc,o.from,o.to)),r.scrollIntoView()}function jD(e,t){let n=TD.getState(e)?.matches[t];return n?e.tr.setMeta(TD,{type:`setActiveIndex`,activeIndex:t}).setSelection(xe.create(e.doc,n.from,n.to)).scrollIntoView():null}function MD(e){return TD.getState(e)??yD}function ND(){return new ln({key:TD,state:{init:()=>yD,apply(e,t,n,r){let i=e.getMeta(TD);if(i?.type===`clear`)return yD;let a=t.query,o=t.options,s=t.activeIndex;if(i?.type===`setQuery`)a=i.query,o={...o,...i.options},s=i.activeIndex??0;else if(i?.type===`setOptions`)o={...o,...i.options},s=i.activeIndex??s;else if(i?.type===`setActiveIndex`)s=i.activeIndex;else if(!e.docChanged)return t;return a.length===0?{query:a,options:o,activeIndex:0,matches:[]}:DD(r,a,o,s)}},props:{decorations(e){let t=TD.getState(e);return!t||t.matches.length===0?null:Be.create(e.doc,t.matches.map((e,n)=>ut.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var PD=W.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(TD,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(TD,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(TD,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=MD(e),r=jD(e,OD(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=MD(e),r=jD(e,OD(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=MD(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=wD(a.doc,r.query,r.options),s=kD(o,i.from,e.length),c=o[s];return a.setMeta(TD,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(xe.create(a.doc,c.from,c.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=MD(t);if(!n)return!1;let i=AD(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(TD,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[ND()]}}),FD=new WeakMap;function ID(e,t){if(t===null){FD.delete(e);return}FD.set(e,t)}function LD(e){return FD.get(e)??null}function RD(e){return`pagesBySlug`in e}function zD(e){return RD(e)?e.pages:e}function BD(e,t){return RD(e)?e.assetPaths??new Set:t??new Set}function VD(e,t){let n=De(e);if(n){if(RD(t))return t.pagesBySlug.get(n);for(let e of t)if(De(e)===n)return e}}function HD(e,t){if(e.includes(`/`))return;let n=De(e);if(!n)return;if(RD(t))return t.pagesByBasename?.get(n);let r;for(let e of t){let t=e.lastIndexOf(`/`);De(t===-1?e:e.slice(t+1))===n&&(r===void 0||e.localeCompare(r)<0)&&(r=e)}return r}function UD(e){let t=e.trim();if(!t)return null;let n=De(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function WD(e){let t=e.trim();if(!t)return[];let n=De(t);return n.length>0&&n!==t?[n]:[]}function GD(e,t){let n=e.trim();if(!n)return;let r=zD(t);if(r.has(n))return n;let i=VD(n,t);if(i)return i;for(let e of WD(n))if(r.has(e))return e;return KD(n,r)||HD(n,t)}function KD(e,t){let n=`${e}/index`;if(t.has(n))return n;let r=e.lastIndexOf(`/`),i=r===-1?e:e.slice(r+1),a=i?`${e}/${i}`:null;if(a&&t.has(a))return a}function qD(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function JD(e,t){let n=qD(e);if(!n)return null;if(t.has(n))return n;let r=n.toLowerCase();for(let e of t)if(e.toLowerCase()===r)return e;if(n.includes(`/`))return null;let i=[...t].filter(e=>{let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()===r});return i.length===0?null:i.sort((e,t)=>e.localeCompare(t))[0]??null}function YD(e,t,n){let r=e.trim();if(!r)return!1;if(JD(r,BD(t,n)))return!0;let i=zD(t);return i.has(r)||WD(r).some(e=>i.has(e))||VD(r,t)!==void 0||KD(r,i)?!0:HD(r,t)!==void 0}var XD=class extends Error{status;instance;constructor(e,t={}){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`HttpResponseParseError`,this.status=t.status,this.instance=t.instance}},ZD=new G(`imageUpload`);function QD(e){let t=document.createElement(`div`);t.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`);let n=e?.name;return t.setAttribute(`aria-label`,n?z._({id:`KDuPiY`,values:{fileName:n}}):z._({id:`bGa3Fk`})),t}var $D=new ln({key:ZD,state:{init(){return{decorations:Be.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(ZD);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=ut.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return ZD.getState(e)?.decorations??Be.empty}}});function eO(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function tO(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function nO(e){return e.split(`/`).filter(e=>e!==``)}function rO(e,t){let n=eO(e),r=eO(t),i=tO(e);if(n===r)return i;let a=nO(r),o=nO(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function iO(e){return LD(e)}function aO(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t}:{src:t,controls:!0}}}}function oO(e){let t=Te(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:V.has(t)?{kind:`jsx-img`,ext:t}:tt.has(t)?{kind:`jsx-video`,ext:t}:Kt.has(t)?{kind:`jsx-audio`,ext:t}:Ct.has(t)?{kind:`jsx-file`,ext:t}:st.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function sO(e,t,n){let r=iO(t),i=r?`${r}.md`:``;if(!i){nr.error(z._({id:`z5pqI8`}));return}let a=crypto.randomUUID(),o=QD(e);t.view.dispatch(t.state.tr.setMeta(ZD,{type:`add`,id:a,pos:n,widget:o}));let s=new FormData;s.append(`file`,e),s.append(`parentDocName`,i);let c;try{c=await fetch(`/api/upload`,{method:`POST`,body:s})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),cO(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),cO(t,a);return}if(!c.ok){let e=ze.safeParse(l);if(!e.success){let n=new XD(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),cO(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),cO(t,a,e.data.title);return}let u=en.safeParse(l);if(!u.success){let e=new XD(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),cO(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=eO(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&nr.info(z._({id:`VbqhBI`,values:{assetContentPath:h}}));let g=oO(e.name),{state:_}=t,v=ZD.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(ZD,{type:`remove`,id:a}),b=rO(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),cO(t,a);return}let n={type:`jsxComponent`,attrs:{componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:{src:x,target:f,alias:null,anchor:null,size:ne(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(ZD,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,n).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(Ke.create(e.doc,n)),!0}).run();return}if(g.kind===`jsx-img`||g.kind===`jsx-video`||g.kind===`jsx-audio`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),cO(t,a);return}let e=aO(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(ZD,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,e).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(Ke.create(e.doc,n)),!0}).run();return}if(g.kind===`wikiembed`){let e=_.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),cO(t,a);return}y.insert(v,e.create({target:f,alias:null,anchor:null,resolvedSrc:x}))}else if(g.kind===`wiki-link`){let n=_.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),cO(t,a);return}let r=UD(e.name.replace(/\.(md|mdx)$/i,``));r?y.insert(v,n.create(r)):y.insert(v,_.schema.text(e.name))}else{let t=_.schema.marks.link;if(t){let n=_.schema.text(e.name,[t.create({href:b})]);y.insert(v,n)}else y.insert(v,_.schema.text(e.name))}t.view.dispatch(y)}function cO(e,t,n){e.view.dispatch(e.state.tr.setMeta(ZD,{type:`remove`,id:t})),nr.error(n??z._({id:`b3Thhd`}))}var lO=new Set;function uO(e){lO.add(e)}function dO(e){return lO.delete(e)}var fO=new G(`markIdentity`);function pO(){return{byId:new Map,counter:0}}function mO(e,t,n,r,i){let a=[];for(let e of t.byId.values()){let t=i?i.map(e.from,-1):e.from,n=i?i.map(e.to,1):e.to;n<=t||a.push({id:e.id,markType:e.markType,attrs:e.attrs,from:t,to:n})}let o=new Map,s=new Set,c=t.counter;return e.descendants((e,t)=>{if(!(!e.isInline||e.marks.length===0))for(let i of e.marks){if(!n.has(i.type.name)||r&&!r(i))continue;let l=null;for(let e of a)if(!s.has(e.id)&&e.markType===i.type.name&&hO(e.attrs,i.attrs)&&!(t<e.from||t>=e.to)){l=e.id;break}let u=l??`m${++c}`;s.add(u);let d=t,f=t+e.nodeSize,p=o.get(u);p?p.to=Math.max(p.to,f):o.set(u,{id:u,markType:i.type.name,attrs:i.attrs,from:d,to:f})}}),{byId:o,counter:c}}function hO(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i&&!(typeof n==`object`&&n&&typeof i==`object`&&i&&hO(n,i)))return!1}return!0}function gO(e,t,n,r){let i=new Set(t.byId.keys());for(let[r,i]of t.byId)e.has(r)||n?.(i);for(let t of e)i.has(t)||r?.(t);return i}function _O(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new ln({key:fO,state:{init(e,t){return mO(t.doc,pO(),a,n)},apply(e,t,r,i){return e.docChanged?mO(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=fO.getState(t.state);n&&(e=gO(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var vO=300,yO=150,bO=500,xO=class{registry=new Map;_activeNodeId=null;listeners=new Set;_snapshot={activeNodeId:null,active:null};register(e){this.registry.set(e.nodeId,e),this._activeNodeId===e.nodeId&&this.refreshSnapshot()}deregister(e){this.registry.delete(e)&&this._activeNodeId===e&&(this._activeNodeId=null,this.refreshSnapshot())}setActiveNode(e){this._activeNodeId!==e&&(e!==null&&!this.registry.has(e)||(this._activeNodeId=e,this.refreshSnapshot()))}getActiveNode(){return this._activeNodeId}getRegistration(e){return this.registry.get(e)}hasRegistration(e){return this.registry.has(e)}clear(){this.registry.clear(),this._activeNodeId=null,this.refreshSnapshot()}getSnapshot=()=>this._snapshot;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});refreshSnapshot(){let e=this._activeNodeId==null?null:this.registry.get(this._activeNodeId)??null;this._snapshot={activeNodeId:this._activeNodeId,active:e};for(let e of this.listeners)e()}};function SO(e,t){let n=e??null;for(;n&&typeof n==`object`;){let e=n.getAttribute;if(typeof e==`function`){let r=e.call(n,`data-mark-id`);if(r&&t.hasRegistration(r))return r;let i=e.call(n,`data-node-id`);if(i&&t.hasRegistration(i))return i}n=n.parentElement??null}return null}function CO(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function wO(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var TO=e=>{let t=(0,J.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,Y.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Y.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,X.jsxs)(X.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function EO(e){return e.editorView?.dom??null}function DO(e,t){let n=e;for(;n;){if(n.getAttribute?.(`data-mark-id`)===t||n.getAttribute?.(`data-node-id`)===t)return!0;n=n.parentElement}return!1}function OO(e){let{editor:t}=e,n=new xO,r=EO(t),i=!1,a=null,o=null,s=null,c=null,l=null,u=()=>{a!==null&&(clearTimeout(a),a=null),s=null},d=()=>{o!==null&&(clearTimeout(o),o=null)},f=()=>{c!==null&&(clearTimeout(c),c=null)},p=e=>{if(n.getActiveNode()===e){d();return}s===e&&a!==null||(u(),d(),s=e,a=setTimeout(()=>{a=null,s=null,n.setActiveNode(e)},vO))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!wO()&&n.setActiveNode(null)},yO))},h=null,g=!1,_=e=>{try{g=!0,e.focus({preventScroll:!0})}catch{}finally{g=!1}},v=n.subscribe(()=>{let e=n.getActiveNode();if(e!==null){if(typeof document<`u`){let t=document.activeElement;h=t&&DO(t,e)?t:null}return}if(typeof document>`u`)return;let i=h;if(h=null,i&&document.contains(i)&&typeof i.focus==`function`){_(i);return}let a=r??EO(t);a&&typeof a.focus==`function`&&_(a)}),y=e=>{let t=e;if(t.button!==2){if(t.metaKey||t.ctrlKey||t.button===1){u(),t.button===1&&t.preventDefault?.();return}if(t.pointerType===`touch`){let t=SO(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},bO);return}u()}},b=()=>{f()},x=e=>{e.pointerType===`touch`&&c!==null&&f()},S=e=>{let t=e;if(t.button===2||t.type===`click`&&t.button===1)return;let r=SO(e.target,n);if(r===null)return;if(l!==null){let e=l===r;if(l=null,e){t.preventDefault?.();return}}let i=t.metaKey||t.ctrlKey||t.button===1,a=n.getRegistration(r);if(a?.handlePrimary&&a.handlePrimary({nodeId:r,type:a.type,newTab:i})){t.preventDefault?.(),i||(u(),d(),n.getActiveNode()===r&&n.setActiveNode(null));return}i||(u(),d(),n.setActiveNode(r))},C=e=>{let t=e;if(t.key===`Escape`){n.getActiveNode()!==null&&(u(),d(),n.setActiveNode(null),t.preventDefault?.());return}if(t.key===`Tab`&&!t.shiftKey&&!t.altKey&&!t.metaKey&&!t.ctrlKey){let r=SO(e.target,n);if(r!==null&&n.getActiveNode()===r){let e=document.querySelector(`[data-ok-prop-panel]`);if(e){let n=e.querySelector(`button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(n){t.preventDefault?.(),n.focus();return}}}return}let r=t.key===`Enter`,i=t.key===` `||t.key===`Spacebar`;if(!r&&!i)return;let a=SO(e.target,n);if(a===null||i&&((e.target instanceof Element?e.target:null)?.closest(`[data-mark-id], [data-node-id]`)??null)?.getAttribute(`role`)===`link`)return;let o=n.getRegistration(a);if(t.preventDefault?.(),o?.handlePrimary&&o.handlePrimary({nodeId:a,type:o.type,newTab:!1})){u(),d(),n.getActiveNode()===a&&n.setActiveNode(null);return}n.setActiveNode(a)},w=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target;if(!(r instanceof Element))return;if(CO(r)){d();return}let i=SO(r,n);i!==null&&p(i)},T=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target,i=t.relatedTarget;if(!(r instanceof Element))return;let a=i instanceof Element?i:null,o=SO(r,n);if(o!==null){if(a&&CO(a)){d();return}if(a&&SO(a,n)===o)return;s===o&&u(),m();return}if(CO(r)){if(a&&CO(a))return;let e=n.getActiveNode();if(e!==null&&a&&SO(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=SO(t,n);r!==null&&(u(),d(),n.setActiveNode(r))},D=e=>{let t=e;if(n.getActiveNode()===null)return;let r=t.relatedTarget,i=r instanceof Element?r:null;i&&CO(i)||i&&SO(i,n)!==null||m()},O=e=>{if(n.getActiveNode()===null)return;let t=e.target;t&&(r?.contains(t)||t instanceof Element&&(t.closest(`[data-ok-interaction-layer]`)||t.closest(`[data-ok-prop-panel]`)||t.closest(`[data-ok-layer-spawned]`))||(u(),d(),n.setActiveNode(null)))},k=()=>{i||(r=EO(t),r&&(r.addEventListener(`pointerdown`,y,!0),r.addEventListener(`pointerup`,b,!0),r.addEventListener(`pointercancel`,b,!0),r.addEventListener(`pointermove`,x,!0),r.addEventListener(`click`,S,!0),r.addEventListener(`auxclick`,S,!0),r.addEventListener(`keydown`,C,!0),typeof document<`u`&&(document.addEventListener(`pointerover`,w,!0),document.addEventListener(`pointerout`,T,!0),document.addEventListener(`focusin`,E,!0),document.addEventListener(`focusout`,D,!0),document.addEventListener(`pointerdown`,O,!0)),i=!0))},A=()=>{i&&=(r?.removeEventListener(`pointerdown`,y,!0),r?.removeEventListener(`pointerup`,b,!0),r?.removeEventListener(`pointercancel`,b,!0),r?.removeEventListener(`pointermove`,x,!0),r?.removeEventListener(`click`,S,!0),r?.removeEventListener(`auxclick`,S,!0),r?.removeEventListener(`keydown`,C,!0),typeof document<`u`&&(document.removeEventListener(`pointerover`,w,!0),document.removeEventListener(`pointerout`,T,!0),document.removeEventListener(`focusin`,E,!0),document.removeEventListener(`focusout`,D,!0),document.removeEventListener(`pointerdown`,O,!0)),!1)};return k(),{register(e){n.register(e),i||k()},deregister(e){n.deregister(e)},setActiveNode(e){n.setActiveNode(e)},getActiveNode(){return n.getActiveNode()},getRegistration(e){return n.getRegistration(e)},destroy(){A(),u(),d(),f(),v(),n.clear()},store:n}}var kO=e=>{let t=(0,J.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,X.jsx)(TO,{store:n})}),t[0]=n,t[1]=r),r},AO=new WeakMap;function jO(e){let t=AO.get(e);if(t)return t;let n=OO({editor:e});return AO.set(e,n),e.on(`destroy`,()=>{n.destroy(),AO.delete(e)}),n}var MO={AppWindow:ki,ChevronRight:rr,CopyPlus:Wi,FileText:Xi,Film:$i,GitBranch:na,Image:sa,LayoutPanelTop:ua,MessageSquareWarning:ya,PanelTop:Ca,Paperclip:wa,Sigma:ja,SquarePlay:Na,Volume2:Va,Workflow:Ha,ZoomIn:Wa};function NO(e){return e&&Object.hasOwn(MO,e)?MO[e]:Ni}var PO={ChevronRight:rr};function FO(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(PO,t)?PO[t]:null}function IO(e){let t=(0,J.c)(24),n;t[0]===e.icon?n=t[1]:(n=FO(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(rr,{size:14,className:`accordion-chevron`,"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=r?(0,X.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[3]=r,t[4]=o);let s=e.title??`Accordion`,c;t[5]===s?c=t[6]:(c=(0,X.jsx)(`span`,{className:`accordion-title`,children:s}),t[5]=s,t[6]=c);let l;t[7]===e.description?l=t[8]:(l=e.description?(0,X.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[7]=e.description,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(`span`,{className:`accordion-title-group`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==u?(d=(0,X.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,o,u]}),t[12]=o,t[13]=u,t[14]=d):d=t[14];let f;t[15]===e.children?f=t[16]:(f=(0,X.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[15]=e.children,t[16]=f);let p;return t[17]!==e.defaultOpen||t[18]!==e.id||t[19]!==e.name||t[20]!==i||t[21]!==d||t[22]!==f?(p=(0,X.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[d,f]}),t[17]=e.defaultOpen,t[18]=e.id,t[19]=e.name,t[20]=i,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function LO(e){return e!==!1}function RO(e){let t=(0,J.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:m(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=LO(e.controls),t[2]=e.controls,t[3]=i);let a;return t[4]!==e.autoplay||t[5]!==e.loop||t[6]!==e.muted||t[7]!==e.preload||t[8]!==e.title||t[9]!==n||t[10]!==i?(a=(0,X.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[4]=e.autoplay,t[5]=e.loop,t[6]=e.muted,t[7]=e.preload,t[8]=e.title,t[9]=n,t[10]=i,t[11]=a):a=t[11],a}var zO={note:ca,tip:da,important:ya,warning:he,caution:xa,abstract:Vi,info:Mi,todo:ga,success:p,question:zi,failure:Bi,danger:Ua,bug:Pi,example:ea,quote:Da},BO={Info:ca,Lightbulb:da,MessageSquareWarning:ya,AlertTriangle:he,AlertOctagon:xa,ClipboardList:Vi,BookOpen:Mi,ListTodo:ga,CircleCheck:p,CircleHelp:zi,CircleX:Bi,Zap:Ua,Bug:Pi,FlaskConical:ea,Quote:Da};function VO(e,t){if(!e||!e.startsWith(`lucide:`))return zO[t];let n=e.slice(7);return Object.hasOwn(BO,n)?BO[n]:zO[t]}var HO=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function UO(e){return typeof e==`string`&&HO.has(e)?e:`note`}function WO(e){let t=(0,J.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=UO(e.type),n=VO(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,a;t[4]===e.color?a=t[5]:(a=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=a);let s=a,c;t[6]!==i||t[7]!==e.title?(c=e.title||i?(0,X.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,X.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,X.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=c):c=t[8];let l=c;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===l?i=t[10]:(i=l??(0,X.jsx)(`span`,{className:`callout-title`,children:(0,X.jsx)(o,{id:`URmyfc`})}),t[9]=l,t[10]=i);let a;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Ii,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=a):a=t[11];let c;t[12]===i?c=t[13]:(c=(0,X.jsxs)(`summary`,{className:`callout-summary`,contentEditable:!1,children:[i,a]}),t[12]=i,t[13]=c);let u;t[14]===e.children?u=t[15]:(u=(0,X.jsx)(`div`,{className:`callout-body`,children:e.children}),t[14]=e.children,t[15]=u);let d;return t[16]!==n||t[17]!==s||t[18]!==c||t[19]!==u||t[20]!==r?(d=(0,X.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:s,children:[c,u]}),t[16]=n,t[17]=s,t[18]=c,t[19]=u,t[20]=r,t[21]=d):d=t[21],d}let u;t[22]===e.children?u=t[23]:(u=(0,X.jsx)(`div`,{className:`callout-body`,children:e.children}),t[22]=e.children,t[23]=u);let d;return t[24]!==l||t[25]!==s||t[26]!==u||t[27]!==r?(d=(0,X.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:s,children:[l,u]}),t[24]=l,t[25]=s,t[26]=u,t[27]=r,t[28]=d):d=t[28],d}var GO=(0,Y.createContext)(null);function KO(e){let t=(0,J.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(GO.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function qO(){return(0,Y.use)(GO)}var JO=[{key:`tl`,dx:-1,dy:-1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--tl`},{key:`t`,dx:0,dy:-1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--t`},{key:`tr`,dx:1,dy:-1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--tr`},{key:`r`,dx:1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--r`},{key:`br`,dx:1,dy:1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--br`},{key:`b`,dx:0,dy:1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--b`},{key:`bl`,dx:-1,dy:1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--bl`},{key:`l`,dx:-1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--l`}];function YO(e){let t=(0,J.c)(7),{targetRef:n,onResize:r,onResizeEnd:a,bounds:o}=e,{_:s}=i(),c=(0,Y.useRef)(null),l;t[0]!==o?.maxHeight||t[1]!==o?.maxWidth||t[2]!==o?.minHeight||t[3]!==o?.minWidth?(l=function(e,t){let n=t===`w`?o?.minWidth??64:o?.minHeight??64,r=t===`w`?o?.maxWidth??1/0:o?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=o?.maxHeight,t[1]=o?.maxWidth,t[2]=o?.minHeight,t[3]=o?.minWidth,t[4]=l):l=t[4];let u=l,d=function(e,t){let i=n.current;if(!i)return;e.preventDefault(),e.stopPropagation();let o=i.getBoundingClientRect();c.current={handle:t,startX:e.clientX,startY:e.clientY,startWidth:o.width,startHeight:o.height,latestWidth:o.width,latestHeight:o.height,hasMoved:!1},document.body.style.setProperty(`cursor`,t.cursor),document.body.style.setProperty(`user-select`,`none`);let s=function(e){let t=c.current;if(!t)return;let n=(e.clientX-t.startX)*t.handle.dx,i=(e.clientY-t.startY)*t.handle.dy,a=t.handle.dx===0?t.startWidth:u(t.startWidth+n,`w`),o=t.handle.dy===0?t.startHeight:u(t.startHeight+i,`h`);t.latestWidth=a,t.latestHeight=o,t.hasMoved=!0,r({width:a,height:o})};function l(){let e=c.current;if(!e)return;let t={width:e.latestWidth,height:e.latestHeight},n=e.hasMoved;c.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l),n&&a?.(t)}window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},f=JO.map(e=>{let t=e.key;return(0,X.jsx)(`button`,{type:`button`,className:yn(e.className),"aria-label":s({id:`NxW-md`,values:{handleKey:t}}),tabIndex:-1,style:{cursor:e.cursor},onPointerDown:t=>d(t,e)},t)}),p;return t[5]===f?p=t[6]:(p=(0,X.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:f}),t[5]=f,t[6]=p),p}var XO=`26rem`,ZO=`Embedded content`,QO=/^https?:\/\//i;function $O(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function ek(e){return!(typeof e!=`string`||!QO.test(e)||!$O(e))}function tk(e){let t=(0,J.c)(21),{src:n,title:r,width:i,height:a}=e,o=(0,Y.useRef)(null),s=qO(),c=i||void 0,l=a||XO,u;t[0]!==c||t[1]!==l?(u={width:c,height:l},t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f,p;if(t[3]!==a||t[4]!==i?(f=()=>{let e=o.current;e&&(e.style.width=i||``,e.style.height=a||XO)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Y.useEffect)(f,p),!ek(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=QO.test(n)?`Embed only supports cross-origin URLs`:`URL must start with http:// or https://`);let r;return t[7]===e?r=t[8]:(r=(0,X.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,X.jsx)(`span`,{children:e})}),t[7]=e,t[8]=r),r}let m;t[9]===s?m=t[10]:(m=e=>{if(!s)return;let{editor:t,getPos:n}=s,r=n();if(typeof r==`number`)try{let n=t.state.doc.nodeAt(r);if(!n||n.type.name!==`jsxComponent`)return;let i={...n.attrs.props??{},width:`${Math.round(e.width)}px`,height:`${Math.round(e.height)}px`};t.view.dispatch(t.state.tr.setNodeMarkup(r,null,{...n.attrs,props:i,sourceDirty:!0}))}catch(e){let t=e;if(t instanceof RangeError)return;throw t}},t[9]=s,t[10]=m);let h=m,g=r||ZO,_;t[11]!==n||t[12]!==g?(_=(0,X.jsx)(`iframe`,{title:g,src:n,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:`no-referrer`,loading:`lazy`,className:`ok-embed-frame`}),t[11]=n,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==s||t[15]!==h?(v=s?(0,X.jsx)(YO,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[14]=s,t[15]=h,t[16]=v):v=t[16];let y;return t[17]!==d||t[18]!==_||t[19]!==v?(y=(0,X.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[_,v]}),t[17]=d,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function nk(e){if(!e)return``;let t,n=null;try{let r=new URL(e,`https://placeholder.local`);n=r.protocol,t=r.pathname}catch{t=e.split(`?`)[0]??e}if(n===`data:`||n===`blob:`)return``;let r=t.split(`/`),i=r[r.length-1]??``;try{return decodeURIComponent(i)}catch{return i}}function rk(e){let t=(0,J.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||nk(e.src)||`Untitled file`,t[0]=e.name,t[1]=e.src,t[2]=n):n=t[2];let r=n,i=e.size?.trim()?e.size:null,a;t[3]===e.src?a=t[4]:(a=e.src?m(e.src):void 0,t[3]=e.src,t[4]=a);let o=a,s;t[5]===o?s=t[6]:(s=e=>{e.stopPropagation(),e.preventDefault(),o&&window.open(o,`_blank`,`noopener,noreferrer`)},t[5]=o,t[6]=s);let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(Zi,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,X.jsx)(`span`,{className:`ok-file-name`,children:r}),t[8]=r,t[9]=u);let d;t[10]===i?d=t[11]:(d=i?(0,X.jsx)(`span`,{className:`ok-file-size`,children:i}):null,t[10]=i,t[11]=d);let f;return t[12]!==c||t[13]!==o||t[14]!==e.title||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:ik,onClick:c,children:[l,u,d]}),t[12]=c,t[13]=o,t[14]=e.title,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function ik(e){return e.stopPropagation()}function ak(){return Y.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Y.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function ok(){return Y.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Y.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function sk(e){return typeof Element>`u`?!1:e instanceof Element}var ck=(e,t)=>sk(t)&&t.tagName.toUpperCase()===e,lk=e=>ck(`DIV`,e)||ck(`SPAN`,e),uk=e=>ck(`IMG`,e),dk=e=>e.complete&&e.naturalHeight!==0,fk=e=>ck(`SVG`,e),pk=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),mk=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=pk({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},hk=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?mk({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):pk({height:e,offset:r,width:t}),gk=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,_k=e=>{if(e!==null){if(uk(e))return e.currentSrc===``?void 0:e.currentSrc;if(lk(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return gk.exec(t)?.[1]}}},vk=e=>{if(e!==null)return uk(e)?e.alt:e.getAttribute(`aria-label`)??void 0},yk=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=hk({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},bk=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},xk=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=bk({position:p,relativeNum:r-l*f}),g=bk({position:m,relativeNum:e-c*f}),_=hk({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=bk({position:a,relativeNum:r-l}),f=bk({position:u,relativeNum:e-c}),p=hk({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=hk({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},Sk=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=bk({position:p,relativeNum:a-l*f}),g=bk({position:m,relativeNum:n-c*f}),_=hk({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=bk({position:t,relativeNum:a-l}),f=bk({position:u,relativeNum:n-c}),p=hk({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=bk({position:u,relativeNum:a}),p=bk({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=bk({position:_,relativeNum:a-l*g}),b=bk({position:v,relativeNum:n-c*g}),x=hk({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},Ck=/\.svg$/i,wk=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&Ck.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&lk(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=yk({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?xk({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?Sk({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},Tk=e=>{if(e==null)return{};if(fk(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},Ek=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},Dk=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),Ok={overflow:``,width:``};function kk(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function Ak(e){e.preventDefault()}function jk(e){return Y.createElement(Mk,{...e})}var Mk=class extends Y.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Y.createRef(),this.refDialog=Y.createRef(),this.refModalContent=Y.createRef(),this.refModalImg=Y.createRef(),this.refWrap=Y.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=Ok,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(Dk),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:Tk(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:Tk(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=_k(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(uk(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:Tk(this.imgEl)})};t.decode().then(r).catch(()=>{if(dk(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||fk(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=Ok},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(dk(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(fk(e)){let r=e.cloneNode(!0);Ek(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=lk(a),j=uk(a),M=fk(a),N=vk(a),P=_k(a),F=j?a.sizes:void 0,ee=j?a.srcset:void 0,I=j?a.crossOrigin:void 0,L=h?.src!==void 0&&h.src!==``,te=this.hasImage(),ne=N!==void 0&&N!==``?`${s}: ${N}`:s,re=T===`LOADING`||T===`LOADED`,R=te?`found`:`not-found`,z=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,ie={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=te&&a!==null?wk({hasZoomImg:L,imgSrc:P,isSvg:M,isZoomed:f&&re,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let B=null;if(te){let t=j||A?Y.createElement(`img`,{alt:N,crossOrigin:I,sizes:F,src:P,srcSet:ee,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Y.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Y.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Y.createElement(u,null));B=m==null?Y.createElement(Y.Fragment,null,t,n):Y.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Y.createElement(p,{"aria-owns":te?O:void 0,"data-rmiz":``,ref:x},Y.createElement(p,{"data-rmiz-content":R,ref:_,style:ie},c),te&&Y.createElement(p,{"data-rmiz-ghost":``,style:D},Y.createElement(`button`,{"aria-label":ne,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Y.createElement(d,null))),te&&Ya.createPortal(Y.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Ak,ref:v,role:`dialog`},Y.createElement(`div`,{"data-rmiz-modal-overlay":z}),Y.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},B)),kk()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};Mk.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:ak,IconZoom:ok,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function Nk({onZoomChange:e,...t}){let[n,r]=Y.useState(!1),i=Y.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Y.createElement(jk,{...t,isZoomed:n,onZoomChange:i})}function Pk(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function Fk(e,t,n){return Pk(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function Ik(e){let t=(0,J.c)(52),n,r,a,o,s,c,l,u,d,f,p,m;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12]):({width:m,height:r,loadingTestId:d,slotTestId:f,slotClassName:c,className:n,onLoad:s,onError:o,src:l,style:u,alt:p,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m);let h=d===void 0?`image-loading-skeleton`:d,g=f===void 0?`image-slot`:f,_=p===void 0?``:p,{_:v}=i(),y=(0,Y.useRef)(null),[b,x]=(0,Y.useState)(!1),S;t[13]!==r||t[14]!==m?(S=Pk(m,r),t[13]=r,t[14]=m,t[15]=S):S=t[15];let C=S,w;t[16]!==r||t[17]!==u||t[18]!==m?(w=Fk(m,r,u),t[16]=r,t[17]=u,t[18]=m,t[19]=w):w=t[19];let T=w,E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{y.current?.complete?x(!0):x(!1)},t[20]=E):E=t[20];let D;t[21]===l?D=t[22]:(D=[l],t[21]=l,t[22]=D),(0,Y.useLayoutEffect)(E,D);let O=!C&&!b&&`aspect-[16/9] w-full max-w-full`,k;t[23]!==c||t[24]!==O?(k=yn(`relative inline-block overflow-hidden`,O,c),t[23]=c,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==v||t[27]!==b||t[28]!==h?(A=!b&&(0,X.jsx)(`span`,{"data-testid":h,role:`status`,"aria-busy":`true`,"aria-label":v({id:`N1YYa7`}),className:`absolute inset-0 animate-pulse rounded-md bg-muted motion-reduce:animate-none`}),t[26]=v,t[27]=b,t[28]=h,t[29]=A):A=t[29];let j=b?`opacity-100`:`opacity-0`,M;t[30]!==n||t[31]!==j?(M=yn(`block max-w-full transition-opacity motion-reduce:transition-none`,j,n),t[30]=n,t[31]=j,t[32]=M):M=t[32];let N;t[33]===s?N=t[34]:(N=e=>{x(!0),s?.(e)},t[33]=s,t[34]=N);let P;t[35]===o?P=t[36]:(P=e=>{x(!0),o?.(e)},t[35]=o,t[36]=P);let F;t[37]!==_||t[38]!==r||t[39]!==a||t[40]!==l||t[41]!==M||t[42]!==N||t[43]!==P||t[44]!==m?(F=(0,X.jsx)(`img`,{...a,ref:y,src:l,alt:_,width:m,height:r,className:M,onLoad:N,onError:P}),t[37]=_,t[38]=r,t[39]=a,t[40]=l,t[41]=M,t[42]=N,t[43]=P,t[44]=m,t[45]=F):F=t[45];let ee;return t[46]!==T||t[47]!==g||t[48]!==A||t[49]!==F||t[50]!==k?(ee=(0,X.jsxs)(`span`,{"data-testid":g,className:k,style:T,children:[A,F]}),t[46]=T,t[47]=g,t[48]=A,t[49]=F,t[50]=k,t[51]=ee):ee=t[51],ee}function Lk(e){return e??`lazy`}function Rk(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function zk(e){let t=(0,J.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:m(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=Rk(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=Rk(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=Lk(e.loading),t[6]=e.loading,t[7]=s);let c;return t[8]!==e.crossorigin||t[9]!==e.decoding||t[10]!==e.fetchpriority||t[11]!==e.referrerpolicy||t[12]!==e.sizes||t[13]!==e.srcset||t[14]!==e.title||t[15]!==n||t[16]!==r||t[17]!==i||t[18]!==a||t[19]!==s?(c=(0,X.jsx)(Ik,{src:n,alt:r,width:i,height:a,title:o,loading:s,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy}),t[8]=e.crossorigin,t[9]=e.decoding,t[10]=e.fetchpriority,t[11]=e.referrerpolicy,t[12]=e.sizes,t[13]=e.srcset,t[14]=e.title,t[15]=n,t[16]=r,t[17]=i,t[18]=a,t[19]=s,t[20]=c):c=t[20],c}function Bk(e){let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,X.jsx)(Nk,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,X.jsx)(zk,{...e})}),t[1]=e,t[2]=r),r}var Vk=(0,Y.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DX-tM4Fr.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,J.c)(7),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!0,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={__html:i},n[2]=i,n[3]=a);let o;return n[4]!==t.id||n[5]!==a?(o=(0,X.jsx)(`div`,{className:`math math-display`,"data-component-type":`math`,id:t.id,dangerouslySetInnerHTML:a}),n[4]=t.id,n[5]=a,n[6]=o):o=n[6],o}return{default:t}});function Hk(e){let t=(0,J.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,X.jsx)(`div`,{className:`math math-placeholder`,"data-component-type":`math`,id:e.id,children:n}),t[0]=e.id,t[1]=n,t[2]=r):r=t[2],r}function Uk(e){let t=(0,J.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,X.jsx)(Hk,{formula:n,id:e.id}),t[0]=n,t[1]=e.id,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e.id?(r=(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(Hk,{formula:n,id:e.id}),children:(0,X.jsx)(Vk,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}var Wk=null;function Gk(){return Wk||=n(()=>import(`./mermaid.core-DRx0wZe0.js`).then(e=>{let t=e.default;return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`default`,suppressErrorRendering:!0}),t}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),import.meta.url).catch(e=>{throw Wk=null,e}),Wk}function Kk(e){let t=(0,J.c)(24),n=e.chart??``,r=(0,Y.useId)(),i;if(t[0]!==r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/:/g,t[2]=e):e=t[2],i=r.replace(e,`_`),t[0]=r,t[1]=i}else i=t[1];let a=`mermaid-${i}`,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={status:`idle`,svg:``,error:``},t[3]=s):s=t[3];let[c,l]=(0,Y.useState)(s),u,d;if(t[4]!==n||t[5]!==a?(u=()=>{if(!n.trim()){l({status:`idle`,svg:``,error:``});return}let e=!1;return l(qk),Gk().then(async t=>{try{let r=await t.render(a,n);e||l({status:`ready`,svg:r.svg,error:``})}catch(t){let n=t;e||l({status:`error`,svg:``,error:n instanceof Error?n.message:String(n)})}}).catch(t=>{e||l({status:`error`,svg:``,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},d=[n,a],t[4]=n,t[5]=a,t[6]=u,t[7]=d):(u=t[6],d=t[7]),(0,Y.useEffect)(u,d),!n.trim()){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`mermaid mermaid-placeholder`,"data-component-type":`mermaid`,children:(0,X.jsx)(`span`,{className:`mermaid-empty`,children:` `})}),t[8]=e):e=t[8],e}if(c.status===`error`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(he,{className:`size-3.5 shrink-0 mt-0.5`,"aria-hidden":!0}),t[9]=e):e=t[9];let r;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(`div`,{className:`font-medium`,children:(0,X.jsx)(o,{id:`OLBz-_`})}),t[10]=r):r=t[10];let i;t[11]===c.error?i=t[12]:(i=(0,X.jsxs)(`div`,{role:`alert`,className:`mermaid-error-message mb-2 flex items-start gap-2 rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive`,children:[e,(0,X.jsxs)(`div`,{className:`min-w-0`,children:[r,(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words font-mono text-[11px] opacity-90`,children:c.error})]})]}),t[11]=c.error,t[12]=i);let a;t[13]===n?a=t[14]:(a=(0,X.jsx)(`pre`,{className:`mermaid-error-source`,children:n}),t[13]=n,t[14]=a);let s;return t[15]!==c.error||t[16]!==i||t[17]!==a?(s=(0,X.jsxs)(`div`,{className:`mermaid mermaid-error`,"data-component-type":`mermaid`,title:c.error,children:[i,a]}),t[15]=c.error,t[16]=i,t[17]=a,t[18]=s):s=t[18],s}let f=`mermaid mermaid-${c.status}`,p;t[19]===c.svg?p=t[20]:(p={__html:c.svg},t[19]=c.svg,t[20]=p);let m;return t[21]!==f||t[22]!==p?(m=(0,X.jsx)(`div`,{className:f,"data-component-type":`mermaid`,dangerouslySetInnerHTML:p}),t[21]=f,t[22]=p,t[23]=m):m=t[23],m}function qk(e){return{...e,status:`rendering`}}var Jk=null;function Yk(){return Jk||=new N({extensions:_e}),Jk}function Xk(e,t){if(e.type===`mdxJsxFlowElement`){let n=e;if(n.name===`MirrorSource`){for(let e of n.attributes??[])if(e.type===`mdxJsxAttribute`&&e.name===`id`&&typeof e.value==`string`&&e.value===t)return n}}let n=e.children;if(Array.isArray(n))for(let e of n){let n=Xk(e,t);if(n)return n}return null}function Zk(e){return cn({type:`root`,children:e.children??[]})}var Qk=new Map,$k=30,eA=150,tA=1e4;function nA(e,t){let n=`${e}|${t}`,r=Qk.get(n);if(r)return r.refcount+=1,r;let i=new Km,a=new LE({url:e,name:t,document:i}),o=new Set,s={provider:a,ySource:i.getText(`source`),refcount:1,synced:!1,subscribers:o};return a.on(`synced`,()=>{s.synced=!0;for(let e of o)e.onSynced()}),s.ySource.observe(()=>{for(let e of o)e.onUpdate()}),Qk.set(n,s),Qk.size>$k&&console.warn(`[Mirror] provider pool exceeded ${$k} entries (current=${Qk.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function rA(e,t){let n=`${e}|${t}`,r=Qk.get(n);if(r&&(--r.refcount,r.refcount<=0)){try{r.provider.destroy()}catch(e){console.warn(`[Mirror] provider.destroy() failed during release`,{src:t,err:e})}Qk.delete(n)}}function iA(e,t){let n=(0,J.c)(8),{collabUrl:r}=Bx(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Y.useState)(i),s=(0,Y.useRef)(t),c=(0,Y.useRef)(null),l,u;n[1]!==r||n[2]!==e?(l=()=>{if(!e){o({kind:`empty-props`});return}if(!r){o({kind:`loading`});return}let t=nA(r,e),n=()=>{let n=s.current;if(!n){o({kind:`empty-props`});return}let r=t.ySource.toString();if(!r){o(t.synced?{kind:`source-removed`}:{kind:`loading`});return}let i;try{i=Yk().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=Xk(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=Zk(a)}catch(t){console.warn(`[Mirror] renderMirrorSubtree failed`,{src:e,anchor:n,err:t}),o({kind:`anchor-not-found`});return}o({kind:`ready`,html:c})},i=null,a={onUpdate:()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,n()},eA)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},tA);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,rA(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Y.useEffect)(l,u);let d,f;return n[5]===t?(d=n[6],f=n[7]):(d=()=>{s.current=t,c.current?.()},f=[t],n[5]=t,n[6]=d,n[7]=f),(0,Y.useEffect)(d,f),a}function aA(e){let t=(0,J.c)(8),n=`ok-mirror-state flex items-start gap-2 rounded-md border border-dashed px-3 py-2 text-sm ${e.tone===`error`?`border-destructive/40 text-destructive`:`border-border text-muted-foreground`}`,r;t[0]===e.tone?r=t[1]:(r=e.tone===`error`?(0,X.jsx)(fa,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(ma,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),t[0]=e.tone,t[1]=r);let i;t[2]===e.children?i=t[3]:(i=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),t[2]=e.children,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,X.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function oA(e){let t=(0,J.c)(30),n=e.src??``,r=e.anchor??``,i=iA(n,r);if(i.kind===`empty-props`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(aA,{tone:`placeholder`,children:(0,X.jsx)(o,{id:`3SDfZl`,components:{0:(0,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{}),2:(0,X.jsx)(`code`,{}),3:(0,X.jsx)(`code`,{})}})}),t[0]=e):e=t[0],e}if(i.kind===`loading`){let e=n&&r?`${n}#${r}`:``,i;t[1]===e?i=t[2]:(i={mirrorRef:e},t[1]=e,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a={0:(0,X.jsx)(`code`,{})},t[3]=a):a=t[3];let s;return t[4]===i?s=t[5]:(s=(0,X.jsx)(aA,{tone:`placeholder`,children:(0,X.jsx)(o,{id:`92rbk2`,values:i,components:a})}),t[4]=i,t[5]=s),s}if(i.kind===`source-removed`){let e;t[6]===n?e=t[7]:(e={src:n},t[6]=n,t[7]=e);let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{})},t[8]=r):r=t[8];let i;return t[9]===e?i=t[10]:(i=(0,X.jsx)(aA,{tone:`error`,children:(0,X.jsx)(o,{id:`Ud0Pj9`,values:e,components:r})}),t[9]=e,t[10]=i),i}if(i.kind===`anchor-not-found`){let e=`<MirrorSource id="${r}">`,i;t[11]!==e||t[12]!==n?(i={mirrorSourceTag:e,src:n},t[11]=e,t[12]=n,t[13]=i):i=t[13];let a;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(a={0:(0,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{}),2:(0,X.jsx)(`code`,{})},t[14]=a):a=t[14];let s;return t[15]===i?s=t[16]:(s=(0,X.jsx)(aA,{tone:`error`,children:(0,X.jsx)(o,{id:`mqSwZH`,values:i,components:a})}),t[15]=i,t[16]=s),s}let a;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Gi,{className:`size-3`,"aria-hidden":`true`}),t[17]=a):a=t[17];let s;t[18]===n?s=t[19]:(s={src:n},t[18]=n,t[19]=s);let c;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(c={0:(0,X.jsx)(`code`,{className:`font-mono`})},t[20]=c):c=t[20];let l;t[21]===s?l=t[22]:(l=(0,X.jsxs)(`div`,{className:`ok-mirror-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,"aria-hidden":`true`,children:[a,(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`wQp1V3`,values:s,components:c})})]}),t[21]=s,t[22]=l);let u;t[23]===i.html?u=t[24]:(u=(0,X.jsx)(`div`,{dangerouslySetInnerHTML:{__html:i.html}}),t[23]=i.html,t[24]=u);let d;return t[25]!==r||t[26]!==n||t[27]!==l||t[28]!==u?(d=(0,X.jsxs)(`div`,{className:`ok-mirror-resolved relative -mx-3 prose-no-margin rounded-md border border-dashed border-transparent px-3 py-2 transition-colors [.jsx-component-wrapper:hover_&]:border-border/40 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/40`,"data-mirror-src":n,"data-mirror-anchor":r,children:[l,u]}),t[25]=r,t[26]=n,t[27]=l,t[28]=u,t[29]=d):d=t[29],d}function sA(e){let t=(0,J.c)(15),{_:n}=i(),r=e.id??``,a;t[0]!==n||t[1]!==r?(a=r||n({id:`12F9WL`}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let s=a,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(Wi,{className:`size-3`,"aria-hidden":`true`}),t[3]=c):c=t[3];let l;t[4]===s?l=t[5]:(l={label:s},t[4]=s,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={0:(0,X.jsx)(`code`,{className:`font-mono`})},t[6]=u):u=t[6];let d;t[7]===l?d=t[8]:(d=(0,X.jsxs)(`div`,{className:`ok-mirror-source-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,children:[c,(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`Zon_qG`,values:l,components:u})})]}),t[7]=l,t[8]=d);let f;t[9]===e.children?f=t[10]:(f=(0,X.jsx)(`div`,{children:e.children}),t[9]=e.children,t[10]=f);let p;return t[11]!==r||t[12]!==d||t[13]!==f?(p=(0,X.jsxs)(`div`,{className:`ok-mirror-source relative -mx-3 rounded-md border border-dashed border-transparent px-3 py-1 transition-colors [.jsx-component-wrapper:hover_&]:border-border/50 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/50`,"data-mirror-source-id":r,children:[d,f]}),t[11]=r,t[12]=d,t[13]=f,t[14]=p):p=t[14],p}var cA=24,lA=24,uA=12,dA=.1;function fA(e,t,n,r){if(n<=0&&(e===`fit-width`||e===`two-odd`||e===`two-even`)||r<=0&&e===`fit-height`)return 1;switch(e){case`fit-width`:return Math.max(dA,(n-cA)/t.naturalWidth);case`fit-height`:return Math.max(dA,(r-lA)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(dA,((n-cA)/2-uA)/t.naturalWidth)}}var pA=600,mA=.5,hA=3,gA=.25,_A=null;function vA(){return _A||(_A=(async()=>{let e=await n(()=>import(`./pdf-wFLJduM2.js`),__vite__mapDeps([24,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-CP44mBOj.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),_A.catch(()=>{_A=null})),_A}function yA(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function bA(e){let t=(0,J.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=yt(e.anchor);n=i===null?e.fillContainer?`100%`:`${pA}px`:`${i}px`,r=EA(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let a=r,s=(0,Y.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Y.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Y.useRef)(u),f=(0,Y.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[h,g]=(0,Y.useState)(p),[_,v]=(0,Y.useState)(!0),[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(a??1),[C,w]=(0,Y.useState)(String(a??1)),[T,E]=(0,Y.useState)(1),[D,O]=(0,Y.useState)(`fit-width`),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)(0),[F,ee]=(0,Y.useState)(0),{_:I}=i(),L=h.length,te,ne;t[7]!==I||t[8]!==e.src?(te=()=>{if(!e.src){v(!1);return}let t=m(e.src),n=!1,r=null;return v(!0),b(null),(async()=>{try{let e=await(await vA()).getDocument({url:t,isEvalSupported:!1}).promise;if(n){await e.destroy();return}r=e,f.current=e;let i=[];for(let t=1;t<=e.numPages;t++){if(n)return;let r=(await e.getPage(t)).getViewport({scale:1});i.push({pageNumber:t,naturalWidth:r.width,naturalHeight:r.height})}if(n)return;g(i)}catch(e){let t=e;if(n)return;b(t instanceof Error?t.message:I({id:`jRHdCz`})),v(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),f.current=null}},ne=[e.src,I],t[7]=I,t[8]=e.src,t[9]=te,t[10]=ne):(te=t[9],ne=t[10]),(0,Y.useEffect)(te,ne);let re,R;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{let e=s.current;if(!e)return;let t=()=>{P(e.clientWidth),ee(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},R=[],t[11]=re,t[12]=R):(re=t[11],R=t[12]),(0,Y.useEffect)(re,R);let z,ie;t[13]!==I||t[14]!==F||t[15]!==N||t[16]!==D||t[17]!==h||t[18]!==T?(z=()=>{let e=f.current;if(!e||h.length===0||N===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of h){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=fA(D,i,N,F)*T,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}t||v(!1)}catch(e){let n=e;if(t||yA(n))return;console.warn(`[Pdf] page render failed:`,n),b(n instanceof Error?n.message:I({id:`_TF8ep`})),v(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},ie=[h,D,T,N,F,I],t[13]=I,t[14]=F,t[15]=N,t[16]=D,t[17]=h,t[18]=T,t[19]=z,t[20]=ie):(z=t[19],ie=t[20]),(0,Y.useEffect)(z,ie);let B,V;t[21]!==h||t[22]!==k?(B=()=>{if(!k)return;let e=f.current;if(!e||h.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of h){if(t)return;let a=d.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let l=a.getContext(`2d`);l&&(l.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:l,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;yA(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},V=[k,h],t[21]=h,t[22]=k,t[23]=B,t[24]=V):(B=t[23],V=t[24]),(0,Y.useEffect)(B,V);let H,U;t[25]!==_||t[26]!==a?(H=()=>{if(_||!a)return;let e=s.current,t=l.current[a-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},U=[_,a],t[25]=_,t[26]=a,t[27]=H,t[28]=U):(H=t[27],U=t[28]),(0,Y.useEffect)(H,U);let ae,oe;t[29]===h?(ae=t[30],oe=t[31]):(ae=()=>{let e=s.current;if(!e||h.length===0)return;let t=!1,n=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let n=e.scrollTop,r=1;for(let t of h){let i=l.current[t.pageNumber-1];i&&i.offsetTop-e.offsetTop<=n+40&&(r=t.pageNumber)}S(r),w(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},oe=[h],t[29]=h,t[30]=ae,t[31]=oe),(0,Y.useEffect)(ae,oe);let se,ce;t[32]===j?(se=t[33],ce=t[34]):(se=()=>{if(!j)return;let e=e=>{let t=e.target,n=s.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){M(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&M(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},ce=[j],t[32]=j,t[33]=se,t[34]=ce),(0,Y.useEffect)(se,ce);let le;t[35]===L?le=t[36]:(le=e=>{let t=Math.max(1,Math.min(L||1,e));S(t),w(String(t));let n=s.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=L,t[36]=le);let ue=le,de;t[37]!==x||t[38]!==ue||t[39]!==C?(de=()=>{let e=Number.parseInt(C,10);if(Number.isNaN(e)){w(String(x));return}ue(e)},t[37]=x,t[38]=ue,t[39]=C,t[40]=de):de=t[40];let fe=de,W;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>E(wA),t[41]=W):W=t[41];let pe=W,me;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>E(CA),t[42]=me):me=t[42];let he=me,ge;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>{O(e),M(!1),E(1)},t[43]=ge):ge=t[43];let _e=ge,ve;t[44]===n?ve=t[45]:(ve={height:n},t[44]=n,t[45]=ve);let G;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>A(SA),t[46]=G):G=t[46];let ye;t[47]!==I||t[48]!==k?(ye=I(k?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=I,t[48]=k,t[49]=ye):ye=t[49];let be;t[50]===I?be=t[51]:(be=I({id:`zo3Dl7`}),t[50]=I,t[51]=be);let xe;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,X.jsx)(Sa,{size:14,"aria-hidden":`true`}),t[52]=xe):xe=t[52];let Se;t[53]!==k||t[54]!==ye||t[55]!==be?(Se=(0,X.jsx)(`button`,{type:`button`,onClick:G,"aria-label":ye,"aria-pressed":k,className:`ok-pdf-btn`,title:be,children:xe}),t[53]=k,t[54]=ye,t[55]=be,t[56]=Se):Se=t[56];let Ce=e.title??`PDF`,we;t[57]===Ce?we=t[58]:(we=(0,X.jsx)(`span`,{className:`ok-pdf-title`,children:Ce}),t[57]=Ce,t[58]=we);let Te;t[59]!==I||t[60]!==j||t[61]!==D||t[62]!==C||t[63]!==fe||t[64]!==L||t[65]!==T?(Te=L>0&&(0,X.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,X.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),fe()},children:(0,X.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:C,onChange:e=>w(e.target.value.replace(/[^0-9]/g,``)),onBlur:fe,"aria-label":I({id:`xsZhu-`})})}),(0,X.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,X.jsx)(o,{id:`1GhYxC`,values:{totalPages:L}})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:he,disabled:T<=mA,"aria-label":I({id:`FjkaiT`}),className:`ok-pdf-btn`,title:I({id:`FjkaiT`}),children:(0,X.jsx)(Ga,{size:14,"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(T*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,onClick:pe,disabled:T>=hA,"aria-label":I({id:`AWOSPo`}),className:`ok-pdf-btn`,title:I({id:`AWOSPo`}),children:(0,X.jsx)(Wa,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>M(xA),"aria-label":I({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":j,className:`ok-pdf-btn`,title:I({id:`rdU729`}),children:(0,X.jsx)(Ii,{size:14,"aria-hidden":`true`})}),j&&(0,X.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,X.jsx)(TA,{label:I({id:`vIxrEk`}),active:D===`fit-width`,onSelect:()=>_e(`fit-width`)}),(0,X.jsx)(TA,{label:I({id:`YlDuro`}),active:D===`fit-height`,onSelect:()=>_e(`fit-height`)}),(0,X.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,X.jsx)(TA,{label:I({id:`BGHHtQ`}),active:D===`single`,onSelect:()=>_e(`single`)}),(0,X.jsx)(TA,{label:I({id:`xK291b`}),active:D===`two-odd`,onSelect:()=>_e(`two-odd`)}),(0,X.jsx)(TA,{label:I({id:`NSnIUP`}),active:D===`two-even`,onSelect:()=>_e(`two-even`)})]})]})]}),t[59]=I,t[60]=j,t[61]=D,t[62]=C,t[63]=fe,t[64]=L,t[65]=T,t[66]=Te):Te=t[66];let Ee;t[67]!==Se||t[68]!==we||t[69]!==Te?(Ee=(0,X.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[Se,we,Te]}),t[67]=Se,t[68]=we,t[69]=Te,t[70]=Ee):Ee=t[70];let De;t[71]!==I||t[72]!==x||t[73]!==ue||t[74]!==h||t[75]!==k?(De=k&&(0,X.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":I({id:`nzaV6Q`}),children:h.map((e,t)=>{let{pageNumber:n}=e;return(0,X.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":x===n||void 0,onClick:()=>ue(n),"aria-label":I({id:`qioCwA`,values:{pageNumber:n}}),children:[(0,X.jsx)(`canvas`,{ref:e=>{d.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,X.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:n})]},n)})}),t[71]=I,t[72]=x,t[73]=ue,t[74]=h,t[75]=k,t[76]=De):De=t[76];let Oe;t[77]===_?Oe=t[78]:(Oe=_&&(0,X.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,X.jsx)(o,{id:`T-654M`})}),t[77]=_,t[78]=Oe);let ke;t[79]===y?ke=t[80]:(ke=y&&(0,X.jsx)(`div`,{className:`ok-pdf-error`,children:(0,X.jsx)(o,{id:`WamGNs`,values:{error:y}})}),t[79]=y,t[80]=ke);let Ae;t[81]!==I||t[82]!==L?(Ae=Array.from({length:L},(e,t)=>{let n=t+1;return(0,X.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":I({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=I,t[82]=L,t[83]=Ae):Ae=t[83];let je;t[84]!==D||t[85]!==Oe||t[86]!==ke||t[87]!==Ae?(je=(0,X.jsxs)(`div`,{className:`ok-pdf-pages`,ref:s,"data-layout":D,children:[Oe,ke,Ae]}),t[84]=D,t[85]=Oe,t[86]=ke,t[87]=Ae,t[88]=je):je=t[88];let Me;t[89]!==De||t[90]!==je?(Me=(0,X.jsxs)(`div`,{className:`ok-pdf-body`,children:[De,je]}),t[89]=De,t[90]=je,t[91]=Me):Me=t[91];let Ne;return t[92]!==ve||t[93]!==Ee||t[94]!==Me?(Ne=(0,X.jsxs)(`div`,{className:`ok-pdf`,style:ve,children:[Ee,Me]}),t[92]=ve,t[93]=Ee,t[94]=Me,t[95]=Ne):Ne=t[95],Ne}function xA(e){return!e}function SA(e){return!e}function CA(e){return Math.max(mA,+(e-gA).toFixed(2))}function wA(e){return Math.min(hA,+(e+gA).toFixed(2))}function TA(e){let t=(0,J.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,X.jsx)(tr,{size:14}),t[0]=e.active,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,X.jsx)(`span`,{className:`ok-pdf-menu-check`,"aria-hidden":`true`,children:r}),t[2]=r,t[3]=i);let a;return t[4]!==e.active||t[5]!==e.label||t[6]!==e.onSelect||t[7]!==n||t[8]!==i?(a=(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.active,className:`ok-pdf-menu-item`,"data-active":n,onClick:e.onSelect,children:[i,e.label]}),t[4]=e.active,t[5]=e.label,t[6]=e.onSelect,t[7]=n,t[8]=i,t[9]=a):a=t[9],a}function EA(e){if(!e)return null;for(let t of e.split(`&`)){let e=t.indexOf(`=`);if(!(e<0)&&t.slice(0,e)===`page`){let n=Number.parseInt(t.slice(e+1),10);if(!Number.isNaN(n)&&n>=1)return n}}return null}function DA(e){let t=(0,J.c)(10),{label:n,id:r,children:i}=e,a=(0,Y.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,X.jsx)(`section`,{className:`tab-panel`,id:s,role:`tabpanel`,"aria-labelledby":c,"data-tab-label":u,"data-tab-id":s,children:i}),t[5]=i,t[6]=s,t[7]=u,t[8]=c,t[9]=d):d=t[9],d}var OA=`[data-component-type="tabs"]`,kA=`[data-node-view-content-react] > .react-renderer`;function AA(e){let t=e.closest(OA);return t?Array.from(e.querySelectorAll(kA)).filter(e=>e.parentElement?.closest(OA)===t).map((e,t)=>{let n=e.querySelector(`[data-tab-label]`);return{index:t,label:(n?.getAttribute(`data-tab-label`))?.trim()||`Tab ${t+1}`,panelId:n?.getAttribute(`data-tab-id`)??null}}):[]}function jA(e){let t=(0,J.c)(26),{id:n,children:r}=e,[i,a]=(0,Y.useState)(0),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0];let[s,c]=(0,Y.useState)(o),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(0),f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=l.current;if(!e)return;let t=AA(e);c(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=f):f=t[1],(0,Y.useLayoutEffect)(f);let p,m;t[2]===s.length?(p=t[3],m=t[4]):(p=()=>{s.length>d.current&&s.length>0&&a(s.length-1),d.current=s.length},m=[s.length],t[2]=s.length,t[3]=p,t[4]=m),(0,Y.useLayoutEffect)(p,m);let h;t[5]===n?h=t[6]:(h=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){a(0);return}let t=l.current;if(!t)return;let r=AA(t).findIndex(t=>t.panelId===e);r<0||(a(r),queueMicrotask(()=>{t.ownerDocument.getElementById(e)?.scrollIntoView({block:`start`,behavior:`auto`})}))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},t[5]=n,t[6]=h),(0,Y.useLayoutEffect)(h);let g=s.length===0?0:Math.min(Math.max(i,0),s.length-1),_;t[7]!==s.length||t[8]!==g?(_=e=>{if(s.length===0)return;let t=null;e.key===`ArrowRight`?t=(g+1)%s.length:e.key===`ArrowLeft`?t=(g-1+s.length)%s.length:e.key===`Home`?t=0:e.key===`End`&&(t=s.length-1),t!==null&&(e.preventDefault(),a(t),(u.current?.querySelectorAll(`[role="tab"]`))?.[t]?.focus())},t[7]=s.length,t[8]=g,t[9]=_):_=t[9];let v=_,y=n?`Tabs: ${n}`:`Tabs`,b;if(t[10]!==s||t[11]!==g){let e;t[13]===g?e=t[14]:(e=e=>(0,X.jsx)(`button`,{id:e.panelId?`${e.panelId}-tab`:void 0,type:`button`,role:`tab`,className:`tabs-strip-pill`,"data-active":e.index===g,"aria-selected":e.index===g,"aria-controls":e.panelId??void 0,tabIndex:e.index===g?0:-1,onMouseDown:MA,onClick:()=>a(e.index),children:e.label},e.index),t[13]=g,t[14]=e),b=s.map(e),t[10]=s,t[11]=g,t[12]=b}else b=t[12];let x;t[15]!==v||t[16]!==y||t[17]!==b?(x=(0,X.jsx)(`div`,{ref:u,role:`tablist`,"aria-label":y,className:`tabs-strip`,contentEditable:!1,onKeyDown:v,children:b}),t[15]=v,t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]!==r||t[20]!==g?(S=(0,X.jsx)(`div`,{ref:l,className:`tabs-content`,"data-active-index":g,children:r}),t[19]=r,t[20]=g,t[21]=S):S=t[21];let C;return t[22]!==n||t[23]!==S||t[24]!==x?(C=(0,X.jsxs)(`div`,{className:`tabs`,id:n,children:[x,S]}),t[22]=n,t[23]=S,t[24]=x,t[25]=C):C=t[25],C}function MA(e){return e.preventDefault()}var NA=typeof global<`u`&&{}.toString.call(global)===`[object global]`,PA=typeof Bun<`u`,FA=typeof Deno<`u`,IA=typeof WebSocketPair==`function`&&caches?.default!==void 0,LA=NA||PA||FA||IA;function RA(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function zA(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function BA(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function VA(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function HA(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function UA(e){let t=(e||``).match(/^(?:https?:)?(?:\/\/)?([^/?]+)/),n=(t&&t[1]||``).replace(`player.`,``);for(let e of[`.videoji.hk`,`.vimeo.work`,`.videoji.cn`])if(n.endsWith(e))return n;return`vimeo.com`}function WA(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.id,n=e.url,r=t||n;if(!r)throw Error(`An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.`);if(BA(r))return`https://vimeo.com/${r}`;if(VA(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var GA=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`addEventListener`,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`removeEventListener`,a=typeof t==`string`?[t]:t;return a.forEach(t=>{e[r](t,n)}),{cancel:()=>a.forEach(t=>e[i](t,n))}};function KA(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:document;if(!e||!t||typeof t.querySelectorAll!=`function`)return null;let n=t.querySelectorAll(`iframe`);for(let t=0;t<n.length;t++)if(n[t]&&n[t].contentWindow===e)return n[t];return null}var qA=Array.prototype.indexOf!==void 0,JA=typeof window<`u`&&window.postMessage!==void 0;if(!LA&&(!qA||!JA))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var YA=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function XA(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e){if(e.WeakMap)return;var t=Object.prototype.hasOwnProperty,n=Object.defineProperty&&function(){try{return Object.defineProperty({},`x`,{value:1}).x===1}catch{}}(),r=function(e,t,r){n?Object.defineProperty(e,t,{configurable:!0,writable:!0,value:r}):e[t]=r};e.WeakMap=function(){function e(){if(this===void 0)throw TypeError(`Constructor WeakMap requires 'new'`);if(r(this,`_id`,a(`_WeakMap`)),arguments.length>0)throw TypeError(`WeakMap iterable is not supported`)}r(e.prototype,`delete`,function(e){if(n(this,`delete`),!i(e))return!1;var t=e[this._id];return t&&t[0]===e?(delete e[this._id],!0):!1}),r(e.prototype,`get`,function(e){if(n(this,`get`),i(e)){var t=e[this._id];if(t&&t[0]===e)return t[1]}}),r(e.prototype,`has`,function(e){if(n(this,`has`),!i(e))return!1;var t=e[this._id];return!!(t&&t[0]===e)}),r(e.prototype,`set`,function(e,t){if(n(this,`set`),!i(e))throw TypeError(`Invalid value used as weak map key`);var a=e[this._id];return a&&a[0]===e?(a[1]=t,this):(r(e,this._id,[e,t]),this)});function n(e,n){if(!i(e)||!t.call(e,`_id`))throw TypeError(n+` method called on incompatible receiver `+typeof e)}function a(e){return e+`_`+o()+`.`+o()}function o(){return Math.random().toString().substring(2)}return r(e,`_polyfill`,!0),e}();function i(e){return Object(e)===e}})(typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:YA);var ZA=XA(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,YA,function(){var e,t,n,r=Object.prototype.toString,i=typeof setImmediate<`u`?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},`x`,{}),e=function(e,t,n,r){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:r!==!1})}}catch{e=function(e,t,n){return e[t]=n,e}}n=function(){var e,n,r;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,a){r=new i(t,a),n?n.next=r:e=r,n=r,r=void 0},drain:function(){var r=e;for(e=n=t=void 0;r;)r.fn.call(r.self),r=r.next}}}();function a(e,r){n.add(e,r),t||=i(n.drain)}function o(e){var t,n=typeof e;return e!=null&&(n==`object`||n==`function`)&&(t=e.then),typeof t==`function`?t:!1}function s(){for(var e=0;e<this.chain.length;e++)c(this,this.state===1?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,t,n){var r,i;try{t===!1?n.reject(e.msg):(r=t===!0?e.msg:t.call(void 0,e.msg),r===n.promise?n.reject(TypeError(`Promise-chain cycle`)):(i=o(r))?i.call(r,n.resolve,n.reject):n.resolve(r))}catch(e){n.reject(e)}}function l(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=o(e))?a(function(){var r=new f(n);try{t.call(e,function(){l.apply(r,arguments)},function(){u.apply(r,arguments)})}catch(e){u.call(r,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&a(s,n))}catch(e){u.call(new f(n),e)}}}function u(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&a(s,t))}function d(e,t,n,r){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},r)})(i)}function f(e){this.def=e,this.triggered=!1}function p(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function m(e){if(typeof e!=`function`)throw TypeError(`Not a function`);if(this.__NPO__!==0)throw TypeError(`Not a promise`);this.__NPO__=1;var t=new p(this);this.then=function(e,n){var r={success:typeof e==`function`?e:!0,failure:typeof n==`function`?n:!1};return r.promise=new this.constructor(function(e,t){if(typeof e!=`function`||typeof t!=`function`)throw TypeError(`Not a function`);r.resolve=e,r.reject=t}),t.chain.push(r),t.state!==0&&a(s,t),r.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){l.call(t,e)},function(e){u.call(t,e)})}catch(e){u.call(t,e)}}var h=e({},`constructor`,m,!1);return m.prototype=h,e(h,`__NPO__`,0,!1),e(m,`resolve`,function(e){var t=this;return e&&typeof e==`object`&&e.__NPO__===1?e:new t(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);t(e)})}),e(m,`reject`,function(e){return new this(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);n(e)})}),e(m,`all`,function(e){var t=this;return r.call(e)==`[object Array]`?e.length===0?t.resolve([]):new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);var i=e.length,a=Array(i),o=0;d(t,e,function(e,t){a[e]=t,++o===i&&n(a)},r)}):t.reject(TypeError(`Not an array`))}),e(m,`race`,function(e){var t=this;return r.call(e)==`[object Array]`?new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);d(t,e,function(e,t){n(t)},r)}):t.reject(TypeError(`Not an array`))}),m})}),QA=new WeakMap;function $A(e,t,n){let r=QA.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),QA.set(e.element,r)}function ej(e,t){return(QA.get(e.element)||{})[t]||[]}function tj(e,t,n){let r=QA.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],QA.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),QA.set(e.element,r),r[t]&&r[t].length===0}function nj(e,t){let n=ej(e,t);if(n.length<1)return!1;let r=n.shift();return tj(e,t,r),r}function rj(e,t){let n=QA.get(e);QA.set(t,n),QA.delete(e)}function ij(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function aj(e,t,n){if(!e.element.contentWindow||!e.element.contentWindow.postMessage)return;let r={method:t};n!==void 0&&(r.value=n);let i=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,`$1`));i>=8&&i<10&&(r=JSON.stringify(r)),e.element.contentWindow.postMessage(r,e.origin)}function oj(e,t){t=ij(t);let n=[],r;if(t.event)t.event===`error`&&ej(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),tj(e,t.data.method,n)}),n=ej(e,`event:${t.event}`),r=t.data;else if(t.method){let i=nj(e,t.method);i&&(n.push(i),r=t.value)}n.forEach(t=>{try{if(typeof t==`function`){t.call(e,r);return}t.resolve(r)}catch{}})}var sj=`airplay.audio_tracks.audiotrack.autopause.autoplay.background.byline.cc.chapter_id.chapters.chromecast.color.colors.controls.disable_context_menu.dnt.end_time.fullscreen.height.id.initial_quality.interactive_params.keyboard.loop.maxheight.max_quality.maxwidth.min_quality.muted.play_button_position.playsinline.portrait.preload.progress_bar.quality.quality_selector.responsive.skipping_forward.speed.start_time.texttrack.thumbnail_id.title.transcript.transparent.unmute_button.url.vimeo_logo.volume.watch_full_video.width`.split(`.`);function cj(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return sj.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function lj(e,t){let{html:n}=e;if(!t)throw TypeError(`An element must be provided`);if(t.getAttribute(`data-vimeo-initialized`)!==null)return t.querySelector(`iframe`);let r=document.createElement(`div`);return r.innerHTML=n,t.appendChild(r.firstChild),t.setAttribute(`data-vimeo-initialized`,`true`),t.querySelector(`iframe`)}function uj(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((r,i)=>{if(!VA(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${UA(e)}/api/oembed.json?url=${encodeURIComponent(e)}`;for(let e in t)t.hasOwnProperty(e)&&(a+=`&${e}=${encodeURIComponent(t[e])}`);let o=`XDomainRequest`in window?new XDomainRequest:new XMLHttpRequest;o.open(`GET`,a,!0),o.onload=function(){if(o.status===404){i(Error(`“${e}” was not found.`));return}if(o.status===403){i(Error(`“${e}” is not embeddable.`));return}try{let t=JSON.parse(o.responseText);if(t.domain_status_code===403){lj(t,n),i(Error(`“${e}” is not embeddable.`));return}r(t)}catch(e){i(e)}},o.onerror=function(){let e=o.status?` (${o.status})`:``;i(Error(`There was an error fetching the embed code from Vimeo${e}.`))},o.send()})}function dj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document,t=[].slice.call(e.querySelectorAll(`[data-vimeo-id], [data-vimeo-url]`)),n=e=>{`console`in window&&console.error&&console.error(`There was an error creating an embed: ${e}`)};t.forEach(e=>{try{if(e.getAttribute(`data-vimeo-defer`)!==null)return;let t=cj(e);uj(WA(t),t,e).then(t=>lj(t,e)).catch(n)}catch(e){n(e)}})}function fj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoPlayerResizeEmbeds_||(window.VimeoPlayerResizeEmbeds_=!0,window.addEventListener(`message`,t=>{if(!VA(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?KA(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function pj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!VA(t.origin))return;let n=ij(t.data);if(!n||n.event!==`ready`)return;let r=t.source?KA(t.source,e):null;r&&HA(r.src)&&new Sj(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function mj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;if(window.VimeoCheckedUrlTimeParam)return;window.VimeoCheckedUrlTimeParam=!0;let t=e=>{`console`in window&&console.error&&console.error(`There was an error getting video Id: ${e}`)};window.addEventListener(`message`,n=>{if(!VA(n.origin))return;let r=ij(n.data);if(!r||r.event!==`ready`)return;let i=n.source?KA(n.source,e):null;if(i&&HA(i.src)){let e=new Sj(i);e.getVideoId().then(t=>{let n=RegExp(`[?&]vimeo_t_${t}=([^&#]*)`).exec(window.location.href);if(n&&n[1]){let t=decodeURI(n[1]);e.setCurrentTime(t)}}).catch(t)}})}function hj(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!VA(e.origin))return;let t=ij(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?KA(e.source):null;if(!n)return;let r=n.getAttribute(`allow`)||``;if(!r.includes(`encrypted-media`)){n.setAttribute(`allow`,`${r}; encrypted-media`);let e=new URL(n.getAttribute(`src`));e.searchParams.set(`forcereload`,`drm`),n.setAttribute(`src`,e.toString());return}}))}function gj(){let e=function(){let e,t=[[`requestFullscreen`,`exitFullscreen`,`fullscreenElement`,`fullscreenEnabled`,`fullscreenchange`,`fullscreenerror`],[`webkitRequestFullscreen`,`webkitExitFullscreen`,`webkitFullscreenElement`,`webkitFullscreenEnabled`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`webkitRequestFullScreen`,`webkitCancelFullScreen`,`webkitCurrentFullScreenElement`,`webkitCancelFullScreen`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`mozRequestFullScreen`,`mozCancelFullScreen`,`mozFullScreenElement`,`mozFullScreenEnabled`,`mozfullscreenchange`,`mozfullscreenerror`],[`msRequestFullscreen`,`msExitFullscreen`,`msFullscreenElement`,`msFullscreenEnabled`,`MSFullscreenChange`,`MSFullscreenError`]],n=0,r=t.length,i={};for(;n<r;n++)if(e=t[n],e&&e[1]in document){for(n=0;n<e.length;n++)i[t[0][n]]=e[n];return i}return!1}(),t={fullscreenchange:e.fullscreenchange,fullscreenerror:e.fullscreenerror},n={request(t){return new Promise((r,i)=>{let a=function(){n.off(`fullscreenchange`,a),r()};n.on(`fullscreenchange`,a),t||=document.documentElement;let o=t[e.requestFullscreen]();o instanceof Promise&&o.then(a).catch(i)})},exit(){return new Promise((t,r)=>{if(!n.isFullscreen){t();return}let i=function(){n.off(`fullscreenchange`,i),t()};n.on(`fullscreenchange`,i);let a=document[e.exitFullscreen]();a instanceof Promise&&a.then(i).catch(r)})},on(e,n){let r=t[e];r&&document.addEventListener(r,n)},off(e,n){let r=t[e];r&&document.removeEventListener(r,n)}};return Object.defineProperties(n,{isFullscreen:{get(){return!!document[e.fullscreenElement]}},element:{enumerable:!0,get(){return document[e.fullscreenElement]}},isEnabled:{enumerable:!0,get(){return!!document[e.fullscreenEnabled]}}}),n}var _j={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},vj=class extends EventTarget{logger;constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;super(),this.logger=r,this.init(t,e,{..._j,...n})}disconnect(){this.dispatchEvent(new Event(`disconnect`))}async init(e,t,n){if(await this.waitForTOReadyState(e,`open`),n.role===`viewer`){await this.updatePlayer(e,t,n);let r=GA(e,`change`,()=>this.updatePlayer(e,t,n)),i=this.maintainPlaybackPosition(e,t,n);this.addEventListener(`disconnect`,()=>{i.cancel(),r.cancel()})}else{await this.updateTimingObject(e,t);let n=GA(t,[`seeked`,`play`,`pause`,`ratechange`],()=>this.updateTimingObject(e,t),`on`,`off`);this.addEventListener(`disconnect`,()=>n.cancel())}}async updateTimingObject(e,t){let[n,r,i]=await Promise.all([t.getCurrentTime(),t.getPaused(),t.getPlaybackRate()]);e.update({position:n,velocity:r?0:i})}async updatePlayer(e,t,n){let{position:r,velocity:i}=e.query();typeof r==`number`&&t.setCurrentTime(r),typeof i==`number`&&(i===0?await t.getPaused()===!1&&t.pause():i>0&&(await t.getPaused()===!0&&(await t.play().catch(async e=>{e.name===`NotAllowedError`&&n.autoPlayMuted&&(await t.setMuted(!0),await t.play().catch(e=>console.error(`Couldn't play the video from TimingSrcConnector. Error:`,e)))}),this.updatePlayer(e,t,n)),await t.getPlaybackRate()!==i&&t.setPlaybackRate(i)))}maintainPlaybackPosition(e,t,n){let{allowedDrift:r,maxAllowedDrift:i,minCheckInterval:a,maxRateAdjustment:o,maxTimeToCatchUp:s}=n,c=Math.min(s,Math.max(a,i))*1e3,l=async()=>{if(e.query().velocity===0||await t.getPaused()===!0)return;let n=e.query().position-await t.getCurrentTime(),a=Math.abs(n);if(this.log(`Drift: ${n}`),a>i)await this.adjustSpeed(t,0),t.setCurrentTime(e.query().position),this.log(`Resync by currentTime`);else if(a>r){let e=a/s,r=o,i=e<r?(r-e)/2:r;await this.adjustSpeed(t,i*Math.sign(n)),this.log(`Resync by playbackRate`)}},u=setInterval(()=>l(),c);return{cancel:()=>clearInterval(u)}}log(e){this.logger?.(`TimingSrcConnector: ${e}`)}speedAdjustment=0;adjustSpeed=async(e,t)=>{if(this.speedAdjustment===t)return;let n=await e.getPlaybackRate()-this.speedAdjustment+t;this.log(`New playbackRate: ${n}`),await e.setPlaybackRate(n),this.speedAdjustment=t};waitForTOReadyState(e,t){return new Promise(n=>{let r=()=>{e.readyState===t?n():e.addEventListener(`readystatechange`,r,{once:!0})};r()})}},yj=new WeakMap,bj=new WeakMap,xj={},Sj=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn(`A jQuery object with multiple elements was passed, using the first element.`),e=e[0]),typeof document<`u`&&typeof e==`string`&&(e=document.getElementById(e)),!zA(e))throw TypeError(`You must pass either a valid element or a valid id.`);if(e.nodeName!==`IFRAME`){let t=e.querySelector(`iframe`);t&&(e=t)}if(e.nodeName===`IFRAME`&&!VA(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(yj.has(e))return yj.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new ZA((n,r)=>{if(this._onMessage=e=>{if(!VA(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=ij(e.data);if(t&&t.event===`error`&&t.data&&t.data.method===`ready`){let e=Error(t.data.message);e.name=t.data.name,r(e);return}let i=t&&t.event===`ready`,a=t&&t.method===`ping`;if(i||a){this.element.setAttribute(`data-ready`,`true`),n();return}oj(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=cj(e,t);uj(WA(n),n,e).then(t=>{let n=lj(t,e);return this.element=n,this._originalElement=e,rj(e,n),yj.set(this.element,this),t}).catch(r)}});if(bj.set(this,n),yj.set(this.element,this),this.element.nodeName===`IFRAME`&&aj(this,`ping`),xj.isEnabled){let e=()=>xj.exit();this.fullscreenchangeHandler=()=>{xj.isFullscreen?$A(this,`event:exitFullscreen`,e):tj(this,`event:exitFullscreen`,e),this.ready().then(()=>{aj(this,`fullscreenchange`,xj.isFullscreen)})},xj.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return VA(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new ZA((n,r)=>this.ready().then(()=>{$A(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),aj(this,e,t)}).catch(r))}get(e){return new ZA((t,n)=>(e=RA(e,`get`),this.ready().then(()=>{$A(this,e,{resolve:t,reject:n}),aj(this,e)}).catch(n)))}set(e,t){return new ZA((n,r)=>{if(e=RA(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{$A(this,e,{resolve:n,reject:r}),aj(this,e,t)}).catch(r)})}on(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(!t)throw TypeError(`You must pass a callback function.`);if(typeof t!=`function`)throw TypeError(`The callback must be a function.`);ej(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),$A(this,`event:${e}`,t)}off(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(t&&typeof t!=`function`)throw TypeError(`The callback must be a function.`);tj(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=bj.get(this)||new ZA((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return ZA.resolve(e)}addCuePoint(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.callMethod(`addCuePoint`,{time:e,data:t})}removeCuePoint(e){return this.callMethod(`removeCuePoint`,e)}enableTextTrack(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`enableTextTrack`,{language:e,kind:t,showing:n})}disableTextTrack(){return this.callMethod(`disableTextTrack`)}selectAudioTrack(e,t){if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`selectAudioTrack`,{language:e,kind:t})}selectDefaultAudioTrack(){return this.callMethod(`selectDefaultAudioTrack`)}pause(){return this.callMethod(`pause`)}play(){return this.callMethod(`play`)}requestFullscreen(){return xj.isEnabled?xj.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return xj.isEnabled?xj.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return xj.isEnabled?ZA.resolve(xj.isFullscreen):this.get(`fullscreen`)}requestPictureInPicture(){return this.callMethod(`requestPictureInPicture`)}exitPictureInPicture(){return this.callMethod(`exitPictureInPicture`)}getPictureInPicture(){return this.get(`pictureInPicture`)}remotePlaybackPrompt(){return this.callMethod(`remotePlaybackPrompt`)}unload(){return this.callMethod(`unload`)}destroy(){return new ZA(e=>{if(bj.delete(this),yj.delete(this.element),this._originalElement&&(yj.delete(this._originalElement),this._originalElement.removeAttribute(`data-vimeo-initialized`)),this.element&&this.element.nodeName===`IFRAME`&&this.element.parentNode&&(this.element.parentNode.parentNode&&this._originalElement&&this._originalElement!==this.element.parentNode?this.element.parentNode.parentNode.removeChild(this.element.parentNode):this.element.parentNode.removeChild(this.element)),this.element&&this.element.nodeName===`DIV`&&this.element.parentNode){this.element.removeAttribute(`data-vimeo-initialized`);let e=this.element.querySelector(`iframe`);e&&e.parentNode&&(e.parentNode.parentNode&&this._originalElement&&this._originalElement!==e.parentNode?e.parentNode.parentNode.removeChild(e.parentNode):e.parentNode.removeChild(e))}this._window.removeEventListener(`message`,this._onMessage),xj.isEnabled&&xj.off(`fullscreenchange`,this.fullscreenchangeHandler),e()})}getAutopause(){return this.get(`autopause`)}setAutopause(e){return this.set(`autopause`,e)}getBuffered(){return this.get(`buffered`)}getCameraProps(){return this.get(`cameraProps`)}setCameraProps(e){return this.set(`cameraProps`,e)}getChapters(){return this.get(`chapters`)}getCurrentChapter(){return this.get(`currentChapter`)}getColor(){return this.get(`color`)}getColors(){return ZA.all([this.get(`colorOne`),this.get(`colorTwo`),this.get(`colorThree`),this.get(`colorFour`)])}setColor(e){return this.set(`color`,e)}setColors(e){if(!Array.isArray(e))return new ZA((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new ZA(e=>e(null)),n=[e[0]?this.set(`colorOne`,e[0]):t,e[1]?this.set(`colorTwo`,e[1]):t,e[2]?this.set(`colorThree`,e[2]):t,e[3]?this.set(`colorFour`,e[3]):t];return ZA.all(n)}getCuePoints(){return this.get(`cuePoints`)}getCurrentTime(){return this.get(`currentTime`)}setCurrentTime(e){return this.set(`currentTime`,e)}getDuration(){return this.get(`duration`)}getEnded(){return this.get(`ended`)}getLoop(){return this.get(`loop`)}setLoop(e){return this.set(`loop`,e)}setMuted(e){return this.set(`muted`,e)}getMuted(){return this.get(`muted`)}getPaused(){return this.get(`paused`)}getPlaybackRate(){return this.get(`playbackRate`)}setPlaybackRate(e){return this.set(`playbackRate`,e)}getPlayed(){return this.get(`played`)}getQualities(){return this.get(`qualities`)}getQuality(){return this.get(`quality`)}setQuality(e){return this.set(`quality`,e)}getRemotePlaybackAvailability(){return this.get(`remotePlaybackAvailability`)}getRemotePlaybackState(){return this.get(`remotePlaybackState`)}getSeekable(){return this.get(`seekable`)}getSeeking(){return this.get(`seeking`)}getTextTracks(){return this.get(`textTracks`)}getAudioTracks(){return this.get(`audioTracks`)}getEnabledAudioTrack(){return this.get(`enabledAudioTrack`)}getDefaultAudioTrack(){return this.get(`defaultAudioTrack`)}getVideoEmbedCode(){return this.get(`videoEmbedCode`)}getVideoId(){return this.get(`videoId`)}getVideoTitle(){return this.get(`videoTitle`)}getVideoWidth(){return this.get(`videoWidth`)}getVideoHeight(){return this.get(`videoHeight`)}getVideoUrl(){return this.get(`videoUrl`)}getVolume(){return this.get(`volume`)}setVolume(e){return this.set(`volume`,e)}async setTimingSrc(e,t){if(!e)throw TypeError(`A Timing Object must be provided.`);await this.ready();let n=new vj(this,e,t);return aj(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>aj(this,`notifyTimingObjectDisconnect`)),n}};LA||(xj=gj(),dj(),fj(),pj(),mj(),hj());function Cj(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,wj(e,t)}function wj(e,t){return wj=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},wj(e,t)}var Tj={play:`onPlay`,playing:`onPlaying`,pause:`onPause`,ended:`onEnd`,timeupdate:`onTimeUpdate`,progress:`onProgress`,seeked:`onSeeked`,texttrackchange:`onTextTrackChange`,cuechange:`onCueChange`,cuepoint:`onCuePoint`,volumechange:`onVolumeChange`,playbackratechange:`onPlaybackRateChange`,error:`onError`,loaded:`onLoaded`},Ej=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}Cj(t,e);var n=t.prototype;return n.componentDidMount=function(){this.createPlayer()},n.componentDidUpdate=function(e){var t=this,n=Object.keys(this.props).filter(function(n){return t.props[n]!==e[n]});this.updateProps(n)},n.componentWillUnmount=function(){this.player.destroy()},n.getInitialOptions=function(){var e,t=this.props.video,n=/^https?:/i.test(t)?`url`:`id`;return e={},e[n]=t,e.width=this.props.width,e.height=this.props.height,e.autopause=this.props.autopause,e.autoplay=this.props.autoplay,e.byline=this.props.showByline,e.color=this.props.color,e.controls=this.props.controls,e.loop=this.props.loop,e.portrait=this.props.showPortrait,e.title=this.props.showTitle,e.muted=this.props.muted,e.background=this.props.background,e.responsive=this.props.responsive,e.dnt=this.props.dnt,e.speed=this.props.speed,e.keyboard=this.props.keyboard,e.pip=this.props.pip,e.playsinline=this.props.playsInline,e.quality=this.props.quality,e.texttrack=this.props.textTrack,e.transparent=this.props.transparent,e},n.updateProps=function(e){var t=this,n=this.player;e.forEach(function(e){var r=t.props[e];switch(e){case`autopause`:n.setAutopause(r);break;case`color`:n.setColor(r);break;case`loop`:n.setLoop(r);break;case`volume`:n.setVolume(r);break;case`paused`:n.getPaused().then(function(e){return r&&!e?n.pause():!r&&e?n.play():null});break;case`width`:case`height`:n.element[e]=r;break;case`video`:if(r){var i=t.props.start,a=n.loadVideo(r);typeof i==`number`&&a.then(function(){n.setCurrentTime(i)})}else n.unload();break;case`playbackRate`:n.setPlaybackRate(r);break;case`quality`:n.setQuality(r);break}})},n.createPlayer=function(){var e=this,t=this.props,n=t.start,r=t.volume,i=t.playbackRate;this.player=new Sj(this.container,this.getInitialOptions()),Object.keys(Tj).forEach(function(t){var n=Tj[t];e.player.on(t,function(t){var r=e.props[n];r&&r(t)})});var a=this.props,o=a.onError,s=a.onReady;this.player.ready().then(function(){s&&s(e.player)},function(e){if(o)o(e);else throw e}),typeof n==`number`&&this.player.setCurrentTime(n),typeof r==`number`&&this.updateProps([`volume`]),typeof i==`number`&&this.updateProps([`playbackRate`])},n.refContainer=function(e){this.container=e},n.render=function(){var e=this.props,t=e.id,n=e.className,r=e.style;return Y.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Y.Component);Ej.defaultProps={autopause:!0,autoplay:!1,showByline:!0,controls:!0,loop:!1,showPortrait:!0,showTitle:!0,muted:!1,background:!1,responsive:!1,dnt:!1,speed:!1,keyboard:!0,pip:!1,playsInline:!0,transparent:!0};var Dj={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},Oj=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Y.useState)(``);return(0,Y.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Dj[r],c=new Image;c.onload=()=>{c.width<s?a(o):a(i)},c.onerror=()=>a(o),c.src=i},[e,t,n,r]),i};function kj(e,t,n,r,i){let a={"@context":`https://schema.org`,"@type":`VideoObject`,name:i?.name||t,thumbnailUrl:[i?.thumbnailUrl||n],embedUrl:i?.embedUrl||`${r}/embed/${e}`,contentUrl:i?.contentUrl||`https://www.youtube.com/watch?v=${e}`,...i?.description&&{description:i.description},...i?.uploadDate&&{uploadDate:i.uploadDate},...i?.duration&&{duration:i.duration}};return JSON.stringify(a)}function Aj(e,t){let[n,r]=Y.useState(!1),[i,a]=Y.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Y.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Y.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Y.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?Oj(e.id,_,g,l):null,y=Y.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Y.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Y.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Y.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,X.jsxs)(X.Fragment,{children:[!e.lazyLoad&&(0,X.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,X.jsx)(X.Fragment,{children:n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:p}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,X.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:kj(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,X.jsx)(`noscript`,{children:(0,X.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,X.jsxs)(k,{onPointerOver:j,onClick:M,className:`${E} ${i?b:``}`,"data-title":c,role:!i&&!e.lazyLoad?`img`:void 0,"aria-label":i?void 0:`${c} - YouTube video preview`,style:{...!e.lazyLoad&&{backgroundImage:`url(${y})`},"--aspect-ratio":`${S/C*100}%`,...e.style||{}},children:[e.lazyLoad&&!i&&(0,X.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,X.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,X.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,X.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,X.jsx)(`iframe`,{ref:t,className:w,title:c,width:`560`,height:`315`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,src:m,referrerPolicy:e.referrerPolicy||`strict-origin-when-cross-origin`})]})]})}var jj=Y.forwardRef(Aj);function Mj(e){return e!==!1}function Nj(e,t){let n=[];return t.startSeconds!==null&&n.push(`start=${t.startSeconds}`),e.controls===!1&&n.push(`controls=0`),e.loop===!0&&n.push(`loop=1`,`playlist=${t.id}`),e.playsinline===!0&&n.push(`playsinline=1`),n.length>0?n.join(`&`):void 0}function Pj(e){if(e.width!==void 0)return{width:e.width}}function Fj(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function Ij(e){let t=(0,J.c)(23),n=(0,Y.useRef)(null),r=e.title??`Vimeo video player`,i;t[0]===r?i=t[1]:(i=e=>{let t=e;n.current=t,t.element&&(t.element.title=r)},t[0]=r,t[1]=i);let a=i,o,s;t[2]===r?(o=t[3],s=t[4]):(o=()=>{let e=n.current;e?.element&&(e.element.title=r)},s=[r],t[2]=r,t[3]=o,t[4]=s),(0,Y.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=Pj(e),t[5]=e,t[6]=c);let l=e.width===void 0,u=e.autoplay===!0,d=e.muted===!0,f=e.muted===!0?0:1,p=e.loop===!0,m=e.controls!==!1,h=e.playsinline!==!1,g;t[7]!==a||t[8]!==e.height||t[9]!==e.src||t[10]!==e.width||t[11]!==h||t[12]!==l||t[13]!==u||t[14]!==d||t[15]!==f||t[16]!==p||t[17]!==m?(g=(0,X.jsx)(Ej,{video:e.src,responsive:l,width:e.width,height:e.height,autoplay:u,muted:d,volume:f,loop:p,controls:m,playsInline:h,onReady:a}),t[7]=a,t[8]=e.height,t[9]=e.src,t[10]=e.width,t[11]=h,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=g):g=t[18];let _;return t[19]!==e.title||t[20]!==g||t[21]!==c?(_=(0,X.jsx)(`div`,{className:`ok-video ok-video-vimeo`,style:c,title:e.title,children:g}),t[19]=e.title,t[20]=g,t[21]=c,t[22]=_):_=t[22],_}function Lj(e){let t=(0,J.c)(17),n;t[0]===e.src?n=t[1]:(n=d(e.src),t[0]=e.src,t[1]=n);let r=n;if(!r)return null;let i;t[2]!==r.startRaw||t[3]!==e.autoplay||t[4]!==e.muted?(i=[],r.startRaw!==null&&i.push(`t=${r.startRaw}`),e.autoplay===!0&&i.push(`autoplay=true`),e.muted===!0&&i.push(`muted=true`),t[2]=r.startRaw,t[3]=e.autoplay,t[4]=e.muted,t[5]=i):i=t[5];let a=i.length>0?`https://www.loom.com/embed/${r.id}?${i.join(`&`)}`:`https://www.loom.com/embed/${r.id}`,o;t[6]===e?o=t[7]:(o=Pj(e),t[6]=e,t[7]=o);let s=e.title??`Loom video player`,c;t[8]!==a||t[9]!==e.height||t[10]!==e.width||t[11]!==s?(c=(0,X.jsx)(`iframe`,{className:`ok-video-loom-iframe`,src:a,title:s,width:e.width,height:e.height,allow:`autoplay; fullscreen`,referrerPolicy:`strict-origin-when-cross-origin`,allowFullScreen:!0}),t[8]=a,t[9]=e.height,t[10]=e.width,t[11]=s,t[12]=c):c=t[12];let l;return t[13]!==e.title||t[14]!==o||t[15]!==c?(l=(0,X.jsx)(`div`,{className:`ok-video ok-video-loom`,style:o,title:e.title,children:c}),t[13]=e.title,t[14]=o,t[15]=c,t[16]=l):l=t[16],l}function Rj(e){let t=(0,J.c)(29);if(e.src!==void 0&&He(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(Lj,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&ye(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,X.jsx)(Ij,{...e,src:e.src}),t[2]=e,t[3]=n),n}let n;if(t[4]!==e){n=Symbol.for(`react.early_return_sentinel`);bb0:{let r=e.src===void 0?null:U(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Pj(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:m(e.poster),t[6]=e.poster,t[7]=s);let c=(0,X.jsx)(jj,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Nj(e,r),muted:e.muted===!0,autoplay:e.autoplay===!0,alwaysLoadIframe:i,thumbnail:s,aspectWidth:a?Number(e.width):void 0,aspectHeight:a?Number(e.height):void 0,style:Fj(e)}),l;t[8]!==o||t[9]!==c?(l=(0,X.jsx)(`div`,{className:`ok-video ok-video-youtube`,style:o,children:c}),t[8]=o,t[9]=c,t[10]=l):l=t[10],n=l;break bb0}}t[4]=e,t[5]=n}else n=t[5];if(n!==Symbol.for(`react.early_return_sentinel`))return n;let r;t[11]===e.src?r=t[12]:(r=e.src===void 0?void 0:m(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=Mj(e.controls),t[13]=e.controls,t[14]=a);let o;t[15]===e.poster?o=t[16]:(o=e.poster===void 0?void 0:m(e.poster),t[15]=e.poster,t[16]=o);let s;return t[17]!==e.autoplay||t[18]!==e.height||t[19]!==e.loop||t[20]!==e.muted||t[21]!==e.playsinline||t[22]!==e.preload||t[23]!==e.title||t[24]!==e.width||t[25]!==r||t[26]!==a||t[27]!==o?(s=(0,X.jsx)(`video`,{className:`ok-video`,src:r,title:i,controls:a,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:o,preload:e.preload,width:e.width,height:e.height}),t[17]=e.autoplay,t[18]=e.height,t[19]=e.loop,t[20]=e.muted,t[21]=e.playsinline,t[22]=e.preload,t[23]=e.title,t[24]=e.width,t[25]=r,t[26]=a,t[27]=o,t[28]=s):s=t[28],s}function zj(e){let t=(0,J.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,X.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var Bj={Callout:WO,img:Bk,video:Rj,audio:RO,Pdf:bA,File:rk,Embed:tk,Accordion:IO,Tabs:jA,Tab:DA,Math:Uk,MermaidFence:Kk,Mirror:oA,MirrorSource:sA,"*":zj};function Vj(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var Hj=ie(),Uj=new Map;function Wj(e){if(e.surface===`compat`){let t=Bj[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:Vj(e.props)}}let t=Bj[e.name];return t?{Component:t,reactNodePropNames:Vj(e.props)}:null}for(let[e,t]of Hj.entries()){let n=Wj(t);n&&Uj.set(e,n)}function Gj(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function Kj(e){let t=Hj.getOrWildcard(e),n=Uj.get(t.name)??Uj.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return Gj(t,n)}function qj(){let e=[];for(let[t,n]of Hj.entries()){if(t===`*`)continue;let r=Uj.get(t);r&&e.push(Gj(n,r))}return e}var Jj=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,Yj=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,Xj={Callout:{description:{id:`322lyb`},props:{type:`note`,title:`Heads up`},children:`Callouts draw attention to key information.`},Accordion:{description:{id:`mWVJRX`},props:{title:`Click to expand`,defaultOpen:!0},children:`Hidden content goes here.`},img:{description:{id:`VUijjF`},props:{src:Jj,alt:`Sample image`}},video:{description:{id:`e1hptq`},props:{controls:!0,poster:Yj}},audio:{description:{id:`9jnjV0`},props:{controls:!0}},Math:{description:{id:`Y-Urt2`},props:{formula:`c = \\pm\\sqrt{a^2 + b^2}`}},Embed:{description:{id:`jTLWxh`},render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`https://example.com/embed`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:{id:`Fqr8BP`},render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,X.jsx)(`title`,{children:`Thumbnails`}),(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,X.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,X.jsx)(`span`,{children:`/ 12`})]}),(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,X.jsx)(`span`,{children:`100%`}),(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:{id:`z0a2EA`},render:()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,X.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,X.jsx)(`defs`,{children:(0,X.jsx)(`marker`,{id:`mermaid-preview-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,X.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,X.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,X.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,X.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,X.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:{id:`75Y1dk`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,X.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,X.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:(0,X.jsx)(o,{id:`m6YGpY`})})]})},Mirror:{description:{id:`8TLE9g`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`absolute -top-2 right-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(Ki,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`EL_YRd`,components:{0:(0,X.jsx)(`code`,{className:`font-mono`})}})})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`qNOgUu`})})]})},MirrorSource:{description:{id:`-KCZ6n`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`absolute -top-2 left-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(Wi,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`maDWIB`,components:{0:(0,X.jsx)(`code`,{className:`font-mono`})}})})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`emgiet`})})]})}};function Zj(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function Qj(e){let t=Kj(e),n=Zj(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var $j=new Set;function eM(e){$j.add(e)}function tM(e){if(typeof e==`number`)return $j.delete(e);let t=$j.values().next();return t.done?!1:($j.delete(t.value),!0)}function nM(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(eM(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function rM(e){return t=>{let n=new WeakSet;t.state.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&n.add(t)});let r=Qj(e.name);if(e.name===`Tabs`){let e=Qj(`Tab`),t=Qj(`Tab`),n=e.attrs,i=t.attrs;n.props={...n.props,label:`Tab 1`},i.props={...i.props,label:`Tab 2`},r.content=[e,t]}t.chain().focus().insertContent(r).run();let i=-1;t.state.doc.descendants((t,r)=>{if(i>=0)return!1;t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&!n.has(t)&&(i=r)}),!(i<0)&&nM(t,i,e)}}var iM=new Set([`File`,`Tab`]);function aM(){return[{name:`component-File`,label:z._({id:`J2eKUI`}),icon:Zi,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:sM,preview:{description:z._({id:`t-JXbf`}),render:()=>(0,X.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,X.jsx)(Zi,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function oM(){return[...qj().filter(e=>e.surface===`canonical`&&!iM.has(e.name)).map(e=>{let t=Xj[e.name],n=e.Component,r=t?{description:z._(t.description),render:t.render??(()=>(0,X.jsx)(n,{...t.props,children:t.children}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:NO(e.icon),category:e.category??`content`,command:rM(e),aliases:e.searchTerms,description:e.description,preview:r}}),...aM()]}function sM(e){let t=document.createElement(`input`);t.type=`file`,t.accept=`*/*`,t.style.display=`none`,t.addEventListener(`change`,()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;sO(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function cM(e,t){let n=fO.getState(e.state);if(!n)return null;for(let e of n.byId.values())if(e.markType===`link`&&e.from<=t&&t<e.to)return e.id;return null}function lM(){return[{name:`wikiLink`,label:z._({id:`mZHJju`}),icon:ma,category:`insert`,aliases:[`wiki`,`wikilink`,`[[`,`internal`,`page`,`backlink`,`cross-link`],description:"Link to another page (`[[page]]`) — opens a page picker",preview:{description:z._({id:`cqA3od`}),render:()=>(0,X.jsx)(`p`,{className:`text-sm leading-7`,children:(0,X.jsx)(o,{id:`u-9fWA`,components:{0:(0,X.jsx)(`span`,{className:`font-medium text-azure-blue underline underline-offset-2 dark:text-sky-blue`})}})})},command:e=>{e.chain().focus().insertContent(`[[`).run()}},{name:`externalLink`,label:z._({id:`0R4wMK`}),icon:Ki,category:`insert`,aliases:[`link`,`url`,`href`,`external`,`web`,`hyperlink`],description:"Link to an external URL (`https://…`)",preview:{description:z._({id:`ClDdyg`}),render:()=>(0,X.jsx)(`p`,{className:`text-sm leading-7`,children:(0,X.jsx)(o,{id:`QWT-Z9`,components:{0:(0,X.jsx)(`span`,{className:`font-medium text-azure-blue underline underline-offset-2 dark:text-sky-blue`}),1:(0,X.jsx)(`span`,{className:`text-[0.85em] opacity-60`})}})})},command:e=>{let t=e.state.selection.from;e.chain().focus().insertContent({type:`text`,text:`link`,marks:[{type:`link`,attrs:{href:`https://`}}]}).run();let n=cM(e,t);n&&(uO(n),requestAnimationFrame(()=>{jO(e).setActiveNode(n)}))}},{name:`component-Tag`,label:z._({id:`UL8A9w`}),icon:ra,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:z._({id:`5ClEAu`}),render:()=>(0,X.jsx)(`p`,{className:`text-sm leading-7`,children:(0,X.jsx)(o,{id:`KZLdgR`,components:{0:(0,X.jsx)(`a`,{className:`tag pointer-events-none`})}})})},command:e=>{e.chain().insertTag(``).run()}}]}function uM(e,t){e.chain().focus().insertContent({type:`codeBlock`,attrs:{language:`html`,meta:`preview`},content:[{type:`text`,text:t}]}).run()}var dM=`<div style="padding:20px;font-family:system-ui,sans-serif;color:var(--foreground)">
|
|
7
7
|
<h1 style="margin:0 0 8px;font-size:20px;font-weight:600">Hello, world!</h1>
|
|
8
8
|
<p style="margin:0;color:var(--muted-foreground)">Edit this HTML — the preview updates live.</p>
|
|
9
9
|
</div>`,fM={chart:{icon:Fi,aliases:[`chart`,`bar`,`graph`,`plot`,`viz`,`data`,`embed`,`preview`],render:()=>(0,X.jsxs)(`div`,{className:`flex h-20 items-end gap-1.5`,children:[(0,X.jsx)(`div`,{className:`h-[45%] flex-1 rounded-t-sm bg-chart-1`}),(0,X.jsx)(`div`,{className:`h-[70%] flex-1 rounded-t-sm bg-chart-2`}),(0,X.jsx)(`div`,{className:`h-[90%] flex-1 rounded-t-sm bg-chart-3`}),(0,X.jsx)(`div`,{className:`h-[60%] flex-1 rounded-t-sm bg-chart-4`}),(0,X.jsx)(`div`,{className:`h-[80%] flex-1 rounded-t-sm bg-chart-5`})]})},"stat-cards":{icon:la,aliases:[`stat`,`stats`,`metric`,`metrics`,`cards`,`kpi`,`embed`,`preview`],render:()=>(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex-1 rounded-md border border-border bg-card p-2`,children:[(0,X.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Users`}),(0,X.jsx)(`div`,{className:`text-sm font-bold text-card-foreground`,children:`12.4k`}),(0,X.jsx)(`div`,{className:`text-[10px] font-semibold text-chart-2`,children:`+8.2%`})]}),(0,X.jsxs)(`div`,{className:`flex-1 rounded-md border border-border bg-card p-2`,children:[(0,X.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Revenue`}),(0,X.jsx)(`div`,{className:`text-sm font-bold text-card-foreground`,children:`$48k`}),(0,X.jsx)(`div`,{className:`text-[10px] font-semibold text-chart-1`,children:`+3.1%`})]})]})},"custom-svg":{icon:Aa,aliases:[`svg`,`vector`,`graphic`,`illustration`,`ring`,`embed`,`preview`],render:()=>(0,X.jsx)(`div`,{className:`flex items-center justify-center text-chart-1`,children:(0,X.jsxs)(`svg`,{width:`72`,height:`72`,viewBox:`0 0 72 72`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{cx:`36`,cy:`36`,r:`28`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.15`,strokeWidth:`9`}),(0,X.jsx)(`circle`,{cx:`36`,cy:`36`,r:`28`,fill:`none`,stroke:`currentColor`,strokeWidth:`9`,strokeLinecap:`round`,strokeDasharray:`176`,strokeDashoffset:`53`,transform:`rotate(-90 36 36)`})]})})},"interactive-control":{icon:Ma,aliases:[`interactive`,`slider`,`control`,`widget`,`input`,`embed`,`preview`],render:()=>(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-lg font-bold text-chart-1`,children:`$2,500`}),(0,X.jsxs)(`div`,{className:`relative h-1.5 rounded-full bg-muted`,children:[(0,X.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-1/3 rounded-full bg-primary`}),(0,X.jsx)(`div`,{className:`-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/3 size-3 rounded-full bg-primary`})]}),(0,X.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Drag to adjust`})]})}};function pM(){return{name:`embed-starter-html`,label:z._({id:`FBknns`}),icon:Ui,category:`embed`,aliases:[`html`,`embed`,`preview`,`iframe`,`sandbox`,`web`,`snippet`],description:z._({id:`4niEzY`}),command:e=>uM(e,dM),preview:{description:z._({id:`rageVb`}),render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`sandbox`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-3`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground text-sm`,children:(0,X.jsx)(o,{id:`3HNlwb`})}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`bH382I`})})]})]})}}}function mM(){let e=re.map(e=>{let t=fM[e.id];return{name:`embed-starter-${e.id}`,label:e.title,icon:t.icon,category:`embed`,command:t=>uM(t,e.html),aliases:t.aliases,description:e.description,preview:{description:e.description,render:t.render}}});return[pM(),...e]}function hM(){return[{name:`heading1`,label:z._({id:`lXKZGw`}),icon:ia,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`],preview:{description:z._({id:`3J7d2N`}),render:()=>(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:(0,X.jsx)(o,{id:`lXKZGw`})})}},{name:`heading2`,label:z._({id:`El7NbA`}),icon:aa,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`],preview:{description:z._({id:`LXdWeS`}),render:()=>(0,X.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:(0,X.jsx)(o,{id:`El7NbA`})})}},{name:`heading3`,label:z._({id:`SFN6dN`}),icon:oa,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`],preview:{description:z._({id:`g4XBm0`}),render:()=>(0,X.jsx)(`h3`,{className:`text-base font-semibold tracking-tight`,children:(0,X.jsx)(o,{id:`SFN6dN`})})}},{name:`bulletList`,label:z._({id:`s1c0ja`}),icon:_a,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`],preview:{description:z._({id:`fYjgXu`}),render:()=>(0,X.jsxs)(`ul`,{className:`list-disc pl-5 text-sm leading-7`,children:[(0,X.jsx)(`li`,{children:(0,X.jsx)(o,{id:`FCxvG5`})}),(0,X.jsx)(`li`,{children:(0,X.jsx)(o,{id:`saIASg`})})]})}},{name:`orderedList`,label:z._({id:`Uci-Ph`}),icon:ha,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`],preview:{description:z._({id:`rXz97P`}),render:()=>(0,X.jsxs)(`ol`,{className:`list-decimal pl-5 text-sm leading-7`,children:[(0,X.jsx)(`li`,{children:(0,X.jsx)(o,{id:`FCxvG5`})}),(0,X.jsx)(`li`,{children:(0,X.jsx)(o,{id:`saIASg`})})]})}},{name:`taskList`,label:z._({id:`G_686w`}),icon:ga,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`],preview:{description:z._({id:`yutJKi`}),render:()=>(0,X.jsxs)(`ul`,{className:`space-y-1.5 text-sm`,children:[(0,X.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!0,readOnly:!0,className:`size-3.5`}),(0,X.jsx)(`span`,{className:`text-muted-foreground line-through`,children:(0,X.jsx)(o,{id:`DPfwMq`})})]}),(0,X.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,readOnly:!0,className:`size-3.5`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`rZ9HZq`})})]})]})}},{name:`blockquote`,label:z._({id:`ZhhOwV`}),icon:Da,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`],preview:{description:z._({id:`w7nm4K`}),render:()=>(0,X.jsx)(`blockquote`,{className:`border-l-2 border-muted-foreground/40 pl-3 text-sm italic text-muted-foreground`,children:(0,X.jsx)(o,{id:`74-bX-`})})}},{name:`codeBlock`,label:z._({id:`N2eHWq`}),icon:Hi,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock({language:`js`}).run(),aliases:[`code`,`fence`],preview:{description:z._({id:`XpIZmv`}),render:()=>(0,X.jsx)(`pre`,{className:`rounded-md bg-muted px-2.5 py-2 font-mono text-xs leading-5`,children:(0,X.jsx)(`code`,{children:`const greeting = "Hello";
|