@inkeep/open-knowledge 0.58.0-beta.7 → 0.58.0-beta.8
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-Dc4QtyQO.mjs → acp-harness-probe-dZsvbgrC.mjs} +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/config-schema.json +1 -1
- package/dist/config.project.schema.json +1 -1
- package/dist/constants-CzhGjsFo.mjs +2 -0
- package/dist/fs-traced-corg4Obj.mjs +1 -0
- package/dist/{fs-traced-xJfl5Rxd.mjs → fs-traced-oq2wG9J_.mjs} +2 -2
- package/dist/{git-handle-3stJTucC.mjs → git-handle-2o4Vxedu.mjs} +2 -2
- package/dist/git-handle-DEjt_7O0.mjs +1 -0
- package/dist/index.mjs +2 -2
- package/dist/init-Ct7mqKVm.mjs +1 -0
- package/dist/{init-CpcterGz.mjs → init-DasMrTCg.mjs} +3 -3
- package/dist/{launch-json-removal-Ci74hesJ.mjs → launch-json-removal-BCc3Wt5o.mjs} +2 -2
- package/dist/loader-C6UUw0ZZ.mjs +1 -0
- package/dist/{loader-D0BmknIi.mjs → loader-CFnKYZR2.mjs} +2 -2
- package/dist/md-manager-FXuCv5zc.mjs +2 -0
- package/dist/{open-browser-Cqyn_9Z_.mjs → open-browser-CMs-r6aL.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-D9SZkYr5.mjs +1 -0
- package/dist/{preview-BrV2S7Xj.mjs → preview-Dv9l315C.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-B0Fp59Qv.js → ActivityModeContent-DB3zhNIv.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-BbIuRvv1.js → AgentDiffPane-BuZT0CFj.js} +1 -1
- package/dist/public/assets/{AgentIconCluster-B26uigRz.js → AgentIconCluster-D_inolLQ.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-M_2EBFIT.js → AgentThreadClientBinder-Db3J-HNk.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-BIdbAIO5.js → CodeMirrorPropInput-B3PfIk_d.js} +1 -1
- package/dist/public/assets/{DocumentContext-DC_8e-cY.js → DocumentContext-BNs9Wc7G.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-CAig-JLx.js → EditorModeToggle-SBfl-yYh.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-CfR-i3bq.js → EnableSyncConfirmDialog-BoBmQwEy.js} +1 -1
- package/dist/public/assets/FeedbackForm-Bwghznhy.js +1 -0
- package/dist/public/assets/{GraphPanel-DejDnC1E.js → GraphPanel-CEcqZRWw.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-CsbbMAso.js → ImportSkillDialog-C7EVNmz7.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-CMwVctJo.js → LintConfigEditor-Bcr2QKP1.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-B3ZJ9FFR.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-BW4zT-vN.js → ManagedArtifactProperties-CZwQTU72.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-GUHma1LV.js → McpConsentDialogBody-CRg_BChy.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-DmX2UpSP.js → MermaidDocEditor-Co4QYa48.js} +1 -1
- package/dist/public/assets/{OpenInAgentMenuItem-8Fp3GsHg.js → OpenInAgentMenuItem-C_aRPIjj.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-WuuztauZ.js → PropertyDisplayRow-CrYGlgp7.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-Ci98J5Bw.js → ReportBugDialogBody-CN1i_Y7g.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-DuCTZiY-.js → SchemaConfigEditor-CntIIKsB.js} +1 -1
- package/dist/public/assets/{SessionsHost-BTd7O7Aa.js → SessionsHost-CdJc0MSK.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-CkI0KfUL.js → SettingsDialogBody-8GHLppL4.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-CpToxQMt.js → ShareBranchSwitchDialog-K6rF_BB-.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-LOwGCI-g.js → ShareReceiveDialog-D2tJPvcw.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-CiPRwQlY.js → ShareReceiveMissDialog-PifhU4tt.js} +1 -1
- package/dist/public/assets/{SkillCostValue-D_6C2Gog.js → SkillCostValue-C0tQ5Ey6.js} +1 -1
- package/dist/public/assets/{SkillDestinationList-DpCf7aFO.js → SkillDestinationList-DYjzv8JN.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-COUIEuU_.js → SkillEditBanner-DUbh82i0.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-y2A7W0zZ.js → SkillInstallMenu-aKaOX_rG.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-Dy9lf16Q.js → SkillOriginInline-Dcw5U9Gu.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-BsmREi0B.js → SkillToolbarControls-CZNGVa1t.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-DNkQ5Ng_.js → SlidesToolbarControls-Cf1lF5oY.js} +1 -1
- package/dist/public/assets/{SourceEditor-CVACSHpy.js → SourceEditor-DrIQgn17.js} +1 -1
- package/dist/public/assets/{TerminalPanel-BW1Psxow.js → TerminalPanel-C61cGKq0.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-DX6H7O5q.js → TerminalWindowApp-Zyc8LXKG.js} +1 -1
- package/dist/public/assets/{TextDocEditor-ywHStFmo.js → TextDocEditor-Dhfis_S6.js} +1 -1
- package/dist/public/assets/{ThreadView-CoW0wzMZ.js → ThreadView-BZYcGOYJ.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-3beAKThM.js → TimelineDiffPane-BBmd35R9.js} +1 -1
- package/dist/public/assets/{auth-state-cache-BBp_stem.js → auth-state-cache-CWPxRafc.js} +1 -1
- package/dist/public/assets/{client-version-DvabycW5.js → client-version-BsMRrwFS.js} +1 -1
- package/dist/public/assets/{comment-chips-Bfc8H6sv.js → comment-chips-DdMmWihZ.js} +1 -1
- package/dist/public/assets/{config-provider-Wm9R6Y25.js → config-provider-DkOV03RH.js} +1 -1
- package/dist/public/assets/{dist-Dih2A8fV.js → dist-CP7w45uR.js} +1 -1
- package/dist/public/assets/{doc-paths-DqJ_A_s7.js → doc-paths-CX0c2GkE.js} +1 -1
- package/dist/public/assets/{documents-events-Ck8o2CoI.js → documents-events-DGovPb4Q.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-BiHRDCv3.js → file-tree-adapter-CNrTrjb9.js} +1 -1
- package/dist/public/assets/{file-tree-utils-CEFaTYgx.js → file-tree-utils-Ceep4GK6.js} +1 -1
- package/dist/public/assets/{folder-config-api-CRLsP3aa.js → folder-config-api-BavUQIxi.js} +1 -1
- package/dist/public/assets/{follow-file-BpuglSLQ.js → follow-file-BDoShwy7.js} +1 -1
- package/dist/public/assets/i18n-fvzGnIHb.js +1 -0
- package/dist/public/assets/{index-B1a_Nq9z.js → index-Br-j853R.js} +7 -7
- package/dist/public/assets/{lint-config-client-Bpxmt15J.js → lint-config-client-BXCLXBm0.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-B9wBZNA_.js → markdownlint-rule-browser-CjQ1_sCE.js} +1 -1
- package/dist/public/assets/{navigation-targets-Qu3klKbE.js → navigation-targets-B9ZSMArq.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-KzE_hPhn.js → open-managed-artifact-tab-FyNAk92K.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-BaSwjYK0.js → pending-receive-nav-store-DR3ooVas.js} +1 -1
- package/dist/public/assets/{prop-types-C0jlhgSv.js → prop-types-BWoV6rdx.js} +1 -1
- package/dist/public/assets/{receive-store-CcixohWp.js → receive-store-sP45Lmaj.js} +1 -1
- package/dist/public/assets/{selection-context-DaLbLtKV.js → selection-context-jZhBCQUz.js} +1 -1
- package/dist/public/assets/{skill-actions-BG-1EQmx.js → skill-actions-BAWcLPFa.js} +1 -1
- package/dist/public/assets/{skill-scope-BmcRzXKj.js → skill-scope-C3ZLyDFU.js} +1 -1
- package/dist/public/assets/{skills-api-DYLAW1HV.js → skills-api-DkJBCb26.js} +1 -1
- package/dist/public/assets/{src-_CcgHCm_.js → src-DXY6B71v.js} +1 -1
- package/dist/public/assets/{tag-pill-input-BjL8aMcQ.js → tag-pill-input-obzr2Bmc.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-1FaM1MO8.js → target-navigation-intent-IjRnfQQ9.js} +1 -1
- package/dist/public/assets/{terminal-cli-display-CyCGNg1t.js → terminal-cli-display-fzswbBoR.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-B92DmpSo.js → terminal-launch-events-BZw6Kevo.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-CPOwGHJS.js → terminal-telemetry-BTfW00Ir.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BySvqCzC.js → typing-burst-detector-adEL1lyg.js} +1 -1
- package/dist/public/assets/{uninstall-DgUSAKgm.js → uninstall-DJb5IlCU.js} +1 -1
- package/dist/public/assets/{use-activity-panel-o4JQhNM3.js → use-activity-panel-bJnzXq1_.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-DonBpBNY.js → use-apply-config-color-theme-hdarUMLl.js} +1 -1
- package/dist/public/assets/{use-collab-url-D_1xfAyN.js → use-collab-url-BSs7OT15.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-Bq43Ad6a.js → use-live-xterm-theme-BQNkHYLe.js} +1 -1
- package/dist/public/assets/{use-open-skill-CR8e9H_i.js → use-open-skill-B2CpqHwW.js} +1 -1
- package/dist/public/assets/{use-popular-skills-BySTLo8O.js → use-popular-skills-DSYrjkIc.js} +1 -1
- package/dist/public/assets/{use-settings-route-QaV_yXgj.js → use-settings-route-CAQ6W9p6.js} +1 -1
- package/dist/public/assets/{use-skill-origin-BwJcy3-O.js → use-skill-origin-DbGsYAIW.js} +1 -1
- package/dist/public/assets/{use-skills-2obCzXwU.js → use-skills-BrC3Upu3.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-CfeUtq4N.js → use-terminal-enabled-B-_ScHv6.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-W_B-6UDh.js → use-timeline-entry-diff-EyIHz_x3.js} +1 -1
- package/dist/public/assets/{use-workspace-D9PQP2Ka.js → use-workspace-CFSG46RY.js} +1 -1
- package/dist/public/index.html +47 -47
- package/dist/public/uninstall.html +3 -3
- package/dist/{repair-launch-json-PUVNVFKs.mjs → repair-launch-json-BU_wTHU6.mjs} +2 -2
- package/dist/{repair-mcp-configs-BOQLD8vy.mjs → repair-mcp-configs-DLGnB9SW.mjs} +2 -2
- package/dist/repair-skills-6kXbAVAI.mjs +1 -0
- package/dist/{repair-skills-D2MDLtIb.mjs → repair-skills-B2XZB3Rs.mjs} +2 -2
- package/dist/schemas/v0/config.project.schema.json +1 -1
- package/dist/{server-lock-DyY8nPTr.mjs → server-lock-CucURT_N.mjs} +2 -2
- package/dist/server-lock-Tb9AMsy7.mjs +1 -0
- package/dist/{skill-teardown-u_V1IN7V.mjs → skill-teardown-C2iNSWvT.mjs} +2 -2
- package/dist/{sleep-D_nNc7T_.mjs → sleep-BU8QtSQy.mjs} +2 -2
- package/dist/src-Bf5oIrhA.mjs +1 -0
- package/dist/{src-ubDzLrbn.mjs → src-BjPajWAS.mjs} +2 -2
- package/dist/{src-oJpaRu7w.mjs → src-C1pxKPYT.mjs} +2 -2
- package/dist/{src-D88J_dwf.mjs → src-CXbUZB_b.mjs} +1 -1
- package/dist/{src-CyDF8_Em.mjs → src-pjKDNsjY.mjs} +435 -435
- package/dist/start-C62GgsB9.mjs +1 -0
- package/dist/{start-Dcjq6fwo.mjs → start-rya2hbae.mjs} +4 -4
- package/dist/{ui-CTuTY_Ny.mjs → ui-UQBOE6mj.mjs} +3 -3
- package/dist/{write-project-skill-CqrttBia.mjs → write-project-skill-7xCQZ9iq.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-c1VuifcA.mjs +0 -2
- package/dist/fs-traced-BEuPZxxL.mjs +0 -1
- package/dist/git-handle-B0ZVs8y7.mjs +0 -1
- package/dist/init-DV09g6ez.mjs +0 -1
- package/dist/loader-Cl4ixwGJ.mjs +0 -1
- package/dist/md-manager-Dz3nKJbO.mjs +0 -2
- package/dist/preview-CbWq8-zC.mjs +0 -1
- package/dist/public/assets/FeedbackForm-CxomQJwt.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-Bph9HlOT.js +0 -1
- package/dist/public/assets/i18n-BbGgvVoN.js +0 -1
- package/dist/repair-skills-BUtcN0G7.mjs +0 -1
- package/dist/server-lock-Bii6_-R-.mjs +0 -1
- package/dist/src-CClot_u_.mjs +0 -1
- package/dist/start-C0IEJ4Mw.mjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./messages-ChE4ifHJ.js","./chunk-CYidjpOJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./preload-helper-Chd9yIcd.js";import{t as n}from"./jsx-runtime-BUgB2tll.js";import{t as r}from"./react-f2sANaYj.js";import{n as i}from"./dist-PQ5KMVDh.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{Fs as o,Ft as s,It as c,Lt as l,Ms as u,Nt as d,Pt as f,Rt as p,St as m,Ti as h,Wo as ee,ao as te,as as ne,cs as g,gn as re,io as ie,is as ae,ks as oe,mn as se,ni as _,no as ce,oi as le,ro as ue,xi as de,zt as fe}from"./dist-Dih2A8fV.js";import{n as pe}from"./dist-CMZSEMCN2.js";import{t as me}from"./dist-CdT2fVlj.js";import{a as he,c as ge,m as _e,p as ve,r as ye}from"./use-apply-config-color-theme-DonBpBNY.js";import"./i18n-BbGgvVoN.js";import{r as be}from"./client-version-DvabycW5.js";var xe=a(),v=e(r(),1),Se=null,Ce=new Set;function we(){return Se}function Te(e){let t=e!==null&&e.length>0?e:null;if(t!==Se){Se=t;for(let e of Ce)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function Ee(e){return Ce.add(e),()=>{Ce.delete(e)}}function De(){return(0,v.useSyncExternalStore)(Ee,we,we)}var y=()=>new Map,Oe=e=>{let t=y();return e.forEach((e,n)=>{t.set(n,e)}),t},b=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ke=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Ae=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},x=()=>new Set,je=e=>e[e.length-1],Me=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},S=Array.from,Ne=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Pe=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Fe=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Ie=Array.isArray,Le=class{constructor(){this._observers=y()}on(e,t){return b(this._observers,e,x).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 S((this._observers.get(e)||y()).values()).forEach(e=>e(...t))}destroy(){this._observers=y()}},Re=class{constructor(){this._observers=y()}on(e,t){b(this._observers,e,x).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 S((this._observers.get(e)||y()).values()).forEach(e=>e(...t))}destroy(){this._observers=y()}},C=Math.floor,ze=Math.abs,Be=(e,t)=>e<t?e:t,w=(e,t)=>e>t?e:t;Number.isNaN;var Ve=e=>e===0?1/e<0:e<0,He=1<<17,Ue=1<<18,We=1<<19,Ge=1<<20,Ke=1<<21,qe=1<<22,Je=1<<23,Ye=1<<24,Xe=1<<25,Ze=1<<26,Qe=1<<27,$e=1<<28,et=1<<29;He-1,Ue-1,We-1,Ge-1,Ke-1,qe-1,Je-1,Ye-1,Xe-1,Ze-1,Qe-1,$e-1,et-1;var tt=2**53-1,nt=-(2**53-1),rt=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&C(e)===e);Number.isNaN,Number.parseInt;var it=String.fromCharCode;String.fromCodePoint,it(65535);var at=e=>e.toLowerCase(),ot=/^\s*/g,st=e=>e.replace(ot,``),ct=/([A-Z])/g,lt=(e,t)=>st(e.replace(ct,e=>`${t}${at(e)}`)),ut=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},dt=typeof TextEncoder<`u`?new TextEncoder:null,ft=dt?e=>dt.encode(e):ut,pt=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});pt&&pt.decode(new Uint8Array).length===1&&(pt=null);var mt=(e,t)=>Fe(t,()=>e).join(``),ht=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},gt=()=>new ht,_t=e=>{let t=gt();return e(t),T(t)},vt=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},T=e=>{let t=new Uint8Array(vt(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},yt=(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(w(n,t)*2),e.cpos=0)},E=(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},bt=E,D=(e,t)=>{for(;t>127;)E(e,128|127&t),t=C(t/128);E(e,127&t)},xt=(e,t)=>{let n=Ve(t);for(n&&(t=-t),E(e,(t>63?128:0)|(n?64:0)|63&t),t=C(t/64);t>0;)E(e,(t>127?128:0)|127&t),t=C(t/128)},St=new Uint8Array(3e4),Ct=St.length/3,wt=dt&&dt.encodeInto?(e,t)=>{if(t.length<Ct){let n=dt.encodeInto(t,St).written||0;D(e,n);for(let t=0;t<n;t++)E(e,St[t])}else O(e,ft(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;D(e,r);for(let t=0;t<r;t++)E(e,n.codePointAt(t))},Tt=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Be(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(w(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},O=(e,t)=>{D(e,t.byteLength),Tt(e,t)},Et=(e,t)=>{yt(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Dt=(e,t)=>Et(e,4).setFloat32(0,t,!1),Ot=(e,t)=>Et(e,8).setFloat64(0,t,!1),kt=(e,t)=>Et(e,8).setBigInt64(0,t,!1),At=new DataView(new ArrayBuffer(4)),jt=e=>(At.setFloat32(0,e),At.getFloat32(0)===e),Mt=(e,t)=>{switch(typeof t){case`string`:E(e,119),wt(e,t);break;case`number`:rt(t)&&ze(t)<=2147483647?(E(e,125),xt(e,t)):jt(t)?(E(e,124),Dt(e,t)):(E(e,123),Ot(e,t));break;case`bigint`:E(e,122),kt(e,t);break;case`object`:if(t===null)E(e,126);else if(Ie(t)){E(e,117),D(e,t.length);for(let n=0;n<t.length;n++)Mt(e,t[n])}else if(t instanceof Uint8Array)E(e,116),O(e,t);else{E(e,118);let n=Object.keys(t);D(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];wt(e,i),Mt(e,t[i])}}break;case`boolean`:E(e,t?120:121);break;default:E(e,127)}},Nt=class extends ht{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&D(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Pt=e=>{e.count>0&&(xt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&D(e.encoder,e.count-2))},Ft=class{constructor(){this.encoder=new ht,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Pt(this),this.count=1,this.s=e)}toUint8Array(){return Pt(this),T(this.encoder)}},It=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);xt(e.encoder,t),e.count>1&&D(e.encoder,e.count-2)}},Lt=class{constructor(){this.encoder=new ht,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(It(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return It(this),T(this.encoder)}},Rt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Ft}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 ht;return this.sarr.push(this.s),this.s=``,wt(e,this.sarr.join(``)),Tt(e,this.lensE.toUint8Array()),T(e)}},k=e=>Error(e),A=()=>{throw k(`Method unimplemented`)},j=()=>{throw k(`Unexpected case`)},zt=k(`Unexpected end of array`),Bt=k(`Integer out of Range`),Vt=class{constructor(e){this.arr=e,this.pos=0}},Ht=e=>new Vt(e),Ut=e=>e.pos!==e.arr.length,Wt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},M=e=>Wt(e,N(e)),Gt=e=>e.arr[e.pos++],N=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>tt)throw Bt}throw zt},Kt=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>tt)throw Bt}throw zt},qt=pt?e=>pt.decode(M(e)):e=>{let t=N(e);if(t===0)return``;{let n=String.fromCodePoint(Gt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Gt(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))}},Jt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Yt=[e=>void 0,e=>null,Kt,e=>Jt(e,4).getFloat32(0,!1),e=>Jt(e,8).getFloat64(0,!1),e=>Jt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,qt,e=>{let t=N(e),n={};for(let r=0;r<t;r++){let t=qt(e);n[t]=Xt(e)}return n},e=>{let t=N(e),n=[];for(let r=0;r<t;r++)n.push(Xt(e));return n},M],Xt=e=>Yt[127-Gt(e)](e),Zt=class extends Vt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ut(this)?this.count=N(this)+1:this.count=-1),this.count--,this.s}},Qt=class extends Vt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Kt(this);let e=Ve(this.s);this.count=1,e&&(this.s=-this.s,this.count=N(this)+2)}return this.count--,this.s}},$t=class extends Vt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Kt(this),t=e&1;this.diff=C(e/2),this.count=1,t&&(this.count=N(this)+2)}return this.s+=this.diff,this.count--,this.s}},en=class{constructor(e){this.decoder=new Qt(e),this.str=qt(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 tn=crypto.getRandomValues.bind(crypto),nn=Math.random,rn=()=>tn(new Uint32Array(1))[0],an=e=>e[C(nn()*e.length)],on=`10000000-1000-4000-8000-100000000000`,sn=()=>on.replace(/[018]/g,e=>(e^rn()&15>>e/4).toString(16)),cn=Date.now,ln=e=>new Promise(e);Promise.all.bind(Promise);var un=e=>e===void 0?null:e,dn=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&&(dn=localStorage)}catch{}var fn=dn,pn=Symbol(`Equality`),mn=(e,t)=>e===t||!!e?.[pn]?.(t)||!1,hn=e=>typeof e==`object`,gn=Object.assign,_n=Object.keys,vn=(e,t)=>{for(let n in e)t(e[n],n)},yn=e=>_n(e).length,bn=e=>{for(let t in e)return!1;return!0},xn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Sn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Cn=(e,t)=>e===t||yn(e)===yn(t)&&xn(e,(e,n)=>(e!==void 0||Sn(t,n))&&mn(t[n],e)),wn=Object.freeze,Tn=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Tn(e[t])}return wn(e)},En=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&En(e,t,n+1)}},Dn=e=>e,On=(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[pn]!=null)return e[pn](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)||!On(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(yn(e)!==yn(t))return!1;for(let n in e)if(!Sn(e,n)||!On(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(!On(e[n],t[n]))return!1;break;default:return!1}return!0},kn=(e,t)=>t.includes(e),An=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,jn=typeof window<`u`&&typeof document<`u`&&!An;typeof navigator<`u`&&/Mac/.test(navigator.platform);var P,Mn=[],Nn=()=>{if(P===void 0)if(An){P=y();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&P.set(t,``),t=r):t===null?Mn.push(r):(P.set(t,r),t=null)}t!==null&&P.set(t,``)}else typeof location==`object`?(P=y(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);P.set(`--${lt(t,`-`)}`,n),P.set(`-${lt(t,`-`)}`,n)}})):P=y();return P},Pn=e=>Nn().has(e),Fn=e=>un(An?{}[e.toUpperCase().replaceAll(`-`,`_`)]:fn.getItem(e)),In=e=>Pn(`--`+e)||Fn(e)!==null,Ln=In(`production`),Rn=An&&kn({}.FORCE_COLOR,[`true`,`1`,`2`])||!Pn(`--no-colors`)&&!In(`no-color`)&&(!An||process.stdout.isTTY)&&(!An||Pn(`--color`)||Fn(`COLORTERM`)!==null||(Fn(`TERM`)||``).includes(`color`)),zn=e=>new Uint8Array(e),Bn=jn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=it(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Vn=e=>{let t=zn(e.byteLength);return t.set(e),t},Hn=e=>_t(t=>Mt(t,e)),Un=class{constructor(e,t){this.left=e,this.right=t}},F=(e,t)=>new Un(e,t),Wn=(e,t)=>e.forEach(e=>t(e.left,e.right)),Gn=e=>e.next()>=.5,Kn=(e,t,n)=>C(e.next()*(n+1-t)+t),qn=(e,t,n)=>C(e.next()*(n+1-t)+t),Jn=(e,t,n)=>qn(e,t,n),Yn=e=>it(Jn(e,97,122)),Xn=(e,t=0,n=20)=>{let r=Jn(e,t,n),i=``;for(let t=0;t<r;t++)i+=Yn(e);return i},Zn=(e,t)=>t[Jn(e,0,t.length-1)],Qn=Symbol(`0schema`),$n=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(mt(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./preload-helper-Chd9yIcd.js";import{t as n}from"./jsx-runtime-BUgB2tll.js";import{t as r}from"./react-f2sANaYj.js";import{n as i}from"./dist-PQ5KMVDh.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{Fs as o,Ft as s,It as c,Lt as l,Ms as u,Nt as d,Pt as f,Rt as p,St as m,Ti as h,Wo as ee,ao as te,as as ne,cs as g,gn as re,io as ie,is as ae,ks as oe,mn as se,ni as _,no as ce,oi as le,ro as ue,xi as de,zt as fe}from"./dist-CP7w45uR.js";import{n as pe}from"./dist-CMZSEMCN2.js";import{t as me}from"./dist-CdT2fVlj.js";import{a as he,c as ge,m as _e,p as ve,r as ye}from"./use-apply-config-color-theme-hdarUMLl.js";import"./i18n-fvzGnIHb.js";import{r as be}from"./client-version-BsMRrwFS.js";var xe=a(),v=e(r(),1),Se=null,Ce=new Set;function we(){return Se}function Te(e){let t=e!==null&&e.length>0?e:null;if(t!==Se){Se=t;for(let e of Ce)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function Ee(e){return Ce.add(e),()=>{Ce.delete(e)}}function De(){return(0,v.useSyncExternalStore)(Ee,we,we)}var y=()=>new Map,Oe=e=>{let t=y();return e.forEach((e,n)=>{t.set(n,e)}),t},b=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ke=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Ae=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},x=()=>new Set,je=e=>e[e.length-1],Me=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},S=Array.from,Ne=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Pe=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Fe=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Ie=Array.isArray,Le=class{constructor(){this._observers=y()}on(e,t){return b(this._observers,e,x).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 S((this._observers.get(e)||y()).values()).forEach(e=>e(...t))}destroy(){this._observers=y()}},Re=class{constructor(){this._observers=y()}on(e,t){b(this._observers,e,x).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 S((this._observers.get(e)||y()).values()).forEach(e=>e(...t))}destroy(){this._observers=y()}},C=Math.floor,ze=Math.abs,Be=(e,t)=>e<t?e:t,w=(e,t)=>e>t?e:t;Number.isNaN;var Ve=e=>e===0?1/e<0:e<0,He=1<<17,Ue=1<<18,We=1<<19,Ge=1<<20,Ke=1<<21,qe=1<<22,Je=1<<23,Ye=1<<24,Xe=1<<25,Ze=1<<26,Qe=1<<27,$e=1<<28,et=1<<29;He-1,Ue-1,We-1,Ge-1,Ke-1,qe-1,Je-1,Ye-1,Xe-1,Ze-1,Qe-1,$e-1,et-1;var tt=2**53-1,nt=-(2**53-1),rt=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&C(e)===e);Number.isNaN,Number.parseInt;var it=String.fromCharCode;String.fromCodePoint,it(65535);var at=e=>e.toLowerCase(),ot=/^\s*/g,st=e=>e.replace(ot,``),ct=/([A-Z])/g,lt=(e,t)=>st(e.replace(ct,e=>`${t}${at(e)}`)),ut=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},dt=typeof TextEncoder<`u`?new TextEncoder:null,ft=dt?e=>dt.encode(e):ut,pt=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});pt&&pt.decode(new Uint8Array).length===1&&(pt=null);var mt=(e,t)=>Fe(t,()=>e).join(``),ht=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},gt=()=>new ht,_t=e=>{let t=gt();return e(t),T(t)},vt=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},T=e=>{let t=new Uint8Array(vt(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},yt=(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(w(n,t)*2),e.cpos=0)},E=(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},bt=E,D=(e,t)=>{for(;t>127;)E(e,128|127&t),t=C(t/128);E(e,127&t)},xt=(e,t)=>{let n=Ve(t);for(n&&(t=-t),E(e,(t>63?128:0)|(n?64:0)|63&t),t=C(t/64);t>0;)E(e,(t>127?128:0)|127&t),t=C(t/128)},St=new Uint8Array(3e4),Ct=St.length/3,wt=dt&&dt.encodeInto?(e,t)=>{if(t.length<Ct){let n=dt.encodeInto(t,St).written||0;D(e,n);for(let t=0;t<n;t++)E(e,St[t])}else O(e,ft(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;D(e,r);for(let t=0;t<r;t++)E(e,n.codePointAt(t))},Tt=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Be(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(w(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},O=(e,t)=>{D(e,t.byteLength),Tt(e,t)},Et=(e,t)=>{yt(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Dt=(e,t)=>Et(e,4).setFloat32(0,t,!1),Ot=(e,t)=>Et(e,8).setFloat64(0,t,!1),kt=(e,t)=>Et(e,8).setBigInt64(0,t,!1),At=new DataView(new ArrayBuffer(4)),jt=e=>(At.setFloat32(0,e),At.getFloat32(0)===e),Mt=(e,t)=>{switch(typeof t){case`string`:E(e,119),wt(e,t);break;case`number`:rt(t)&&ze(t)<=2147483647?(E(e,125),xt(e,t)):jt(t)?(E(e,124),Dt(e,t)):(E(e,123),Ot(e,t));break;case`bigint`:E(e,122),kt(e,t);break;case`object`:if(t===null)E(e,126);else if(Ie(t)){E(e,117),D(e,t.length);for(let n=0;n<t.length;n++)Mt(e,t[n])}else if(t instanceof Uint8Array)E(e,116),O(e,t);else{E(e,118);let n=Object.keys(t);D(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];wt(e,i),Mt(e,t[i])}}break;case`boolean`:E(e,t?120:121);break;default:E(e,127)}},Nt=class extends ht{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&D(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Pt=e=>{e.count>0&&(xt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&D(e.encoder,e.count-2))},Ft=class{constructor(){this.encoder=new ht,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Pt(this),this.count=1,this.s=e)}toUint8Array(){return Pt(this),T(this.encoder)}},It=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);xt(e.encoder,t),e.count>1&&D(e.encoder,e.count-2)}},Lt=class{constructor(){this.encoder=new ht,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(It(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return It(this),T(this.encoder)}},Rt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Ft}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 ht;return this.sarr.push(this.s),this.s=``,wt(e,this.sarr.join(``)),Tt(e,this.lensE.toUint8Array()),T(e)}},k=e=>Error(e),A=()=>{throw k(`Method unimplemented`)},j=()=>{throw k(`Unexpected case`)},zt=k(`Unexpected end of array`),Bt=k(`Integer out of Range`),Vt=class{constructor(e){this.arr=e,this.pos=0}},Ht=e=>new Vt(e),Ut=e=>e.pos!==e.arr.length,Wt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},M=e=>Wt(e,N(e)),Gt=e=>e.arr[e.pos++],N=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>tt)throw Bt}throw zt},Kt=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>tt)throw Bt}throw zt},qt=pt?e=>pt.decode(M(e)):e=>{let t=N(e);if(t===0)return``;{let n=String.fromCodePoint(Gt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Gt(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))}},Jt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Yt=[e=>void 0,e=>null,Kt,e=>Jt(e,4).getFloat32(0,!1),e=>Jt(e,8).getFloat64(0,!1),e=>Jt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,qt,e=>{let t=N(e),n={};for(let r=0;r<t;r++){let t=qt(e);n[t]=Xt(e)}return n},e=>{let t=N(e),n=[];for(let r=0;r<t;r++)n.push(Xt(e));return n},M],Xt=e=>Yt[127-Gt(e)](e),Zt=class extends Vt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ut(this)?this.count=N(this)+1:this.count=-1),this.count--,this.s}},Qt=class extends Vt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Kt(this);let e=Ve(this.s);this.count=1,e&&(this.s=-this.s,this.count=N(this)+2)}return this.count--,this.s}},$t=class extends Vt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Kt(this),t=e&1;this.diff=C(e/2),this.count=1,t&&(this.count=N(this)+2)}return this.s+=this.diff,this.count--,this.s}},en=class{constructor(e){this.decoder=new Qt(e),this.str=qt(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 tn=crypto.getRandomValues.bind(crypto),nn=Math.random,rn=()=>tn(new Uint32Array(1))[0],an=e=>e[C(nn()*e.length)],on=`10000000-1000-4000-8000-100000000000`,sn=()=>on.replace(/[018]/g,e=>(e^rn()&15>>e/4).toString(16)),cn=Date.now,ln=e=>new Promise(e);Promise.all.bind(Promise);var un=e=>e===void 0?null:e,dn=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&&(dn=localStorage)}catch{}var fn=dn,pn=Symbol(`Equality`),mn=(e,t)=>e===t||!!e?.[pn]?.(t)||!1,hn=e=>typeof e==`object`,gn=Object.assign,_n=Object.keys,vn=(e,t)=>{for(let n in e)t(e[n],n)},yn=e=>_n(e).length,bn=e=>{for(let t in e)return!1;return!0},xn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Sn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Cn=(e,t)=>e===t||yn(e)===yn(t)&&xn(e,(e,n)=>(e!==void 0||Sn(t,n))&&mn(t[n],e)),wn=Object.freeze,Tn=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Tn(e[t])}return wn(e)},En=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&En(e,t,n+1)}},Dn=e=>e,On=(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[pn]!=null)return e[pn](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)||!On(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(yn(e)!==yn(t))return!1;for(let n in e)if(!Sn(e,n)||!On(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(!On(e[n],t[n]))return!1;break;default:return!1}return!0},kn=(e,t)=>t.includes(e),An=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,jn=typeof window<`u`&&typeof document<`u`&&!An;typeof navigator<`u`&&/Mac/.test(navigator.platform);var P,Mn=[],Nn=()=>{if(P===void 0)if(An){P=y();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&P.set(t,``),t=r):t===null?Mn.push(r):(P.set(t,r),t=null)}t!==null&&P.set(t,``)}else typeof location==`object`?(P=y(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);P.set(`--${lt(t,`-`)}`,n),P.set(`-${lt(t,`-`)}`,n)}})):P=y();return P},Pn=e=>Nn().has(e),Fn=e=>un(An?{}[e.toUpperCase().replaceAll(`-`,`_`)]:fn.getItem(e)),In=e=>Pn(`--`+e)||Fn(e)!==null,Ln=In(`production`),Rn=An&&kn({}.FORCE_COLOR,[`true`,`1`,`2`])||!Pn(`--no-colors`)&&!In(`no-color`)&&(!An||process.stdout.isTTY)&&(!An||Pn(`--color`)||Fn(`COLORTERM`)!==null||(Fn(`TERM`)||``).includes(`color`)),zn=e=>new Uint8Array(e),Bn=jn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=it(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Vn=e=>{let t=zn(e.byteLength);return t.set(e),t},Hn=e=>_t(t=>Mt(t,e)),Un=class{constructor(e,t){this.left=e,this.right=t}},F=(e,t)=>new Un(e,t),Wn=(e,t)=>e.forEach(e=>t(e.left,e.right)),Gn=e=>e.next()>=.5,Kn=(e,t,n)=>C(e.next()*(n+1-t)+t),qn=(e,t,n)=>C(e.next()*(n+1-t)+t),Jn=(e,t,n)=>qn(e,t,n),Yn=e=>it(Jn(e,97,122)),Xn=(e,t=0,n=20)=>{let r=Jn(e,t,n),i=``;for(let t=0;t<r;t++)i+=Yn(e);return i},Zn=(e,t)=>t[Jn(e,0,t.length-1)],Qn=Symbol(`0schema`),$n=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(mt(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
3
3
|
`)}},er=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[pn]?mn(e,t):Ie(e)?Ne(e,e=>Pe(t,t=>er(e,t))):hn(e)?xn(e,(e,n)=>er(e,t[n])):!1,I=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),er(t,n)}equals(e){return this.constructor===e.constructor&&On(this.shape,e.shape)}[Qn](){return!0}[pn](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){A()}get nullable(){return jr(this,Kr)}get optional(){return new lr(this)}cast(e){return Xr(e,this),e}expect(e){return Xr(e,this),e}},tr=class extends I{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}},L=(e,t=null)=>new tr(e,t);L(tr);var nr=class extends I{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}},R=e=>new nr(e);L(nr);var rr=class extends I{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}},ir=(...e)=>new rr(e),ar=L(rr),or=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),sr=e=>{if(Vr.check(e))return[or(e)];if(ar.check(e))return e.shape.map(e=>e+``);if(Br.check(e))return[`[+-]?\\d+.?\\d*`];if(Hr.check(e))return[`.*`];if(Mr.check(e))return e.shape.map(sr).flat(1);j()};L(class extends I{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(sr).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 cr=Symbol(`optional`),lr=class extends I{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[cr](){return!0}},ur=L(lr),dr=class extends I{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new dr,L(dr);var fr=class e extends I{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):xn(this.shape,(n,r)=>{let i=this._isPartial&&!Sn(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},pr=e=>new fr(e),mr=L(fr),hr=R(e=>e!=null&&(e.constructor===Object||e.constructor==null)),gr=class extends I{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&xn(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)})}},_r=(e,t)=>new gr(e,t),vr=L(gr),yr=class extends I{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&xn(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},br=(...e)=>new yr(e);L(yr);var xr=class extends I{constructor(e){super(),this.shape=e.length===1?e[0]:new Ar(e)}check(e,t){let n=Ie(e)&&Ne(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},Sr=(...e)=>new xr(e),Cr=L(xr),wr=R(e=>Ie(e)),Tr=class extends I{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}},Er=(e,t=null)=>new Tr(e,t);L(Tr);var Dr=Er(I),Or=L(class extends I{constructor(e){super(),this.len=e.length-1,this.args=br(...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}}),kr=R(e=>typeof e==`function`);L(class extends I{constructor(e){super(),this.shape=e}check(e,t){let n=Ne(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Ar=class extends I{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Pe(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},jr=(...e)=>e.findIndex(e=>Mr.check(e))>=0?jr(...e.map(e=>Yr(e)).map(e=>Mr.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Ar(e),Mr=L(Ar),Nr=()=>!0,Pr=R(Nr),Fr=L(nr,e=>e.shape===Nr),Ir=R(e=>typeof e==`bigint`),Lr=R(e=>e===Ir),Rr=R(e=>typeof e==`symbol`);R(e=>e===Rr);var zr=R(e=>typeof e==`number`),Br=R(e=>e===zr),Vr=R(e=>typeof e==`string`),Hr=R(e=>e===Vr),Ur=R(e=>typeof e==`boolean`),Wr=R(e=>e===Ur),Gr=ir(void 0);L(rr,e=>e.shape.length===1&&e.shape[0]===void 0),ir(void 0);var Kr=ir(null),qr=L(rr,e=>e.shape.length===1&&e.shape[0]===null);L(Uint8Array),L(tr,e=>e.shape===Uint8Array);var Jr=jr(zr,Vr,Kr,Gr,Ir,Ur,Rr);(()=>{let e=Sr(Pr),t=_r(Vr,Pr),n=jr(zr,Vr,Kr,Ur,e,t);return e.shape=n,t.shape.values=n,n})();var Yr=e=>{if(Dr.check(e))return e;if(hr.check(e)){let t={};for(let n in e)t[n]=Yr(e[n]);return pr(t)}else if(wr.check(e))return jr(...e.map(Yr));else if(Jr.check(e))return ir(e);else if(kr.check(e))return L(e);j()},Xr=Ln?()=>{}:(e,t)=>{let n=new $n;if(!t.check(e,n))throw k(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Zr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Yr(e),h:t}),this}else(e){return this.if(Pr,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 k(`Unhandled pattern`)}}},Qr=(e=>new Zr(e))(Pr).if(Br,(e,t)=>Kn(t,nt,tt)).if(Hr,(e,t)=>Xn(t)).if(Wr,(e,t)=>Gn(t)).if(Lr,(e,t)=>BigInt(Kn(t,nt,tt))).if(Mr,(e,t)=>$r(t,Zn(t,e.shape))).if(mr,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(ur.check(i)){if(Gn(t))continue;i=i.shape}n[r]=Qr(i,t)}return n}).if(Cr,(e,t)=>{let n=[],r=qn(t,0,42);for(let i=0;i<r;i++)n.push($r(t,e.shape));return n}).if(ar,(e,t)=>Zn(t,e.shape)).if(qr,(e,t)=>null).if(Or,(e,t)=>{let n=$r(t,e.res);return()=>n}).if(Fr,(e,t)=>$r(t,Zn(t,[zr,Vr,Kr,Gr,Ir,Ur,Sr(zr),_r(jr(`a`,`b`,`c`),zr)]))).if(vr,(e,t)=>{let n={},r=Kn(t,0,3);for(let i=0;i<r;i++){let r=$r(t,e.shape.keys);n[r]=$r(t,e.shape.values)}return n}).done(),$r=(e,t)=>Qr(Yr(t),e),z=typeof document<`u`?document:{},ei=e=>z.createElement(e),ti=()=>z.createDocumentFragment();R(e=>e.nodeType===pi);var ni=e=>z.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var ri=(e,t)=>(Wn(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),ii=e=>{let t=ti();for(let n=0;n<e.length;n++)li(t,e[n]);return t},ai=(e,t)=>(li(e,ii(t)),e),oi=(e,t=[],n=[])=>ai(ri(ei(e),t),n);R(e=>e.nodeType===ui);var si=ni;R(e=>e.nodeType===di);var ci=e=>ke(e,(e,t)=>`${t}:${e};`).join(``),li=(e,t)=>e.appendChild(t),ui=z.ELEMENT_NODE,di=z.TEXT_NODE;z.CDATA_SECTION_NODE,z.COMMENT_NODE;var fi=z.DOCUMENT_NODE;z.DOCUMENT_TYPE_NODE;var pi=z.DOCUMENT_FRAGMENT_NODE;R(e=>e.nodeType===fi);var mi=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),hi=(e,t)=>new mi(setTimeout(t,e)),gi=Symbol,_i=gi(),vi=gi(),yi=gi(),bi=gi(),xi=gi(),Si=gi(),Ci=gi(),wi=gi(),Ti=gi(),Ei=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};cn();var Di={[_i]:F(`font-weight`,`bold`),[vi]:F(`font-weight`,`normal`),[yi]:F(`color`,`blue`),[xi]:F(`color`,`green`),[bi]:F(`color`,`grey`),[Si]:F(`color`,`red`),[Ci]:F(`color`,`purple`),[wi]:F(`color`,`orange`),[Ti]:F(`color`,`black`)},Oi=Rn?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=y(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=Di[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=ci(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}:Ei,ki=(...e)=>{console.log(...Oi(e)),ji.forEach(t=>t.print(e))},Ai=(...e)=>{console.warn(...Oi(e)),e.unshift(wi),ji.forEach(t=>t.print(e))},ji=x(),Mi=e=>({[Symbol.iterator](){return this},next:e}),Ni=(e,t)=>Mi(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Pi=(e,t)=>Mi(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Fi=class{constructor(e,t){this.clock=e,this.len=t}},Ii=class{constructor(){this.clients=new Map}},Li=(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])Qa(e,i,o.clock,o.len,n)}}),Ri=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=C((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},zi=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Ri(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 Fi(r.clock,w(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Vi=e=>{let t=new Ii;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},Hi=(e,t,n,r)=>{b(e.clients,t,()=>[]).push(new Fi(n,r))},Ui=()=>new Ii,Wi=e=>{let t=Ui();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 Fi(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Gi=(e,t)=>{D(e.restEncoder,t.clients.size),S(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),D(e.restEncoder,t);let r=n.length;D(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Ki=e=>{let t=new Ii,n=N(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=N(e.restDecoder),r=N(e.restDecoder);if(r>0){let i=b(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new Fi(e.readDsClock(),e.readDsLen()))}}return t},qi=(e,t,n)=>{let r=new Ii,i=N(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=N(e.restDecoder),a=N(e.restDecoder),o=n.clients.get(i)||[],s=V(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Hi(r,i,s,a-s);let e=H(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,dc(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,dc(t,c,a-c.id.clock)),c.delete(t))}else Hi(r,i,n,a-n)}}if(r.clients.size>0){let e=new ra;return D(e.restEncoder,0),Gi(e,r),e.toUint8Array()}return null},Ji=rn,Yi=class e extends Le{constructor({guid:e=sn(),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=Ji(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ga,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=ln(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>ln(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&&W(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(S(this.subdocs).map(e=>e.guid))}transact(e,t=null){return W(this,e,t)}get(e,t=K){let n=b(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==K&&r!==t)if(r===K){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,ts)}getText(e=``){return this.get(e,Ss)}getMap(e=``){return this.get(e,is)}getXmlElement(e=``){return this.get(e,Ds)}getXmlFragment(e=``){return this.get(e,Ts)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,S(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,W(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()}},Xi=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return N(this.restDecoder)}readDsLen(){return N(this.restDecoder)}},Zi=class extends Xi{readLeftID(){return B(N(this.restDecoder),N(this.restDecoder))}readRightID(){return B(N(this.restDecoder),N(this.restDecoder))}readClient(){return N(this.restDecoder)}readInfo(){return Gt(this.restDecoder)}readString(){return qt(this.restDecoder)}readParentInfo(){return N(this.restDecoder)===1}readTypeRef(){return N(this.restDecoder)}readLen(){return N(this.restDecoder)}readAny(){return Xt(this.restDecoder)}readBuf(){return Vn(M(this.restDecoder))}readJSON(){return JSON.parse(qt(this.restDecoder))}readKey(){return qt(this.restDecoder)}},Qi=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=N(this.restDecoder),this.dsCurrVal}readDsLen(){let e=N(this.restDecoder)+1;return this.dsCurrVal+=e,e}},$i=class extends Qi{constructor(e){super(e),this.keys=[],N(e),this.keyClockDecoder=new $t(M(e)),this.clientDecoder=new Qt(M(e)),this.leftClockDecoder=new $t(M(e)),this.rightClockDecoder=new $t(M(e)),this.infoDecoder=new Zt(M(e),Gt),this.stringDecoder=new en(M(e)),this.parentInfoDecoder=new Zt(M(e),Gt),this.typeRefDecoder=new Qt(M(e)),this.lenDecoder=new Qt(M(e))}readLeftID(){return new Ea(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ea(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 Xt(this.restDecoder)}readBuf(){return M(this.restDecoder)}readJSON(){return Xt(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}}},ea=class{constructor(){this.restEncoder=gt()}toUint8Array(){return T(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){D(this.restEncoder,e)}writeDsLen(e){D(this.restEncoder,e)}},ta=class extends ea{writeLeftID(e){D(this.restEncoder,e.client),D(this.restEncoder,e.clock)}writeRightID(e){D(this.restEncoder,e.client),D(this.restEncoder,e.clock)}writeClient(e){D(this.restEncoder,e)}writeInfo(e){bt(this.restEncoder,e)}writeString(e){wt(this.restEncoder,e)}writeParentInfo(e){D(this.restEncoder,+!!e)}writeTypeRef(e){D(this.restEncoder,e)}writeLen(e){D(this.restEncoder,e)}writeAny(e){Mt(this.restEncoder,e)}writeBuf(e){O(this.restEncoder,e)}writeJSON(e){wt(this.restEncoder,JSON.stringify(e))}writeKey(e){wt(this.restEncoder,e)}},na=class{constructor(){this.restEncoder=gt(),this.dsCurrVal=0}toUint8Array(){return T(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,D(this.restEncoder,t)}writeDsLen(e){e===0&&j(),D(this.restEncoder,e-1),this.dsCurrVal+=e}},ra=class extends na{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Lt,this.clientEncoder=new Ft,this.leftClockEncoder=new Lt,this.rightClockEncoder=new Lt,this.infoEncoder=new Nt(bt),this.stringEncoder=new Rt,this.parentInfoEncoder=new Nt(bt),this.typeRefEncoder=new Ft,this.lenEncoder=new Ft}toUint8Array(){let e=gt();return D(e,0),O(e,this.keyClockEncoder.toUint8Array()),O(e,this.clientEncoder.toUint8Array()),O(e,this.leftClockEncoder.toUint8Array()),O(e,this.rightClockEncoder.toUint8Array()),O(e,T(this.infoEncoder)),O(e,this.stringEncoder.toUint8Array()),O(e,T(this.parentInfoEncoder)),O(e,this.typeRefEncoder.toUint8Array()),O(e,this.lenEncoder.toUint8Array()),Tt(e,T(this.restEncoder)),T(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){Mt(this.restEncoder,e)}writeBuf(e){O(this.restEncoder,e)}writeJSON(e){Mt(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)}},ia=(e,t,n,r)=>{r=w(r,t[0].id.clock);let i=H(t,r);D(e.restEncoder,t.length-i),e.writeClient(n),D(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)},aa=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{V(t,n)>e&&r.set(n,e)}),Ka(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),D(e.restEncoder,r.size),S(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{ia(e,t.clients.get(n),n,r)})},oa=(e,t)=>{let n=y(),r=N(e.restDecoder);for(let i=0;i<r;i++){let r=N(e.restDecoder),i=Array(r),a=e.readClient(),o=N(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 q(B(a,o),t),o+=t;break}case 10:{let t=N(e.restDecoder);i[n]=new X(B(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new Y(B(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,mc(e,r));i[n]=c,o+=c.length}}}}return n},sa=(e,t,n)=>{let r=[],i=S(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 Ga,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!==X){let i=b(d,u.id.client,()=>V(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,V(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 ra;return aa(e,s,new Map),D(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},ca=(e,t)=>aa(e,t.doc.store,t.beforeState),la=(e,t,n,r=new $i(e))=>W(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=sa(e,i,oa(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<V(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=go([o.update,a.update])}}else i.pendingStructs=a;let s=qi(r,e,i);if(i.pendingDs){let t=new $i(Ht(i.pendingDs));N(t.restDecoder);let n=qi(t,e,i);s&&n?i.pendingDs=go([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,ua(e.doc,t)}},n,!1),ua=(e,t,n,r=$i)=>{let i=Ht(t);la(i,e,n,new r(i))},da=(e,t,n)=>ua(e,t,n,Zi),fa=(e,t,n=new Map)=>{aa(e,t.store,n),Gi(e,Wi(t.store))},pa=(e,t=new Uint8Array([0]),n=new ra)=>{fa(n,e,ga(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(_o(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===ta)return mo(r.map((e,t)=>t===0?e:So(e)));if(n.constructor===ra)return go(r)}return r[0]},ma=(e,t)=>pa(e,t,new ta),ha=e=>{let t=new Map,n=N(e.restDecoder);for(let r=0;r<n;r++){let n=N(e.restDecoder),r=N(e.restDecoder);t.set(n,r)}return t},ga=e=>ha(new Xi(Ht(e))),_a=(e,t)=>(D(e.restEncoder,t.size),S(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{D(e.restEncoder,t),D(e.restEncoder,n)}),e),va=(e,t)=>_a(e,Ka(t.store)),ya=(e,t=new na)=>(e instanceof Map?_a(t,e):va(t,e),t.toUint8Array()),ba=e=>ya(e,new ea),xa=class{constructor(){this.l=[]}},Sa=()=>new xa,Ca=(e,t)=>e.l.push(t),wa=(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.`)},Ta=(e,t,n)=>En(e.l,[t,n]),Ea=class{constructor(e,t){this.client=e,this.clock=t}},Da=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,B=(e,t)=>new Ea(e,t),Oa=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw j()},ka=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Aa=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ja=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},Ma=e=>new Aa(e.type==null?null:B(e.type.client,e.type.clock),e.tname??null,e.item==null?null:B(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Na=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Pa=(e,t,n=0)=>new Na(e,t,n),Fa=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Oa(e):r=B(e._item.id.client,e._item.id.clock),new Aa(r,i,t,n)},Ia=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Fa(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Fa(e,B(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Fa(e,r.lastId,n);r=r.right}return Fa(e,null,n)},La=(e,t)=>{let n=Ja(e,t);return{item:n,diff:t.clock-n.id.clock}},Ra=(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(V(r,i.client)<=i.clock)return null;let e=n?lc(r,i):La(r,i),t=e.item;if(!(t instanceof Y))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(V(r,a.client)<=a.clock)return null;let{item:e}=n?lc(r,a):{item:Ja(r,a)};if(e instanceof Y&&e.content instanceof sc)c=e.content.type;else return null}else throw j();l=s>=0?c._length:0}return Pa(c,l,e.assoc)},za=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Da(e.item,t.item)&&Da(e.type,t.type)&&e.assoc===t.assoc,Ba=class{constructor(e,t){this.ds=e,this.sv=t}},Va=(e,t)=>new Ba(e,t);Va(Ui(),new Map);var Ha=e=>Va(Wi(e.store),Ka(e.store)),Ua=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!zi(t.ds,e.id),Wa=(e,t)=>{let n=b(e.meta,Wa,x),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<V(r,n)&&U(e,B(n,t))}),Li(e,t.ds,e=>{}),n.add(t))},Ga=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ka=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},V=(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},qa=(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 j()}n.push(t)},H=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=C(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=C((n+r)/2)}throw j()},Ja=(e,t)=>{let n=e.clients.get(t.client);return n[H(n,t.clock)]},Ya=(e,t,n)=>{let r=H(t,n),i=t[r];return i.id.clock<n&&i instanceof Y?(t.splice(r+1,0,dc(e,i,n-i.id.clock)),r+1):r},U=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Ya(e,n,t.clock)]},Xa=(e,t,n)=>{let r=t.clients.get(n.client),i=H(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==q&&r.splice(i+1,0,dc(e,a,n.clock-a.id.clock+1)),a},Za=(e,t,n)=>{let r=e.clients.get(t.id.client);r[H(r,t.id.clock)]=n},Qa=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Ya(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Ya(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},$a=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Ii,this.beforeState=Ka(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}},eo=(e,t)=>t.deleteSet.clients.size===0&&!Ae(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Bi(t.deleteSet),ca(e,t),Gi(e,t.deleteSet),!0),to=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&b(e.changed,t,x).add(n)},no=(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 Y&&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},ro=(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=H(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 Y&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},io=(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=Be(r.length-1,1+H(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+no(r,e)}})},ao=(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=Ka(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(()=>{Ta(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&ys(n)})}),En(e,[])}finally{r.gc&&ro(a,i,r.gcFilter),io(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=w(H(e,r),1);for(let t=e.length-1;t>=n;)t-=1+no(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=H(r,n);a+1<r.length&&no(r,a+1)>1||a>0&&no(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(ki(wi,_i,`[yjs] `,vi,Si,`Changed the client-id because another client seems to be using it.`),r.clientID=Ji()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new ta;eo(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new ra;eo(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])):ao(e,t+1)}}},W=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new $a(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&&ao(i,0)}}return o},oo=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},so=(e,t,n)=>{Li(e,n.deletions,n=>{n instanceof Y&&t.scope.some(t=>t===e.doc||ka(t,n))&&uc(n,!1)})},co=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;W(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;Li(n,o.insertions,e=>{if(e instanceof Y){if(e.redone!==null){let{item:t,diff:i}=lc(r,e.id);i>0&&(t=U(n,B(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ka(t,e))&&c.push(e)}}),Li(n,o.deletions,e=>{e instanceof Y&&a.some(t=>t===n.doc||ka(t,e))&&!zi(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=pc(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},lo=class extends Le{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=Ie(e)?e[0].doc:e instanceof Yi?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 Ii;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Hi(i,n,r,a)});let a=cn(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=Vi([t.deletions,e.deleteSet]),t.insertions=Vi([t.insertions,i])}else r.push(new oo(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),Li(e,e.deleteSet,t=>{t instanceof Y&&this.scope.some(n=>n===e.doc||ka(n,t))&&uc(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=Ie(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof K?e.doc!==this.doc:e!==this.doc)&&Ai(`[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=>so(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>so(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=co(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=co(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*uo(e){let t=N(e.restDecoder);for(let n=0;n<t;n++){let t=N(e.restDecoder),n=e.readClient(),r=N(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=N(e.restDecoder);yield new X(B(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new Y(B(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,mc(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new q(B(n,r),t),r+=t}}}}var fo=class{constructor(e,t){this.gen=uo(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===X);return this.curr}},po=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},mo=e=>go(e,Zi,ta),ho=(e,t)=>{if(e.constructor===q){let{client:n,clock:r}=e.id;return new q(B(n,r+t),e.length-t)}else if(e.constructor===X){let{client:n,clock:r}=e.id;return new X(B(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new Y(B(r,i+t),null,B(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},go=(e,t=$i,n=ra)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Ht(e))),i=r.map(e=>new fo(e,!0)),a=null,o=new n,s=new po(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===X?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)yo(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===X)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{yo(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new X(B(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===X?a.struct.length-=t:n=ho(n,t)),a.struct.mergeWith(n)||(yo(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!==X;n=e.next())yo(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(yo(s,a.struct,a.offset),a=null),bo(s),Gi(o,Vi(r.map(e=>Ki(e)))),o.toUint8Array()},_o=(e,t,n=$i,r=ra)=>{let i=ga(t),a=new r,o=new po(a),s=new n(Ht(e)),c=new fo(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===X){c.next();continue}if(e.id.clock+e.length>n)for(yo(o,e,w(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)yo(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 bo(o),Gi(a,Ki(s)),a.toUint8Array()},vo=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:T(e.encoder.restEncoder)}),e.encoder.restEncoder=gt(),e.written=0)},yo=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&vo(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),D(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},bo=e=>{vo(e);let t=e.encoder.restEncoder;D(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];D(t,r.written),Tt(t,r.restEncoder)}},xo=(e,t,n,r)=>{let i=new n(Ht(e)),a=new fo(i,!1),o=new r,s=new po(o);for(let e=a.curr;e!==null;e=a.next())yo(s,t(e),0);return bo(s),Gi(o,Ki(i)),o.toUint8Array()},So=e=>xo(e,Dn,$i,ta),Co=`You must not compute changes after the event-handler fired.`,wo=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||=To(this.currentTarget,this.target)}deletes(e){return zi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw k(Co);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=je(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=je(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=je(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 k(Co);let t=this.target,n=x(),r=x(),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}},To=(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},G=()=>{Ai(`Invalid access: Add Yjs type to a document before reading data.`)},Eo=80,Do=0,Oo=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Do++}},ko=e=>{e.timestamp=Do++},Ao=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Do++},jo=(e,t,n)=>{if(e.length>=Eo){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Ao(r,t,n),r}else{let r=new Oo(t,n);return e.push(r),r}},Mo=(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)=>ze(t-e.index)<ze(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,ko(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&&ze(n.index-i)<r.parent.length/Eo?(Ao(n,r,i),n):jo(e._searchMarker,r,i)},No=(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=w(t,i.index+n))}},Po=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;b(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Ta(r._eH,n,t)},K=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Sa(),this._dEH=Sa(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw A()}clone(){throw A()}_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){Ca(this._eH,e)}observeDeep(e){Ca(this._dEH,e)}unobserve(e){wa(this._eH,e)}unobserveDeep(e){wa(this._dEH,e)}toJSON(){}},Fo=(e,t,n)=>{e.doc??G(),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},Io=e=>{e.doc??G();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},Lo=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Ua(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},Ro=(e,t)=>{let n=0,r=e._start;for(e.doc??G();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}},zo=(e,t)=>{let n=[];return Ro(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}}}},Vo=(e,t)=>{e.doc??G();let n=Mo(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}},Ho=(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 Y(B(o,V(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ys(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 Y(B(o,V(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Is(new Uint8Array(n))),i.integrate(e,0);break;case Yi:i=new Y(B(o,V(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Vs(n)),i.integrate(e,0);break;default:if(n instanceof K)i=new Y(B(o,V(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new sc(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Uo=()=>k(`Length exceeded!`),Wo=(e,t,n,r)=>{if(n>t._length)throw Uo();if(n===0)return t._searchMarker&&No(t._searchMarker,n,r.length),Ho(e,t,null,r);let i=n,a=Mo(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&&U(e,B(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&No(t._searchMarker,i,r.length),Ho(e,t,o,r)},Go=(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 Ho(e,t,r,n)},Ko=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=Mo(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&&U(e,B(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&U(e,B(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Uo();t._searchMarker&&No(t._searchMarker,i,-a+r)},qo=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Jo=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Ys([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Ys([r]);break;case Uint8Array:s=new Is(r);break;case Yi:s=new Vs(r);break;default:if(r instanceof K)s=new sc(r);else throw Error(`Unexpected content type`)}new Y(B(o,V(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Yo=(e,t)=>{e.doc??G();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Xo=e=>{let t={};return e.doc??G(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Zo=(e,t)=>{e.doc??G();let n=e._map.get(t);return n!==void 0&&!n.deleted},Qo=(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&&Ua(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},$o=e=>(e.doc??G(),Ni(e._map.entries(),e=>!e[1].deleted)),es=class extends wo{},ts=class e extends K{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 K?e.clone():e)),t}get length(){return this.doc??G(),this._length}_callObserver(e,t){super._callObserver(e,t),Po(this,e,new es(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):W(this.doc,n=>{Wo(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):W(this.doc,t=>{Go(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):W(this.doc,n=>{Ko(n,this,e,t)})}get(e){return Vo(this,e)}toArray(){return Io(this)}slice(e=0,t=this.length){return Fo(this,e,t)}toJSON(){return this.map(e=>e instanceof K?e.toJSON():e)}map(e){return zo(this,e)}forEach(e){Ro(this,e)}[Symbol.iterator](){return Bo(this)}_write(e){e.writeTypeRef(ec)}},ns=e=>new ts,rs=class extends wo{constructor(e,t,n){super(e,t),this.keysChanged=n}},is=class e extends K{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 K?e.clone():e)}),t}_callObserver(e,t){Po(this,e,new rs(this,e,t))}toJSON(){this.doc??G();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof K?r.toJSON():r}}),e}get size(){return[...$o(this)].length}keys(){return Pi($o(this),e=>e[0])}values(){return Pi($o(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Pi($o(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??G(),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):W(this.doc,t=>{qo(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):W(this.doc,n=>{Jo(n,this,e,t)}),t}get(e){return Yo(this,e)}has(e){return Zo(this,e)}clear(){this.doc===null?this._prelimContent.clear():W(this.doc,e=>{this.forEach(function(t,n,r){qo(e,r,n)})})}_write(e){e.writeTypeRef(tc)}},as=e=>new is,os=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Cn(e,t),ss=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&j(),this.right.content.constructor){case J:this.right.deleted||ds(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}},cs=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case J:t.right.deleted||ds(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&U(e,B(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},ls=(e,t,n,r)=>{let i=new Map,a=r?Mo(t,n):null;return a?cs(e,new ss(a.p.left,a.p,a.index,i),n-a.index):cs(e,new ss(null,t._start,0,i),n)},us=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===J&&os(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 Y(B(a,V(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new J(o,r));l.integrate(e,0),n.right=l,n.forward()})},ds=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},fs=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===J&&os(t[e.right.content.key]??null,e.right.content.value));)e.forward()},ps=(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(!os(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Y(B(a,V(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new J(s,c)),n.right.integrate(e,0),n.forward()}}return o},ms=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;fs(n,i);let s=ps(e,t,n,i),c=r.constructor===String?new Zs(r):r instanceof K?new sc(r):new Us(r),{left:l,right:u,index:d}=n;t._searchMarker&&No(t._searchMarker,n.index,c.getLength()),u=new Y(B(o,V(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(),us(e,t,n,s)},hs=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;fs(n,i);let s=ps(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===J));){if(!n.right.deleted)switch(n.right.content.constructor){case J:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(os(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&&U(e,B(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
4
4
|
`;n.right=new Y(B(o,V(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Zs(i)),n.right.integrate(e,0),n.forward()}us(e,t,n,s)},gs=(e,t,n,r,i)=>{let a=t,o=y();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===J){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 J:{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&&ds(i,n);break}}}t=t.right}return s},_s=(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===J){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},vs=e=>{let t=0;return W(e.doc,n=>{let r=e._start,i=e._start,a=y(),o=Oe(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case J:ds(o,i.content);break;default:t+=gs(n,r,i,a,o),a=Oe(o),r=i;break}i=i.right}}),t},ys=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&&Qa(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===J&&e.constructor!==q&&t.add(e.parent)})}W(n,n=>{Li(e,e.deleteSet,e=>{if(e instanceof q||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===J?t.add(r):_s(n,e)});for(let e of t)vs(e)})},bs=(e,t,n)=>{let r=n,i=Oe(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case sc:case Us:case Zs:n<t.right.length&&U(e,B(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&gs(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&No(o._searchMarker,t.index,-r+n),t},xs=class extends wo{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=[];W(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},bn(o)||(e.attributes=gn({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case sc:case Us: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 Zs: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 J:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(os(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),os(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;os(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(os(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),ds(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}},Ss=class e extends K{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??G(),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 xs(this,e,t);Po(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??G();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Zs&&(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)):W(this.doc,n=>{let r=new ss(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
5
5
|
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&ms(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&bs(n,r,a.delete):hs(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??G();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(Ua(s,e)||t!==void 0&&Ua(s,t))switch(s.content.constructor){case Zs:{let r=i.get(`ychange`);e!==void 0&&!Ua(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&&!Ua(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 sc:case Us:{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 J:Ua(s,e)&&(c(),ds(i,s.content));break}s=s.right}c()};return e||t?W(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)):W(r,r=>{let i=ls(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),ms(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):W(r,r=>{let i=ls(r,this,e,!n);ms(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)):W(n,n=>{bs(n,ls(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)):W(r,r=>{let i=ls(r,this,e,!1);i.right!==null&&hs(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):W(this.doc,t=>{qo(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):W(this.doc,n=>{Jo(n,this,e,t)})}getAttribute(e){return Yo(this,e)}getAttributes(){return Xo(this)}_write(e){e.writeTypeRef(nc)}},Cs=e=>new Ss,ws=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??G()}[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===Ds||t.constructor===Ts)&&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})}},Ts=class e extends K{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 K?e.clone():e)),t}get length(){return this.doc??G(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ws(this,e)}querySelector(e){e=e.toUpperCase();let t=new ws(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),S(new ws(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Po(this,e,new ks(this,t,e))}toString(){return zo(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),Ro(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):W(this.doc,n=>{Wo(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)W(this.doc,n=>{let r=e&&e instanceof K?e._item:e;Ho(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 k(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):W(this.doc,n=>{Ko(n,this,e,t)})}toArray(){return Io(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Vo(this,e)}slice(e=0,t=this.length){return Fo(this,e,t)}forEach(e){Ro(this,e)}_write(e){e.writeTypeRef(ic)}},Es=e=>new Ts,Ds=class e extends Ts{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 vn(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof K?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):W(this.doc,t=>{qo(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):W(this.doc,n=>{Jo(n,this,e,t)})}getAttribute(e){return Yo(this,e)}hasAttribute(e){return Zo(this,e)}getAttributes(e){return e?Qo(this,e):Xo(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 Ro(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(rc),e.writeKey(this.nodeName)}},Os=e=>new Ds(e.readKey()),ks=class extends wo{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)})}},As=class e extends is{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(ac),e.writeKey(this.hookName)}},js=e=>new As(e.readKey()),Ms=class e extends Ss{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(oc)}},Ns=e=>new Ms,Ps=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw A()}mergeWith(e){return!1}write(e,t,n){throw A()}integrate(e,t){throw A()}},Fs=0,q=class extends Ps{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),qa(e.doc.store,this)}write(e,t){e.writeInfo(Fs),e.writeLen(this.length-t)}getMissing(e,t){return null}},Is=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 A()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Ls=e=>new Is(e.readBuf()),Rs=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){Hi(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}},zs=e=>new Rs(e.readLen()),Bs=(e,t)=>new Yi({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Vs=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 A()}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}},Hs=e=>new Vs(Bs(e.readString(),e.readAny())),Us=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 A()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Ws=e=>new Us(e.readJSON()),J=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 A()}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}},Gs=e=>new J(e.readKey(),e.readJSON()),Ks=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}},qs=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 Ks(n)},Js=Fn(`node_env`)===`development`,Ys=class e{constructor(e){this.arr=e,Js&&Tn(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}},Xs=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Ys(n)},Zs=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}},Qs=e=>new Zs(e.readString()),$s=[ns,as,Cs,Os,Es,js,Ns],ec=0,tc=1,nc=2,rc=3,ic=4,ac=5,oc=6,sc=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 A()}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}},cc=e=>new sc($s[e.readTypeRef()](e)),lc=(e,t)=>{let n=t,r=0,i;do r>0&&(n=B(n.client,n.clock+r)),i=Ja(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Y);return{item:i,diff:r}},uc=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},dc=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Y(B(r,i+n),t,B(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=B(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},fc=(e,t)=>Pe(e,e=>zi(e.deletions,t)),pc=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return U(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||pc(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=U(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:U(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:U(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||zi(r,d.right.id)||fc(a.undoStack,d.right.id)||fc(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=U(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;d!==null&&d.parent._item!==u&&(d=p._map.get(t.parentSub)||null)}let m=B(c,V(s,c)),h=new Y(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,uc(h,!0),h.integrate(e,0),h},Y=class e extends Ps{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>=V(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=V(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Ea&&this.id.client!==this.parent.client&&this.parent.clock>=V(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Xa(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=U(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===q||this.right&&this.right.constructor===q)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===Ea){let e=Ja(n,this.parent);e.constructor===q?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Xa(e,e.doc.store,B(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),Da(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(Da(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Ja(e.doc.store,n.origin)))r.has(Ja(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),qa(e.doc.store,this),this.content.integrate(e,this),to(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new q(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:B(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Da(e.origin,this.lastId)&&this.right===e&&Da(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(),Hi(e.deleteSet,this.id.client,this.id.clock,this.length),to(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw j();this.content.gc(e),t?Za(e,this,new q(this.id,this.length)):this.content=new Rs(this.length)}write(e,t){let n=t>0?B(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=Oa(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===Ea?(e.writeParentInfo(!1),e.writeLeftID(t)):j();i!==null&&e.writeString(i)}this.content.write(e,t)}},mc=(e,t)=>hc[t&31](e),hc=[()=>{j()},zs,qs,Ls,Qs,Ws,Gs,cc,Xs,Hs,()=>{j()}],gc=10,X=class extends Ps{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){j()}write(e,t){e.writeInfo(gc),D(e.restEncoder,this.length-t)}getMissing(e,t){return null}},_c=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},vc=`__ $YJS$ __`;_c[vc]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),_c[vc]=!0;var yc=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),bc=(e,t)=>{D(e,yc.Token),wt(e,t)},xc=(e,t,n,r)=>{switch(N(e)){case yc.Token:t();break;case yc.PermissionDenied:n(qt(e));break;case yc.Authenticated:r(qt(e));break;default:}},Sc=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),Cc=`\0`;function wc(e,t){return e+Cc+t}function Tc(e){let t=e.indexOf(Cc);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Ec=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 Dc(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 Oc(e){return new Promise(t=>setTimeout(t,e))}function kc(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 Ac(e,t){let n=Dc(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||kc;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 Oc(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 Oc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await Oc(e)}return a()}var jc=Math.floor,Mc=(e,t)=>e<t?e:t,Nc=(e,t)=>e>t?e:t;Number.isNaN;var Pc=64,Fc=128,Ic=1<<17,Lc=1<<18,Rc=1<<19,zc=1<<20,Bc=1<<21,Vc=1<<22,Hc=1<<23,Uc=1<<24,Wc=1<<25,Gc=1<<26,Kc=1<<27,qc=1<<28,Jc=1<<29,Yc=1<<30,Xc=63,Zc=127;Ic-1,Lc-1,Rc-1,zc-1,Bc-1,Vc-1,Hc-1,Uc-1,Wc-1,Gc-1,Kc-1,qc-1,Jc-1,Yc-1;var Qc=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var $c=()=>new Set,el=Array.from;Array.isArray;var tl=String.fromCharCode;String.fromCodePoint,tl(65535);var nl=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},rl=typeof TextEncoder<`u`?new TextEncoder:null,il=rl?e=>rl.encode(e):nl,al=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});al&&al.decode(new Uint8Array).length===1&&(al=null);var ol=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},sl=()=>new ol,cl=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},ll=e=>{let t=new Uint8Array(cl(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},ul=(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},Z=(e,t)=>{for(;t>Zc;)ul(e,Fc|Zc&t),t=jc(t/128);ul(e,Zc&t)},dl=new Uint8Array(3e4),fl=dl.length/3,pl=rl&&rl.encodeInto?(e,t)=>{if(t.length<fl){let n=rl.encodeInto(t,dl).written||0;Z(e,n);for(let t=0;t<n;t++)ul(e,dl[t])}else hl(e,il(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Z(e,r);for(let t=0;t<r;t++)ul(e,n.codePointAt(t))},ml=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Mc(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(Nc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},hl=(e,t)=>{Z(e,t.byteLength),ml(e,t)},gl=e=>Error(e),_l=gl(`Unexpected end of array`),vl=gl(`Integer out of Range`),yl=class{constructor(e){this.arr=e,this.pos=0}},bl=e=>new yl(e),xl=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Sl=e=>xl(e,wl(e)),Cl=e=>e.arr[e.pos++],wl=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&Zc)*n,n*=128,r<Fc)return t;if(t>Qc)throw vl}throw _l},Tl=e=>{let t=e.arr[e.pos++],n=t&Xc,r=64,i=(t&Pc)>0?-1:1;if((t&Fc)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&Zc)*r,r*=128,t<Fc)return i*n;if(n>Qc)throw vl}throw _l},El=al?e=>al.decode(Sl(e)):e=>{let t=wl(e);if(t===0)return``;{let n=String.fromCodePoint(Cl(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Cl(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))}},Dl=e=>{let t=e.pos,n=El(e);return e.pos=t,n},Ol=Date.now,kl=()=>new Map,Al=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},jl=class{constructor(){this._observers=kl()}on(e,t){Al(this._observers,e,$c).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 el((this._observers.get(e)||kl()).values()).forEach(e=>e(...t))}destroy(){this._observers=kl()}},Ml=Symbol(`Equality`),Nl=Object.keys,Pl=e=>Nl(e).length,Fl=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Il=(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[Ml]!=null)return e[Ml](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)||!Il(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(!Fl(e,n)||!Il(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(!Il(e[n],t[n]))return!1;break;default:return!1}return!0},Ll=3e4,Rl=class extends jl{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Ol();this.getLocalState()!==null&&Ll/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&Ll<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&zl(this,t,`timeout`)},jc(Ll/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:Ol()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Il(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}},zl=(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:Ol()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},Bl=(e,t,n=e.states)=>{let r=t.length,i=sl();Z(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;Z(i,r),Z(i,s),pl(i,JSON.stringify(o))}return ll(i)},Vl=(e,t,n)=>{let r=bl(t),i=Ol(),a=[],o=[],s=[],c=[],l=wl(r);for(let t=0;t<l;t++){let t=wl(r),n=wl(r),l=JSON.parse(El(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&&(Il(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])},Hl=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={}}},Ul=class{constructor(e){this.data=e,this.encoder=sl(),this.decoder=bl(new Uint8Array(this.data))}peekVarString(){return Dl(this.decoder)}readVarUint(){return wl(this.decoder)}readVarString(){return El(this.decoder)}readVarUint8Array(){return Sl(this.decoder)}writeVarUint(e){return Z(this.encoder,e)}writeVarString(e){return pl(this.encoder,e)}writeVarUint8Array(e){return hl(this.encoder,e)}length(){return cl(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}({}),Wl=class{constructor(){this.encoder=sl()}get(e){return e.encoder}toUint8Array(){return ll(this.encoder)}},Gl=class extends Wl{constructor(...e){super(...e),this.type=Q.CLOSE,this.description=`Ask the server to close the connection`}get(e){return pl(this.encoder,e.documentName),Z(this.encoder,this.type),this.encoder}},Kl=class e extends Hl{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(Gl,{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:Ac(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=Ol();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Q.Ping){this.sendPong();return}let n=new Ul(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=sl();Z(e,Q.Pong),this.send(ll(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>=Ol()-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=bl(e);return{documentName:El(t),messageType:wl(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===Ec.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()}},ql=0,Jl=1,Yl=2,Xl=(e,t)=>{Z(e,ql),hl(e,ba(t))},Zl=(e,t,n)=>{Z(e,Jl),hl(e,ma(t,n))},Ql=(e,t,n)=>Zl(t,n,Sl(e)),$l=(e,t,n,r)=>{try{da(t,Sl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},eu=(e,t)=>{Z(e,Yl),hl(e,t)},tu=$l,nu=(e,t,n,r,i)=>{let a=wl(e);switch(a){case ql:Ql(e,t,n);break;case Jl:$l(e,n,r,i);break;case Yl:tu(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},ru=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(El(n.decoder));break;case Q.SyncStatus:this.applySyncStatusMessage(e,Tl(n.decoder)===1);break;case Q.CLOSE:let i={code:1e3,reason:El(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(Wl,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Q.Sync);let r=nu(n.decoder,n.encoder,e.document,e);t&&r===Jl&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;Vl(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;xc(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(Bl(e.awareness,Array.from(e.awareness.getStates().keys())))}},iu=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return ll(this.encoder)}send(e){e?.send(this.create())}},au=`4.0.0-rc.1`,ou=class extends Wl{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 pl(this.encoder,e.documentName),Z(this.encoder,this.type),bc(this.encoder,e.token),pl(this.encoder,au),this.encoder}},su=class extends Wl{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`);pl(this.encoder,e.documentName),Z(this.encoder,this.type);let t;return t=e.states===void 0?Bl(e.awareness,e.clients):Bl(e.awareness,e.clients,e.states),hl(this.encoder,t),this.encoder}},cu=class extends Wl{constructor(...e){super(...e),this.type=Q.Stateless,this.description=`A stateless message`}get(e){return pl(this.encoder,e.documentName),Z(this.encoder,this.type),pl(this.encoder,e.payload??``),this.encoder}},lu=class extends Wl{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 pl(this.encoder,e.documentName),Z(this.encoder,this.type),Xl(this.encoder,e.document),this.encoder}},uu=class extends Wl{constructor(...e){super(...e),this.type=Q.Sync,this.description=`A document update`}get(e){return pl(this.encoder,e.documentName),Z(this.encoder,this.type),eu(this.encoder,e.update),this.encoder}},du=class extends Error{constructor(...e){super(...e),this.code=1001}},fu=class extends Hl{get effectiveName(){return this.configuration.sessionAwareness?wc(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 Yi,this.configuration.awareness=e.awareness===void 0?new Rl(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:Sc(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Sc(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 Kl(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(lu,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&zl(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(cu,{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(ou,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(uu,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(su,{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(lu,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(su,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new iu(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new Ul(e.data),{documentName:n}=Tc(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new Ul(e.data)}),new ru(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&zl(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&&(zl(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 du(`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 pu(e,t,n=null,r=null){let i={...be()};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 mu(e,t,n){let r=(0,xe.c)(5),i,a;r[0]!==e||r[1]!==t||r[2]!==n?(i=()=>{!e||!n||typeof e.setLanguagePreference==`function`&&e.setLanguagePreference(t??`system`).catch(e=>{console.warn(JSON.stringify({event:`language-preference-push-failed`,preference:t??`system`,error:e instanceof Error?e.message:String(e)}))})},a=[e,t,n],r[0]=e,r[1]=t,r[2]=n,r[3]=i,r[4]=a):(i=r[3],a=r[4]),(0,v.useEffect)(i,a)}function hu(e){let t=/^rgba?\(([^)]*)\)$/i.exec(e.trim())?.[1];if(t===void 0)return null;let n=t.split(/[\s,/]+/).filter(Boolean);if(n.length<3)return null;let r=`#`;for(let e=0;e<3;e++){let t=Math.round(Number(n[e]));if(!Number.isFinite(t)||t<0||t>255)return null;r+=t.toString(16).padStart(2,`0`)}return r}function gu(e){if(typeof document>`u`)return null;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return null;t.fillStyle=`#000000`,t.fillStyle=e;let n=t.fillStyle;return t.fillStyle=`#ffffff`,t.fillStyle=e,t.fillStyle===n&&typeof n==`string`&&/^#[0-9a-f]{6}$/i.test(n)?n.toLowerCase():null}function _u(e){return gu(e)??hu(e)}function vu(e){let t=document.createElement(`span`);t.style.display=`none`,t.style.backgroundColor=`var(${e})`,document.body.appendChild(t);try{let e=getComputedStyle(t).backgroundColor;return!e||e===`rgba(0, 0, 0, 0)`||e.includes(`var(`)?null:_u(e)}finally{t.remove()}}function yu(){if(!(typeof document>`u`))try{let e=vu(`--sidebar`),t=vu(`--sidebar-foreground`);return!e||!t?void 0:{bg:e,symbol:t}}catch{return}}function bu(e,t,n){let r=(0,xe.c)(10),i;r[0]!==e||r[1]!==t?(i=()=>{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,chrome:yu()})}),()=>{n=!0}},r[0]=e,r[1]=t,r[2]=i):i=r[2];let a;r[3]!==e||r[4]!==n||r[5]!==t?(a=[e,t,n],r[3]=e,r[4]=n,r[5]=t,r[6]=a):a=r[6],(0,v.useEffect)(i,a);let o,s;r[7]===e?(o=r[8],s=r[9]):(o=()=>{if(!e)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`),n=t=>{e.signalThemeApplied({reducedTransparency:t.matches,chrome:yu()})};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},s=[e],r[7]=e,r[8]=o,r[9]=s),(0,v.useEffect)(o,s)}function xu(e){return{authoritative:e,themes:ne,warnings:[],truncated:!1}}function Su(e){let{scheme:t}=e;return{id:e.id,label:t.name,kind:t.variant,scheme:t,toTokens:()=>g(t)}}function Cu(e,t){return{id:e,label:t.name,kind:t.variant,scheme:t,toTokens:()=>g(t)}}function wu(e,t,n={}){console.warn(JSON.stringify({event:`ok-saved-theme-request-failed`,action:e,result:t,...n.status===void 0?{}:{status:n.status},...n.error===void 0?{}:{errorName:n.error instanceof Error?n.error.name:`UnknownError`}}))}async function Tu(e={}){let t=e.request??globalThis.fetch;try{let n=await t(`/api/saved-themes`,{signal:e.signal});if(!n.ok)return wu(`list`,`http-error`,{status:n.status}),xu(!1);let r=fe.safeParse(await n.json());if(!r.success)return console.warn(`[themes] saved-themes response failed schema validation`,r.error.issues),xu(!1);let i=[],a=[];for(let e of r.data.themes)e.ok?i.push(Su(e)):a.push({filename:e.filename,id:e.id,code:e.code,...e.conflictingFilenames?{conflictingFilenames:e.conflictingFilenames}:{}});return{authoritative:!0,themes:i.length===0?ne:[...ne,...i],warnings:a,truncated:r.data.truncated}}catch(t){return e.signal?.aborted||wu(`list`,`request-error`,{error:t}),xu(!1)}}function Eu(e){switch(e.detail){case`empty`:case`too-long`:case`invalid-chars`:return e.detail;default:return}}async function Du(e,t={}){let n=f.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=s.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=m.safeParse(t);if(!i.success)return{ok:!1,reason:`unexpected`};if(i.data.type===`urn:ok:error:theme-name-taken`)return{ok:!1,reason:`name-taken`};if(i.data.type===`urn:ok:error:theme-name-invalid`){let e=Eu(i.data);return e?{ok:!1,reason:`name-invalid`,detail:e}:{ok:!1,reason:`name-invalid`}}return{ok:!1,reason:`unexpected`}}catch(e){return wu(`save`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function Ou(e,t={}){let n=l.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=p.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=m.safeParse(t);return i.success&&i.data.type===`urn:ok:error:not-found`?{ok:!1,reason:`not-found`}:{ok:!1,reason:`unexpected`}}catch(e){return wu(`update`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function ku(e,t={}){if(!oe(e).ok)return{ok:!1,reason:`unexpected`};let n=t.request??globalThis.fetch;try{let t=await n(`/api/saved-theme?${new URLSearchParams({id:e})}`,{method:`DELETE`}),r=await t.json().catch(()=>null);if(!t.ok)return{ok:!1,reason:`unexpected`};let i=d.safeParse(r);if(!i.success)return{ok:!1,reason:`unexpected`};if(!i.data.existed)return{ok:!0,existed:!1};let a=c.safeParse(i.data.scheme);return a.success?{ok:!0,existed:!0,filename:i.data.filename,scheme:a.data}:{ok:!1,reason:`unexpected`}}catch(e){return wu(`delete`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}var Au=(0,v.createContext)(null);function ju(e){let t=(0,xe.c)(20),{children:n}=e,r=De(),[i,a]=(0,v.useState)(Pu),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(`custom`),[f,p]=(0,v.useState)(!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={},t[0]=m):m=t[0];let h=(0,v.useRef)(m),ee;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(ee={},t[1]=ee):ee=t[1];let[te,ne]=(0,v.useState)(ee),g=(0,v.useRef)(0),re;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{let e=0,t=null,n=!1,r=null,i,o=[250,1e3,4e3],c=()=>{i!==void 0&&clearTimeout(i),i=void 0},u=()=>{if(t)return n=!0,t;let i=e,o=(async()=>{let t;do{n=!1;let o=g.current,u=new AbortController;r=u;let{authoritative:d,...f}=await Tu({signal:u.signal});if(i!==e)return!1;t=d,d?(c(),o===g.current&&a(f),s(!0),l(!1)):l(!0)}while(n);return t})().finally(()=>{t===o&&(t=null)});return t=o,o};return{refresh:u,startAutomaticRetry:()=>{e+=1;let a=e;r?.abort(),r=null,t=null,n=!1,c();let s=async t=>{let n=await u();a!==e||n||t>=o.length||(i=setTimeout(()=>void s(t+1),o[t]))};return s(0),()=>{a===e&&(e+=1,r?.abort(),r=null,t=null,n=!1,c())}}}},t[2]=re):re=t[2];let[ie]=(0,v.useState)(re),ae=ie.refresh,oe;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>{let e=new Map,t=(t,n)=>{let r=(e.get(t)??Promise.resolve()).then(n,n),i=r.then(Nu,Mu);return e.set(t,i),i.finally(()=>{e.get(t)===i&&e.delete(t)}),r},n=(e,t,n)=>{g.current+=1;let r=Cu(e,t);a(t=>({...t,themes:t.themes.some(t=>t.id===e)?t.themes.map(t=>t.id===e?r:t):[...t.themes,r],warnings:t.warnings.filter(t=>t.id!==e&&(n===void 0||t.filename!==n))}))};return{updateTheme:e=>t(e.id,async()=>{let t=await Ou(e);return t.ok&&n(e.id,e.scheme,t.filename),t}),deleteTheme:e=>t(e,async()=>{let t=await ku(e);if(t.ok){let t={...h.current,[e]:(h.current[e]??0)+1};h.current=t,ne(t),g.current+=1,a(t=>({...t,themes:t.themes.filter(t=>t.id!==e),warnings:t.warnings.filter(t=>t.id!==e)}))}return t}),restoreTheme:e=>t(e.id,async()=>{let t=await Du({name:e.name,stem:e.stem,scheme:e.scheme,extension:e.extension});return t.ok&&n(t.id,e.scheme,t.filename),t})}},t[3]=oe):oe=t[3];let[se]=(0,v.useState)(oe),_;t[4]===ie?_=t[5]:(_=()=>ie.startAutomaticRetry(),t[4]=ie,t[5]=_);let ce;t[6]!==ie||t[7]!==r?(ce=[ie,r],t[6]=ie,t[7]=r,t[8]=ce):ce=t[8],(0,v.useEffect)(_,ce);let le;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(le=function(e){if(e===null){p(!1);return}d(e),p(!0)},t[9]=le):le=t[9];let ue=le,de;return t[10]!==n||t[11]!==i||t[12]!==u||t[13]!==c||t[14]!==o||t[15]!==se||t[16]!==ae||t[17]!==f||t[18]!==te?(de=(0,v.createElement)(Au,{value:{...i,loaded:o,loadError:c,refresh:ae,...se,editingThemeId:u,themeIncarnations:te,themeEditorOpen:f,selectThemeToEdit:ue}},n),t[10]=n,t[11]=i,t[12]=u,t[13]=c,t[14]=o,t[15]=se,t[16]=ae,t[17]=f,t[18]=te,t[19]=de):de=t[19],de}function Mu(){}function Nu(){}function Pu(){return xu(!1)}function Fu(){let e=(0,v.use)(Au);if(!e)throw Error(`useSavedThemes must be used within <SavedThemesProvider />`);return e}var Iu={en:()=>t(()=>import(`./messages-ChE4ifHJ.js`).then(e=>e.n),__vite__mapDeps([0,1]),import.meta.url),"zh-Hans":()=>t(()=>import(`./messages-BiqhEyiZ.js`),[],import.meta.url),"zh-Hant":()=>t(()=>import(`./messages-CWuRF_g4.js`),[],import.meta.url),hi:()=>t(()=>import(`./messages-D-dvdC6u.js`),[],import.meta.url),es:()=>t(()=>import(`./messages-B6xCk04J.js`),[],import.meta.url),ar:()=>t(()=>import(`./messages-BdOR8jpl.js`),[],import.meta.url),fr:()=>t(()=>import(`./messages-D3F4EU1O.js`),[],import.meta.url),bn:()=>t(()=>import(`./messages-Dwk3zwPu.js`),[],import.meta.url),"pt-BR":()=>t(()=>import(`./messages-Dr79fPY9.js`),[],import.meta.url),id:()=>t(()=>import(`./messages-6l97Z9l-.js`),[],import.meta.url),ur:()=>t(()=>import(`./messages-D7hPscmx.js`),[],import.meta.url),ko:()=>t(()=>import(`./messages-Debu1u7T.js`),[],import.meta.url)},Lu=new Set([`en`]),Ru=`en`;async function zu(e){if(Ru=e,!Lu.has(e)){let{default:t}=await Iu[e]();me.load(e,t.messages),Lu.add(e)}Ru===e&&me.activate(e)}function Bu(){return!1}async function Vu(){}var Hu=`ok-locale-load-failed`;function Uu(){window.location.reload()}function Wu({locale:e,reload:t=Uu}){let n=new Intl.DisplayNames([me.locale],{type:`language`}).of(e)??e;pe.error(me._({id:`loE6tM`,values:{language:n}}),{id:Hu,description:me._({id:`GtPGNJ`}),duration:1/0,action:{label:me._({id:`HpK_8d`}),onClick:t}})}function Gu(){pe.dismiss(Hu)}var Ku=`ok-language-v1`;function qu({preference:e,locale:t}){if(typeof document>`u`)return;let n=_(t),r=document.documentElement;r.lang=t,r.dir=n;try{localStorage.setItem(Ku,JSON.stringify({pref:e,locale:t,dir:n}))}catch{}}function Ju(e){return e===`system`?`system`:ae.includes(e)?e:void 0}function Yu(){if(!(typeof localStorage>`u`))try{let e=localStorage.getItem(Ku);return e===null?void 0:Ju(JSON.parse(e).pref)}catch{return}}function Xu(e){let t=(0,xe.c)(4),{preference:n,userConfigSynced:r}=e,i,a;t[0]!==n||t[1]!==r?(i=()=>{if(Bu()){Vu().catch(Zu);return}if(!r)return;let{locale:e}=h({override:void 0,storedPreference:n,preferenceList:de(),supportedLocales:ae,autoDetectableLocales:ee}),t=!1;return zu(e).then(()=>{t||(Gu(),qu({preference:n??`system`,locale:e}))}).catch(n=>{console.warn(JSON.stringify({event:`ok-locale-activate-failed`,locale:e,error:String(n)})),!t&&Wu({locale:e})}),()=>{t=!0}},a=[n,r],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,v.useEffect)(i,a)}function Zu(e){console.warn(JSON.stringify({event:`ok-pseudo-locale-activate-failed`,error:String(e)}))}function Qu(e){let t=(0,xe.c)(5),{setTheme:n}=i(),r;t[0]!==n||t[1]!==e?(r=()=>{(e===`light`||e===`dark`||e===`system`)&&n(e)},t[0]=n,t[1]=e,t[2]=r):r=t[2];let a;t[3]===e?a=t[4]:(a=[e],t[3]=e,t[4]=a),(0,v.useEffect)(r,a)}var $u=n();function ed(e,t,n,r){console.warn(JSON.stringify({event:`ok-${e}-${n}`,docName:t,code:r?.code,reason:r?.reason??void 0}))}function td(e,t,n,r){let i=new Yi,a=new fu({url:e,name:t,document:i,token:pu(null,r,null),onDisconnect:({event:e})=>ed(`config-provider`,t,`disconnect`,e),onClose:({event:e})=>ed(`config-provider`,t,`close`,e)}),o=se(a,n);return{binding:o,config:o.current(),cleanup:()=>{o.dispose(),a.destroy(),i.destroy()}}}function nd(e,t){let n=new Yi,r=new fu({url:e,name:ce,document:n,token:pu(null,t,null),onDisconnect:({event:e})=>ed(`okignore-provider`,ce,`disconnect`,e),onClose:({event:e})=>ed(`okignore-provider`,ce,`close`,e)}),i=re(r);return{binding:i,provider:r,cleanup:()=>{i.dispose(),r.destroy(),n.destroy()}}}function rd(e){let t=(0,xe.c)(24),{collabUrl:n,children:r}=e,{themes:a,loaded:s,loadError:c}=Fu(),l=De(),{systemTheme:d}=i(),f=d===`dark`,[p,m]=(0,v.useState)(null),[h,ee]=(0,v.useState)(null),[ne,g]=(0,v.useState)(null),[re,ae]=(0,v.useState)(null),oe,se;t[0]!==n||t[1]!==l?(oe=()=>{if(n===null)return;let e=td(n,te,`user`,l),t=td(n,ue,`project`,l),r=td(n,ie,`project-local`,l),i=nd(n,l);m({binding:e.binding,config:e.config,synced:e.binding.hasSynced()}),ee({binding:t.binding,config:t.config,synced:t.binding.hasSynced()}),g({binding:r.binding,config:r.config,synced:r.binding.hasSynced()}),ae({binding:i.binding,synced:!1});let a=e.binding.subscribe(t=>{m(n=>n?.binding===e.binding?{...n,config:t}:n)}),o=e.binding.subscribeSynced(()=>{m(t=>t?.binding===e.binding?{...t,config:e.binding.current(),synced:!0}:t)}),s=t.binding.subscribe(e=>{ee(n=>n?.binding===t.binding?{...n,config:e}:n)}),c=t.binding.subscribeSynced(()=>{ee(e=>e?.binding===t.binding?{...e,config:t.binding.current(),synced:!0}:e)}),u=r.binding.subscribe(e=>{g(t=>t?.binding===r.binding?{...t,config:e}:t)}),d=r.binding.subscribeSynced(()=>{g(e=>e?.binding===r.binding?{...e,config:r.binding.current(),synced:!0}:e)}),f=()=>{ae(e=>e?.binding===i.binding?{...e,synced:!0}:e)};return i.provider.on(`synced`,f),()=>{a(),o(),s(),c(),u(),d(),i.provider.off(`synced`,f);for(let n of[e,t,r,i])try{n.cleanup()}catch(e){console.warn(JSON.stringify({event:`ok-config-provider-cleanup-error`,error:String(e)}))}m(t=>t?.binding===e.binding?null:t),ee(e=>e?.binding===t.binding?null:e),g(e=>e?.binding===r.binding?null:e),ae(e=>e?.binding===i.binding?null:e)}},se=[n,l],t[0]=n,t[1]=l,t[2]=oe,t[3]=se):(oe=t[2],se=t[3]),(0,v.useEffect)(oe,se);let _=p&&h?le(p.config,h.config,ne?.config):null,ce=_?.appearance?.theme,de=_?.appearance?.customTheme,fe=_?.appearance?.colorThemeEnabled!==!1,pe=n===null||p?.synced===!0&&h?.synced===!0&&ne?.synced===!0,me=[_?.appearance?.colorThemeLight,_?.appearance?.colorThemeDark,_?.appearance?.colorTheme],be=fe&&me.some(id),Se=pe&&(!be||s),Ce=pe&&(!be||s||c),we=u(_?.appearance,a),Te=o(ce,f),Ee=fe?we[Te]:`default`,y=Ee===`custom`?ge(ve(de)):he(Ee,a)??ce;Qu(Se?y:void 0),ye({selection:we,modePreference:ce,slotMode:Te,customSeed:de,themes:a,enabled:fe,ready:Se}),Xu({preference:_?.appearance?.language,userConfigSynced:p?.synced??!1}),mu(typeof window<`u`?window.okDesktop:void 0,_?.appearance?.language,p?.synced??!1);let Oe=Ee.startsWith(`saved-`)?a.find(e=>e.id===Ee)?.scheme:void 0,b=Ee===`custom`?JSON.stringify(de??null):Oe?JSON.stringify(Oe):``,ke;t[4]!==Ce||t[5]!==Se||t[6]!==y?(ke=Ce&&!Se&&typeof document<`u`?document.documentElement.classList.contains(`dark`)?`dark`:`light`:y??`system`,t[4]=Ce,t[5]=Se,t[6]=y,t[7]=ke):ke=t[7];let Ae=ke;bu(Ce&&typeof window<`u`?window.okDesktop:void 0,Ce?Ae:void 0,`${Ee}:${b}`);let x=p?.binding??null,je=p?.synced??!1,Me=h?.binding??null,S=ne?.binding??null,Ne=re?.binding??null,Pe=re?.synced??!1,Fe=p?.config??null,Ie=h?.config??null,Le=h?.synced??!1,Re=ne?.config??null,C=ne?.synced??!1,ze;t[8]!==_||t[9]!==Fe||t[10]!==Ie||t[11]!==Le||t[12]!==Re||t[13]!==C||t[14]!==x||t[15]!==je||t[16]!==Me||t[17]!==S||t[18]!==Ne||t[19]!==Pe?(ze={userBinding:x,userSynced:je,projectBinding:Me,projectLocalBinding:S,okignoreBinding:Ne,okignoreSynced:Pe,userConfig:Fe,projectConfig:Ie,projectSynced:Le,projectLocalConfig:Re,projectLocalSynced:C,merged:_},t[8]=_,t[9]=Fe,t[10]=Ie,t[11]=Le,t[12]=Re,t[13]=C,t[14]=x,t[15]=je,t[16]=Me,t[17]=S,t[18]=Ne,t[19]=Pe,t[20]=ze):ze=t[20];let Be=ze,w;return t[21]!==r||t[22]!==Be?(w=(0,$u.jsx)(_e,{value:Be,children:r}),t[21]=r,t[22]=Be,t[23]=w):w=t[23],w}function id(e){return typeof e==`string`&&e.startsWith(`saved-`)}function ad(e){let t=(0,xe.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$u.jsx)(ju,{children:(0,$u.jsx)(rd,{...e})}),t[0]=e,t[1]=n),n}export{k as $,ma as A,Lo as B,Ra as C,Ia as D,Ma as E,ka as F,F as G,z as H,Li as I,jn as J,Hn as K,ja as L,H as M,Oa as N,Va as O,zi as P,an as Q,Ha as R,za as S,B as T,oi as U,hi as V,si as W,_n as X,xn as Y,ln as Z,Ss as _,Fu as a,Re as at,da as b,fu as c,b as ct,sc as d,A as et,Yi as f,lo as g,Ba as h,Xu as i,Be as it,ba as j,ga as k,J as l,Te as lt,Aa as m,Ju as n,et as nt,bu as o,x as ot,Y as p,Bn as q,Yu as r,w as rt,pu as s,y as st,ad as t,j as tt,Zs as u,Ds as v,Ui as w,ua as x,Ms as y,W as z};
|
|
@@ -170,7 +170,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
170
170
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
171
171
|
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=du(uu(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=du(uu(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function hu(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new ou||null,prettyErrors:t}}function gu(e,t={}){let{lineCounter:n,prettyErrors:r}=hu(t),i=new mu(n?.addNewLine),a=new Kl(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new cl(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(ul(e,n)),o.warnings.forEach(ul(e,n))),o}function _u(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=gu(e,n);if(!i)return null;if(i.warnings.forEach(e=>Ws(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}var vu=[`off`,`follow`,`full`],yu=[`follow`,`full`],bu=`pull`,xu=[`off`,`follow`,`full`,bu],Su=[`follow`,`full`,bu];function Cu(e){return e===bu?`follow`:wu(e)?e:null}function wu(e){return typeof e==`string`&&vu.includes(e)}function Tu(e){return typeof e==`string`&&yu.includes(e)}function Eu(e){let t=e?.resumeMode;return t===bu?`follow`:Tu(t)?t:null}function Du(e){return Mu(e)===`off`&&Eu(e)!==null}function Ou(e){let t=Mu(e);return t===`follow`||t===`full`||Du(e)}function ku(e){let t=Mu(e);return Tu(t)?t:Eu(e)??`full`}function Au(e){return e===!0?`full`:e===!1?`off`:null}function ju(e){return e===!0?`full`:e===!1?`off`:Cu(e)}function Mu(e){let t=Cu(e?.mode);return t===null?Au(e?.enabled):t}var Nu={sh:`bash`,zsh:`bash`,bash:`bash`,c:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,"c++":`cpp`,h:`c`,hh:`cpp`,hpp:`cpp`,cs:`csharp`,css:`css`,less:`less`,scss:`scss`,sass:`scss`,diff:`diff`,patch:`diff`,feature:`gherkin`,go:`go`,gql:`graphql`,graphql:`graphql`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`ini`,java:`java`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,kt:`kotlin`,kts:`kotlin`,lua:`lua`,makefile:`makefile`,md:`markdown`,mdx:`markdown`,m:`objectivec`,mm:`objectivec`,pl:`perl`,pm:`perl`,php:`php`,phtml:`php`,py:`python`,pyi:`python`,pyx:`python`,r:`r`,rb:`ruby`,rs:`rust`,sql:`sql`,swift:`swift`,ts:`typescript`,tsx:`typescript`,xml:`xml`,yaml:`yaml`,yml:`yaml`},Pu=new Set(Object.keys(Nu));function Fu(e){return Nu[e.toLowerCase().replace(/^\./,``)]??null}var Iu=new Set([`md`,`mdx`,`mmd`,`mermaid`]),Lu=new Set([...Pu,`txt`,`text`,`csv`,`tsv`,`log`,`toml`,`html`,`htm`,`svg`,`vue`,`svelte`,`astro`,`lock`].filter(e=>!Iu.has(e))),Ru={html:`html`,htm:`html`,svg:`xml`,vue:`html`,svelte:`html`,astro:`html`,lock:`yaml`};function zu(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:Lu.has(t.slice(n+1).toLowerCase())}var Bu=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],Vu=[`video/mp4`,`video/webm`,`video/ogg`],Hu=[`audio/mpeg`,`audio/wav`,`audio/ogg`],Uu=[`application/pdf`],Wu=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`]),Gu=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`]),Ku=new Set([`pdf`]),qu=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]),Ju=new Set(`pdf.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),Yu=new Set(`png.jpg.jpeg.gif.webp.avif.svg.apng.heic.heif.tiff.bmp.ico.pdf.mp4.webm.mov.m4v.mkv.avi.flv.wmv.mpeg.mpg.mp3.wav.ogg.m4a.flac.aac.opus.zip.7z.tar.gz.rar.woff.woff2.ttf.otf.eot.docx.xlsx.pptx.doc.xls.ppt.odt.ods.odp.pages.numbers.key.epub.mobi.csv.tsv.txt.rtf.json.yaml.yml.xml.toml.lock.gpx.html.htm`.split(`.`)),Xu=new Set(`png.jpg.jpeg.gif.webp.avif.apng.heic.heif.tiff.bmp.ico.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.json.toml.lock`.split(`.`)),Zu=`wikiembed`,Qu=`toast`,$u=new Set(`png.jpg.jpeg.gif.webp.avif.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),ed=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`],td=[`mp4`,`webm`,`mov`,`m4v`],nd=[`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`],rd=[`pdf`],id=[`json`,`toml`,`lock`];function ad(e,t,n){for(let r of t)if(!n.has(r))throw Error(`${e}: ${r} is not present in canonical upload constants`)}ad(`SIDEBAR_IMAGE_ASSET_EXTENSIONS`,ed,Wu),ad(`SIDEBAR_VIDEO_ASSET_EXTENSIONS`,td,Gu),ad(`SIDEBAR_AUDIO_ASSET_EXTENSIONS`,nd,qu),ad(`SIDEBAR_PDF_ASSET_EXTENSIONS`,rd,Ku),ad(`FILE_ATTACHMENT_EXTENSIONS`,[...Ju],$u),ad(`WIKI_EMBED_EXTENSIONS`,[...$u],Yu);var od=new Set(ed),sd=new Set(td),cd=new Set(nd),ld=new Set(rd),ud=new Set(id);ad(`SIDEBAR_RENDERABLE_ASSET_EXTENSIONS`,[...new Set([...ed,...td,...nd,...rd,...id])],Xu);var dd=new Set([`base`,`canvas`]),fd=new Set([`mmd`,`mermaid`]);function pd(e){let t=e.lastIndexOf(`.`);return t<0?!1:fd.has(e.slice(t+1).toLowerCase())}new Set([...Yu,...dd,...fd]);function md(e){let t=e.toLowerCase().replace(/^\./,``);return od.has(t)?`image`:sd.has(t)?`video`:cd.has(t)?`audio`:ld.has(t)?`pdf`:ud.has(t)||dd.has(t)?`text`:fd.has(t)?`mermaid`:Pu.has(t)?`text`:null}var hd=[`en`,`zh-Hans`,`zh-Hant`,`hi`,`es`,`ar`,`fr`,`bn`,`pt-BR`,`id`,`ur`,`ko`],gd=[`en`,`zh-Hans`,`zh-Hant`,`hi`,`es`,`fr`,`bn`,`pt-BR`,`id`,`ko`],_d=new Set([`ar`,`ur`]),vd=hd.filter(e=>!_d.has(e)),yd=[`off`,`warning`,`error`],bd=`warning`,xd=[`error`,`warning`],Sd=[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`],Cd={base00:`default background`,base01:`alt background — cards, popovers, sidebar`,base02:`selection background, borders`,base03:`comments, invisibles`,base04:`secondary text`,base05:`default foreground`,base06:`light foreground`,base07:`lightest foreground`,base08:`red — variables, tags, diff deleted`,base09:`orange — numbers, constants`,base0A:`yellow — classes, search highlight`,base0B:`green — strings, diff inserted`,base0C:`cyan — support, escapes, quotes`,base0D:`blue — functions, headings, accent`,base0E:`magenta — keywords, storage`,base0F:`deprecated markers, embedded tags`},wd=/^#[0-9a-fA-F]{6}$/,Td=/\P{White_Space}/u;function Ed(e){return Td.test(e)}function Dd(e){return typeof e==`string`&&wd.test(e)}function Od(e){let t=e.palette;return{background:t.base00,foreground:t.base05,card:t.base01,"card-foreground":t.base05,popover:t.base01,"popover-foreground":t.base05,primary:t.base0D,"primary-foreground":t.base00,secondary:t.base01,"secondary-foreground":t.base05,muted:t.base01,"muted-foreground":t.base04,accent:t.base02,"accent-foreground":t.base05,destructive:t.base08,border:t.base02,input:t.base02,ring:t.base0D,"selection-soft":t.base02,"chart-1":t.base0D,"chart-2":t.base0B,"chart-3":t.base0A,"chart-4":t.base0E,"chart-5":t.base08,sidebar:t.base01,"sidebar-foreground":t.base05,"sidebar-primary":t.base0D,"sidebar-primary-foreground":t.base00,"sidebar-accent":t.base02,"sidebar-accent-foreground":t.base0D,"sidebar-hover":t.base02,"sidebar-border":t.base02,"sidebar-ring":t.base0D,"syntax-keyword":t.base0E,"syntax-tag":t.base08,"syntax-attr":t.base0D,"syntax-string":t.base0B,"syntax-number":t.base09,"syntax-atom":t.base0C,"syntax-comment":t.base03,"syntax-func":t.base0D,"syntax-var":t.base08,"syntax-type":t.base0A,"syntax-operator":t.base05,"syntax-meta":t.base0F,"syntax-bg":t.base01,"link-color":t.base0D,"broken-link-color":t.base08,"lint-warning-color":t.base0A,"lint-error-color":t.base08,"diff-added":t.base0B,"diff-removed":t.base08,"callout-note-color":t.base0D,"callout-info-color":t.base0D,"callout-todo-color":t.base0D,"callout-abstract-color":t.base0C,"callout-tip-color":t.base0B,"callout-success-color":t.base0B,"callout-important-color":t.base0E,"callout-example-color":t.base0E,"callout-question-color":t.base0E,"callout-warning-color":t.base0A,"callout-caution-color":t.base09,"callout-danger-color":t.base09,"callout-failure-color":t.base08,"callout-bug-color":t.base08,"callout-quote-color":t.base03,...jd(t)}}var kd={black:`base00`,red:`base08`,green:`base0B`,yellow:`base0A`,blue:`base0D`,magenta:`base0E`,cyan:`base0C`,white:`base05`,brightBlack:`base03`,brightRed:`base08`,brightGreen:`base0B`,brightYellow:`base0A`,brightBlue:`base0D`,brightMagenta:`base0E`,brightCyan:`base0C`,brightWhite:`base07`},Ad=Object.keys(kd);function jd(e){let t={};for(let n of Ad)t[`ansi-${Md(n)}`]=e[kd[n]];return t}function Md(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}function Nd(e){return JSON.stringify(e).replace(/[\u007f-\u009f\u2028\u2029\ufffe\uffff]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function Pd(e){return`${[`system: "base16"`,`name: ${Nd(e.name)}`,...e.author?[`author: ${Nd(e.author)}`]:[],`variant: ${Nd(e.variant)}`,`palette:`,...Sd.map(t=>` ${t}: ${Nd(e.palette[t])}`)].join(`
|
|
172
172
|
`)}\n`}function Fd(e){let t;try{t=_u(e,{schema:`failsafe`})}catch(e){let t=e?.linePos;return{ok:!1,error:{kind:`unparseable`,line:typeof t?.[0]?.line==`number`?t[0].line:void 0}}}if(!t||typeof t!=`object`||Array.isArray(t))return{ok:!1,error:{kind:`not-a-scheme`}};let n=t,r=n.palette,i=r&&typeof r==`object`&&!Array.isArray(r)?r:n,a={},o=[],s=[];for(let e of Sd){let t=i[e]??i[e.toLowerCase()];if(t==null){o.push(e);continue}let n=Id(t);if(!n){s.push(e);continue}a[e]=n}return o.length?{ok:!1,error:{kind:`missing-slots`,slots:o}}:s.length?{ok:!1,error:{kind:`bad-hex`,slots:s}}:typeof n.name==`string`&&!Ed(n.name)||typeof n.author==`string`&&!Ed(n.author)?{ok:!1,error:{kind:`not-a-scheme`}}:{ok:!0,scheme:{name:typeof n.name==`string`?n.name:`Imported`,author:typeof n.author==`string`?n.author:void 0,variant:n.variant===`light`||n.variant===`dark`?n.variant:zd(a),palette:a}}}function Id(e){if(typeof e!=`string`)return null;let t=e.trim();return t.startsWith(`#`)||(t=`#${t}`),/^#[0-9a-fA-F]{3}$/.test(t)&&(t=`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`),wd.test(t)?t.toLowerCase():null}function Ld(e,t,n){let r=Dd(e)?e:`#000000`,i=Dd(t)?t:`#000000`,a=Math.min(1,Math.max(0,n)),o=`#`;for(let e=0;e<3;e++){let t=Number.parseInt(r.slice(1+e*2,3+e*2),16),n=Number.parseInt(i.slice(1+e*2,3+e*2),16);o+=Math.round(t+(n-t)*a).toString(16).padStart(2,`0`)}return o}function Rd(e){let t=Dd(e)?e:`#000000`,n=e=>{let n=Number.parseInt(t.slice(1+e*2,3+e*2),16)/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(0)+.7152*n(1)+.0722*n(2)}function zd(e){return Rd(e.base00)<Rd(e.base05)?`dark`:`light`}var Bd={name:`Dracula`,author:`clach04 (https://github.com/clach04)`,variant:`dark`,palette:{base00:`#282a36`,base01:`#21222c`,base02:`#44475a`,base03:`#6272a4`,base04:`#9ea8c7`,base05:`#f8f8f2`,base06:`#f8f8f2`,base07:`#ffffff`,base08:`#ff5555`,base09:`#ffb86c`,base0A:`#f1fa8c`,base0B:`#50fa7b`,base0C:`#8be9fd`,base0D:`#bd93f9`,base0E:`#ff79c6`,base0F:`#993333`}},Vd={name:`Catppuccin Frappé`,author:`https://github.com/catppuccin/catppuccin`,variant:`dark`,palette:{base00:`#303446`,base01:`#292c3c`,base02:`#414559`,base03:`#51576d`,base04:`#626880`,base05:`#c6d0f5`,base06:`#f2d5cf`,base07:`#babbf1`,base08:`#e78284`,base09:`#ef9f76`,base0A:`#e5c890`,base0B:`#a6d189`,base0C:`#81c8be`,base0D:`#8caaee`,base0E:`#ca9ee6`,base0F:`#eebebe`}},Hd={name:`Catppuccin Latte`,author:`https://github.com/catppuccin/catppuccin`,variant:`light`,palette:{base00:`#eff1f5`,base01:`#e6e9ef`,base02:`#ccd0da`,base03:`#bcc0cc`,base04:`#acb0be`,base05:`#4c4f69`,base06:`#dc8a78`,base07:`#7287fd`,base08:`#d20f39`,base09:`#fe640b`,base0A:`#df8e1d`,base0B:`#40a02b`,base0C:`#179299`,base0D:`#1e66f5`,base0E:`#8839ef`,base0F:`#dd7878`}},Ud={name:`Monokai`,author:`Wimer Hazenberg (http://www.monokai.nl)`,variant:`dark`,palette:{base00:`#272822`,base01:`#383830`,base02:`#49483e`,base03:`#75715e`,base04:`#a59f85`,base05:`#f8f8f2`,base06:`#f5f4f1`,base07:`#f9f8f5`,base08:`#f92672`,base09:`#fd971f`,base0A:`#f4bf75`,base0B:`#a6e22e`,base0C:`#a1efe4`,base0D:`#66d9ef`,base0E:`#ae81ff`,base0F:`#cc6633`}},Wd={name:`Gruvbox dark, medium`,author:`Dawid Kurek, morhetz (https://github.com/morhetz/gruvbox)`,variant:`dark`,palette:{base00:`#282828`,base01:`#3c3836`,base02:`#504945`,base03:`#665c54`,base04:`#bdae93`,base05:`#d5c4a1`,base06:`#ebdbb2`,base07:`#fbf1c7`,base08:`#fb4934`,base09:`#fe8019`,base0A:`#fabd2f`,base0B:`#b8bb26`,base0C:`#8ec07c`,base0D:`#83a598`,base0E:`#d3869b`,base0F:`#d65d0e`}},Gd={name:`Solarized Dark`,author:`Ethan Schoonover (modified by aramisgithub)`,variant:`dark`,palette:{base00:`#002b36`,base01:`#073642`,base02:`#586e75`,base03:`#657b83`,base04:`#839496`,base05:`#93a1a1`,base06:`#eee8d5`,base07:`#fdf6e3`,base08:`#dc322f`,base09:`#cb4b16`,base0A:`#b58900`,base0B:`#859900`,base0C:`#2aa198`,base0D:`#268bd2`,base0E:`#6c71c4`,base0F:`#d33682`}};function Kd(e,t,n){return{id:e,label:t,kind:n.variant,scheme:n,toTokens:()=>Od(n)}}function qd(e,t){return{id:e,label:t,kind:`system`}}var Jd=[qd(`default`,`Default`),Kd(`dracula`,`Dracula`,Bd),Kd(`catppuccin-frappe`,`Catppuccin Frappé`,Vd),Kd(`catppuccin-latte`,`Catppuccin Latte`,Hd),Kd(`monokai`,`Monokai`,Ud),Kd(`gruvbox`,`Gruvbox`,Wd),Kd(`solarized`,`Solarized`,Gd),qd(`custom`,`Custom`)],Yd=Jd.map(e=>e.id),Xd=/^[a-z0-9-]{1,32}$/,Zd=`saved-`,Qd=26,$d=/\p{M}+/gu,ef=/['\u2019\u02bc]+/gu,tf=/[^a-z0-9]+/g;function nf(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function rf(e){let t=e.trim();if(t.length===0)return{ok:!1,code:`empty`};let n=t.normalize(`NFKD`).replace($d,``).toLowerCase().replace(ef,``).replace(tf,`-`).replace(/^-+|-+$/g,``),r=nf(t),i=n.length===0?`theme-${r}`:n.length<=Qd?n:`${n.slice(0,Qd-r.length-1).replace(/-+$/g,``)}-${r}`,a=af(i);if(!a.ok)throw Error(`Saved theme name derivation produced an invalid id`);return{ok:!0,name:t,stem:i,id:a.id}}function af(e){if(e.length===0)return{ok:!1,code:`empty`};let t=Zd+e;return Xd.test(t)?{ok:!0,id:t}:{ok:!1,code:/^[a-z0-9-]+$/.test(t)?`too-long`:`invalid-chars`}}function of(e){if(!Xd.test(e)||!e.startsWith(`saved-`))return{ok:!1};let t=e.slice(6);return t.length===0?{ok:!1}:{ok:!0,stem:t}}var sf=new Map(Jd.map(e=>[e.id,e]));function cf(e){return e&&sf.get(e)||Jd[0]}function lf(e,t=Jd){let n=new Set(t.map(e=>e.id)),r=e?.colorTheme,i=r&&n.has(r)?r:Jd[0].id,a=e=>e===void 0?i:n.has(e)?e:Jd[0].id;return{light:a(e?.colorThemeLight),dark:a(e?.colorThemeDark)}}function uf(e,t){return e===`light`||e===`dark`?e:t?`dark`:`light`}function df(e,t,n){return`${e} {\n color-scheme: ${t};\n${Object.entries(n).map(([e,t])=>` --${e}: ${t};`).join(`
|
|
173
|
-
`)}\n}`}var ff=Symbol.for(`@inkeep/open-knowledge/field-registry`),pf=globalThis;pf[ff]===void 0&&(pf[ff]=Er());var H=pf[ff];function mf(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=hf(t)?H.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function hf(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}function gf(){return Object.fromEntries(Sd.map(e=>[e,N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: base16 ${e} — ${Cd[e]}, as a #rrggbb hex string.`}).optional()]))}function _f(){return Yd.filter(e=>e!==`default`&&e!==`custom`).map(e=>`'${e}'`).join(`, `)}var vf=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),yf=52428800,bf=26214400,xf=12582912,Sf=`https://api.openai.com/v1`,Cf=`text-embedding-3-small`,wf=Object.freeze([`127.0.0.1`]),Tf=/^[1-9]\d*(s|m|h)$/,Ef=/^https?:\/\//,Df=24550;function Of(e){let t;try{t=new URL(e)}catch{return!1}let n=t.hostname.toLowerCase();return n===`localhost`||n===`127.0.0.1`||n===`[::1]`}function kf(e){let t;try{t=new URL(e)}catch{return`invalid-url`}return t.protocol===`https:`||t.protocol===`http:`&&Of(e)?null:`insecure-scheme`}function Af(e){let t=e.trim();return t===``?`./`:t}function jf(e){let t=Af(e);return t.includes(`\0`)||t.includes(`\\`)?!1:t===`/`?!0:!(t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.split(`/`).some(e=>e===`..`))}var Mf=R({content:R({dir:N().register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Folder OpenKnowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore. Read at server start; changing it requires a restart.`}).default(`.`),attachmentFolderPath:N().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Where pasted and dropped assets are stored, relative to the content root. './' colocates beside the current document (default); '/' targets the content root; './subdir' targets a subfolder under the current document folder; 'folder' targets a fixed folder under the content root. Whitespace-only values are treated as './'.`}).refine(jf,{message:`Invalid attachment folder path: must not contain '..' segments, NUL bytes, backslashes, or OS absolute paths (use '/' for the content root).`}).default(`./`)}).default({dir:`.`,attachmentFolderPath:`./`}),appearance:R({theme:z([`light`,`dark`,`system`]).register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),language:z([`system`,...hd]).register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Interface language. 'system' follows the operating system. A personal preference (user scope) — not shared with the project, and never applied to document content.`}).optional(),colorThemeLight:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in light mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${_f()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(Xd,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeDark:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in dark mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${_f()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(Xd,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorTheme:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Superseded by appearance.colorThemeLight / appearance.colorThemeDark. Read as the palette for both modes while neither of those is set. A short theme id (lowercase letters, digits, and hyphens; max 32 characters); an id no palette matches falls back to 'default'. A personal preference (user scope) — not shared with the project.`}).regex(Xd,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeEnabled:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Whether the Themes plugin appears in Settings → Plugins. A personal preference (user scope). Default on.`}).optional(),customTheme:R({name:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's display name.`}).optional(),author:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's author credit, carried through from an imported base16 scheme.`}).optional(),variant:z([`dark`,`light`]).register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: whether the scheme is 'dark' or 'light'. Auto-detected from the palette when omitted.`}).optional(),...gf()}).optional(),preview:R({autoOpen:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:R({showHiddenFiles:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showOnlyMarkdownFiles:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show only markdown documents (.md/.mdx) and folders in the file tree, hiding other file types from view. View-only: hidden files stay on disk and remain reachable via links and search. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillsSection:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show the Skills section in the sidebar. Skill documents remain reachable via links and search while the section is hidden. Per-machine (project-local) — not shared with collaborators.`}).default(!0),showOkFolders:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show .ok folders (skills, templates, and other OpenKnowledge-managed state) in the file tree as read-only entries. .ok/worktrees and .ok/local never appear. Per-machine (project-local) — not shared with collaborators.`}).default(!1)}).optional()}).default({preview:{autoOpen:!0}}),editor:R({wordWrap:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0),previewTabs:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Reuse one tab when clicking through the Files and Skills sidebars, the way an editor preview tab works. Turn off to open every click in its own tab. Pinned tabs keep their own tab either way. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0,previewTabs:!0}),agents:R({autoApproveOkTools:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools (and `ok open` on Claude) for agents launched from the built-in terminal. Destructive tools (delete/move/share/install) still prompt. Per-machine personal preference (user scope)."}).default(!0)}).default({autoApproveOkTools:!0}),autoSync:R({mode:z(xu).register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`How this machine syncs this project with its git remote: 'off' (no sync), 'follow' (one-directional — pull remote changes, never push your own; 'pull' is accepted as a legacy alias), or 'full' (bidirectional pull and push). null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared. Supersedes the legacy autoSync.enabled boolean.`}).nullable().default(null),enabled:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Legacy per-machine sync toggle, superseded by autoSync.mode. Read only when mode is absent (true = full, false = off). null = not chosen yet. Per-machine (project-local) — not shared.`}).nullable().default(null),resumeMode:z(Su).register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`When sync is paused (autoSync.mode 'off') after having been enabled, the active mode to resume into ('follow' | 'full'). Per-machine UI memory; ignored while a mode is active. Not shared.`}).optional(),default:to([F(),z(xu)]).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Committed project default for a machine's sync mode on first open: 'off' | 'follow' | 'full', or the legacy boolean (true = full, false = off). null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.mode choice overrides it.`}).nullable().default(null)}).default({mode:null,enabled:null,default:null}),terminal:R({enabled:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null)}).default({enabled:null}),slides:R({enabled:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Whether the Slides plugin appears in Settings → Plugins. When on, a document whose frontmatter has `slides: true` offers an action that opens the deck in a dedicated window (desktop only, requires a resolvable slidev). A personal preference (user scope). Default off."}).default(!1)}).default({enabled:!1}),telemetry:R({localSink:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:R({maxBytes:P().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(yf)}).default({maxBytes:yf}),logs:R({maxBytes:P().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(bf)}).default({maxBytes:bf}),attributeDenylist:I(N()).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...vf])}).default({enabled:!0,spans:{maxBytes:yf},logs:{maxBytes:bf},attributeDenylist:[...vf]}),skillInstallReports:R({enabled:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Report skill installs to skills.sh so a published skill shows an accurate install count. Sends the skill name, its source repo, and which agent tools it was installed for — never file contents, and never for a private or local source. One report per skill per machine. Default on; the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables also turn it off.`}).default(!0)}).default({enabled:!0})}).default({localSink:{enabled:!0,spans:{maxBytes:yf},logs:{maxBytes:bf},attributeDenylist:[...vf]},skillInstallReports:{enabled:!0}}),lossCapture:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Record bridge loss-class events (content-free) under .ok/local/loss-capture/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),maxBytes:P().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local loss-capture file before it rotates (default ~12 MB).`}).default(xf)}).default({enabled:!0,maxBytes:xf}),bridge:R({backgroundThrottle:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Keep the desktop window's timers running at full rate while it holds unsynced work, so backgrounding the app never starves sync or recovery; when the window is idle the OS-default background throttling is restored (battery). Honored by the desktop app. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),deferGuard:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Defer a drain-shaped Observer B re-derive when the WYSIWYG fragment holds an un-propagated keystroke Y.Text lacks, so the keystroke survives instead of being stomped. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),lossDetector:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Detect content the bridge silently dropped at its reconciliation boundary (an Observer-A apply arm or a paired agent-undo derive) and write a recovery checkpoint plus a content-free loss event. Detection only — never blocks a write. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),fixedPoint:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Bound the Y.Text→WYSIWYG re-derive loop with a drain-count backstop: a run of re-derive drains that never reaches a raw-byte fixed point freezes the re-derive loop and writes a recovery checkpoint plus a content-free loss event, instead of churning unbounded. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),preDrain:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Before an agent write or undo rebuilds the WYSIWYG fragment, flush an un-propagated keystroke that provably does not overlap the operation into Y.Text so the keystroke survives instead of needing recovery; overlapping or unmodellable cases fall back to the checkpoint floor. Scope: appending writes and single-frame undos — a write that replaces the whole body (replace / edit) overwrites the keystroke either way, so those always take the checkpoint floor. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),flushOnHide:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`On tab hide/unload, force-send each doc's unsynced work to the server and commit its local cache, and re-sync on return to foreground, so a backgrounded tab never strands edits that IndexedDB alone would lose on recycle. Honored client-side. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0})}).default({backgroundThrottle:{enabled:!0},deferGuard:{enabled:!0},lossDetector:{enabled:!0},fixedPoint:{enabled:!0},preDrain:{enabled:!0},flushOnHide:{enabled:!0}}),search:R({semantic:R({enabled:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:N().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override to point at a self-hosted server (Ollama / vLLM / LM Studio) or another provider. The API key is NOT stored here — set it with `ok embeddings set-key` (`~/.ok/secrets.yml`); it is sent to whichever endpoint this names."}).default(Sf),model:N().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(Cf),dimensions:P().int().positive().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit (recommended) to detect the model's native size from its first response — that is what lets a non-OpenAI model work without knowing its size up front. Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality; a server that ignores the request param then fails loudly instead of silently. Changing it re-embeds the corpus.`}).optional(),similarityFloor:P().min(0).max(1).register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional()}).default({enabled:!1,baseUrl:Sf,model:Cf})}).default({semantic:{enabled:!1,baseUrl:Sf,model:Cf}}),contentRules:R({markdownlint:L({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the markdownlint plugin (body rules) contributes diagnostics.`}).default(!1)}).default({enabled:!1}),frontmatter:L({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the frontmatter plugin (JSON-Schema validation of document frontmatter) contributes diagnostics.`}).default(!1),schemas:I(L({appliesTo:to([N(),I(N())]).optional(),file:N(),enabled:F().optional()})).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Frontmatter schema mappings: which docs (appliesTo globs) validate against which JSON Schema file (project-root-relative path).`}).default([])}).default({enabled:!1,schemas:[]}),okf:L({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the OKF plugin (Open Knowledge Format portability + conformance rules) contributes diagnostics. Advisory warnings; never blocks a write.`}).default(!1),rules:so(N(),F()).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Per-rule opt-outs for the OKF plugin, keyed by rule id (e.g. no-wiki-links). Omit a rule to leave it enabled; set false to silence it while keeping the plugin on.`}).optional(),generate:L({index:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether OK generates and maintains a navigation index.md in every folder that contains Markdown, each listing the documents in that folder grouped by frontmatter type and linking to its subfolders. OK owns these files: edits to them are replaced on the next rebuild.`}).default(!1)}).default({index:!1})}).default({enabled:!1,generate:{index:!1}})}).default({markdownlint:{enabled:!1},frontmatter:{enabled:!1,schemas:[]},okf:{enabled:!1,generate:{index:!1}}}),validation:R({links:z(yd).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`How broken internal links are reported on the validation plane: 'off' hides them, 'warning' (default) or 'error' sets their severity.`}).default(bd),fileTreeIndicators:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the file tree tints and badges files that have validation problems.`}).default(!0)}).default({links:bd,fileTreeIndicators:!0}),linkPreviews:R({enabled:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show a rich preview card (site name, page title, description, favicon) when you hover an external link in the editor. When ON, hovering an external link sends that link's URL to the destination site to fetch its preview metadata — outbound egress, one request per previewed link. Default ON; set to false to turn external previews off. Per-machine (project-local) — not shared with collaborators. Previews of links to other documents in this project are read from the local index with no network request and are always on.`}).default(!0)}).default({enabled:!0}),remote:R({url:N().register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:"Superseded by server.externalUrl — read only while server.externalUrl (and its deprecated server.publicUrl spelling) is absent. Public URL your tunnel gives you, e.g. https://myproject.ngrok.app. Used only with `ok start --remote` (config alone never enables remote access); its host is admitted through the Host-header allowlist. There is no server-side auth, so restrict access at the tunnel (ngrok OAuth, Cloudflare Access, Tailscale ACLs)."}).optional(),port:P().int().min(1).max(65535).register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Superseded by server.port — read only while server.port is absent. TCP port the server binds when remote access is enabled (default 24550). Fixed so the tunnel's port mapping survives restarts. Set it only on a conflict. An explicit --port still wins; the PORT env var is ignored in remote mode.`}).optional()}).default({}),server:R({port:P().int().min(1).max(65535).register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`TCP port the server listens on. Unset by default: a local start picks a free port dynamically, and deployment platforms inject the PORT environment variable instead. Supersedes remote.port (still read while this key is absent). Read at server start; changing it requires a restart.`}).optional(),bind:I(N().min(1)).min(1).register(H,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Addresses the server binds, e.g. [127.0.0.1] or [0.0.0.0]. Default loopback-only ([127.0.0.1]): nothing off this machine can connect. A non-loopback bind additionally requires the server.allowExternal consent interlock. Per-machine (project-local): a value committed to .ok/config.yml is ignored, so one machine exposing the server can never break local clones for the rest of the team — the exposing host sets it via OK_BIND, --bind, or .ok/local/config.yml. Lists replace, never merge. Read at server start; changing it requires a restart.`}).default([...wf]),externalUrl:Ea({protocol:/^https?$/}).regex(Ef).register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Canonical external origin the server is reached at, e.g. https://kb.example.com — drives issued URLs and CORS. Unset by default: a loopback server derives http://localhost:<port>. Setting it declares external exposure, which additionally requires the server.allowExternal consent interlock. Supersedes server.publicUrl (its former name) and remote.url — both still read while this key is absent. Read at server start; changing it requires a restart.`}).optional(),publicUrl:Ea({protocol:/^https?$/}).regex(Ef).register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Deprecated alias of server.externalUrl (the former name of that key) — read only while server.externalUrl is absent, with identical semantics. Use server.externalUrl instead; if this config is committed and shared, keep both keys until every collaborator has upgraded (older versions read only server.publicUrl).`}).optional(),allowExternal:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Exposure consent interlock. Once the unified server boot lands, a non-loopback server.bind or a server.externalUrl without allowExternal: true will be refused at boot with a one-line fix. Default off. Per-machine (project-local) — consent never travels via git, clone, or share; containers consent via the environment instead.`}).default(!1),openBrowser:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Open the UI in a browser when the server starts. Default derived: true when every bind address is loopback (a laptop start pops the UI), false otherwise (a container or exposed bind is headless and must never try). Acts once at start. Per-machine (project-local) — not shared.`}).optional(),idleShutdown:to([B(`off`),N().regex(Tf)]).register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Shut the server down after this long with no activity: a duration like '30m' (positive integer with unit s, m, or h), or 'off'. Default derived: '30m' when every bind address is loopback, 'off' otherwise (an exposed or containerized server stays up). Reloadable — a valid change applies without a restart. Per-machine (project-local) — not shared.`}).optional()}).default({bind:[...wf],allowExternal:!1})}),Nf=`open-knowledge-config`;function Pf(e,t,n){let r=c.getTracer(Nf),i=t?{attributes:t}:{};return r.startActiveSpan(e,i,e=>{try{return n(e)}catch(t){throw e.recordException(t),e.setStatus({code:s.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function Ff(e,t){let n=c.getActiveSpan();n&&n.addEvent(e,t)}function If(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Lf(e,t){let n=e;for(let e of t){n=If(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function Rf(e,t){let n=Lf(e,t);if(n!==void 0)return mf(n)}function zf(e,t){return e===`either`?!0:e===t}function Bf(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}let a=Rf(Mf,i);a?.scope!==void 0&&(zf(a.scope,t)||(n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t}))}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}function Vf(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&($o(e.getIn(r,!0))||e.deleteIn(r))}}function Hf(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){Vf(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}Vf(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function Uf(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}var Wf=L({file:N(),line:P().int().min(1),column:P().int().min(1),snippet:N().optional()}),Gf=L({path:I(to([N(),P()])),message:N(),issueCode:N(),params:so(N(),Ya()).optional(),source:Wf.optional()}),Kf=z([`user`,`project`,`project-local`,`either`]),qf=z([`user`,`project`,`project-local`]),Jf=L({code:B(`YAML_PARSE`),detail:N()}),Yf=L({code:B(`UNREADABLE`),detail:N()}),Xf=L({code:B(`SCHEMA_INVALID`),issues:I(Gf)}),Zf=L({code:B(`REMOVED_KEY`),path:I(N()),redirect:N(),source:Wf.optional()}),Qf=ro(`code`,[Jf,Xf,Yf,L({code:B(`SCOPE_VIOLATION`),path:I(N()),expectedScope:Kf,actualScope:qf}),L({code:B(`NOT_AGENT_SETTABLE`),path:I(N())}),L({code:B(`MIXED_SCOPE`),paths:I(L({path:I(N()),scope:qf}))}),Zf,L({code:B(`WRITE_ERROR`),detail:N()}),L({code:B(`OKIGNORE_INVALID`),detail:N(),lineNumber:P().int().min(1).optional()}),L({code:B(`UNKNOWN`),message:N().optional()})]);ro(`code`,[Zf,Jf,Xf,Yf]),L({diagnostics:I(ro(`code`,[L({code:B(`REMOVED_KEY`),scope:qf,file:N(),path:I(N()),redirect:N()}),L({code:B(`YAML_PARSE`),scope:qf,file:N()}),L({code:B(`SCHEMA_INVALID`),scope:qf,file:N()}),L({code:B(`UNREADABLE`),scope:qf,file:N()})]))});var $f=new Set(Qf.options.map(e=>e.shape.code.value)),ep=to([Qf,R({code:N(),message:N().optional()})]);function tp(e){return $f.has(e.code)}function np(e){switch(e){case`user`:return`~/.ok/global.yml`;case`project`:return`.ok/config.yml`;case`project-local`:return`.ok/local/config.yml`;case`either`:return`.ok/config.yml or ~/.ok/global.yml`}}function rp(e){switch(e){case`user`:return`personal to you, across all projects`;case`project`:return`shared with your team via git`;case`project-local`:return`this machine only, not shared`;case`either`:return`user or project`}}function ip(e){if(!tp(e))return e.message??`Unknown error (${e.code}).`;switch(e.code){case`YAML_PARSE`:return`Failed to parse YAML: ${e.detail}`;case`UNREADABLE`:return`Could not read the file: ${e.detail}`;case`SCHEMA_INVALID`:{if(e.issues.length===0)return`Invalid configuration.`;let t=new Map;for(let n of e.issues){let e=n.source?.file??`<no source>`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];for(let[e,r]of t){e===`<no source>`?n.push(`Invalid configuration:`):n.push(`Invalid configuration at ${e}:`);for(let t of r){let r=t.path.length===0?`<root>`:t.path.join(`.`);if(t.source){if(n.push(` ${e}:${t.source.line}:${t.source.column}`),n.push(` ${r}: ${t.message}`),t.source.snippet&&t.source.snippet.length>0)for(let e of t.source.snippet.split(`
|
|
173
|
+
`)}\n}`}var ff=Symbol.for(`@inkeep/open-knowledge/field-registry`),pf=globalThis;pf[ff]===void 0&&(pf[ff]=Er());var H=pf[ff];function mf(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=hf(t)?H.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function hf(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}function gf(){return Object.fromEntries(Sd.map(e=>[e,N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: base16 ${e} — ${Cd[e]}, as a #rrggbb hex string.`}).optional()]))}function _f(){return Yd.filter(e=>e!==`default`&&e!==`custom`).map(e=>`'${e}'`).join(`, `)}var vf=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),yf=52428800,bf=26214400,xf=12582912,Sf=`https://api.openai.com/v1`,Cf=`text-embedding-3-small`,wf=Object.freeze([`127.0.0.1`]),Tf=/^[1-9]\d*(s|m|h)$/,Ef=/^https?:\/\//,Df=24550;function Of(e){let t;try{t=new URL(e)}catch{return!1}let n=t.hostname.toLowerCase();return n===`localhost`||n===`127.0.0.1`||n===`[::1]`}function kf(e){let t;try{t=new URL(e)}catch{return`invalid-url`}return t.protocol===`https:`||t.protocol===`http:`&&Of(e)?null:`insecure-scheme`}function Af(e){let t=e.trim();return t===``?`./`:t}function jf(e){let t=Af(e);return t.includes(`\0`)||t.includes(`\\`)?!1:t===`/`?!0:!(t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.split(`/`).some(e=>e===`..`))}var Mf=R({content:R({dir:N().register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Folder OpenKnowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore. Read at server start; changing it requires a restart.`}).default(`.`),attachmentFolderPath:N().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Where pasted and dropped assets are stored, relative to the content root. './' colocates beside the current document (default); '/' targets the content root; './subdir' targets a subfolder under the current document folder; 'folder' targets a fixed folder under the content root. Whitespace-only values are treated as './'.`}).refine(jf,{message:`Invalid attachment folder path: must not contain '..' segments, NUL bytes, backslashes, or OS absolute paths (use '/' for the content root).`}).default(`./`)}).default({dir:`.`,attachmentFolderPath:`./`}),appearance:R({theme:z([`light`,`dark`,`system`]).register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),language:z([`system`,...hd]).register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Interface language. 'system' follows the operating system. A personal preference (user scope) — not shared with the project, and never applied to document content.`}).optional(),colorThemeLight:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in light mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${_f()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(Xd,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeDark:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in dark mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${_f()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(Xd,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorTheme:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Superseded by appearance.colorThemeLight / appearance.colorThemeDark. Read as the palette for both modes while neither of those is set. A short theme id (lowercase letters, digits, and hyphens; max 32 characters); an id no palette matches falls back to 'default'. A personal preference (user scope) — not shared with the project.`}).regex(Xd,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeEnabled:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Whether the Themes plugin appears in Settings → Plugins. A personal preference (user scope). Default on.`}).optional(),customTheme:R({name:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's display name.`}).optional(),author:N().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's author credit, carried through from an imported base16 scheme.`}).optional(),variant:z([`dark`,`light`]).register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: whether the scheme is 'dark' or 'light'. Auto-detected from the palette when omitted.`}).optional(),...gf()}).optional(),preview:R({autoOpen:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:R({showHiddenFiles:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showOnlyMarkdownFiles:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show only markdown documents (.md/.mdx) and folders in the file tree, hiding other file types from view. View-only: hidden files stay on disk and remain reachable via links and search. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillsSection:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show the Skills section in the sidebar. Skill documents remain reachable via links and search while the section is hidden. Per-machine (project-local) — not shared with collaborators.`}).default(!0),showOkFolders:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show .ok folders (skills, templates, and other OpenKnowledge-managed state) in the file tree as read-only entries. .ok/worktrees and .ok/local never appear. Per-machine (project-local) — not shared with collaborators.`}).default(!1)}).optional()}).default({preview:{autoOpen:!0}}),editor:R({wordWrap:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0),previewTabs:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Reuse one tab when clicking through the Files and Skills sidebars, the way an editor preview tab works. Turn off to open every click in its own tab. Pinned tabs keep their own tab either way. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0,previewTabs:!0}),agents:R({autoApproveOkTools:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools (and `ok open` on Claude) for agents launched from the built-in terminal. Destructive tools (delete/move/share/install) still prompt. Per-machine personal preference (user scope)."}).default(!0)}).default({autoApproveOkTools:!0}),autoSync:R({mode:z(xu).register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`How this machine syncs this project with its git remote: 'off' (no sync), 'follow' (one-directional — pull remote changes, never push your own; 'pull' is accepted as a legacy alias), or 'full' (bidirectional pull and push). null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared. Supersedes the legacy autoSync.enabled boolean.`}).nullable().default(null),enabled:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Legacy per-machine sync toggle, superseded by autoSync.mode. Read only when mode is absent (true = full, false = off). null = not chosen yet. Per-machine (project-local) — not shared.`}).nullable().default(null),resumeMode:z(Su).register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`When sync is paused (autoSync.mode 'off') after having been enabled, the active mode to resume into ('follow' | 'full'). Per-machine UI memory; ignored while a mode is active. Not shared.`}).optional(),default:to([F(),z(xu)]).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Committed project default for a machine's sync mode on first open: 'off' | 'follow' | 'full', or the legacy boolean (true = full, false = off). null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.mode choice overrides it.`}).nullable().default(null)}).default({mode:null,enabled:null,default:null}),terminal:R({enabled:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null)}).default({enabled:null}),slides:R({enabled:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Whether the Slides plugin appears in Settings → Plugins. When on, a document whose frontmatter has `slides: true` offers an action that opens the deck in a dedicated window (desktop only, requires a resolvable slidev). A personal preference (user scope). Default off."}).default(!1)}).default({enabled:!1}),telemetry:R({localSink:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:R({maxBytes:P().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(yf)}).default({maxBytes:yf}),logs:R({maxBytes:P().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(bf)}).default({maxBytes:bf}),attributeDenylist:I(N()).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...vf])}).default({enabled:!0,spans:{maxBytes:yf},logs:{maxBytes:bf},attributeDenylist:[...vf]}),skillInstallReports:R({enabled:F().register(H,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Report skill installs to skills.sh so a published skill shows an accurate install count. Sends the skill name, its source repo, and which agent tools it was installed for — never file contents, and never for a private or local source. One report per skill per machine. Default on; the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables also turn it off.`}).default(!0)}).default({enabled:!0})}).default({localSink:{enabled:!0,spans:{maxBytes:yf},logs:{maxBytes:bf},attributeDenylist:[...vf]},skillInstallReports:{enabled:!0}}),lossCapture:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Record bridge loss-class events (content-free) under .ok/local/loss-capture/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),maxBytes:P().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local loss-capture file before it rotates (default ~12 MB).`}).default(xf)}).default({enabled:!0,maxBytes:xf}),bridge:R({backgroundThrottle:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Keep the desktop window's timers running at full rate while it holds unsynced work, so backgrounding the app never starves sync or recovery; when the window is idle the OS-default background throttling is restored (battery). Honored by the desktop app. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),deferGuard:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Defer a drain-shaped Observer B re-derive when the WYSIWYG fragment holds an un-propagated keystroke Y.Text lacks, so the keystroke survives instead of being stomped. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),lossDetector:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Detect content the bridge silently dropped at its reconciliation boundary (an Observer-A apply arm or a paired agent-undo derive) and write a recovery checkpoint plus a content-free loss event. Detection only — never blocks a write. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),fixedPoint:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Bound the Y.Text→WYSIWYG re-derive loop with a drain-count backstop: a run of re-derive drains that never reaches a raw-byte fixed point freezes the re-derive loop and writes a recovery checkpoint plus a content-free loss event, instead of churning unbounded. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),preDrain:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Before an agent write or undo rebuilds the WYSIWYG fragment, flush an un-propagated keystroke that provably does not overlap the operation into Y.Text so the keystroke survives instead of needing recovery; overlapping or unmodellable cases fall back to the checkpoint floor. Scope: appending writes and single-frame undos — a write that replaces the whole body (replace / edit) overwrites the keystroke either way, so those always take the checkpoint floor. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),flushOnHide:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`On tab hide/unload, force-send each doc's unsynced work to the server and commit its local cache, and re-sync on return to foreground, so a backgrounded tab never strands edits that IndexedDB alone would lose on recycle. Honored client-side. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0})}).default({backgroundThrottle:{enabled:!0},deferGuard:{enabled:!0},lossDetector:{enabled:!0},fixedPoint:{enabled:!0},preDrain:{enabled:!0},flushOnHide:{enabled:!0}}),search:R({semantic:R({enabled:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:N().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override to point at a self-hosted server (Ollama / vLLM / LM Studio) or another provider. The API key is NOT stored here — set it with `ok embeddings set-key` (`~/.ok/secrets.yml`); it is sent to whichever endpoint this names."}).default(Sf),model:N().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(Cf),dimensions:P().int().positive().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit (recommended) to detect the model's native size from its first response — that is what lets a non-OpenAI model work without knowing its size up front. Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality; a server that ignores the request param then fails loudly instead of silently. Changing it re-embeds the corpus.`}).optional(),similarityFloor:P().min(0).max(1).register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional()}).default({enabled:!1,baseUrl:Sf,model:Cf})}).default({semantic:{enabled:!1,baseUrl:Sf,model:Cf}}),contentRules:R({markdownlint:L({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the markdownlint plugin (body rules) contributes diagnostics.`}).default(!1)}).default({enabled:!1}),frontmatter:L({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the frontmatter plugin (JSON-Schema validation of document frontmatter) contributes diagnostics.`}).default(!1),schemas:I(L({appliesTo:to([N(),I(N())]).optional(),file:N(),enabled:F().optional()})).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Frontmatter schema mappings: which docs (appliesTo globs) validate against which JSON Schema file (project-root-relative path).`}).default([])}).default({enabled:!1,schemas:[]}),okf:L({enabled:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the OKF plugin (Open Knowledge Format portability + conformance rules) contributes diagnostics. Advisory warnings; never blocks a write.`}).default(!1),rules:so(N(),F()).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Per-rule opt-outs for the OKF plugin, keyed by rule id (e.g. no-wiki-links). Omit a rule to leave it enabled; set false to silence it while keeping the plugin on.`}).optional(),generate:L({index:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether OK generates and maintains a navigation index.md in every folder that contains Markdown, each listing the documents in that folder grouped by frontmatter type and linking to its subfolders. OK owns these files: edits to them are replaced on the next rebuild.`}).default(!1)}).default({index:!1})}).default({enabled:!1,generate:{index:!1}})}).default({markdownlint:{enabled:!1},frontmatter:{enabled:!1,schemas:[]},okf:{enabled:!1,generate:{index:!1}}}),validation:R({links:z(yd).register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`How broken internal links are reported on the validation plane: 'off' hides them, 'warning' (default) or 'error' sets their severity.`}).default(bd),fileTreeIndicators:F().register(H,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the file tree tints and badges files that have validation problems.`}).default(!0)}).default({links:bd,fileTreeIndicators:!0}),linkPreviews:R({enabled:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show a rich preview card (site name, page title, description, favicon) when you hover an external link in the editor. When ON, hovering an external link sends that link's URL to the destination site to fetch its preview metadata — outbound egress, one request per previewed link. Default ON; set to false to turn external previews off. Per-machine (project-local) — not shared with collaborators. Previews of links to other documents in this project are read from the local index with no network request and are always on.`}).default(!0)}).default({enabled:!0}),remote:R({url:N().register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:"Superseded by server.externalUrl — read only while server.externalUrl (and its deprecated server.publicUrl spelling) is absent. Public URL your tunnel gives you, e.g. https://myproject.ngrok.app. Used only with `ok start --remote` (config alone never enables remote access); its host is admitted through the Host-header allowlist. There is no server-side auth, so restrict access at the tunnel (ngrok OAuth, Cloudflare Access, Tailscale ACLs)."}).optional(),port:P().int().min(1).max(65535).register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Superseded by server.port — read only while server.port is absent. TCP port the server binds when remote access is enabled (default 24550). Fixed so the tunnel's port mapping survives restarts. Set it only on a conflict. An explicit --port still wins; the PORT env var is ignored in remote mode.`}).optional()}).default({}),server:R({port:P().int().min(1).max(65535).register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`TCP port the server listens on. Unset by default: a local start picks a free port dynamically, and deployment platforms inject the PORT environment variable instead. Supersedes remote.port (still read while this key is absent). Read at server start; changing it requires a restart.`}).optional(),bind:I(N().min(1)).min(1).register(H,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Addresses the server binds, e.g. [127.0.0.1] or [0.0.0.0]. Default loopback-only ([127.0.0.1]): nothing off this machine can connect. A non-loopback bind additionally requires the server.allowExternal consent interlock. Per-machine (project-local): a value committed to .ok/config.yml is ignored, so one machine exposing the server can never break local clones for the rest of the team — the exposing host sets it via OK_BIND, --bind, or .ok/local/config.yml. Lists replace, never merge. Read at server start; changing it requires a restart.`}).default([...wf]),externalUrl:Ea({protocol:/^https?$/}).regex(Ef).register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Canonical external origin the server is reached at, e.g. https://kb.example.com — its host joins the Host/Origin allowlists (external-Host + CORS admission). Unset by default: the server admits only loopback Hosts. Setting it declares external exposure, which additionally requires the server.allowExternal consent interlock. Supersedes server.publicUrl (its former name) and remote.url — both still read while this key is absent. Read at server start; changing it requires a restart.`}).optional(),publicUrl:Ea({protocol:/^https?$/}).regex(Ef).register(H,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Deprecated alias of server.externalUrl (the former name of that key) — read only while server.externalUrl is absent, with identical semantics. Use server.externalUrl instead; if this config is committed and shared, keep both keys until every collaborator has upgraded (older versions read only server.publicUrl).`}).optional(),allowExternal:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Exposure consent interlock. Once the unified server boot lands, a non-loopback server.bind or a server.externalUrl without allowExternal: true will be refused at boot with a one-line fix. Default off. Per-machine (project-local) — consent never travels via git, clone, or share; containers consent via the environment instead.`}).default(!1),openBrowser:F().register(H,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Open the UI in a browser when the server starts. Default derived: true when every bind address is loopback (a laptop start pops the UI), false otherwise (a container or exposed bind is headless and must never try). Acts once at start. Per-machine (project-local) — not shared.`}).optional(),idleShutdown:to([B(`off`),N().regex(Tf)]).register(H,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Shut the server down after this long with no activity: a duration like '30m' (positive integer with unit s, m, or h), or 'off'. Default derived: '30m' when every bind address is loopback, 'off' otherwise (an exposed or containerized server stays up). Reloadable — a valid change applies without a restart. Per-machine (project-local) — not shared.`}).optional()}).default({bind:[...wf],allowExternal:!1})}),Nf=`open-knowledge-config`;function Pf(e,t,n){let r=c.getTracer(Nf),i=t?{attributes:t}:{};return r.startActiveSpan(e,i,e=>{try{return n(e)}catch(t){throw e.recordException(t),e.setStatus({code:s.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function Ff(e,t){let n=c.getActiveSpan();n&&n.addEvent(e,t)}function If(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Lf(e,t){let n=e;for(let e of t){n=If(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function Rf(e,t){let n=Lf(e,t);if(n!==void 0)return mf(n)}function zf(e,t){return e===`either`?!0:e===t}function Bf(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}let a=Rf(Mf,i);a?.scope!==void 0&&(zf(a.scope,t)||(n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t}))}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}function Vf(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&($o(e.getIn(r,!0))||e.deleteIn(r))}}function Hf(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){Vf(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}Vf(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function Uf(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}var Wf=L({file:N(),line:P().int().min(1),column:P().int().min(1),snippet:N().optional()}),Gf=L({path:I(to([N(),P()])),message:N(),issueCode:N(),params:so(N(),Ya()).optional(),source:Wf.optional()}),Kf=z([`user`,`project`,`project-local`,`either`]),qf=z([`user`,`project`,`project-local`]),Jf=L({code:B(`YAML_PARSE`),detail:N()}),Yf=L({code:B(`UNREADABLE`),detail:N()}),Xf=L({code:B(`SCHEMA_INVALID`),issues:I(Gf)}),Zf=L({code:B(`REMOVED_KEY`),path:I(N()),redirect:N(),source:Wf.optional()}),Qf=ro(`code`,[Jf,Xf,Yf,L({code:B(`SCOPE_VIOLATION`),path:I(N()),expectedScope:Kf,actualScope:qf}),L({code:B(`NOT_AGENT_SETTABLE`),path:I(N())}),L({code:B(`MIXED_SCOPE`),paths:I(L({path:I(N()),scope:qf}))}),Zf,L({code:B(`WRITE_ERROR`),detail:N()}),L({code:B(`OKIGNORE_INVALID`),detail:N(),lineNumber:P().int().min(1).optional()}),L({code:B(`UNKNOWN`),message:N().optional()})]);ro(`code`,[Zf,Jf,Xf,Yf]),L({diagnostics:I(ro(`code`,[L({code:B(`REMOVED_KEY`),scope:qf,file:N(),path:I(N()),redirect:N()}),L({code:B(`YAML_PARSE`),scope:qf,file:N()}),L({code:B(`SCHEMA_INVALID`),scope:qf,file:N()}),L({code:B(`UNREADABLE`),scope:qf,file:N()})]))});var $f=new Set(Qf.options.map(e=>e.shape.code.value)),ep=to([Qf,R({code:N(),message:N().optional()})]);function tp(e){return $f.has(e.code)}function np(e){switch(e){case`user`:return`~/.ok/global.yml`;case`project`:return`.ok/config.yml`;case`project-local`:return`.ok/local/config.yml`;case`either`:return`.ok/config.yml or ~/.ok/global.yml`}}function rp(e){switch(e){case`user`:return`personal to you, across all projects`;case`project`:return`shared with your team via git`;case`project-local`:return`this machine only, not shared`;case`either`:return`user or project`}}function ip(e){if(!tp(e))return e.message??`Unknown error (${e.code}).`;switch(e.code){case`YAML_PARSE`:return`Failed to parse YAML: ${e.detail}`;case`UNREADABLE`:return`Could not read the file: ${e.detail}`;case`SCHEMA_INVALID`:{if(e.issues.length===0)return`Invalid configuration.`;let t=new Map;for(let n of e.issues){let e=n.source?.file??`<no source>`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];for(let[e,r]of t){e===`<no source>`?n.push(`Invalid configuration:`):n.push(`Invalid configuration at ${e}:`);for(let t of r){let r=t.path.length===0?`<root>`:t.path.join(`.`);if(t.source){if(n.push(` ${e}:${t.source.line}:${t.source.column}`),n.push(` ${r}: ${t.message}`),t.source.snippet&&t.source.snippet.length>0)for(let e of t.source.snippet.split(`
|
|
174
174
|
`))n.push(` ${e}`)}else n.push(` ${r}: ${t.message}`)}}return n.join(`
|
|
175
175
|
`)}case`SCOPE_VIOLATION`:return[`Setting ${e.path.join(`.`)} belongs in your ${e.expectedScope} config`,`(${np(e.expectedScope)} — ${rp(e.expectedScope)}),`,`but it was set in the ${e.actualScope} config (${np(e.actualScope)}).`,`Move it to ${np(e.expectedScope)}.`].join(` `);case`NOT_AGENT_SETTABLE`:return[`Setting ${e.path.join(`.`)} is human-only and can't be changed by an agent.`,`Change it in the Settings pane, or edit the config.yml by hand.`].join(` `);case`MIXED_SCOPE`:return[`This change touches settings that live in different config files. Apply them one file at a time:`,e.paths.map(({path:e,scope:t})=>` ${e.join(`.`)} → ${np(t)} (${t})`).join(`
|
|
176
176
|
`)].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{do as e}from"./dist-
|
|
1
|
+
import{do as e}from"./dist-CP7w45uR.js";function t(t){return e.includes(t)}function n(e){if(e.startsWith(_)||e.startsWith(x)||e.startsWith(S)||e.startsWith(T)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=v(t),r=n>=0?t.slice(0,n):t;if(!r)return null;try{return r.split(`/`).map(decodeURIComponent).join(`/`)}catch{return r}}function r(e){if(e.startsWith(_)||!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 i(e,t){let n=`#/${e}`;return t?`${n}#${encodeURIComponent(t)}`:n}function a(e,t){return e===t||o(e)===o(t)}function o(e){try{return decodeURIComponent(e)}catch{return e}}var s=`__okHashHistoryEntry`;function c(e){return{...typeof e==`object`&&e?e:{},[s]:!0}}function l(e){return typeof e==`object`&&!!e&&e[s]===!0}function u(){l(window.history.state)||window.history.replaceState(c(window.history.state),``)}function d(e){let{pathname:t,search:n}=window.location;window.history.replaceState(c(window.history.state),``,`${t}${n}${e}`)}function f(e){if(a(window.location.hash,e))return;let{pathname:t,search:n}=window.location;window.history.pushState(c(window.history.state),``,`${t}${n}${e}`)}function p(e){return e.endsWith(`.mdx`)?e.slice(0,-4):e.endsWith(`.md`)?e.slice(0,-3):e}function m(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?`#/${n}/`:`#/`;return t?`${r}#${encodeURIComponent(t)}`:r}function h(e,t,n){if(e===`folder`)return m(t);let r=`#/${encodeURIComponent(t)}`;return n==null||n===``?r:`${r}?branch=${encodeURIComponent(n)}`}function g(e){if(e===`#/`)return!0;if(!e.startsWith(`#/`))return!1;let t=e.slice(2);return t.length>0&&t[0]===`?`}var _=`#/__asset__/`;function v(e){let t=e.indexOf(`?`),n=e.indexOf(`#`);return t<0?n:n<0?t:Math.min(t,n)}function y(e){if(!e.startsWith(_))return null;let t=e.slice(12);if(!t)return null;try{return t.split(`/`).map(decodeURIComponent).join(`/`)}catch{return t}}function b(e){return`${_}${e.split(`/`).map(encodeURIComponent).join(`/`)}`}var x=`#/__skill-file__/`,S=`#/__skills__`;function C(){return S}function w(e){return e===S||e.startsWith(`${S}/`)}var T=`#/__skill-preview__/`,E=[`explore`,`detected`,`builtin`,`foreign`];function D(e){return e!==void 0&&E.includes(e)}var O=`project`;function k(e){return[e.flavor,e.source,e.name,e.subtitle,e.level??O].map(encodeURIComponent).join(`/`)}function A(e){if(!e)return null;let n;try{n=e.split(`/`).map(decodeURIComponent)}catch{return null}if(n.length<4||n.length>6)return null;let[r,i,a,o,s,c]=n;return!D(r)||!i||!a?null:{flavor:r,source:i,name:a,subtitle:o??``,...s&&t(s)?{level:s}:{},...c?{path:c}:{}}}function j(e){let t=k(e);return e.path&&(t+=`/${encodeURIComponent(e.path)}`),`${T}${t}`}function M(e){return e.startsWith(T)?A(e.slice(20)):null}var N=`:`;function P(e){let t=e.host===void 0?e.name:`${e.name}${N}${e.host}`;return`${x}${[e.scope,t].map(encodeURIComponent).join(`/`)}/${e.path.split(`/`).map(encodeURIComponent).join(`/`)}`}function F(e){if(!e.startsWith(x))return null;let n=e.slice(17);if(!n)return null;let r;try{r=n.split(`/`).map(decodeURIComponent)}catch{return null}if(r.length<3)return null;let[i,a,...o]=r,s=o.join(`/`);if(!i||!a||!s||!t(i))return null;let c=a.indexOf(N),l=c===-1?a:a.slice(0,c),u=c===-1?void 0:a.slice(c+1);return l?{scope:i,name:l,path:s,...u?{host:u}:{}}:null}var I=/\.(md|mdx)$/i;function L(e){return e.trim().replace(/^\.\/+/,``).replace(/^\/+/,``)}function R(e){return L(e).replace(I,``)}function z(e){let t=L(e);return t?I.test(t)?t:`${t}.md`:`untitled.md`}function B(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`}}export{F as C,d as S,w as T,g as _,y as a,u as b,h as c,b as d,i as f,C as g,j as h,r as i,k as l,P as m,z as n,A as o,m as p,R as r,n as s,B as t,p as u,l as v,M as w,f as x,a as y};
|