@inkeep/open-knowledge 0.43.0-beta.1 → 0.43.0-beta.3
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/{acp-harness-probe-DGTFmQbn.mjs → acp-harness-probe-BtTqdDc1.mjs} +2 -2
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/assets/skills/write-skill/SKILL.md +1 -1
- package/dist/cli.mjs +13 -13
- package/dist/constants-VzdgUlYN.mjs +2 -0
- package/dist/{git-handle-vqpcA9VH.mjs → git-handle-Brc1fNLy.mjs} +2 -2
- package/dist/git-handle-DHnKEzLR.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-CCnKaiOs.mjs → init-C8p7yCX2.mjs} +31 -31
- package/dist/init-D7L1owe_.mjs +1 -0
- package/dist/{launch-json-removal-DpMakhDe.mjs → launch-json-removal-Do3ZM3UC.mjs} +2 -2
- package/dist/loader-CZtD2zE4.mjs +1 -0
- package/dist/{loader-96AKdkqe.mjs → loader-DVjQPZbo.mjs} +2 -2
- package/dist/md-manager-Cz4fhjnd.mjs +2 -0
- package/dist/{open-browser-D62jJdtT.mjs → open-browser-CZVSVsTE.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-C9-DF3ta.mjs +1 -0
- package/dist/{preview-DyAg02Zz.mjs → preview-D0GN6S4V.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-g89D5S8f.js → ActivityModeContent-DcY2DMsH.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-DEEEC5SC.js → AgentDiffPane-DCaKB1m-.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-DEl9X_lO.js → AgentThreadClientBinder-DmS2wmOY.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-Bu3Fs6zS.js → CodeMirrorPropInput-BuDk69fH.js} +1 -1
- package/dist/public/assets/{DocumentContext-rC30TeU1.js → DocumentContext-BlhsCPmc.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-sLw-NDKx.js → EditorModeToggle-DyeYvRF2.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-CyQvFQvF.js → EnableSyncConfirmDialog-D3BVydfv.js} +1 -1
- package/dist/public/assets/FeedbackForm-DhdtE4G5.js +1 -0
- package/dist/public/assets/{GraphPanel-D__pyQFw.js → GraphPanel-1c013bf_.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-8qwaKsqI.js → LintConfigEditor-IzCFcaas.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-C6PhweIc.js → ManagedArtifactProperties-ColUfFbc.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-v3xzJlUc.js → McpConsentDialogBody-B6Gwaht3.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-Cb1XUuYg.js → MermaidDocEditor-P11-MZ38.js} +1 -1
- package/dist/public/assets/{PropertyPanel-CNbo8u41.js → PropertyPanel-DVXQWN0C.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-B9Fanm3L.js → ReportBugDialogBody-D-51Fi6S.js} +1 -1
- package/dist/public/assets/SchemaConfigEditor-BNRxJxXG.js +1 -0
- package/dist/public/assets/{SettingsDialogBody-D60WwzYw.js → SettingsDialogBody-Cxcf7oPC.js} +2 -2
- package/dist/public/assets/{ShareBranchSwitchDialog-CBAwJPzC.js → ShareBranchSwitchDialog-CPxlFKib.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-By_ADxES.js → ShareReceiveDialog-BVziJqwR.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-DRPeFjq_.js → ShareReceiveMissDialog-DgtFYgCB.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-DUmsYRmo.js → SkillEditorActions-Cs6ruYBc.js} +1 -1
- package/dist/public/assets/{SourceEditor-C-UqlkGB.js → SourceEditor-BXTJz5Ix.js} +1 -1
- package/dist/public/assets/{TerminalPanel-CTqU6o3s.js → TerminalPanel-ocG4IGRI.js} +1 -1
- package/dist/public/assets/{TerminalSessionsHost-BPvs6cwd.js → TerminalSessionsHost-p10nQyGj.js} +2 -2
- package/dist/public/assets/{TerminalWindowApp-OPcXReB3.js → TerminalWindowApp-Ci4-2fyd.js} +1 -1
- package/dist/public/assets/{ThreadView-3ad12XVo.js → ThreadView-D3uOn3E4.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-DgNva1gq.js → TimelineDiffPane-CqUFJz9a.js} +1 -1
- package/dist/public/assets/{agent-diff-store-C047fGBn.js → agent-diff-store-CDu00oUs.js} +1 -1
- package/dist/public/assets/{agent-visibility-BF9jUA-S.js → agent-visibility-Doi5rQGj.js} +1 -1
- package/dist/public/assets/{auth-state-cache-BlO5xkpU.js → auth-state-cache-D6s_c1y9.js} +1 -1
- package/dist/public/assets/client-version-BxRjWpxD.js +1 -0
- package/dist/public/assets/{config-provider-Csi6hMEt.js → config-provider-C6yc5YBH.js} +1 -1
- package/dist/public/assets/{dist-D5TEqH45.js → dist-DmmOGEYy.js} +1 -1
- package/dist/public/assets/{doc-hash--5hQmcT5.js → doc-hash-npYJLwiA.js} +1 -1
- package/dist/public/assets/{documents-events-B0k6hZi4.js → documents-events-DR-3KwvB.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-CZ6DDAA4.js → file-tree-adapter-_Iw9bOfm.js} +1 -1
- package/dist/public/assets/{file-tree-utils-BaZOVY6J.js → file-tree-utils-D0sM1hl6.js} +1 -1
- package/dist/public/assets/{index-CMPrUhWJ.js → index-CB_F7yyz.js} +7 -7
- package/dist/public/assets/{lint-config-client-DbmBCBFs.js → lint-config-client-P4Vl5_Ll.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-CKqigNbJ.js → markdownlint-rule-browser-CgMCf9t4.js} +1 -1
- package/dist/public/assets/{navigation-targets-CYyBnqZZ.js → navigation-targets-DeBO_CiV.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-BEVP0SdK.js → open-managed-artifact-tab-C3XHRPjz.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-D6BuHzW7.js → pending-receive-nav-store-CqjfAzzm.js} +1 -1
- package/dist/public/assets/{prop-types-BBKV1S78.js → prop-types-Bhd8xMdJ.js} +1 -1
- package/dist/public/assets/{receive-store-CLSRRsUo.js → receive-store-B0la12DE.js} +1 -1
- package/dist/public/assets/{schema-fields-view-intent-BeD8vY0v.js → schema-fields-view-intent-D_s-Cynn.js} +1 -1
- package/dist/public/assets/{selection-context-CoAzJLgJ.js → selection-context-2bZ6fnVY.js} +1 -1
- package/dist/public/assets/{skill-actions-G-6FdAWg.js → skill-actions-QNwfiy_e.js} +1 -1
- package/dist/public/assets/{skills-api-nci6FoVp.js → skills-api-BM7Qxf1S.js} +1 -1
- package/dist/public/assets/{src-Dqj4tsR9.js → src-D-PwH09g.js} +1 -1
- package/dist/public/assets/{tag-pill-input-BGvE8IPF.js → tag-pill-input-_HZuox-k.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-BtjSk9Ck.js → target-navigation-intent-voqLi0RG.js} +1 -1
- package/dist/public/assets/{telemetry-impl-Z8PmW_aL.js → telemetry-impl-rSw405SP.js} +1 -1
- package/dist/public/assets/{telemetry-startup-Cy7C8oSF.js → telemetry-startup-CfHWVhDL.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-BAOu6SND.js → terminal-launch-events-CgQk_kaz.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-CSLY2tMg.js → terminal-telemetry-CBfCAmXL.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-YikvFcgi.js → typing-burst-detector-B0_asf0o.js} +1 -1
- package/dist/public/assets/{uninstall-CVwJS9oE.js → uninstall-C-l5Ivsg.js} +1 -1
- package/dist/public/assets/{use-activity-panel-DRiVx8dd.js → use-activity-panel-CC2ch2Ri.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-8mWh6sFH.js → use-apply-config-color-theme-DRPFp4xs.js} +1 -1
- package/dist/public/assets/{use-collab-url-Byylx1V6.js → use-collab-url-BwoofE89.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-B8pvprD8.js → use-live-xterm-theme-CEP9y4ZI.js} +1 -1
- package/dist/public/assets/{use-settings-route-CCeZ7dN_.js → use-settings-route-DPMg_rMU.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-LoKyqz9U.js → use-terminal-enabled-H8JidfQP.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-CdO4y6y7.js → use-timeline-entry-diff-gYsui2K8.js} +1 -1
- package/dist/public/assets/{use-workspace-BVbiw6ue.js → use-workspace-BIKWmfQe.js} +1 -1
- package/dist/public/assets/{workspace-paths-xqj_kQWP.js → workspace-paths-BJBhipCI.js} +1 -1
- package/dist/public/index.html +35 -35
- package/dist/public/uninstall.html +2 -2
- package/dist/{repair-launch-json-yRaU75sa.mjs → repair-launch-json-DX0YwjHi.mjs} +2 -2
- package/dist/{repair-mcp-configs-Dhz6Ht8f.mjs → repair-mcp-configs-DDYZC6Po.mjs} +2 -2
- package/dist/repair-skills-B05O8c60.mjs +1 -0
- package/dist/{repair-skills-hJ4Ol2SE.mjs → repair-skills-dZDoxvRM.mjs} +2 -2
- package/dist/server-lock-B7mZG_Hv.mjs +1 -0
- package/dist/{server-lock-BaAxTOkZ.mjs → server-lock-CH_iezNY.mjs} +2 -2
- package/dist/{src-Bpg-FG-z.mjs → src-BRIunPu2.mjs} +1 -1
- package/dist/{src-DZ0ZiS77.mjs → src-CbnujJE-.mjs} +342 -340
- package/dist/{src-BctJxQjz.mjs → src-CpxEUq6v.mjs} +2 -2
- package/dist/{src-B5_KtSx0.mjs → src-Duzu_tVF.mjs} +124 -124
- package/dist/start-DBG7-_mG.mjs +1 -0
- package/dist/start-DMRZAT-1.mjs +4 -0
- package/dist/{write-project-skill-2xPw07AZ.mjs → write-project-skill-CJb6JZQ_.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-O0xpb7mH.mjs +0 -2
- package/dist/git-handle-DsVW51IO.mjs +0 -1
- package/dist/init-CF2-_1EB.mjs +0 -1
- package/dist/loader-Bm4GaiwL.mjs +0 -1
- package/dist/md-manager-DqqkZBfY.mjs +0 -2
- package/dist/preview-Df7P6EY2.mjs +0 -1
- package/dist/public/assets/FeedbackForm-Xv5Ofoot.js +0 -1
- package/dist/public/assets/SchemaConfigEditor-BsQuL-UF.js +0 -1
- package/dist/public/assets/client-version-BXkMIB54.js +0 -1
- package/dist/repair-skills-BH1pQ2tJ.mjs +0 -1
- package/dist/server-lock-BT7lExvG.mjs +0 -1
- package/dist/start-D0gmTzCW.mjs +0 -4
- package/dist/start-D5jQn9rZ.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r}from"./dist-PQ5KMVDh.js";import{t as i}from"./compiler-runtime-BfE3aGVn.js";import{Fa as a,Mr as o,S as s,b as c,en as l,nn as u,x as d,y as f}from"./dist-D5TEqH45.js";import{r as ee}from"./client-version-BXkMIB54.js";import{a as te,l as ne,r as re}from"./use-apply-config-color-theme-8mWh6sFH.js";import{t as ie}from"./config-context-gd3BC-iY.js";var ae=i(),p=e(n(),1),m=null,oe=new Set;function se(){return m}function ce(e){let t=e!==null&&e.length>0?e:null;if(t!==m){m=t;for(let e of oe)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function le(e){return oe.add(e),()=>{oe.delete(e)}}function ue(){return(0,p.useSyncExternalStore)(le,se,se)}var h=()=>new Map,de=e=>{let t=h();return e.forEach((e,n)=>{t.set(n,e)}),t},g=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},fe=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},_=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},v=()=>new Set,pe=e=>e[e.length-1],me=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},y=Array.from,he=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},ge=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},_e=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},b=Array.isArray,ve=class{constructor(){this._observers=h()}on(e,t){return g(this._observers,e,v).add(t),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 y((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},ye=class{constructor(){this._observers=h()}on(e,t){g(this._observers,e,v).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 y((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},x=Math.floor,be=Math.abs,xe=(e,t)=>e<t?e:t,S=(e,t)=>e>t?e:t;Number.isNaN;var Se=e=>e===0?1/e<0:e<0,Ce=1<<17,we=1<<18,Te=1<<19,Ee=1<<20,De=1<<21,Oe=1<<22,ke=1<<23,Ae=1<<24,je=1<<25,Me=1<<26,Ne=1<<27,Pe=1<<28,Fe=1<<29;Ce-1,we-1,Te-1,Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1,Fe-1;var Ie=2**53-1,Le=-(2**53-1),Re=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&x(e)===e);Number.isNaN,Number.parseInt;var ze=String.fromCharCode;String.fromCodePoint,ze(65535);var Be=e=>e.toLowerCase(),Ve=/^\s*/g,He=e=>e.replace(Ve,``),Ue=/([A-Z])/g,We=(e,t)=>He(e.replace(Ue,e=>`${t}${Be(e)}`)),Ge=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},Ke=typeof TextEncoder<`u`?new TextEncoder:null,qe=Ke?e=>Ke.encode(e):Ge,Je=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Je&&Je.decode(new Uint8Array).length===1&&(Je=null);var Ye=(e,t)=>_e(t,()=>e).join(``),Xe=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Ze=()=>new Xe,Qe=e=>{let t=Ze();return e(t),C(t)},$e=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},C=e=>{let t=new Uint8Array($e(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},et=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(S(n,t)*2),e.cpos=0)},w=(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},tt=w,T=(e,t)=>{for(;t>127;)w(e,128|127&t),t=x(t/128);w(e,127&t)},nt=(e,t)=>{let n=Se(t);for(n&&(t=-t),w(e,(t>63?128:0)|(n?64:0)|63&t),t=x(t/64);t>0;)w(e,(t>127?128:0)|127&t),t=x(t/128)},rt=new Uint8Array(3e4),it=rt.length/3,at=Ke&&Ke.encodeInto?(e,t)=>{if(t.length<it){let n=Ke.encodeInto(t,rt).written||0;T(e,n);for(let t=0;t<n;t++)w(e,rt[t])}else E(e,qe(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;T(e,r);for(let t=0;t<r;t++)w(e,n.codePointAt(t))},ot=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=xe(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(S(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},E=(e,t)=>{T(e,t.byteLength),ot(e,t)},st=(e,t)=>{et(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ct=(e,t)=>st(e,4).setFloat32(0,t,!1),lt=(e,t)=>st(e,8).setFloat64(0,t,!1),ut=(e,t)=>st(e,8).setBigInt64(0,t,!1),dt=new DataView(new ArrayBuffer(4)),ft=e=>(dt.setFloat32(0,e),dt.getFloat32(0)===e),pt=(e,t)=>{switch(typeof t){case`string`:w(e,119),at(e,t);break;case`number`:Re(t)&&be(t)<=2147483647?(w(e,125),nt(e,t)):ft(t)?(w(e,124),ct(e,t)):(w(e,123),lt(e,t));break;case`bigint`:w(e,122),ut(e,t);break;case`object`:if(t===null)w(e,126);else if(b(t)){w(e,117),T(e,t.length);for(let n=0;n<t.length;n++)pt(e,t[n])}else if(t instanceof Uint8Array)w(e,116),E(e,t);else{w(e,118);let n=Object.keys(t);T(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];at(e,i),pt(e,t[i])}}break;case`boolean`:w(e,t?120:121);break;default:w(e,127)}},mt=class extends Xe{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&T(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},ht=e=>{e.count>0&&(nt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&T(e.encoder,e.count-2))},gt=class{constructor(){this.encoder=new Xe,this.s=0,this.count=0}write(e){this.s===e?this.count++:(ht(this),this.count=1,this.s=e)}toUint8Array(){return ht(this),C(this.encoder)}},_t=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);nt(e.encoder,t),e.count>1&&T(e.encoder,e.count-2)}},vt=class{constructor(){this.encoder=new Xe,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(_t(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return _t(this),C(this.encoder)}},yt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new gt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Xe;return this.sarr.push(this.s),this.s=``,at(e,this.sarr.join(``)),ot(e,this.lensE.toUint8Array()),C(e)}},D=e=>Error(e),O=()=>{throw D(`Method unimplemented`)},k=()=>{throw D(`Unexpected case`)},bt=D(`Unexpected end of array`),xt=D(`Integer out of Range`),St=class{constructor(e){this.arr=e,this.pos=0}},Ct=e=>new St(e),wt=e=>e.pos!==e.arr.length,Tt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},A=e=>Tt(e,j(e)),Et=e=>e.arr[e.pos++],j=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Ie)throw xt}throw bt},Dt=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Ie)throw xt}throw bt},Ot=Je?e=>Je.decode(A(e)):e=>{let t=j(e);if(t===0)return``;{let n=String.fromCodePoint(Et(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Et(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))}},kt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},At=[e=>void 0,e=>null,Dt,e=>kt(e,4).getFloat32(0,!1),e=>kt(e,8).getFloat64(0,!1),e=>kt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Ot,e=>{let t=j(e),n={};for(let r=0;r<t;r++){let t=Ot(e);n[t]=jt(e)}return n},e=>{let t=j(e),n=[];for(let r=0;r<t;r++)n.push(jt(e));return n},A],jt=e=>At[127-Et(e)](e),Mt=class extends St{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),wt(this)?this.count=j(this)+1:this.count=-1),this.count--,this.s}},Nt=class extends St{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Dt(this);let e=Se(this.s);this.count=1,e&&(this.s=-this.s,this.count=j(this)+2)}return this.count--,this.s}},Pt=class extends St{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Dt(this),t=e&1;this.diff=x(e/2),this.count=1,t&&(this.count=j(this)+2)}return this.s+=this.diff,this.count--,this.s}},Ft=class{constructor(e){this.decoder=new Nt(e),this.str=Ot(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var It=crypto.getRandomValues.bind(crypto),Lt=Math.random,Rt=()=>It(new Uint32Array(1))[0],zt=e=>e[x(Lt()*e.length)],Bt=`10000000-1000-4000-8000-100000000000`,Vt=()=>Bt.replace(/[018]/g,e=>(e^Rt()&15>>e/4).toString(16)),Ht=Date.now,Ut=e=>new Promise(e);Promise.all.bind(Promise);var Wt=e=>e===void 0?null:e,Gt=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Gt=localStorage)}catch{}var Kt=Gt,qt=Symbol(`Equality`),Jt=(e,t)=>e===t||!!e?.[qt]?.(t)||!1,Yt=e=>typeof e==`object`,Xt=Object.assign,Zt=Object.keys,Qt=(e,t)=>{for(let n in e)t(e[n],n)},$t=e=>Zt(e).length,en=e=>{for(let t in e)return!1;return!0},tn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},nn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),rn=(e,t)=>e===t||$t(e)===$t(t)&&tn(e,(e,n)=>(e!==void 0||nn(t,n))&&Jt(t[n],e)),an=Object.freeze,on=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&on(e[t])}return an(e)},sn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&sn(e,t,n+1)}},cn=e=>e,ln=(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[qt]!=null)return e[qt](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)||!ln(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if($t(e)!==$t(t))return!1;for(let n in e)if(!nn(e,n)||!ln(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(!ln(e[n],t[n]))return!1;break;default:return!1}return!0},un=(e,t)=>t.includes(e),dn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,fn=typeof window<`u`&&typeof document<`u`&&!dn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var M,pn=[],mn=()=>{if(M===void 0)if(dn){M=h();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&M.set(t,``),t=r):t===null?pn.push(r):(M.set(t,r),t=null)}t!==null&&M.set(t,``)}else typeof location==`object`?(M=h(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);M.set(`--${We(t,`-`)}`,n),M.set(`-${We(t,`-`)}`,n)}})):M=h();return M},hn=e=>mn().has(e),gn=e=>Wt(dn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Kt.getItem(e)),_n=e=>hn(`--`+e)||gn(e)!==null,vn=_n(`production`),yn=dn&&un({}.FORCE_COLOR,[`true`,`1`,`2`])||!hn(`--no-colors`)&&!_n(`no-color`)&&(!dn||process.stdout.isTTY)&&(!dn||hn(`--color`)||gn(`COLORTERM`)!==null||(gn(`TERM`)||``).includes(`color`)),bn=e=>new Uint8Array(e),xn=fn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=ze(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Sn=e=>{let t=bn(e.byteLength);return t.set(e),t},Cn=e=>Qe(t=>pt(t,e)),wn=class{constructor(e,t){this.left=e,this.right=t}},N=(e,t)=>new wn(e,t),Tn=(e,t)=>e.forEach(e=>t(e.left,e.right)),En=e=>e.next()>=.5,Dn=(e,t,n)=>x(e.next()*(n+1-t)+t),On=(e,t,n)=>x(e.next()*(n+1-t)+t),kn=(e,t,n)=>On(e,t,n),An=e=>ze(kn(e,97,122)),jn=(e,t=0,n=20)=>{let r=kn(e,t,n),i=``;for(let t=0;t<r;t++)i+=An(e);return i},Mn=(e,t)=>t[kn(e,0,t.length-1)],Nn=Symbol(`0schema`),Pn=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Ye(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r}from"./dist-PQ5KMVDh.js";import{t as i}from"./compiler-runtime-BfE3aGVn.js";import{Fa as a,Mr as o,S as s,b as c,en as l,nn as u,x as d,y as f}from"./dist-DmmOGEYy.js";import{r as ee}from"./client-version-BxRjWpxD.js";import{a as te,l as ne,r as re}from"./use-apply-config-color-theme-DRPFp4xs.js";import{t as ie}from"./config-context-gd3BC-iY.js";var ae=i(),p=e(n(),1),m=null,oe=new Set;function se(){return m}function ce(e){let t=e!==null&&e.length>0?e:null;if(t!==m){m=t;for(let e of oe)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function le(e){return oe.add(e),()=>{oe.delete(e)}}function ue(){return(0,p.useSyncExternalStore)(le,se,se)}var h=()=>new Map,de=e=>{let t=h();return e.forEach((e,n)=>{t.set(n,e)}),t},g=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},fe=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},_=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},v=()=>new Set,pe=e=>e[e.length-1],me=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},y=Array.from,he=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},ge=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},_e=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},b=Array.isArray,ve=class{constructor(){this._observers=h()}on(e,t){return g(this._observers,e,v).add(t),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 y((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},ye=class{constructor(){this._observers=h()}on(e,t){g(this._observers,e,v).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 y((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},x=Math.floor,be=Math.abs,xe=(e,t)=>e<t?e:t,S=(e,t)=>e>t?e:t;Number.isNaN;var Se=e=>e===0?1/e<0:e<0,Ce=1<<17,we=1<<18,Te=1<<19,Ee=1<<20,De=1<<21,Oe=1<<22,ke=1<<23,Ae=1<<24,je=1<<25,Me=1<<26,Ne=1<<27,Pe=1<<28,Fe=1<<29;Ce-1,we-1,Te-1,Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1,Fe-1;var Ie=2**53-1,Le=-(2**53-1),Re=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&x(e)===e);Number.isNaN,Number.parseInt;var ze=String.fromCharCode;String.fromCodePoint,ze(65535);var Be=e=>e.toLowerCase(),Ve=/^\s*/g,He=e=>e.replace(Ve,``),Ue=/([A-Z])/g,We=(e,t)=>He(e.replace(Ue,e=>`${t}${Be(e)}`)),Ge=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},Ke=typeof TextEncoder<`u`?new TextEncoder:null,qe=Ke?e=>Ke.encode(e):Ge,Je=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Je&&Je.decode(new Uint8Array).length===1&&(Je=null);var Ye=(e,t)=>_e(t,()=>e).join(``),Xe=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Ze=()=>new Xe,Qe=e=>{let t=Ze();return e(t),C(t)},$e=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},C=e=>{let t=new Uint8Array($e(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},et=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(S(n,t)*2),e.cpos=0)},w=(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},tt=w,T=(e,t)=>{for(;t>127;)w(e,128|127&t),t=x(t/128);w(e,127&t)},nt=(e,t)=>{let n=Se(t);for(n&&(t=-t),w(e,(t>63?128:0)|(n?64:0)|63&t),t=x(t/64);t>0;)w(e,(t>127?128:0)|127&t),t=x(t/128)},rt=new Uint8Array(3e4),it=rt.length/3,at=Ke&&Ke.encodeInto?(e,t)=>{if(t.length<it){let n=Ke.encodeInto(t,rt).written||0;T(e,n);for(let t=0;t<n;t++)w(e,rt[t])}else E(e,qe(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;T(e,r);for(let t=0;t<r;t++)w(e,n.codePointAt(t))},ot=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=xe(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(S(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},E=(e,t)=>{T(e,t.byteLength),ot(e,t)},st=(e,t)=>{et(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ct=(e,t)=>st(e,4).setFloat32(0,t,!1),lt=(e,t)=>st(e,8).setFloat64(0,t,!1),ut=(e,t)=>st(e,8).setBigInt64(0,t,!1),dt=new DataView(new ArrayBuffer(4)),ft=e=>(dt.setFloat32(0,e),dt.getFloat32(0)===e),pt=(e,t)=>{switch(typeof t){case`string`:w(e,119),at(e,t);break;case`number`:Re(t)&&be(t)<=2147483647?(w(e,125),nt(e,t)):ft(t)?(w(e,124),ct(e,t)):(w(e,123),lt(e,t));break;case`bigint`:w(e,122),ut(e,t);break;case`object`:if(t===null)w(e,126);else if(b(t)){w(e,117),T(e,t.length);for(let n=0;n<t.length;n++)pt(e,t[n])}else if(t instanceof Uint8Array)w(e,116),E(e,t);else{w(e,118);let n=Object.keys(t);T(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];at(e,i),pt(e,t[i])}}break;case`boolean`:w(e,t?120:121);break;default:w(e,127)}},mt=class extends Xe{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&T(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},ht=e=>{e.count>0&&(nt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&T(e.encoder,e.count-2))},gt=class{constructor(){this.encoder=new Xe,this.s=0,this.count=0}write(e){this.s===e?this.count++:(ht(this),this.count=1,this.s=e)}toUint8Array(){return ht(this),C(this.encoder)}},_t=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);nt(e.encoder,t),e.count>1&&T(e.encoder,e.count-2)}},vt=class{constructor(){this.encoder=new Xe,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(_t(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return _t(this),C(this.encoder)}},yt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new gt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Xe;return this.sarr.push(this.s),this.s=``,at(e,this.sarr.join(``)),ot(e,this.lensE.toUint8Array()),C(e)}},D=e=>Error(e),O=()=>{throw D(`Method unimplemented`)},k=()=>{throw D(`Unexpected case`)},bt=D(`Unexpected end of array`),xt=D(`Integer out of Range`),St=class{constructor(e){this.arr=e,this.pos=0}},Ct=e=>new St(e),wt=e=>e.pos!==e.arr.length,Tt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},A=e=>Tt(e,j(e)),Et=e=>e.arr[e.pos++],j=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Ie)throw xt}throw bt},Dt=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Ie)throw xt}throw bt},Ot=Je?e=>Je.decode(A(e)):e=>{let t=j(e);if(t===0)return``;{let n=String.fromCodePoint(Et(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Et(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))}},kt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},At=[e=>void 0,e=>null,Dt,e=>kt(e,4).getFloat32(0,!1),e=>kt(e,8).getFloat64(0,!1),e=>kt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Ot,e=>{let t=j(e),n={};for(let r=0;r<t;r++){let t=Ot(e);n[t]=jt(e)}return n},e=>{let t=j(e),n=[];for(let r=0;r<t;r++)n.push(jt(e));return n},A],jt=e=>At[127-Et(e)](e),Mt=class extends St{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),wt(this)?this.count=j(this)+1:this.count=-1),this.count--,this.s}},Nt=class extends St{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Dt(this);let e=Se(this.s);this.count=1,e&&(this.s=-this.s,this.count=j(this)+2)}return this.count--,this.s}},Pt=class extends St{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Dt(this),t=e&1;this.diff=x(e/2),this.count=1,t&&(this.count=j(this)+2)}return this.s+=this.diff,this.count--,this.s}},Ft=class{constructor(e){this.decoder=new Nt(e),this.str=Ot(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var It=crypto.getRandomValues.bind(crypto),Lt=Math.random,Rt=()=>It(new Uint32Array(1))[0],zt=e=>e[x(Lt()*e.length)],Bt=`10000000-1000-4000-8000-100000000000`,Vt=()=>Bt.replace(/[018]/g,e=>(e^Rt()&15>>e/4).toString(16)),Ht=Date.now,Ut=e=>new Promise(e);Promise.all.bind(Promise);var Wt=e=>e===void 0?null:e,Gt=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Gt=localStorage)}catch{}var Kt=Gt,qt=Symbol(`Equality`),Jt=(e,t)=>e===t||!!e?.[qt]?.(t)||!1,Yt=e=>typeof e==`object`,Xt=Object.assign,Zt=Object.keys,Qt=(e,t)=>{for(let n in e)t(e[n],n)},$t=e=>Zt(e).length,en=e=>{for(let t in e)return!1;return!0},tn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},nn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),rn=(e,t)=>e===t||$t(e)===$t(t)&&tn(e,(e,n)=>(e!==void 0||nn(t,n))&&Jt(t[n],e)),an=Object.freeze,on=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&on(e[t])}return an(e)},sn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&sn(e,t,n+1)}},cn=e=>e,ln=(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[qt]!=null)return e[qt](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)||!ln(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if($t(e)!==$t(t))return!1;for(let n in e)if(!nn(e,n)||!ln(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(!ln(e[n],t[n]))return!1;break;default:return!1}return!0},un=(e,t)=>t.includes(e),dn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,fn=typeof window<`u`&&typeof document<`u`&&!dn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var M,pn=[],mn=()=>{if(M===void 0)if(dn){M=h();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&M.set(t,``),t=r):t===null?pn.push(r):(M.set(t,r),t=null)}t!==null&&M.set(t,``)}else typeof location==`object`?(M=h(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);M.set(`--${We(t,`-`)}`,n),M.set(`-${We(t,`-`)}`,n)}})):M=h();return M},hn=e=>mn().has(e),gn=e=>Wt(dn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Kt.getItem(e)),_n=e=>hn(`--`+e)||gn(e)!==null,vn=_n(`production`),yn=dn&&un({}.FORCE_COLOR,[`true`,`1`,`2`])||!hn(`--no-colors`)&&!_n(`no-color`)&&(!dn||process.stdout.isTTY)&&(!dn||hn(`--color`)||gn(`COLORTERM`)!==null||(gn(`TERM`)||``).includes(`color`)),bn=e=>new Uint8Array(e),xn=fn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=ze(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Sn=e=>{let t=bn(e.byteLength);return t.set(e),t},Cn=e=>Qe(t=>pt(t,e)),wn=class{constructor(e,t){this.left=e,this.right=t}},N=(e,t)=>new wn(e,t),Tn=(e,t)=>e.forEach(e=>t(e.left,e.right)),En=e=>e.next()>=.5,Dn=(e,t,n)=>x(e.next()*(n+1-t)+t),On=(e,t,n)=>x(e.next()*(n+1-t)+t),kn=(e,t,n)=>On(e,t,n),An=e=>ze(kn(e,97,122)),jn=(e,t=0,n=20)=>{let r=kn(e,t,n),i=``;for(let t=0;t<r;t++)i+=An(e);return i},Mn=(e,t)=>t[kn(e,0,t.length-1)],Nn=Symbol(`0schema`),Pn=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Ye(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
2
|
`)}},Fn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[qt]?Jt(e,t):b(e)?he(e,e=>ge(t,t=>Fn(e,t))):Yt(e)?tn(e,(e,n)=>Fn(e,t[n])):!1,P=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Fn(t,n)}equals(e){return this.constructor===e.constructor&&ln(this.shape,e.shape)}[Nn](){return!0}[qt](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){O()}get nullable(){return fr(this,Dr)}get optional(){return new Wn(this)}cast(e){return jr(e,this),e}expect(e){return jr(e,this),e}},In=class extends P{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}},F=(e,t=null)=>new In(e,t);F(In);var Ln=class extends P{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}},I=e=>new Ln(e);F(Ln);var Rn=class extends P{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}},zn=(...e)=>new Rn(e),Bn=F(Rn),Vn=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Hn=e=>{if(Sr.check(e))return[Vn(e)];if(Bn.check(e))return e.shape.map(e=>e+``);if(xr.check(e))return[`[+-]?\\d+.?\\d*`];if(Cr.check(e))return[`.*`];if(pr.check(e))return e.shape.map(Hn).flat(1);k()};F(class extends P{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Hn).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 Un=Symbol(`optional`),Wn=class extends P{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[Un](){return!0}},Gn=F(Wn),Kn=class extends P{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Kn,F(Kn);var qn=class e extends P{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):tn(this.shape,(n,r)=>{let i=this._isPartial&&!nn(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Jn=e=>new qn(e),Yn=F(qn),Xn=I(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Zn=class extends P{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&tn(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)})}},Qn=(e,t)=>new Zn(e,t),$n=F(Zn),er=class extends P{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&tn(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},tr=(...e)=>new er(e);F(er);var nr=class extends P{constructor(e){super(),this.shape=e.length===1?e[0]:new dr(e)}check(e,t){let n=b(e)&&he(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},rr=(...e)=>new nr(e),ir=F(nr),ar=I(e=>b(e)),or=class extends P{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}},sr=(e,t=null)=>new or(e,t);F(or);var cr=sr(P),lr=F(class extends P{constructor(e){super(),this.len=e.length-1,this.args=tr(...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}}),ur=I(e=>typeof e==`function`);F(class extends P{constructor(e){super(),this.shape=e}check(e,t){let n=he(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var dr=class extends P{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=ge(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},fr=(...e)=>e.findIndex(e=>pr.check(e))>=0?fr(...e.map(e=>Ar(e)).map(e=>pr.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new dr(e),pr=F(dr),mr=()=>!0,hr=I(mr),gr=F(Ln,e=>e.shape===mr),_r=I(e=>typeof e==`bigint`),vr=I(e=>e===_r),yr=I(e=>typeof e==`symbol`);I(e=>e===yr);var br=I(e=>typeof e==`number`),xr=I(e=>e===br),Sr=I(e=>typeof e==`string`),Cr=I(e=>e===Sr),wr=I(e=>typeof e==`boolean`),Tr=I(e=>e===wr),Er=zn(void 0);F(Rn,e=>e.shape.length===1&&e.shape[0]===void 0),zn(void 0);var Dr=zn(null),Or=F(Rn,e=>e.shape.length===1&&e.shape[0]===null);F(Uint8Array),F(In,e=>e.shape===Uint8Array);var kr=fr(br,Sr,Dr,Er,_r,wr,yr);(()=>{let e=rr(hr),t=Qn(Sr,hr),n=fr(br,Sr,Dr,wr,e,t);return e.shape=n,t.shape.values=n,n})();var Ar=e=>{if(cr.check(e))return e;if(Xn.check(e)){let t={};for(let n in e)t[n]=Ar(e[n]);return Jn(t)}else if(ar.check(e))return fr(...e.map(Ar));else if(kr.check(e))return zn(e);else if(ur.check(e))return F(e);k()},jr=vn?()=>{}:(e,t)=>{let n=new Pn;if(!t.check(e,n))throw D(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Mr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Ar(e),h:t}),this}else(e){return this.if(hr,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 D(`Unhandled pattern`)}}},Nr=(e=>new Mr(e))(hr).if(xr,(e,t)=>Dn(t,Le,Ie)).if(Cr,(e,t)=>jn(t)).if(Tr,(e,t)=>En(t)).if(vr,(e,t)=>BigInt(Dn(t,Le,Ie))).if(pr,(e,t)=>Pr(t,Mn(t,e.shape))).if(Yn,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Gn.check(i)){if(En(t))continue;i=i.shape}n[r]=Nr(i,t)}return n}).if(ir,(e,t)=>{let n=[],r=On(t,0,42);for(let i=0;i<r;i++)n.push(Pr(t,e.shape));return n}).if(Bn,(e,t)=>Mn(t,e.shape)).if(Or,(e,t)=>null).if(lr,(e,t)=>{let n=Pr(t,e.res);return()=>n}).if(gr,(e,t)=>Pr(t,Mn(t,[br,Sr,Dr,Er,_r,wr,rr(br),Qn(fr(`a`,`b`,`c`),br)]))).if($n,(e,t)=>{let n={},r=Dn(t,0,3);for(let i=0;i<r;i++){let r=Pr(t,e.shape.keys);n[r]=Pr(t,e.shape.values)}return n}).done(),Pr=(e,t)=>Nr(Ar(t),e),L=typeof document<`u`?document:{},Fr=e=>L.createElement(e),Ir=()=>L.createDocumentFragment();I(e=>e.nodeType===Jr);var Lr=e=>L.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Rr=(e,t)=>(Tn(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),zr=e=>{let t=Ir();for(let n=0;n<e.length;n++)Wr(t,e[n]);return t},Br=(e,t)=>(Wr(e,zr(t)),e),Vr=(e,t=[],n=[])=>Br(Rr(Fr(e),t),n);I(e=>e.nodeType===Gr);var Hr=Lr;I(e=>e.nodeType===Kr);var Ur=e=>fe(e,(e,t)=>`${t}:${e};`).join(``),Wr=(e,t)=>e.appendChild(t),Gr=L.ELEMENT_NODE,Kr=L.TEXT_NODE;L.CDATA_SECTION_NODE,L.COMMENT_NODE;var qr=L.DOCUMENT_NODE;L.DOCUMENT_TYPE_NODE;var Jr=L.DOCUMENT_FRAGMENT_NODE;I(e=>e.nodeType===qr);var Yr=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),Xr=(e,t)=>new Yr(setTimeout(t,e)),R=Symbol,Zr=R(),Qr=R(),$r=R(),ei=R(),ti=R(),ni=R(),ri=R(),ii=R(),ai=R(),oi=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};Ht();var si={[Zr]:N(`font-weight`,`bold`),[Qr]:N(`font-weight`,`normal`),[$r]:N(`color`,`blue`),[ti]:N(`color`,`green`),[ei]:N(`color`,`grey`),[ni]:N(`color`,`red`),[ri]:N(`color`,`purple`),[ii]:N(`color`,`orange`),[ai]:N(`color`,`black`)},ci=yn?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=h(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=si[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=Ur(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}:oi,li=(...e)=>{console.log(...ci(e)),di.forEach(t=>t.print(e))},ui=(...e)=>{console.warn(...ci(e)),e.unshift(ii),di.forEach(t=>t.print(e))},di=v(),fi=e=>({[Symbol.iterator](){return this},next:e}),pi=(e,t)=>fi(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),mi=(e,t)=>fi(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),hi=class{constructor(e,t){this.clock=e,this.len=t}},gi=class{constructor(){this.clients=new Map}},_i=(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])Ma(e,i,o.clock,o.len,n)}}),vi=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=x((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},yi=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&vi(n,t.clock)!==null},bi=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 hi(r.clock,S(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},xi=e=>{let t=new gi;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++)me(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return bi(t),t},Si=(e,t,n,r)=>{g(e.clients,t,()=>[]).push(new hi(n,r))},Ci=()=>new gi,wi=e=>{let t=Ci();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 hi(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Ti=(e,t)=>{T(e.restEncoder,t.clients.size),y(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),T(e.restEncoder,t);let r=n.length;T(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Ei=e=>{let t=new gi,n=j(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=j(e.restDecoder),r=j(e.restDecoder);if(r>0){let i=g(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new hi(e.readDsClock(),e.readDsLen()))}}return t},Di=(e,t,n)=>{let r=new gi,i=j(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=j(e.restDecoder),a=j(e.restDecoder),o=n.clients.get(i)||[],s=B(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Si(r,i,s,a-s);let e=V(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Gs(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,Gs(t,c,a-c.id.clock)),c.delete(t))}else Si(r,i,n,a-n)}}if(r.clients.size>0){let e=new Li;return T(e.restEncoder,0),Ti(e,r),e.toUint8Array()}return null},Oi=Rt,ki=class e extends ve{constructor({guid:e=Vt(),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=Oi(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ta,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=Ut(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Ut(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&&U(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(y(this.subdocs).map(e=>e.guid))}transact(e,t=null){return U(this,e,t)}get(e,t=G){let n=g(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==G&&r!==t)if(r===G){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,Fo)}getText(e=``){return this.get(e,ns)}getMap(e=``){return this.get(e,Ro)}getXmlElement(e=``){return this.get(e,ss)}getXmlFragment(e=``){return this.get(e,as)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,y(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,U(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()}},Ai=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return j(this.restDecoder)}readDsLen(){return j(this.restDecoder)}},ji=class extends Ai{readLeftID(){return z(j(this.restDecoder),j(this.restDecoder))}readRightID(){return z(j(this.restDecoder),j(this.restDecoder))}readClient(){return j(this.restDecoder)}readInfo(){return Et(this.restDecoder)}readString(){return Ot(this.restDecoder)}readParentInfo(){return j(this.restDecoder)===1}readTypeRef(){return j(this.restDecoder)}readLen(){return j(this.restDecoder)}readAny(){return jt(this.restDecoder)}readBuf(){return Sn(A(this.restDecoder))}readJSON(){return JSON.parse(Ot(this.restDecoder))}readKey(){return Ot(this.restDecoder)}},Mi=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=j(this.restDecoder),this.dsCurrVal}readDsLen(){let e=j(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Ni=class extends Mi{constructor(e){super(e),this.keys=[],j(e),this.keyClockDecoder=new Pt(A(e)),this.clientDecoder=new Nt(A(e)),this.leftClockDecoder=new Pt(A(e)),this.rightClockDecoder=new Pt(A(e)),this.infoDecoder=new Mt(A(e),Et),this.stringDecoder=new Ft(A(e)),this.parentInfoDecoder=new Mt(A(e),Et),this.typeRefDecoder=new Nt(A(e)),this.lenDecoder=new Nt(A(e))}readLeftID(){return new oa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new oa(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 jt(this.restDecoder)}readBuf(){return A(this.restDecoder)}readJSON(){return jt(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}}},Pi=class{constructor(){this.restEncoder=Ze()}toUint8Array(){return C(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){T(this.restEncoder,e)}writeDsLen(e){T(this.restEncoder,e)}},Fi=class extends Pi{writeLeftID(e){T(this.restEncoder,e.client),T(this.restEncoder,e.clock)}writeRightID(e){T(this.restEncoder,e.client),T(this.restEncoder,e.clock)}writeClient(e){T(this.restEncoder,e)}writeInfo(e){tt(this.restEncoder,e)}writeString(e){at(this.restEncoder,e)}writeParentInfo(e){T(this.restEncoder,+!!e)}writeTypeRef(e){T(this.restEncoder,e)}writeLen(e){T(this.restEncoder,e)}writeAny(e){pt(this.restEncoder,e)}writeBuf(e){E(this.restEncoder,e)}writeJSON(e){at(this.restEncoder,JSON.stringify(e))}writeKey(e){at(this.restEncoder,e)}},Ii=class{constructor(){this.restEncoder=Ze(),this.dsCurrVal=0}toUint8Array(){return C(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,T(this.restEncoder,t)}writeDsLen(e){e===0&&k(),T(this.restEncoder,e-1),this.dsCurrVal+=e}},Li=class extends Ii{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new vt,this.clientEncoder=new gt,this.leftClockEncoder=new vt,this.rightClockEncoder=new vt,this.infoEncoder=new mt(tt),this.stringEncoder=new yt,this.parentInfoEncoder=new mt(tt),this.typeRefEncoder=new gt,this.lenEncoder=new gt}toUint8Array(){let e=Ze();return T(e,0),E(e,this.keyClockEncoder.toUint8Array()),E(e,this.clientEncoder.toUint8Array()),E(e,this.leftClockEncoder.toUint8Array()),E(e,this.rightClockEncoder.toUint8Array()),E(e,C(this.infoEncoder)),E(e,this.stringEncoder.toUint8Array()),E(e,C(this.parentInfoEncoder)),E(e,this.typeRefEncoder.toUint8Array()),E(e,this.lenEncoder.toUint8Array()),ot(e,C(this.restEncoder)),C(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){pt(this.restEncoder,e)}writeBuf(e){E(this.restEncoder,e)}writeJSON(e){pt(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)}},Ri=(e,t,n,r)=>{r=S(r,t[0].id.clock);let i=V(t,r);T(e.restEncoder,t.length-i),e.writeClient(n),T(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)},zi=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{B(t,n)>e&&r.set(n,e)}),Ea(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),T(e.restEncoder,r.size),y(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Ri(e,t.clients.get(n),n,r)})},Bi=(e,t)=>{let n=h(),r=j(e.restDecoder);for(let i=0;i<r;i++){let r=j(e.restDecoder),i=Array(r),a=e.readClient(),o=j(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 K(z(a,o),t),o+=t;break}case 10:{let t=j(e.restDecoder);i[n]=new Y(z(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new J(z(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,Js(e,r));i[n]=c,o+=c.length}}}}return n},Vi=(e,t,n)=>{let r=[],i=y(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 Ta,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!==Y){let i=g(d,u.id.client,()=>B(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,B(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 Li;return zi(e,s,new Map),T(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Hi=(e,t)=>zi(e,t.doc.store,t.beforeState),Ui=(e,t,n,r=new Ni(e))=>U(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Vi(e,i,Bi(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<B(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=Ya([o.update,a.update])}}else i.pendingStructs=a;let s=Di(r,e,i);if(i.pendingDs){let t=new Ni(Ct(i.pendingDs));j(t.restDecoder);let n=Di(t,e,i);s&&n?i.pendingDs=Ya([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Wi(e.doc,t)}},n,!1),Wi=(e,t,n,r=Ni)=>{let i=Ct(t);Ui(i,e,n,new r(i))},Gi=(e,t,n)=>Wi(e,t,n,ji),Ki=(e,t,n=new Map)=>{zi(e,t.store,n),Ti(e,wi(t.store))},qi=(e,t=new Uint8Array([0]),n=new Li)=>{Ki(n,e,Xi(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Xa(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Fi)return qa(r.map((e,t)=>t===0?e:to(e)));if(n.constructor===Li)return Ya(r)}return r[0]},Ji=(e,t)=>qi(e,t,new Fi),Yi=e=>{let t=new Map,n=j(e.restDecoder);for(let r=0;r<n;r++){let n=j(e.restDecoder),r=j(e.restDecoder);t.set(n,r)}return t},Xi=e=>Yi(new Ai(Ct(e))),Zi=(e,t)=>(T(e.restEncoder,t.size),y(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{T(e.restEncoder,t),T(e.restEncoder,n)}),e),Qi=(e,t)=>Zi(e,Ea(t.store)),$i=(e,t=new Ii)=>(e instanceof Map?Zi(t,e):Qi(t,e),t.toUint8Array()),ea=e=>$i(e,new Pi),ta=class{constructor(){this.l=[]}},na=()=>new ta,ra=(e,t)=>e.l.push(t),ia=(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.`)},aa=(e,t,n)=>sn(e.l,[t,n]),oa=class{constructor(e,t){this.client=e,this.clock=t}},sa=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,z=(e,t)=>new oa(e,t),ca=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw k()},la=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},ua=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},da=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},fa=e=>new ua(e.type==null?null:z(e.type.client,e.type.clock),e.tname??null,e.item==null?null:z(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),pa=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},ma=(e,t,n=0)=>new pa(e,t,n),ha=(e,t,n)=>{let r=null,i=null;return e._item===null?i=ca(e):r=z(e._item.id.client,e._item.id.clock),new ua(r,i,t,n)},ga=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ha(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ha(e,z(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ha(e,r.lastId,n);r=r.right}return ha(e,null,n)},_a=(e,t)=>{let n=Oa(e,t);return{item:n,diff:t.clock-n.id.clock}},va=(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(B(r,i.client)<=i.clock)return null;let e=n?Us(r,i):_a(r,i),t=e.item;if(!(t instanceof J))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(B(r,a.client)<=a.clock)return null;let{item:e}=n?Us(r,a):{item:Oa(r,a)};if(e instanceof J&&e.content instanceof Vs)c=e.content.type;else return null}else throw k();l=s>=0?c._length:0}return ma(c,l,e.assoc)},ya=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&sa(e.item,t.item)&&sa(e.type,t.type)&&e.assoc===t.assoc,ba=class{constructor(e,t){this.ds=e,this.sv=t}},xa=(e,t)=>new ba(e,t);xa(Ci(),new Map);var Sa=e=>xa(wi(e.store),Ea(e.store)),Ca=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!yi(t.ds,e.id),wa=(e,t)=>{let n=g(e.meta,wa,v),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<B(r,n)&&H(e,z(n,t))}),_i(e,t.ds,e=>{}),n.add(t))},Ta=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ea=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},B=(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},Da=(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 k()}n.push(t)},V=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=x(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=x((n+r)/2)}throw k()},Oa=(e,t)=>{let n=e.clients.get(t.client);return n[V(n,t.clock)]},ka=(e,t,n)=>{let r=V(t,n),i=t[r];return i.id.clock<n&&i instanceof J?(t.splice(r+1,0,Gs(e,i,n-i.id.clock)),r+1):r},H=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[ka(e,n,t.clock)]},Aa=(e,t,n)=>{let r=t.clients.get(n.client),i=V(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==K&&r.splice(i+1,0,Gs(e,a,n.clock-a.id.clock+1)),a},ja=(e,t,n)=>{let r=e.clients.get(t.id.client);r[V(r,t.id.clock)]=n},Ma=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=ka(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&ka(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Na=class{constructor(e,t,n){this.doc=e,this.deleteSet=new gi,this.beforeState=Ea(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}},Pa=(e,t)=>t.deleteSet.clients.size===0&&!_(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(bi(t.deleteSet),Hi(e,t),Ti(e,t.deleteSet),!0),Fa=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&g(e.changed,t,v).add(n)},Ia=(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 J&&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},La=(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=V(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 J&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Ra=(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=xe(r.length-1,1+V(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+Ia(r,e)}})},za=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{bi(a),n.afterState=Ea(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(()=>{aa(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&$o(n)})}),sn(e,[])}finally{r.gc&&La(a,i,r.gcFilter),Ra(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=S(V(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Ia(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=V(r,n);a+1<r.length&&Ia(r,a+1)>1||a>0&&Ia(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(li(ii,Zr,`[yjs] `,Qr,ni,`Changed the client-id because another client seems to be using it.`),r.clientID=Oi()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Fi;Pa(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Li;Pa(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])):za(e,t+1)}}},U=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Na(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&&za(i,0)}}return o},Ba=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Va=(e,t,n)=>{_i(e,n.deletions,n=>{n instanceof J&&t.scope.some(t=>t===e.doc||la(t,n))&&Ws(n,!1)})},Ha=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;U(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;_i(n,o.insertions,e=>{if(e instanceof J){if(e.redone!==null){let{item:t,diff:i}=Us(r,e.id);i>0&&(t=H(n,z(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||la(t,e))&&c.push(e)}}),_i(n,o.deletions,e=>{e instanceof J&&a.some(t=>t===n.doc||la(t,e))&&!yi(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=qs(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},Ua=class extends ve{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=b(e)?e[0].doc:e instanceof ki?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 gi;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Si(i,n,r,a)});let a=Ht(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=xi([t.deletions,e.deleteSet]),t.insertions=xi([t.insertions,i])}else r.push(new Ba(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),_i(e,e.deleteSet,t=>{t instanceof J&&this.scope.some(n=>n===e.doc||la(n,t))&&Ws(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=b(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof G?e.doc!==this.doc:e!==this.doc)&&ui(`[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=>Va(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Va(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=Ha(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ha(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*Wa(e){let t=j(e.restDecoder);for(let n=0;n<t;n++){let t=j(e.restDecoder),n=e.readClient(),r=j(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=j(e.restDecoder);yield new Y(z(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new J(z(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,Js(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new K(z(n,r),t),r+=t}}}}var Ga=class{constructor(e,t){this.gen=Wa(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===Y);return this.curr}},Ka=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},qa=e=>Ya(e,ji,Fi),Ja=(e,t)=>{if(e.constructor===K){let{client:n,clock:r}=e.id;return new K(z(n,r+t),e.length-t)}else if(e.constructor===Y){let{client:n,clock:r}=e.id;return new Y(z(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new J(z(r,i+t),null,z(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Ya=(e,t=Ni,n=Li)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Ct(e))),i=r.map(e=>new Ga(e,!0)),a=null,o=new n,s=new Ka(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===Y?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)Qa(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===Y)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Qa(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Y(z(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===Y?a.struct.length-=t:n=Ja(n,t)),a.struct.mergeWith(n)||(Qa(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!==Y;n=e.next())Qa(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Qa(s,a.struct,a.offset),a=null),$a(s),Ti(o,xi(r.map(e=>Ei(e)))),o.toUint8Array()},Xa=(e,t,n=Ni,r=Li)=>{let i=Xi(t),a=new r,o=new Ka(a),s=new n(Ct(e)),c=new Ga(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Y){c.next();continue}if(e.id.clock+e.length>n)for(Qa(o,e,S(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Qa(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 $a(o),Ti(a,Ei(s)),a.toUint8Array()},Za=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:C(e.encoder.restEncoder)}),e.encoder.restEncoder=Ze(),e.written=0)},Qa=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Za(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),T(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},$a=e=>{Za(e);let t=e.encoder.restEncoder;T(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];T(t,r.written),ot(t,r.restEncoder)}},eo=(e,t,n,r)=>{let i=new n(Ct(e)),a=new Ga(i,!1),o=new r,s=new Ka(o);for(let e=a.curr;e!==null;e=a.next())Qa(s,t(e),0);return $a(s),Ti(o,Ei(i)),o.toUint8Array()},to=e=>eo(e,cn,Ni,Fi),no=`You must not compute changes after the event-handler fired.`,ro=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||=io(this.currentTarget,this.target)}deletes(e){return yi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw D(no);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=pe(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=pe(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=pe(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 D(no);let t=this.target,n=v(),r=v(),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}},io=(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},W=()=>{ui(`Invalid access: Add Yjs type to a document before reading data.`)},ao=80,oo=0,so=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=oo++}},co=e=>{e.timestamp=oo++},lo=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=oo++},uo=(e,t,n)=>{if(e.length>=ao){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return lo(r,t,n),r}else{let r=new so(t,n);return e.push(r),r}},fo=(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)=>be(t-e.index)<be(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,co(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&&be(n.index-i)<r.parent.length/ao?(lo(n,r,i),n):uo(e._searchMarker,r,i)},po=(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=S(t,i.index+n))}},mo=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;g(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;aa(r._eH,n,t)},G=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=na(),this._dEH=na(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw O()}clone(){throw O()}_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){ra(this._eH,e)}observeDeep(e){ra(this._dEH,e)}unobserve(e){ia(this._eH,e)}unobserveDeep(e){ia(this._dEH,e)}toJSON(){}},ho=(e,t,n)=>{e.doc??W(),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},go=e=>{e.doc??W();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},_o=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Ca(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},vo=(e,t)=>{let n=0,r=e._start;for(e.doc??W();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}},yo=(e,t)=>{let n=[];return vo(e,(r,i)=>{n.push(t(r,i,e))}),n},bo=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}}}},xo=(e,t)=>{e.doc??W();let n=fo(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}},So=(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 J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ks(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 J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new gs(new Uint8Array(n))),i.integrate(e,0);break;case ki:i=new J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new xs(n)),i.integrate(e,0);break;default:if(n instanceof G)i=new J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Vs(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Co=()=>D(`Length exceeded!`),wo=(e,t,n,r)=>{if(n>t._length)throw Co();if(n===0)return t._searchMarker&&po(t._searchMarker,n,r.length),So(e,t,null,r);let i=n,a=fo(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&&H(e,z(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&po(t._searchMarker,i,r.length),So(e,t,o,r)},To=(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 So(e,t,r,n)},Eo=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=fo(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&&H(e,z(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&H(e,z(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Co();t._searchMarker&&po(t._searchMarker,i,-a+r)},Do=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Oo=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new ks([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new ks([r]);break;case Uint8Array:s=new gs(r);break;case ki:s=new xs(r);break;default:if(r instanceof G)s=new Vs(r);else throw Error(`Unexpected content type`)}new J(z(o,B(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},ko=(e,t)=>{e.doc??W();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Ao=e=>{let t={};return e.doc??W(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},jo=(e,t)=>{e.doc??W();let n=e._map.get(t);return n!==void 0&&!n.deleted},Mo=(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&&Ca(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},No=e=>(e.doc??W(),pi(e._map.entries(),e=>!e[1].deleted)),Po=class extends ro{},Fo=class e extends G{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 G?e.clone():e)),t}get length(){return this.doc??W(),this._length}_callObserver(e,t){super._callObserver(e,t),mo(this,e,new Po(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):U(this.doc,n=>{wo(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):U(this.doc,t=>{To(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):U(this.doc,n=>{Eo(n,this,e,t)})}get(e){return xo(this,e)}toArray(){return go(this)}slice(e=0,t=this.length){return ho(this,e,t)}toJSON(){return this.map(e=>e instanceof G?e.toJSON():e)}map(e){return yo(this,e)}forEach(e){vo(this,e)}[Symbol.iterator](){return bo(this)}_write(e){e.writeTypeRef(Ps)}},Io=e=>new Fo,Lo=class extends ro{constructor(e,t,n){super(e,t),this.keysChanged=n}},Ro=class e extends G{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 G?e.clone():e)}),t}_callObserver(e,t){mo(this,e,new Lo(this,e,t))}toJSON(){this.doc??W();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof G?r.toJSON():r}}),e}get size(){return[...No(this)].length}keys(){return mi(No(this),e=>e[0])}values(){return mi(No(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return mi(No(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??W(),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):U(this.doc,t=>{Do(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):U(this.doc,n=>{Oo(n,this,e,t)}),t}get(e){return ko(this,e)}has(e){return jo(this,e)}clear(){this.doc===null?this._prelimContent.clear():U(this.doc,e=>{this.forEach(function(t,n,r){Do(e,r,n)})})}_write(e){e.writeTypeRef(Fs)}},zo=e=>new Ro,Bo=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&rn(e,t),Vo=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&k(),this.right.content.constructor){case q:this.right.deleted||Go(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}},Ho=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case q:t.right.deleted||Go(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&H(e,z(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},Uo=(e,t,n,r)=>{let i=new Map,a=r?fo(t,n):null;return a?Ho(e,new Vo(a.p.left,a.p,a.index,i),n-a.index):Ho(e,new Vo(null,t._start,0,i),n)},Wo=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===q&&Bo(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 J(z(a,B(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new q(o,r));l.integrate(e,0),n.right=l,n.forward()})},Go=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Ko=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===q&&Bo(t[e.right.content.key]??null,e.right.content.value));)e.forward()},qo=(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(!Bo(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new J(z(a,B(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new q(s,c)),n.right.integrate(e,0),n.forward()}}return o},Jo=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Ko(n,i);let s=qo(e,t,n,i),c=r.constructor===String?new js(r):r instanceof G?new Vs(r):new Cs(r),{left:l,right:u,index:d}=n;t._searchMarker&&po(t._searchMarker,n.index,c.getLength()),u=new J(z(o,B(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(),Wo(e,t,n,s)},Yo=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Ko(n,i);let s=qo(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===q));){if(!n.right.deleted)switch(n.right.content.constructor){case q:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Bo(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&&H(e,z(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+=`
|
|
3
3
|
`;n.right=new J(z(o,B(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new js(i)),n.right.integrate(e,0),n.forward()}Wo(e,t,n,s)},Xo=(e,t,n,r,i)=>{let a=t,o=h();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===q){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 q:{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&&Go(i,n);break}}}t=t.right}return s},Zo=(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===q){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Qo=e=>{let t=0;return U(e.doc,n=>{let r=e._start,i=e._start,a=h(),o=de(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case q:Go(o,i.content);break;default:t+=Xo(n,r,i,a,o),a=de(o),r=i;break}i=i.right}}),t},$o=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&&Ma(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===q&&e.constructor!==K&&t.add(e.parent)})}U(n,n=>{_i(e,e.deleteSet,e=>{if(e instanceof K||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===q?t.add(r):Zo(n,e)});for(let e of t)Qo(e)})},es=(e,t,n)=>{let r=n,i=de(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Vs:case Cs:case js:n<t.right.length&&H(e,z(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&Xo(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&po(o._searchMarker,t.index,-r+n),t},ts=class extends ro{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=[];U(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},en(o)||(e.attributes=Xt({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Vs:case Cs: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 js: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 q:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Bo(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Bo(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;Bo(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Bo(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Go(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}},ns=class e extends G{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??W(),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 ts(this,e,t);mo(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??W();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===js&&(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)):U(this.doc,n=>{let r=new Vo(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)===`
|
|
4
4
|
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Jo(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&es(n,r,a.delete):Yo(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??W();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(Ca(s,e)||t!==void 0&&Ca(s,t))switch(s.content.constructor){case js:{let r=i.get(`ychange`);e!==void 0&&!Ca(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&&!Ca(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 Vs:case Cs:{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 q:Ca(s,e)&&(c(),Go(i,s.content));break}s=s.right}c()};return e||t?U(a,n=>{e&&wa(n,e),t&&wa(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)):U(r,r=>{let i=Uo(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Jo(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):U(r,r=>{let i=Uo(r,this,e,!n);Jo(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)):U(n,n=>{es(n,Uo(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)):U(r,r=>{let i=Uo(r,this,e,!1);i.right!==null&&Yo(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):U(this.doc,t=>{Do(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):U(this.doc,n=>{Oo(n,this,e,t)})}getAttribute(e){return ko(this,e)}getAttributes(){return Ao(this)}_write(e){e.writeTypeRef(Is)}},rs=e=>new ns,is=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??W()}[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===ss||t.constructor===as)&&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})}},as=class e extends G{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 G?e.clone():e)),t}get length(){return this.doc??W(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new is(this,e)}querySelector(e){e=e.toUpperCase();let t=new is(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),y(new is(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){mo(this,e,new ls(this,t,e))}toString(){return yo(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),vo(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):U(this.doc,n=>{wo(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)U(this.doc,n=>{let r=e&&e instanceof G?e._item:e;So(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 D(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):U(this.doc,n=>{Eo(n,this,e,t)})}toArray(){return go(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return xo(this,e)}slice(e=0,t=this.length){return ho(this,e,t)}forEach(e){vo(this,e)}_write(e){e.writeTypeRef(Rs)}},os=e=>new as,ss=class e extends as{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 Qt(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof G?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):U(this.doc,t=>{Do(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):U(this.doc,n=>{Oo(n,this,e,t)})}getAttribute(e){return ko(this,e)}hasAttribute(e){return jo(this,e)}getAttributes(e){return e?Mo(this,e):Ao(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 vo(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ls),e.writeKey(this.nodeName)}},cs=e=>new ss(e.readKey()),ls=class extends ro{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)})}},us=class e extends Ro{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(zs),e.writeKey(this.hookName)}},ds=e=>new us(e.readKey()),fs=class e extends ns{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(Bs)}},ps=e=>new fs,ms=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw O()}mergeWith(e){return!1}write(e,t,n){throw O()}integrate(e,t){throw O()}},hs=0,K=class extends ms{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),Da(e.doc.store,this)}write(e,t){e.writeInfo(hs),e.writeLen(this.length-t)}getMissing(e,t){return null}},gs=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 O()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},_s=e=>new gs(e.readBuf()),vs=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){Si(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}},ys=e=>new vs(e.readLen()),bs=(e,t)=>new ki({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),xs=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(bs(this.doc.guid,this.opts))}splice(e){throw O()}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}},Ss=e=>new xs(bs(e.readString(),e.readAny())),Cs=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 O()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},ws=e=>new Cs(e.readJSON()),q=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 O()}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}},Ts=e=>new q(e.readKey(),e.readJSON()),Es=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}},Ds=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 Es(n)},Os=gn(`node_env`)===`development`,ks=class e{constructor(e){this.arr=e,Os&&on(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}},As=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new ks(n)},js=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}},Ms=e=>new js(e.readString()),Ns=[Io,zo,rs,cs,os,ds,ps],Ps=0,Fs=1,Is=2,Ls=3,Rs=4,zs=5,Bs=6,Vs=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 O()}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}},Hs=e=>new Vs(Ns[e.readTypeRef()](e)),Us=(e,t)=>{let n=t,r=0,i;do r>0&&(n=z(n.client,n.clock+r)),i=Oa(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof J);return{item:i,diff:r}},Ws=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Gs=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new J(z(r,i+n),t,z(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=z(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},Ks=(e,t)=>ge(e,e=>yi(e.deletions,t)),qs=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return H(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||qs(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=H(e,u.redone)}let ee=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:H(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:H(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||yi(r,d.right.id)||Ks(a.undoStack,d.right.id)||Ks(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=H(e,d.redone);if(d&&d.right!==null)return null}else d=ee._map.get(t.parentSub)||null;d!==null&&d.parent._item!==u&&(d=ee._map.get(t.parentSub)||null)}let te=z(c,B(s,c)),ne=new J(te,d,d&&d.lastId,f,f&&f.id,ee,t.parentSub,t.content.copy());return t.redone=te,Ws(ne,!0),ne.integrate(e,0),ne},J=class e extends ms{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>=B(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=B(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===oa&&this.id.client!==this.parent.client&&this.parent.clock>=B(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Aa(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=H(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===K||this.right&&this.right.constructor===K)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===oa){let e=Oa(n,this.parent);e.constructor===K?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Aa(e,e.doc.store,z(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),sa(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(sa(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Oa(e.doc.store,n.origin)))r.has(Oa(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),Da(e.doc.store,this),this.content.integrate(e,this),Fa(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new K(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:z(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&sa(e.origin,this.lastId)&&this.right===e&&sa(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(),Si(e.deleteSet,this.id.client,this.id.clock,this.length),Fa(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw k();this.content.gc(e),t?ja(e,this,new K(this.id,this.length)):this.content=new vs(this.length)}write(e,t){let n=t>0?z(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=ca(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===oa?(e.writeParentInfo(!1),e.writeLeftID(t)):k();i!==null&&e.writeString(i)}this.content.write(e,t)}},Js=(e,t)=>Ys[t&31](e),Ys=[()=>{k()},ys,Ds,_s,Ms,ws,Ts,Hs,As,Ss,()=>{k()}],Xs=10,Y=class extends ms{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){k()}write(e,t){e.writeInfo(Xs),T(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Zs=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Qs=`__ $YJS$ __`;Zs[Qs]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Zs[Qs]=!0;var $s=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),ec=(e,t)=>{T(e,$s.Token),at(e,t)},tc=(e,t,n,r)=>{switch(j(e)){case $s.Token:t();break;case $s.PermissionDenied:n(Ot(e));break;case $s.Authenticated:r(Ot(e));break;default:}},nc=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),rc=`\0`;function ic(e,t){return e+rc+t}function ac(e){let t=e.indexOf(rc);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var oc=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 sc(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 cc(e){return new Promise(t=>setTimeout(t,e))}function lc(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 uc(e,t){let n=sc(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||lc;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 cc(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 cc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await cc(e)}return a()}var dc=Math.floor,fc=(e,t)=>e<t?e:t,pc=(e,t)=>e>t?e:t;Number.isNaN;var mc=64,hc=128,gc=1<<17,_c=1<<18,vc=1<<19,yc=1<<20,bc=1<<21,xc=1<<22,Sc=1<<23,Cc=1<<24,wc=1<<25,Tc=1<<26,Ec=1<<27,Dc=1<<28,Oc=1<<29,kc=1<<30,Ac=63,jc=127;gc-1,_c-1,vc-1,yc-1,bc-1,xc-1,Sc-1,Cc-1,wc-1,Tc-1,Ec-1,Dc-1,Oc-1,kc-1;var Mc=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Nc=()=>new Set,Pc=Array.from;Array.isArray;var Fc=String.fromCharCode;String.fromCodePoint,Fc(65535);var Ic=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},Lc=typeof TextEncoder<`u`?new TextEncoder:null,Rc=Lc?e=>Lc.encode(e):Ic,zc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});zc&&zc.decode(new Uint8Array).length===1&&(zc=null);var Bc=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Vc=()=>new Bc,Hc=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Uc=e=>{let t=new Uint8Array(Hc(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},Wc=(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},X=(e,t)=>{for(;t>jc;)Wc(e,hc|jc&t),t=dc(t/128);Wc(e,jc&t)},Gc=new Uint8Array(3e4),Kc=Gc.length/3,Z=Lc&&Lc.encodeInto?(e,t)=>{if(t.length<Kc){let n=Lc.encodeInto(t,Gc).written||0;X(e,n);for(let t=0;t<n;t++)Wc(e,Gc[t])}else Jc(e,Rc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;X(e,r);for(let t=0;t<r;t++)Wc(e,n.codePointAt(t))},qc=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=fc(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(pc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Jc=(e,t)=>{X(e,t.byteLength),qc(e,t)},Yc=e=>Error(e),Xc=Yc(`Unexpected end of array`),Zc=Yc(`Integer out of Range`),Qc=class{constructor(e){this.arr=e,this.pos=0}},$c=e=>new Qc(e),el=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},tl=e=>el(e,rl(e)),nl=e=>e.arr[e.pos++],rl=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&jc)*n,n*=128,r<hc)return t;if(t>Mc)throw Zc}throw Xc},il=e=>{let t=e.arr[e.pos++],n=t&Ac,r=64,i=(t&mc)>0?-1:1;if((t&hc)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&jc)*r,r*=128,t<hc)return i*n;if(n>Mc)throw Zc}throw Xc},al=zc?e=>zc.decode(tl(e)):e=>{let t=rl(e);if(t===0)return``;{let n=String.fromCodePoint(nl(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(nl(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))}},ol=e=>{let t=e.pos,n=al(e);return e.pos=t,n},sl=Date.now,cl=()=>new Map,ll=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ul=class{constructor(){this._observers=cl()}on(e,t){ll(this._observers,e,Nc).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 Pc((this._observers.get(e)||cl()).values()).forEach(e=>e(...t))}destroy(){this._observers=cl()}},dl=Symbol(`Equality`),fl=Object.keys,pl=e=>fl(e).length,ml=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),hl=(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[dl]!=null)return e[dl](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)||!hl(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(pl(e)!==pl(t))return!1;for(let n in e)if(!ml(e,n)||!hl(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(!hl(e[n],t[n]))return!1;break;default:return!1}return!0},gl=3e4,_l=class extends ul{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=sl();this.getLocalState()!==null&&gl/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&gl<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&vl(this,t,`timeout`)},dc(gl/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:sl()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),hl(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}},vl=(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:sl()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},yl=(e,t,n=e.states)=>{let r=t.length,i=Vc();X(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;X(i,r),X(i,s),Z(i,JSON.stringify(o))}return Uc(i)},bl=(e,t,n)=>{let r=$c(t),i=sl(),a=[],o=[],s=[],c=[],l=rl(r);for(let t=0;t<l;t++){let t=rl(r),n=rl(r),l=JSON.parse(al(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&&(hl(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])},xl=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={}}},Sl=class{constructor(e){this.data=e,this.encoder=Vc(),this.decoder=$c(new Uint8Array(this.data))}peekVarString(){return ol(this.decoder)}readVarUint(){return rl(this.decoder)}readVarString(){return al(this.decoder)}readVarUint8Array(){return tl(this.decoder)}writeVarUint(e){return X(this.encoder,e)}writeVarString(e){return Z(this.encoder,e)}writeVarUint8Array(e){return Jc(this.encoder,e)}length(){return Hc(this.encoder)}},Q=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}({}),$=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),Cl=class{constructor(){this.encoder=Vc()}get(e){return e.encoder}toUint8Array(){return Uc(this.encoder)}},wl=class extends Cl{constructor(...e){super(...e),this.type=Q.CLOSE,this.description=`Ask the server to close the connection`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),this.encoder}},Tl=class e extends xl{static{this.DEDUPLICATABLE_TYPES=new Set([Q.Awareness,Q.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=$.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=$.Connected,this.emit(`status`,{status:$.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===$.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===$.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(wl,{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===$.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:uc(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=$.Connecting,this.emit(`status`,{status:$.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=sl();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Q.Ping){this.sendPong();return}let n=new Sl(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=Vc();X(e,Q.Pong),this.send(Uc(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=$.Connected,this.emit(`status`,{status:$.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===$.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=sl()-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=$c(e);return{documentName:al(t),messageType:rl(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===oc.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=$.Disconnected,this.emit(`status`,{status:$.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()}},El=0,Dl=1,Ol=2,kl=(e,t)=>{X(e,El),Jc(e,ea(t))},Al=(e,t,n)=>{X(e,Dl),Jc(e,Ji(t,n))},jl=(e,t,n)=>Al(t,n,tl(e)),Ml=(e,t,n,r)=>{try{Gi(t,tl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},Nl=(e,t)=>{X(e,Ol),Jc(e,t)},Pl=Ml,Fl=(e,t,n,r,i)=>{let a=rl(e);switch(a){case El:jl(e,t,n);break;case Dl:Ml(e,n,r,i);break;case Ol:Pl(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},Il=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case Q.Sync:this.applySyncMessage(e,t);break;case Q.Awareness:this.applyAwarenessMessage(e);break;case Q.Auth:this.applyAuthMessage(e);break;case Q.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Q.Stateless:e.receiveStateless(al(n.decoder));break;case Q.SyncStatus:this.applySyncStatusMessage(e,il(n.decoder)===1);break;case Q.CLOSE:let i={code:1e3,reason:al(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(Cl,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Q.Sync);let r=Fl(n.decoder,n.encoder,e.document,e);t&&r===Dl&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;bl(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;tc(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(Q.Awareness),t.writeVarUint8Array(yl(e.awareness,Array.from(e.awareness.getStates().keys())))}},Ll=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Uc(this.encoder)}send(e){e?.send(this.create())}},Rl=`4.0.0-rc.1`,zl=class extends Cl{constructor(...e){super(...e),this.type=Q.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return Z(this.encoder,e.documentName),X(this.encoder,this.type),ec(this.encoder,e.token),Z(this.encoder,Rl),this.encoder}},Bl=class extends Cl{constructor(...e){super(...e),this.type=Q.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`);Z(this.encoder,e.documentName),X(this.encoder,this.type);let t;return t=e.states===void 0?yl(e.awareness,e.clients):yl(e.awareness,e.clients,e.states),Jc(this.encoder,t),this.encoder}},Vl=class extends Cl{constructor(...e){super(...e),this.type=Q.Stateless,this.description=`A stateless message`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),Z(this.encoder,e.payload??``),this.encoder}},Hl=class extends Cl{constructor(...e){super(...e),this.type=Q.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 Z(this.encoder,e.documentName),X(this.encoder,this.type),kl(this.encoder,e.document),this.encoder}},Ul=class extends Cl{constructor(...e){super(...e),this.type=Q.Sync,this.description=`A document update`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),Nl(this.encoder,e.update),this.encoder}},Wl=class extends Error{constructor(...e){super(...e),this.code=1001}},Gl=class extends xl{get effectiveName(){return this.configuration.sessionAwareness?ic(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 ki,this.configuration.awareness=e.awareness===void 0?new _l(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:nc(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:nc(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 Tl(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(Hl,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&vl(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(Vl,{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(zl,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Ul,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(Bl,{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(Hl,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Bl,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new Ll(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new Sl(e.data),{documentName:n}=ac(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new Sl(e.data)}),new Il(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&vl(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&&(vl(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 Wl(`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)}};function Kl(e,t,n=null,r=null){let i={...ee()};return e!==null&&(i.principalId=e.principalId,i.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(i.expectedServerInstanceId=t),n!==null&&n.length>0&&(i.expectedBranch=n),r!==null&&r.length>0&&(i.expectedDocLineageEpoch=r),JSON.stringify(i)}function ql(e,t){let n=(0,ae.c)(7),r,i;n[0]!==e||n[1]!==t?(r=()=>{if(t!==`light`&&t!==`dark`&&t!==`system`||!e)return;let n=!1;return e.setThemeSource(t).catch(e=>{console.warn(JSON.stringify({event:`theme-source-set-failed`,themeValue:t,error:e instanceof Error?e.message:String(e)}))}).finally(()=>{if(n)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`).matches;e.signalThemeApplied({reducedTransparency:t})}),()=>{n=!0}},i=[e,t],n[0]=e,n[1]=t,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,p.useEffect)(r,i);let a,o;n[4]===e?(a=n[5],o=n[6]):(a=()=>{if(!e)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`),n=t=>{e.signalThemeApplied({reducedTransparency:t.matches})};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},o=[e],n[4]=e,n[5]=a,n[6]=o),(0,p.useEffect)(a,o)}function Jl(e){let t=(0,ae.c)(5),{setTheme:n}=r(),i;t[0]!==n||t[1]!==e?(i=()=>{(e===`light`||e===`dark`||e===`system`)&&n(e)},t[0]=n,t[1]=e,t[2]=i):i=t[2];let a;t[3]===e?a=t[4]:(a=[e],t[3]=e,t[4]=a),(0,p.useEffect)(i,a)}var Yl=t();function Xl(e,t,n,r){console.warn(JSON.stringify({event:`ok-${e}-${n}`,docName:t,code:r?.code,reason:r?.reason??void 0}))}function Zl(e,t,n,r){let i=new ki,a=new Gl({url:e,name:t,document:i,token:Kl(null,r,null),onDisconnect:({event:e})=>Xl(`config-provider`,t,`disconnect`,e),onClose:({event:e})=>Xl(`config-provider`,t,`close`,e)}),o=l(a,n);return{binding:o,config:o.current(),cleanup:()=>{o.dispose(),a.destroy(),i.destroy()}}}function Ql(e,t){let n=new ki,r=new Gl({url:e,name:f,document:n,token:Kl(null,t,null),onDisconnect:({event:e})=>Xl(`okignore-provider`,f,`disconnect`,e),onClose:({event:e})=>Xl(`okignore-provider`,f,`close`,e)}),i=u(r);return{binding:i,provider:r,cleanup:()=>{i.dispose(),r.destroy(),n.destroy()}}}function $l(e){let t=(0,ae.c)(28),{collabUrl:n,children:r}=e,i=ue(),[l,u]=(0,p.useState)(null),[f,ee]=(0,p.useState)(null),[m,oe]=(0,p.useState)(null),[se,ce]=(0,p.useState)(null),le,h;t[0]!==n||t[1]!==i?(le=()=>{if(n===null)return;let e=Zl(n,s,`user`,i),t=Zl(n,c,`project`,i),r=Zl(n,d,`project-local`,i),a=Ql(n,i);u({binding:e.binding,config:e.config,synced:e.binding.hasSynced()}),ee({binding:t.binding,config:t.config,synced:t.binding.hasSynced()}),oe({binding:r.binding,config:r.config,synced:r.binding.hasSynced()}),ce({binding:a.binding,synced:!1});let o=e.binding.subscribe(t=>{u(n=>n?.binding===e.binding?{...n,config:t}:n)}),l=e.binding.subscribeSynced(()=>{u(t=>t?.binding===e.binding?{...t,synced:!0}:t)}),f=t.binding.subscribe(e=>{ee(n=>n?.binding===t.binding?{...n,config:e}:n)}),te=t.binding.subscribeSynced(()=>{ee(e=>e?.binding===t.binding?{...e,synced:!0}:e)}),ne=r.binding.subscribe(e=>{oe(t=>t?.binding===r.binding?{...t,config:e}:t)}),re=r.binding.subscribeSynced(()=>{oe(e=>e?.binding===r.binding?{...e,synced:!0}:e)}),ie=()=>{ce(e=>e?.binding===a.binding?{...e,synced:!0}:e)};return a.provider.on(`synced`,ie),()=>{o(),l(),f(),te(),ne(),re(),a.provider.off(`synced`,ie);for(let n of[e,t,r,a])try{n.cleanup()}catch(e){console.warn(JSON.stringify({event:`ok-config-provider-cleanup-error`,error:String(e)}))}u(t=>t?.binding===e.binding?null:t),ee(e=>e?.binding===t.binding?null:e),oe(e=>e?.binding===r.binding?null:e),ce(e=>e?.binding===a.binding?null:e)}},h=[n,i],t[0]=n,t[1]=i,t[2]=le,t[3]=h):(le=t[2],h=t[3]),(0,p.useEffect)(le,h);let de,g,fe,_,v;if(t[4]!==m?.config||t[5]!==f||t[6]!==l){_=l&&f?o(l.config,f.config,m?.config):null;let e=_?.appearance?.theme;g=_?.appearance?.colorTheme,fe=_?.appearance?.customTheme,de=_?.appearance?.colorThemeEnabled!==!1,v=de?g===`custom`?te(ne(fe)):a(g)??e:e,t[4]=m?.config,t[5]=f,t[6]=l,t[7]=de,t[8]=g,t[9]=fe,t[10]=_,t[11]=v}else de=t[7],g=t[8],fe=t[9],_=t[10],v=t[11];let pe=v;Jl(pe),re(g,fe,de),ql(typeof window<`u`?window.okDesktop:void 0,pe??`system`);let me=l?.binding??null,y=l?.synced??!1,he=f?.binding??null,ge=m?.binding??null,_e=se?.binding??null,b=se?.synced??!1,ve=l?.config??null,ye=f?.config??null,x=f?.synced??!1,be=m?.config??null,xe=m?.synced??!1,S;t[12]!==_||t[13]!==ve||t[14]!==ye||t[15]!==x||t[16]!==be||t[17]!==xe||t[18]!==me||t[19]!==y||t[20]!==he||t[21]!==ge||t[22]!==_e||t[23]!==b?(S={userBinding:me,userSynced:y,projectBinding:he,projectLocalBinding:ge,okignoreBinding:_e,okignoreSynced:b,userConfig:ve,projectConfig:ye,projectSynced:x,projectLocalConfig:be,projectLocalSynced:xe,merged:_},t[12]=_,t[13]=ve,t[14]=ye,t[15]=x,t[16]=be,t[17]=xe,t[18]=me,t[19]=y,t[20]=he,t[21]=ge,t[22]=_e,t[23]=b,t[24]=S):S=t[24];let Se=S,Ce;return t[25]!==r||t[26]!==Se?(Ce=(0,Yl.jsx)(ie,{value:Se,children:r}),t[25]=r,t[26]=Se,t[27]=Ce):Ce=t[27],Ce}export{S as $,yi as A,Hr as B,ga as C,ea as D,Ji as E,U as F,tn as G,Cn as H,_o as I,zt as J,Zt as K,Xr as L,_i as M,da as N,V as O,Sa as P,Fe as Q,L as R,fa as S,Xi as T,xn as U,N as V,fn as W,O as X,D as Y,k as Z,Wi as _,q as a,ce as at,Ci as b,ki as c,ba as d,xe as et,Ua as f,Gi as g,fs as h,Gl as i,g as it,la as j,ca as k,J as l,ss as m,ql as n,v as nt,js as o,ns as p,Ut as q,Kl as r,h as rt,Vs as s,$l as t,ye as tt,ua as u,ya as v,xa as w,z as x,va as y,Vr as z};
|
|
@@ -174,7 +174,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
174
174
|
`)].join(`
|
|
175
175
|
`);case`REMOVED_KEY`:{let t=e.path.join(`.`),n=[`${e.source?`Removed key at ${e.source.file}:${e.source.line}:${e.source.column}`:`Removed key in configuration`}: ${t}`,e.redirect];if(e.source?.snippet&&e.source.snippet.length>0)for(let t of e.source.snippet.split(`
|
|
176
176
|
`))n.push(` ${t}`);return n.join(`
|
|
177
|
-
`)}case`WRITE_ERROR`:return`Failed to write config file: ${e.detail}`;case`OKIGNORE_INVALID`:return e.lineNumber===void 0?`.okignore: ${e.detail}`:`.okignore line ${e.lineNumber}: ${e.detail}`;case`UNKNOWN`:return e.message??`Unknown error.`}}var Xf="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.";[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,Xf].join(` `),[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,Xf].join(` `),[`folders is no longer a top-level config field.`,"A folder's own frontmatter (open-shape, like a doc's) lives in nested `<folder>/.ok/frontmatter.yml`; new-doc starting properties come from templates in `<folder>/.ok/templates/`.","Edit via the folder overview in the editor sidebar, or `edit({ folder: { path, frontmatter } })` via the MCP.",Xf].join(` `),[`appearance.editorModeDefault was removed and is never read — new docs always open in WYSIWYG; toggle mode via the editor mode button.`,Xf].join(` `),[`streaming uploads have no user-facing cap; the value is hardcoded in @inkeep/open-knowledge-core.`,Xf].join(` `),[`Use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID environment variable instead.`,Xf].join(` `),[`Use the --host CLI flag or the HOST environment variable instead.`,Xf].join(` `),[`This behavior was removed; the value is hardcoded.`,Xf].join(` `),[`To disable MCP auto-start, set OK_MCP_AUTOSTART=0.`,Xf].join(` `),[`This value is hardcoded in @inkeep/open-knowledge-core.`,Xf].join(` `),[`This value is hardcoded in @inkeep/open-knowledge-core.`,Xf].join(` `),[`The search result cap is hardcoded in @inkeep/open-knowledge-core; this config key was removed.`,Xf].join(` `),["preview URLs now resolve only to the running UI process — start one with `ok ui`.",Xf].join(` `),[`preview.scriptSrc has been removed.`,`The code-block preview iframe now runs a fixed open network policy (it is no longer configurable).`,Xf].join(` `),[`appearance.sidebar.showAllFiles has been removed.`,`The sidebar lists every file on disk by default; dot-prefixed entries are gated by appearance.sidebar.showHiddenFiles, and appearance.sidebar.showOnlyMarkdownFiles scopes the tree down to markdown documents as a per-machine view preference.`,Xf].join(` `);var Zf={"bridge-merge-loss":{visibility:`surfaced`,gcBucket:`bridge-merge-loss`,bundleExposure:`subject-only`},"producer-guard-loss":{visibility:`surfaced`,gcBucket:`producer-guard-loss`,bundleExposure:`metadata`},"observer-a-duplication":{visibility:`surfaced`,gcBucket:`observer-a-duplication`,bundleExposure:`metadata`},"external-change-rescue":{visibility:`surfaced`,gcBucket:`external-change-rescue`,bundleExposure:`metadata`},"defer-exhaustion-loss":{visibility:`surfaced`,gcBucket:`defer-exhaustion-loss`,bundleExposure:`metadata`},"observer-a-apply-loss":{visibility:`surfaced`,gcBucket:`observer-a-apply-loss`,bundleExposure:`subject-only`},"bridge-derive-loss":{visibility:`surfaced`,gcBucket:`bridge-derive-loss`,bundleExposure:`subject-only`},"bridge-backstop-trip":{visibility:`surfaced`,gcBucket:`bridge-backstop-trip`,bundleExposure:`metadata`},"persistence-reconcile-loss":{visibility:`surfaced`,gcBucket:`persistence-reconcile-loss`,bundleExposure:`metadata`},"persistence-duplication-reset":{visibility:`surfaced`,gcBucket:`persistence-duplication-reset`,bundleExposure:`metadata`},"auto-consolidation":{visibility:`hidden`,gcBucket:`auto-consolidation`,bundleExposure:`none`}};function Qf(e){return e==null?!0:Zf[e].visibility===`surfaced`}function $f(e){this.content=e}$f.prototype={constructor:$f,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new $f(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new $f(n)},addToStart:function(e,t){return new $f([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new $f(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new $f(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=$f.from(e),e.size?new $f(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=$f.from(e),e.size?new $f(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=$f.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},$f.from=function(e){if(e instanceof $f)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new $f(t)};function ep(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=ep(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function tp(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=tp(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var U=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return ep(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return tp(this,e,t,n)}findIndex(e){if(e==0)return rp(0,e);if(e==this.size)return rp(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?rp(t+1,i):rp(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};U.empty=new U([],0);var np={index:0,offset:0};function rp(e,t){return np.index=e,np.offset=t,np}function ip(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!ip(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!ip(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var ap=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ip(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};ap.none=[];var op=class extends Error{},W=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=cp(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(sp(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(U.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};W.empty=new W(U.empty,0,0);function sp(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(sp(a.content,t-i-1,n-i-1)))}function cp(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=cp(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function lp(e,t,n){if(n.openStart>e.depth)throw new op(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new op(`Inconsistent open depths`);return up(e,t,n,0)}function up(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=up(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return hp(a,_p(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return hp(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=vp(n,e);return hp(a,gp(e,i,o,t,r))}}function dp(e,t){if(!t.type.compatibleContent(e.type))throw new op(`Cannot join `+t.type.name+` onto `+e.type.name)}function fp(e,t,n){let r=e.node(n);return dp(r,t.node(n)),r}function pp(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function mp(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(pp(e.nodeAfter,r),a++));for(let e=a;e<o;e++)pp(i.child(e),r);t&&t.depth==n&&t.textOffset&&pp(t.nodeBefore,r)}function hp(e,t){return e.type.checkContent(t),e.copy(t)}function gp(e,t,n,r,i){let a=e.depth>i&&fp(e,t,i+1),o=r.depth>i&&fp(n,r,i+1),s=[];return mp(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(dp(a,o),pp(hp(a,gp(e,t,n,r,i+1)),s)):(a&&pp(hp(a,_p(e,t,i+1)),s),mp(t,n,i,s),o&&pp(hp(o,_p(n,r,i+1)),s)),mp(r,null,i,s),new U(s)}function _p(e,t,n){let r=[];return mp(null,e,n,r),e.depth>n&&pp(hp(fp(e,t,n+1),_p(e,t,n+1)),r),mp(t,null,n,r),new U(r)}function vp(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(U.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var yp=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ap.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Cp(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Sp.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Sp.set(t,r=new bp);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%xp,i}},bp=class{constructor(){this.elts=[],this.i=0}},xp=12,Sp=new WeakMap,Cp=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},wp=Object.create(null),Tp=class e{constructor(e,t,n,r=ap.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||U.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&ip(this.attrs,t||e.defaultAttrs||wp)&&ap.sameSet(this.marks,n||ap.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return W.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new W(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return lp(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return yp.resolveCached(this,e)}resolveNoCache(e){return yp.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Dp(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=U.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ap.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!ap.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=U.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Tp.prototype.text=void 0;var Ep=class e extends Tp{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Dp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Dp(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Op=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new kp(t,n);if(r.next==null)return e.empty;let i=Ap(r);r.next&&r.err(`Unexpected trailing text`);let a=Bp(Lp(i));return Vp(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return U.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
177
|
+
`)}case`WRITE_ERROR`:return`Failed to write config file: ${e.detail}`;case`OKIGNORE_INVALID`:return e.lineNumber===void 0?`.okignore: ${e.detail}`:`.okignore line ${e.lineNumber}: ${e.detail}`;case`UNKNOWN`:return e.message??`Unknown error.`}}var Xf="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.";[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,Xf].join(` `),[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,Xf].join(` `),[`folders is no longer a top-level config field.`,"A folder's own frontmatter (open-shape, like a doc's) lives in nested `<folder>/.ok/frontmatter.yml`; new-doc starting properties come from templates in `<folder>/.ok/templates/`.","Edit via the folder overview in the editor sidebar, or `edit({ folder: { path, frontmatter } })` via the MCP.",Xf].join(` `),[`appearance.editorModeDefault was removed and is never read — new docs always open in WYSIWYG; toggle mode via the editor mode button.`,Xf].join(` `),[`streaming uploads have no user-facing cap; the value is hardcoded in @inkeep/open-knowledge-core.`,Xf].join(` `),[`Use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID environment variable instead.`,Xf].join(` `),[`Use the --host CLI flag or the HOST environment variable instead.`,Xf].join(` `),[`This behavior was removed; the value is hardcoded.`,Xf].join(` `),[`To disable MCP auto-start, set OK_MCP_AUTOSTART=0.`,Xf].join(` `),[`This value is hardcoded in @inkeep/open-knowledge-core.`,Xf].join(` `),[`This value is hardcoded in @inkeep/open-knowledge-core.`,Xf].join(` `),[`The search result cap is hardcoded in @inkeep/open-knowledge-core; this config key was removed.`,Xf].join(` `),["preview URLs now resolve only to the running UI process — start one with `ok ui`.",Xf].join(` `),[`preview.scriptSrc has been removed.`,`The code-block preview iframe now runs a fixed open network policy (it is no longer configurable).`,Xf].join(` `),[`appearance.sidebar.showAllFiles has been removed.`,`The sidebar lists every file on disk by default; dot-prefixed entries are gated by appearance.sidebar.showHiddenFiles, and appearance.sidebar.showOnlyMarkdownFiles scopes the tree down to markdown documents as a per-machine view preference.`,Xf].join(` `);var Zf={"bridge-merge-loss":{visibility:`surfaced`,gcBucket:`bridge-merge-loss`,bundleExposure:`subject-only`,chainAnchor:!1},"producer-guard-loss":{visibility:`surfaced`,gcBucket:`producer-guard-loss`,bundleExposure:`metadata`,chainAnchor:!1},"observer-a-duplication":{visibility:`surfaced`,gcBucket:`observer-a-duplication`,bundleExposure:`metadata`,chainAnchor:!1},"external-change-rescue":{visibility:`surfaced`,gcBucket:`external-change-rescue`,bundleExposure:`metadata`,chainAnchor:!1},"defer-exhaustion-loss":{visibility:`surfaced`,gcBucket:`defer-exhaustion-loss`,bundleExposure:`metadata`,chainAnchor:!1},"observer-a-apply-loss":{visibility:`surfaced`,gcBucket:`observer-a-apply-loss`,bundleExposure:`subject-only`,chainAnchor:!1},"bridge-derive-loss":{visibility:`surfaced`,gcBucket:`bridge-derive-loss`,bundleExposure:`subject-only`,chainAnchor:!1},"bridge-backstop-trip":{visibility:`surfaced`,gcBucket:`bridge-backstop-trip`,bundleExposure:`metadata`,chainAnchor:!1},"persistence-reconcile-loss":{visibility:`surfaced`,gcBucket:`persistence-reconcile-loss`,bundleExposure:`metadata`,chainAnchor:!1},"persistence-duplication-reset":{visibility:`surfaced`,gcBucket:`persistence-duplication-reset`,bundleExposure:`metadata`,chainAnchor:!1},"auto-consolidation":{visibility:`hidden`,gcBucket:`auto-consolidation`,bundleExposure:`none`,chainAnchor:!0}};function Qf(e){return e==null?!0:Zf[e].visibility===`surfaced`}function $f(e){this.content=e}$f.prototype={constructor:$f,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new $f(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new $f(n)},addToStart:function(e,t){return new $f([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new $f(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new $f(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=$f.from(e),e.size?new $f(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=$f.from(e),e.size?new $f(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=$f.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},$f.from=function(e){if(e instanceof $f)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new $f(t)};function ep(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=ep(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function tp(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=tp(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var U=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return ep(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return tp(this,e,t,n)}findIndex(e){if(e==0)return rp(0,e);if(e==this.size)return rp(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?rp(t+1,i):rp(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};U.empty=new U([],0);var np={index:0,offset:0};function rp(e,t){return np.index=e,np.offset=t,np}function ip(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!ip(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!ip(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var ap=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ip(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};ap.none=[];var op=class extends Error{},W=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=cp(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(sp(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(U.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};W.empty=new W(U.empty,0,0);function sp(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(sp(a.content,t-i-1,n-i-1)))}function cp(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=cp(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function lp(e,t,n){if(n.openStart>e.depth)throw new op(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new op(`Inconsistent open depths`);return up(e,t,n,0)}function up(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=up(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return hp(a,_p(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return hp(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=vp(n,e);return hp(a,gp(e,i,o,t,r))}}function dp(e,t){if(!t.type.compatibleContent(e.type))throw new op(`Cannot join `+t.type.name+` onto `+e.type.name)}function fp(e,t,n){let r=e.node(n);return dp(r,t.node(n)),r}function pp(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function mp(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(pp(e.nodeAfter,r),a++));for(let e=a;e<o;e++)pp(i.child(e),r);t&&t.depth==n&&t.textOffset&&pp(t.nodeBefore,r)}function hp(e,t){return e.type.checkContent(t),e.copy(t)}function gp(e,t,n,r,i){let a=e.depth>i&&fp(e,t,i+1),o=r.depth>i&&fp(n,r,i+1),s=[];return mp(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(dp(a,o),pp(hp(a,gp(e,t,n,r,i+1)),s)):(a&&pp(hp(a,_p(e,t,i+1)),s),mp(t,n,i,s),o&&pp(hp(o,_p(n,r,i+1)),s)),mp(r,null,i,s),new U(s)}function _p(e,t,n){let r=[];return mp(null,e,n,r),e.depth>n&&pp(hp(fp(e,t,n+1),_p(e,t,n+1)),r),mp(t,null,n,r),new U(r)}function vp(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(U.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var yp=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ap.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Cp(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Sp.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Sp.set(t,r=new bp);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%xp,i}},bp=class{constructor(){this.elts=[],this.i=0}},xp=12,Sp=new WeakMap,Cp=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},wp=Object.create(null),Tp=class e{constructor(e,t,n,r=ap.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||U.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&ip(this.attrs,t||e.defaultAttrs||wp)&&ap.sameSet(this.marks,n||ap.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return W.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new W(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return lp(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return yp.resolveCached(this,e)}resolveNoCache(e){return yp.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Dp(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=U.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ap.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!ap.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=U.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Tp.prototype.text=void 0;var Ep=class e extends Tp{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Dp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Dp(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Op=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new kp(t,n);if(r.next==null)return e.empty;let i=Ap(r);r.next&&r.err(`Unexpected trailing text`);let a=Bp(Lp(i));return Vp(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return U.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
178
178
|
`)}};Op.empty=new Op(!0);var kp=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Ap(e){let t=[];do t.push(jp(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function jp(e){let t=[];do t.push(Mp(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Mp(e){let t=Ip(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Pp(e,t);else break;return t}function Np(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Pp(e,t){let n=Np(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Np(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Fp(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Ip(e){if(e.eat(`(`)){let t=Ap(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Fp(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Lp(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Rp(e,t){return t-e}function zp(e,t){let n=[];return r(t),n.sort(Rp);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function Bp(e){let t=Object.create(null);return n(zp(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);zp(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Op(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Rp);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Vp(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Hp(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Up(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function Wp(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Gp(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Jp(e,r,t[r]);return n}var Kp=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Gp(e,n.attrs),this.defaultAttrs=Hp(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Op.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Up(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Tp(this,this.computeAttrs(e),U.from(t),ap.setFrom(n))}createChecked(e=null,t,n){return t=U.from(t),this.checkContent(t),new Tp(this,this.computeAttrs(e),t,ap.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=U.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(U.empty,!0);return i?new Tp(this,e,t.append(i),ap.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Wp(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:ap.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function qp(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Jp=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?qp(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Yp=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Gp(e,r.attrs),this.excluded=null;let i=Hp(this.attrs);this.instance=i?new ap(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ap(this,Up(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Wp(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Xp=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=$f.from(e.nodes),t.marks=$f.from(e.marks||{}),this.nodes=Kp.compile(this.spec.nodes,this),this.marks=Yp.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Op.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Zp(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Zp(this,n.split(` `))}this.nodeFromJSON=e=>Tp.fromJSON(this,e),this.markFromJSON=e=>ap.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Kp))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new Ep(n,n.defaultAttrs,e,ap.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function Zp(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Qp(e){return e.tag!=null}function $p(e){return e.style!=null}var em=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Qp(e))this.tags.push(e);else if($p(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new lm(this,t,!1);return n.addAll(e,ap.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new lm(this,t,!0);return n.addAll(e,ap.none,t.from,t.to),W.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(dm(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=fm(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=fm(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},tm={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},nm={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},rm={ol:!0,ul:!0},im=1,am=2,om=4;function sm(e,t,n){return t==null?e&&e.whitespace==`pre`?im|am:n&~om:(t?im:0)|(t===`full`?am:0)}var cm=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=ap.none,this.match=i||(a&om?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(U.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&im)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=U.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(U.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!tm.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},lm=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=sm(null,t.preserveWhitespace,0)|(n?om:0);i=r?new cm(r.type,r.attrs,ap.none,!0,t.topMatch||r.type.contentMatch,a):n?new cm(null,null,ap.none,!0,null,a):new cm(e.schema.topNodeType,null,ap.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&am?`full`:this.localPreserveWS||(r.options&im)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
179
179
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;rm.hasOwnProperty(a)&&this.parser.normalizeLists&&um(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:nm.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(tm.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
180
180
|
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=ap.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):pm(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=sm(e,i,a.options);a.options&om&&a.content.length==0&&(o|=om);let s=ap.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):pm(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new cm(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=im);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function um(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&rm.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function dm(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function fm(e){let t={};for(let n in e)t[n]=e[n];return t}function pm(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var mm=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=gm(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=bm(gm(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&bm(gm(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return bm(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=hm(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return hm(e.marks)}};function hm(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function gm(e){return e.document||window.document}var _m=new WeakMap;function vm(e){let t=_m.get(e);return t===void 0&&_m.set(e,t=ym(e)),t}function ym(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function bm(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=vm(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=bm(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var xm=65535,Sm=2**16;function Cm(e,t){return e+t*Sm}function wm(e){return e&xm}function Tm(e){return(e-(e&xm))/Sm}var Em=1,Dm=2,Om=4,km=8,Am=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&km)>0}get deletedBefore(){return(this.delInfo&(Em|Om))>0}get deletedAfter(){return(this.delInfo&(Dm|Om))>0}get deletedAcross(){return(this.delInfo&Om)>0}},jm=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=wm(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Tm(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Cm(o/3,e-s),f=e==s?Dm:e==u?Em:Om;return(t<0?e!=s:e!=u)&&(f|=km),new Am(a,f,d)}r+=l-c}return n?e+r:new Am(e+r,0,null)}touches(e,t){let n=0,r=wm(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};jm.empty=new jm([]);var Mm=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Am(e,r,null)}},Nm=Object.create(null),Pm=class{getMap(){return jm.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Nm[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Nm)throw RangeError(`Duplicate use of step JSON ID `+e);return Nm[e]=t,t.prototype.jsonID=e,t}},Fm=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof op)return e.fail(t.message);throw t}}};function Im(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Im(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return U.fromArray(r)}var Lm=class e extends Pm{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new W(Im(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return Fm.fromReplace(e,this.from,this.to,i)}invert(){return new Rm(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Pm.jsonID(`addMark`,Lm);var Rm=class e extends Pm{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new W(Im(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Fm.fromReplace(e,this.from,this.to,n)}invert(){return new Lm(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Pm.jsonID(`removeMark`,Rm);var zm=class e extends Pm{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Fm.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Fm.fromReplace(e,this.pos,this.pos+1,new W(U.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Bm(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Pm.jsonID(`addNodeMark`,zm);var Bm=class e extends Pm{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Fm.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Fm.fromReplace(e,this.pos,this.pos+1,new W(U.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new zm(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Pm.jsonID(`removeNodeMark`,Bm);var Vm=class e extends Pm{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Um(e,this.from,this.to)?Fm.fail(`Structure replace would overwrite content`):Fm.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new jm([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?W.empty:new W(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?W.empty:new W(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,W.fromJSON(t,n.slice),!!n.structure)}};Vm.MAP_BIAS=1,Pm.jsonID(`replace`,Vm);var Hm=class e extends Pm{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Um(e,this.from,this.gapFrom)||Um(e,this.gapTo,this.to)))return Fm.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Fm.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Fm.fromReplace(e,this.from,this.to,n):Fm.fail(`Content does not fit in gap`)}getMap(){return new jm([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,W.fromJSON(t,n.slice),n.insert,!!n.structure)}};Pm.jsonID(`replaceAround`,Hm);function Um(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Wm(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Rm(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Lm(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Gm(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Yp){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Rm(t.from,t.to,t.style)))}function Km(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Vm(s,l,W.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Rm(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new W(U.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Vm(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(U.empty,!0);e.replace(s,s,new W(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function qm(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Jm(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!qm(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Ym(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=U.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=U.from(r.node(e).copy(u)),d++):c--;let f=U.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=U.from(i.node(e).copy(f)),p++):l++;e.step(new Hm(c,l,o,s,new W(u.append(f),d,p),u.size-d,!0))}function Xm(e,t,n=null,r=e){let i=Qm(e,t),a=i&&$m(r,t);return a?i.map(Zm).concat({type:t,attrs:n}).concat(a.map(Zm)):null}function Zm(e){return{type:e,attrs:null}}function Qm(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function $m(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function eh(e,t,n){let r=U.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=U.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Hm(i,a,i,a,new W(r,0,0),n.length,!0))}function th(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&ih(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&rh(e,t,n,a),Km(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Hm(c,l,c+1,l-1,new W(U.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&nh(e,t,n,a),!1}})}function nh(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function rh(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{it as e}from"./dist-
|
|
1
|
+
import{it as e}from"./dist-DmmOGEYy.js";var t=/\.(md|mdx)$/i;function n(e){return e.trim().replace(/^\.\/+/,``).replace(/^\/+/,``)}function r(e){return n(e).replace(t,``)}function i(e){let r=n(e);return r?t.test(r)?r:`${r}.md`:`untitled.md`}function a(e){let t=r(e),n=t.lastIndexOf(`/`);return{initialDir:n>0?t.slice(0,n):``,suggestedName:`${n>=0?t.slice(n+1):t||`untitled`}.md`}}function o(t){return e.includes(t)}function s(e){if(e.startsWith(b)||e.startsWith(w)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=x(t),r=n>=0?t.slice(0,n):t;if(!r)return null;try{return r.split(`/`).map(decodeURIComponent).join(`/`)}catch{return r}}function c(e){if(e.startsWith(b)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=t.indexOf(`#`);if(n<0)return null;let r=t.slice(n+1);if(!r)return null;try{return decodeURIComponent(r)}catch{return r}}function l(e,t){let n=`#/${e}`;return t?`${n}#${encodeURIComponent(t)}`:n}var u=`__okHashHistoryEntry`;function d(e){return{...typeof e==`object`&&e?e:{},[u]:!0}}function f(e){return typeof e==`object`&&!!e&&e[u]===!0}function p(){f(window.history.state)||window.history.replaceState(d(window.history.state),``)}function m(e){let{pathname:t,search:n}=window.location;window.history.replaceState(d(window.history.state),``,`${t}${n}${e}`)}function h(e){if(window.location.hash===e)return;let{pathname:t,search:n}=window.location;window.history.pushState(d(window.history.state),``,`${t}${n}${e}`)}function g(e){return e.endsWith(`.mdx`)?e.slice(0,-4):e.endsWith(`.md`)?e.slice(0,-3):e}function _(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?`#/${n}/`:`#/`;return t?`${r}#${encodeURIComponent(t)}`:r}function v(e,t,n){if(e===`folder`)return _(t);let r=`#/${encodeURIComponent(t)}`;return n==null||n===``?r:`${r}?branch=${encodeURIComponent(n)}`}function y(e){if(e===`#/`)return!0;if(!e.startsWith(`#/`))return!1;let t=e.slice(2);return t.length>0&&t[0]===`?`}var b=`#/__asset__/`;function x(e){let t=e.indexOf(`?`),n=e.indexOf(`#`);return t<0?n:n<0?t:Math.min(t,n)}function S(e){if(!e.startsWith(b))return null;let t=e.slice(12);if(!t)return null;try{return t.split(`/`).map(decodeURIComponent).join(`/`)}catch{return t}}function C(e){return`${b}${e.split(`/`).map(encodeURIComponent).join(`/`)}`}var w=`#/__skill-file__/`;function T(e){return`${w}${[e.scope,e.name].map(encodeURIComponent).join(`/`)}/${e.path.split(`/`).map(encodeURIComponent).join(`/`)}`}function E(e){if(!e.startsWith(w))return null;let t=e.slice(17);if(!t)return null;let n;try{n=t.split(`/`).map(decodeURIComponent)}catch{return null}if(n.length<3)return null;let[r,i,...a]=n,s=a.join(`/`);return!r||!i||!s||!o(r)?null:{scope:r,name:i,path:s}}export{i as _,g as a,_ as c,f as d,p as f,a as g,E as h,v as i,T as l,m,S as n,C as o,h as p,s as r,l as s,c as t,y as u,r as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./dist-
|
|
1
|
+
import{j as e}from"./dist-DmmOGEYy.js";var t=`open-knowledge:documents-changed`,n=new Set(e.options);function r(e){return e===void 0||!Array.isArray(e)?[`files`]:[...new Set(e.filter(e=>n.has(e)))]}function i(e=[`files`]){window.dispatchEvent(new CustomEvent(t,{detail:{channels:r(e)}}))}function a(e){let n=t=>{e(r(t instanceof CustomEvent?t.detail?.channels:void 0))};return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}var o=`open-knowledge:doc-persisted`;function s(e){window.dispatchEvent(new CustomEvent(o,{detail:{docName:e}}))}function c(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail?.docName;typeof n==`string`&&n.length>0&&e(n)};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)}var l=`open-knowledge:branch-changed`;function u(e){window.dispatchEvent(new CustomEvent(l,{detail:{branch:e}}))}function d(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail;e(n?.branch??null)};return window.addEventListener(l,t),()=>window.removeEventListener(l,t)}var f=`open-knowledge:templates-changed`;function p(){window.dispatchEvent(new CustomEvent(f))}function m(e){let t=()=>e();return window.addEventListener(f,t),()=>window.removeEventListener(f,t)}var h=`open-knowledge:skills-changed`;function g(){window.dispatchEvent(new CustomEvent(h))}function _(e){let t=()=>e();return window.addEventListener(h,t),()=>window.removeEventListener(h,t)}export{p as a,a as c,g as i,_ as l,s as n,d as o,i as r,c as s,u as t,m as u};
|