@inkeep/open-knowledge 0.30.1-beta.3 → 0.30.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +7 -7
- package/dist/constants-BamtMweE.mjs +2 -0
- package/dist/{dist-BXlA66Rv.mjs → dist-BGPS5oTH.mjs} +4 -4
- package/dist/{dist-MZRC45Vk.mjs → dist-CeqL7XDw.mjs} +1 -1
- package/dist/{gh-detect-BAop1ZEi.mjs → gh-detect-BBQ0hvZQ.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{init-DBwV0fyT.mjs → init-D5CAJYnk.mjs} +3 -3
- package/dist/init-DForgZd5.mjs +1 -0
- package/dist/{launch-json-removal-Bi1DnKqd.mjs → launch-json-removal-BGBjI4lC.mjs} +2 -2
- package/dist/loader-D6uZxgbr.mjs +1 -0
- package/dist/{loader-Y1OosjD1.mjs → loader-Dp1Djrsa.mjs} +2 -2
- package/dist/{open-browser-c8D-FzSc.mjs → open-browser-DuGgPkJK.mjs} +2 -2
- package/dist/{preview-D0-YLiYg.mjs → preview-BAPgNX0a.mjs} +2 -2
- package/dist/preview-CwkW9IFR.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-BmNXHtkV.js → ActivityModeContent-B6in_O1Z.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-Cqy5AMG8.js → CodeMirrorPropInput-NUkzT5mr.js} +1 -1
- package/dist/public/assets/{DocumentContext-TfAt4kJ2.js → DocumentContext-BJAwL4P0.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-CWfJC2tV.js → EnableSyncConfirmDialog-RbsLrbh4.js} +1 -1
- package/dist/public/assets/{GraphPanel-64dKrEeN.js → GraphPanel-DTvcxzIw.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-CdDmcobU.js → ManagedArtifactProperties-Z_fG0UXy.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-CBhFj_dO.js → McpConsentDialogBody-c8Z3og82.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-DHYDIKqN.js → MermaidDocEditor-Birdx5AP.js} +1 -1
- package/dist/public/assets/{PropertyPanel-zzS00_gE.js → PropertyPanel-5vzuwqyv.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-EMrRvJxz.js → SettingsDialogBody-Ct-kMNEx.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-BlhZ6hTx.js → ShareBranchSwitchDialog-D0MZJQUW.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-L3wJj8ez.js → ShareReceiveDialog-DOKc1Gtw.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-D6rKf26E.js → ShareReceiveMissDialog-DYS6Y8F-.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-BDxlCXpQ.js → SkillEditorActions-XG9-h7bh.js} +1 -1
- package/dist/public/assets/{SourceEditor-CEgPDQLe.js → SourceEditor-cp8eWJdW.js} +1 -1
- package/dist/public/assets/{TerminalPanel-CFfN7G5Q.js → TerminalPanel-e_PHIlot.js} +1 -1
- package/dist/public/assets/{agent-presence-DiQ_l3Q4.js → agent-presence-BTzwleGa.js} +1 -1
- package/dist/public/assets/{auth-state-cache-CRs0ug6Z.js → auth-state-cache-XVNbXSDx.js} +1 -1
- package/dist/public/assets/{config-provider-DON2sTkv.js → config-provider-CKk4xZCs.js} +1 -1
- package/dist/public/assets/{dist-cAytzZ0r.js → dist-C5brA6O_.js} +6 -6
- package/dist/public/assets/{dist-CUDp0fN-.js → dist-DQGNvD3o.js} +1 -1
- package/dist/public/assets/{doc-hash-KGQoVCvb.js → doc-hash-BEmwYTPt.js} +1 -1
- package/dist/public/assets/{documents-events-BnMDLvDB.js → documents-events-CQXM3_h4.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-uHXxUJ8g.js → file-tree-adapter-Cy45lbPy.js} +1 -1
- package/dist/public/assets/{index-CldKDggb.js → index-BnMlfMHb.js} +7 -7
- package/dist/public/assets/{keyboard-shortcuts-bJc2PBGE.js → keyboard-shortcuts-DHR0gqUE.js} +1 -1
- package/dist/public/assets/{navigation-targets-DdhO6GKu.js → navigation-targets-CSpdkJ79.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-qxJ9p8Vi.js → open-managed-artifact-tab-TVKjkwwk.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-v67LB7tS.js → pending-receive-nav-store-BkSZ5PVb.js} +1 -1
- package/dist/public/assets/{prop-types-Dkcm5cUg.js → prop-types-BM7SqB0E.js} +1 -1
- package/dist/public/assets/{receive-store-CtqQYghY.js → receive-store-CGifY8KG.js} +1 -1
- package/dist/public/assets/{selection-context-CowvMKTL.js → selection-context-DjUitADF.js} +1 -1
- package/dist/public/assets/{skill-actions-BPr2Aud_.js → skill-actions-h3b2AkKX.js} +1 -1
- package/dist/public/assets/{skills-api-Dg6gQ9CV.js → skills-api-CfTjwoyN.js} +1 -1
- package/dist/public/assets/{src-BYPkKUxg.js → src-Czck1vIx.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-DhT4boi_.js → target-navigation-intent-CoZvE5kT.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-PdfZQie3.js → typing-burst-detector-JLobuU6w.js} +1 -1
- package/dist/public/assets/{workspace-paths-DYS2c17l.js → workspace-paths-BSNpeUdb.js} +1 -1
- package/dist/public/index.html +25 -25
- package/dist/{repair-launch-json-DSPyAvfv.mjs → repair-launch-json-CQOagNZT.mjs} +2 -2
- package/dist/{repair-mcp-configs-D90tpFWq.mjs → repair-mcp-configs-CYvTKyqP.mjs} +2 -2
- package/dist/repair-skills-Dnzybfoq.mjs +1 -0
- package/dist/{repair-skills-BwUGllKc.mjs → repair-skills-EKmjzH3m.mjs} +2 -2
- package/dist/server-lock-GuuouVft-Dfr98QQD.mjs +1 -0
- package/dist/{server-lock-iLcBw_q0-WEyo7ukm.mjs → server-lock-iLcBw_q0-CMNgPc8K.mjs} +24 -24
- package/dist/{src-DFyrOeWH.mjs → src-CuuwWu2B.mjs} +2 -2
- package/dist/{start-BCB9qe0r.mjs → start-C35fHxrE.mjs} +2 -2
- package/dist/start-CgRJMaPV.mjs +1 -0
- package/dist/{write-project-skill-dxucK8PX.mjs → write-project-skill-PDBwVwKS.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-cCdfzfu9.mjs +0 -2
- package/dist/init-Barn0jh-.mjs +0 -1
- package/dist/loader-B28SY9O5.mjs +0 -1
- package/dist/preview-BbYvaq8Z.mjs +0 -1
- package/dist/repair-skills-BAEDb9Ho.mjs +0 -1
- package/dist/server-lock-GuuouVft-uqSUkxXo.mjs +0 -1
- package/dist/start-BhT_ogbu.mjs +0 -1
|
@@ -385,7 +385,7 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
|
|
|
385
385
|
`;)a--;if(a===r)return null;let o=t.slice(a,r);if(!NZ.test(o))return null;let s=t.slice(a,i);if(!PZ(s))return null;let c={start:{line:n.start.line,column:1,offset:a},end:n.end};return{type:`code`,lang:null,meta:null,value:FZ(s).replace(/\n+$/,``),position:c,data:{sourceStyle:`indented`}}}const LZ=function(){return(e,t)=>{let n=String(t.value??``);n&&dM(e,`paragraph`,(e,t,r)=>{if(!r||r.type!==`root`||t==null)return;let i=r.children[t-1];if(i&&i.type===`list`)return;let a=IZ(e,n);a&&(r.children[t]=a)})}};function RZ(e,t,n){let r={type:`mdxJsxFlowElement`,name:e,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t}],children:[]};return n&&(r.position=n),r}function zZ(){return e=>{dM(e,`math`,(e,t,n)=>{if(!n||t==null)return;let r=RZ(`DollarMath`,typeof e.value==`string`?e.value:``,e.position);n.children[t]=r}),dM(e,`code`,(e,t,n)=>{if(!n||t==null||e.lang!==`math`)return;let r=RZ(`MathFence`,typeof e.value==`string`?e.value:``,e.position);n.children[t]=r})}}const BZ=/<([a-zA-Z][a-zA-Z0-9+.-]*:[^\s<>]+)>/g;function VZ(e,t=``){let n=[],r=!1;for(let i of e.children){if(i.type!==`text`){n.push(i);continue}let e=i.value;BZ.lastIndex=0;let a=[],o=0;for(;;){let n=BZ.exec(e);if(n===null)break;let s=n[0],c=n[1],l=n.index;if(l>o){let n={type:`text`,value:e.slice(o,l)},r=XX(t,i,o,l);r&&(n.position=r),a.push(n)}let u={type:`text`,value:c},d=XX(t,i,l+1,l+1+c.length);d&&(u.position=d);let f={type:`link`,url:c,title:null,children:[u],data:{sourceStyle:`autolink`}},p=XX(t,i,l,l+s.length);p&&(f.position=p),a.push(f),o=l+s.length,r=!0}if(a.length===0)n.push(i);else{if(o<e.length){let n={type:`text`,value:e.slice(o)},r=XX(t,i,o,e.length);r&&(n.position=r),a.push(n)}n.push(...a)}}r&&(e.children=n)}const HZ=new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`.split(``));function UZ(e){let t=[],n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`&&r+1<e.length&&e[r+1]===`|`){n+=`${i}|`,r++;continue}if(i===`|`){t.push(n),n=``;continue}n+=i}return t.push(n),t}function WZ(e,t,n=!1,r){if(!t)return;let i=e.position;if(!i||typeof i.start?.offset!=`number`){n&&console.warn(`[position-slice] node type=${e.type} has no position — fidelity defaults apply`);return}let a=i.start.offset,o=i.end?.offset??a;if(a<0||o>t.length){n&&console.warn(`[position-slice] node type=${e.type} position out of bounds: start=${a} end=${o} sourceLen=${t.length}`);return}switch(e.data??={},e.type){case`text`:{let n=t.slice(a,o),r=e.value??``;if(n.length>r.length&&n.includes(`\\`)){let t=[],i=0,a=0;for(;i<n.length&&a<r.length;)n[i]===`\\`&&i+1<n.length&&HZ.has(n[i+1])&&r[a]===n[i+1]?(t.push({offset:a,char:n[i+1]}),i+=2,a+=1):(i++,a++);t.length>0&&(e.data.escapedChars=t)}n.endsWith(`\\`)&&r.endsWith(`\\`)&&(e.data.sourceRaw=n);break}case`emphasis`:{let n=t[a];(n===`*`||n===`_`)&&(e.data.sourceDelimiter=n);break}case`strong`:{let n=t.slice(a,a+2);(n===`**`||n===`__`)&&(e.data.sourceDelimiter=n);break}case`heading`:{let n=t[a],i=t.slice(a,o);if(n===`#`){if(e.data.sourceStyle=`atx`,r?.type===`root`){let n=a;for(;n>0&&t[n-1]!==`
|
|
386
386
|
`;)n--;let r=t.slice(n,a);r.length>=1&&r.length<=3&&/^ +$/.test(r)&&(e.data.sourceLeadingIndent=r.length)}let n=/^#+( {2,})[^ ]/.exec(i);n&&(e.data.sourceInteriorSpacing=n[1].length);let o=/^.*?[ \t](#+)[ \t]*$/.exec(i);o&&(e.data.sourceTrailingHashes=o[1].length)}else{let t=/\n(=+)[ \t]*$/.exec(i),n=/\n(-+)[ \t]*$/.exec(i),r=t??n;r?(e.data.sourceStyle=`setext`,e.data.sourceUnderlineLength=r[1].length):e.data.sourceStyle=`atx`}break}case`blockquote`:{let n=a;for(;n>0&&t[n-1]!==`
|
|
387
387
|
`;)n--;let r=!1;for(let e=n;e<a;e++)if(t[e]===`>`){r=!0;break}let i=t.slice(a,o).split(`
|
|
388
|
-
`),s=[];for(let e=0;e<i.length;e++){let t=i[e];if(t.length===0)continue;if(r&&e>0)break;let n=t.replace(/^ {1,3}/,``);if(n[0]
|
|
388
|
+
`),s=[];for(let e=0;e<i.length;e++){let t=i[e];if(t.trim().length===0)continue;if(r&&e>0)break;let n=t.replace(/^ {1,3}/,``);if(n[0]!==`>`){e>0&&t.trimStart()[0]!==`>`&&s.push(`lazy`);continue}if(n.slice(1).trimEnd()!==``)if(n[1]===` `)s.push(1);else{let e=0;for(;n[1+e]===` `;)e++;s.push(e)}}s.length>0&&(e.data.sourceMarkerSpacings=s);break}case`list`:{let n=e.children?.[0];if(n?.position?.start?.offset!=null){let r=n.position.start.offset;if(r>=0&&r<t.length){let n=t[r];if(!e.ordered&&(n===`-`||n===`*`||n===`+`))e.data.bulletMarker=n;else if(e.ordered){let n=t.slice(r,Math.min(r+10,t.length)).match(/^\d+([.)])/);n&&(e.data.listMarkerDelimiter=n[1])}}}break}case`listItem`:{let n=t.slice(a,o),r=/^(?:([-+*])|(\d{1,9})[.)])( *)/.exec(n);if(!r)break;let s=r[1]?1:(r[2]?.length??0)+1,c=r[3].length;c>=2&&c<=4&&(e.data.sourceMarkerSpacing=c),r[2]&&(e.data.sourceOrdinal=Number.parseInt(r[2],10)),e.checked!=null&&/^\[([xX])\] /.exec(n.slice(s+Math.max(c,1)))?.[1]===`X`&&(e.data.sourceCheckboxChar=`X`);let l=s+(c>=2&&c<=4?c:1),u=a;for(;u>0&&t[u-1]!==`
|
|
389
389
|
`;)u--;let d=i.start.column;for(let n of e.children??[]){if(n.type!==`list`)continue;let r=n.position?.start?.offset,i=n.position?.start?.column;if(typeof r!=`number`||typeof i!=`number`)continue;let a=r;for(;a>0&&t[a-1]!==`
|
|
390
390
|
`;)a--;if(a===u)continue;let o=i-d;o!==l&&o>=l&&o<=l+3&&/^ +$/.test(t.slice(a,r))&&(e.data.sourceContinuationIndent=o);break}break}case`delete`:t[a]===`~`&&(e.data.sourceDelimiter=t[a+1]===`~`?`~~`:`~`);break;case`code`:{let n=t[a];if(n==="`"||n===`~`){e.data.sourceStyle=`fenced`,e.data.sourceFenceChar=n;let i=0;for(;a+i<t.length&&t[a+i]===n;)i++;if(i>=3&&(e.data.sourceFenceLength=i),r?.type===`root`){let n=a;for(;n>0&&t[n-1]!==`
|
|
391
391
|
`;)n--;let r=t.slice(n,a);r.length>=1&&r.length<=3&&/^ +$/.test(r)&&(e.data.sourceFenceIndent=r.length)}if(e.lang){let n=0;for(;t[a+i+n]===` `;)n++;n>=1&&(e.data.sourceInfoPadding=n)}let s=t.slice(a,o),c=RegExp(`\\n[ \\t]*(\\${n}+)[ \\t]*$`).exec(s);c&&c[1].length>i&&(e.data.sourceClosingFenceLength=c[1].length)}else if(e.data.sourceStyle=`indented`,r?.type===`root`){let n=t.slice(a,o).split(`
|
|
@@ -398,9 +398,9 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
|
|
|
398
398
|
`);)t--;n[t]===`"`?e.data.sourceTitleMarker=`double`:n[t]===`'`?e.data.sourceTitleMarker=`single`:n[t]===`)`&&(e.data.sourceTitleMarker=`paren`)}}}}break;case`definition`:{let n=t.slice(a,o);if(e.data.sourceLayout=n.includes(`
|
|
399
399
|
`)?`multiline`:`inline`,typeof e.title==`string`&&n.length>0){let t=n[n.length-1];t===`"`?e.data.sourceTitleMarker=`double`:t===`'`?e.data.sourceTitleMarker=`single`:t===`)`&&(e.data.sourceTitleMarker=`paren`)}break}case`mdxJsxFlowElement`:case`mdxJsxTextElement`:case`mdxFlowExpression`:case`mdxTextExpression`:e.data.sourceRaw=t.slice(a,o);break;case`break`:if(e.data.sourceRaw)break;t.slice(a,o).includes(`\\`)?e.data.sourceStyle=`backslash`:e.data.sourceStyle=`spaces`;break}}function GZ(){return RegExp(`(^|\\s)#([a-zA-Z][\\w/-]*)`,`g`)}const KZ=GZ();function qZ(e,t){if(t<=0||e[t-1]!==`\\`)return!1;let n=t-1,r=0;for(;n>=0&&e[n]===`\\`;)r++,n--;return r%2==1}function JZ(e,t=``){let n=[],r=!1;for(let i of e.children){if(i.type!==`text`){n.push(i);continue}let e=i.value,a=typeof i.position?.start?.offset==`number`?i.position?.start?.offset??0:0;KZ.lastIndex=0;let o=[],s=0;for(;;){let n=KZ.exec(e);if(n===null)break;let c=n[1]??``,l=n[2]??``,u=n.index+c.length;if(t&&a>=0){let n=a,r=0,i=-1;for(;r<=u&&n<t.length;){let a=t[n]===`\\`&&n+1<t.length&&e[r]===t[n+1],o=a?n+1:n;if(r===u){i=o;break}n=a?n+2:n+1,r+=1}if(i>=0&&qZ(t,i))continue}if(u>s){let n={type:`text`,value:e.slice(s,u)},r=XX(t,i,s,u);r&&(n.position=r),o.push(n)}let d={type:`tag`,value:l},f=XX(t,i,u,u+1+l.length);f&&(d.position=f),o.push(d),s=u+1+l.length,r=!0}if(o.length===0)n.push(i);else{if(s<e.length){let n={type:`text`,value:e.slice(s)},r=XX(t,i,s,e.length);r&&(n.position=r),o.push(n)}n.push(...o)}}r&&(e.children=n)}const YZ=new Set(`root.paragraph.heading.text.emphasis.strong.blockquote.list.listItem.code.inlineCode.link.image.linkReference.imageReference.definition.html.thematicBreak.break.yaml.toml.table.tableRow.tableCell.delete.footnoteDefinition.footnoteReference.mdxFlowExpression.mdxJsxFlowElement.mdxJsxTextElement.mdxTextExpression.wikiLink.wikiLinkEmbed.tag.math.inlineMath.mark.comment.commentBlock.rawMdxFallbackMdast`.split(`.`));function XZ(e,t){if(!e||typeof e!=`object`)return null;if(typeof e.offset==`number`)return e.offset>=0&&e.offset<=t.length?e.offset:null;let{line:n,column:r}=e;if(typeof n!=`number`||typeof r!=`number`||n<1||r<1)return null;let i=0;for(let e=1;e<n;e++){let e=t.indexOf(`
|
|
400
400
|
`,i);if(e===-1)return null;i=e+1}let a=t.indexOf(`
|
|
401
|
-
`,i),o=a===-1?t.length:a,s=i+r-1;return s<=o?s:null}function ZZ(e,t){if(!e)return null;let n=XZ(e.start,t),r=XZ(e.end,t);return n===null||r===null||r<n?null:t.slice(n,r)}function QZ(e,t){let n=ZZ(e.position,t);return{type:`rawMdxFallbackMdast`,originalType:e.type??`unknown`,value:n??``,unresolvedPosition:n===null,position:e.position}}function $Z(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``,r=typeof process<`u`&&process.env?.OK_DEBUG_POSITION_SLICE===`1`;dM(e,(e,t,i)=>{if(i!==void 0&&typeof t==`number`&&typeof e.type==`string`&&!YZ.has(e.type)){let r=QZ(e,n);return i.children[t]=r,cM}if(`children`in e&&Array.isArray(e.children)){let t=e;t.children.some(e=>e.type===`text`)&&(VZ(t,n),JZ(t,n))}if(WZ(e,n,r,i),e.type===`heading`&&i!==void 0&&typeof t==`number`&&e.data?.sourceStyle===`setext`){let n=e.position?.end?.line,r=i.children[t+1],a=r?.position?.start?.line;if(r?.type===`paragraph`&&typeof n==`number`&&typeof a==`number`&&a===n+1){let t=e;t.data??={},t.data.sourceContiguousNext=!0}}})}}function eQ(e,t){let n={type:`mdxJsxFlowElement`,name:`MermaidFence`,attributes:[{type:`mdxJsxAttribute`,name:`chart`,value:e}],children:[]};return t&&(n.position=t),n}function tQ(){return e=>{dM(e,`code`,(e,t,n)=>{if(!n||t==null||e.lang!==`mermaid`)return;let r=eQ(typeof e.value==`string`?e.value:``,e.position);n.children[t]=r})}}function nQ(e,t){let n=e,r=t;return n.type===`heading`&&n.data?.sourceContiguousNext===!0&&r.type===`paragraph`}const rQ=(e,t)=>{if(nQ(e,t))return 0;let n=t.data?.sourcePrecedingBlankLines;if(typeof n==`number`&&n>=2)return n;let r=e.position,i=t.position;if(!r||!i)return;let a=i.start.line-r.end.line-1;return a>=1?a:void 0},iQ=OV(),aQ=KB(),oQ=qB();function sQ(){let e=this.data();e.micromarkExtensions||=[],e.fromMarkdownExtensions||=[],e.toMarkdownExtensions||=[];let t=e.micromarkExtensions;t.some(e=>e===iQ)||t.push(iQ);let n=e.fromMarkdownExtensions;n.some(e=>e===aQ)||n.push(aQ);let r=e.toMarkdownExtensions;r.some(e=>e===oQ)||r.push(oQ)}const cQ=/(?<!\\)\$(?=\S)([^$\n]*?[^\s$])\$(?!\d)/g;function lQ(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``;dM(e,`text`,(e,t,r)=>{if(r===void 0||t==null)return;let i=e.value;if(i.indexOf(`$`)===-1)return;cQ.lastIndex=0;let a=[],o;for(;(o=cQ.exec(i))!==null;)a.push(o);if(a.length===0)return;let s=[],c=0;for(let t of a){let r=t.index,a=r+t[0].length;if(r>c){let t={type:`text`,value:i.slice(c,r)},a=XX(n,e,c,r);a&&(t.position=a),s.push(t)}let o={type:`inlineMath`,value:t[1]},l=XX(n,e,r,a);l&&(o.position=l),s.push(o),c=a}if(c<i.length){let t={type:`text`,value:i.slice(c)},r=XX(n,e,c,i.length);r&&(t.position=r),s.push(t)}return r.children.splice(t,1,...s),[cM,t+s.length]})}}const uQ={handlers:{tag:e=>`#${e.value}`},unsafe:[{character:`#`,inConstruct:[`phrasing`],before:`\\s`,after:`[a-zA-Z]`}]};function dQ(){let e=this.data();e.toMarkdownExtensions||=[],e.toMarkdownExtensions.some(e=>e===uQ)||e.toMarkdownExtensions.push(uQ)}const fQ=/(?<!\uE102)<br[ \t]*\/?>/g,pQ=new Set([`mdxJsxTextElement`,`mdxJsxFlowElement`]);function mQ(e,t){let n=[],r=!1;for(let i of e.children){if(i.type!==`text`){n.push(i);continue}let e=i.value;fQ.lastIndex=0;let a=[],o=0;for(;;){let n=fQ.exec(e);if(n===null)break;let s=n.index;if(s>o){let n={type:`text`,value:e.slice(o,s)},r=XX(t,i,o,s);r&&(n.position=r),a.push(n)}let c={type:`break`,data:{sourceStyle:`html`,sourceRaw:n[0]}},l=XX(t,i,s,s+n[0].length);l&&(c.position=l),a.push(c),o=s+n[0].length,r=!0}if(a.length===0)n.push(i);else{if(o<e.length){let n={type:`text`,value:e.slice(o)},r=XX(t,i,o,e.length);r&&(n.position=r),a.push(n)}n.push(...a)}}r&&(e.children=n)}function hQ(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``;dM(e,e=>{if(pQ.has(e.type))return cM;let t=e;Array.isArray(t.children)&&mQ(e,n)})}}const gQ={name:`wikiLink`,tokenize:(e,t,n)=>{let r=0,i=0,a=0;return o;function o(t){return t===91?(e.enter(`wikiLink`),e.enter(`wikiLinkMarker`),e.consume(t),s):n(t)}function s(t){return t===91?(e.consume(t),e.exit(`wikiLinkMarker`),e.enter(`wikiLinkTarget`),c):n(t)}function c(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?r===0?n(t):(e.exit(`wikiLinkTarget`),d(t)):t===35?r===0?n(t):(e.exit(`wikiLinkTarget`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAnchor`),l):t===124?r===0?n(t):(e.exit(`wikiLinkTarget`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAlias`),u):(e.consume(t),r++,c)}function l(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?i===0?n(t):(e.exit(`wikiLinkAnchor`),d(t)):t===124?i===0?n(t):(e.exit(`wikiLinkAnchor`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAlias`),u):(e.consume(t),i++,l)}function u(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?a===0?n(t):(e.exit(`wikiLinkAlias`),d(t)):(e.consume(t),a++,u)}function d(t){return t===93?(e.enter(`wikiLinkMarker`),e.consume(t),f):n(t)}function f(r){return r===93?(e.consume(r),e.exit(`wikiLinkMarker`),e.exit(`wikiLink`),t):n(r)}}},_Q={name:`wikiLinkEmbed`,tokenize:(e,t,n)=>{let r=0,i=0,a=0;return o;function o(t){return t===33?(e.enter(`wikiLinkEmbed`),e.enter(`wikiLinkEmbedBang`),e.consume(t),e.exit(`wikiLinkEmbedBang`),s):n(t)}function s(t){return t===91?(e.enter(`wikiLinkMarker`),e.consume(t),c):n(t)}function c(t){return t===91?(e.consume(t),e.exit(`wikiLinkMarker`),e.enter(`wikiLinkTarget`),l):n(t)}function l(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?r===0?n(t):(e.exit(`wikiLinkTarget`),f(t)):t===35?r===0?n(t):(e.exit(`wikiLinkTarget`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAnchor`),u):t===124?r===0?n(t):(e.exit(`wikiLinkTarget`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAlias`),d):(e.consume(t),r++,l)}function u(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?i===0?n(t):(e.exit(`wikiLinkAnchor`),f(t)):t===124?i===0?n(t):(e.exit(`wikiLinkAnchor`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAlias`),d):(e.consume(t),i++,u)}function d(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?a===0?n(t):(e.exit(`wikiLinkAlias`),f(t)):(e.consume(t),a++,d)}function f(t){return t===93?(e.enter(`wikiLinkMarker`),e.consume(t),p):n(t)}function p(r){return r===93?(e.consume(r),e.exit(`wikiLinkMarker`),e.exit(`wikiLinkEmbed`),t):n(r)}}};function vQ(){return{text:{91:gQ,33:_Q}}}function yQ(e){this.enter({type:`wikiLink`,value:``,data:{target:``,anchor:null,alias:null},children:[]},e)}function bQ(e){this.enter({type:`wikiLinkEmbed`,value:``,data:{target:``,anchor:null,alias:null},children:[]},e)}function xQ(e){return e.stack[e.stack.length-1]}function SQ(e){let t=xQ(this),n=this.sliceSerialize(e);t.data.target=n.trim(),n!==t.data.target&&(t.data.sourceTarget=n)}function CQ(e){let t=xQ(this),n=this.sliceSerialize(e),r=n.trim();t.data.anchor=r.length?r:null,t.data.anchor!==null&&n!==r&&(t.data.sourceAnchor=n)}function wQ(e){let t=xQ(this),n=this.sliceSerialize(e),r=n.trim();t.data.alias=r.length?r:null,t.data.alias!==null&&n!==r&&(t.data.sourceAlias=n)}function TQ(e){let{target:t,anchor:n,alias:r}=e.data,i=r||(n?`${t}#${n}`:t);e.value=i,e.children=[{type:`text`,value:i}]}function EQ(e){TQ(xQ(this)),this.exit(e)}function DQ(e){TQ(xQ(this)),this.exit(e)}const OQ={enter:{wikiLink:yQ,wikiLinkEmbed:bQ},exit:{wikiLinkTarget:SQ,wikiLinkAnchor:CQ,wikiLinkAlias:wQ,wikiLink:EQ,wikiLinkEmbed:DQ}};function kQ(e,t){return typeof e==`string`&&e.trim()===t?e:t}const AQ={handlers:{wikiLink:e=>{let t=e,n=t.data?.target??``,r=t.data?.anchor,i=t.data?.alias,a=`[[${kQ(t.data?.sourceTarget,n)}`;return r&&(a+=`#${kQ(t.data?.sourceAnchor,r)}`),i&&(a+=`|${kQ(t.data?.sourceAlias,i)}`),`${a}]]`},wikiLinkEmbed:e=>{let t=e,n=t.data?.target??``,r=t.data?.anchor,i=t.data?.alias,a=`![[${n}`;return r&&(a+=`#${r}`),i&&(a+=`|${i}`),`${a}]]`}},unsafe:[{character:`[`,inConstruct:[`phrasing`]}]},jQ=vQ();function MQ(){let e=this.data();e.micromarkExtensions||=[],e.micromarkExtensions.some(e=>e===jQ)||e.micromarkExtensions.push(jQ),e.fromMarkdownExtensions||=[],e.fromMarkdownExtensions.some(e=>e===OQ)||e.fromMarkdownExtensions.push(OQ),e.toMarkdownExtensions||=[],e.toMarkdownExtensions.some(e=>e===AQ)||e.toMarkdownExtensions.push(AQ)}function NQ(e){return e.children.some(e=>{let t=e.type;return t!==`yaml`&&t!==`toml`})?e:{...e,children:[...e.children,{type:`paragraph`,children:[]}]}}const PQ=[{name:`remark-parse`,plugin:oB},{name:`remark-mdx-agnostic`,plugin:sQ},{name:`remark-gfm`,plugin:tR},{name:`remark-math`,plugin:xz,options:{singleDollarTextMath:!1}},{name:`remark-wiki-link`,plugin:MQ},{name:`remark-github-alerts`,plugin:lz,options:KX},{name:`callout-transformer`,plugin:GX},{name:`restore-from-mdx`,plugin:SX},{name:`void-br-promoter`,plugin:hQ},{name:`restore-entity-refs`,plugin:AX},{name:`restore-backslash-escapes`,plugin:NX},{name:`details-accordion-promoter`,plugin:CZ},{name:`image-promoter`,plugin:jZ},{name:`indented-code-promoter`,plugin:LZ},{name:`math-promoter`,plugin:zZ},{name:`single-dollar-math-promoter`,plugin:lQ},{name:`highlight-promoter`,plugin:AZ},{name:`mermaid-promoter`,plugin:tQ},{name:`comment-promoter`,plugin:$X},{name:`merged-post-parse-walker`,plugin:$Z},{name:`ensure-non-empty-doc`,plugin:()=>NQ}];function FQ(e){let t=dR();for(let e of PQ)t=`options`in e&&e.options!==void 0?t.use(e.plugin,e.options):t.use(e.plugin);return t=t.use(FR,{schema:e.schema,handlers:e.handlers}),t.freeze(),t}function IQ(e){let t=dR().use(az,[`yaml`]).use(tR,{tablePipeAlign:!1}).use(xz,{singleDollarTextMath:!1}).use(sQ).use(MQ).use(dQ).use(nR,{bullet:`-`,fences:!0,rule:`-`,join:[rQ],...e.toMarkdownHandlers?{handlers:e.toMarkdownHandlers}:{}});return t.freeze(),t}function LQ(e){return e.charCodeAt(0)===65279?{source:e.slice(1),hadBom:!0}:{source:e,hadBom:!1}}const RQ=/^\n+$/,zQ=/^\n{2,}$/;function BQ(e,t,n){let r,i,a,o=e.children;if(o.length>0){let e=o[0]?.position?.start?.offset;if(typeof e==`number`&&e>0){let n=t.slice(0,e);RQ.test(n)&&(r=n)}let n=o[o.length-1]?.position?.end?.offset;if(typeof n==`number`&&n<=t.length){let e=t.slice(n);zQ.test(e)&&(i=e)}let s=[],c=!1;for(let e=1;e<o.length;e++){let n=o[e-1]?.position?.end?.offset,r=o[e]?.position?.start?.offset,i=null;if(typeof n==`number`&&typeof r==`number`&&r>=n){let e=t.slice(n,r);RegExp(`^\\n{3,}$`).test(e)&&(i=e.length-1,c=!0)}s.push(i)}c&&(a=s)}if(!n&&r===void 0&&i===void 0&&!a)return;let s={...n?{bom:!0}:{},...r===void 0?{}:{leading:r},...i===void 0?{}:{trailing:i},...a?{gapBlankLines:a}:{}};return e.data??={},e.data.sourceDocBoundary=s,s}function VQ(e){if(typeof e!=`object`||!e)return;let t=e,n={};return t.bom===!0&&(n.bom=!0),typeof t.leading==`string`&&RQ.test(t.leading)&&(n.leading=t.leading),typeof t.trailing==`string`&&zQ.test(t.trailing)&&(n.trailing=t.trailing),Array.isArray(t.gapBlankLines)&&t.gapBlankLines.every(e=>e===null||typeof e==`number`&&Number.isInteger(e)&&e>=2)&&(n.gapBlankLines=t.gapBlankLines),n.bom||n.leading||n.trailing||n.gapBlankLines?n:void 0}function HQ(e,t){let{source:n,hadBom:r}=LQ(e),i=fZ(n),a=new Ij(DX(bX(MX(i)))),o=t.parse(a);a.value=i;let s=t.runSync(o,a),c=BQ(s,i,r),l=t.stringify(s);return c?l.type.create({...l.attrs,sourceDocBoundary:c},l.content,l.marks):l}function UQ(e,t){let{source:n,hadBom:r}=LQ(e),i=fZ(n),a=new Ij(DX(bX(MX(i)))),o=t.parse(a);a.value=i;let s=t.runSync(o,a);return BQ(s,i,r),s}function WQ(e,t,n){let r=LR(e,{schema:n.schema,nodeHandlers:n.pmNodeHandlers,markHandlers:n.pmMarkHandlers}),i=VQ(e.attrs?.sourceDocBoundary),a=i?.gapBlankLines;if(a&&a.length===r.children.length-1)for(let e=1;e<r.children.length;e++){let t=a[e-1];if(typeof t==`number`){let n=r.children[e];n.data??={},n.data.sourcePrecedingBlankLines=t}}let o=String(t.stringify(r));return i?.leading&&(o=i.leading+o),i?.trailing&&(o=o.replace(/\n+$/,``)+i.trailing),i?.bom&&(o=`\uFEFF${o}`),o}function GQ(){return typeof process>`u`||!process.env?!1:process.env.NODE_ENV===`development`||process.env.NODE_ENV===`test`}function KQ(e){let t=e.lastIndexOf(`/`);return t===-1?``:t===0?`/`:e.slice(0,t)}function qQ(e,t){let n=e?`${e}/${t}`:t,r=n.startsWith(`/`),i=[];for(let e of n.split(`/`))if(!(e===``||e===`.`)){if(e===`..`){let e=i[i.length-1];i.length>0&&e!==`..`?i.pop():r||i.push(`..`);continue}i.push(e)}let a=i.join(`/`);return r?`/${a}`:a}function JQ(e,t){if(typeof e!=`string`||e===``||!t||e.startsWith(`/`)||!wK(e))return e;let n=qQ(KQ(t),e);return n===``||n===`..`||n.startsWith(`../`)?(GQ()&&console.warn(`[resolve-image-url] doc-relative path escapes contentDir; emitting raw URL: ${e} (from sourcePath ${t})`),e):`/${n}`}const YQ=Object.assign(m$,{peek:()=>`$`}),XQ=Object.assign(h$,{peek:()=>`~`}),ZQ=(()=>{for(let e of oQ.extensions??[]){let t=e?.handlers?.mdxJsxFlowElement;if(typeof t==`function`)return t}throw Error(`mdast-util-mdx-jsx mdxJsxFlowElement to-markdown handler not found — the dirty MDX JSX serialize path cannot bind. Likely a breaking change in mdast-util-mdx-jsx (pinned in the root overrides); re-run the markdown-pipeline upgrade protocol (test:fidelity).`)})(),QQ={text(e,t,n,r){if(typeof e.data?.sourceRaw==`string`&&QK(e.data.sourceRaw,e.value??``))return e.data.sourceRaw;if(e.data?.escapedChars?.length){let t=e.value??``,i=e.data.escapedChars,a=``,o=0;for(let{offset:e,char:s}of i)e>o&&(a+=o$(n,t.slice(o,e),{...r,before:r.before+a,after:`\\`})),a+=`\\${s}`,o=e+1;return o<t.length&&(a+=o$(n,t.slice(o),{...r,before:r.before+a})),a}return o$(n,(e.value??``).replaceAll(`\xA0`,` `),r)},emphasis(e,t,n,r){let i=e.data?.sourceDelimiter??`*`,a=n.createTracker(r),o=n.enter(`emphasis`),s=a.move(i);return s+=d$(n.containerPhrasing(e,{before:s,after:i,...a.current()}),r,i),s+=a.move(i),o(),s},strong(e,t,n,r){let i=e.data?.sourceDelimiter??`**`,a=n.createTracker(r),o=n.enter(`strong`),s=a.move(i);return s+=d$(n.containerPhrasing(e,{before:s,after:i,...a.current()}),r,i),s+=a.move(i),o(),s},link(e,t,n,r){if(e.data?.sourceStyle===`autolink`)return`<${e.url??``}>`;if(e.data?.sourceStyle===`gfm-autolink`){let t=e.children?.length===1?e.children[0]:null;if(t?.type===`text`&&typeof t.value==`string`)return t.value}let i=n.createTracker(r),a=n.enter(`link`),o=n.enter(`label`),s=i.move(`[`);s+=i.move(n.containerPhrasing(e,{before:s,after:`](`,...i.current()})),s+=i.move(`](`),o();let c=n.enter(`destinationRaw`),l=String(e.url??``),u=e.data?.sourceUrlForm===`angle-bracketed`,d=l.startsWith(`<`)&&l.endsWith(`>`),f=u&&!d?`<${l}>`:r$(l);if(s+=i.move(f),c(),e.title){let t=e.data?.sourceTitleMarker??`double`;s+=i.move(n$(e.title,t))}return s+=i.move(`)`),a(),s},image(e,t,n,r){let i=n.createTracker(r),a=n.enter(`image`),o=n.enter(`label`),s=i.move(`})),s+=i.move(`](`),o();let c=n.enter(`destinationRaw`);if(s+=i.move(r$(String(e.url??``))),c(),e.title){let t=n.enter(`titleQuote`);s+=i.move(` "`),s+=i.move(n.safe(e.title,{before:s,after:`"`,...i.current()})),s+=i.move(`"`),t()}return s+=i.move(`)`),a(),s},definition(e,t,n,r){let i=e.data?.sourceLayout??`inline`,a=e.data?.sourceTitleMarker??`double`,o=n.enter(`definition`),s=n.createTracker(r),c=n.enter(`label`),l=s.move(`[`);l+=s.move(n.safe(n.associationId(e),{before:l,after:`]`,...s.current()})),l+=s.move(`]:`),c();let u=i===`multiline`?`
|
|
402
|
-
`:` `;l+=s.move(u);let d=String(e.url??``);if(!d||/[\0- ]/.test(d)){let e=n.enter(`destinationLiteral`);l+=s.move(`<`),l+=s.move(n.safe(d,{before:l,after:`>`,...s.current()})),l+=s.move(`>`),e()}else{let e=n.enter(`destinationRaw`);l+=s.move(
|
|
403
|
-
`:` `;l+=s.move(
|
|
401
|
+
`,i),o=a===-1?t.length:a,s=i+r-1;return s<=o?s:null}function ZZ(e,t){if(!e)return null;let n=XZ(e.start,t),r=XZ(e.end,t);return n===null||r===null||r<n?null:t.slice(n,r)}function QZ(e,t){let n=ZZ(e.position,t);return{type:`rawMdxFallbackMdast`,originalType:e.type??`unknown`,value:n??``,unresolvedPosition:n===null,position:e.position}}function $Z(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``,r=typeof process<`u`&&process.env?.OK_DEBUG_POSITION_SLICE===`1`;dM(e,(e,t,i)=>{if(i!==void 0&&typeof t==`number`&&typeof e.type==`string`&&!YZ.has(e.type)){let r=QZ(e,n);return i.children[t]=r,cM}if(`children`in e&&Array.isArray(e.children)){let t=e;t.children.some(e=>e.type===`text`)&&(VZ(t,n),JZ(t,n))}if(WZ(e,n,r,i),e.type===`heading`&&i!==void 0&&typeof t==`number`){let n=e.position?.end?.line,r=i.children[t+1],a=r?.position?.start?.line;if(r?.type===`paragraph`&&typeof n==`number`&&typeof a==`number`&&a===n+1){let t=e;t.data??={},t.data.sourceContiguousNext=!0}}})}}function eQ(e,t){let n={type:`mdxJsxFlowElement`,name:`MermaidFence`,attributes:[{type:`mdxJsxAttribute`,name:`chart`,value:e}],children:[]};return t&&(n.position=t),n}function tQ(){return e=>{dM(e,`code`,(e,t,n)=>{if(!n||t==null||e.lang!==`mermaid`)return;let r=eQ(typeof e.value==`string`?e.value:``,e.position);n.children[t]=r})}}function nQ(e,t){let n=e,r=t;return n.type===`heading`&&n.data?.sourceContiguousNext===!0&&r.type===`paragraph`}const rQ=(e,t)=>{if(nQ(e,t))return 0;let n=t.data?.sourcePrecedingBlankLines;if(typeof n==`number`&&n>=2)return n;let r=e.position,i=t.position;if(!r||!i)return;let a=i.start.line-r.end.line-1;return a>=1?a:void 0},iQ=OV(),aQ=KB(),oQ=qB();function sQ(){let e=this.data();e.micromarkExtensions||=[],e.fromMarkdownExtensions||=[],e.toMarkdownExtensions||=[];let t=e.micromarkExtensions;t.some(e=>e===iQ)||t.push(iQ);let n=e.fromMarkdownExtensions;n.some(e=>e===aQ)||n.push(aQ);let r=e.toMarkdownExtensions;r.some(e=>e===oQ)||r.push(oQ)}const cQ=/(?<!\\)\$(?=\S)([^$\n]*?[^\s$])\$(?!\d)/g;function lQ(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``;dM(e,`text`,(e,t,r)=>{if(r===void 0||t==null)return;let i=e.value;if(i.indexOf(`$`)===-1)return;cQ.lastIndex=0;let a=[],o;for(;(o=cQ.exec(i))!==null;)a.push(o);if(a.length===0)return;let s=[],c=0;for(let t of a){let r=t.index,a=r+t[0].length;if(r>c){let t={type:`text`,value:i.slice(c,r)},a=XX(n,e,c,r);a&&(t.position=a),s.push(t)}let o={type:`inlineMath`,value:t[1]},l=XX(n,e,r,a);l&&(o.position=l),s.push(o),c=a}if(c<i.length){let t={type:`text`,value:i.slice(c)},r=XX(n,e,c,i.length);r&&(t.position=r),s.push(t)}return r.children.splice(t,1,...s),[cM,t+s.length]})}}const uQ={handlers:{tag:e=>`#${e.value}`},unsafe:[{character:`#`,inConstruct:[`phrasing`],before:`\\s`,after:`[a-zA-Z]`}]};function dQ(){let e=this.data();e.toMarkdownExtensions||=[],e.toMarkdownExtensions.some(e=>e===uQ)||e.toMarkdownExtensions.push(uQ)}const fQ=/(?<!\uE102)<br[ \t]*\/?>/g,pQ=new Set([`mdxJsxTextElement`,`mdxJsxFlowElement`]);function mQ(e,t){let n=[],r=!1;for(let i of e.children){if(i.type!==`text`){n.push(i);continue}let e=i.value;fQ.lastIndex=0;let a=[],o=0;for(;;){let n=fQ.exec(e);if(n===null)break;let s=n.index;if(s>o){let n={type:`text`,value:e.slice(o,s)},r=XX(t,i,o,s);r&&(n.position=r),a.push(n)}let c={type:`break`,data:{sourceStyle:`html`,sourceRaw:n[0]}},l=XX(t,i,s,s+n[0].length);l&&(c.position=l),a.push(c),o=s+n[0].length,r=!0}if(a.length===0)n.push(i);else{if(o<e.length){let n={type:`text`,value:e.slice(o)},r=XX(t,i,o,e.length);r&&(n.position=r),a.push(n)}n.push(...a)}}r&&(e.children=n)}function hQ(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``;dM(e,e=>{if(pQ.has(e.type))return cM;let t=e;Array.isArray(t.children)&&mQ(e,n)})}}const gQ={name:`wikiLink`,tokenize:(e,t,n)=>{let r=0,i=0,a=0;return o;function o(t){return t===91?(e.enter(`wikiLink`),e.enter(`wikiLinkMarker`),e.consume(t),s):n(t)}function s(t){return t===91?(e.consume(t),e.exit(`wikiLinkMarker`),e.enter(`wikiLinkTarget`),c):n(t)}function c(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?r===0?n(t):(e.exit(`wikiLinkTarget`),d(t)):t===35?r===0?n(t):(e.exit(`wikiLinkTarget`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAnchor`),l):t===124?r===0?n(t):(e.exit(`wikiLinkTarget`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAlias`),u):(e.consume(t),r++,c)}function l(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?i===0?n(t):(e.exit(`wikiLinkAnchor`),d(t)):t===124?i===0?n(t):(e.exit(`wikiLinkAnchor`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAlias`),u):(e.consume(t),i++,l)}function u(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?a===0?n(t):(e.exit(`wikiLinkAlias`),d(t)):(e.consume(t),a++,u)}function d(t){return t===93?(e.enter(`wikiLinkMarker`),e.consume(t),f):n(t)}function f(r){return r===93?(e.consume(r),e.exit(`wikiLinkMarker`),e.exit(`wikiLink`),t):n(r)}}},_Q={name:`wikiLinkEmbed`,tokenize:(e,t,n)=>{let r=0,i=0,a=0;return o;function o(t){return t===33?(e.enter(`wikiLinkEmbed`),e.enter(`wikiLinkEmbedBang`),e.consume(t),e.exit(`wikiLinkEmbedBang`),s):n(t)}function s(t){return t===91?(e.enter(`wikiLinkMarker`),e.consume(t),c):n(t)}function c(t){return t===91?(e.consume(t),e.exit(`wikiLinkMarker`),e.enter(`wikiLinkTarget`),l):n(t)}function l(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?r===0?n(t):(e.exit(`wikiLinkTarget`),f(t)):t===35?r===0?n(t):(e.exit(`wikiLinkTarget`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAnchor`),u):t===124?r===0?n(t):(e.exit(`wikiLinkTarget`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAlias`),d):(e.consume(t),r++,l)}function u(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?i===0?n(t):(e.exit(`wikiLinkAnchor`),f(t)):t===124?i===0?n(t):(e.exit(`wikiLinkAnchor`),e.enter(`wikiLinkSeparator`),e.consume(t),e.exit(`wikiLinkSeparator`),e.enter(`wikiLinkAlias`),d):(e.consume(t),i++,u)}function d(t){return t===null||t===-5||t===-4||t===-3||t===91?n(t):t===93?a===0?n(t):(e.exit(`wikiLinkAlias`),f(t)):(e.consume(t),a++,d)}function f(t){return t===93?(e.enter(`wikiLinkMarker`),e.consume(t),p):n(t)}function p(r){return r===93?(e.consume(r),e.exit(`wikiLinkMarker`),e.exit(`wikiLinkEmbed`),t):n(r)}}};function vQ(){return{text:{91:gQ,33:_Q}}}function yQ(e){this.enter({type:`wikiLink`,value:``,data:{target:``,anchor:null,alias:null},children:[]},e)}function bQ(e){this.enter({type:`wikiLinkEmbed`,value:``,data:{target:``,anchor:null,alias:null},children:[]},e)}function xQ(e){return e.stack[e.stack.length-1]}function SQ(e){let t=xQ(this),n=this.sliceSerialize(e);t.data.target=n.trim(),n!==t.data.target&&(t.data.sourceTarget=n)}function CQ(e){let t=xQ(this),n=this.sliceSerialize(e),r=n.trim();t.data.anchor=r.length?r:null,t.data.anchor!==null&&n!==r&&(t.data.sourceAnchor=n)}function wQ(e){let t=xQ(this),n=this.sliceSerialize(e),r=n.trim();t.data.alias=r.length?r:null,t.data.alias!==null&&n!==r&&(t.data.sourceAlias=n)}function TQ(e){let{target:t,anchor:n,alias:r}=e.data,i=r||(n?`${t}#${n}`:t);e.value=i,e.children=[{type:`text`,value:i}]}function EQ(e){TQ(xQ(this)),this.exit(e)}function DQ(e){TQ(xQ(this)),this.exit(e)}const OQ={enter:{wikiLink:yQ,wikiLinkEmbed:bQ},exit:{wikiLinkTarget:SQ,wikiLinkAnchor:CQ,wikiLinkAlias:wQ,wikiLink:EQ,wikiLinkEmbed:DQ}};function kQ(e,t){return typeof e==`string`&&e.trim()===t?e:t}const AQ={handlers:{wikiLink:e=>{let t=e,n=t.data?.target??``,r=t.data?.anchor,i=t.data?.alias,a=`[[${kQ(t.data?.sourceTarget,n)}`;return r&&(a+=`#${kQ(t.data?.sourceAnchor,r)}`),i&&(a+=`|${kQ(t.data?.sourceAlias,i)}`),`${a}]]`},wikiLinkEmbed:e=>{let t=e,n=t.data?.target??``,r=t.data?.anchor,i=t.data?.alias,a=`![[${n}`;return r&&(a+=`#${r}`),i&&(a+=`|${i}`),`${a}]]`}},unsafe:[{character:`[`,inConstruct:[`phrasing`]}]},jQ=vQ();function MQ(){let e=this.data();e.micromarkExtensions||=[],e.micromarkExtensions.some(e=>e===jQ)||e.micromarkExtensions.push(jQ),e.fromMarkdownExtensions||=[],e.fromMarkdownExtensions.some(e=>e===OQ)||e.fromMarkdownExtensions.push(OQ),e.toMarkdownExtensions||=[],e.toMarkdownExtensions.some(e=>e===AQ)||e.toMarkdownExtensions.push(AQ)}function NQ(e){return e.children.some(e=>{let t=e.type;return t!==`yaml`&&t!==`toml`})?e:{...e,children:[...e.children,{type:`paragraph`,children:[]}]}}const PQ=[{name:`remark-parse`,plugin:oB},{name:`remark-mdx-agnostic`,plugin:sQ},{name:`remark-gfm`,plugin:tR},{name:`remark-math`,plugin:xz,options:{singleDollarTextMath:!1}},{name:`remark-wiki-link`,plugin:MQ},{name:`remark-github-alerts`,plugin:lz,options:KX},{name:`callout-transformer`,plugin:GX},{name:`restore-from-mdx`,plugin:SX},{name:`void-br-promoter`,plugin:hQ},{name:`restore-entity-refs`,plugin:AX},{name:`restore-backslash-escapes`,plugin:NX},{name:`details-accordion-promoter`,plugin:CZ},{name:`image-promoter`,plugin:jZ},{name:`indented-code-promoter`,plugin:LZ},{name:`math-promoter`,plugin:zZ},{name:`single-dollar-math-promoter`,plugin:lQ},{name:`highlight-promoter`,plugin:AZ},{name:`mermaid-promoter`,plugin:tQ},{name:`comment-promoter`,plugin:$X},{name:`merged-post-parse-walker`,plugin:$Z},{name:`ensure-non-empty-doc`,plugin:()=>NQ}];function FQ(e){let t=dR();for(let e of PQ)t=`options`in e&&e.options!==void 0?t.use(e.plugin,e.options):t.use(e.plugin);return t=t.use(FR,{schema:e.schema,handlers:e.handlers}),t.freeze(),t}function IQ(e){let t=dR().use(az,[`yaml`]).use(tR,{tablePipeAlign:!1}).use(xz,{singleDollarTextMath:!1}).use(sQ).use(MQ).use(dQ).use(nR,{bullet:`-`,fences:!0,rule:`-`,join:[rQ],...e.toMarkdownHandlers?{handlers:e.toMarkdownHandlers}:{}});return t.freeze(),t}function LQ(e){return e.charCodeAt(0)===65279?{source:e.slice(1),hadBom:!0}:{source:e,hadBom:!1}}const RQ=/^\n+$/,zQ=/^\n{2,}$/;function BQ(e,t,n){let r,i,a,o=e.children;if(o.length>0){let e=o[0]?.position?.start?.offset;if(typeof e==`number`&&e>0){let n=t.slice(0,e);RQ.test(n)&&(r=n)}let n=o[o.length-1]?.position?.end?.offset;if(typeof n==`number`&&n<=t.length){let e=t.slice(n);zQ.test(e)&&(i=e)}let s=[],c=!1;for(let e=1;e<o.length;e++){let n=o[e-1]?.position?.end?.offset,r=o[e]?.position?.start?.offset,i=null;if(typeof n==`number`&&typeof r==`number`&&r>=n){let e=t.slice(n,r);RegExp(`^\\n{3,}$`).test(e)&&(i=e.length-1,c=!0)}s.push(i)}c&&(a=s)}if(!n&&r===void 0&&i===void 0&&!a)return;let s={...n?{bom:!0}:{},...r===void 0?{}:{leading:r},...i===void 0?{}:{trailing:i},...a?{gapBlankLines:a}:{}};return e.data??={},e.data.sourceDocBoundary=s,s}function VQ(e){if(typeof e!=`object`||!e)return;let t=e,n={};return t.bom===!0&&(n.bom=!0),typeof t.leading==`string`&&RQ.test(t.leading)&&(n.leading=t.leading),typeof t.trailing==`string`&&zQ.test(t.trailing)&&(n.trailing=t.trailing),Array.isArray(t.gapBlankLines)&&t.gapBlankLines.every(e=>e===null||typeof e==`number`&&Number.isInteger(e)&&e>=2)&&(n.gapBlankLines=t.gapBlankLines),n.bom||n.leading||n.trailing||n.gapBlankLines?n:void 0}function HQ(e,t){let{source:n,hadBom:r}=LQ(e),i=fZ(n),a=new Ij(DX(bX(MX(i)))),o=t.parse(a);a.value=i;let s=t.runSync(o,a),c=BQ(s,i,r),l=t.stringify(s);return c?l.type.create({...l.attrs,sourceDocBoundary:c},l.content,l.marks):l}function UQ(e,t){let{source:n,hadBom:r}=LQ(e),i=fZ(n),a=new Ij(DX(bX(MX(i)))),o=t.parse(a);a.value=i;let s=t.runSync(o,a);return BQ(s,i,r),s}function WQ(e,t,n){let r=LR(e,{schema:n.schema,nodeHandlers:n.pmNodeHandlers,markHandlers:n.pmMarkHandlers}),i=VQ(e.attrs?.sourceDocBoundary),a=i?.gapBlankLines;if(a&&a.length===r.children.length-1)for(let e=1;e<r.children.length;e++){let t=a[e-1];if(typeof t==`number`){let n=r.children[e];n.data??={},n.data.sourcePrecedingBlankLines=t}}let o=String(t.stringify(r));return i?.leading&&(o=i.leading+o),i?.trailing&&(o=o.replace(/\n+$/,``)+i.trailing),i?.bom&&(o=`\uFEFF${o}`),o}function GQ(){return typeof process>`u`||!process.env?!1:process.env.NODE_ENV===`development`||process.env.NODE_ENV===`test`}function KQ(e){let t=e.lastIndexOf(`/`);return t===-1?``:t===0?`/`:e.slice(0,t)}function qQ(e,t){let n=e?`${e}/${t}`:t,r=n.startsWith(`/`),i=[];for(let e of n.split(`/`))if(!(e===``||e===`.`)){if(e===`..`){let e=i[i.length-1];i.length>0&&e!==`..`?i.pop():r||i.push(`..`);continue}i.push(e)}let a=i.join(`/`);return r?`/${a}`:a}function JQ(e,t){if(typeof e!=`string`||e===``||!t||e.startsWith(`/`)||!wK(e))return e;let n=qQ(KQ(t),e);return n===``||n===`..`||n.startsWith(`../`)?(GQ()&&console.warn(`[resolve-image-url] doc-relative path escapes contentDir; emitting raw URL: ${e} (from sourcePath ${t})`),e):`/${n}`}const YQ=Object.assign(h$,{peek:()=>`$`}),XQ=Object.assign(g$,{peek:()=>`~`}),ZQ=(()=>{for(let e of oQ.extensions??[]){let t=e?.handlers?.mdxJsxFlowElement;if(typeof t==`function`)return t}throw Error(`mdast-util-mdx-jsx mdxJsxFlowElement to-markdown handler not found — the dirty MDX JSX serialize path cannot bind. Likely a breaking change in mdast-util-mdx-jsx (pinned in the root overrides); re-run the markdown-pipeline upgrade protocol (test:fidelity).`)})(),QQ=/^[ \t]*(?:$|#{1,6}(?:[ \t]|[ \t]*$)|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/,$Q={text(e,t,n,r){if(typeof e.data?.sourceRaw==`string`&&QK(e.data.sourceRaw,e.value??``))return e.data.sourceRaw;if(e.data?.escapedChars?.length){let t=e.value??``,i=e.data.escapedChars,a=``,o=0;for(let{offset:e,char:s}of i)e>o&&(a+=s$(n,t.slice(o,e),{...r,before:r.before+a,after:`\\`})),a+=`\\${s}`,o=e+1;return o<t.length&&(a+=s$(n,t.slice(o),{...r,before:r.before+a})),a}return s$(n,(e.value??``).replaceAll(`\xA0`,` `),r)},emphasis(e,t,n,r){let i=e.data?.sourceDelimiter??`*`,a=n.createTracker(r),o=n.enter(`emphasis`),s=a.move(i);return s+=f$(n.containerPhrasing(e,{before:s,after:i,...a.current()}),r,i),s+=a.move(i),o(),s},strong(e,t,n,r){let i=e.data?.sourceDelimiter??`**`,a=n.createTracker(r),o=n.enter(`strong`),s=a.move(i);return s+=f$(n.containerPhrasing(e,{before:s,after:i,...a.current()}),r,i),s+=a.move(i),o(),s},link(e,t,n,r){if(e.data?.sourceStyle===`autolink`)return`<${e.url??``}>`;if(e.data?.sourceStyle===`gfm-autolink`){let t=e.children?.length===1?e.children[0]:null;if(t?.type===`text`&&typeof t.value==`string`)return t.value}let i=n.createTracker(r),a=n.enter(`link`),o=n.enter(`label`),s=i.move(`[`);s+=i.move(n.containerPhrasing(e,{before:s,after:`](`,...i.current()})),s+=i.move(`](`),o();let c=n.enter(`destinationRaw`),l=String(e.url??``),u=e.data?.sourceUrlForm===`angle-bracketed`,d=l.startsWith(`<`)&&l.endsWith(`>`),f=u&&!d?`<${l}>`:i$(l);if(s+=i.move(f),c(),e.title){let t=e.data?.sourceTitleMarker??`double`;s+=i.move(r$(e.title,t))}return s+=i.move(`)`),a(),s},image(e,t,n,r){let i=n.createTracker(r),a=n.enter(`image`),o=n.enter(`label`),s=i.move(`})),s+=i.move(`](`),o();let c=n.enter(`destinationRaw`);if(s+=i.move(i$(String(e.url??``))),c(),e.title){let t=n.enter(`titleQuote`);s+=i.move(` "`),s+=i.move(n.safe(e.title,{before:s,after:`"`,...i.current()})),s+=i.move(`"`),t()}return s+=i.move(`)`),a(),s},definition(e,t,n,r){let i=e.data?.sourceLayout??`inline`,a=e.data?.sourceTitleMarker??`double`,o=n.enter(`definition`),s=n.createTracker(r),c=n.enter(`label`),l=s.move(`[`);l+=s.move(n.safe(n.associationId(e),{before:l,after:`]`,...s.current()})),l+=s.move(`]:`),c();let u=i===`multiline`?`
|
|
402
|
+
`:` `;l+=s.move(u);let d=String(e.url??``);if(!d||/[\0- ]/.test(d)){let e=n.enter(`destinationLiteral`);l+=s.move(`<`),l+=s.move(n.safe(d,{before:l,after:`>`,...s.current()})),l+=s.move(`>`),e()}else{let e=n.enter(`destinationRaw`);l+=s.move(i$(d)),e()}if(e.title){let t=i===`multiline`?`
|
|
403
|
+
`:` `;l+=s.move(r$(e.title,a,t))}return o(),l},thematicBreak(e){return e.data?.sourceRaw??`---`},break(e,t,n){let r=e.data?.sourceRaw;return typeof r==`string`&&r.length>0?r:n.stack.includes(`tableCell`)||n.stack.includes(`okAtxHeading`)?`<br />`:e.data?.sourceStyle===`backslash`?`\\
|
|
404
404
|
`:`
|
|
405
405
|
`},code(e){let t=e.value??``;if(e.data?.sourceStyle===`indented`){let n=t.split(`
|
|
406
406
|
`),r=e.data.sourceIndents;return Array.isArray(r)&&r.length===n.length?n.map((e,t)=>`${r[t]??(e.length>0?` `:``)}${e}`).join(`
|
|
@@ -422,39 +422,39 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
|
|
|
422
422
|
|
|
423
423
|
`:`
|
|
424
424
|
`;return l.join(f)},table(e,t,n,r){let i=n.enter(`table`),a=[],o=[],s=e.children??[];for(let e of s){let t=e.children??[],i=[],s=[];for(let e of t){let t=n.enter(`tableCell`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,{...r,before:` `,after:` `});a(),t(),i.push(o);let c=e.data?.sourcePadding;s.push(c&&typeof c.left==`number`&&typeof c.right==`number`?{left:c.left,right:c.right}:null)}a.push(i),o.push(s)}i();let c=e.align??[],l=e.data?.sourceDashCounts,u=a[0]?.length??0,d=a.slice(1).reduce((e,t)=>Math.max(e,t.length),0),f=Math.max(u,d,c.length);if(f===0)return console.warn(JSON.stringify({event:`table-serialize-dropped-empty`,rows:s.length})),``;let p=[];for(let e=0;e<f;e++){let t=c[e],n=``,r=``;t===`center`?(n=`:`,r=`:`):t===`left`?n=`:`:t===`right`&&(r=`:`);let i=l?.[e],a=typeof i==`number`&&i>=1?i:1;p.push(n+`-`.repeat(a)+r)}let m=(e,t)=>{let n=[];for(let r=0;r<f;r++){let i=e[r]??``,a=t[r]??{left:1,right:1};n.push(` `.repeat(a.left)+i+` `.repeat(a.right))}let r=v&&!v.leading?``:`|`,i=v&&!v.trailing?``:`|`;return`${r}${n.join(`|`)}${i}`},h=e.data?.sourceAlignmentPadding,g=Array.from({length:f},(e,t)=>{let n=h?.[t];return n&&typeof n.left==`number`&&typeof n.right==`number`?n:null}),_=e.data?.sourceOuterPipes,v=_&&f>=2&&a.every(e=>{let t=(e[0]??``).trim(),n=(e[f-1]??``).trim();return(_.leading||t.length>0)&&(_.trailing||n.length>0&&!n.endsWith(`\\`))})?_:null;if(a.length===0)return m(p,g);let y=[];y.push(m(a[0],o[0]??[])),y.push(m(p,g));for(let e=1;e<a.length;e++)y.push(m(a[e],o[e]??[]));return y.join(`
|
|
425
|
-
`)},mdxJsxFlowElement(e,t,n,r){let i=e,a=i.data?.sourceRaw;if(typeof a==`string`)return a;let o=i.data?.htmlBoundary;if(o&&typeof o.opener==`string`&&typeof o.closer==`string`){let e=n.containerFlow({type:`root`,children:i.children??[]},r);return`${o.opener}\n\n${e}\n\n${o.closer}`}let s=i.name??``,c
|
|
426
|
-
]|$)`};return delete t._compiled,t});let i;try{i=e.safe(t,n)}finally{e.unsafe=r}return
|
|
427
|
-
`||e[r]===`\r`;let i=n.after.charCodeAt(0);return Number.isNaN(i)||i===10||i===13}function u$(e,t){let n=``,r=0;for(;r<e.length;){let i=e.charAt(r);if(i===`\\`){n+=e.slice(r,r+2),r+=2;continue}if(i===`*`||i===`_`||i===`~`||i===`=`){let a=r+1;for(;a<e.length&&e.charAt(a)===i;)a++;let o=r===0?t.before.charCodeAt(t.before.length-1):e.charCodeAt(r-1);if(i===`=`)n+=(Number.isNaN(o)||o===10||o===13)&&l$(e,a,t)?`\\${e.slice(r,a)}`:e.slice(r,a);else{let s=a<e.length?e.charCodeAt(a):t.after.charCodeAt(0);n+=c$(i,o,s)?`\\${i}`.repeat(a-r):e.slice(r,a)}r=a;continue}n+=i,r+=1}return n}function d$(e,t,n){let r=n.startsWith(`_`)?`_`:`*`,i=t.before??``,a=t.after??``,o=e,s=o.charCodeAt(0);f$(i.charCodeAt(i.length-1),s,r)&&(o=p$(s)+o.slice(1));let c=o.charCodeAt(o.length-1);return f$(a.charCodeAt(0),c,r)&&(o=o.slice(0,-1)+p$(c)),o}function f$(e,t,n){return!(UN(t)!==1||n===`_`&&UN(e)===void 0)}function p$(e){return`&#x${e.toString(16).toUpperCase()};`}function m$(e,t,n,r){let i=e.value??``,a=e.data?.sourceDelimiter,o=typeof a==`string`&&/^\$+$/.test(a)?a.length:2;for(o===1&&!g$(i,r)&&(o=2);RegExp(`(^|[^$])${`\\$`.repeat(o)}([^$]|$)`).test(i);)o++;let s=`$`.repeat(o);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` ${i} `);let c=-1;for(;++c<n.unsafe.length;){let e=n.unsafe[c];if(!e.atBreak)continue;let t=n.compilePattern(e),r;for(;(r=t.exec(i))!==null;){let e=r.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=`${i.slice(0,e)} ${i.slice(r.index+1)}`}}return s+i+s}function h$(e,t,n,r){let i=e.data?.sourceDelimiter===`~`?`~`:`~~`,a=n.createTracker(r),o=n.enter(`strikethrough`),s=a.move(i);return s+=d$(n.containerPhrasing(e,{...a.current(),before:s,after:`~`}),r,i),s+=a.move(i),o(),s}function g$(e,t){return!(e.length===0||!/^\S/.test(e)||!/\S$/.test(e)||/[$\r\n]/.test(e)||e.endsWith(`\\`)||/\\[!-/:-@[-`{-~]/.test(e)||/^\d/.test(t.after)||t.before.endsWith(`\\`))}function _$(e){if(!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KiB`,`MiB`,`GiB`,`TiB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(1).replace(/\.0$/,``)} ${t[r]}`}var v$=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};freshnessHolder={checker:void 0};constructor(e){this.schema=_b(e.extensions),this.handlers=O$(this.schema,this.parseCtx),this.freshnessHolder.checker=e.deriveStructuralFreshness?zJ({parse:e=>this.parseWithFallback(e)}):void 0;let{nodeHandlers:t,markHandlers:n}=k$(this.schema,this.freshnessHolder);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=FQ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=IQ({toMarkdownHandlers:QQ})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return HQ(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?UQ(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?UY(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e,t){let n;try{n=this.schema.nodeFromJSON(e)}catch(t){let n=`MarkdownManager.serialize() failed: schema rejected JSONContent (type=${e.type}, childCount=${e.content?.length??0})`;throw Error(n,{cause:t})}let r=this.freshnessHolder.checker;t?.skipFreshnessDerive&&(this.freshnessHolder.checker=void 0);try{return WQ(n,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}finally{this.freshnessHolder.checker=r}}};const y$=jY();function b$(e,t){let n=new Map;for(let e of t)n.set(e.name,e);let r={};for(let t of e){if(t.type===`mdxJsxExpressionAttribute`)continue;let e=t.name,i=n.get(e);if(t.value===null||t.value===void 0){r[e]=!0;continue}if(typeof t.value==`string`){if(i?.type===`number`){let n=Number(t.value);r[e]=Number.isNaN(n)?t.value:n}else i?.type===`boolean`?r[e]=t.value===`true`:r[e]=t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function x$(e){let t=!1;return e.descendants(e=>t||e.type.name===`jsxInline`?!1:e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function S$(e,t){return e.attrs.sourceDirty||x$(e)?!0:t?t.isDiverged(e.toJSON()):!1}function C$(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0?!0:t.every(e=>e.type===`text`&&e.value===``)}function w$(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),t.sourcePadded===!0&&(n.sourcePadded=!0),Object.keys(n).length===0?e:{...e,data:n}}function T$(e,t){if(e.length===0)return w$({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return w$({type:`inlineCode`,value:e.map(e=>e.value).join(``)},t);if(e.length===1&&`children`in e[0]){let n=e[0];return{...n,children:[T$(n.children,t)]}}return w$({type:`inlineCode`,value:E$(e)},t)}function E$(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=E$(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const D$=Vc;function O$(e,t){let n=e.nodes,r=e.marks,i={};n.paragraph&&(i.paragraph=(e,t,r)=>{let i=r.all(e).flat(),a=i.some(e=>e?.isBlock&&!e?.isInline),o=i.some(e=>e?.isInline||e?.isText||e?.isTextblock);if(a&&!o)return i.length===1?i[0]:i;if(a&&o){let e=i.filter(e=>!e?.isBlock||e?.isInline),t=i.filter(e=>e?.isBlock&&!e?.isInline),r=[],a=n.paragraph.createAndFill(null,e.length>0?e:null);return a&&r.push(a),r.push(...t),r.length===1?r[0]:r}return n.paragraph.createAndFill(null,i.length>0?i:null)}),n.blockquote&&(i.blockquote=MR(n.blockquote,e=>({sourceMarkerSpacings:e.data?.sourceMarkerSpacings??null}))),n.tableCell&&(i.tableCell=(e=>(t,r,i)=>{let a=i.all(t).flat();if(a.length>0&&n.paragraph){let t=n.paragraph.create(null,a);return e.createAndFill(null,[t])}return e.createAndFill(null,null)})(n.tableCell)),n.tableRow&&(i.tableRow=MR(n.tableRow)),n.table&&n.tableRow&&n.tableCell&&(i.table=(e,t,r)=>{let i=e.align??[],a=e.children??[],o=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type!==`tableRow`)continue;let s=t.children??[],c=[];for(let t=0;t<s.length;t++){let a=s[t];if(a.type!==`tableCell`)continue;let o=r.all(a).flat(),l=o.length>0&&n.paragraph?[n.paragraph.create(null,o)]:null,u=i[t]??null,d=e===0&&n.tableHeader?n.tableHeader:n.tableCell,f=a.data?.sourcePadding??null,p=d.createAndFill({align:u,sourcePadding:f},l);p&&c.push(p)}let l=n.tableRow.createAndFill(null,c.length>0?c:null);l&&o.push(l)}let s=e.data?.sourceDashCounts??null,c=e.data?.sourceOuterPipes??null,l=e.data?.sourceAlignmentPadding??null;return n.table.createAndFill({sourceDashCounts:s,sourceOuterPipes:c,sourceAlignmentPadding:l},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=JQ(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r})},n.imageReference?i.imageReference=e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):i.imageReference=e=>n.image.createAndFill({src:``,alt:e.alt??null,title:null})),r.escapeMark&&(i.text=t=>{let n=t.value??``,i=typeof t.data?.sourceRaw==`string`?t.data.sourceRaw:null;if(!n&&!i)return null;if(i){let t=n.replaceAll(`\xA0`,` `);return r.sourceLiteral?e.text(t,[r.sourceLiteral.create({sourceRaw:i})]):e.text(t)}let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n.replaceAll(`\xA0`,` `));let s=[...(a??[]).map(e=>({kind:`escape`,offset:e.offset,length:1})),...(o??[]).map(e=>({kind:`entity`,offset:e.offset,length:e.length,raw:e.raw}))];s.sort((e,t)=>e.offset-t.offset);let c=[];for(let e of s){let t=c[c.length-1];e.kind===`entity`&&t?.kind===`entity`&&t.offset+t.length===e.offset&&XK(t.raw)!==null&&qK(e.raw)?c[c.length-1]={kind:`entity`,offset:t.offset,length:t.length+e.length,raw:t.raw+e.raw}:c.push(e)}let l=[],u=0;for(let t of c){if(t.offset>u){let r=n.slice(u,t.offset).replaceAll(`\xA0`,` `);r&&l.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length).replaceAll(`\xA0`,` `);if(i)if(t.kind===`escape`)l.push(e.text(i,[r.escapeMark.create()]));else if(r.sourceLiteral){let n=XK(t.raw);l.push(e.text(n??i,[r.sourceLiteral.create({sourceRaw:t.raw})]))}else l.push(e.text(i));u=t.offset+t.length}}if(u<n.length){let t=n.slice(u).replaceAll(`\xA0`,` `);t&&l.push(e.text(t))}return l.length===1?l[0]:l}),r.code&&(i.inlineCode=t=>e.text(t.value,[r.code.create({sourceFenceChar:t.data?.sourceFenceChar??"`",sourceFenceLength:typeof t.data?.sourceFenceLength==`number`?t.data.sourceFenceLength:1,sourcePadded:t.data?.sourcePadded===!0})]));let a=r.strike??r.delete;if(a&&(i.delete=NR(a,e=>({sourceDelimiter:e.data?.sourceDelimiter===`~`?`~`:`~~`}))),r.highlight&&(i.mark=NR(r.highlight)),r.comment&&(i.comment=NR(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=MR(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=NR(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=NR(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=MR(n.heading,e=>({level:e.depth,headingStyle:e.data?.sourceStyle??`atx`,sourceTrailingHashes:e.data?.sourceTrailingHashes??null,sourceUnderlineLength:e.data?.sourceUnderlineLength??null,sourceContiguousNext:e.data?.sourceContiguousNext??!1,sourceLeadingIndent:e.data?.sourceLeadingIndent??null,sourceInteriorSpacing:e.data?.sourceInteriorSpacing??null}))),n.codeBlock&&(i.code=t=>{let r=t.value?[e.text(t.value)]:[];return n.codeBlock.createAndFill({language:t.lang??null,meta:t.meta??null,fenceDelimiter:t.data?.sourceFenceChar??"`",fenceLength:t.data?.sourceFenceLength??3,sourceStyle:t.data?.sourceStyle??`fenced`,sourceClosingFenceLength:t.data?.sourceClosingFenceLength??null,sourceFenceIndent:t.data?.sourceFenceIndent??null,sourceInfoPadding:t.data?.sourceInfoPadding??null,sourceIndents:t.data?.sourceIndents??null},r)}),n.thematicBreak&&(i.thematicBreak=e=>n.thematicBreak.createAndFill({sourceRaw:e.data?.sourceRaw??`---`})),n.hardBreak&&(i.break=e=>n.hardBreak.createAndFill({hardBreakStyle:e.data?.sourceStyle??`spaces`,sourceRaw:e.data?.sourceRaw??null})),n.list&&(i.list=MR(n.list,e=>({ordered:!!e.ordered,start:e.start??1,spread:!!e.spread,bulletMarker:e.data?.bulletMarker??null,listMarkerDelimiter:e.data?.listMarkerDelimiter??null}))),n.listItem&&(i.listItem=MR(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread,sourceMarkerSpacing:e.data?.sourceMarkerSpacing??null,sourceOrdinal:e.data?.sourceOrdinal??null,sourceCheckboxChar:e.data?.sourceCheckboxChar??null,sourceContinuationIndent:e.data?.sourceContinuationIndent??null}))),r.link){let t=r.sourceLiteral;i.link=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[](${n.url??``})`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.url??``,title:n.title??null,linkStyle:n.data?.sourceStyle??`inline`,refLabel:null,sourceUrlForm:n.data?.sourceUrlForm??null,sourceTitleMarker:n.data?.sourceTitleMarker??null});return o.map(e=>e.mark(s.addToSet(e.marks)))},i.linkReference=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[${n.label??``}][${n.identifier??``}]`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:``,title:null,linkStyle:n.referenceType??`shortcut`,refLabel:n.label??n.identifier??null});return o.map(e=>e.mark(s.addToSet(e.marks)))}}n.htmlBlock&&(i.html=e=>n.htmlBlock.createAndFill({content:e.value??``}));let o=n.linkDefinition??n.linkRefDef;if(o){let e=!!o.spec.attrs?.url,t=!!o.spec.attrs?.href,n=!!o.spec.attrs?.identifier,r=!!o.spec.attrs?.sourceLayout,a=!!o.spec.attrs?.sourceTitleMarker;i.definition=i=>{let s={title:i.title??null};return n&&(s.identifier=i.identifier??``),s.label=i.label??i.identifier??``,e?s.url=i.url??``:t&&(s.href=i.url??``),r&&(s.sourceLayout=i.data?.sourceLayout??null),a&&(s.sourceTitleMarker=i.data?.sourceTitleMarker??null),o.createAndFill(s)}}if(n.jsxComponent){let r=e=>{if(e&&typeof e==`object`&&`sourceRaw`in e){let t=e.sourceRaw;if(typeof t==`string`)return t}};i.mdxJsxFlowElement=(e,i,a)=>{let o=e.name??``,s=y$.getOrWildcard(o),c=b$(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=JQ(e,t.current.sourcePath);n!==e&&(c.src=n,c.sourceUrl=e)}let l=a.all(e).flat();return n.jsxComponent.createAndFill({componentName:o,kind:`element`,attributes:e.attributes,sourceRaw:r(e.data)??``,sourceDirty:!1,props:c},l.length?l:void 0)};let a=(e,t)=>{let n=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return n&&typeof n.value==`string`?n.value:null};i.mdxJsxTextElement=t=>{if(t.name===`InlineMath`&&n.mathInline){let e=a(t,`formula`)??``,r=a(t,`id`);return n.mathInline.create({formula:e,id:r??null})}if(t.name===`Tag`&&n.tag){let e=a(t,`value`)??``;return n.tag.create({value:e})}if(n.jsxInline){let i=r(t.data)??``;return n.jsxInline.createAndFill({},i?[e.text(i)]:null)}return n.jsxComponent.createAndFill({sourceRaw:r(t.data)??``})},i.mdxFlowExpression=e=>{let t=r(e.data)??`{${e.value??``}}`;return n.jsxComponent.createAndFill({kind:`expression`,sourceRaw:t,sourceDirty:!1})},i.mdxTextExpression=t=>{let n=r(t.data)??`{${t.value??``}}`;return e.text(n)}}return n.wikiLink&&(i.wikiLink=e=>n.wikiLink.createAndFill({target:e.data?.target??``,alias:e.data?.alias??null,anchor:e.data?.anchor??null,sourceTarget:e.data?.sourceTarget??null,sourceAnchor:e.data?.sourceAnchor??null,sourceAlias:e.data?.sourceAlias??null})),n.tag&&(i.tag=e=>n.tag.createAndFill({value:e.value})),n.wikiLinkEmbed&&(i.wikiLinkEmbed=(i,a)=>{let o=i.data?.target??``,s=i.data?.alias??null,c=i.data?.anchor??null,l=dq(o),{resolveEmbed:u,sourcePath:d}=t.current,f=u&&d?u(o,d)??null:null,p=f?`/${f}`:o,m=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(m&&D$.has(l)&&n.jsxComponent&&y$.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,alt:s??o,target:o,anchor:c,alias:s}});if(m&&Hc.has(l)&&n.jsxComponent&&y$.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&Wc.has(l)&&n.jsxComponent&&y$.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&Gc.has(l)&&n.jsxComponent&&y$.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&d?e(o,d)??null:null,i=r===null?null:_$(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,target:o,anchor:c,alias:s,size:i}})}let h=s||(c?`${o}#${c}`:o);if(r.link){let t=r.link.create({href:p,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s});return e.text(h,[t])}throw Error("[wikiLinkEmbed handler] schema lacks `link` mark — cannot dispatch without violating the STOP rule against emitting PM wikiLinkEmbed server-side")}),n.mathInline&&(i.inlineMath=e=>n.mathInline.create({formula:e.value??``,sourceDelimiter:e.data?.sourceDelimiter??null})),i.math||=t=>{let r=t.value==null?`«unknown:${t.type}»`:t.value;return n.rawMdxFallback?(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled block mdast: ${t.type}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled block mdast: ${t.type}`},r?[e.text(r)]:null)):null},i.inlineMath||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled inline mdast: ${t.type}`})),t.value==null?e.text(`«unknown:${t.type}»`):e.text(t.value)),n.footnoteReference?i.footnoteReference=e=>n.footnoteReference.create({identifier:e.identifier,label:e.label??e.identifier}):i.footnoteReference||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteReference`,reason:`FootnoteReference extension missing — recovering [^id] source`})),e.text(`[^${t.label??t.identifier}]`)),n.footnoteDefinition?i.footnoteDefinition=MR(n.footnoteDefinition,e=>{let t=e;return{identifier:t.identifier,label:t.label??t.identifier}}):i.footnoteDefinition||=t=>{console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteDefinition`,reason:`FootnoteDefinition extension missing — recovering [^id]: marker`}));let r=`[^${t.label??t.identifier}]: `;return n.paragraph?n.paragraph.create(null,e.text(r)):null},i.rawMdxFallbackMdast=t=>{if(!n.rawMdxFallback)return null;let r=t.position?{start:t.position.start?.offset??0,end:t.position.end?.offset??0}:{start:0,end:0};return console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.originalType,reason:`Unhandled mdast: ${t.originalType}`,unresolvedPosition:t.unresolvedPosition??!1})),n.rawMdxFallback.createAndFill({reason:`Unhandled mdast: ${t.originalType}`,originalSpan:r},t.value?[e.text(t.value)]:null)},i}function k$(e,t){let n={},r={},i=e.nodes,a=e.marks;i.paragraph&&(n.paragraph=RR(`paragraph`)),i.blockquote&&(n.blockquote=RR(`blockquote`,e=>{let t=e.attrs.sourceMarkerSpacings,n={};return Array.isArray(t)&&t.length>0&&(n.sourceMarkerSpacings=t),Object.keys(n).length>0?{data:n}:{}})),i.heading&&(n.heading=RR(`heading`,e=>({depth:e.attrs.level,data:{sourceStyle:e.attrs.headingStyle,sourceTrailingHashes:e.attrs.sourceTrailingHashes??void 0,sourceUnderlineLength:e.attrs.sourceUnderlineLength??void 0,sourceContiguousNext:e.attrs.sourceContiguousNext===!0?!0:void 0,sourceLeadingIndent:e.attrs.sourceLeadingIndent??void 0,sourceInteriorSpacing:e.attrs.sourceInteriorSpacing??void 0}}))),i.codeBlock&&(n.codeBlock=e=>{let t=e.attrs.sourceStyle===`indented`?`indented`:`fenced`;return{type:`code`,lang:t===`indented`?null:e.attrs.language??null,meta:t===`indented`?null:e.attrs.meta??null,value:e.textContent??``,data:{sourceFenceChar:e.attrs.fenceDelimiter,sourceFenceLength:e.attrs.fenceLength,sourceStyle:t,sourceClosingFenceLength:e.attrs.sourceClosingFenceLength??void 0,sourceFenceIndent:e.attrs.sourceFenceIndent??void 0,sourceInfoPadding:e.attrs.sourceInfoPadding??void 0,sourceIndents:e.attrs.sourceIndents??void 0}}}),i.thematicBreak&&(n.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),i.hardBreak&&(n.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle,...typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0?{sourceRaw:e.attrs.sourceRaw}:{}}})),i.list&&(n.list=RR(`list`,e=>({ordered:e.attrs.ordered??!1,start:e.attrs.ordered?e.attrs.start??1:null,spread:e.attrs.spread??!1,data:{bulletMarker:e.attrs.bulletMarker,listMarkerDelimiter:e.attrs.listMarkerDelimiter}}))),i.listItem&&(n.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&C$(r[0])?r.slice(1):r,a={};return typeof e.attrs.sourceMarkerSpacing==`number`&&(a.sourceMarkerSpacing=e.attrs.sourceMarkerSpacing),typeof e.attrs.sourceOrdinal==`number`&&(a.sourceOrdinal=e.attrs.sourceOrdinal),e.attrs.sourceCheckboxChar===`X`&&(a.sourceCheckboxChar=`X`),typeof e.attrs.sourceContinuationIndent==`number`&&(a.sourceContinuationIndent=e.attrs.sourceContinuationIndent),{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,...Object.keys(a).length>0?{data:a}:{},children:i}}),i.table&&(n.table=(e,t,n)=>{let r=n.all(e),i=[],a=e.firstChild;a&&a.forEach(e=>{let t=e.attrs.align;i.push(t===`left`||t===`right`||t===`center`?t:null)});let o=r.filter(e=>e.type===`tableRow`),s=e.attrs.sourceDashCounts,c={};Array.isArray(s)&&s.length>0&&(c.sourceDashCounts=s);let l=e.attrs.sourceOuterPipes;typeof l==`object`&&l&&typeof l.leading==`boolean`&&typeof l.trailing==`boolean`&&(c.sourceOuterPipes=l);let u=e.attrs.sourceAlignmentPadding;Array.isArray(u)&&u.length>0&&(c.sourceAlignmentPadding=u);let d=Object.keys(c).length>0?c:void 0,f={type:`table`,align:i,children:o};return d&&(f.data=d),f}),i.tableRow&&(n.tableRow=RR(`tableRow`));let o=(e,t)=>{let n={type:`tableCell`,children:dJ(t)},r=e.attrs.sourcePadding;return typeof r==`object`&&r&&typeof r.left==`number`&&typeof r.right==`number`&&(n.data={sourcePadding:r}),n};if(i.tableCell&&(n.tableCell=(e,t,n)=>o(e,n.all(e))),i.tableHeader&&(n.tableHeader=(e,t,n)=>o(e,n.all(e))),i.image&&(n.image=e=>({type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title})),i.imageReference&&(n.imageReference=e=>{let t=e.attrs.label??``,n=e.attrs.identifier??t;return{type:`imageReference`,alt:e.attrs.alt??``,identifier:n,label:t||n,referenceType:e.attrs.referenceType??`shortcut`}}),i.htmlBlock&&(n.htmlBlock=e=>({type:`html`,value:e.attrs.content})),i.linkDefinition??i.linkRefDef){let e=i.linkDefinition?`linkDefinition`:`linkRefDef`;n[e]=e=>{let t={},n=e.attrs.sourceLayout;(n===`multiline`||n===`inline`)&&(t.sourceLayout=n);let r=e.attrs.sourceTitleMarker;(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r);let i={type:`definition`,identifier:e.attrs.identifier??e.attrs.label??``,label:e.attrs.label??e.attrs.identifier??``,url:e.attrs.url??e.attrs.href??``,title:e.attrs.title};return Object.keys(t).length>0&&(i.data=t),i}}if(i.jsxComponent&&(n.jsxComponent=(e,n,r)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let i=e.attrs.componentName||null,a=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!S$(e,t.checker)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:i,attributes:a,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:y$.getOrWildcard(i??`*`).serialize(e,{all:e=>r.all(e),registry:y$,serializeChildren:()=>{throw Error(`SerializeContext.serializeChildren is not available in the PM→mdast handler. Compat descriptors that need markdown-byte body rendering must emit a marker mdast node and let the to-markdown handler render the body via state.containerFlow.`)}})}),i.rawMdxFallback&&(n.rawMdxFallback=e=>{let t=e.textContent??``,n=typeof e.attrs.reason==`string`?e.attrs.reason:``,r=e.attrs.originalSpan;return{type:`rawMdxFallback`,value:t,data:{reason:n,originalSpan:r&&typeof r==`object`&&`start`in r&&`end`in r?{start:Number(r.start)||0,end:Number(r.end)||0}:{start:0,end:0}}}}),i.jsxInline&&(n.jsxInline=e=>{let t=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:null,attributes:[],children:[],data:{sourceRaw:String(t)}}}),i.mathInline&&(n.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;if(typeof n==`string`&&n.length>0)return{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]};let r=e.attrs.sourceDelimiter;return{type:`inlineMath`,value:t,...typeof r==`string`&&r.length>0?{data:{sourceDelimiter:r}}:{}}}),i.wikiLink&&(n.wikiLink=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLink`,value:i,data:{target:t,anchor:n,alias:r,sourceTarget:typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,sourceAnchor:typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,sourceAlias:typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null},children:[{type:`text`,value:i}]}}),i.tag&&(n.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),i.wikiLinkEmbed&&(n.wikiLinkEmbed=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),a.emphasis&&(r.emphasis=zR(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.strong&&(r.strong=zR(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.code&&(r.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return T$(n,{sourceFenceChar:r,sourceFenceLength:i,sourcePadded:e.attrs.sourcePadded===!0?!0:void 0})}),a.strike??a.delete){let e=a.strike?`strike`:`delete`;r[e]=zR(`delete`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter===`~`?`~`:`~~`}}))}return a.highlight&&(r.highlight=zR(`mark`)),a.comment&&(r.comment=zR(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),i.commentBlock&&(n.commentBlock=RR(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),i.footnoteReference&&(n.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),i.footnoteDefinition&&(n.footnoteDefinition=RR(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),a.link&&(r.link=(e,t,n)=>{if(e.attrs.sourceForm===`wikiembed`){let t=typeof e.attrs.target==`string`&&e.attrs.target.length>0?e.attrs.target:e.attrs.href??``,r=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,i=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,a=i||(r?`${t}#${r}`:t),o=n.map(e=>`value`in e&&typeof e.value==`string`?e.value:``).join(``);return o!==a&&o.trim().length>0&&!o.includes(`]]`)&&(i=o,a=o),{type:`wikiLinkEmbed`,value:a,data:{target:t,anchor:r,alias:i},children:[{type:`text`,value:a}]}}let r=e.attrs.linkStyle;if(r===`autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`autolink`}};if(r===`gfm-autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`gfm-autolink`}};if(r===`inline`||!r){let t={};e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let r=e.attrs.sourceTitleMarker;return(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),{type:`link`,url:e.attrs.href??``,title:e.attrs.title??null,children:n,...Object.keys(t).length>0?{data:t}:{}}}return{type:`linkReference`,identifier:(e.attrs.refLabel??``).toLowerCase(),label:e.attrs.refLabel,referenceType:r,children:n}}),a.escapeMark&&(r.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data??={},t.data.escapedChars??=[];for(let e=0;e<t.value.length;e++)t.data.escapedChars.push({offset:e,char:t.value[e]})}return n.length===1?n[0]:n}),a.sourceLiteral&&(r.sourceLiteral=(e,t,n)=>{let r=typeof e.attrs.sourceRaw==`string`?e.attrs.sourceRaw:``;if(n.length===1&&n[0]?.type===`text`){let e=n[0],t=r||e.value;return QK(t,e.value)&&(e.data??={},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:n,markHandlers:r}}const A$=/\p{M}+/gu,j$=/[^\p{L}\p{N}]+/gu,M$=/^-+|-+$/g;function N$(e){return e.trim().normalize(`NFKD`).replace(A$,``).toLowerCase().replace(j$,`-`).replace(M$,``)}function P$(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function F$(e,t){let n=N$(e);return n?P$(n,t):``}const I$=new Set([`img`,`video`,`audio`,`mark`]);new Map(kY.flatMap(e=>e.surface===`compat`&&I$.has(e.rendersAs)?[[e.name,e]]:[])),GF(`<>`);const L$=OV(),R$=KB(),z$=qB();function B$(){return kY.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function V$(){return B$().filter(e=>H$(e)!==`fence`)}function H$(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function U$(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:H$(e)}}function W$(e){if(e.hidden!==!0&&e.type!==`reactnode`){if(`defaultValue`in e&&e.defaultValue!==void 0)return e.defaultValue;if(e.type===`enum`)return e.enumValues[0];if(e.type===`string`)return``;if(e.type===`number`)return 0;if(e.type===`boolean`)return!1}}function G$(e,t){return!(e.omitOnDefault===!0&&`defaultValue`in e&&Object.is(e.defaultValue,t)||e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&t===``)}function K$(e){let t=[];for(let n of e.props){let e=W$(n);e!==void 0&&G$(n,e)&&t.push(HJ(n.name,e))}return t}function q$(e){return eB(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[L$],mdastExtensions:[R$]}).children}function J$(e){let t=H$(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
|
|
428
|
-
A --> B`};else{let r=
|
|
429
|
-
`)}const Q$=[`text`,`number`,`boolean`,`date`,`list`,`object`];F(Q$);const $$=$s([A(),j(),M()]),e1=kc(()=>$s([$$.transform(e=>String(e)),ac(A(),t1),N(e1)])),t1=kc(()=>$s([A(),j(),M(),N(e1),ac(A(),t1)]));function n1(e){if(Array.isArray(e)){let t=[];for(let n of e)n!==null&&t.push(n1(n));return t}if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e))t[n]=r===null?``:n1(r);return t}return e}const r1=Pc(n1,ac(A(),t1));ac(A(),$s([t1,Hs()]));function i1(e){return!!(e===null||typeof e==`string`&&e===``||Array.isArray(e)&&e.length===0)}const a1=P({docName:bq,summary:Sq,content:A().optional(),...xq}).loose(),o1=P({docName:bq,summary:Sq,markdown:A(),position:F([`append`,`prepend`,`replace`]).optional(),extension:F(VG).optional(),...xq}).loose(),s1=P({docName:bq,summary:Sq,find:A().min(1),replace:A(),offset:j().int().nonnegative().optional(),...xq}).loose(),c1=P({docName:bq,connectionId:A().min(1),scope:F([`last`,`session`,`file`]).optional(),...xq}).loose(),l1=P({value:A(),truncatedFrom:j().int().nonnegative().optional(),hint:A().optional()}).loose(),u1=tc(`kind`,[P({kind:I(`inline`),content:A()}),P({kind:I(`truncated`),byteLength:j().int().nonnegative(),hint:A()})]),d1=P({kind:I(`content-divergence`),intendedBytes:j().int().nonnegative(),actualBytes:j().int().nonnegative(),byteDelta:j().int(),divergenceType:A().optional(),currentState:u1.optional(),hint:A().optional()}).loose(),f1=P({type:I(`orphan`),parentCandidates:N(A()),message:A()}).loose(),p1=P({kind:I(`disk-edit-reconciled`),intendedBytes:j().int().nonnegative(),actualBytes:j().int().nonnegative(),byteDelta:j().int(),mergeOutcome:A().optional(),hint:A().optional()}).loose(),m1=tc(`kind`,[d1,p1]),h1=tc(`kind`,[d1,p1,P({kind:I(`mermaid-parse-error`),fenceIndex:j().int().positive(),fenceFirstLine:A(),message:A(),line:j().int().positive().optional()}).loose()]),g1=N(h1).min(1),_1=P({href:A(),resolvedTo:A().nullable(),reason:F([`no-such-doc`,`no-such-file`,`unresolvable`])}).loose(),v1=N(_1),y1=P({timestamp:A().min(1),summary:l1.optional(),warning:m1.optional(),warnings:g1.optional()}).loose(),b1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),hints:N(f1).optional(),summary:l1.optional(),warning:m1.optional(),warnings:g1.optional(),brokenLinks:v1}).loose(),x1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),summary:l1.optional(),warning:m1.optional(),warnings:g1.optional(),brokenLinks:v1}).loose(),S1=P({docName:A().min(1),scope:F([`last`,`session`]),undone:M()}).loose(),C1=P({docName:bq,patch:ac(A(),$s([t1,Hs()])),types:ac(A(),F(Q$)).optional(),summary:Sq,...xq}).loose(),w1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),appliedKeys:N(A()),summary:l1.optional(),warning:m1.optional(),warnings:g1.optional(),brokenLinks:v1}).loose(),T1=P({entries:N(P({level:F([`info`,`warn`,`error`]),message:A().max(8192),event:A().optional(),fields:ac(A(),Ks()).optional(),ts:j().optional(),sourceId:A().optional(),lineNumber:j().optional()}).loose()).max(100)}).loose(),E1=P({accepted:j().int().min(0)}).loose(),D1=P({status:A().min(1),reason:A()}).loose(),O1=P({docName:A().min(1),content:A(),lifecycle:D1.nullable()}).loose(),k1=P({documents:N(P({kind:F([`document`,`asset`,`folder`,`file`]).default(`document`),docName:A().min(1).optional(),docExt:A().min(1).default(`.md`),size:j().int().nonnegative(),modified:A().min(1),isSymlink:M().default(!1),canonicalDocName:A().nullable().default(null),targetPath:A().nullable().default(null),path:A().min(1).optional(),assetExt:A().min(1).optional(),mediaKind:F([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`]).nullable().optional(),referencedBy:N(A().min(1)).optional(),hasChildren:M().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.kind===`file`?e.path!==void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder/file kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName; file → path, no mediaKind/referencedBy/hasChildren)`})),truncated:M().optional()}).loose(),A1=P({source:A().min(1),anchor:A().nullable(),title:A(),snippet:A().nullable()}).loose(),j1=P({docName:A().min(1),backlinks:N(A1)}).loose(),M1=P({counts:ac(A().min(1),j().int().nonnegative())}).loose(),N1=tc(`kind`,[P({kind:I(`doc`),docName:A().min(1),anchor:A().nullable(),title:A(),snippet:A().nullable()}).loose(),P({kind:I(`external`),url:A().min(1),title:A(),snippet:A().nullable()}).loose()]),P1=P({docName:A().min(1),forwardLinks:N(N1)}).loose(),F1=tc(`kind`,[P({id:A().min(1),kind:I(`doc`),docName:A().min(1),anchor:A().nullable(),label:A(),cluster:A().nullable(),category:A().nullable(),tags:N(A()).nullable()}).loose(),P({id:A().min(1),kind:I(`external`),url:A().min(1),label:A()}).loose()]),I1=P({source:A().min(1),target:A().min(1)}).loose(),L1=P({nodes:N(F1),links:N(I1)}).loose(),R1=P({ts:j().int().min(0),url:A(),method:A(),ua:A().optional(),origin:A().optional(),referer:A().optional(),host:A().optional(),remote:A().optional(),secChUa:A().optional(),secChUaMobile:A().optional(),secChUaPlatform:A().optional(),secFetchSite:A().optional(),secFetchDest:A().optional(),secFetchMode:A().optional(),secFetchUser:A().optional()}).loose(),z1=P({app:$s([I(`cursor`),I(`codex`),I(`claude`),Hs()]),signals_fired:N(A())}).loose(),B1=P({entries:N(R1),count:j().int().min(0),detection:z1}).loose(),V1=P({writers:N(P({id:A().min(1),name:A().optional(),email:A().optional()}).loose()).optional(),summary:Sq,...xq}).loose(),H1=P({checkpointRef:A().min(1)}).loose(),U1=P({v:j().int().optional(),id:A().min(1),name:A().min(1),colorSeed:A().optional(),docs:N(A()),summaries:N(A()).optional()}).loose(),W1=P({entries:N(P({sha:A().min(1),timestamp:A().min(1),author:A(),authorEmail:A(),type:F([`checkpoint`,`wip`,`upstream`,`park`]),message:A(),contributors:N(U1),checkpoint:Ks().nullable()}).loose()),total:j().int().nonnegative().optional(),truncated:M().optional(),hasMore:M().optional()}).loose(),G1=P({sha:A().regex(/^[0-9a-f]{40}$/i),content:A(),timestamp:A(),author:A()}).loose(),K1=P({contentDir:A().min(1),pathSeparator:F([`/`,`\\`]),symlinkResolved:M()}).loose(),q1=N(tc(`source`,[P({docName:A().min(1),timestamp:A().min(1),size:j().int().nonnegative(),source:I(`flat`)}).loose(),P({docName:A().min(1),timestamp:A().min(1),source:I(`timeline`),sha:A().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),J1=P({orphans:N(P({docName:A().min(1),title:A()}).loose())}).loose(),Y1=P({hubs:N(P({docName:A().min(1),title:A(),count:j().int().nonnegative()}).loose())}).loose(),X1=P({source:A().min(1),title:A(),snippet:A().nullable()}).loose(),Z1=P({deadLinks:N(P({target:A().min(1),sources:N(X1)}).loose())}).loose(),Q1=P({target:P({docName:A().min(1),title:A(),aliases:N(A())}).loose(),mentions:N(P({source:A().min(1),excerpt:A(),offset:j().int().nonnegative()}).loose()),truncated:M()}).loose(),$1=P({projectPath:A().min(1)}).loose(),e0=F([`not-a-git-worktree`,`init-failed`]),t0=tc(`ok`,[P({ok:I(!0),projectPath:A().min(1)}).loose(),P({ok:I(!1),reason:e0,message:A().min(1)}).loose()]),n0=P({host:A().min(1).optional()}).loose(),r0=P({key:A().min(1)}).loose(),i0=P({keyPresent:M()}).loose(),a0=P({name:A().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:A().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),o0=P({authenticated:M()}).loose(),s0=P({}).loose(),c0=P({stackIndex:j().int().min(0),ts:j().int().min(0),additions:j().int().min(0),deletions:j().int().min(0)}).loose(),l0=P({docName:A().min(1),additionsTotal:j().int().min(0),deletionsTotal:j().int().min(0),lastTs:j().int().min(0),bursts:N(c0)}).loose(),u0=P({displayName:A().min(1),color:A().min(1),icon:A().optional(),connectionId:A().min(1)}).loose(),d0=P({sessionAlive:M(),agent:u0.nullable(),files:N(l0)}).loose(),f0=P({diff:A(),generatedAt:j().int().min(0)}).loose(),p0=P({}).loose(),m0=P({}).loose(),h0=P({}).loose(),g0=P({}).loose(),_0=P({}).loose(),v0=P({}).loose(),y0=P({displayName:A().min(1),icon:A(),color:A().min(1),currentDoc:A().nullable(),mode:F([`idle`,`writing`]),ts:j().int().min(0)}).loose(),b0=P({presence:ac(A().min(1),y0)}).loose(),x0=ac(A().min(1),M()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});P({path:A().min(1,`path must be non-empty`)}).loose();const S0=P({}).loose(),C0=P({fromDocName:A().min(1),toDocName:A().min(1)}).loose(),w0=P({fromPath:A().min(1),toPath:A().min(1)}).loose(),T0=P({}).loose(),E0=P({path:A().min(1),...xq,summary:Sq}).loose(),D0=P({docName:A().min(1)}).loose(),O0=P({path:A().min(1),...xq,summary:Sq}).loose(),k0=P({path:A().min(1)}).loose(),A0=P({kind:F([`file`,`folder`]),path:A().min(1),...xq,summary:Sq}).loose(),j0=P({kind:F([`file`,`folder`]),path:A().min(1),duplicatedDocNames:N(A().min(1))}).loose(),M0=P({pages:N(P({docName:A().min(1),title:A(),docExt:A().min(1),size:j().int().nonnegative(),modified:A().min(1),icon:A().min(1).max(2048).optional()}).loose())}).loose(),N0=P({level:j().int().min(1).max(6),text:A(),slug:A()}).loose(),P0=P({docName:A().min(1),headings:N(N0)}).loose(),F0=P({docName:A().min(1),rewrites:j().int().nonnegative()}).loose(),I0=P({kind:F([`file`,`folder`,`asset`]),fromPath:A().min(1),toPath:A().min(1),...xq,summary:Sq}).loose(),L0=P({renamed:N(C0),renamedAssets:N(w0),rewrittenDocs:N(F0).optional(),summary:l1.optional()}).loose(),R0=P({kind:F([`file`,`folder`,`asset`]),path:A().min(1),...xq}).loose(),z0=P({deletedDocNames:N(A().min(1))}).loose(),B0=P({kind:F([`file`,`folder`,`asset`]),path:A().min(1),...xq,summary:Sq}).loose(),V0=P({deletedDocNames:N(A().min(1))}).loose(),H0=P({docName:A().min(1),commitSha:A().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:Sq,...xq}).loose(),U0=P({restoredFrom:A().min(1),timestamp:A().min(1),summary:l1.optional(),warning:d1.optional(),warnings:g1.optional()}).loose(),W0=F([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),G0=P({label:A().min(1),webUrl:xs().nullable()}).loose(),K0=tc(`checkStatus`,[P({checkStatus:I(`allowed`)}).loose(),P({checkStatus:I(`denied`),deniedReason:F([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),P({checkStatus:I(`unknown`),unknownError:F([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),q0=F([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),J0=P({state:W0,lastSyncUtc:A().nullable(),lastFetchUtc:A().nullable(),lastPushedSha:A().nullable(),ahead:j().int().min(0),behind:j().int().min(0),consecutiveFailures:j().int().min(0),conflictCount:j().int().min(0),hasRemote:M(),syncEnabled:M(),identityUnresolved:M(),remote:G0.nullable().optional(),pushError:A().optional(),pushErrorCode:q0.optional(),pullError:A().optional(),pullErrorCode:q0.optional(),pausedReason:A().optional(),pushPermission:K0.optional()}).loose(),Y0=P({op:F([`sync`,`push`,`pull`]).optional()}).loose(),X0=P({op:F([`sync`,`push`,`pull`])}).loose(),Z0=P({conflicts:N(P({file:A().min(1),detectedAt:A().min(1),oursSha:A().optional(),theirsSha:A().optional(),baseSha:A().optional()}).loose())}).loose(),Q0=P({file:A().min(1),strategy:F([`mine`,`theirs`,`content`,`delete`]),content:A().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),$0=P({}).loose(),e2=P({file:A().min(1),base:A(),ours:A(),theirs:A(),kind:F([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:A().nullable()}).loose(),t2=P({plan:jc(e=>e!==void 0,{message:`plan is required`})}).loose(),n2=P({plan:jc(e=>e!==void 0,{message:`plan is required`})}).loose(),r2=P({result:jc(e=>e!==void 0,{message:`result is required`})}).loose(),i2=P({path:A().min(1),summary:A().min(1)}).loose(),a2=P({files:j().int().nonnegative(),folders:j().int().nonnegative()}).loose(),o2=P({packs:N(P({id:A().min(1),name:A().min(1),description:A().min(1),defaultSubfolder:A().optional(),folders:N(i2),entryCounts:a2}).loose())}).loose(),s2=P({noOpen:M().optional(),out:A().min(1).optional()}).loose(),c2=P({reason:F([`unsupported-platform`,`spawn-error`]),message:A()}).loose(),l2=tc(`status`,[P({status:I(`installed`),outputPath:A(),size:j().int().nonnegative(),sha256:A(),skillVersion:A()}).loose(),P({status:I(`built`),outputPath:A(),size:j().int().nonnegative(),sha256:A(),skillVersion:A(),handoffError:c2.optional()}).loose(),P({status:I(`failed`),buildError:A()}).loose(),P({status:I(`skip-current`),skillVersion:A(),recordedAt:A().optional()}).loose()]),u2=[`.ok`,`skill-targets.json`],d2=F(qG),f2=Zs({schema:I(1),targets:N(d2).default([])});function p2(e){let t;try{t=JSON.parse(e)}catch{return null}let n=f2.safeParse(t);return n.success?n.data:null}const m2=P({tags:N(P({name:A().min(1),count:j().int().nonnegative(),isLeaf:M()}).loose())}).loose(),h2=P({docName:A().min(1),title:A(),matchingTags:N(A().min(1)),snippet:A().nullable()}).loose(),g2=P({name:A().min(1),docs:N(h2)}).loose(),_2=P({folder:Ks(),frontmatter_local:ac(A(),Ks()).nullable()}).loose(),v2=P({path:A(),frontmatter:ac(A(),Ks()).optional()}).loose(),y2=P({applied:Ks()}).loose(),b2=ac(A(),Ks()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),x2=P({template:P({name:A().min(1),folder:A(),scope:F([`local`,`inherited`]),path:A().min(1),frontmatter:b2,body:A()}).strict()}).strict(),S2=P({templates:N(P({name:A().min(1),title:A().optional(),description:A().optional(),path:A().min(1),source_folder:A()}).strict()),truncated:M()}).strict(),C2=P({folder:A(),name:A(),body:A().optional(),frontmatter:b2.optional(),...xq,summary:Sq}).strict(),w2=P({path:A().min(1),created:M(),warnings:N(A())}).strict(),T2=P({existed:M(),path:A().min(1)}).strict(),E2=P({fromFolder:A(),fromName:A(),toFolder:A(),toName:A(),body:A().optional(),frontmatter:b2.optional(),...xq,summary:Sq}).strict(),D2=P({from:A().min(1),to:A().min(1),committed:M()}).strict(),O2=F(EG),k2=/^[a-z0-9-]+$/,A2=/<\/?[A-Za-z][^>]*>/;function j2(e){return A2.test(e)}const M2=/^[A-Za-z0-9_-]+$/,N2=P({name:A(),description:A()}).strict(),P2=P({skill:P({name:A().min(1),scope:O2,path:A().min(1),frontmatter:N2,body:A(),files:N(P({path:A().min(1),text:A().nullable()})).optional()}).strict()}).strict(),F2=P({skills:N(P({name:A().min(1),description:A().optional(),scope:O2,path:A().min(1),absolutePath:A().min(1).optional(),installed:M(),hosts:N(A()),installedVersion:A().optional(),bundledVersion:A().optional(),updateAvailable:M().optional()}).strict()),truncated:M()}).strict(),I2=P({scope:O2.default(`project`),name:A(),body:A().optional(),frontmatter:N2,...xq,summary:Sq}).strict(),L2=P({path:A().min(1),created:M(),warnings:N(A())}).strict(),R2=P({scope:O2.default(`project`),name:A(),...xq,summary:Sq}).strict(),z2=P({name:A().min(1),version:A().min(1),previousVersion:A().optional(),checkpointRef:A().optional()}).strict(),B2=P({existed:M(),path:A().min(1)}).strict(),V2=P({scope:O2.default(`project`),fromName:A(),toName:A(),body:A().optional(),frontmatter:N2.optional(),...xq,summary:Sq}).strict(),H2=P({from:A().min(1),to:A().min(1),committed:M()}).strict(),U2=F([`reference`,`script`]),W2=P({scope:O2.default(`project`),name:A(),path:A().min(1),content:A(),...xq,summary:Sq}).strict(),G2=P({path:A().min(1),created:M(),kind:U2,content:M()}).strict(),K2=P({path:A().min(1),kind:U2,text:A()}).strict(),q2=P({path:A().min(1),existed:M(),kind:U2}).strict(),J2=P({scope:O2.default(`project`),name:A(),targets:N(d2).optional().meta({description:`Explicit editor ids to install into; omit to use project-configured editors.`}),...xq,summary:Sq}).strict(),Y2=P({name:A().min(1),hosts:N(A()),scripts:M(),warnings:N(A()),warningCodes:N(F([`no-targets`,`scripts-present`]))}).strict(),X2=P({scope:O2.default(`project`),name:A()}).strict(),Z2=P({name:A().min(1),uninstalled:M()}).strict(),Q2=P({targets:N(d2),configured:M()}).strict(),$2=P({targets:N(d2)}).strict(),e4=P({targets:N(d2),reprojected:N(P({name:A(),hosts:N(A())}).strict()),bundleHosts:N(A()),removedFrom:N(A())}).strict(),t4=P({scope:O2.default(`project`),name:A(),version:A().regex(/^[0-9a-f]{40}$/i),...xq,summary:Sq}).strict(),n4=P({name:A().min(1),version:A(),restoredFiles:N(A()),warnings:N(A())}).strict(),r4=P({query:A().optional(),intent:F([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:F([`navigation`,`relevance`]).optional(),scopes:N(F([`page`,`folder`,`content`,`file`])).optional(),scope:A().optional(),limit:j().int().nonnegative().optional(),semantic:M().optional(),source:F([`omnibar`,`mcp`,`http`]).optional()}).loose(),i4=P({kind:F([`page`,`folder`,`content`,`file`]),path:A().min(1),title:A(),score:j(),signals:ac(A(),Ks()),snippet:A().optional()}).loose(),a4=P({capable:M(),applied:M(),coverage:P({embedded:j().int().nonnegative(),total:j().int().nonnegative()})}).loose(),o4=P({enabled:M(),keyPresent:M(),keySource:F([`file`,`env`]).nullable(),keyHint:A().nullable(),ready:M(),capable:M(),embedded:j().int().nonnegative(),total:j().int().nonnegative()}).loose(),s4=P({query:A(),intent:F([`autocomplete`,`full_text`,`omnibar`]),results:N(i4),elapsedMs:j().nonnegative(),semantic:a4.optional(),truncated:M().optional(),ready:M().optional()}).loose(),c4=P({version:A().min(1),recordedAt:A().min(1)}).loose(),l4=P({currentVersion:A().min(1),targets:ac(A(),c4.nullable())}).loose(),u4=`server-info`,d4=`branch-switched`,f4=`disk-ack`,p4=`config-validation-rejected`,m4=`config-ignore-nested-error`,h4=F([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),g4=P({v:I(1),ch:I(u4),seq:j(),serverInstanceId:A().min(1),currentBranch:A().min(1).optional()}).loose(),_4=P({v:I(1),ch:I(d4),seq:j(),branch:A().min(1)}).loose(),v4=P({v:I(1),ch:h4,seq:j()}).loose(),y4=P({v:I(1),ch:I(f4),seq:j(),docName:A().min(1),sv:A().min(1)}).loose(),b4=P({v:I(1),ch:I(p4),seq:j(),docName:A().min(1),error:ql}).loose(),x4=P({v:I(1),ch:I(m4),seq:j(),path:A().min(1),error:A().min(1)}).loose(),S4=new pG.default;function C4(e,t){if(e===t)return[{value:e}];let{chars1:n,chars2:r,lineArray:i}=S4.diff_linesToChars_(e,t),a=S4.diff_main(n,r,!1);S4.diff_charsToLines_(a,i),S4.diff_cleanupSemantic(a);let o=[];for(let[e,t]of a)e===pG.default.DIFF_DELETE?o.push({value:t,removed:!0}):e===pG.default.DIFF_INSERT?o.push({value:t,added:!0}):o.push({value:t});return o}const w4=new pG.default;w4.Diff_Timeout=.25;const T4=256*1024;function E4(e,t,n){if(t===n)return;let r=C4(t,n),i=0;for(let n=0;n<r.length;n++){let a=r[n],o=r[n+1];if(a.removed&&o?.added){if(t.substring(i,i+o.value.length)===o.value){i+=o.value.length,n++;continue}e.delete(i,a.value.length),e.insert(i,o.value),i+=o.value.length,n++}else a.removed?e.delete(i,a.value.length):(a.added&&e.insert(i,a.value),i+=a.value.length)}}function D4(e,t,n){if(t===n)return;if(t.length>T4||n.length>T4){O4(e,t,n);return}let r=w4.diff_main(t,n);w4.diff_cleanupSemantic(r);let i=0;for(let[t,n]of r)t===0?i+=n.length:t===-1?e.delete(i,n.length):t===1&&(e.insert(i,n),i+=n.length)}function O4(e,t,n){let r=0,i=Math.min(t.length,n.length);for(;r<i&&t.charCodeAt(r)===n.charCodeAt(r);)r++;let a=0;for(;a<i-r&&t.charCodeAt(t.length-1-a)===n.charCodeAt(n.length-1-a);)a++;let o=t.length-r-a,s=n.slice(r,n.length-a);o>0&&e.delete(r,o),s.length>0&&e.insert(r,s)}const k4=P({path:N($s([A(),j()])),message:A(),issueCode:A()});tc(`code`,[P({code:I(`SCHEMA_INVALID`),issues:N(k4)}),P({code:I(`WRITE_ERROR`),detail:A()})]);const A4={defaultKeyType:`PLAIN`,defaultStringType:`PLAIN`,lineWidth:0};function j4(e){if(e.trim()===``)return{doc:new Fc.Document({}),map:{}};let t;try{t=(0,Fc.parseDocument)(e)}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new Fc.Document({}),map:null,parseError:`parse threw: ${t}`}}if(t.errors.length>0)return{doc:t,map:null,parseError:t.errors[0]?.message??`yaml parse errors`};let n;try{n=t.toJS()}catch(e){let n=e instanceof Error?e.message:String(e);return{doc:t,map:null,parseError:`toJS threw: ${n}`}}if(typeof n!=`object`||!n||Array.isArray(n))return{doc:t,map:null,parseError:`top-level value is not a mapping`};let r=r1.safeParse(n);if(!r.success){let e=r.error.issues[0],n=e&&Array.isArray(e.path)?e.path.join(`.`):``,i=e?.message??`unknown`;return{doc:t,map:null,parseError:n?`value at "${n}" failed schema: ${i}`:`schema validation failed: ${i}`}}return{doc:t,map:r.data}}function M4(e){return Object.keys(e).length===0?``:new Fc.Document(e).toString(A4)}function N4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function P4(e,t,n){if(Array.isArray(n)){let r=e.createNode(n),i=(0,Fc.isSeq)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}if(N4(n)){let r=e.createNode(n),i=(0,Fc.isMap)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}return n}function F4(e){return e===``?``:`---\n${e.endsWith(`
|
|
430
|
-
`)?e.slice(0,-1):e}\n---\n`}function
|
|
431
|
-
`)}function
|
|
432
|
-
`)){if(!
|
|
425
|
+
`)},mdxJsxFlowElement(e,t,n,r){let i=e,a=i.data?.sourceRaw;if(typeof a==`string`)return a;let o=i.data?.htmlBoundary;if(o&&typeof o.opener==`string`&&typeof o.closer==`string`){let e=n.containerFlow({type:`root`,children:i.children??[]},r);return`${o.opener}\n\n${e}\n\n${o.closer}`}let s=i.name??``,c=e$(i.attributes??[]);return!i.children||i.children.length===0?s?c?`<${s} ${c} />`:`<${s} />`:``:ZQ({...i,attributes:(i.attributes??[]).map(n$)},t,n,r)},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=f$(n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),r,`==`),o+=i.move(`==`),a(),o},comment(e,t,n,r){let i=e.data?.sourceForm,a=i===`html`?`<!-- `:`%%`,o=i===`html`?` -->`:`%%`,s=n.createTracker(r),c=n.enter(`comment`),l=s.move(a);return l+=n.containerPhrasing(e,{before:l,after:o,...s.current()}),l+=s.move(o),c(),l},commentBlock(e,t,n,r){let i=n.createTracker(r),a=n.enter(`commentBlock`),o=e.children??[],s=e.data?.sourceForm,c=e.data?.sourceLayout,l=o.length===1&&o[0]?.type===`paragraph`;if(s===`html`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`<!-- `,after:` -->`,...i.current()});return a(),`<!-- ${t} -->`}if(c===`inline`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`%% `,after:` %%`,...i.current()});return a(),`%% ${t} %%`}let u=n.containerFlow(e,i.current());return a(),`%%\n\n${u}\n\n%%`},mdxJsxTextElement(e){let t=e.data?.sourceRaw;if(typeof t==`string`)return t;let n=e.name??``,r=e$(e.attributes??[]);return r?`<${n} ${r} />`:`<${n}/>`},rawMdxFallback(e){return e.value??``},blockquote(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.containerFlow(e,a.current());i();let s=e.data?.sourceMarkerSpacings,c=0;return n.indentLines(o,(e,t,n)=>{if(n)return`>`;let r=c++,i=s?.[r];return i===`lazy`&&r>0&&!QQ.test(e)?e:i===`none`||i===0?`>${e}`:typeof i==`number`&&i>=2&&!e.startsWith(` `)?`>${` `.repeat(i)}${e}`:`> ${e}`})}};function e$(e){let t=[];for(let n of e){if(n.type===`mdxJsxExpressionAttribute`){t.push(`{${n.value}}`);continue}let e=n.name;if(n.value===null||n.value===void 0){t.push(e);continue}if(typeof n.value==`string`){n.value.includes(`"`)?t.push(`${e}={${t$(n.value)}}`):t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function t$(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function n$(e){return e.type===`mdxJsxAttribute`&&typeof e.value==`string`&&e.value.includes(`"`)?{type:`mdxJsxAttribute`,name:e.name,value:{type:`mdxJsxAttributeValueExpression`,value:t$(e.value)}}:e}function r$(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function i$(e){if(!e)return``;let t=0,n=!0;for(let r of e)r===`(`?t++:r===`)`&&(t--,t<0&&(n=!1));return t!==0&&(n=!1),n?e:e.replace(/[\\()]/g,`\\$&`)}function a$(e){return e.replace(/(?<!\\)&(?=(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z][A-Za-z0-9]*);)/g,(e,t)=>o$(t)?e:`\\${e}`)}function o$(e){if(e.charCodeAt(0)!==35)return!1;let t=e[1]===`x`||e[1]===`X`?Number.parseInt(e.slice(2),16):Number.parseInt(e.slice(1),10);return t===9||t===10||t===11||t===12||t===13||t===32}function s$(e,t,n){let r=e.unsafe;e.unsafe=r.filter(e=>!(e.character===`&`&&e.after===`[#A-Za-z]`||e.character===`<`||e.character===`[`||e.character===`(`||e.character===`!`&&e.after===`\\[`&&e.inConstruct===`phrasing`||e.character===`@`&&e.before===`[+\\-.\\w]`||e.character===`{`&&Array.isArray(e.inConstruct)&&e.inConstruct.includes(`phrasing`)||e.character==="`"||(e.character===`*`||e.character===`_`||e.character===`~`)&&e.inConstruct===`phrasing`||e.character===`=`&&e.atBreak===!0||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`)),e.unsafe=e.unsafe.map(e=>{if(e.character!==`)`||e.atBreak!==!0||e.before!==`\\d+`||e.after!==void 0)return e;let t={...e,after:`(?:[ \r
|
|
426
|
+
]|$)`};return delete t._compiled,t});let i;try{i=e.safe(t,n)}finally{e.unsafe=r}return a$(d$(i,n))}function c$(e){if(Number.isNaN(e))return`ws`;let t=UN(e);return t===1?`ws`:t===2?`punct`:`other`}function l$(e,t,n){let r=c$(t),i=c$(n),a=i!==`ws`&&(i===`other`||r!==`other`),o=r!==`ws`&&(r===`other`||i!==`other`);return e===`_`?a&&(!o||r===`punct`)||o&&(!a||i===`punct`):a||o}function u$(e,t,n){let r=t;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;if(r<e.length)return e[r]===`
|
|
427
|
+
`||e[r]===`\r`;let i=n.after.charCodeAt(0);return Number.isNaN(i)||i===10||i===13}function d$(e,t){let n=``,r=0;for(;r<e.length;){let i=e.charAt(r);if(i===`\\`){n+=e.slice(r,r+2),r+=2;continue}if(i===`*`||i===`_`||i===`~`||i===`=`){let a=r+1;for(;a<e.length&&e.charAt(a)===i;)a++;let o=r===0?t.before.charCodeAt(t.before.length-1):e.charCodeAt(r-1);if(i===`=`)n+=(Number.isNaN(o)||o===10||o===13)&&u$(e,a,t)?`\\${e.slice(r,a)}`:e.slice(r,a);else{let s=a<e.length?e.charCodeAt(a):t.after.charCodeAt(0);n+=l$(i,o,s)?`\\${i}`.repeat(a-r):e.slice(r,a)}r=a;continue}n+=i,r+=1}return n}function f$(e,t,n){let r=n.startsWith(`_`)?`_`:`*`,i=t.before??``,a=t.after??``,o=e,s=o.charCodeAt(0);p$(i.charCodeAt(i.length-1),s,r)&&(o=m$(s)+o.slice(1));let c=o.charCodeAt(o.length-1);return p$(a.charCodeAt(0),c,r)&&(o=o.slice(0,-1)+m$(c)),o}function p$(e,t,n){return!(UN(t)!==1||n===`_`&&UN(e)===void 0)}function m$(e){return`&#x${e.toString(16).toUpperCase()};`}function h$(e,t,n,r){let i=e.value??``,a=e.data?.sourceDelimiter,o=typeof a==`string`&&/^\$+$/.test(a)?a.length:2;for(o===1&&!_$(i,r)&&(o=2);RegExp(`(^|[^$])${`\\$`.repeat(o)}([^$]|$)`).test(i);)o++;let s=`$`.repeat(o);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` ${i} `);let c=-1;for(;++c<n.unsafe.length;){let e=n.unsafe[c];if(!e.atBreak)continue;let t=n.compilePattern(e),r;for(;(r=t.exec(i))!==null;){let e=r.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=`${i.slice(0,e)} ${i.slice(r.index+1)}`}}return s+i+s}function g$(e,t,n,r){let i=e.data?.sourceDelimiter===`~`?`~`:`~~`,a=n.createTracker(r),o=n.enter(`strikethrough`),s=a.move(i);return s+=f$(n.containerPhrasing(e,{...a.current(),before:s,after:`~`}),r,i),s+=a.move(i),o(),s}function _$(e,t){return!(e.length===0||!/^\S/.test(e)||!/\S$/.test(e)||/[$\r\n]/.test(e)||e.endsWith(`\\`)||/\\[!-/:-@[-`{-~]/.test(e)||/^\d/.test(t.after)||t.before.endsWith(`\\`))}function v$(e){if(!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KiB`,`MiB`,`GiB`,`TiB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(1).replace(/\.0$/,``)} ${t[r]}`}var y$=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};freshnessHolder={checker:void 0};constructor(e){this.schema=_b(e.extensions),this.handlers=k$(this.schema,this.parseCtx),this.freshnessHolder.checker=e.deriveStructuralFreshness?zJ({parse:e=>this.parseWithFallback(e)}):void 0;let{nodeHandlers:t,markHandlers:n}=A$(this.schema,this.freshnessHolder);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=FQ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=IQ({toMarkdownHandlers:$Q})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return HQ(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?UQ(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?UY(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e,t){let n;try{n=this.schema.nodeFromJSON(e)}catch(t){let n=`MarkdownManager.serialize() failed: schema rejected JSONContent (type=${e.type}, childCount=${e.content?.length??0})`;throw Error(n,{cause:t})}let r=this.freshnessHolder.checker;t?.skipFreshnessDerive&&(this.freshnessHolder.checker=void 0);try{return WQ(n,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}finally{this.freshnessHolder.checker=r}}};const b$=jY();function x$(e,t){let n=new Map;for(let e of t)n.set(e.name,e);let r={};for(let t of e){if(t.type===`mdxJsxExpressionAttribute`)continue;let e=t.name,i=n.get(e);if(t.value===null||t.value===void 0){r[e]=!0;continue}if(typeof t.value==`string`){if(i?.type===`number`){let n=Number(t.value);r[e]=Number.isNaN(n)?t.value:n}else i?.type===`boolean`?r[e]=t.value===`true`:r[e]=t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function S$(e){let t=!1;return e.descendants(e=>t||e.type.name===`jsxInline`?!1:e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function C$(e,t){return e.attrs.sourceDirty||S$(e)?!0:t?t.isDiverged(e.toJSON()):!1}function w$(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0?!0:t.every(e=>e.type===`text`&&e.value===``)}function T$(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),t.sourcePadded===!0&&(n.sourcePadded=!0),Object.keys(n).length===0?e:{...e,data:n}}function E$(e,t){if(e.length===0)return T$({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return T$({type:`inlineCode`,value:e.map(e=>e.value).join(``)},t);if(e.length===1&&`children`in e[0]){let n=e[0];return{...n,children:[E$(n.children,t)]}}return T$({type:`inlineCode`,value:D$(e)},t)}function D$(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=D$(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const O$=Vc;function k$(e,t){let n=e.nodes,r=e.marks,i={};n.paragraph&&(i.paragraph=(e,t,r)=>{let i=r.all(e).flat(),a=i.some(e=>e?.isBlock&&!e?.isInline),o=i.some(e=>e?.isInline||e?.isText||e?.isTextblock);if(a&&!o)return i.length===1?i[0]:i;if(a&&o){let e=i.filter(e=>!e?.isBlock||e?.isInline),t=i.filter(e=>e?.isBlock&&!e?.isInline),r=[],a=n.paragraph.createAndFill(null,e.length>0?e:null);return a&&r.push(a),r.push(...t),r.length===1?r[0]:r}return n.paragraph.createAndFill(null,i.length>0?i:null)}),n.blockquote&&(i.blockquote=MR(n.blockquote,e=>({sourceMarkerSpacings:e.data?.sourceMarkerSpacings??null}))),n.tableCell&&(i.tableCell=(e=>(t,r,i)=>{let a=i.all(t).flat();if(a.length>0&&n.paragraph){let t=n.paragraph.create(null,a);return e.createAndFill(null,[t])}return e.createAndFill(null,null)})(n.tableCell)),n.tableRow&&(i.tableRow=MR(n.tableRow)),n.table&&n.tableRow&&n.tableCell&&(i.table=(e,t,r)=>{let i=e.align??[],a=e.children??[],o=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type!==`tableRow`)continue;let s=t.children??[],c=[];for(let t=0;t<s.length;t++){let a=s[t];if(a.type!==`tableCell`)continue;let o=r.all(a).flat(),l=o.length>0&&n.paragraph?[n.paragraph.create(null,o)]:null,u=i[t]??null,d=e===0&&n.tableHeader?n.tableHeader:n.tableCell,f=a.data?.sourcePadding??null,p=d.createAndFill({align:u,sourcePadding:f},l);p&&c.push(p)}let l=n.tableRow.createAndFill(null,c.length>0?c:null);l&&o.push(l)}let s=e.data?.sourceDashCounts??null,c=e.data?.sourceOuterPipes??null,l=e.data?.sourceAlignmentPadding??null;return n.table.createAndFill({sourceDashCounts:s,sourceOuterPipes:c,sourceAlignmentPadding:l},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=JQ(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r})},n.imageReference?i.imageReference=e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):i.imageReference=e=>n.image.createAndFill({src:``,alt:e.alt??null,title:null})),r.escapeMark&&(i.text=t=>{let n=t.value??``,i=typeof t.data?.sourceRaw==`string`?t.data.sourceRaw:null;if(!n&&!i)return null;if(i){let t=n.replaceAll(`\xA0`,` `);return r.sourceLiteral?e.text(t,[r.sourceLiteral.create({sourceRaw:i})]):e.text(t)}let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n.replaceAll(`\xA0`,` `));let s=[...(a??[]).map(e=>({kind:`escape`,offset:e.offset,length:1})),...(o??[]).map(e=>({kind:`entity`,offset:e.offset,length:e.length,raw:e.raw}))];s.sort((e,t)=>e.offset-t.offset);let c=[];for(let e of s){let t=c[c.length-1];e.kind===`entity`&&t?.kind===`entity`&&t.offset+t.length===e.offset&&XK(t.raw)!==null&&qK(e.raw)?c[c.length-1]={kind:`entity`,offset:t.offset,length:t.length+e.length,raw:t.raw+e.raw}:c.push(e)}let l=[],u=0;for(let t of c){if(t.offset>u){let r=n.slice(u,t.offset).replaceAll(`\xA0`,` `);r&&l.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length).replaceAll(`\xA0`,` `);if(i)if(t.kind===`escape`)l.push(e.text(i,[r.escapeMark.create()]));else if(r.sourceLiteral){let n=XK(t.raw);l.push(e.text(n??i,[r.sourceLiteral.create({sourceRaw:t.raw})]))}else l.push(e.text(i));u=t.offset+t.length}}if(u<n.length){let t=n.slice(u).replaceAll(`\xA0`,` `);t&&l.push(e.text(t))}return l.length===1?l[0]:l}),r.code&&(i.inlineCode=t=>e.text(t.value,[r.code.create({sourceFenceChar:t.data?.sourceFenceChar??"`",sourceFenceLength:typeof t.data?.sourceFenceLength==`number`?t.data.sourceFenceLength:1,sourcePadded:t.data?.sourcePadded===!0})]));let a=r.strike??r.delete;if(a&&(i.delete=NR(a,e=>({sourceDelimiter:e.data?.sourceDelimiter===`~`?`~`:`~~`}))),r.highlight&&(i.mark=NR(r.highlight)),r.comment&&(i.comment=NR(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=MR(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=NR(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=NR(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=MR(n.heading,e=>({level:e.depth,headingStyle:e.data?.sourceStyle??`atx`,sourceTrailingHashes:e.data?.sourceTrailingHashes??null,sourceUnderlineLength:e.data?.sourceUnderlineLength??null,sourceContiguousNext:e.data?.sourceContiguousNext??!1,sourceLeadingIndent:e.data?.sourceLeadingIndent??null,sourceInteriorSpacing:e.data?.sourceInteriorSpacing??null}))),n.codeBlock&&(i.code=t=>{let r=t.value?[e.text(t.value)]:[];return n.codeBlock.createAndFill({language:t.lang??null,meta:t.meta??null,fenceDelimiter:t.data?.sourceFenceChar??"`",fenceLength:t.data?.sourceFenceLength??3,sourceStyle:t.data?.sourceStyle??`fenced`,sourceClosingFenceLength:t.data?.sourceClosingFenceLength??null,sourceFenceIndent:t.data?.sourceFenceIndent??null,sourceInfoPadding:t.data?.sourceInfoPadding??null,sourceIndents:t.data?.sourceIndents??null},r)}),n.thematicBreak&&(i.thematicBreak=e=>n.thematicBreak.createAndFill({sourceRaw:e.data?.sourceRaw??`---`})),n.hardBreak&&(i.break=e=>n.hardBreak.createAndFill({hardBreakStyle:e.data?.sourceStyle??`spaces`,sourceRaw:e.data?.sourceRaw??null})),n.list&&(i.list=MR(n.list,e=>({ordered:!!e.ordered,start:e.start??1,spread:!!e.spread,bulletMarker:e.data?.bulletMarker??null,listMarkerDelimiter:e.data?.listMarkerDelimiter??null}))),n.listItem&&(i.listItem=MR(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread,sourceMarkerSpacing:e.data?.sourceMarkerSpacing??null,sourceOrdinal:e.data?.sourceOrdinal??null,sourceCheckboxChar:e.data?.sourceCheckboxChar??null,sourceContinuationIndent:e.data?.sourceContinuationIndent??null}))),r.link){let t=r.sourceLiteral;i.link=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[](${n.url??``})`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.url??``,title:n.title??null,linkStyle:n.data?.sourceStyle??`inline`,refLabel:null,sourceUrlForm:n.data?.sourceUrlForm??null,sourceTitleMarker:n.data?.sourceTitleMarker??null});return o.map(e=>e.mark(s.addToSet(e.marks)))},i.linkReference=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[${n.label??``}][${n.identifier??``}]`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:``,title:null,linkStyle:n.referenceType??`shortcut`,refLabel:n.label??n.identifier??null});return o.map(e=>e.mark(s.addToSet(e.marks)))}}n.htmlBlock&&(i.html=e=>n.htmlBlock.createAndFill({content:e.value??``}));let o=n.linkDefinition??n.linkRefDef;if(o){let e=!!o.spec.attrs?.url,t=!!o.spec.attrs?.href,n=!!o.spec.attrs?.identifier,r=!!o.spec.attrs?.sourceLayout,a=!!o.spec.attrs?.sourceTitleMarker;i.definition=i=>{let s={title:i.title??null};return n&&(s.identifier=i.identifier??``),s.label=i.label??i.identifier??``,e?s.url=i.url??``:t&&(s.href=i.url??``),r&&(s.sourceLayout=i.data?.sourceLayout??null),a&&(s.sourceTitleMarker=i.data?.sourceTitleMarker??null),o.createAndFill(s)}}if(n.jsxComponent){let r=e=>{if(e&&typeof e==`object`&&`sourceRaw`in e){let t=e.sourceRaw;if(typeof t==`string`)return t}};i.mdxJsxFlowElement=(e,i,a)=>{let o=e.name??``,s=b$.getOrWildcard(o),c=x$(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=JQ(e,t.current.sourcePath);n!==e&&(c.src=n,c.sourceUrl=e)}let l=a.all(e).flat();return n.jsxComponent.createAndFill({componentName:o,kind:`element`,attributes:e.attributes,sourceRaw:r(e.data)??``,sourceDirty:!1,props:c},l.length?l:void 0)};let a=(e,t)=>{let n=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return n&&typeof n.value==`string`?n.value:null};i.mdxJsxTextElement=t=>{if(t.name===`InlineMath`&&n.mathInline){let e=a(t,`formula`)??``,r=a(t,`id`);return n.mathInline.create({formula:e,id:r??null})}if(t.name===`Tag`&&n.tag){let e=a(t,`value`)??``;return n.tag.create({value:e})}if(n.jsxInline){let i=r(t.data)??``;return n.jsxInline.createAndFill({},i?[e.text(i)]:null)}return n.jsxComponent.createAndFill({sourceRaw:r(t.data)??``})},i.mdxFlowExpression=e=>{let t=r(e.data)??`{${e.value??``}}`;return n.jsxComponent.createAndFill({kind:`expression`,sourceRaw:t,sourceDirty:!1})},i.mdxTextExpression=t=>{let n=r(t.data)??`{${t.value??``}}`;return e.text(n)}}return n.wikiLink&&(i.wikiLink=e=>n.wikiLink.createAndFill({target:e.data?.target??``,alias:e.data?.alias??null,anchor:e.data?.anchor??null,sourceTarget:e.data?.sourceTarget??null,sourceAnchor:e.data?.sourceAnchor??null,sourceAlias:e.data?.sourceAlias??null})),n.tag&&(i.tag=e=>n.tag.createAndFill({value:e.value})),n.wikiLinkEmbed&&(i.wikiLinkEmbed=(i,a)=>{let o=i.data?.target??``,s=i.data?.alias??null,c=i.data?.anchor??null,l=dq(o),{resolveEmbed:u,sourcePath:d}=t.current,f=u&&d?u(o,d)??null:null,p=f?`/${f}`:o,m=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(m&&O$.has(l)&&n.jsxComponent&&b$.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,alt:s??o,target:o,anchor:c,alias:s}});if(m&&Hc.has(l)&&n.jsxComponent&&b$.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&Wc.has(l)&&n.jsxComponent&&b$.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&Gc.has(l)&&n.jsxComponent&&b$.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&d?e(o,d)??null:null,i=r===null?null:v$(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,target:o,anchor:c,alias:s,size:i}})}let h=s||(c?`${o}#${c}`:o);if(r.link){let t=r.link.create({href:p,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s});return e.text(h,[t])}throw Error("[wikiLinkEmbed handler] schema lacks `link` mark — cannot dispatch without violating the STOP rule against emitting PM wikiLinkEmbed server-side")}),n.mathInline&&(i.inlineMath=e=>n.mathInline.create({formula:e.value??``,sourceDelimiter:e.data?.sourceDelimiter??null})),i.math||=t=>{let r=t.value==null?`«unknown:${t.type}»`:t.value;return n.rawMdxFallback?(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled block mdast: ${t.type}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled block mdast: ${t.type}`},r?[e.text(r)]:null)):null},i.inlineMath||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled inline mdast: ${t.type}`})),t.value==null?e.text(`«unknown:${t.type}»`):e.text(t.value)),n.footnoteReference?i.footnoteReference=e=>n.footnoteReference.create({identifier:e.identifier,label:e.label??e.identifier}):i.footnoteReference||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteReference`,reason:`FootnoteReference extension missing — recovering [^id] source`})),e.text(`[^${t.label??t.identifier}]`)),n.footnoteDefinition?i.footnoteDefinition=MR(n.footnoteDefinition,e=>{let t=e;return{identifier:t.identifier,label:t.label??t.identifier}}):i.footnoteDefinition||=t=>{console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteDefinition`,reason:`FootnoteDefinition extension missing — recovering [^id]: marker`}));let r=`[^${t.label??t.identifier}]: `;return n.paragraph?n.paragraph.create(null,e.text(r)):null},i.rawMdxFallbackMdast=t=>{if(!n.rawMdxFallback)return null;let r=t.position?{start:t.position.start?.offset??0,end:t.position.end?.offset??0}:{start:0,end:0};return console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.originalType,reason:`Unhandled mdast: ${t.originalType}`,unresolvedPosition:t.unresolvedPosition??!1})),n.rawMdxFallback.createAndFill({reason:`Unhandled mdast: ${t.originalType}`,originalSpan:r},t.value?[e.text(t.value)]:null)},i}function A$(e,t){let n={},r={},i=e.nodes,a=e.marks;i.paragraph&&(n.paragraph=RR(`paragraph`)),i.blockquote&&(n.blockquote=RR(`blockquote`,e=>{let t=e.attrs.sourceMarkerSpacings,n={};return Array.isArray(t)&&t.length>0&&(n.sourceMarkerSpacings=t),Object.keys(n).length>0?{data:n}:{}})),i.heading&&(n.heading=RR(`heading`,e=>({depth:e.attrs.level,data:{sourceStyle:e.attrs.headingStyle,sourceTrailingHashes:e.attrs.sourceTrailingHashes??void 0,sourceUnderlineLength:e.attrs.sourceUnderlineLength??void 0,sourceContiguousNext:e.attrs.sourceContiguousNext===!0?!0:void 0,sourceLeadingIndent:e.attrs.sourceLeadingIndent??void 0,sourceInteriorSpacing:e.attrs.sourceInteriorSpacing??void 0}}))),i.codeBlock&&(n.codeBlock=e=>{let t=e.attrs.sourceStyle===`indented`?`indented`:`fenced`;return{type:`code`,lang:t===`indented`?null:e.attrs.language??null,meta:t===`indented`?null:e.attrs.meta??null,value:e.textContent??``,data:{sourceFenceChar:e.attrs.fenceDelimiter,sourceFenceLength:e.attrs.fenceLength,sourceStyle:t,sourceClosingFenceLength:e.attrs.sourceClosingFenceLength??void 0,sourceFenceIndent:e.attrs.sourceFenceIndent??void 0,sourceInfoPadding:e.attrs.sourceInfoPadding??void 0,sourceIndents:e.attrs.sourceIndents??void 0}}}),i.thematicBreak&&(n.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),i.hardBreak&&(n.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle,...typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0?{sourceRaw:e.attrs.sourceRaw}:{}}})),i.list&&(n.list=RR(`list`,e=>({ordered:e.attrs.ordered??!1,start:e.attrs.ordered?e.attrs.start??1:null,spread:e.attrs.spread??!1,data:{bulletMarker:e.attrs.bulletMarker,listMarkerDelimiter:e.attrs.listMarkerDelimiter}}))),i.listItem&&(n.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&w$(r[0])?r.slice(1):r,a={};return typeof e.attrs.sourceMarkerSpacing==`number`&&(a.sourceMarkerSpacing=e.attrs.sourceMarkerSpacing),typeof e.attrs.sourceOrdinal==`number`&&(a.sourceOrdinal=e.attrs.sourceOrdinal),e.attrs.sourceCheckboxChar===`X`&&(a.sourceCheckboxChar=`X`),typeof e.attrs.sourceContinuationIndent==`number`&&(a.sourceContinuationIndent=e.attrs.sourceContinuationIndent),{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,...Object.keys(a).length>0?{data:a}:{},children:i}}),i.table&&(n.table=(e,t,n)=>{let r=n.all(e),i=[],a=e.firstChild;a&&a.forEach(e=>{let t=e.attrs.align;i.push(t===`left`||t===`right`||t===`center`?t:null)});let o=r.filter(e=>e.type===`tableRow`),s=e.attrs.sourceDashCounts,c={};Array.isArray(s)&&s.length>0&&(c.sourceDashCounts=s);let l=e.attrs.sourceOuterPipes;typeof l==`object`&&l&&typeof l.leading==`boolean`&&typeof l.trailing==`boolean`&&(c.sourceOuterPipes=l);let u=e.attrs.sourceAlignmentPadding;Array.isArray(u)&&u.length>0&&(c.sourceAlignmentPadding=u);let d=Object.keys(c).length>0?c:void 0,f={type:`table`,align:i,children:o};return d&&(f.data=d),f}),i.tableRow&&(n.tableRow=RR(`tableRow`));let o=(e,t)=>{let n={type:`tableCell`,children:dJ(t)},r=e.attrs.sourcePadding;return typeof r==`object`&&r&&typeof r.left==`number`&&typeof r.right==`number`&&(n.data={sourcePadding:r}),n};if(i.tableCell&&(n.tableCell=(e,t,n)=>o(e,n.all(e))),i.tableHeader&&(n.tableHeader=(e,t,n)=>o(e,n.all(e))),i.image&&(n.image=e=>({type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title})),i.imageReference&&(n.imageReference=e=>{let t=e.attrs.label??``,n=e.attrs.identifier??t;return{type:`imageReference`,alt:e.attrs.alt??``,identifier:n,label:t||n,referenceType:e.attrs.referenceType??`shortcut`}}),i.htmlBlock&&(n.htmlBlock=e=>({type:`html`,value:e.attrs.content})),i.linkDefinition??i.linkRefDef){let e=i.linkDefinition?`linkDefinition`:`linkRefDef`;n[e]=e=>{let t={},n=e.attrs.sourceLayout;(n===`multiline`||n===`inline`)&&(t.sourceLayout=n);let r=e.attrs.sourceTitleMarker;(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r);let i={type:`definition`,identifier:e.attrs.identifier??e.attrs.label??``,label:e.attrs.label??e.attrs.identifier??``,url:e.attrs.url??e.attrs.href??``,title:e.attrs.title};return Object.keys(t).length>0&&(i.data=t),i}}if(i.jsxComponent&&(n.jsxComponent=(e,n,r)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let i=e.attrs.componentName||null,a=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!C$(e,t.checker)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:i,attributes:a,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:b$.getOrWildcard(i??`*`).serialize(e,{all:e=>r.all(e),registry:b$,serializeChildren:()=>{throw Error(`SerializeContext.serializeChildren is not available in the PM→mdast handler. Compat descriptors that need markdown-byte body rendering must emit a marker mdast node and let the to-markdown handler render the body via state.containerFlow.`)}})}),i.rawMdxFallback&&(n.rawMdxFallback=e=>{let t=e.textContent??``,n=typeof e.attrs.reason==`string`?e.attrs.reason:``,r=e.attrs.originalSpan;return{type:`rawMdxFallback`,value:t,data:{reason:n,originalSpan:r&&typeof r==`object`&&`start`in r&&`end`in r?{start:Number(r.start)||0,end:Number(r.end)||0}:{start:0,end:0}}}}),i.jsxInline&&(n.jsxInline=e=>{let t=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:null,attributes:[],children:[],data:{sourceRaw:String(t)}}}),i.mathInline&&(n.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;if(typeof n==`string`&&n.length>0)return{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]};let r=e.attrs.sourceDelimiter;return{type:`inlineMath`,value:t,...typeof r==`string`&&r.length>0?{data:{sourceDelimiter:r}}:{}}}),i.wikiLink&&(n.wikiLink=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLink`,value:i,data:{target:t,anchor:n,alias:r,sourceTarget:typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,sourceAnchor:typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,sourceAlias:typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null},children:[{type:`text`,value:i}]}}),i.tag&&(n.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),i.wikiLinkEmbed&&(n.wikiLinkEmbed=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),a.emphasis&&(r.emphasis=zR(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.strong&&(r.strong=zR(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.code&&(r.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return E$(n,{sourceFenceChar:r,sourceFenceLength:i,sourcePadded:e.attrs.sourcePadded===!0?!0:void 0})}),a.strike??a.delete){let e=a.strike?`strike`:`delete`;r[e]=zR(`delete`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter===`~`?`~`:`~~`}}))}return a.highlight&&(r.highlight=zR(`mark`)),a.comment&&(r.comment=zR(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),i.commentBlock&&(n.commentBlock=RR(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),i.footnoteReference&&(n.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),i.footnoteDefinition&&(n.footnoteDefinition=RR(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),a.link&&(r.link=(e,t,n)=>{if(e.attrs.sourceForm===`wikiembed`){let t=typeof e.attrs.target==`string`&&e.attrs.target.length>0?e.attrs.target:e.attrs.href??``,r=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,i=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,a=i||(r?`${t}#${r}`:t),o=n.map(e=>`value`in e&&typeof e.value==`string`?e.value:``).join(``);return o!==a&&o.trim().length>0&&!o.includes(`]]`)&&(i=o,a=o),{type:`wikiLinkEmbed`,value:a,data:{target:t,anchor:r,alias:i},children:[{type:`text`,value:a}]}}let r=e.attrs.linkStyle;if(r===`autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`autolink`}};if(r===`gfm-autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`gfm-autolink`}};if(r===`inline`||!r){let t={};e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let r=e.attrs.sourceTitleMarker;return(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),{type:`link`,url:e.attrs.href??``,title:e.attrs.title??null,children:n,...Object.keys(t).length>0?{data:t}:{}}}return{type:`linkReference`,identifier:(e.attrs.refLabel??``).toLowerCase(),label:e.attrs.refLabel,referenceType:r,children:n}}),a.escapeMark&&(r.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data??={},t.data.escapedChars??=[];for(let e=0;e<t.value.length;e++)t.data.escapedChars.push({offset:e,char:t.value[e]})}return n.length===1?n[0]:n}),a.sourceLiteral&&(r.sourceLiteral=(e,t,n)=>{let r=typeof e.attrs.sourceRaw==`string`?e.attrs.sourceRaw:``;if(n.length===1&&n[0]?.type===`text`){let e=n[0],t=r||e.value;return QK(t,e.value)&&(e.data??={},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:n,markHandlers:r}}const j$=/\p{M}+/gu,M$=/[^\p{L}\p{N}]+/gu,N$=/^-+|-+$/g;function P$(e){return e.trim().normalize(`NFKD`).replace(j$,``).toLowerCase().replace(M$,`-`).replace(N$,``)}function F$(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function I$(e,t){let n=P$(e);return n?F$(n,t):``}const L$=new Set([`img`,`video`,`audio`,`mark`]);new Map(kY.flatMap(e=>e.surface===`compat`&&L$.has(e.rendersAs)?[[e.name,e]]:[])),GF(`<>`);const R$=OV(),z$=KB(),B$=qB();function V$(){return kY.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function H$(){return V$().filter(e=>U$(e)!==`fence`)}function U$(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function W$(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:U$(e)}}function G$(e){if(e.hidden!==!0&&e.type!==`reactnode`){if(`defaultValue`in e&&e.defaultValue!==void 0)return e.defaultValue;if(e.type===`enum`)return e.enumValues[0];if(e.type===`string`)return``;if(e.type===`number`)return 0;if(e.type===`boolean`)return!1}}function K$(e,t){return!(e.omitOnDefault===!0&&`defaultValue`in e&&Object.is(e.defaultValue,t)||e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&t===``)}function q$(e){let t=[];for(let n of e.props){let e=G$(n);e!==void 0&&K$(n,e)&&t.push(HJ(n.name,e))}return t}function J$(e){return eB(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[R$],mdastExtensions:[z$]}).children}function Y$(e){let t=U$(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
|
|
428
|
+
A --> B`};else{let r=q$(e),i=t===`jsx-block`?J$(e):[];n={type:`mdxJsxFlowElement`,name:e.name,attributes:r,children:i}}return KP({type:`root`,children:[n]},{extensions:[B$]}).trimEnd()}function X$(e){let t=[];for(let n of e.props){if(n.hidden===!0)continue;let e={name:n.name,type:n.type,required:n.required};n.description!==void 0&&(e.description=n.description),n.advanced===!0&&(e.advanced=!0),n.omitOnDefault===!0&&(e.omitOnDefault=!0),n.type===`enum`&&(e.values=n.enumValues,n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue)),n.type===`string`&&(n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.language!==void 0&&(e.language=n.language),n.accept!==void 0&&(e.accept=n.accept)),n.type===`boolean`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.type===`number`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),t.push(e)}return t}function Z$(e){return{...W$(e),example:Y$(e),params:X$(e)}}function Q$(){return[``,"**Custom canonical components.** OK `.md` / `.mdx` supports the JSX components below — use whichever is semantically useful in any part of the doc. For full source syntax + parameter schemas, call `palette({ components: [ids] })` with the ids you want to use. Fenced code blocks render naturally and don't need a fetch — including ` ```mermaid ` for diagrams (mermaid label text has sharp edges — `palette({ components: [\"Mermaid\"] })` lists them; parse failures come back as `warnings` entries on write/edit) and ` ```html preview ` for interactive HTML/JS/CSS pages (the fence info-string `preview` token renders the block as a live iframe; works for `html` / `htm` / `xml`; optional `h=` / `w=` tokens set size, e.g. ` ```html preview h=400px `). Use ` ```html preview ` whenever you want anything interactive or JS-powered (charts, demos, calculators, animations) — just author the standalone HTML page in the fence. Call `palette` for the markdown-native component forms (write `> [!NOTE]`, not `<Callout>`), copy-ready themed `html preview` starters, and the theme tokens (`var(--chart-1)`, `var(--foreground)`, …) an embed should reference so it tracks the reader's light/dark theme. Arbitrary `<TagName>` JSX falls through as raw MDX when no canonical fits.",``,...H$().map(W$).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
|
|
429
|
+
`)}const $$=[`text`,`number`,`boolean`,`date`,`list`,`object`];F($$);const e1=$s([A(),j(),M()]),t1=kc(()=>$s([e1.transform(e=>String(e)),ac(A(),n1),N(t1)])),n1=kc(()=>$s([A(),j(),M(),N(t1),ac(A(),n1)]));function r1(e){if(Array.isArray(e)){let t=[];for(let n of e)n!==null&&t.push(r1(n));return t}if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e))t[n]=r===null?``:r1(r);return t}return e}const i1=Pc(r1,ac(A(),n1));ac(A(),$s([n1,Hs()]));function a1(e){return!!(e===null||typeof e==`string`&&e===``||Array.isArray(e)&&e.length===0)}const o1=P({docName:bq,summary:Sq,content:A().optional(),...xq}).loose(),s1=P({docName:bq,summary:Sq,markdown:A(),position:F([`append`,`prepend`,`replace`]).optional(),extension:F(VG).optional(),...xq}).loose(),c1=P({docName:bq,summary:Sq,find:A().min(1),replace:A(),offset:j().int().nonnegative().optional(),...xq}).loose(),l1=P({docName:bq,connectionId:A().min(1),scope:F([`last`,`session`,`file`]).optional(),...xq}).loose(),u1=P({value:A(),truncatedFrom:j().int().nonnegative().optional(),hint:A().optional()}).loose(),d1=tc(`kind`,[P({kind:I(`inline`),content:A()}),P({kind:I(`truncated`),byteLength:j().int().nonnegative(),hint:A()})]),f1=P({kind:I(`content-divergence`),intendedBytes:j().int().nonnegative(),actualBytes:j().int().nonnegative(),byteDelta:j().int(),divergenceType:A().optional(),currentState:d1.optional(),hint:A().optional()}).loose(),p1=P({type:I(`orphan`),parentCandidates:N(A()),message:A()}).loose(),m1=P({kind:I(`disk-edit-reconciled`),intendedBytes:j().int().nonnegative(),actualBytes:j().int().nonnegative(),byteDelta:j().int(),mergeOutcome:A().optional(),hint:A().optional()}).loose(),h1=tc(`kind`,[f1,m1]),g1=tc(`kind`,[f1,m1,P({kind:I(`mermaid-parse-error`),fenceIndex:j().int().positive(),fenceFirstLine:A(),message:A(),line:j().int().positive().optional()}).loose()]),_1=N(g1).min(1),v1=P({href:A(),resolvedTo:A().nullable(),reason:F([`no-such-doc`,`no-such-file`,`unresolvable`])}).loose(),y1=N(v1),b1=P({timestamp:A().min(1),summary:u1.optional(),warning:h1.optional(),warnings:_1.optional()}).loose(),x1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),hints:N(p1).optional(),summary:u1.optional(),warning:h1.optional(),warnings:_1.optional(),brokenLinks:y1}).loose(),S1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),summary:u1.optional(),warning:h1.optional(),warnings:_1.optional(),brokenLinks:y1}).loose(),C1=P({docName:A().min(1),scope:F([`last`,`session`]),undone:M()}).loose(),w1=P({docName:bq,patch:ac(A(),$s([n1,Hs()])),types:ac(A(),F($$)).optional(),summary:Sq,...xq}).loose(),T1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),appliedKeys:N(A()),summary:u1.optional(),warning:h1.optional(),warnings:_1.optional(),brokenLinks:y1}).loose(),E1=P({entries:N(P({level:F([`info`,`warn`,`error`]),message:A().max(8192),event:A().optional(),fields:ac(A(),Ks()).optional(),ts:j().optional(),sourceId:A().optional(),lineNumber:j().optional()}).loose()).max(100)}).loose(),D1=P({accepted:j().int().min(0)}).loose(),O1=P({status:A().min(1),reason:A()}).loose(),k1=P({docName:A().min(1),content:A(),lifecycle:O1.nullable()}).loose(),A1=P({documents:N(P({kind:F([`document`,`asset`,`folder`,`file`]).default(`document`),docName:A().min(1).optional(),docExt:A().min(1).default(`.md`),size:j().int().nonnegative(),modified:A().min(1),isSymlink:M().default(!1),canonicalDocName:A().nullable().default(null),targetPath:A().nullable().default(null),path:A().min(1).optional(),assetExt:A().min(1).optional(),mediaKind:F([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`]).nullable().optional(),referencedBy:N(A().min(1)).optional(),hasChildren:M().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.kind===`file`?e.path!==void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder/file kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName; file → path, no mediaKind/referencedBy/hasChildren)`})),truncated:M().optional()}).loose(),j1=P({source:A().min(1),anchor:A().nullable(),title:A(),snippet:A().nullable()}).loose(),M1=P({docName:A().min(1),backlinks:N(j1)}).loose(),N1=P({counts:ac(A().min(1),j().int().nonnegative())}).loose(),P1=tc(`kind`,[P({kind:I(`doc`),docName:A().min(1),anchor:A().nullable(),title:A(),snippet:A().nullable()}).loose(),P({kind:I(`external`),url:A().min(1),title:A(),snippet:A().nullable()}).loose()]),F1=P({docName:A().min(1),forwardLinks:N(P1)}).loose(),I1=tc(`kind`,[P({id:A().min(1),kind:I(`doc`),docName:A().min(1),anchor:A().nullable(),label:A(),cluster:A().nullable(),category:A().nullable(),tags:N(A()).nullable()}).loose(),P({id:A().min(1),kind:I(`external`),url:A().min(1),label:A()}).loose()]),L1=P({source:A().min(1),target:A().min(1)}).loose(),R1=P({nodes:N(I1),links:N(L1)}).loose(),z1=P({ts:j().int().min(0),url:A(),method:A(),ua:A().optional(),origin:A().optional(),referer:A().optional(),host:A().optional(),remote:A().optional(),secChUa:A().optional(),secChUaMobile:A().optional(),secChUaPlatform:A().optional(),secFetchSite:A().optional(),secFetchDest:A().optional(),secFetchMode:A().optional(),secFetchUser:A().optional()}).loose(),B1=P({app:$s([I(`cursor`),I(`codex`),I(`claude`),Hs()]),signals_fired:N(A())}).loose(),V1=P({entries:N(z1),count:j().int().min(0),detection:B1}).loose(),H1=P({writers:N(P({id:A().min(1),name:A().optional(),email:A().optional()}).loose()).optional(),summary:Sq,...xq}).loose(),U1=P({checkpointRef:A().min(1)}).loose(),W1=P({v:j().int().optional(),id:A().min(1),name:A().min(1),colorSeed:A().optional(),docs:N(A()),summaries:N(A()).optional()}).loose(),G1=P({entries:N(P({sha:A().min(1),timestamp:A().min(1),author:A(),authorEmail:A(),type:F([`checkpoint`,`wip`,`upstream`,`park`]),message:A(),contributors:N(W1),checkpoint:Ks().nullable()}).loose()),total:j().int().nonnegative().optional(),truncated:M().optional(),hasMore:M().optional()}).loose(),K1=P({sha:A().regex(/^[0-9a-f]{40}$/i),content:A(),timestamp:A(),author:A()}).loose(),q1=P({contentDir:A().min(1),pathSeparator:F([`/`,`\\`]),symlinkResolved:M()}).loose(),J1=N(tc(`source`,[P({docName:A().min(1),timestamp:A().min(1),size:j().int().nonnegative(),source:I(`flat`)}).loose(),P({docName:A().min(1),timestamp:A().min(1),source:I(`timeline`),sha:A().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),Y1=P({orphans:N(P({docName:A().min(1),title:A()}).loose())}).loose(),X1=P({hubs:N(P({docName:A().min(1),title:A(),count:j().int().nonnegative()}).loose())}).loose(),Z1=P({source:A().min(1),title:A(),snippet:A().nullable()}).loose(),Q1=P({deadLinks:N(P({target:A().min(1),sources:N(Z1)}).loose())}).loose(),$1=P({target:P({docName:A().min(1),title:A(),aliases:N(A())}).loose(),mentions:N(P({source:A().min(1),excerpt:A(),offset:j().int().nonnegative()}).loose()),truncated:M()}).loose(),e0=P({projectPath:A().min(1)}).loose(),t0=F([`not-a-git-worktree`,`init-failed`]),n0=tc(`ok`,[P({ok:I(!0),projectPath:A().min(1)}).loose(),P({ok:I(!1),reason:t0,message:A().min(1)}).loose()]),r0=P({host:A().min(1).optional()}).loose(),i0=P({key:A().min(1)}).loose(),a0=P({keyPresent:M()}).loose(),o0=P({name:A().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:A().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),s0=P({authenticated:M()}).loose(),c0=P({}).loose(),l0=P({stackIndex:j().int().min(0),ts:j().int().min(0),additions:j().int().min(0),deletions:j().int().min(0)}).loose(),u0=P({docName:A().min(1),additionsTotal:j().int().min(0),deletionsTotal:j().int().min(0),lastTs:j().int().min(0),bursts:N(l0)}).loose(),d0=P({displayName:A().min(1),color:A().min(1),icon:A().optional(),connectionId:A().min(1)}).loose(),f0=P({sessionAlive:M(),agent:d0.nullable(),files:N(u0)}).loose(),p0=P({diff:A(),generatedAt:j().int().min(0)}).loose(),m0=P({}).loose(),h0=P({}).loose(),g0=P({}).loose(),_0=P({}).loose(),v0=P({}).loose(),y0=P({}).loose(),b0=P({displayName:A().min(1),icon:A(),color:A().min(1),currentDoc:A().nullable(),mode:F([`idle`,`writing`]),ts:j().int().min(0)}).loose(),x0=P({presence:ac(A().min(1),b0)}).loose(),S0=ac(A().min(1),M()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});P({path:A().min(1,`path must be non-empty`)}).loose();const C0=P({}).loose(),w0=P({fromDocName:A().min(1),toDocName:A().min(1)}).loose(),T0=P({fromPath:A().min(1),toPath:A().min(1)}).loose(),E0=P({}).loose(),D0=P({path:A().min(1),...xq,summary:Sq}).loose(),O0=P({docName:A().min(1)}).loose(),k0=P({path:A().min(1),...xq,summary:Sq}).loose(),A0=P({path:A().min(1)}).loose(),j0=P({kind:F([`file`,`folder`]),path:A().min(1),...xq,summary:Sq}).loose(),M0=P({kind:F([`file`,`folder`]),path:A().min(1),duplicatedDocNames:N(A().min(1))}).loose(),N0=P({pages:N(P({docName:A().min(1),title:A(),docExt:A().min(1),size:j().int().nonnegative(),modified:A().min(1),icon:A().min(1).max(2048).optional()}).loose())}).loose(),P0=P({level:j().int().min(1).max(6),text:A(),slug:A()}).loose(),F0=P({docName:A().min(1),headings:N(P0)}).loose(),I0=P({docName:A().min(1),rewrites:j().int().nonnegative()}).loose(),L0=P({kind:F([`file`,`folder`,`asset`]),fromPath:A().min(1),toPath:A().min(1),...xq,summary:Sq}).loose(),R0=P({renamed:N(w0),renamedAssets:N(T0),rewrittenDocs:N(I0).optional(),summary:u1.optional()}).loose(),z0=P({kind:F([`file`,`folder`,`asset`]),path:A().min(1),...xq}).loose(),B0=P({deletedDocNames:N(A().min(1))}).loose(),V0=P({kind:F([`file`,`folder`,`asset`]),path:A().min(1),...xq,summary:Sq}).loose(),H0=P({deletedDocNames:N(A().min(1))}).loose(),U0=P({docName:A().min(1),commitSha:A().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:Sq,...xq}).loose(),W0=P({restoredFrom:A().min(1),timestamp:A().min(1),summary:u1.optional(),warning:f1.optional(),warnings:_1.optional()}).loose(),G0=F([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),K0=P({label:A().min(1),webUrl:xs().nullable()}).loose(),q0=tc(`checkStatus`,[P({checkStatus:I(`allowed`)}).loose(),P({checkStatus:I(`denied`),deniedReason:F([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),P({checkStatus:I(`unknown`),unknownError:F([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),J0=F([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),Y0=P({state:G0,lastSyncUtc:A().nullable(),lastFetchUtc:A().nullable(),lastPushedSha:A().nullable(),ahead:j().int().min(0),behind:j().int().min(0),consecutiveFailures:j().int().min(0),conflictCount:j().int().min(0),hasRemote:M(),syncEnabled:M(),identityUnresolved:M(),remote:K0.nullable().optional(),pushError:A().optional(),pushErrorCode:J0.optional(),pullError:A().optional(),pullErrorCode:J0.optional(),pausedReason:A().optional(),pushPermission:q0.optional()}).loose(),X0=P({op:F([`sync`,`push`,`pull`]).optional()}).loose(),Z0=P({op:F([`sync`,`push`,`pull`])}).loose(),Q0=P({conflicts:N(P({file:A().min(1),detectedAt:A().min(1),oursSha:A().optional(),theirsSha:A().optional(),baseSha:A().optional()}).loose())}).loose(),$0=P({file:A().min(1),strategy:F([`mine`,`theirs`,`content`,`delete`]),content:A().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),e2=P({}).loose(),t2=P({file:A().min(1),base:A(),ours:A(),theirs:A(),kind:F([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:A().nullable()}).loose(),n2=P({plan:jc(e=>e!==void 0,{message:`plan is required`})}).loose(),r2=P({plan:jc(e=>e!==void 0,{message:`plan is required`})}).loose(),i2=P({result:jc(e=>e!==void 0,{message:`result is required`})}).loose(),a2=P({path:A().min(1),summary:A().min(1)}).loose(),o2=P({files:j().int().nonnegative(),folders:j().int().nonnegative()}).loose(),s2=P({packs:N(P({id:A().min(1),name:A().min(1),description:A().min(1),defaultSubfolder:A().optional(),folders:N(a2),entryCounts:o2}).loose())}).loose(),c2=P({noOpen:M().optional(),out:A().min(1).optional()}).loose(),l2=P({reason:F([`unsupported-platform`,`spawn-error`]),message:A()}).loose(),u2=tc(`status`,[P({status:I(`installed`),outputPath:A(),size:j().int().nonnegative(),sha256:A(),skillVersion:A()}).loose(),P({status:I(`built`),outputPath:A(),size:j().int().nonnegative(),sha256:A(),skillVersion:A(),handoffError:l2.optional()}).loose(),P({status:I(`failed`),buildError:A()}).loose(),P({status:I(`skip-current`),skillVersion:A(),recordedAt:A().optional()}).loose()]),d2=[`.ok`,`skill-targets.json`],f2=F(qG),p2=Zs({schema:I(1),targets:N(f2).default([])});function m2(e){let t;try{t=JSON.parse(e)}catch{return null}let n=p2.safeParse(t);return n.success?n.data:null}const h2=P({tags:N(P({name:A().min(1),count:j().int().nonnegative(),isLeaf:M()}).loose())}).loose(),g2=P({docName:A().min(1),title:A(),matchingTags:N(A().min(1)),snippet:A().nullable()}).loose(),_2=P({name:A().min(1),docs:N(g2)}).loose(),v2=P({folder:Ks(),frontmatter_local:ac(A(),Ks()).nullable()}).loose(),y2=P({path:A(),frontmatter:ac(A(),Ks()).optional()}).loose(),b2=P({applied:Ks()}).loose(),x2=ac(A(),Ks()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),S2=P({template:P({name:A().min(1),folder:A(),scope:F([`local`,`inherited`]),path:A().min(1),frontmatter:x2,body:A()}).strict()}).strict(),C2=P({templates:N(P({name:A().min(1),title:A().optional(),description:A().optional(),path:A().min(1),source_folder:A()}).strict()),truncated:M()}).strict(),w2=P({folder:A(),name:A(),body:A().optional(),frontmatter:x2.optional(),...xq,summary:Sq}).strict(),T2=P({path:A().min(1),created:M(),warnings:N(A())}).strict(),E2=P({existed:M(),path:A().min(1)}).strict(),D2=P({fromFolder:A(),fromName:A(),toFolder:A(),toName:A(),body:A().optional(),frontmatter:x2.optional(),...xq,summary:Sq}).strict(),O2=P({from:A().min(1),to:A().min(1),committed:M()}).strict(),k2=F(EG),A2=/^[a-z0-9-]+$/,j2=/<\/?[A-Za-z][^>]*>/;function M2(e){return j2.test(e)}const N2=/^[A-Za-z0-9_-]+$/,P2=P({name:A(),description:A()}).strict(),F2=P({skill:P({name:A().min(1),scope:k2,path:A().min(1),frontmatter:P2,body:A(),files:N(P({path:A().min(1),text:A().nullable()})).optional()}).strict()}).strict(),I2=P({skills:N(P({name:A().min(1),description:A().optional(),scope:k2,path:A().min(1),absolutePath:A().min(1).optional(),installed:M(),hosts:N(A()),installedVersion:A().optional(),bundledVersion:A().optional(),updateAvailable:M().optional()}).strict()),truncated:M()}).strict(),L2=P({scope:k2.default(`project`),name:A(),body:A().optional(),frontmatter:P2,...xq,summary:Sq}).strict(),R2=P({path:A().min(1),created:M(),warnings:N(A())}).strict(),z2=P({scope:k2.default(`project`),name:A(),...xq,summary:Sq}).strict(),B2=P({name:A().min(1),version:A().min(1),previousVersion:A().optional(),checkpointRef:A().optional()}).strict(),V2=P({existed:M(),path:A().min(1)}).strict(),H2=P({scope:k2.default(`project`),fromName:A(),toName:A(),body:A().optional(),frontmatter:P2.optional(),...xq,summary:Sq}).strict(),U2=P({from:A().min(1),to:A().min(1),committed:M()}).strict(),W2=F([`reference`,`script`]),G2=P({scope:k2.default(`project`),name:A(),path:A().min(1),content:A(),...xq,summary:Sq}).strict(),K2=P({path:A().min(1),created:M(),kind:W2,content:M()}).strict(),q2=P({path:A().min(1),kind:W2,text:A()}).strict(),J2=P({path:A().min(1),existed:M(),kind:W2}).strict(),Y2=P({scope:k2.default(`project`),name:A(),targets:N(f2).optional().meta({description:`Explicit editor ids to install into; omit to use project-configured editors.`}),...xq,summary:Sq}).strict(),X2=P({name:A().min(1),hosts:N(A()),scripts:M(),warnings:N(A()),warningCodes:N(F([`no-targets`,`scripts-present`]))}).strict(),Z2=P({scope:k2.default(`project`),name:A()}).strict(),Q2=P({name:A().min(1),uninstalled:M()}).strict(),$2=P({targets:N(f2),configured:M()}).strict(),e4=P({targets:N(f2)}).strict(),t4=P({targets:N(f2),reprojected:N(P({name:A(),hosts:N(A())}).strict()),bundleHosts:N(A()),removedFrom:N(A())}).strict(),n4=P({scope:k2.default(`project`),name:A(),version:A().regex(/^[0-9a-f]{40}$/i),...xq,summary:Sq}).strict(),r4=P({name:A().min(1),version:A(),restoredFiles:N(A()),warnings:N(A())}).strict(),i4=P({query:A().optional(),intent:F([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:F([`navigation`,`relevance`]).optional(),scopes:N(F([`page`,`folder`,`content`,`file`])).optional(),scope:A().optional(),limit:j().int().nonnegative().optional(),semantic:M().optional(),source:F([`omnibar`,`mcp`,`http`]).optional()}).loose(),a4=P({kind:F([`page`,`folder`,`content`,`file`]),path:A().min(1),title:A(),score:j(),signals:ac(A(),Ks()),snippet:A().optional()}).loose(),o4=P({capable:M(),applied:M(),coverage:P({embedded:j().int().nonnegative(),total:j().int().nonnegative()})}).loose(),s4=P({enabled:M(),keyPresent:M(),keySource:F([`file`,`env`]).nullable(),keyHint:A().nullable(),ready:M(),capable:M(),embedded:j().int().nonnegative(),total:j().int().nonnegative()}).loose(),c4=P({query:A(),intent:F([`autocomplete`,`full_text`,`omnibar`]),results:N(a4),elapsedMs:j().nonnegative(),semantic:o4.optional(),truncated:M().optional(),ready:M().optional()}).loose(),l4=P({version:A().min(1),recordedAt:A().min(1)}).loose(),u4=P({currentVersion:A().min(1),targets:ac(A(),l4.nullable())}).loose(),d4=`server-info`,f4=`branch-switched`,p4=`disk-ack`,m4=`config-validation-rejected`,h4=`config-ignore-nested-error`,g4=F([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),_4=P({v:I(1),ch:I(d4),seq:j(),serverInstanceId:A().min(1),currentBranch:A().min(1).optional()}).loose(),v4=P({v:I(1),ch:I(f4),seq:j(),branch:A().min(1)}).loose(),y4=P({v:I(1),ch:g4,seq:j()}).loose(),b4=P({v:I(1),ch:I(p4),seq:j(),docName:A().min(1),sv:A().min(1)}).loose(),x4=P({v:I(1),ch:I(m4),seq:j(),docName:A().min(1),error:ql}).loose(),S4=P({v:I(1),ch:I(h4),seq:j(),path:A().min(1),error:A().min(1)}).loose(),C4=new pG.default;function w4(e,t){if(e===t)return[{value:e}];let{chars1:n,chars2:r,lineArray:i}=C4.diff_linesToChars_(e,t),a=C4.diff_main(n,r,!1);C4.diff_charsToLines_(a,i),C4.diff_cleanupSemantic(a);let o=[];for(let[e,t]of a)e===pG.default.DIFF_DELETE?o.push({value:t,removed:!0}):e===pG.default.DIFF_INSERT?o.push({value:t,added:!0}):o.push({value:t});return o}const T4=new pG.default;T4.Diff_Timeout=.25;const E4=256*1024;function D4(e,t,n){if(t===n)return;let r=w4(t,n),i=0;for(let n=0;n<r.length;n++){let a=r[n],o=r[n+1];if(a.removed&&o?.added){if(t.substring(i,i+o.value.length)===o.value){i+=o.value.length,n++;continue}e.delete(i,a.value.length),e.insert(i,o.value),i+=o.value.length,n++}else a.removed?e.delete(i,a.value.length):(a.added&&e.insert(i,a.value),i+=a.value.length)}}function O4(e,t,n){if(t===n)return;if(t.length>E4||n.length>E4){k4(e,t,n);return}let r=T4.diff_main(t,n);T4.diff_cleanupSemantic(r);let i=0;for(let[t,n]of r)t===0?i+=n.length:t===-1?e.delete(i,n.length):t===1&&(e.insert(i,n),i+=n.length)}function k4(e,t,n){let r=0,i=Math.min(t.length,n.length);for(;r<i&&t.charCodeAt(r)===n.charCodeAt(r);)r++;let a=0;for(;a<i-r&&t.charCodeAt(t.length-1-a)===n.charCodeAt(n.length-1-a);)a++;let o=t.length-r-a,s=n.slice(r,n.length-a);o>0&&e.delete(r,o),s.length>0&&e.insert(r,s)}const A4=P({path:N($s([A(),j()])),message:A(),issueCode:A()});tc(`code`,[P({code:I(`SCHEMA_INVALID`),issues:N(A4)}),P({code:I(`WRITE_ERROR`),detail:A()})]);const j4={defaultKeyType:`PLAIN`,defaultStringType:`PLAIN`,lineWidth:0};function M4(e){if(e.trim()===``)return{doc:new Fc.Document({}),map:{}};let t;try{t=(0,Fc.parseDocument)(e)}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new Fc.Document({}),map:null,parseError:`parse threw: ${t}`}}if(t.errors.length>0)return{doc:t,map:null,parseError:t.errors[0]?.message??`yaml parse errors`};let n;try{n=t.toJS()}catch(e){let n=e instanceof Error?e.message:String(e);return{doc:t,map:null,parseError:`toJS threw: ${n}`}}if(typeof n!=`object`||!n||Array.isArray(n))return{doc:t,map:null,parseError:`top-level value is not a mapping`};let r=i1.safeParse(n);if(!r.success){let e=r.error.issues[0],n=e&&Array.isArray(e.path)?e.path.join(`.`):``,i=e?.message??`unknown`;return{doc:t,map:null,parseError:n?`value at "${n}" failed schema: ${i}`:`schema validation failed: ${i}`}}return{doc:t,map:r.data}}function N4(e){return Object.keys(e).length===0?``:new Fc.Document(e).toString(j4)}function P4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F4(e,t,n){if(Array.isArray(n)){let r=e.createNode(n),i=(0,Fc.isSeq)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}if(P4(n)){let r=e.createNode(n),i=(0,Fc.isMap)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}return n}function I4(e){return e===``?``:`---\n${e.endsWith(`
|
|
430
|
+
`)?e.slice(0,-1):e}\n---\n`}function L4(e){let t=e.match(dK);return t?{fenced:t[0],body:e.slice(t[0].length)}:{fenced:``,body:e}}function R4(e){if(e.trim()===``)return{doc:new Fc.Document({}),map:{}};let t;try{t=(0,Fc.parseDocument)(e,{uniqueKeys:!1})}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new Fc.Document({}),map:null,parseError:`parse threw: ${t}`}}if(t.errors.length>0)return{doc:t,map:null,parseError:t.errors[0]?.message??`yaml parse errors`};let n;try{n=t.toJS()}catch(e){let n=e instanceof Error?e.message:String(e);return{doc:t,map:null,parseError:`toJS threw: ${n}`}}if(typeof n!=`object`||!n||Array.isArray(n))return{doc:t,map:null,parseError:`top-level value is not a mapping`};let r=i1.safeParse(n);if(!r.success){let e=r.error.issues[0],n=e&&Array.isArray(e.path)?e.path.join(`.`):``,i=e?.message??`unknown`;return{doc:t,map:null,parseError:n?`value at "${n}" failed schema: ${i}`:`schema validation failed: ${i}`}}return{doc:t,map:r.data}}function z4(e){return e===``?{doc:new Fc.Document({}),map:{}}:R4(mK(e))}function B4(e){let{fenced:t}=L4(e),{map:n}=z4(t);return n??{}}function V4(e){if(e.contents==null||!(`items`in e.contents)){let t=e.createNode({});return e.contents=t,t}return e.contents}function H4(e){let t=e.contents;return!t||!(`items`in t)||(t.items?.length??0)===0?``:I4(e.toString(j4))}function U4(e){let t=new TextEncoder().encode(e).byteLength;return t>65536?{kind:`region_too_large`,bytes:t,limit:65536}:null}function W4(e){let t=H4(e),n=U4(t);return n?{ok:!1,error:n}:{ok:!0,nextFenced:t}}function G4(e,t){if(Object.hasOwn(t,`frontmatter`))return{ok:!1,error:{kind:`reserved_key`,key:`frontmatter`}};let{doc:n,map:r}=z4(e);if(r===null)return{ok:!1,error:{kind:`parse_failed`,reason:`fm region unparseable`}};try{V4(n);for(let[e,r]of Object.entries(t)){if(r===null){n.delete(e);continue}let t=n1.safeParse(r);if(!t.success)return{ok:!1,error:{kind:`invalid_value`,key:e,reason:t.error.issues[0]?.message??`invalid value`}};n.set(e,F4(n,n.get(e,!0),t.data))}return W4(n)}catch(e){return{ok:!1,error:{kind:`parse_failed`,reason:`yaml@2 threw: ${e instanceof Error?e.message:String(e)}`}}}}Object.freeze({source:`local`,skipStoreHooks:!1,context:Object.freeze({origin:`form-write`})});function K4(e,t){let n=t?.verbose===!0,r=t?.nowMs===void 0?new Date().toISOString():new Date(t.nowMs).toISOString(),i={event:`bridge-invariant-violation`,site:e.site,"doc.name":e.docName??null,"tolerance-class-attempted":`untracked`,"normalize-equal-modulo-tolerance":!1,ytextLen:e.ytextSnapshot.length,fragmentLen:e.fragmentMdSnapshot.length,ytextHash:uu(e.ytextSnapshot),fragmentHash:uu(e.fragmentMdSnapshot),redacted:!n,timestamp:r};return n?{...i,diff:e.unifiedDiff}:i}var q4=class extends Error{violation;constructor(e){let t=typeof e.origin==`string`?e.origin:e.origin?.context?.origin??`unknown-object`,n=e.docName?` doc='${e.docName}'`:``;super(`Bridge invariant violated [site='${e.site}'${n}, origin='${t}'].\n Y.Text (${e.ytextSnapshot.length} chars): ${e.ytextSnapshot.slice(0,200)}...\n Fragment (${e.fragmentMdSnapshot.length} chars): ${e.fragmentMdSnapshot.slice(0,200)}...\n Diff:\n${e.unifiedDiff}`),this.name=`BridgeInvariantViolationError`,this.violation=e}};const J4=/^(?:\r?\n)+/;function Y4(e){let{frontmatter:t,body:n}=fK(e),r=n.match(J4);if(!r)return{boundary:``,text:e};let i=n.slice(r[0].length);return t===``&&dK.test(i)?{boundary:``,text:e}:{boundary:r[0],text:t+i}}function X4(e,t){if(t===``)return e;let{frontmatter:n,body:r}=fK(e);return n+t+r}function Z4(e){let t=Y4(e).text;return fK(t).frontmatter===``?t:X4(t,`
|
|
431
|
+
`)}function Q4(e,t=16){let n=e.trim();return n.length<t?!1:!(n.startsWith(`<`)||n.startsWith("```")||n.startsWith(`|`))}function $4(e,t=16){let n=new Map;for(let r of e.split(`
|
|
432
|
+
`)){if(!Q4(r,t))continue;let e=r.trim();n.set(e,(n.get(e)??0)+1)}return n}function e3(e,t,n=16){let r=$4(t,n),i=[];for(let[t,a]of $4(e,n))a>=2&&a>(r.get(t)??0)&&i.push(t);return i}const t3=new pG.default;t3.Match_Threshold=.5;function n3(e,t,n){let r=r3(e,t,n);return c3(e,t,n,r),r}function r3(e,t,n){if(e===t)return n;if(e===n||t===n)return t;let r=NV(t.split(`
|
|
433
433
|
`),e.split(`
|
|
434
434
|
`),n.split(`
|
|
435
435
|
`)),i=[];for(let e=0;e<r.length;e++){let t=r[e];if(`ok`in t&&t.ok)i.push(t.ok.join(`
|
|
436
436
|
`));else if(`conflict`in t&&t.conflict){let e=t.conflict.o.join(`
|
|
437
437
|
`),n=t.conflict.a.join(`
|
|
438
438
|
`),r=t.conflict.b.join(`
|
|
439
|
-
`);i.push(
|
|
440
|
-
`)}function
|
|
441
|
-
`)){let t=e.trim();t.length!==0&&r.push(t)}return r}function
|
|
439
|
+
`);i.push(l3(e,n,r))}}return i.join(`
|
|
440
|
+
`)}function i3(e){return e.map(e=>({len:e.length,digest:uu(e)}))}var a3=class extends Error{info;constructor(e){let t=e.lostSubstrings.map(e=>JSON.stringify(e.length>80?`${e.slice(0,77)}...`:e)).join(`, `);super(`Bridge merge content loss (which=${e.which}, side=${e.side}): ${t}`),this.name=`BridgeMergeContentLossError`,this.info=e}toLog(e){let t=e?.verbose===!0;return{event:`bridge-merge-content-loss`,which:this.info.which,side:this.info.side,baselineLen:this.info.baseline.length,userTextLen:this.info.userText.length,agentTextLen:this.info.agentText.length,resultLen:this.info.result.length,lostSubstrings:t?this.info.lostSubstrings:i3(this.info.lostSubstrings),redacted:!t}}};function o3(e,t){if(e===t)return[];let n=t3.diff_main(e,t);t3.diff_cleanupSemantic(n);let r=[];for(let[e,t]of n)if(e===1)for(let e of t.split(`
|
|
441
|
+
`)){let t=e.trim();t.length!==0&&r.push(t)}return r}function s3(e,t){let n=0;for(let r of t){let t=e.indexOf(r,n);if(t<0){if(e.indexOf(r)<0)continue;return r}n=t+r.length}return null}function c3(e,t,n,r){let i=o3(e,t),a=o3(e,n),o=i.filter(e=>!r.includes(e));if(o.length>0)throw new a3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:o,which:`substring`,side:`user`});let s=a.filter(e=>!r.includes(e));if(s.length>0)throw new a3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:s,which:`substring`,side:`agent`});let c=s3(r,i);if(c!==null)throw new a3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[c],which:`order`,side:`user`});let l=s3(r,a);if(l!==null)throw new a3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[l],which:`order`,side:`agent`});let u=$4(e),d=$4(t),f=$4(n);for(let[i,a]of $4(r))if(!(a<2)&&a>Math.max(u.get(i)??0,d.get(i)??0,f.get(i)??0))throw new a3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[i],which:`growth`,side:`user`})}function l3(e,t,n){if(t===``)return n;if(n===``)return t;let r=t3.patch_make(e,t),[i,a]=t3.patch_apply(r,n);return a.some(e=>!e)&&console.warn(JSON.stringify({event:`bridge-merge-patch-drop`,applied:a.filter(Boolean).length,total:a.length,regionSize:n.length})),i}const u3=/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g,d3=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/,f3=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/,p3=/^\d+([.)])(?=\s)/,m3=/\*\*\s*(`[^`]+`)\s*\*\*/g,h3=/^(`{3,}|~{3,})/;function g3(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r].trimEnd(),a=h3.exec(i);if(a){let e=a[1][0];if(n===null){n=e;continue}if(n===e){n=null;continue}}if(n!==null||r===0||!d3.test(i))continue;let o=e[r-1].trimEnd();if(!(!o.startsWith(`|`)||d3.test(o))){t.add(r-1),t.add(r);for(let n=r+1;n<e.length&&e[n].trimEnd().startsWith(`|`);n++)t.add(n)}}return t}function _3(e){return e.slice(0,-1).trimEnd()}const v3=/^(?:#{1,6}[ \t]|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function y3(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r]??``,a=/^(`{3,}|~{3,})/.exec(i.trimStart());if(a?.[1]){let e=a[1][0];if(n===null){n=e;continue}if(n===e){n=null;continue}}n!==null&&t.add(r)}return t}const b3=/^<\/?[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,x3=/^<[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,S3=/^<\/[A-Z][A-Za-z0-9.]*\s*>$/,C3=/<\/?[A-Z]/;function w3(e){let t=!1;for(let n=0;n<e.length;n++)if(C3.test(e[n]??``)){t=!0;break}if(!t)return e;let n=y3(e),r=[],i=[],a=0;for(let t=0;t<e.length;t++){let o=e[t]??``,s=o.trim();if(n.has(t)){r.push(!1),i.push(a);continue}let c=a>=1||!/^[ \t]/.test(o);r.push(c&&b3.test(s));let l=c&&S3.test(s),u=c&&!l&&x3.test(s)&&!s.endsWith(`/>`);l?(a=Math.max(0,a-1),i.push(a)):(i.push(a),u&&(a+=1))}let o=Array(e.length);for(let t=0,n=-1;t<e.length;t++)o[t]=n,(e[t]??``).trim()!==``&&(n=t);let s=Array(e.length);for(let t=e.length-1,n=e.length;t>=0;t--)s[t]=n,(e[t]??``).trim()!==``&&(n=t);let c=new Set;for(let t=0;t<e.length;t++){if((e[t]??``).trim()!==``||n.has(t)||(i[t]??0)<1)continue;let a=o[t]??-1,l=s[t]??e.length;(a>=0&&r[a]===!0||l<e.length&&r[l]===!0)&&c.add(t)}let l=[];for(let t=0;t<e.length;t++){if(c.has(t))continue;let n=e[t]??``;l.push(r[t]===!0&&(i[t]??0)>=1?n.replace(/^[ \t]+/,``):n)}return l}function T3(e){let t=w3(e.replace(/^/,``).replace(/\r/g,``).replace(u3,`$1`).replace(m3,`$1`).replace(/^\n+/,``).replace(/^[*-]{3,}(?=\n|$)/,`---`).replace(/(\n)([#>+-]|\d+[.)]|`{3,}|~{3,})/g,`
|
|
442
442
|
|
|
443
443
|
$2`).replace(/^([#>+-].*|\d+[.)].*|`{3,}.*|~{3,}.*)\n([^\n])/gm,`$1
|
|
444
444
|
|
|
445
445
|
$2`).split(`
|
|
446
|
-
`)),n=
|
|
446
|
+
`)),n=g3(t),r=y3(t);return t.map((e,i)=>{let a=e.trimEnd();if(i>0&&!r.has(i)&&/^[ \t]+\S/.test(a)&&(t[i-1]??``).trim()!==``&&!f3.test(a)&&!v3.test(a.trimStart())){let e=(t[i-1]??``).trimStart();if(!v3.test(e)&&!e.startsWith(`|`))return a.replace(/^[ \t]+/,``)}if(d3.test(a)){let e=a.replace(/\s+/g,``);return n.has(i)&&e.length>1&&e.startsWith(`|`)&&e.endsWith(`|`)?_3(e):e}let o=f3.test(a)?a.replace(/^[ \t]+/,``):a;return n.has(i)&&o.length>1&&o.startsWith(`|`)&&o.endsWith(`|`)&&(o=_3(o)),o.replace(p3,`1$1`)}).join(`
|
|
447
447
|
`).replace(/\n{3,}/g,`
|
|
448
448
|
|
|
449
|
-
`).replace(/\n+$/,``)}function
|
|
449
|
+
`).replace(/\n+$/,``)}function E3(e,t){let n=[];(e.charCodeAt(0)===65279||t.charCodeAt(0)===65279)&&n.push(`bom`),(e.includes(`\r`)||t.includes(`\r`))&&n.push(`crlf`),(/\\[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/.test(e)||/\\[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/.test(t))&&n.push(`commonmark-escape`),(/\*\*\s*`[^`]+`\s*\*\*/.test(e)||/\*\*\s*`[^`]+`\s*\*\*/.test(t))&&n.push(`emphasis-around-code`);let r=e.replace(/^/,``),i=t.replace(/^/,``);r.startsWith(`
|
|
450
450
|
`)!==i.startsWith(`
|
|
451
451
|
`)&&n.push(`leading-newline`);let a=r.replace(/^\n+/,``),o=i.replace(/^\n+/,``),s=/^\*{3,}(?=\n|$)/.test(a),c=/^-{3,}(?=\n|$)/.test(a),l=/^\*{3,}(?=\n|$)/.test(o),u=/^-{3,}(?=\n|$)/.test(o);(s&&u||c&&l)&&n.push(`doc-start-thematic`);let d=/\n\n([#>+-]|\d+[.)]|`{3,}|~{3,})/,f=/^([#>+-].*|\d+[.)].*|`{3,}.*|~{3,}.*)\n\n[^\n]/m,p=d.test(r),m=d.test(i),h=f.test(r),g=f.test(i);(p!==m||h!==g)&&n.push(`block-separator-collapse`);let _=r.replace(/\r/g,``),v=i.replace(/\r/g,``),y=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/m;(y.test(_)||y.test(v))&&n.push(`table-align-row-spacing`);let b=e=>y.test(e)&&/^\|[^\n]*[^|\s][ \t]*$/m.test(e);b(_)!==b(v)&&n.push(`row-no-trailing-pipe`);let x=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/m;(x.test(_)||x.test(v))&&n.push(`list-indent-canonical`);let S=/[^\n]\n[ \t]+(?![-+*>#]|\d+[.)])\S/;(S.test(_)||S.test(v))&&n.push(`paragraph-continuation-indent`);let C=_.split(`
|
|
452
452
|
`),w=v.split(`
|
|
453
|
-
`),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&
|
|
453
|
+
`),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&b3.test(n),a=n===``&&r!==``&&b3.test(r);if(i||a)return!0}return!1};(T(C)||T(w))&&n.push(`jsx-container-boundary-blank`);let E=e=>e.replace(/^[ \t]+/,``).replace(p3,`1$1`),ee=Math.min(C.length,w.length);for(let e=0;e<ee;e++){let t=C[e]??``,r=w[e]??``;if(t!==r&&E(t)===E(r)&&/^[ \t]*\d+[.)]\s/.test(t)){n.push(`ordered-list-marker-number`);break}}return(/[ \t]\n/.test(_)||/[ \t]\n/.test(v))&&n.push(`trailing-whitespace`),(/[ \t]$/.test(_)||/[ \t]$/.test(v))&&(n.includes(`trailing-whitespace`)||n.push(`trailing-whitespace`)),(/\n{3,}/.test(_)||/\n{3,}/.test(v))&&n.push(`blank-line-collapse`),_.endsWith(`
|
|
454
454
|
`)!==v.endsWith(`
|
|
455
|
-
`)&&n.push(`trailing-newline`),n}const
|
|
456
|
-
`).map(e=>e.replace(k3,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const j3=new Set;function M3(e,t,n){let r=fK(e),i=fK(t);if(r.frontmatter!==i.frontmatter)return!1;if(r.body===i.body)return!0;let a;try{a=n(r.body)}catch(e){let t=e instanceof Error?e.message:String(e);return j3.size<8&&!j3.has(t)&&(j3.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return D3(O3(a))===D3(O3(i.body))?fJ(A3(r.body),A3(a)):!1}const N3={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},P3={"emphasis-around-code":`pm-model-caused`,bom:`parser-caused`,crlf:`parser-caused`,"commonmark-escape":`parser-caused`,"leading-newline":`parser-caused`,"paragraph-continuation-indent":`parser-caused`,"doc-start-thematic":`parser-caused`,"block-separator-collapse":`serializer-caused`,"table-align-row-spacing":`serializer-caused`,"row-no-trailing-pipe":`serializer-caused`,"ordered-list-marker-number":`serializer-caused`,"list-indent-canonical":`serializer-caused`,"jsx-container-boundary-blank":`serializer-caused`,"trailing-whitespace":`serializer-caused`,"blank-line-collapse":`serializer-caused`,"trailing-newline":`serializer-caused`,"parse-equivalence":`parser-caused`};function F3(e){return P3[e]}function I3(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return e.length===t.length?-1:n}let L3=null;function R3(e){L3=e}function z3(e,t,n,r){if(!L3||e.length===0)return;let i=I3(t,n),a=new Date().toISOString();for(let t of e)L3({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:F3(t)})}const B3=1e4,V3=`last-spawn-error.log`,H3=/^[a-zA-Z0-9][\w/-]*$/;function U3(e){return e.startsWith(`#`)?e.slice(1):e}function W3(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function G3(e){if(!e||e.trim()===``)return[];let{map:t}=j4(e);if(!t)return[];let n=W3(t.tags),r=[];for(let e of n){let t=U3(e);H3.test(t)&&r.push(t)}return r}const K3=[`.ok`,`local`,`installed-skills.json`],q3=F(EG),J3=Zs({hosts:N(A()),scope:q3,scripts:M(),installedAt:Go()}),Y3=Zs({schema:I(1),skills:ac(A(),J3).default({})});function X3(){return{schema:1,skills:{}}}function Z3(e){let t;try{t=JSON.parse(e)}catch{return null}let n=Y3.safeParse(t);return n.success?n.data:null}const Q3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},$3=new WeakMap;function e6(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function t6(e){return e.trim().toLowerCase()}const n6=/\.(?:md|mdx)$/;function r6(e,t){if(t!==`page`)return e;let n=e.replace(n6,``);return n.length>0?n:e}function i6(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function a6(e){let t=i6(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function o6(e){let t=CW({schema:Q3});return e.length>0&&PW(t,e),t}function s6(e){let t={documents:e};return $3.set(t,o6(e)),t}function c6(e){let t=$3.get(e);if(t)return t;let n=o6(e.documents);return $3.set(e,n),n}function l6(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function u6(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function d6(e,t){let n=t6(t);if(!n)return 0;let r=r6(n,e.kind),i=t6(e.title),a=t6(e.name),o=t6(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function f6(e,t){let n=d6(e,t);return n<=0?n:vq(e.path)?n*.5:n}function p6(e){return e===`file`?-60:0}function m6(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function h6(e,t,n,r){return e+t*20+n+p6(r)}function g6(e,t,n,r,i,a){return e===`relevance`?h6(t,n,r,i):m6(t,n,r,i,a)}function _6(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function v6(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function y6(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function b6(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function x6(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function S6(e,t){return t6(t).length<4?0:e===`full_text`?1:0}function C6(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function w6(e){let t=[],n=[],r=[];for(let i of e){let e=C6(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function T6(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=w6(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function E6(e,t,n={}){let r=n.intent??`omnibar`,i=_6(r,n.ranking),a=e6(n.limit),o=new Set(n.scopes??l6(r)),s=e.documents.filter(e=>u6(e,o)),c=t6(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=uG(c6(e),{term:c,properties:b6(r),boost:x6(r),tolerance:S6(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>u6(e.document,o)).map(e=>[e.document.id,e.score])),d=y6(s),f=new Map;for(let e of s)f6(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)u6(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=v6(f.values(),u);return T6([...f.values()].map(t=>{let n=Math.max(0,f6(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:g6(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return T6(O6({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function D6(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function O6(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=v6(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,f6(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?g6(o,t,n,s,e.kind,m):h6(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=D6(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=D6(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function k6(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),A6(n)}function A6(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const j6=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),M6=globalThis;M6[j6]===void 0&&(M6[j6]=Ri());const N6=M6[j6],P6=[`.ok`,`skill-state.yml`],F6=[`claude-cowork`,`cli-hosts`],I6=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],L6=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,R6=Zs({version:A().regex(L6,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(N6,{description:`Recorded skill version for this target.`}),recordedAt:Go().register(N6,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:F(I6).register(N6,{description:`Install-source surface that recorded this entry.`}).optional()}),z6=Zs({enabled:M().register(N6,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:Go().register(N6,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),B6=Zs({schema:I(1).register(N6,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Zs({"claude-cowork":R6.optional(),"cli-hosts":R6.optional()}).register(N6,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:ac(A(),z6).register(N6,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function V6(e,t){return e??t.installedOnDisk}function H6(){return{schema:1,targets:{}}}const U6=`template`;function W6(e){if(e.trim()===``)return{};let t;try{t=(0,Fc.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function G6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function K6(e){let{frontmatter:t,body:n}=fK(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:mK(t),markdown:n}}function q6(e){let t=e.split(`
|
|
457
|
-
`);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=
|
|
458
|
-
`))[
|
|
459
|
-
`).replace(/\n+$/,``)}}function J6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=fK(t);if(n===``)return{identity:{},starterContent:t};let i=mK(n),a=q6(i);if(a)return{identity:a.identity,starterContent:G6(a.docFrontmatterText,r)};let{frontmatter:o}=fK(r);if(o!==``)return{identity:W6(i),starterContent:r};let s=W6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:G6(i,r)}}function Y6(e,t){let{docFrontmatterText:n,markdown:r}=K6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Fc.stringify)({[U6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function X6(e){return J6(e).starterContent}function Z6(){let e=!1,t=``,n=0;return r=>{let i=Q6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function Q6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const $6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],e8={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function t8(e,t=$6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const n8={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function r8(e){return e?n8[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const i8={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function a8(e){let t=e?.trim();return t?i8[r8(t)]??t:`Agent`}function o8(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const s8=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function c8(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function l8(e){let t=e.trim();return s8.test(t)||t.startsWith(`//`)}function u8(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(l8(n))return{kind:`external`,url:n};let r=o8(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=c8(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function d8(e,t){let n=e.trim();if(!n)return null;if(l8(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=c8(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function f8(e,t){let n=e.trim();if(!n||s8.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function p8(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function m8(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function h8(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function g8(e){return e.split(`/`).filter(e=>e!==``)}function _8(e,t){let n=h8(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function v8(e,t){let n=h8(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:g8(r).length}function y8(e,t){let n=g8(e),r=g8(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function b8(){let e=new Map;function t(t){let n=p8(t);if(n===``)return;let r=m8(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=p8(t),r=m8(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=h8(p8(n)),o=[],s=[];for(let e of i)_8(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=v8(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=v8(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=y8(a,h8(t));for(let r=1;r<e.length;r++){let i=e[r],o=y8(a,h8(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function x8(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function S8(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function C8(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function w8(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}const T8=/^[A-Za-z0-9-]{8,64}$/;let E8=null;function D8(e){return l(e??m(),`.ok`,`machine-id`)}function O8(e){if(e===void 0&&E8!==null)return E8;let t=D8(e),n=null;try{let e=b(t,`utf-8`).trim();T8.test(e)&&(n=e)}catch{}if(n===null){n=w();try{v(c(t),{recursive:!0}),S(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){console.warn(`[machine-id] Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(E8=n),n}function k8(){try{let e=u(c(f(import.meta.url)),`..`,`package.json`),t=JSON.parse(b(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const A8=k8(),j8=1;var M8=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function N8(e,t){return u(e,`${t}.lock`)}const P8=new Map;function F8(e){P8.set(e,(P8.get(e)??0)+1)}function I8(e){let t=P8.get(e);return t===void 0||t<=1?(P8.delete(e),!0):(P8.set(e,t-1),!1)}function L8(e){return typeof e.machineId==`string`?e.machineId===O8():e.hostname===h()}const R8=new Set;let z8=!1;function B8(e){R8.add(e),!z8&&(z8=!0,process.on(`exit`,()=>{for(let e of R8)try{let t=JSON.parse(b(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==O8()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==h())continue;x(e)}catch{}}))}function V8(e,t){try{let n=JSON.parse(b(e,`utf-8`));return n&&typeof n==`object`&&w8(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function H8(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;v(n,{recursive:!0});let a=N8(n,t),o={pid:process.pid,hostname:h(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:O8(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??A8},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!_(a))try{let e=y(a,`wx`,384);try{C(e,s)}finally{g(e)}return F8(a),B8(a),U8({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=V8(a,i);if(e){if(L8(e)&&e.pid===process.pid)return S(a,s,{encoding:`utf-8`,mode:384}),F8(a),B8(a),U8({lockName:t,lockDir:n,lockPath:a});if(C8(e.pid))throw new M8(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{x(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function U8(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>Y8({lockName:t,lockDir:n}),updatePort:e=>W8({lockName:t,lockDir:n,port:e})}}function W8(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=N8(n,t);if(!_(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||!w8(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&L8(o)){o.port=r;try{S(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function G8(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=N8(n,t);if((P8.get(i)??0)>1)return;let a;try{let e=JSON.parse(b(i,`utf-8`));if(!e||typeof e!=`object`||!w8(e.pid)){console.warn(`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){e.code!==`ENOENT`&&console.warn(`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&L8(a)&&a.draining!==!0){a.draining=!0;try{S(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function K8(e){let{lockName:t,lockDir:n}=e,r=N8(n,t);if(!_(r))return null;let i;try{let e=JSON.parse(b(r,`utf-8`));if(!e||typeof e!=`object`||!w8(e.pid))return null;i=e}catch{return null}if(!L8(i))return null;if(!C8(i.pid)){try{x(r)}catch{}return null}return i}function q8(e){let{lockName:t,lockDir:n}=e,r=N8(n,t);if(!_(r))return{status:`absent`};let i;try{i=JSON.parse(b(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!w8(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!L8(o))return{status:`stale`,lock:o};if(!C8(o.pid)){try{x(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}async function J8(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>K8({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function Y8(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=N8(n,t);if(I8(a)){if(r){G8({lockName:t,lockDir:n});return}if(_(a))try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!L8(e))return;x(a),R8.delete(a)}catch(e){console.warn(`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var X8=class extends M8{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Z8(e,t){try{return H8({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof M8&&e.lockName===`server`?new X8(e.existing,e.lockPath):e}}function Q8(e,t){W8({lockName:`server`,lockDir:e,port:t})}function $8(e){return K8({lockName:`server`,lockDir:e})}function e5(e,t){Y8({lockName:`server`,lockDir:e,...t})}function t5(e){G8({lockName:`server`,lockDir:e})}function n5(e,t){return J8({lockName:`server`,lockDir:e,...t})}export{hG as $,Zl as $a,NG as $i,B2 as $n,XG as $r,r0 as $t,o1 as A,L as Aa,_$ as Ai,L6 as An,xs as Ao,Z0 as Ar,v2 as At,_1 as B,bl as Ba,Kq as Bi,r2 as Bn,mn as Bo,T2 as Br,K3 as Bt,h1 as C,G4 as Ca,a8 as Ci,q1 as Cn,P as Co,R2 as Cr,j0 as Ct,x1 as D,F4 as Da,k6 as Di,k2 as Dn,A as Do,uJ as Dr,B1 as Dt,s1 as E,gq as Ea,H6 as Ei,OG as En,ac as Eo,S0 as Er,KG as Et,M1 as F,Zc as Fa,r8 as Fi,V1 as Fn,qa as Fo,X0 as Fr,t1 as Ft,y4 as G,cu as Ga,BG as Gi,wq as Gn,k as Go,w2 as Gr,HG as Gt,x4 as H,Xc as Ha,$G as Hi,t2 as Hn,cn as Ho,E2 as Hr,l2 as Ht,j1 as I,Cl as Ia,X6 as Ii,H1 as In,si as Io,U6 as Ir,JG as It,m4 as J,Jc as Ja,$4 as Ji,jq as Jn,mt as Jo,m0 as Jr,n0 as Jt,g4 as K,ru as Ka,t3 as Ki,Dq as Kn,O as Ko,S2 as Kr,L1 as Kt,Jq as L,wl as La,zq as Li,r4 as Ln,br as Lo,M2 as Lr,W1 as Lt,a1 as M,qc as Ma,F$ as Mi,V3 as Mn,Uo as Mo,$0 as Mr,P1 as Mt,y1 as N,su as Na,LY as Ni,VG as Nn,ma as No,J0 as Nr,C1 as Nt,c1 as O,_b as Oa,x8 as Oi,P6 as On,$s as Oo,Q1 as Or,T0 as Ot,rJ as P,Ol as Pa,lq as Pi,_G as Pn,Ka as Po,Y0 as Pr,w1 as Pt,vG as Q,ou as Qa,RG as Qi,$q as Qn,V0 as Qr,i0 as Qt,K4 as R,Sl as Ra,i1 as Ri,s4 as Rn,un as Ro,g2 as Rr,G1 as Rt,WG as S,S8 as Sa,I4 as Si,L0 as Sn,j as So,Z2 as Sr,A0 as St,f0 as T,mK as Ta,X3 as Ti,U0 as Tn,Pc as To,F2 as Tr,YG as Tt,b4 as U,pl as Ua,M3 as Ui,o4 as Un,zt as Uo,D2 as Ur,x0 as Ut,_4 as V,Kc as Va,DG as Vi,o2 as Vn,gn as Vo,x2 as Vr,s2 as Vt,v4 as W,lu as Wa,Lq as Wi,tJ as Wn,Dt as Wo,C2 as Wr,Y3 as Wt,f4 as X,zl as Xa,FG as Xi,Iq as Xn,p0 as Xr,o0 as Xt,p4 as Y,Ml as Ya,j4 as Yi,Pq as Yn,h0 as Yr,a0 as Yt,u4 as Z,Tl as Za,Z3 as Zi,Qq as Zn,B0 as Zr,lJ as Zt,e5 as _,pq as _a,GZ as _i,P0 as _n,jc as _o,Q2 as _r,Z1 as _t,H8 as a,X4 as aa,W4 as ai,eK as an,El as ao,J2 as ar,Yq as at,n5 as b,J4 as ba,N3 as bi,oJ as bn,I as bo,f2 as br,k1 as bt,C8 as c,Y4 as ca,u8 as ci,v0 as cn,Al as co,V2 as cr,E1 as ct,G8 as d,V6 as da,t8 as di,J1 as dn,uc as do,L2 as dr,E0 as dt,p2 as ea,cJ as ei,$1 as en,Jl as eo,q2 as er,CG as et,t5 as f,o8 as fa,AJ as fi,E3 as fn,F as fo,t4 as fr,D0 as ft,Y8 as g,R3 as ga,Z6 as gi,mG as gn,M as go,d2 as gr,UG as gt,$8 as h,M4 as ha,b8 as hi,qG as hn,N as ho,B6 as hr,B3 as ht,X8 as i,X$ as ia,E4 as ii,EG as in,ml as io,P2 as ir,bG as it,b1 as j,uu as ja,V$ as ji,u2 as jn,Go as jo,Q0 as jr,y2 as jt,S1 as k,sp as ka,G3 as ki,F6 as kn,Ks as ko,e2 as kr,_2 as kt,w8 as l,Z$ as la,d8 as li,_0 as ln,jl as lo,H2 as lr,O0 as lt,q8 as m,E6 as ma,j2 as mi,rK as mn,Ws as mo,O2 as mr,iK as mt,A8 as n,pK as na,K1 as ni,wG as nn,Dl as no,W2 as nr,yG as nt,Z8 as o,kG as oa,aJ as oi,v$ as on,Bl as oo,l4 as or,Zq as ot,K8 as p,jG as pa,Y6 as pi,tK as pn,Hs as po,n4 as pr,ZG as pt,d4 as q,Yc as qa,w3 as qi,Mq as qn,ht as qo,g0 as qr,s0 as qt,j8 as r,nK as ra,D4 as ri,TG as rn,tu as ro,G2 as rr,xG as rt,O8 as s,z4 as sa,Gq as si,b0 as sn,Ll as so,Y2 as sr,T1 as st,M8 as t,J6 as ta,sJ as ti,t0 as tn,fl as to,K2 as tr,SG as tt,N8 as u,f8 as ua,gG as ui,QG as un,Ls as uo,I2 as ur,k0 as ut,W8 as v,hq as va,s6 as vi,M0 as vn,tc as vo,$2 as vr,R0 as vt,d0 as w,N$ as wa,z3 as wi,H0 as wn,dc as wo,z2 as wr,GG as wt,e8 as x,fK as xa,T3 as xi,I0 as xn,Zs as xo,X2 as xr,O1 as xt,Q8 as y,IG as ya,a6 as yi,nJ as yn,rc as yo,e4 as yr,z0 as yt,i3 as z,xl as za,vq as zi,n2 as zn,fn as zo,m2 as zr,Y1 as zt};
|
|
460
|
-
//# sourceMappingURL=server-lock-iLcBw_q0-
|
|
455
|
+
`)&&n.push(`trailing-newline`),n}const D3=`parse-equivalence`;function O3(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function k3(e){return e.replace(/[ \t]+$/gm,``)}const A3=/^([ \t]*)\d+([.)])(?=[ \t])/;function j3(e){return e.split(`
|
|
456
|
+
`).map(e=>e.replace(A3,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const M3=new Set;function N3(e,t,n){let r=fK(e),i=fK(t);if(r.frontmatter!==i.frontmatter)return!1;if(r.body===i.body)return!0;let a;try{a=n(r.body)}catch(e){let t=e instanceof Error?e.message:String(e);return M3.size<8&&!M3.has(t)&&(M3.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return O3(k3(a))===O3(k3(i.body))?fJ(j3(r.body),j3(a)):!1}const P3={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},F3={"emphasis-around-code":`pm-model-caused`,bom:`parser-caused`,crlf:`parser-caused`,"commonmark-escape":`parser-caused`,"leading-newline":`parser-caused`,"paragraph-continuation-indent":`parser-caused`,"doc-start-thematic":`parser-caused`,"block-separator-collapse":`serializer-caused`,"table-align-row-spacing":`serializer-caused`,"row-no-trailing-pipe":`serializer-caused`,"ordered-list-marker-number":`serializer-caused`,"list-indent-canonical":`serializer-caused`,"jsx-container-boundary-blank":`serializer-caused`,"trailing-whitespace":`serializer-caused`,"blank-line-collapse":`serializer-caused`,"trailing-newline":`serializer-caused`,"parse-equivalence":`parser-caused`};function I3(e){return F3[e]}function L3(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return e.length===t.length?-1:n}let R3=null;function z3(e){R3=e}function B3(e,t,n,r){if(!R3||e.length===0)return;let i=L3(t,n),a=new Date().toISOString();for(let t of e)R3({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:I3(t)})}const V3=1e4,H3=`last-spawn-error.log`,U3=/^[a-zA-Z0-9][\w/-]*$/;function W3(e){return e.startsWith(`#`)?e.slice(1):e}function G3(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function K3(e){if(!e||e.trim()===``)return[];let{map:t}=M4(e);if(!t)return[];let n=G3(t.tags),r=[];for(let e of n){let t=W3(e);U3.test(t)&&r.push(t)}return r}const q3=[`.ok`,`local`,`installed-skills.json`],J3=F(EG),Y3=Zs({hosts:N(A()),scope:J3,scripts:M(),installedAt:Go()}),X3=Zs({schema:I(1),skills:ac(A(),Y3).default({})});function Z3(){return{schema:1,skills:{}}}function Q3(e){let t;try{t=JSON.parse(e)}catch{return null}let n=X3.safeParse(t);return n.success?n.data:null}const $3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},e6=new WeakMap;function t6(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function n6(e){return e.trim().toLowerCase()}const r6=/\.(?:md|mdx)$/;function i6(e,t){if(t!==`page`)return e;let n=e.replace(r6,``);return n.length>0?n:e}function a6(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function o6(e){let t=a6(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function s6(e){let t=CW({schema:$3});return e.length>0&&PW(t,e),t}function c6(e){let t={documents:e};return e6.set(t,s6(e)),t}function l6(e){let t=e6.get(e);if(t)return t;let n=s6(e.documents);return e6.set(e,n),n}function u6(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function d6(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function f6(e,t){let n=n6(t);if(!n)return 0;let r=i6(n,e.kind),i=n6(e.title),a=n6(e.name),o=n6(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function p6(e,t){let n=f6(e,t);return n<=0?n:vq(e.path)?n*.5:n}function m6(e){return e===`file`?-60:0}function h6(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function g6(e,t,n,r){return e+t*20+n+m6(r)}function _6(e,t,n,r,i,a){return e===`relevance`?g6(t,n,r,i):h6(t,n,r,i,a)}function v6(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function y6(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function b6(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function x6(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function S6(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function C6(e,t){return n6(t).length<4?0:e===`full_text`?1:0}function w6(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function T6(e){let t=[],n=[],r=[];for(let i of e){let e=w6(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function E6(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=T6(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function D6(e,t,n={}){let r=n.intent??`omnibar`,i=v6(r,n.ranking),a=t6(n.limit),o=new Set(n.scopes??u6(r)),s=e.documents.filter(e=>d6(e,o)),c=n6(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=uG(l6(e),{term:c,properties:x6(r),boost:S6(r),tolerance:C6(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>d6(e.document,o)).map(e=>[e.document.id,e.score])),d=b6(s),f=new Map;for(let e of s)p6(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)d6(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=y6(f.values(),u);return E6([...f.values()].map(t=>{let n=Math.max(0,p6(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:_6(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return E6(k6({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function O6(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function k6(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=y6(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,p6(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?_6(o,t,n,s,e.kind,m):g6(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=O6(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=O6(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function A6(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),j6(n)}function j6(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const M6=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),N6=globalThis;N6[M6]===void 0&&(N6[M6]=Ri());const P6=N6[M6],F6=[`.ok`,`skill-state.yml`],I6=[`claude-cowork`,`cli-hosts`],L6=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],R6=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,z6=Zs({version:A().regex(R6,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(P6,{description:`Recorded skill version for this target.`}),recordedAt:Go().register(P6,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:F(L6).register(P6,{description:`Install-source surface that recorded this entry.`}).optional()}),B6=Zs({enabled:M().register(P6,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:Go().register(P6,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),V6=Zs({schema:I(1).register(P6,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Zs({"claude-cowork":z6.optional(),"cli-hosts":z6.optional()}).register(P6,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:ac(A(),B6).register(P6,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function H6(e,t){return e??t.installedOnDisk}function U6(){return{schema:1,targets:{}}}const W6=`template`;function G6(e){if(e.trim()===``)return{};let t;try{t=(0,Fc.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function K6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function q6(e){let{frontmatter:t,body:n}=fK(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:mK(t),markdown:n}}function J6(e){let t=e.split(`
|
|
457
|
+
`);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=G6(n.join(`
|
|
458
|
+
`))[W6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
|
|
459
|
+
`).replace(/\n+$/,``)}}function Y6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=fK(t);if(n===``)return{identity:{},starterContent:t};let i=mK(n),a=J6(i);if(a)return{identity:a.identity,starterContent:K6(a.docFrontmatterText,r)};let{frontmatter:o}=fK(r);if(o!==``)return{identity:G6(i),starterContent:r};let s=G6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:K6(i,r)}}function X6(e,t){let{docFrontmatterText:n,markdown:r}=q6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Fc.stringify)({[W6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function Z6(e){return Y6(e).starterContent}function Q6(){let e=!1,t=``,n=0;return r=>{let i=$6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function $6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const e8=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],t8={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function n8(e,t=e8){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const r8={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function i8(e){return e?r8[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const a8={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function o8(e){let t=e?.trim();return t?a8[i8(t)]??t:`Agent`}function s8(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const c8=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function l8(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function u8(e){let t=e.trim();return c8.test(t)||t.startsWith(`//`)}function d8(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(u8(n))return{kind:`external`,url:n};let r=s8(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=l8(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function f8(e,t){let n=e.trim();if(!n)return null;if(u8(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=l8(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function p8(e,t){let n=e.trim();if(!n||c8.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function m8(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function h8(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function g8(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function _8(e){return e.split(`/`).filter(e=>e!==``)}function v8(e,t){let n=g8(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function y8(e,t){let n=g8(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:_8(r).length}function b8(e,t){let n=_8(e),r=_8(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function x8(){let e=new Map;function t(t){let n=m8(t);if(n===``)return;let r=h8(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=m8(t),r=h8(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=g8(m8(n)),o=[],s=[];for(let e of i)v8(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=y8(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=y8(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=b8(a,g8(t));for(let r=1;r<e.length;r++){let i=e[r],o=b8(a,g8(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function S8(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function C8(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function w8(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function T8(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}const E8=/^[A-Za-z0-9-]{8,64}$/;let D8=null;function O8(e){return l(e??m(),`.ok`,`machine-id`)}function k8(e){if(e===void 0&&D8!==null)return D8;let t=O8(e),n=null;try{let e=b(t,`utf-8`).trim();E8.test(e)&&(n=e)}catch{}if(n===null){n=w();try{v(c(t),{recursive:!0}),S(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){console.warn(`[machine-id] Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(D8=n),n}function A8(){try{let e=u(c(f(import.meta.url)),`..`,`package.json`),t=JSON.parse(b(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const j8=A8(),M8=1;var N8=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function P8(e,t){return u(e,`${t}.lock`)}const F8=new Map;function I8(e){F8.set(e,(F8.get(e)??0)+1)}function L8(e){let t=F8.get(e);return t===void 0||t<=1?(F8.delete(e),!0):(F8.set(e,t-1),!1)}function R8(e){return typeof e.machineId==`string`?e.machineId===k8():e.hostname===h()}const z8=new Set;let B8=!1;function V8(e){z8.add(e),!B8&&(B8=!0,process.on(`exit`,()=>{for(let e of z8)try{let t=JSON.parse(b(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==k8()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==h())continue;x(e)}catch{}}))}function H8(e,t){try{let n=JSON.parse(b(e,`utf-8`));return n&&typeof n==`object`&&T8(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function U8(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;v(n,{recursive:!0});let a=P8(n,t),o={pid:process.pid,hostname:h(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:k8(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??j8},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!_(a))try{let e=y(a,`wx`,384);try{C(e,s)}finally{g(e)}return I8(a),V8(a),W8({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=H8(a,i);if(e){if(R8(e)&&e.pid===process.pid)return S(a,s,{encoding:`utf-8`,mode:384}),I8(a),V8(a),W8({lockName:t,lockDir:n,lockPath:a});if(w8(e.pid))throw new N8(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{x(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function W8(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>X8({lockName:t,lockDir:n}),updatePort:e=>G8({lockName:t,lockDir:n,port:e})}}function G8(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=P8(n,t);if(!_(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||!T8(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&R8(o)){o.port=r;try{S(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function K8(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=P8(n,t);if((F8.get(i)??0)>1)return;let a;try{let e=JSON.parse(b(i,`utf-8`));if(!e||typeof e!=`object`||!T8(e.pid)){console.warn(`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){e.code!==`ENOENT`&&console.warn(`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&R8(a)&&a.draining!==!0){a.draining=!0;try{S(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function q8(e){let{lockName:t,lockDir:n}=e,r=P8(n,t);if(!_(r))return null;let i;try{let e=JSON.parse(b(r,`utf-8`));if(!e||typeof e!=`object`||!T8(e.pid))return null;i=e}catch{return null}if(!R8(i))return null;if(!w8(i.pid)){try{x(r)}catch{}return null}return i}function J8(e){let{lockName:t,lockDir:n}=e,r=P8(n,t);if(!_(r))return{status:`absent`};let i;try{i=JSON.parse(b(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!T8(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!R8(o))return{status:`stale`,lock:o};if(!w8(o.pid)){try{x(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}async function Y8(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>q8({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function X8(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=P8(n,t);if(L8(a)){if(r){K8({lockName:t,lockDir:n});return}if(_(a))try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!R8(e))return;x(a),z8.delete(a)}catch(e){console.warn(`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var Z8=class extends N8{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Q8(e,t){try{return U8({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof N8&&e.lockName===`server`?new Z8(e.existing,e.lockPath):e}}function $8(e,t){G8({lockName:`server`,lockDir:e,port:t})}function e5(e){return q8({lockName:`server`,lockDir:e})}function t5(e,t){X8({lockName:`server`,lockDir:e,...t})}function n5(e){K8({lockName:`server`,lockDir:e})}function r5(e,t){return Y8({lockName:`server`,lockDir:e,...t})}export{hG as $,Zl as $a,NG as $i,V2 as $n,XG as $r,i0 as $t,s1 as A,L as Aa,v$ as Ai,R6 as An,xs as Ao,Q0 as Ar,y2 as At,v1 as B,bl as Ba,Kq as Bi,i2 as Bn,mn as Bo,E2 as Br,q3 as Bt,g1 as C,K4 as Ca,o8 as Ci,J1 as Cn,P as Co,z2 as Cr,M0 as Ct,S1 as D,I4 as Da,A6 as Di,A2 as Dn,A as Do,uJ as Dr,V1 as Dt,c1 as E,gq as Ea,U6 as Ei,OG as En,ac as Eo,C0 as Er,KG as Et,N1 as F,Zc as Fa,i8 as Fi,H1 as Fn,qa as Fo,Z0 as Fr,n1 as Ft,b4 as G,cu as Ga,BG as Gi,wq as Gn,k as Go,T2 as Gr,HG as Gt,S4 as H,Xc as Ha,$G as Hi,n2 as Hn,cn as Ho,D2 as Hr,u2 as Ht,M1 as I,Cl as Ia,Z6 as Ii,U1 as In,si as Io,W6 as Ir,JG as It,h4 as J,Jc as Ja,e3 as Ji,jq as Jn,mt as Jo,h0 as Jr,r0 as Jt,_4 as K,ru as Ka,n3 as Ki,Dq as Kn,O as Ko,C2 as Kr,R1 as Kt,Jq as L,wl as La,zq as Li,i4 as Ln,br as Lo,N2 as Lr,G1 as Lt,o1 as M,qc as Ma,I$ as Mi,H3 as Mn,Uo as Mo,e2 as Mr,F1 as Mt,b1 as N,su as Na,LY as Ni,VG as Nn,ma as No,Y0 as Nr,w1 as Nt,l1 as O,_b as Oa,S8 as Oi,F6 as On,$s as Oo,$1 as Or,E0 as Ot,rJ as P,Ol as Pa,lq as Pi,_G as Pn,Ka as Po,X0 as Pr,T1 as Pt,vG as Q,ou as Qa,RG as Qi,$q as Qn,H0 as Qr,a0 as Qt,q4 as R,Sl as Ra,a1 as Ri,c4 as Rn,un as Ro,_2 as Rr,K1 as Rt,WG as S,C8 as Sa,L4 as Si,R0 as Sn,j as So,Q2 as Sr,j0 as St,p0 as T,mK as Ta,Z3 as Ti,W0 as Tn,Pc as To,I2 as Tr,YG as Tt,x4 as U,pl as Ua,N3 as Ui,s4 as Un,zt as Uo,O2 as Ur,S0 as Ut,v4 as V,Kc as Va,DG as Vi,s2 as Vn,gn as Vo,S2 as Vr,c2 as Vt,y4 as W,lu as Wa,Lq as Wi,tJ as Wn,Dt as Wo,w2 as Wr,X3 as Wt,p4 as X,zl as Xa,FG as Xi,Iq as Xn,m0 as Xr,s0 as Xt,m4 as Y,Ml as Ya,M4 as Yi,Pq as Yn,g0 as Yr,o0 as Yt,d4 as Z,Tl as Za,Q3 as Zi,Qq as Zn,V0 as Zr,lJ as Zt,t5 as _,pq as _a,GZ as _i,F0 as _n,jc as _o,$2 as _r,Q1 as _t,U8 as a,Z4 as aa,G4 as ai,eK as an,El as ao,Y2 as ar,Yq as at,r5 as b,Y4 as ba,P3 as bi,oJ as bn,I as bo,p2 as br,A1 as bt,w8 as c,X4 as ca,d8 as ci,y0 as cn,Al as co,H2 as cr,D1 as ct,K8 as d,H6 as da,n8 as di,Y1 as dn,uc as do,R2 as dr,D0 as dt,m2 as ea,cJ as ei,e0 as en,Jl as eo,J2 as er,CG as et,n5 as f,s8 as fa,AJ as fi,D3 as fn,F as fo,n4 as fr,O0 as ft,X8 as g,z3 as ga,Q6 as gi,mG as gn,M as go,f2 as gr,UG as gt,e5 as h,N4 as ha,x8 as hi,qG as hn,N as ho,V6 as hr,V3 as ht,Z8 as i,Z$ as ia,D4 as ii,EG as in,ml as io,F2 as ir,bG as it,x1 as j,uu as ja,H$ as ji,d2 as jn,Go as jo,$0 as jr,b2 as jt,C1 as k,sp as ka,K3 as ki,I6 as kn,Ks as ko,t2 as kr,v2 as kt,T8 as l,Q$ as la,f8 as li,v0 as ln,jl as lo,U2 as lr,k0 as lt,J8 as m,D6 as ma,M2 as mi,rK as mn,Ws as mo,k2 as mr,iK as mt,j8 as n,pK as na,q1 as ni,wG as nn,Dl as no,G2 as nr,yG as nt,Q8 as o,kG as oa,aJ as oi,y$ as on,Bl as oo,u4 as or,Zq as ot,q8 as p,jG as pa,X6 as pi,tK as pn,Hs as po,r4 as pr,ZG as pt,f4 as q,Yc as qa,T3 as qi,Mq as qn,ht as qo,_0 as qr,c0 as qt,M8 as r,nK as ra,O4 as ri,TG as rn,tu as ro,K2 as rr,xG as rt,k8 as s,B4 as sa,Gq as si,x0 as sn,Ll as so,X2 as sr,E1 as st,N8 as t,Y6 as ta,sJ as ti,n0 as tn,fl as to,q2 as tr,SG as tt,P8 as u,p8 as ua,gG as ui,QG as un,Ls as uo,L2 as ur,A0 as ut,G8 as v,hq as va,c6 as vi,N0 as vn,tc as vo,e4 as vr,z0 as vt,f0 as w,P$ as wa,B3 as wi,U0 as wn,dc as wo,B2 as wr,GG as wt,t8 as x,fK as xa,E3 as xi,L0 as xn,Zs as xo,Z2 as xr,k1 as xt,$8 as y,IG as ya,o6 as yi,nJ as yn,rc as yo,t4 as yr,B0 as yt,a3 as z,xl as za,vq as zi,r2 as zn,fn as zo,h2 as zr,X1 as zt};
|
|
460
|
+
//# sourceMappingURL=server-lock-iLcBw_q0-CMNgPc8K.mjs.map
|