@inkeep/open-knowledge 0.41.2 → 0.41.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/{acp-harness-probe-Ba7DTFOh.mjs → acp-harness-probe-BOwFyTWe.mjs} +2 -2
  2. package/dist/assets/skills/discovery/SKILL.md +1 -1
  3. package/dist/assets/skills/project/SKILL.md +1 -1
  4. package/dist/cli.mjs +45 -45
  5. package/dist/constants-BVSTPfUv.mjs +2 -0
  6. package/dist/{git-handle-ZhJgz79A.mjs → git-handle-C0Vkx9lA.mjs} +2 -2
  7. package/dist/git-handle-z2kbZHY3.mjs +1 -0
  8. package/dist/index.mjs +1 -1
  9. package/dist/{init-CBWhyX1U.mjs → init-D6sC54Pr.mjs} +4 -4
  10. package/dist/init-DBeufZJj.mjs +1 -0
  11. package/dist/{launch-json-removal-0rPdkMtH.mjs → launch-json-removal-IpmYWqR_.mjs} +2 -2
  12. package/dist/{loader-C0DzGeNZ.mjs → loader-5nE64IiE.mjs} +2 -2
  13. package/dist/loader-rVkazX7x.mjs +1 -0
  14. package/dist/md-manager-B4y6B-tT.mjs +2 -0
  15. package/dist/{open-browser-BvP05JKj.mjs → open-browser-B4QMCuDE.mjs} +2 -2
  16. package/dist/parse-worker.mjs +1 -1
  17. package/dist/{preview-Dn1YxNMX.mjs → preview-cTIYUtdg.mjs} +2 -2
  18. package/dist/preview-lbNLNqVo.mjs +1 -0
  19. package/dist/public/assets/{ActivityModeContent-BPE8dCmt.js → ActivityModeContent-V56HhfHm.js} +1 -1
  20. package/dist/public/assets/{AgentDiffPane-DBIJrjq2.js → AgentDiffPane-DnNDgiq4.js} +1 -1
  21. package/dist/public/assets/{AgentThreadClientBinder-DIlw7iBC.js → AgentThreadClientBinder-Dg8x_dvd.js} +1 -1
  22. package/dist/public/assets/{CodeMirrorPropInput-RC4sdh9E.js → CodeMirrorPropInput-CiPNj8ti.js} +1 -1
  23. package/dist/public/assets/{DocumentContext-DhKWMrL2.js → DocumentContext-BKR16aYr.js} +2 -2
  24. package/dist/public/assets/{EditorModeToggle-EBc2Cv8z.js → EditorModeToggle-D8dxPhYZ.js} +1 -1
  25. package/dist/public/assets/{EnableSyncConfirmDialog-Dv9jJ1OH.js → EnableSyncConfirmDialog-BzDGK1B9.js} +1 -1
  26. package/dist/public/assets/FeedbackForm-B-fO65RC.js +1 -0
  27. package/dist/public/assets/{GraphPanel-DBxTtvfS.js → GraphPanel-BB3PZd_i.js} +1 -1
  28. package/dist/public/assets/{LintConfigEditor-COmMwK8k.js → LintConfigEditor-DtvxnniJ.js} +1 -1
  29. package/dist/public/assets/{ManagedArtifactProperties-urT0cuW8.js → ManagedArtifactProperties-DYQ1JUmF.js} +1 -1
  30. package/dist/public/assets/{McpConsentDialogBody-QnsIyr5m.js → McpConsentDialogBody-DscJLJPg.js} +1 -1
  31. package/dist/public/assets/{MermaidDocEditor-CNmMqMG0.js → MermaidDocEditor-wUCR0srX.js} +1 -1
  32. package/dist/public/assets/{PropertyPanel-mY4SzTn-.js → PropertyPanel-CckAc_Sq.js} +1 -1
  33. package/dist/public/assets/{ReportBugDialogBody-D6DyX_AO.js → ReportBugDialogBody-BMejD0M2.js} +1 -1
  34. package/dist/public/assets/{SchemaConfigEditor-DOlc8PRA.js → SchemaConfigEditor-nuU-YHpP.js} +1 -1
  35. package/dist/public/assets/{SettingsDialogBody-DT5rxl3R.js → SettingsDialogBody-DNdlho-U.js} +1 -1
  36. package/dist/public/assets/{ShareBranchSwitchDialog-DOd9FqHR.js → ShareBranchSwitchDialog-BzvjNuw_.js} +1 -1
  37. package/dist/public/assets/{ShareReceiveDialog-WarQNnjb.js → ShareReceiveDialog-CznGTWez.js} +1 -1
  38. package/dist/public/assets/{ShareReceiveMissDialog-B4qzjtcO.js → ShareReceiveMissDialog-BKcrHSOs.js} +1 -1
  39. package/dist/public/assets/{SkillEditorActions-BgCcV1OO.js → SkillEditorActions-C7jWaMNZ.js} +1 -1
  40. package/dist/public/assets/{SourceEditor-iS9U8XVV.js → SourceEditor-DVqYQflP.js} +1 -1
  41. package/dist/public/assets/{TerminalPanel-DCL0YXc0.js → TerminalPanel-CDDchf68.js} +1 -1
  42. package/dist/public/assets/{TerminalSessionsHost-CjgiUwL3.js → TerminalSessionsHost-DEXiA3WZ.js} +2 -2
  43. package/dist/public/assets/{TerminalWindowApp-BZhG11Jf.js → TerminalWindowApp-CSzPSa7h.js} +1 -1
  44. package/dist/public/assets/{ThreadView-BExAZkQQ.js → ThreadView-CoHq4aL7.js} +1 -1
  45. package/dist/public/assets/{TimelineDiffPane-BBVTd7ZF.js → TimelineDiffPane-BTaUZ3Kb.js} +1 -1
  46. package/dist/public/assets/{agent-diff-store-C_yI-auj.js → agent-diff-store-CE54PhoR.js} +1 -1
  47. package/dist/public/assets/{agent-visibility-BKKH1E-K.js → agent-visibility-BsnQwNdc.js} +1 -1
  48. package/dist/public/assets/{auth-state-cache-BYWBVAT1.js → auth-state-cache-nPfU5e_O.js} +7 -7
  49. package/dist/public/assets/{client-version-D0idjqLu.js → client-version-C9dKI6XY.js} +1 -1
  50. package/dist/public/assets/{config-provider-DDGPIoo7.js → config-provider-DNKyP_6q.js} +1 -1
  51. package/dist/public/assets/{dist-DgX6o3Xd.js → dist-BGfU2QP2.js} +1 -1
  52. package/dist/public/assets/{doc-hash-CzmSG2uM.js → doc-hash-BSk1YYn9.js} +1 -1
  53. package/dist/public/assets/{documents-events-0MJ8ER3I.js → documents-events-BtgGTIqA.js} +1 -1
  54. package/dist/public/assets/{file-tree-adapter-DGXFJhkO.js → file-tree-adapter-C0J3tc2q.js} +1 -1
  55. package/dist/public/assets/{file-tree-utils-BvgxJuFW.js → file-tree-utils-DAVYMBYf.js} +1 -1
  56. package/dist/public/assets/{globals-CpkAXqfZ.js → globals-CnEbugkx.js} +1 -1
  57. package/dist/public/assets/{index-DDSda67s.js → index-CQ4DveM_.js} +7 -7
  58. package/dist/public/assets/{lint-config-client-DXbikwgI.js → lint-config-client-CNmTHHQl.js} +1 -1
  59. package/dist/public/assets/{markdownlint-rule-browser-DHpnQBnJ.js → markdownlint-rule-browser-IrQQnbe7.js} +1 -1
  60. package/dist/public/assets/{navigation-targets-Bo1TKplU.js → navigation-targets-CGUSVL6j.js} +1 -1
  61. package/dist/public/assets/{open-managed-artifact-tab-Dvme3cv4.js → open-managed-artifact-tab-CxOXkAIY.js} +1 -1
  62. package/dist/public/assets/{pending-receive-nav-store-CVH9OLs-.js → pending-receive-nav-store-D4kTIsaK.js} +1 -1
  63. package/dist/public/assets/{prop-types-BjU4ptk9.js → prop-types-Benz74B2.js} +1 -1
  64. package/dist/public/assets/{receive-store-DHX5arqk.js → receive-store-DbySZt8N.js} +1 -1
  65. package/dist/public/assets/{selection-context-Cp7p3Q_N.js → selection-context-DCJMxWzU.js} +1 -1
  66. package/dist/public/assets/{skill-actions-bZFiRAYm.js → skill-actions-S0UIcdB8.js} +1 -1
  67. package/dist/public/assets/{skills-api-DstI-vVv.js → skills-api-D8XA69bH.js} +1 -1
  68. package/dist/public/assets/{src-CAZXe_Ov.js → src-DrSxCOVW.js} +1 -1
  69. package/dist/public/assets/{tag-pill-input-C7Caa2Cw.js → tag-pill-input-CScqBN3p.js} +1 -1
  70. package/dist/public/assets/{target-navigation-intent-B54BgTCv.js → target-navigation-intent-mVGCycSm.js} +1 -1
  71. package/dist/public/assets/{terminal-launch-events-DG8hI3w-.js → terminal-launch-events-BMUxfSI9.js} +1 -1
  72. package/dist/public/assets/{terminal-telemetry-DSZCcYb_.js → terminal-telemetry-BbC-kUyB.js} +1 -1
  73. package/dist/public/assets/{typing-burst-detector-DfFn9ASH.js → typing-burst-detector-w83TGJFT.js} +1 -1
  74. package/dist/public/assets/{uninstall-C2rwdK6e.js → uninstall-B8_uL8NV.js} +1 -1
  75. package/dist/public/assets/{use-activity-panel-CHsvsZ8L.js → use-activity-panel-YhP8vGtR.js} +1 -1
  76. package/dist/public/assets/{use-apply-config-color-theme-Gy3JNvol.js → use-apply-config-color-theme-u-JcfGJu.js} +1 -1
  77. package/dist/public/assets/{use-collab-url-9qlw7MfN.js → use-collab-url-DRZdoC-F.js} +1 -1
  78. package/dist/public/assets/{use-live-xterm-theme-7CBgYc0a.js → use-live-xterm-theme-DcxHtUZd.js} +1 -1
  79. package/dist/public/assets/{use-settings-route-DEm8dDzV.js → use-settings-route-CcWyPW0f.js} +1 -1
  80. package/dist/public/assets/{use-terminal-enabled-Bx_nsTHh.js → use-terminal-enabled-DznqTIoa.js} +1 -1
  81. package/dist/public/assets/{use-timeline-entry-diff-Y2CdT0M4.js → use-timeline-entry-diff-CYoaYTqW.js} +1 -1
  82. package/dist/public/assets/{use-workspace-DnIHeQAh.js → use-workspace-RSGV5qeq.js} +1 -1
  83. package/dist/public/assets/{workspace-paths-CGx2PUFr.js → workspace-paths-CTLwXmK5.js} +1 -1
  84. package/dist/public/index.html +36 -36
  85. package/dist/public/uninstall.html +3 -3
  86. package/dist/{repair-launch-json-BVxKvPAo.mjs → repair-launch-json-DcHGX6hC.mjs} +2 -2
  87. package/dist/{repair-mcp-configs-CL00iu8h.mjs → repair-mcp-configs-CPUx3Y1R.mjs} +2 -2
  88. package/dist/repair-skills-BNFFh5kk.mjs +1 -0
  89. package/dist/{repair-skills-xgU4BBSK.mjs → repair-skills-XXmzc0-v.mjs} +2 -2
  90. package/dist/{server-lock-D7lpEbZj.mjs → server-lock-NDXM24F6.mjs} +2 -2
  91. package/dist/server-lock-l_qcQskg.mjs +1 -0
  92. package/dist/{src-3SN72BHH.mjs → src-BTs5LPkM.mjs} +20 -20
  93. package/dist/src-BbntdRLo.mjs +3265 -0
  94. package/dist/src-CdRO3m1f.mjs +1 -0
  95. package/dist/{src-CxD3JHmH.mjs → src-CriPjh3C.mjs} +6 -6
  96. package/dist/{start-5e_XN39i.mjs → start-Bo1-QvAn.mjs} +2 -2
  97. package/dist/start-C0xMv3I3.mjs +1 -0
  98. package/dist/{write-project-skill-4OvW1cn1.mjs → write-project-skill-C-xPIQus.mjs} +3 -3
  99. package/package.json +4 -4
  100. package/dist/constants-Ej-ZzjYT.mjs +0 -2
  101. package/dist/git-handle-Cg7vsIVu.mjs +0 -1
  102. package/dist/init-BHsIRFIC.mjs +0 -1
  103. package/dist/loader-CjpqkbhW.mjs +0 -1
  104. package/dist/md-manager-BOzKVLRL.mjs +0 -2
  105. package/dist/preview-DSJriqm9.mjs +0 -1
  106. package/dist/public/assets/FeedbackForm-Bb9Yf3Zz.js +0 -1
  107. package/dist/repair-skills-DnayrFzZ.mjs +0 -1
  108. package/dist/server-lock-CIl-U-as.mjs +0 -1
  109. package/dist/src-Cf8OhPA7.mjs +0 -1
  110. package/dist/src-DAzaO37g.mjs +0 -3265
  111. package/dist/start-DULQ0fI2.mjs +0 -1
@@ -277,45 +277,45 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content:
277
277
  `){let{editColumn:r,deleteCount:i,insertText:a}=QG(t),o=r-1;return i===-1?null:e.slice(0,o)+a.replace(/\n/g,n)+e.slice(o+i)}function eK(e,t){let n=Z.getPreferredLineEnding(e,pH),r=e.split(Z.newLineRe),i=t.filter(e=>e.fixInfo).map(e=>QG(e.fixInfo,e.lineNumber));i.sort((e,t)=>{let n=e.deleteCount===-1,r=t.deleteCount===-1;return t.lineNumber-e.lineNumber||(n?1:r?-1:0)||t.editColumn-e.editColumn||t.insertText.length-e.insertText.length});let a={};i=i.filter(e=>{let t=e.lineNumber!==a.lineNumber||e.editColumn!==a.editColumn||e.deleteCount!==a.deleteCount||e.insertText!==a.insertText;return a=e,t}),a={lineNumber:-1};for(let e of i)e.lineNumber===a.lineNumber&&e.editColumn===a.editColumn&&!e.insertText&&e.deleteCount>0&&a.insertText&&!a.deleteCount&&(e.insertText=a.insertText,a.lineNumber=0),a=e;i=i.filter(e=>e.lineNumber);let o=-1,s=-1;for(let e of i){let{lineNumber:t,editColumn:i,deleteCount:a}=e,c=t-1,l=i-1;(c!==o||a===-1||l+a<=s-(a>0?0:1))&&(r[c]=$G(r[c],e,n)),o=c,s=l}return r.filter(e=>e!==null).join(n)}function tK(e,t){return eK(e,ZG({strings:{doc:e},config:t}).doc??[])}function nK(e,t){let n=ZG({strings:{doc:e},config:t}).doc??[],r=e.split(`
278
278
  `),i=rK(t);return n.map(e=>aK(e,r,iK(e,i)))}function rK(e){let t=new Map;return Object.entries(e).forEach(([e,n],r)=>{let i=e.toUpperCase();if(i===`DEFAULT`)return;let a=null;if(n===`error`||n===`warning`)a=n;else if(typeof n==`object`&&n&&!Array.isArray(n)){let e=n.severity;(e===`error`||e===`warning`)&&(a=e)}a!==null&&t.set(i,{entryIndex:r,severity:a})}),t}function iK(e,t){let n;for(let r of e.ruleNames){let e=t.get(r.toUpperCase());e!==void 0&&(n===void 0||e.entryIndex>n.entryIndex)&&(n=e)}return n?.severity??`warning`}function aK(e,t,n){let[r,i]=e.errorRange??[1,null],a=e.lineNumber-1,o=(r??1)-1,s=t[a]?.length??0,c=i==null?s:Math.min(o+i,s),l=e.fixInfo?[oK(e.fixInfo,e.lineNumber,t)]:void 0;return{range:{start:{line:a,character:o},end:{line:a,character:Math.max(c,o)}},severity:n,source:`markdownlint`,code:e.ruleNames[0]??`MD000`,message:e.errorDetail?`${e.ruleDescription}: ${e.errorDetail}`:e.ruleDescription,...l?{fixes:l}:{}}}function oK(e,t,n){let r=e.lineNumber??t,i=r-1;if(e.deleteCount===-1){if(r<n.length)return{range:{start:{line:i,character:0},end:{line:i+1,character:0}},newText:``};if(i>0){let e=n[i-1]?.length??0;return{range:{start:{line:i-1,character:e},end:{line:i,character:n[i]?.length??0}},newText:``}}return{range:{start:{line:0,character:0},end:{line:0,character:n[0]?.length??0}},newText:``}}let a=(e.editColumn??1)-1;return{range:{start:{line:i,character:a},end:{line:i,character:a+Math.max(0,e.deleteCount??0)}},newText:e.insertText??``}}const sK=y([E(),d(l),T(b(),h())]),cK={id:`markdownlint`,sliceSchema:v({enabled:E(),rules:T(b(),sK)}),defaultSlice:{enabled:!1,rules:SB},async lint(e,t){return nK(e,CB(t.rules))},fix(e,t){return tK(e,CB(t.rules))}},lK=v({appliesTo:y([b(),k(b())]).optional(),file:b(),enabled:E().optional(),key:b().optional(),schema:T(b(),h()).optional()}),uK=[cK,{id:`frontmatter`,sliceSchema:v({enabled:E(),schemas:k(lK)}),defaultSlice:{enabled:!1,schemas:[]},async lint(e,t,n){return dH(e,$V(t.schemas,n.docName))}}],dK={enabled:!0,plugins:Object.fromEntries(uK.map(e=>[e.id,e.defaultSlice]))};function fK(e){return{enabled:e.enabled??!0,plugins:{markdownlint:{...e.markdownlint,rules:e.markdownlint.rules??SB},frontmatter:{enabled:e.frontmatter?.enabled??!1,schemas:e.frontmatter?.schemas??[]}}}}const pK=Object.fromEntries(uK.map(e=>[e.id,e.sliceSchema])),mK=v({effective:v({enabled:E(),plugins:v(pK)}),configFile:b().nullable().optional(),configProblems:k(b()).optional()}),hK=y([E(),T(b(),h())]),gK=v({ruleId:b().min(1).max(64).regex(/^[A-Za-z][A-Za-z0-9_-]*$/),value:y([hK,i()])}),_K=v({file:b().min(1).max(512),delete:_(!0).optional(),field:b().min(1).max(256).optional(),parentPath:k(y([b().min(1).max(256),v({items:_(!0)}).strict()])).max(8).optional(),removeField:_(!0).optional(),renameTo:b().min(1).max(256).optional(),constraint:v({type:d([`string`,`number`,`boolean`,`array`,`object`]).nullable().optional(),enum:k(y([b(),A(),E()])).nullable().optional(),itemsEnum:k(y([b(),A(),E()])).nullable().optional(),itemsType:d([`string`,`number`,`boolean`,`object`]).nullable().optional(),pattern:b().nullable().optional(),format:b().nullable().optional(),description:b().max(2048).nullable().optional(),required:E().optional()}).optional()}).refine(e=>e.delete===void 0||e.field===void 0&&e.constraint===void 0&&e.removeField===void 0&&e.renameTo===void 0,{message:`delete cannot be combined with a field edit`}).refine(e=>[e.constraint,e.removeField,e.renameTo].filter(e=>e!==void 0).length<=1,{message:`constraint, removeField, and renameTo are mutually exclusive`}).refine(e=>e.removeField===void 0&&e.renameTo===void 0||e.field!==void 0,{message:`removeField and renameTo require field`}).refine(e=>e.parentPath===void 0||e.field!==void 0,{message:`parentPath requires field`}).refine(e=>e.field===void 0?e.constraint===void 0:e.constraint!==void 0||e.removeField!==void 0||e.renameTo!==void 0,{message:`field requires constraint, removeField, or renameTo`}),vK=v({schemas:k(b()),truncated:E()}).strict(),yK=v({line:A(),character:A()}),bK=v({start:yK,end:yK}),xK=v({range:bK,severity:d([`error`,`warning`,`info`,`hint`]),source:b(),code:b(),message:b(),fixes:k(v({range:bK,newText:b()})).optional()}),SK=v({file:b(),diagnostics:k(xK),warnings:k(b()).optional()}),CK=v({files:k(SK),fileCount:A(),errorCount:A(),warningCount:A(),warnings:k(b())}),wK=xK.extend({linkTarget:b().optional()}),TK=v({files:k(v({file:b(),diagnostics:k(wK)})),fileCount:A(),errorCount:A(),warningCount:A(),warnings:k(b())}),EK=v({docName:$v,summary:ny,...ty}).loose(),DK=v({file:b(),fixedCount:A(),diagnostics:k(xK),errorCount:A(),warningCount:A(),warning:b().optional()});function OK(){return`${JSON.stringify({$schema:eH[0],type:`object`},null,2)}\n`}function kK(e){let t=e.trim().replace(/^\.\//,``);if(!t.startsWith(`.ok/schemas/`))return!1;let n=t.slice(12);return n.length>0&&!n.includes(`/`)&&!n.includes(`\\`)&&n!==`.`&&n!==`..`}function AK(e){let t=e.trim().toLowerCase().split(`/`).pop()??``;return t.endsWith(`.schema.json`)&&t.length>12?!0:kK(e)&&t.endsWith(`.json`)}var jK=class extends Error{};function MK(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function NK(e,t,n){let r=e;for(let e of t){if(typeof e!=`string`){let e=r.items;if(e===void 0){if(!n)throw new jK(`field path items does not exist`);let e={type:`object`};r.items=e,r=e;continue}if(!MK(e))throw new jK(`field path items is not an object sub-schema`);r=e;continue}let t=IK(r),i=t[e];if(i===void 0){if(!n)throw new jK(`field path ${JSON.stringify(e)} does not exist`);let i={type:`object`};r.properties={...t,[e]:i},r=i;continue}if(!MK(i))throw new jK(`field path ${JSON.stringify(e)} is not an object property`);r=i}return r}function PK(e,t,n,r=[]){let i;i=e.trim()===``?JSON.parse(OK()):FK(e);let a=NK(i,r,!0),o=IK(a),s={...MK(o[t])?o[t]:{}};for(let e of[`type`,`enum`,`pattern`,`format`,`description`]){if(!(e in n))continue;let t=n[e];t==null?delete s[e]:s[e]=t}if(`itemsEnum`in n||`itemsType`in n){if(s.items!==void 0&&!MK(s.items))throw new jK(`field path items is not an object sub-schema`);let e=MK(s.items)?{...s.items}:{};`itemsEnum`in n&&(n.itemsEnum===null||n.itemsEnum===void 0?delete e.enum:e.enum=n.itemsEnum),`itemsType`in n&&(n.itemsType===null||n.itemsType===void 0?delete e.type:e.type=n.itemsType),Object.keys(e).length>0?s.items=e:delete s.items}if(Object.keys(s).length>0)a.properties={...o,[t]:s};else if(t in o){let{[t]:e,...n}=o;Object.keys(n).length>0?a.properties=n:delete a.properties}if(n.required!==void 0){let e=LK(a),r=e.includes(t);n.required&&!r?a.required=[...e,t]:!n.required&&r&&RK(a,e.filter(e=>e!==t))}return`${JSON.stringify(i,null,2)}\n`}function FK(e){let t;try{t=JSON.parse(e)}catch(e){throw new jK(`schema is not valid JSON (${e instanceof Error?e.message:String(e)})`)}if(!MK(t))throw new jK(`schema is not a JSON object`);return t}function IK(e){return MK(e.properties)?e.properties:{}}function LK(e){return Array.isArray(e.required)?e.required.filter(e=>typeof e==`string`):[]}function RK(e,t){t.length>0?e.required=t:delete e.required}function zK(e,t,n=[]){let r=FK(e),i=NK(r,n,!1),a=IK(i);if(t in a){let{[t]:e,...n}=a;Object.keys(n).length>0?i.properties=n:delete i.properties}return RK(i,LK(i).filter(e=>e!==t)),`${JSON.stringify(r,null,2)}\n`}function BK(e,t,n,r=[]){let i=FK(e),a=NK(i,r,!1),o=IK(a);if(!(t in o))throw new jK(`field ${JSON.stringify(t)} does not exist`);if(n in o)throw new jK(`field ${JSON.stringify(n)} already exists`);let s={};for(let[e,r]of Object.entries(o))s[e===t?n:e]=r;return a.properties=s,RK(a,LK(a).map(e=>e===t?n:e)),`${JSON.stringify(i,null,2)}\n`}const VK=[{id:`MD001`,alias:`heading-increment`,aliases:[`heading-increment`],name:`Heading levels should only increment by one level at a time`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md001.md`,tags:[`headings`],options:[{key:`front_matter_title`,type:`string`,description:`RegExp for matching title in front matter`,default:`^\\s*title\\s*[:=]`}]},{id:`MD003`,alias:`heading-style`,aliases:[`heading-style`],name:`Heading style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md003.md`,tags:[`headings`],options:[{key:`style`,type:`enum`,description:`Heading style`,enum:[`consistent`,`atx`,`atx_closed`,`setext`,`setext_with_atx`,`setext_with_atx_closed`],default:`consistent`}]},{id:`MD004`,alias:`ul-style`,aliases:[`ul-style`],name:`Unordered list style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md004.md`,tags:[`bullet`,`ul`],options:[{key:`style`,type:`enum`,description:`List style`,enum:[`consistent`,`asterisk`,`plus`,`dash`,`sublist`],default:`consistent`}]},{id:`MD005`,alias:`list-indent`,aliases:[`list-indent`],name:`Inconsistent indentation for list items at the same level`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md005.md`,tags:[`bullet`,`ul`,`indentation`],options:[]},{id:`MD007`,alias:`ul-indent`,aliases:[`ul-indent`],name:`Unordered list indentation`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md007.md`,tags:[`bullet`,`ul`,`indentation`],options:[{key:`indent`,type:`integer`,description:`Spaces for indent`,default:2,minimum:1},{key:`start_indented`,type:`boolean`,description:`Whether to indent the first level of the list`,default:!1},{key:`start_indent`,type:`integer`,description:`Spaces for first level indent (when start_indented is set)`,default:2,minimum:1}]},{id:`MD009`,alias:`no-trailing-spaces`,aliases:[`no-trailing-spaces`],name:`Trailing spaces`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md009.md`,tags:[`whitespace`],options:[{key:`br_spaces`,type:`integer`,description:`Spaces for line break`,default:2,minimum:0},{key:`code_blocks`,type:`boolean`,description:`Include code blocks`,default:!1},{key:`list_item_empty_lines`,type:`boolean`,description:`Allow spaces for empty lines in list items`,default:!1},{key:`strict`,type:`boolean`,description:`Include unnecessary breaks`,default:!1}]},{id:`MD010`,alias:`no-hard-tabs`,aliases:[`no-hard-tabs`],name:`Hard tabs`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md010.md`,tags:[`whitespace`,`hard_tab`],options:[{key:`code_blocks`,type:`boolean`,description:`Include code blocks`,default:!0},{key:`ignore_code_languages`,type:`string-array`,description:`Fenced code languages to ignore`,default:[]},{key:`spaces_per_tab`,type:`integer`,description:`Number of spaces for each hard tab`,default:1,minimum:0}]},{id:`MD011`,alias:`no-reversed-links`,aliases:[`no-reversed-links`],name:`Reversed link syntax`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md011.md`,tags:[`links`],options:[]},{id:`MD012`,alias:`no-multiple-blanks`,aliases:[`no-multiple-blanks`],name:`Multiple consecutive blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md012.md`,tags:[`whitespace`,`blank_lines`],options:[{key:`maximum`,type:`integer`,description:`Consecutive blank lines`,default:1,minimum:1}]},{id:`MD013`,alias:`line-length`,aliases:[`line-length`],name:`Line length`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md013.md`,tags:[`line_length`],options:[{key:`line_length`,type:`integer`,description:`Number of characters`,default:80,minimum:1},{key:`heading_line_length`,type:`integer`,description:`Number of characters for headings`,default:80,minimum:1},{key:`code_block_line_length`,type:`integer`,description:`Number of characters for code blocks`,default:80,minimum:1},{key:`code_blocks`,type:`boolean`,description:`Include code blocks`,default:!0},{key:`tables`,type:`boolean`,description:`Include tables`,default:!0},{key:`headings`,type:`boolean`,description:`Include headings`,default:!0},{key:`strict`,type:`boolean`,description:`Strict length checking`,default:!1},{key:`stern`,type:`boolean`,description:`Stern length checking`,default:!1}]},{id:`MD014`,alias:`commands-show-output`,aliases:[`commands-show-output`],name:`Dollar signs used before commands without showing output`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md014.md`,tags:[`code`],options:[]},{id:`MD018`,alias:`no-missing-space-atx`,aliases:[`no-missing-space-atx`],name:`No space after hash on atx style heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md018.md`,tags:[`headings`,`atx`,`spaces`],options:[]},{id:`MD019`,alias:`no-multiple-space-atx`,aliases:[`no-multiple-space-atx`],name:`Multiple spaces after hash on atx style heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md019.md`,tags:[`headings`,`atx`,`spaces`],options:[]},{id:`MD020`,alias:`no-missing-space-closed-atx`,aliases:[`no-missing-space-closed-atx`],name:`No space inside hashes on closed atx style heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md020.md`,tags:[`headings`,`spaces`,`atx_closed`],options:[]},{id:`MD021`,alias:`no-multiple-space-closed-atx`,aliases:[`no-multiple-space-closed-atx`],name:`Multiple spaces inside hashes on closed atx style heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md021.md`,tags:[`headings`,`spaces`,`atx_closed`],options:[]},{id:`MD022`,alias:`blanks-around-headings`,aliases:[`blanks-around-headings`],name:`Headings should be surrounded by blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md022.md`,tags:[`headings`,`blank_lines`],options:[{key:`include_front_matter`,type:`boolean`,description:`Include front matter content`,default:!1},{key:`lines_above`,type:`unsupported`,description:`Blank lines above heading`,default:1},{key:`lines_below`,type:`unsupported`,description:`Blank lines below heading`,default:1}]},{id:`MD023`,alias:`heading-start-left`,aliases:[`heading-start-left`],name:`Headings must start at the beginning of the line`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md023.md`,tags:[`headings`,`spaces`],options:[]},{id:`MD024`,alias:`no-duplicate-heading`,aliases:[`no-duplicate-heading`],name:`Multiple headings with the same content`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md024.md`,tags:[`headings`],options:[{key:`siblings_only`,type:`boolean`,description:`Only check sibling headings`,default:!1}]},{id:`MD025`,alias:`single-title`,aliases:[`single-title`,`single-h1`],name:`Multiple top-level headings in the same document`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md025.md`,tags:[`headings`],options:[{key:`front_matter_title`,type:`string`,description:`RegExp for matching title in front matter`,default:`^\\s*title\\s*[:=]`},{key:`level`,type:`integer`,description:`Heading level`,default:1,minimum:1,maximum:6}]},{id:`MD026`,alias:`no-trailing-punctuation`,aliases:[`no-trailing-punctuation`],name:`Trailing punctuation in heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md026.md`,tags:[`headings`],options:[{key:`punctuation`,type:`string`,description:`Punctuation characters`,default:`.,;:!。,;:!`}]},{id:`MD027`,alias:`no-multiple-space-blockquote`,aliases:[`no-multiple-space-blockquote`],name:`Multiple spaces after blockquote symbol`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md027.md`,tags:[`indentation`,`whitespace`,`blockquote`],options:[{key:`list_items`,type:`boolean`,description:`Include list items`,default:!0}]},{id:`MD028`,alias:`no-blanks-blockquote`,aliases:[`no-blanks-blockquote`],name:`Blank line inside blockquote`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md028.md`,tags:[`whitespace`,`blockquote`],options:[]},{id:`MD029`,alias:`ol-prefix`,aliases:[`ol-prefix`],name:`Ordered list item prefix`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md029.md`,tags:[`ol`],options:[{key:`style`,type:`enum`,description:`List style`,enum:[`one`,`ordered`,`one_or_ordered`,`zero`],default:`one_or_ordered`}]},{id:`MD030`,alias:`list-marker-space`,aliases:[`list-marker-space`],name:`Spaces after list markers`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md030.md`,tags:[`ul`,`whitespace`,`ol`],options:[{key:`ul_single`,type:`integer`,description:`Spaces for single-line unordered list items`,default:1,minimum:1},{key:`ol_single`,type:`integer`,description:`Spaces for single-line ordered list items`,default:1,minimum:1},{key:`ul_multi`,type:`integer`,description:`Spaces for multi-line unordered list items`,default:1,minimum:1},{key:`ol_multi`,type:`integer`,description:`Spaces for multi-line ordered list items`,default:1,minimum:1}]},{id:`MD031`,alias:`blanks-around-fences`,aliases:[`blanks-around-fences`],name:`Fenced code blocks should be surrounded by blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md031.md`,tags:[`blank_lines`,`code`],options:[{key:`list_items`,type:`boolean`,description:`Include list items`,default:!0}]},{id:`MD032`,alias:`blanks-around-lists`,aliases:[`blanks-around-lists`],name:`Lists should be surrounded by blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md032.md`,tags:[`bullet`,`ul`,`blank_lines`,`ol`],options:[]},{id:`MD033`,alias:`no-inline-html`,aliases:[`no-inline-html`],name:`Inline HTML`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md033.md`,tags:[`html`],options:[{key:`allowed_elements`,type:`string-array`,description:`Allowed elements`,default:[]},{key:`table_allowed_elements`,type:`string-array`,description:`Allowed elements in tables`,default:[]}]},{id:`MD034`,alias:`no-bare-urls`,aliases:[`no-bare-urls`],name:`Bare URL used`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md034.md`,tags:[`links`,`url`],options:[]},{id:`MD035`,alias:`hr-style`,aliases:[`hr-style`],name:`Horizontal rule style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md035.md`,tags:[`hr`],options:[{key:`style`,type:`string`,description:`Horizontal rule style`,default:`consistent`}]},{id:`MD036`,alias:`no-emphasis-as-heading`,aliases:[`no-emphasis-as-heading`],name:`Emphasis used instead of a heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md036.md`,tags:[`headings`,`emphasis`],options:[{key:`punctuation`,type:`string`,description:`Punctuation characters`,default:`.,;:!?。,;:!?`}]},{id:`MD037`,alias:`no-space-in-emphasis`,aliases:[`no-space-in-emphasis`],name:`Spaces inside emphasis markers`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md037.md`,tags:[`whitespace`,`emphasis`],options:[]},{id:`MD038`,alias:`no-space-in-code`,aliases:[`no-space-in-code`],name:`Spaces inside code span elements`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md038.md`,tags:[`whitespace`,`code`],options:[]},{id:`MD039`,alias:`no-space-in-links`,aliases:[`no-space-in-links`],name:`Spaces inside link text`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md039.md`,tags:[`whitespace`,`links`],options:[]},{id:`MD040`,alias:`fenced-code-language`,aliases:[`fenced-code-language`],name:`Fenced code blocks should have a language specified`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md040.md`,tags:[`code`,`language`],options:[{key:`allowed_languages`,type:`string-array`,description:`List of languages`,default:[]},{key:`language_only`,type:`boolean`,description:`Require language only`,default:!1}]},{id:`MD041`,alias:`first-line-heading`,aliases:[`first-line-heading`,`first-line-h1`],name:`First line in a file should be a top-level heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md041.md`,tags:[`headings`],options:[{key:`allow_preamble`,type:`boolean`,description:`Allow content before first heading`,default:!1},{key:`front_matter_title`,type:`string`,description:`RegExp for matching title in front matter`,default:`^\\s*title\\s*[:=]`},{key:`level`,type:`integer`,description:`Heading level`,default:1,minimum:1,maximum:6}]},{id:`MD042`,alias:`no-empty-links`,aliases:[`no-empty-links`],name:`No empty links`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md042.md`,tags:[`links`],options:[]},{id:`MD043`,alias:`required-headings`,aliases:[`required-headings`],name:`Required heading structure`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md043.md`,tags:[`headings`],options:[{key:`headings`,type:`string-array`,description:`List of headings`,default:[]},{key:`match_case`,type:`boolean`,description:`Match case of headings`,default:!1}]},{id:`MD044`,alias:`proper-names`,aliases:[`proper-names`],name:`Proper names should have the correct capitalization`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md044.md`,tags:[`spelling`],options:[{key:`names`,type:`string-array`,description:`List of proper names`,default:[]},{key:`code_blocks`,type:`boolean`,description:`Include code blocks`,default:!0},{key:`html_elements`,type:`boolean`,description:`Include HTML elements`,default:!0}]},{id:`MD045`,alias:`no-alt-text`,aliases:[`no-alt-text`],name:`Images should have alternate text (alt text)`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md045.md`,tags:[`accessibility`,`images`],options:[]},{id:`MD046`,alias:`code-block-style`,aliases:[`code-block-style`],name:`Code block style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md046.md`,tags:[`code`],options:[{key:`style`,type:`enum`,description:`Block style`,enum:[`consistent`,`fenced`,`indented`],default:`consistent`}]},{id:`MD047`,alias:`single-trailing-newline`,aliases:[`single-trailing-newline`],name:`Files should end with a single newline character`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md047.md`,tags:[`blank_lines`],options:[]},{id:`MD048`,alias:`code-fence-style`,aliases:[`code-fence-style`],name:`Code fence style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md048.md`,tags:[`code`],options:[{key:`style`,type:`enum`,description:`Code fence style`,enum:[`consistent`,`backtick`,`tilde`],default:`consistent`}]},{id:`MD049`,alias:`emphasis-style`,aliases:[`emphasis-style`],name:`Emphasis style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md049.md`,tags:[`emphasis`],options:[{key:`style`,type:`enum`,description:`Emphasis style`,enum:[`consistent`,`asterisk`,`underscore`],default:`consistent`}]},{id:`MD050`,alias:`strong-style`,aliases:[`strong-style`],name:`Strong style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md050.md`,tags:[`emphasis`],options:[{key:`style`,type:`enum`,description:`Strong style`,enum:[`consistent`,`asterisk`,`underscore`],default:`consistent`}]},{id:`MD051`,alias:`link-fragments`,aliases:[`link-fragments`],name:`Link fragments should be valid`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md051.md`,tags:[`links`],options:[{key:`ignore_case`,type:`boolean`,description:`Ignore case of fragments`,default:!1},{key:`ignored_pattern`,type:`string`,description:`Pattern for ignoring additional fragments`,default:``}]},{id:`MD052`,alias:`reference-links-images`,aliases:[`reference-links-images`],name:`Reference links and images should use a label that is defined`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md052.md`,tags:[`links`,`images`],options:[{key:`ignored_labels`,type:`string-array`,description:`Ignored link labels`,default:[`x`]},{key:`shortcut_syntax`,type:`boolean`,description:`Include shortcut syntax`,default:!1}]},{id:`MD053`,alias:`link-image-reference-definitions`,aliases:[`link-image-reference-definitions`],name:`Link and image reference definitions should be needed`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md053.md`,tags:[`links`,`images`],options:[{key:`ignored_definitions`,type:`string-array`,description:`Ignored definitions`,default:[`//`]}]},{id:`MD054`,alias:`link-image-style`,aliases:[`link-image-style`],name:`Link and image style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md054.md`,tags:[`links`,`images`],options:[{key:`autolink`,type:`boolean`,description:`Allow autolinks`,default:!0},{key:`inline`,type:`boolean`,description:`Allow inline links and images`,default:!0},{key:`full`,type:`boolean`,description:`Allow full reference links and images`,default:!0},{key:`collapsed`,type:`boolean`,description:`Allow collapsed reference links and images`,default:!0},{key:`shortcut`,type:`boolean`,description:`Allow shortcut reference links and images`,default:!0},{key:`url_inline`,type:`boolean`,description:`Allow URLs as inline links`,default:!0}]},{id:`MD055`,alias:`table-pipe-style`,aliases:[`table-pipe-style`],name:`Table pipe style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md055.md`,tags:[`table`],options:[{key:`style`,type:`enum`,description:`Table pipe style`,enum:[`consistent`,`leading_only`,`trailing_only`,`leading_and_trailing`,`no_leading_or_trailing`],default:`consistent`}]},{id:`MD056`,alias:`table-column-count`,aliases:[`table-column-count`],name:`Table column count`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md056.md`,tags:[`table`],options:[]},{id:`MD058`,alias:`blanks-around-tables`,aliases:[`blanks-around-tables`],name:`Tables should be surrounded by blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md058.md`,tags:[`table`],options:[]},{id:`MD059`,alias:`descriptive-link-text`,aliases:[`descriptive-link-text`],name:`Link text should be descriptive`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md059.md`,tags:[`links`,`accessibility`],options:[{key:`prohibited_texts`,type:`string-array`,description:`Prohibited link texts`,default:[`click here`,`here`,`link`,`more`]}]},{id:`MD060`,alias:`table-column-style`,aliases:[`table-column-style`],name:`Table column style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md060.md`,tags:[`table`],options:[{key:`style`,type:`enum`,description:`Table column style`,enum:[`any`,`aligned`,`compact`,`tight`],default:`any`},{key:`aligned_delimiter`,type:`boolean`,description:`Aligned delimiter columns`,default:!1}]}],HK=(()=>{let e=new Map;for(let t of VK){e.set(t.id.toUpperCase(),t.id);for(let n of t.aliases)e.set(n.toUpperCase(),t.id)}return e})();function UK(e){return HK.get(e.toUpperCase())??null}function WK(e,t){let n=UK(t);if(n===null)return;let r;for(let[t,i]of Object.entries(e))UK(t)===n&&(r={key:t,value:i});return r}async function GK(e,t,n){if(!t.enabled)return[];let r=[];for(let i of uK){let a=t.plugins[i.id];a.enabled&&r.push(...await i.lint(e,a,{docName:n}))}return r}function KK(e,t){if(!t.enabled)return e;let n=e;for(let e of uK){let r=t.plugins[e.id];!r.enabled||!e.fix||(n=e.fix(n,r))}return n}const qK=/\p{M}+/gu,JK=/[^\p{L}\p{N}]+/gu,YK=/^-+|-+$/g;function XK(e){return e.trim().normalize(`NFKD`).replace(qK,``).toLowerCase().replace(JK,`-`).replace(YK,``)}function ZK(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function QK(e,t){let n=XK(e);return n?ZK(n,t):``}const $K=new Set([`img`,`video`,`audio`,`mark`]);new Map(yN.flatMap(e=>e.surface===`compat`&&$K.has(e.rendersAs)?[[e.name,e]]:[])),sk(`<>`);const eq=LR(),tq=tR(),nq=nR();function rq(){return yN.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function iq(){return rq().filter(e=>aq(e)!==`fence`)}function aq(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function oq(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:aq(e)}}function sq(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 cq(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 lq(e){let t=[];for(let n of e.props){let e=sq(n);e!==void 0&&cq(n,e)&&t.push(MM(n.name,e))}return t}function uq(e){return oF(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[eq],mdastExtensions:[tq]}).children}function dq(e){let t=aq(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
279
279
  A --> B`};else{let r=lq(e),i=t===`jsx-block`?uq(e):[];n={type:`mdxJsxFlowElement`,name:e.name,attributes:r,children:i}}return cO({type:`root`,children:[n]},{extensions:[nq]}).trimEnd()}function fq(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 pq(e){return{...oq(e),example:dq(e),params:fq(e)}}function mq(){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.",``,...iq().map(oq).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
280
- `)}const hq=[`text`,`number`,`boolean`,`date`,`list`,`object`];d(hq);const gq=y([b(),A(),E()]),_q=te(()=>y([gq.transform(e=>String(e)),T(b(),vq),k(_q)])),vq=te(()=>y([b(),A(),E(),k(_q),T(b(),vq)]));function yq(e){if(Array.isArray(e)){let t=[];for(let n of e)n!==null&&t.push(yq(n));return t}if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e))t[n]=r===null?``:yq(r);return t}return e}const bq=D(yq,T(b(),vq));T(b(),y([vq,i()]));function xq(e){return!!(e===null||typeof e==`string`&&e===``||Array.isArray(e)&&e.length===0)}const Sq=v({docName:$v,summary:ny,content:b().optional(),...ty}).loose(),Cq=v({docName:$v,summary:ny,markdown:b(),position:d([`append`,`prepend`,`replace`]).optional(),extension:d(Ge).optional(),...ty}).loose(),wq=v({docName:$v,summary:ny,find:b().min(1),replace:b(),offset:A().int().nonnegative().optional(),...ty}).loose(),Tq=v({docName:$v,connectionId:b().min(1),scope:d([`last`,`session`,`file`,`count`]).optional(),count:A().int().positive().optional(),...ty}).loose().refine(e=>e.scope!==`count`||e.count!==void 0,{message:`count is required when scope is 'count'`,path:[`count`]}),Eq=v({value:b(),truncatedFrom:A().int().nonnegative().optional(),hint:b().optional()}).loose(),Dq=x(`kind`,[v({kind:_(`inline`),content:b()}),v({kind:_(`truncated`),byteLength:A().int().nonnegative(),hint:b()})]),Oq=v({kind:_(`content-divergence`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),divergenceType:b().optional(),currentState:Dq.optional(),hint:b().optional()}).loose(),kq=v({type:_(`orphan`),parentCandidates:k(b()),message:b()}).loose(),Aq=v({kind:_(`disk-edit-reconciled`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),mergeOutcome:b().optional(),hint:b().optional()}).loose(),jq=x(`kind`,[Oq,Aq]),Mq=x(`kind`,[Oq,Aq,v({kind:_(`mermaid-parse-error`),fenceIndex:A().int().positive(),fenceFirstLine:b(),message:b(),line:A().int().positive().optional()}).loose(),v({kind:_(`lint-violation`),source:b(),code:b(),message:b(),severity:d([`error`,`warning`,`info`,`hint`]),line:A().int().positive(),column:A().int().positive(),linkTarget:b().optional()}).loose()]),Nq=k(Mq).min(1),Pq=v({href:b(),resolvedTo:b().nullable(),reason:d([`no-such-doc`,`no-such-file`,`unresolvable`])}).loose(),Fq=k(Pq),Iq=v({timestamp:b().min(1),summary:Eq.optional(),warning:jq.optional(),warnings:Nq.optional()}).loose(),Lq=v({timestamp:b().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:k(kq).optional(),summary:Eq.optional(),warning:jq.optional(),warnings:Nq.optional(),brokenLinks:Fq}).loose(),Rq=v({timestamp:b().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:Eq.optional(),warning:jq.optional(),warnings:Nq.optional(),brokenLinks:Fq}).loose(),zq=v({docName:b().min(1),scope:d([`last`,`session`,`count`]),undone:E()}).loose(),Bq=v({docs:k(v({docName:ey,markdown:b(),position:d([`append`,`prepend`,`replace`]).optional(),extension:d(Ge).optional(),summary:ny}).loose()).min(1).max(100),...ty}).loose(),Vq=v({type:Ry,title:b(),detail:b().optional()}).loose(),Hq=x(`status`,[v({status:_(`written`),docName:b().min(1),summary:Eq.optional(),warnings:Nq.optional(),brokenLinks:Fq}).loose(),v({status:_(`error`),docName:b().min(1),error:Vq}).loose()]),Uq=v({timestamp:b().min(1),results:k(Hq),written:A().int().nonnegative(),failed:A().int().nonnegative()}).loose(),Wq=v({docName:$v,patch:T(b(),y([vq,i()])),types:T(b(),d(hq)).optional(),summary:ny,...ty}).loose(),Gq=v({timestamp:b().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:k(b()),summary:Eq.optional(),warning:jq.optional(),warnings:Nq.optional(),brokenLinks:Fq}).loose(),Kq=v({entries:k(v({level:d([`info`,`warn`,`error`]),message:b().max(8192),event:b().optional(),fields:T(b(),h()).optional(),ts:A().optional(),sourceId:b().optional(),lineNumber:A().optional()}).loose()).max(100),droppedSinceLastFlush:A().int().min(0).optional()}).loose(),qq=v({accepted:A().int().min(0)}).loose(),Jq=v({status:b().min(1),reason:b()}).loose(),Yq=v({docName:b().min(1),content:b(),lifecycle:Jq.nullable()}).loose(),Xq=v({documents:k(v({kind:d([`document`,`asset`,`folder`,`file`]).default(`document`),docName:b().min(1).optional(),docExt:b().min(1).default(`.md`),size:A().int().nonnegative(),modified:b().min(1),isSymlink:E().default(!1),canonicalDocName:b().nullable().default(null),targetPath:b().nullable().default(null),path:b().min(1).optional(),assetExt:b().min(1).optional(),mediaKind:d([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`]).nullable().optional(),referencedBy:k(b().min(1)).optional(),hasChildren:E().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:E().optional()}).loose(),Zq=v({source:b().min(1),anchor:b().nullable(),title:b(),snippet:b().nullable()}).loose(),Qq=v({docName:b().min(1),backlinks:k(Zq)}).loose(),$q=v({counts:T(b().min(1),A().int().nonnegative())}).loose(),eJ=x(`kind`,[v({kind:_(`doc`),docName:b().min(1),anchor:b().nullable(),title:b(),snippet:b().nullable()}).loose(),v({kind:_(`external`),url:b().min(1),title:b(),snippet:b().nullable()}).loose()]),tJ=v({docName:b().min(1),forwardLinks:k(eJ)}).loose(),nJ=x(`kind`,[v({id:b().min(1),kind:_(`doc`),docName:b().min(1),anchor:b().nullable(),label:b(),cluster:b().nullable(),category:b().nullable(),tags:k(b()).nullable()}).loose(),v({id:b().min(1),kind:_(`external`),url:b().min(1),label:b()}).loose()]),rJ=v({source:b().min(1),target:b().min(1)}).loose(),iJ=v({nodes:k(nJ),links:k(rJ)}).loose(),aJ=v({ts:A().int().min(0),url:b(),method:b(),ua:b().optional(),origin:b().optional(),referer:b().optional(),host:b().optional(),remote:b().optional(),secChUa:b().optional(),secChUaMobile:b().optional(),secChUaPlatform:b().optional(),secFetchSite:b().optional(),secFetchDest:b().optional(),secFetchMode:b().optional(),secFetchUser:b().optional()}).loose(),oJ=v({app:y([_(`cursor`),_(`codex`),_(`claude`),i()]),signals_fired:k(b())}).loose(),sJ=v({entries:k(aJ),count:A().int().min(0),detection:oJ}).loose(),cJ=v({writers:k(v({id:b().min(1),name:b().optional(),email:b().optional()}).loose()).optional(),summary:ny,...ty}).loose(),lJ=v({checkpointRef:b().min(1)}).loose(),uJ=v({v:A().int().optional(),id:b().min(1),name:b().min(1),colorSeed:b().optional(),docs:k(b()),summaries:k(b()).optional()}).loose(),dJ=v({entries:k(v({sha:b().min(1),timestamp:b().min(1),author:b(),authorEmail:b(),type:d([`checkpoint`,`wip`,`upstream`,`park`]),message:b(),contributors:k(uJ),checkpoint:h().nullable(),parentSha:b().nullable().optional()}).loose()),total:A().int().nonnegative().optional(),truncated:E().optional(),hasMore:E().optional()}).loose(),fJ=v({sha:b().regex(/^[0-9a-f]{40}$/i),content:b(),timestamp:b(),author:b()}).loose(),pJ=v({contentDir:b().min(1),pathSeparator:d([`/`,`\\`]),symlinkResolved:E()}).loose(),mJ=k(x(`source`,[v({docName:b().min(1),timestamp:b().min(1),size:A().int().nonnegative(),source:_(`flat`)}).loose(),v({docName:b().min(1),timestamp:b().min(1),source:_(`timeline`),sha:b().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),hJ=v({domain:b().min(1),title:b().optional(),description:b().optional(),siteName:b().optional(),faviconDataUri:b().optional()}).loose(),gJ=v({url:b()}).loose(),_J=x(`ok`,[v({ok:_(!0),metadata:hJ}).loose(),v({ok:_(!1),reason:b()}).loose()]),vJ=v({orphans:k(v({docName:b().min(1),title:b()}).loose())}).loose(),yJ=v({hubs:k(v({docName:b().min(1),title:b(),count:A().int().nonnegative()}).loose())}).loose(),bJ=v({source:b().min(1),title:b(),snippet:b().nullable()}).loose(),xJ=v({deadLinks:k(v({target:b().min(1),sources:k(bJ)}).loose())}).loose(),SJ=v({target:v({docName:b().min(1),title:b(),aliases:k(b())}).loose(),mentions:k(v({source:b().min(1),excerpt:b(),offset:A().int().nonnegative()}).loose()),truncated:E()}).loose(),CJ=v({projectPath:b().min(1)}).loose(),wJ=d([`not-a-git-worktree`,`init-failed`]),TJ=x(`ok`,[v({ok:_(!0),projectPath:b().min(1)}).loose(),v({ok:_(!1),reason:wJ,message:b().min(1)}).loose()]),EJ=v({host:b().min(1).optional()}).loose(),DJ=v({host:b().min(1).optional(),token:b().min(1)}).loose(),OJ=v({host:b(),login:b()}).loose(),kJ=v({key:b().min(1)}).loose(),AJ=v({keyPresent:E()}).loose(),jJ=d([`no_key`,`invalid_endpoint`,`rate_limit`,`timeout`,`http_error`,`network`,`dims_mismatch`,`malformed_response`]),MJ=x(`ok`,[v({ok:_(!0),endpoint:b().min(1),model:b().min(1),dimensions:A().int().positive()}).loose(),v({ok:_(!1),endpoint:b().min(1),model:b().min(1),reason:jJ,status:A().int().optional()}).loose()]),NJ=v({name:b().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:b().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),PJ=v({authenticated:E()}).loose(),FJ=v({}).loose(),IJ=v({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),LJ=v({docName:b().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:k(IJ)}).loose(),RJ=v({displayName:b().min(1),color:b().min(1),icon:b().optional(),connectionId:b().min(1)}).loose(),zJ=v({sessionAlive:E(),agent:RJ.nullable(),files:k(LJ)}).loose(),BJ=v({diff:b(),before:b(),after:b(),generatedAt:A().int().min(0)}).loose(),VJ=v({}).loose(),HJ=v({}).loose(),UJ=v({}).loose(),WJ=v({}).loose(),GJ=v({}).loose(),KJ=v({}).loose(),qJ=v({displayName:b().min(1),icon:b(),color:b().min(1),currentDoc:b().nullable(),mode:d([`idle`,`writing`]),ts:A().int().min(0)}).loose(),JJ=v({presence:T(b().min(1),qJ)}).loose(),YJ=v({sessionId:b().min(1),agentType:b().min(1),ts:A().int().min(0),insertedChars:A().int().min(0),deletedChars:A().int().min(0)}).loose(),XJ=v({effects:k(v({"doc.name":b().min(1),entries:k(YJ)}).loose())}).loose(),ZJ=v({decisions:k(v({ts:A().int().min(0),decision:b().min(1),kind:b().min(1),"doc.name":b().min(1),pathRole:b().min(1)}).loose())}).loose(),QJ=T(b().min(1),E()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});v({path:b().min(1,`path must be non-empty`)}).loose();const $J=v({}).loose(),eY=v({fromDocName:b().min(1),toDocName:b().min(1)}).loose(),tY=v({fromPath:b().min(1),toPath:b().min(1)}).loose(),nY=v({}).loose(),rY=v({path:b().min(1),...ty,summary:ny}).loose(),iY=v({docName:b().min(1)}).loose(),aY=v({path:b().min(1),...ty,summary:ny}).loose(),oY=v({path:b().min(1)}).loose(),sY=v({kind:d([`file`,`folder`]),path:b().min(1),...ty,summary:ny}).loose(),cY=v({kind:d([`file`,`folder`]),path:b().min(1),duplicatedDocNames:k(b().min(1))}).loose(),lY=v({pages:k(v({docName:b().min(1),title:b(),docExt:b().min(1),size:A().int().nonnegative(),modified:b().min(1),icon:b().min(1).max(2048).optional()}).loose())}).loose(),uY=v({level:A().int().min(1).max(6),text:b(),slug:b()}).loose(),dY=v({docName:b().min(1),headings:k(uY)}).loose(),fY=v({docName:b().min(1),rewrites:A().int().nonnegative()}).loose(),pY=v({kind:d([`file`,`folder`,`asset`]),fromPath:b().min(1),toPath:b().min(1),...ty,summary:ny}).loose(),mY=v({renamed:k(eY),renamedAssets:k(tY),rewrittenDocs:k(fY).optional(),summary:Eq.optional()}).loose(),hY=v({kind:d([`file`,`folder`,`asset`]),path:b().min(1),...ty}).loose(),gY=v({deletedDocNames:k(b().min(1))}).loose(),_Y=v({kind:d([`file`,`folder`,`asset`]),path:b().min(1),...ty,summary:ny}).loose(),vY=v({deletedDocNames:k(b().min(1))}).loose(),yY=v({docName:b().min(1),commitSha:b().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:ny,...ty}).loose(),bY=v({restoredFrom:b().min(1),timestamp:b().min(1),summary:Eq.optional(),warning:Oq.optional(),warnings:Nq.optional()}).loose(),xY=d([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),SY=v({label:b().min(1),webUrl:j().nullable()}).loose(),CY=x(`checkStatus`,[v({checkStatus:_(`allowed`)}).loose(),v({checkStatus:_(`denied`),deniedReason:d([`no-collaborator`,`private-no-access`,`repo-not-found`,`not-authenticated`])}).loose(),v({checkStatus:_(`unknown`),unknownError:d([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`,`ssh-unverified`]).optional()}).loose()]),wY=d([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),TY=d(O),EY=d([`succeeded`,`up-to-date`,`conflict`,`refused`,`error`]),DY=v({state:xY,lastSyncUtc:b().nullable(),lastFetchUtc:b().nullable(),lastPushedSha:b().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:E(),syncEnabled:E(),identityUnresolved:E(),remote:SY.nullable().optional(),pushError:b().optional(),pushErrorCode:wY.optional(),pullError:b().optional(),pullErrorCode:wY.optional(),pausedReason:b().optional(),pushPermission:CY.optional(),syncMode:TY.optional(),lastPullUtc:b().nullable().optional(),lastPullOutcome:EY.nullable().optional()}).loose(),OY=v({op:d([`sync`,`push`,`pull`]).optional()}).loose(),kY=v({op:d([`sync`,`push`,`pull`])}).loose(),AY=v({conflicts:k(v({file:b().min(1),detectedAt:b().min(1),oursSha:b().optional(),theirsSha:b().optional(),baseSha:b().optional()}).loose())}).loose(),jY=v({file:b().min(1),strategy:d([`mine`,`theirs`,`content`,`delete`]),content:b().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`]}),MY=v({}).loose(),NY=v({file:b().min(1),base:b(),ours:b(),theirs:b(),kind:d([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:b().nullable()}).loose(),PY=v({plan:ee(e=>e!==void 0,{message:`plan is required`})}).loose(),FY=v({plan:ee(e=>e!==void 0,{message:`plan is required`})}).loose(),IY=v({result:ee(e=>e!==void 0,{message:`result is required`})}).loose(),LY=v({path:b().min(1),summary:b().min(1)}).loose(),RY=v({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),zY=v({packs:k(v({id:b().min(1),name:b().min(1),description:b().min(1),defaultSubfolder:b().optional(),folders:k(LY),entryCounts:RY}).loose())}).loose(),BY=v({noOpen:E().optional(),out:b().min(1).optional()}).loose(),VY=v({reason:d([`unsupported-platform`,`spawn-error`]),message:b()}).loose(),HY=x(`status`,[v({status:_(`installed`),outputPath:b(),size:A().int().nonnegative(),sha256:b(),skillVersion:b()}).loose(),v({status:_(`built`),outputPath:b(),size:A().int().nonnegative(),sha256:b(),skillVersion:b(),handoffError:VY.optional()}).loose(),v({status:_(`failed`),buildError:b()}).loose(),v({status:_(`skip-current`),skillVersion:b(),recordedAt:b().optional()}).loose()]),UY=[`.ok`,`skill-targets.json`],WY=d(Ze),GY=w({schema:_(1),targets:k(WY).default([])});function KY(e){let t;try{t=JSON.parse(e)}catch{return null}let n=GY.safeParse(t);return n.success?n.data:null}const qY=v({tags:k(v({name:b().min(1),count:A().int().nonnegative(),isLeaf:E()}).loose())}).loose(),JY=v({docName:b().min(1),title:b(),matchingTags:k(b().min(1)),snippet:b().nullable()}).loose(),YY=v({name:b().min(1),docs:k(JY)}).loose(),XY=v({folder:h(),frontmatter_local:T(b(),h()).nullable()}).loose(),ZY=v({path:b(),frontmatter:T(b(),h()).optional()}).loose(),QY=v({applied:h()}).loose(),$Y=T(b(),h()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),eX=v({template:v({name:b().min(1),folder:b(),scope:d([`local`,`inherited`]),path:b().min(1),frontmatter:$Y,body:b()}).strict()}).strict(),tX=v({templates:k(v({name:b().min(1),title:b().optional(),description:b().optional(),path:b().min(1),source_folder:b()}).strict()),truncated:E()}).strict(),nX=v({folder:b(),name:b(),body:b().optional(),frontmatter:$Y.optional(),...ty,summary:ny}).strict(),rX=v({path:b().min(1),created:E(),warnings:k(b())}).strict(),iX=v({sourcePath:b().min(1),targetFolder:b(),name:b().optional(),title:b().optional(),deleteSource:E().optional(),...ty,summary:ny}).strict(),aX=v({path:b().min(1),created:E(),warnings:k(b())}).strict(),oX=v({existed:E(),path:b().min(1)}).strict(),sX=v({fromFolder:b(),fromName:b(),toFolder:b(),toName:b(),body:b().optional(),frontmatter:$Y.optional(),...ty,summary:ny}).strict(),cX=v({from:b().min(1),to:b().min(1),committed:E()}).strict(),lX=d(Ae),uX=/^[a-z0-9-]+$/,dX=/<\/?[A-Za-z][^>]*>/;function fX(e){return dX.test(e)}const pX=/^[A-Za-z0-9_-]+$/,mX=v({name:b(),description:b()}).strict(),hX=v({skill:v({name:b().min(1),scope:lX,path:b().min(1),frontmatter:mX,body:b(),files:k(v({path:b().min(1),text:b().nullable()})).optional(),managed:E().optional()}).strict()}).strict(),gX=v({skills:k(v({name:b().min(1),description:b().optional(),scope:lX,path:b().min(1),absolutePath:b().min(1).optional(),installed:E(),hosts:k(b()),installedVersion:b().optional(),bundledVersion:b().optional(),updateAvailable:E().optional(),managed:E().optional()}).strict()),truncated:E()}).strict(),_X=v({scope:lX.default(`project`),name:b(),body:b().optional(),frontmatter:mX,...ty,summary:ny}).strict(),vX=v({path:b().min(1),created:E(),warnings:k(b())}).strict(),yX=v({scope:lX.default(`project`),name:b(),...ty,summary:ny}).strict(),bX=v({name:b().min(1),version:b().min(1),previousVersion:b().optional(),checkpointRef:b().optional()}).strict(),xX=v({existed:E(),path:b().min(1)}).strict(),SX=v({scope:lX.default(`project`),fromName:b(),toName:b(),body:b().optional(),frontmatter:mX.optional(),...ty,summary:ny}).strict(),CX=v({from:b().min(1),to:b().min(1),committed:E()}).strict(),wX=d([`reference`,`script`]),TX=v({scope:lX.default(`project`),name:b(),path:b().min(1),content:b(),...ty,summary:ny}).strict(),EX=v({path:b().min(1),created:E(),kind:wX,content:E()}).strict(),DX=v({path:b().min(1),kind:wX,text:b()}).strict(),OX=v({path:b().min(1),existed:E(),kind:wX}).strict(),kX=v({scope:lX.default(`project`),name:b(),targets:k(WY).optional().meta({description:`Explicit editor ids to install into; omit to use project-configured editors.`}),...ty,summary:ny}).strict(),AX=v({name:b().min(1),hosts:k(b()),scripts:E(),warnings:k(b()),warningCodes:k(d([`no-targets`,`scripts-present`]))}).strict(),jX=v({scope:lX.default(`project`),name:b()}).strict(),MX=v({name:b().min(1),uninstalled:E()}).strict(),NX=v({targets:k(WY),configured:E()}).strict(),PX=v({targets:k(WY)}).strict(),FX=v({targets:k(WY),reprojected:k(v({name:b(),hosts:k(b())}).strict()),bundleHosts:k(b()),removedFrom:k(b())}).strict(),IX=v({scope:lX.default(`project`),name:b(),version:b().regex(/^[0-9a-f]{40}$/i),...ty,summary:ny}).strict(),LX=v({name:b().min(1),version:b(),restoredFiles:k(b()),warnings:k(b())}).strict(),RX=v({query:b().optional(),intent:d([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:d([`navigation`,`relevance`]).optional(),scopes:k(d([`page`,`folder`,`content`,`file`])).optional(),scope:b().optional(),limit:A().int().nonnegative().optional(),semantic:E().optional(),source:d([`omnibar`,`mcp`,`http`]).optional()}).loose(),zX=v({kind:d([`page`,`folder`,`content`,`file`]),path:b().min(1),title:b(),score:A(),signals:T(b(),h()),snippet:b().optional()}).loose(),BX=v({capable:E(),applied:E(),coverage:v({embedded:A().int().nonnegative(),total:A().int().nonnegative()})}).loose(),VX=v({enabled:E(),keyPresent:E(),keyNotRequired:E(),keySource:d([`project`,`file`,`env`]).nullable(),keyHint:b().nullable(),ready:E(),capable:E(),embedded:A().int().nonnegative(),total:A().int().nonnegative()}).loose(),HX=v({query:b(),intent:d([`autocomplete`,`full_text`,`omnibar`]),results:k(zX),elapsedMs:A().nonnegative(),semantic:BX.optional(),truncated:E().optional(),ready:E().optional()}).loose(),UX=v({version:b().min(1),recordedAt:b().min(1)}).loose(),WX=v({currentVersion:b().min(1),targets:T(b(),UX.nullable())}).loose(),GX=`server-info`,KX=`branch-switched`,qX=`disk-ack`,JX=`config-validation-rejected`,YX=`config-ignore-nested-error`,XX=d([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`,`lint-config`]),ZX=v({v:_(1),ch:_(GX),seq:A(),serverInstanceId:b().min(1),currentBranch:b().min(1).optional()}).loose(),QX=v({v:_(1),ch:_(KX),seq:A(),branch:b().min(1)}).loose(),$X=v({v:_(1),ch:XX,seq:A()}).loose(),eZ=v({v:_(1),ch:_(qX),seq:A(),docName:b().min(1),sv:b().min(1)}).loose(),tZ=v({v:_(1),ch:_(JX),seq:A(),docName:b().min(1),error:g}).loose(),nZ=v({v:_(1),ch:_(YX),seq:A(),path:b().min(1),error:b().min(1)}).loose();function rZ(e){let t=e?.trim();return t===void 0||t===``?void 0:t}function iZ(e){return e.reason!==void 0||rZ(e.note)!==void 0||rZ(e.email)!==void 0}function aZ(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol===`https:`)return t;let n=t.hostname===`localhost`||t.hostname===`127.0.0.1`||t.hostname===`[::1]`;return t.protocol===`http:`&&n?t:null}function oZ(){return aZ((typeof process>`u`?void 0:rZ(process.env?.OK_FEEDBACK_INTAKE_ORIGIN))??`https://openknowledge.ai`)}function sZ(e){let t=rZ(e);if(t!==void 0)return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?t:void 0}async function cZ(e,t,n){try{let r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t),signal:AbortSignal.timeout(n)});if(r.ok){let e=await r.json().catch(()=>null);return{ok:!0,reference:typeof e?.reference==`string`?e.reference:``}}return r.status===400||r.status===413?{ok:!1,reason:`invalid`}:r.status===503?{ok:!1,reason:`unavailable`}:{ok:!1,reason:`error`}}catch(e){return{ok:!1,reason:e instanceof Error&&(e.name===`TimeoutError`||e.name===`AbortError`)?`timeout`:`error`}}}async function lZ(e,t={}){let n=oZ();if(n===null)return{ok:!1,reason:`error`};let r=new URL(`/api/feedback`,n),i=rZ(e.note),a=sZ(e.email),o={kind:`uninstall`,reasons:e.reason===void 0?[]:[e.reason],...i===void 0?{}:{message:i},appVersion:e.appVersion,platform:e.platform,source:e.source},s=Date.now()+(t.timeoutMs??4e3),c=()=>s-Date.now();if(a===void 0)return cZ(r,o,c());let l=await cZ(r,{...o,email:a},c());return l.ok||l.reason!==`invalid`||c()<=0?l:cZ(r,o,c())}var uZ=t(r(((e,t)=>{var n=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},r=-1,i=1,a=0;n.Diff=function(e,t){return[e,t]},n.prototype.diff_main=function(e,t,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+this.Diff_Timeout*1e3);var o=i;if(e==null||t==null)throw Error(`Null input. (diff_main)`);if(e==t)return e?[new n.Diff(a,e)]:[];r===void 0&&(r=!0);var s=r,c=this.diff_commonPrefix(e,t),l=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=this.diff_commonSuffix(e,t);var u=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var d=this.diff_compute_(e,t,s,o);return l&&d.unshift(new n.Diff(a,l)),u&&d.push(new n.Diff(a,u)),this.diff_cleanupMerge(d),d},n.prototype.diff_compute_=function(e,t,o,s){var c;if(!e)return[new n.Diff(i,t)];if(!t)return[new n.Diff(r,e)];var l=e.length>t.length?e:t,u=e.length>t.length?t:e,d=l.indexOf(u);if(d!=-1)return c=[new n.Diff(i,l.substring(0,d)),new n.Diff(a,u),new n.Diff(i,l.substring(d+u.length))],e.length>t.length&&(c[0][0]=c[2][0]=r),c;if(u.length==1)return[new n.Diff(r,e),new n.Diff(i,t)];var f=this.diff_halfMatch_(e,t);if(f){var p=f[0],m=f[1],h=f[2],g=f[3],_=f[4],v=this.diff_main(p,h,o,s),y=this.diff_main(m,g,o,s);return v.concat([new n.Diff(a,_)],y)}return o&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,s):this.diff_bisect_(e,t,s)},n.prototype.diff_lineMode_=function(e,t,o){var s=this.diff_linesToChars_(e,t);e=s.chars1,t=s.chars2;var c=s.lineArray,l=this.diff_main(e,t,!1,o);this.diff_charsToLines_(l,c),this.diff_cleanupSemantic(l),l.push(new n.Diff(a,``));for(var u=0,d=0,f=0,p=``,m=``;u<l.length;){switch(l[u][0]){case i:f++,m+=l[u][1];break;case r:d++,p+=l[u][1];break;case a:if(d>=1&&f>=1){l.splice(u-d-f,d+f),u=u-d-f;for(var h=this.diff_main(p,m,!1,o),g=h.length-1;g>=0;g--)l.splice(u,0,h[g]);u+=h.length}f=0,d=0,p=``,m=``;break}u++}return l.pop(),l},n.prototype.diff_bisect_=function(e,t,a){for(var o=e.length,s=t.length,c=Math.ceil((o+s)/2),l=c,u=2*c,d=Array(u),f=Array(u),p=0;p<u;p++)d[p]=-1,f[p]=-1;d[l+1]=0,f[l+1]=0;for(var m=o-s,h=m%2!=0,g=0,_=0,v=0,y=0,b=0;b<c&&!(new Date().getTime()>a);b++){for(var x=-b+g;x<=b-_;x+=2){for(var S=l+x,C=x==-b||x!=b&&d[S-1]<d[S+1]?d[S+1]:d[S-1]+1,w=C-x;C<o&&w<s&&e.charAt(C)==t.charAt(w);)C++,w++;if(d[S]=C,C>o)_+=2;else if(w>s)g+=2;else if(h){var T=l+m-x;if(T>=0&&T<u&&f[T]!=-1){var E=o-f[T];if(C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}for(var D=-b+v;D<=b-y;D+=2){for(var T=l+D,E=D==-b||D!=b&&f[T-1]<f[T+1]?f[T+1]:f[T-1]+1,O=E-D;E<o&&O<s&&e.charAt(o-E-1)==t.charAt(s-O-1);)E++,O++;if(f[T]=E,E>o)y+=2;else if(O>s)v+=2;else if(!h){var S=l+m-D;if(S>=0&&S<u&&d[S]!=-1){var C=d[S],w=l+C-S;if(E=o-E,C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}}return[new n.Diff(r,e),new n.Diff(i,t)]},n.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},n.prototype.diff_linesToChars_=function(e,t){var n=[],r={};n[0]=``;function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){o=e.indexOf(`
280
+ `)}const hq=[`text`,`number`,`boolean`,`date`,`list`,`object`];d(hq);const gq=y([b(),A(),E()]),_q=te(()=>y([gq.transform(e=>String(e)),T(b(),vq),k(_q)])),vq=te(()=>y([b(),A(),E(),k(_q),T(b(),vq)]));function yq(e){if(Array.isArray(e)){let t=[];for(let n of e)n!==null&&t.push(yq(n));return t}if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e))t[n]=r===null?``:yq(r);return t}return e}const bq=D(yq,T(b(),vq));T(b(),y([vq,i()]));function xq(e){return!!(e===null||typeof e==`string`&&e===``||Array.isArray(e)&&e.length===0)}const Sq=v({docName:$v,summary:ny,content:b().optional(),...ty}).loose(),Cq=v({docName:$v,summary:ny,markdown:b(),position:d([`append`,`prepend`,`replace`]).optional(),extension:d(Ge).optional(),...ty}).loose(),wq=v({docName:$v,summary:ny,find:b().min(1),replace:b(),offset:A().int().nonnegative().optional(),...ty}).loose(),Tq=v({docName:$v,connectionId:b().min(1),scope:d([`last`,`session`,`file`,`count`]).optional(),count:A().int().positive().optional(),...ty}).loose().refine(e=>e.scope!==`count`||e.count!==void 0,{message:`count is required when scope is 'count'`,path:[`count`]}),Eq=v({value:b(),truncatedFrom:A().int().nonnegative().optional(),hint:b().optional()}).loose(),Dq=x(`kind`,[v({kind:_(`inline`),content:b()}),v({kind:_(`truncated`),byteLength:A().int().nonnegative(),hint:b()})]),Oq=v({kind:_(`content-divergence`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),divergenceType:b().optional(),currentState:Dq.optional(),hint:b().optional()}).loose(),kq=v({type:_(`orphan`),parentCandidates:k(b()),message:b()}).loose(),Aq=v({kind:_(`disk-edit-reconciled`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),mergeOutcome:b().optional(),hint:b().optional()}).loose(),jq=x(`kind`,[Oq,Aq]),Mq=x(`kind`,[Oq,Aq,v({kind:_(`mermaid-parse-error`),fenceIndex:A().int().positive(),fenceFirstLine:b(),message:b(),line:A().int().positive().optional()}).loose(),v({kind:_(`lint-violation`),source:b(),code:b(),message:b(),severity:d([`error`,`warning`,`info`,`hint`]),line:A().int().positive(),column:A().int().positive(),linkTarget:b().optional()}).loose()]),Nq=k(Mq).min(1),Pq=v({href:b(),resolvedTo:b().nullable(),reason:d([`no-such-doc`,`no-such-file`,`unresolvable`])}).loose(),Fq=k(Pq),Iq=v({timestamp:b().min(1),summary:Eq.optional(),warning:jq.optional(),warnings:Nq.optional()}).loose(),Lq=v({timestamp:b().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:k(kq).optional(),summary:Eq.optional(),warning:jq.optional(),warnings:Nq.optional(),brokenLinks:Fq}).loose(),Rq=v({timestamp:b().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:Eq.optional(),warning:jq.optional(),warnings:Nq.optional(),brokenLinks:Fq}).loose(),zq=v({docName:b().min(1),scope:d([`last`,`session`,`count`]),undone:E()}).loose(),Bq=v({docs:k(v({docName:ey,markdown:b(),position:d([`append`,`prepend`,`replace`]).optional(),extension:d(Ge).optional(),summary:ny}).loose()).min(1).max(100),...ty}).loose(),Vq=v({type:Ry,title:b(),detail:b().optional()}).loose(),Hq=x(`status`,[v({status:_(`written`),docName:b().min(1),summary:Eq.optional(),warnings:Nq.optional(),brokenLinks:Fq}).loose(),v({status:_(`error`),docName:b().min(1),error:Vq}).loose()]),Uq=v({timestamp:b().min(1),results:k(Hq),written:A().int().nonnegative(),failed:A().int().nonnegative()}).loose(),Wq=v({docName:$v,patch:T(b(),y([vq,i()])),types:T(b(),d(hq)).optional(),summary:ny,...ty}).loose(),Gq=v({timestamp:b().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:k(b()),summary:Eq.optional(),warning:jq.optional(),warnings:Nq.optional(),brokenLinks:Fq}).loose(),Kq=v({entries:k(v({level:d([`info`,`warn`,`error`]),message:b().max(8192),event:b().optional(),fields:T(b(),h()).optional(),ts:A().optional(),sourceId:b().optional(),lineNumber:A().optional()}).loose()).max(100),droppedSinceLastFlush:A().int().min(0).optional()}).loose(),qq=v({accepted:A().int().min(0)}).loose(),Jq=v({status:b().min(1),reason:b()}).loose(),Yq=v({docName:b().min(1),content:b(),lifecycle:Jq.nullable()}).loose(),Xq=v({documents:k(v({kind:d([`document`,`asset`,`folder`,`file`]).default(`document`),docName:b().min(1).optional(),docExt:b().min(1).default(`.md`),size:A().int().nonnegative(),modified:b().min(1),isSymlink:E().default(!1),canonicalDocName:b().nullable().default(null),targetPath:b().nullable().default(null),path:b().min(1).optional(),assetExt:b().min(1).optional(),mediaKind:d([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`]).nullable().optional(),referencedBy:k(b().min(1)).optional(),hasChildren:E().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:E().optional()}).loose(),Zq=v({source:b().min(1),anchor:b().nullable(),title:b(),snippet:b().nullable()}).loose(),Qq=v({docName:b().min(1),backlinks:k(Zq)}).loose(),$q=v({counts:T(b().min(1),A().int().nonnegative())}).loose(),eJ=x(`kind`,[v({kind:_(`doc`),docName:b().min(1),anchor:b().nullable(),title:b(),snippet:b().nullable()}).loose(),v({kind:_(`external`),url:b().min(1),title:b(),snippet:b().nullable()}).loose()]),tJ=v({docName:b().min(1),forwardLinks:k(eJ)}).loose(),nJ=x(`kind`,[v({id:b().min(1),kind:_(`doc`),docName:b().min(1),anchor:b().nullable(),label:b(),cluster:b().nullable(),category:b().nullable(),tags:k(b()).nullable()}).loose(),v({id:b().min(1),kind:_(`external`),url:b().min(1),label:b()}).loose()]),rJ=v({source:b().min(1),target:b().min(1)}).loose(),iJ=v({nodes:k(nJ),links:k(rJ)}).loose(),aJ=v({ts:A().int().min(0),url:b(),method:b(),ua:b().optional(),origin:b().optional(),referer:b().optional(),host:b().optional(),remote:b().optional(),secChUa:b().optional(),secChUaMobile:b().optional(),secChUaPlatform:b().optional(),secFetchSite:b().optional(),secFetchDest:b().optional(),secFetchMode:b().optional(),secFetchUser:b().optional()}).loose(),oJ=v({app:y([_(`cursor`),_(`codex`),_(`claude`),i()]),signals_fired:k(b())}).loose(),sJ=v({entries:k(aJ),count:A().int().min(0),detection:oJ}).loose(),cJ=v({writers:k(v({id:b().min(1),name:b().optional(),email:b().optional()}).loose()).optional(),summary:ny,...ty}).loose(),lJ=v({checkpointRef:b().min(1)}).loose(),uJ=v({v:A().int().optional(),id:b().min(1),name:b().min(1),colorSeed:b().optional(),docs:k(b()),summaries:k(b()).optional()}).loose(),dJ=v({entries:k(v({sha:b().min(1),timestamp:b().min(1),author:b(),authorEmail:b(),type:d([`checkpoint`,`wip`,`upstream`,`park`]),message:b(),contributors:k(uJ),checkpoint:h().nullable(),parentSha:b().nullable().optional()}).loose()),total:A().int().nonnegative().optional(),truncated:E().optional(),hasMore:E().optional()}).loose(),fJ=v({sha:b().regex(/^[0-9a-f]{40}$/i),content:b(),timestamp:b(),author:b()}).loose(),pJ=v({contentDir:b().min(1),pathSeparator:d([`/`,`\\`]),symlinkResolved:E()}).loose(),mJ=k(x(`source`,[v({docName:b().min(1),timestamp:b().min(1),size:A().int().nonnegative(),source:_(`flat`)}).loose(),v({docName:b().min(1),timestamp:b().min(1),source:_(`timeline`),sha:b().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),hJ=v({domain:b().min(1),title:b().optional(),description:b().optional(),siteName:b().optional(),faviconDataUri:b().optional()}).loose(),gJ=v({url:b()}).loose(),_J=x(`ok`,[v({ok:_(!0),metadata:hJ}).loose(),v({ok:_(!1),reason:b()}).loose()]),vJ=v({orphans:k(v({docName:b().min(1),title:b()}).loose())}).loose(),yJ=v({hubs:k(v({docName:b().min(1),title:b(),count:A().int().nonnegative()}).loose())}).loose(),bJ=v({source:b().min(1),title:b(),snippet:b().nullable()}).loose(),xJ=v({deadLinks:k(v({target:b().min(1),sources:k(bJ)}).loose())}).loose(),SJ=v({target:v({docName:b().min(1),title:b(),aliases:k(b())}).loose(),mentions:k(v({source:b().min(1),excerpt:b(),offset:A().int().nonnegative()}).loose()),truncated:E()}).loose(),CJ=v({projectPath:b().min(1)}).loose(),wJ=d([`not-a-git-worktree`,`init-failed`]),TJ=x(`ok`,[v({ok:_(!0),projectPath:b().min(1)}).loose(),v({ok:_(!1),reason:wJ,message:b().min(1)}).loose()]),EJ=v({host:b().min(1).optional()}).loose(),DJ=v({host:b().min(1).optional(),token:b().min(1)}).loose(),OJ=v({host:b(),login:b()}).loose(),kJ=v({key:b().min(1)}).loose(),AJ=v({keyPresent:E()}).loose(),jJ=d([`no_key`,`invalid_endpoint`,`rate_limit`,`timeout`,`http_error`,`network`,`dims_mismatch`,`malformed_response`]),MJ=x(`ok`,[v({ok:_(!0),endpoint:b().min(1),model:b().min(1),dimensions:A().int().positive()}).loose(),v({ok:_(!1),endpoint:b().min(1),model:b().min(1),reason:jJ,status:A().int().optional()}).loose()]),NJ=v({name:b().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:b().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),PJ=v({authenticated:E()}).loose(),FJ=v({channel:d([`login`,`gh-login`]).default(`login`)}).loose(),IJ=v({}).loose(),LJ=v({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),RJ=v({docName:b().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:k(LJ)}).loose(),zJ=v({displayName:b().min(1),color:b().min(1),icon:b().optional(),connectionId:b().min(1)}).loose(),BJ=v({sessionAlive:E(),agent:zJ.nullable(),files:k(RJ)}).loose(),VJ=v({diff:b(),before:b(),after:b(),generatedAt:A().int().min(0)}).loose(),HJ=v({}).loose(),UJ=v({}).loose(),WJ=v({}).loose(),GJ=v({}).loose(),KJ=v({}).loose(),qJ=v({}).loose(),JJ=v({displayName:b().min(1),icon:b(),color:b().min(1),currentDoc:b().nullable(),mode:d([`idle`,`writing`]),ts:A().int().min(0)}).loose(),YJ=v({presence:T(b().min(1),JJ)}).loose(),XJ=v({sessionId:b().min(1),agentType:b().min(1),ts:A().int().min(0),insertedChars:A().int().min(0),deletedChars:A().int().min(0)}).loose(),ZJ=v({effects:k(v({"doc.name":b().min(1),entries:k(XJ)}).loose())}).loose(),QJ=v({decisions:k(v({ts:A().int().min(0),decision:b().min(1),kind:b().min(1),"doc.name":b().min(1),pathRole:b().min(1)}).loose())}).loose(),$J=T(b().min(1),E()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});v({path:b().min(1,`path must be non-empty`)}).loose();const eY=v({}).loose(),tY=v({fromDocName:b().min(1),toDocName:b().min(1)}).loose(),nY=v({fromPath:b().min(1),toPath:b().min(1)}).loose(),rY=v({}).loose(),iY=v({path:b().min(1),...ty,summary:ny}).loose(),aY=v({docName:b().min(1)}).loose(),oY=v({path:b().min(1),...ty,summary:ny}).loose(),sY=v({path:b().min(1)}).loose(),cY=v({kind:d([`file`,`folder`]),path:b().min(1),...ty,summary:ny}).loose(),lY=v({kind:d([`file`,`folder`]),path:b().min(1),duplicatedDocNames:k(b().min(1))}).loose(),uY=v({pages:k(v({docName:b().min(1),title:b(),docExt:b().min(1),size:A().int().nonnegative(),modified:b().min(1),icon:b().min(1).max(2048).optional()}).loose())}).loose(),dY=v({level:A().int().min(1).max(6),text:b(),slug:b()}).loose(),fY=v({docName:b().min(1),headings:k(dY)}).loose(),pY=v({docName:b().min(1),rewrites:A().int().nonnegative()}).loose(),mY=v({kind:d([`file`,`folder`,`asset`]),fromPath:b().min(1),toPath:b().min(1),...ty,summary:ny}).loose(),hY=v({renamed:k(tY),renamedAssets:k(nY),rewrittenDocs:k(pY).optional(),summary:Eq.optional()}).loose(),gY=v({kind:d([`file`,`folder`,`asset`]),path:b().min(1),...ty}).loose(),_Y=v({deletedDocNames:k(b().min(1))}).loose(),vY=v({kind:d([`file`,`folder`,`asset`]),path:b().min(1),...ty,summary:ny}).loose(),yY=v({deletedDocNames:k(b().min(1))}).loose(),bY=v({docName:b().min(1),commitSha:b().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:ny,...ty}).loose(),xY=v({restoredFrom:b().min(1),timestamp:b().min(1),summary:Eq.optional(),warning:Oq.optional(),warnings:Nq.optional()}).loose(),SY=d([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),CY=v({label:b().min(1),webUrl:j().nullable()}).loose(),wY=x(`checkStatus`,[v({checkStatus:_(`allowed`)}).loose(),v({checkStatus:_(`denied`),deniedReason:d([`no-collaborator`,`private-no-access`,`repo-not-found`,`not-authenticated`])}).loose(),v({checkStatus:_(`unknown`),unknownError:d([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`,`ssh-unverified`]).optional()}).loose()]),TY=d([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),EY=d(O),DY=d([`succeeded`,`up-to-date`,`conflict`,`refused`,`error`]),OY=v({state:SY,lastSyncUtc:b().nullable(),lastFetchUtc:b().nullable(),lastPushedSha:b().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:E(),syncEnabled:E(),identityUnresolved:E(),remote:CY.nullable().optional(),pushError:b().optional(),pushErrorCode:TY.optional(),pullError:b().optional(),pullErrorCode:TY.optional(),pausedReason:b().optional(),pushPermission:wY.optional(),syncMode:EY.optional(),lastPullUtc:b().nullable().optional(),lastPullOutcome:DY.nullable().optional()}).loose(),kY=v({op:d([`sync`,`push`,`pull`]).optional()}).loose(),AY=v({op:d([`sync`,`push`,`pull`])}).loose(),jY=v({conflicts:k(v({file:b().min(1),detectedAt:b().min(1),oursSha:b().optional(),theirsSha:b().optional(),baseSha:b().optional()}).loose())}).loose(),MY=v({file:b().min(1),strategy:d([`mine`,`theirs`,`content`,`delete`]),content:b().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`]}),NY=v({}).loose(),PY=v({file:b().min(1),base:b(),ours:b(),theirs:b(),kind:d([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:b().nullable()}).loose(),FY=v({plan:ee(e=>e!==void 0,{message:`plan is required`})}).loose(),IY=v({plan:ee(e=>e!==void 0,{message:`plan is required`})}).loose(),LY=v({result:ee(e=>e!==void 0,{message:`result is required`})}).loose(),RY=v({path:b().min(1),summary:b().min(1)}).loose(),zY=v({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),BY=v({packs:k(v({id:b().min(1),name:b().min(1),description:b().min(1),defaultSubfolder:b().optional(),folders:k(RY),entryCounts:zY}).loose())}).loose(),VY=v({noOpen:E().optional(),out:b().min(1).optional()}).loose(),HY=v({reason:d([`unsupported-platform`,`spawn-error`]),message:b()}).loose(),UY=x(`status`,[v({status:_(`installed`),outputPath:b(),size:A().int().nonnegative(),sha256:b(),skillVersion:b()}).loose(),v({status:_(`built`),outputPath:b(),size:A().int().nonnegative(),sha256:b(),skillVersion:b(),handoffError:HY.optional()}).loose(),v({status:_(`failed`),buildError:b()}).loose(),v({status:_(`skip-current`),skillVersion:b(),recordedAt:b().optional()}).loose()]),WY=[`.ok`,`skill-targets.json`],GY=d(Ze),KY=w({schema:_(1),targets:k(GY).default([])});function qY(e){let t;try{t=JSON.parse(e)}catch{return null}let n=KY.safeParse(t);return n.success?n.data:null}const JY=v({tags:k(v({name:b().min(1),count:A().int().nonnegative(),isLeaf:E()}).loose())}).loose(),YY=v({docName:b().min(1),title:b(),matchingTags:k(b().min(1)),snippet:b().nullable()}).loose(),XY=v({name:b().min(1),docs:k(YY)}).loose(),ZY=v({folder:h(),frontmatter_local:T(b(),h()).nullable()}).loose(),QY=v({path:b(),frontmatter:T(b(),h()).optional()}).loose(),$Y=v({applied:h()}).loose(),eX=T(b(),h()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),tX=v({template:v({name:b().min(1),folder:b(),scope:d([`local`,`inherited`]),path:b().min(1),frontmatter:eX,body:b()}).strict()}).strict(),nX=v({templates:k(v({name:b().min(1),title:b().optional(),description:b().optional(),path:b().min(1),source_folder:b()}).strict()),truncated:E()}).strict(),rX=v({folder:b(),name:b(),body:b().optional(),frontmatter:eX.optional(),...ty,summary:ny}).strict(),iX=v({path:b().min(1),created:E(),warnings:k(b())}).strict(),aX=v({sourcePath:b().min(1),targetFolder:b(),name:b().optional(),title:b().optional(),deleteSource:E().optional(),...ty,summary:ny}).strict(),oX=v({path:b().min(1),created:E(),warnings:k(b())}).strict(),sX=v({existed:E(),path:b().min(1)}).strict(),cX=v({fromFolder:b(),fromName:b(),toFolder:b(),toName:b(),body:b().optional(),frontmatter:eX.optional(),...ty,summary:ny}).strict(),lX=v({from:b().min(1),to:b().min(1),committed:E()}).strict(),uX=d(Ae),dX=/^[a-z0-9-]+$/,fX=/<\/?[A-Za-z][^>]*>/;function pX(e){return fX.test(e)}const mX=/^[A-Za-z0-9_-]+$/,hX=v({name:b(),description:b()}).strict(),gX=v({skill:v({name:b().min(1),scope:uX,path:b().min(1),frontmatter:hX,body:b(),files:k(v({path:b().min(1),text:b().nullable()})).optional(),managed:E().optional()}).strict()}).strict(),_X=v({skills:k(v({name:b().min(1),description:b().optional(),scope:uX,path:b().min(1),absolutePath:b().min(1).optional(),installed:E(),hosts:k(b()),installedVersion:b().optional(),bundledVersion:b().optional(),updateAvailable:E().optional(),managed:E().optional()}).strict()),truncated:E()}).strict(),vX=v({scope:uX.default(`project`),name:b(),body:b().optional(),frontmatter:hX,...ty,summary:ny}).strict(),yX=v({path:b().min(1),created:E(),warnings:k(b())}).strict(),bX=v({scope:uX.default(`project`),name:b(),...ty,summary:ny}).strict(),xX=v({name:b().min(1),version:b().min(1),previousVersion:b().optional(),checkpointRef:b().optional()}).strict(),SX=v({existed:E(),path:b().min(1)}).strict(),CX=v({scope:uX.default(`project`),fromName:b(),toName:b(),body:b().optional(),frontmatter:hX.optional(),...ty,summary:ny}).strict(),wX=v({from:b().min(1),to:b().min(1),committed:E()}).strict(),TX=d([`reference`,`script`]),EX=v({scope:uX.default(`project`),name:b(),path:b().min(1),content:b(),...ty,summary:ny}).strict(),DX=v({path:b().min(1),created:E(),kind:TX,content:E()}).strict(),OX=v({path:b().min(1),kind:TX,text:b()}).strict(),kX=v({path:b().min(1),existed:E(),kind:TX}).strict(),AX=v({scope:uX.default(`project`),name:b(),targets:k(GY).optional().meta({description:`Explicit editor ids to install into; omit to use project-configured editors.`}),...ty,summary:ny}).strict(),jX=v({name:b().min(1),hosts:k(b()),scripts:E(),warnings:k(b()),warningCodes:k(d([`no-targets`,`scripts-present`]))}).strict(),MX=v({scope:uX.default(`project`),name:b()}).strict(),NX=v({name:b().min(1),uninstalled:E()}).strict(),PX=v({targets:k(GY),configured:E()}).strict(),FX=v({targets:k(GY)}).strict(),IX=v({targets:k(GY),reprojected:k(v({name:b(),hosts:k(b())}).strict()),bundleHosts:k(b()),removedFrom:k(b())}).strict(),LX=v({scope:uX.default(`project`),name:b(),version:b().regex(/^[0-9a-f]{40}$/i),...ty,summary:ny}).strict(),RX=v({name:b().min(1),version:b(),restoredFiles:k(b()),warnings:k(b())}).strict(),zX=v({query:b().optional(),intent:d([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:d([`navigation`,`relevance`]).optional(),scopes:k(d([`page`,`folder`,`content`,`file`])).optional(),scope:b().optional(),limit:A().int().nonnegative().optional(),semantic:E().optional(),source:d([`omnibar`,`mcp`,`http`]).optional()}).loose(),BX=v({kind:d([`page`,`folder`,`content`,`file`]),path:b().min(1),title:b(),score:A(),signals:T(b(),h()),snippet:b().optional()}).loose(),VX=v({capable:E(),applied:E(),coverage:v({embedded:A().int().nonnegative(),total:A().int().nonnegative()})}).loose(),HX=v({enabled:E(),keyPresent:E(),keyNotRequired:E(),keySource:d([`project`,`file`,`env`]).nullable(),keyHint:b().nullable(),ready:E(),capable:E(),embedded:A().int().nonnegative(),total:A().int().nonnegative()}).loose(),UX=v({query:b(),intent:d([`autocomplete`,`full_text`,`omnibar`]),results:k(BX),elapsedMs:A().nonnegative(),semantic:VX.optional(),truncated:E().optional(),ready:E().optional()}).loose(),WX=v({version:b().min(1),recordedAt:b().min(1)}).loose(),GX=v({currentVersion:b().min(1),targets:T(b(),WX.nullable())}).loose(),KX=`server-info`,qX=`branch-switched`,JX=`disk-ack`,YX=`config-validation-rejected`,XX=`config-ignore-nested-error`,ZX=d([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`,`lint-config`]),QX=v({v:_(1),ch:_(KX),seq:A(),serverInstanceId:b().min(1),currentBranch:b().min(1).optional()}).loose(),$X=v({v:_(1),ch:_(qX),seq:A(),branch:b().min(1)}).loose(),eZ=v({v:_(1),ch:ZX,seq:A()}).loose(),tZ=v({v:_(1),ch:_(JX),seq:A(),docName:b().min(1),sv:b().min(1)}).loose(),nZ=v({v:_(1),ch:_(YX),seq:A(),docName:b().min(1),error:g}).loose(),rZ=v({v:_(1),ch:_(XX),seq:A(),path:b().min(1),error:b().min(1)}).loose();function iZ(e){let t=e?.trim();return t===void 0||t===``?void 0:t}function aZ(e){return e.reason!==void 0||iZ(e.note)!==void 0||iZ(e.email)!==void 0}function oZ(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol===`https:`)return t;let n=t.hostname===`localhost`||t.hostname===`127.0.0.1`||t.hostname===`[::1]`;return t.protocol===`http:`&&n?t:null}function sZ(){return oZ((typeof process>`u`?void 0:iZ(process.env?.OK_FEEDBACK_INTAKE_ORIGIN))??`https://openknowledge.ai`)}function cZ(e){let t=iZ(e);if(t!==void 0)return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?t:void 0}async function lZ(e,t,n){try{let r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t),signal:AbortSignal.timeout(n)});if(r.ok){let e=await r.json().catch(()=>null);return{ok:!0,reference:typeof e?.reference==`string`?e.reference:``}}return r.status===400||r.status===413?{ok:!1,reason:`invalid`}:r.status===503?{ok:!1,reason:`unavailable`}:{ok:!1,reason:`error`}}catch(e){return{ok:!1,reason:e instanceof Error&&(e.name===`TimeoutError`||e.name===`AbortError`)?`timeout`:`error`}}}async function uZ(e,t={}){let n=sZ();if(n===null)return{ok:!1,reason:`error`};let r=new URL(`/api/feedback`,n),i=iZ(e.note),a=cZ(e.email),o={kind:`uninstall`,reasons:e.reason===void 0?[]:[e.reason],...i===void 0?{}:{message:i},appVersion:e.appVersion,platform:e.platform,source:e.source},s=Date.now()+(t.timeoutMs??4e3),c=()=>s-Date.now();if(a===void 0)return lZ(r,o,c());let l=await lZ(r,{...o,email:a},c());return l.ok||l.reason!==`invalid`||c()<=0?l:lZ(r,o,c())}var dZ=t(r(((e,t)=>{var n=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},r=-1,i=1,a=0;n.Diff=function(e,t){return[e,t]},n.prototype.diff_main=function(e,t,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+this.Diff_Timeout*1e3);var o=i;if(e==null||t==null)throw Error(`Null input. (diff_main)`);if(e==t)return e?[new n.Diff(a,e)]:[];r===void 0&&(r=!0);var s=r,c=this.diff_commonPrefix(e,t),l=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=this.diff_commonSuffix(e,t);var u=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var d=this.diff_compute_(e,t,s,o);return l&&d.unshift(new n.Diff(a,l)),u&&d.push(new n.Diff(a,u)),this.diff_cleanupMerge(d),d},n.prototype.diff_compute_=function(e,t,o,s){var c;if(!e)return[new n.Diff(i,t)];if(!t)return[new n.Diff(r,e)];var l=e.length>t.length?e:t,u=e.length>t.length?t:e,d=l.indexOf(u);if(d!=-1)return c=[new n.Diff(i,l.substring(0,d)),new n.Diff(a,u),new n.Diff(i,l.substring(d+u.length))],e.length>t.length&&(c[0][0]=c[2][0]=r),c;if(u.length==1)return[new n.Diff(r,e),new n.Diff(i,t)];var f=this.diff_halfMatch_(e,t);if(f){var p=f[0],m=f[1],h=f[2],g=f[3],_=f[4],v=this.diff_main(p,h,o,s),y=this.diff_main(m,g,o,s);return v.concat([new n.Diff(a,_)],y)}return o&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,s):this.diff_bisect_(e,t,s)},n.prototype.diff_lineMode_=function(e,t,o){var s=this.diff_linesToChars_(e,t);e=s.chars1,t=s.chars2;var c=s.lineArray,l=this.diff_main(e,t,!1,o);this.diff_charsToLines_(l,c),this.diff_cleanupSemantic(l),l.push(new n.Diff(a,``));for(var u=0,d=0,f=0,p=``,m=``;u<l.length;){switch(l[u][0]){case i:f++,m+=l[u][1];break;case r:d++,p+=l[u][1];break;case a:if(d>=1&&f>=1){l.splice(u-d-f,d+f),u=u-d-f;for(var h=this.diff_main(p,m,!1,o),g=h.length-1;g>=0;g--)l.splice(u,0,h[g]);u+=h.length}f=0,d=0,p=``,m=``;break}u++}return l.pop(),l},n.prototype.diff_bisect_=function(e,t,a){for(var o=e.length,s=t.length,c=Math.ceil((o+s)/2),l=c,u=2*c,d=Array(u),f=Array(u),p=0;p<u;p++)d[p]=-1,f[p]=-1;d[l+1]=0,f[l+1]=0;for(var m=o-s,h=m%2!=0,g=0,_=0,v=0,y=0,b=0;b<c&&!(new Date().getTime()>a);b++){for(var x=-b+g;x<=b-_;x+=2){for(var S=l+x,C=x==-b||x!=b&&d[S-1]<d[S+1]?d[S+1]:d[S-1]+1,w=C-x;C<o&&w<s&&e.charAt(C)==t.charAt(w);)C++,w++;if(d[S]=C,C>o)_+=2;else if(w>s)g+=2;else if(h){var T=l+m-x;if(T>=0&&T<u&&f[T]!=-1){var E=o-f[T];if(C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}for(var D=-b+v;D<=b-y;D+=2){for(var T=l+D,E=D==-b||D!=b&&f[T-1]<f[T+1]?f[T+1]:f[T-1]+1,O=E-D;E<o&&O<s&&e.charAt(o-E-1)==t.charAt(s-O-1);)E++,O++;if(f[T]=E,E>o)y+=2;else if(O>s)v+=2;else if(!h){var S=l+m-D;if(S>=0&&S<u&&d[S]!=-1){var C=d[S],w=l+C-S;if(E=o-E,C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}}return[new n.Diff(r,e),new n.Diff(i,t)]},n.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},n.prototype.diff_linesToChars_=function(e,t){var n=[],r={};n[0]=``;function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){o=e.indexOf(`
281
281
  `,i),o==-1&&(o=e.length-1);var c=e.substring(i,o+1);(r.hasOwnProperty?r.hasOwnProperty(c):r[c]!==void 0)?t+=String.fromCharCode(r[c]):(s==a&&(c=e.substring(i),o=e.length),t+=String.fromCharCode(s),r[c]=s,n[s++]=c),i=o+1}return t}var a=4e4,o=i(e);return a=65535,{chars1:o,chars2:i(t),lineArray:n}},n.prototype.diff_charsToLines_=function(e,t){for(var n=0;n<e.length;n++){for(var r=e[n][1],i=[],a=0;a<r.length;a++)i[a]=t[r.charCodeAt(a)];e[n][1]=i.join(``)}},n.prototype.diff_commonPrefix=function(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return i},n.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return i},n.prototype.diff_commonOverlap_=function(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,(c==0||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}},n.prototype.diff_halfMatch_=function(e,t){if(this.Diff_Timeout<=0)return null;var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;var i=this;function a(e,t,n){for(var r=e.substring(n,n+Math.floor(e.length/4)),a=-1,o=``,s,c,l,u;(a=t.indexOf(r,a+1))!=-1;){var d=i.diff_commonPrefix(e.substring(n),t.substring(a)),f=i.diff_commonSuffix(e.substring(0,n),t.substring(0,a));o.length<f+d&&(o=t.substring(a-f,a)+t.substring(a,a+d),s=e.substring(0,n-f),c=e.substring(n+d),l=t.substring(0,a-f),u=t.substring(a+d))}return o.length*2>=e.length?[s,c,l,u,o]:null}var o=a(n,r,Math.ceil(n.length/4)),s=a(n,r,Math.ceil(n.length/2)),c;if(!o&&!s)return null;c=s?o&&o[4].length>s[4].length?o:s:o;var l,u,d,f;e.length>t.length?(l=c[0],u=c[1],d=c[2],f=c[3]):(d=c[0],f=c[1],l=c[2],u=c[3]);var p=c[4];return[l,u,d,f,p]},n.prototype.diff_cleanupSemantic=function(e){for(var t=!1,o=[],s=0,c=null,l=0,u=0,d=0,f=0,p=0;l<e.length;)e[l][0]==a?(o[s++]=l,u=f,d=p,f=0,p=0,c=e[l][1]):(e[l][0]==i?f+=e[l][1].length:p+=e[l][1].length,c&&c.length<=Math.max(u,d)&&c.length<=Math.max(f,p)&&(e.splice(o[s-1],0,new n.Diff(r,c)),e[o[s-1]+1][0]=i,s--,s--,l=s>0?o[s-1]:-1,u=0,d=0,f=0,p=0,c=null,t=!0)),l++;for(t&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),l=1;l<e.length;){if(e[l-1][0]==r&&e[l][0]==i){var m=e[l-1][1],h=e[l][1],g=this.diff_commonOverlap_(m,h),_=this.diff_commonOverlap_(h,m);g>=_?(g>=m.length/2||g>=h.length/2)&&(e.splice(l,0,new n.Diff(a,h.substring(0,g))),e[l-1][1]=m.substring(0,m.length-g),e[l+1][1]=h.substring(g),l++):(_>=m.length/2||_>=h.length/2)&&(e.splice(l,0,new n.Diff(a,m.substring(0,_))),e[l-1][0]=i,e[l-1][1]=h.substring(0,h.length-_),e[l+1][0]=r,e[l+1][1]=m.substring(_),l++),l++}l++}},n.prototype.diff_cleanupSemanticLossless=function(e){function t(e,t){if(!e||!t)return 6;var r=e.charAt(e.length-1),i=t.charAt(0),a=r.match(n.nonAlphaNumericRegex_),o=i.match(n.nonAlphaNumericRegex_),s=a&&r.match(n.whitespaceRegex_),c=o&&i.match(n.whitespaceRegex_),l=s&&r.match(n.linebreakRegex_),u=c&&i.match(n.linebreakRegex_),d=l&&e.match(n.blanklineEndRegex_),f=u&&t.match(n.blanklineStartRegex_);return d||f?5:l||u?4:a&&!s&&c?3:s||c?2:a||o?1:0}for(var r=1;r<e.length-1;){if(e[r-1][0]==a&&e[r+1][0]==a){var i=e[r-1][1],o=e[r][1],s=e[r+1][1],c=this.diff_commonSuffix(i,o);if(c){var l=o.substring(o.length-c);i=i.substring(0,i.length-c),o=l+o.substring(0,o.length-c),s=l+s}for(var u=i,d=o,f=s,p=t(i,o)+t(o,s);o.charAt(0)===s.charAt(0);){i+=o.charAt(0),o=o.substring(1)+s.charAt(0),s=s.substring(1);var m=t(i,o)+t(o,s);m>=p&&(p=m,u=i,d=o,f=s)}e[r-1][1]!=u&&(u?e[r-1][1]=u:(e.splice(r-1,1),r--),e[r][1]=d,f?e[r+1][1]=f:(e.splice(r+1,1),r--))}r++}},n.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,n.whitespaceRegex_=/\s/,n.linebreakRegex_=/[\r\n]/,n.blanklineEndRegex_=/\n\r?\n$/,n.blanklineStartRegex_=/^\r?\n\r?\n/,n.prototype.diff_cleanupEfficiency=function(e){for(var t=!1,o=[],s=0,c=null,l=0,u=!1,d=!1,f=!1,p=!1;l<e.length;)e[l][0]==a?(e[l][1].length<this.Diff_EditCost&&(f||p)?(o[s++]=l,u=f,d=p,c=e[l][1]):(s=0,c=null),f=p=!1):(e[l][0]==r?p=!0:f=!0,c&&(u&&d&&f&&p||c.length<this.Diff_EditCost/2&&u+d+f+p==3)&&(e.splice(o[s-1],0,new n.Diff(r,c)),e[o[s-1]+1][0]=i,s--,c=null,u&&d?(f=p=!0,s=0):(s--,l=s>0?o[s-1]:-1,f=p=!1),t=!0)),l++;t&&this.diff_cleanupMerge(e)},n.prototype.diff_cleanupMerge=function(e){e.push(new n.Diff(a,``));for(var t=0,o=0,s=0,c=``,l=``,u;t<e.length;)switch(e[t][0]){case i:s++,l+=e[t][1],t++;break;case r:o++,c+=e[t][1],t++;break;case a:o+s>1?(o!==0&&s!==0&&(u=this.diff_commonPrefix(l,c),u!==0&&(t-o-s>0&&e[t-o-s-1][0]==a?e[t-o-s-1][1]+=l.substring(0,u):(e.splice(0,0,new n.Diff(a,l.substring(0,u))),t++),l=l.substring(u),c=c.substring(u)),u=this.diff_commonSuffix(l,c),u!==0&&(e[t][1]=l.substring(l.length-u)+e[t][1],l=l.substring(0,l.length-u),c=c.substring(0,c.length-u))),t-=o+s,e.splice(t,o+s),c.length&&(e.splice(t,0,new n.Diff(r,c)),t++),l.length&&(e.splice(t,0,new n.Diff(i,l)),t++),t++):t!==0&&e[t-1][0]==a?(e[t-1][1]+=e[t][1],e.splice(t,1)):t++,s=0,o=0,c=``,l=``;break}e[e.length-1][1]===``&&e.pop();var d=!1;for(t=1;t<e.length-1;)e[t-1][0]==a&&e[t+1][0]==a&&(e[t][1].substring(e[t][1].length-e[t-1][1].length)==e[t-1][1]?(e[t][1]=e[t-1][1]+e[t][1].substring(0,e[t][1].length-e[t-1][1].length),e[t+1][1]=e[t-1][1]+e[t+1][1],e.splice(t-1,1),d=!0):e[t][1].substring(0,e[t+1][1].length)==e[t+1][1]&&(e[t-1][1]+=e[t+1][1],e[t][1]=e[t][1].substring(e[t+1][1].length)+e[t+1][1],e.splice(t+1,1),d=!0)),t++;d&&this.diff_cleanupMerge(e)},n.prototype.diff_xIndex=function(e,t){var n=0,a=0,o=0,s=0,c;for(c=0;c<e.length&&(e[c][0]!==i&&(n+=e[c][1].length),e[c][0]!==r&&(a+=e[c][1].length),!(n>t));c++)o=n,s=a;return e.length!=c&&e[c][0]===r?s:s+(t-o)},n.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,o=/</g,s=/>/g,c=/\n/g,l=0;l<e.length;l++){var u=e[l][0],d=e[l][1].replace(n,`&amp;`).replace(o,`&lt;`).replace(s,`&gt;`).replace(c,`&para;<br>`);switch(u){case i:t[l]=`<ins style="background:#e6ffe6;">`+d+`</ins>`;break;case r:t[l]=`<del style="background:#ffe6e6;">`+d+`</del>`;break;case a:t[l]=`<span>`+d+`</span>`;break}}return t.join(``)},n.prototype.diff_text1=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==i&&(t[n]=e[n][1]);return t.join(``)},n.prototype.diff_text2=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==r&&(t[n]=e[n][1]);return t.join(``)},n.prototype.diff_levenshtein=function(e){for(var t=0,n=0,o=0,s=0;s<e.length;s++){var c=e[s][0],l=e[s][1];switch(c){case i:n+=l.length;break;case r:o+=l.length;break;case a:t+=Math.max(n,o),n=0,o=0;break}}return t+=Math.max(n,o),t},n.prototype.diff_toDelta=function(e){for(var t=[],n=0;n<e.length;n++)switch(e[n][0]){case i:t[n]=`+`+encodeURI(e[n][1]);break;case r:t[n]=`-`+e[n][1].length;break;case a:t[n]=`=`+e[n][1].length;break}return t.join(` `).replace(/%20/g,` `)},n.prototype.diff_fromDelta=function(e,t){for(var o=[],s=0,c=0,l=t.split(/\t/g),u=0;u<l.length;u++){var d=l[u].substring(1);switch(l[u].charAt(0)){case`+`:try{o[s++]=new n.Diff(i,decodeURI(d))}catch{throw Error(`Illegal escape in diff_fromDelta: `+d)}break;case`-`:case`=`:var f=parseInt(d,10);if(isNaN(f)||f<0)throw Error(`Invalid number in diff_fromDelta: `+d);var p=e.substring(c,c+=f);l[u].charAt(0)==`=`?o[s++]=new n.Diff(a,p):o[s++]=new n.Diff(r,p);break;default:if(l[u])throw Error(`Invalid diff operation in diff_fromDelta: `+l[u])}}if(c!=e.length)throw Error(`Delta length (`+c+`) does not equal source text length (`+e.length+`).`);return o},n.prototype.match_main=function(e,t,n){if(e==null||t==null||n==null)throw Error(`Null input. (match_main)`);return n=Math.max(0,Math.min(n,e.length)),e==t?0:e.length?e.substring(n,n+t.length)==t?n:this.match_bitap_(e,t,n):-1},n.prototype.match_bitap_=function(e,t,n){if(t.length>this.Match_MaxBits)throw Error(`Pattern too long for this browser.`);var r=this.match_alphabet_(t),i=this;function a(e,r){var a=e/t.length,o=Math.abs(n-r);return i.Match_Distance?a+o/i.Match_Distance:o?1:a}var o=this.Match_Threshold,s=e.indexOf(t,n);s!=-1&&(o=Math.min(a(0,s),o),s=e.lastIndexOf(t,n+t.length),s!=-1&&(o=Math.min(a(0,s),o)));var c=1<<t.length-1;s=-1;for(var l,u,d=t.length+e.length,f,p=0;p<t.length;p++){for(l=0,u=d;l<u;)a(p,n+u)<=o?l=u:d=u,u=Math.floor((d-l)/2+l);d=u;var m=Math.max(1,n-u+1),h=Math.min(n+u,e.length)+t.length,g=Array(h+2);g[h+1]=(1<<p)-1;for(var _=h;_>=m;_--){var v=r[e.charAt(_-1)];if(p===0?g[_]=(g[_+1]<<1|1)&v:g[_]=(g[_+1]<<1|1)&v|(f[_+1]|f[_])<<1|1|f[_+1],g[_]&c){var y=a(p,_-1);if(y<=o)if(o=y,s=_-1,s>n)m=Math.max(1,2*n-s);else break}}if(a(p+1,n)>o)break;f=g}return s},n.prototype.match_alphabet_=function(e){for(var t={},n=0;n<e.length;n++)t[e.charAt(n)]=0;for(var n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t},n.prototype.patch_addContext_=function(e,t){if(t.length!=0){if(e.start2===null)throw Error(`patch not initialized`);for(var r=t.substring(e.start2,e.start2+e.length1),i=0;t.indexOf(r)!=t.lastIndexOf(r)&&r.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)i+=this.Patch_Margin,r=t.substring(e.start2-i,e.start2+e.length1+i);i+=this.Patch_Margin;var o=t.substring(e.start2-i,e.start2);o&&e.diffs.unshift(new n.Diff(a,o));var s=t.substring(e.start2+e.length1,e.start2+e.length1+i);s&&e.diffs.push(new n.Diff(a,s)),e.start1-=o.length,e.start2-=o.length,e.length1+=o.length+s.length,e.length2+=o.length+s.length}},n.prototype.patch_make=function(e,t,o){var s,c;if(typeof e==`string`&&typeof t==`string`&&o===void 0)s=e,c=this.diff_main(s,t,!0),c.length>2&&(this.diff_cleanupSemantic(c),this.diff_cleanupEfficiency(c));else if(e&&typeof e==`object`&&t===void 0&&o===void 0)c=e,s=this.diff_text1(c);else if(typeof e==`string`&&t&&typeof t==`object`&&o===void 0)s=e,c=t;else if(typeof e==`string`&&typeof t==`string`&&o&&typeof o==`object`)s=e,c=o;else throw Error(`Unknown call format to patch_make.`);if(c.length===0)return[];for(var l=[],u=new n.patch_obj,d=0,f=0,p=0,m=s,h=s,g=0;g<c.length;g++){var _=c[g][0],v=c[g][1];switch(!d&&_!==a&&(u.start1=f,u.start2=p),_){case i:u.diffs[d++]=c[g],u.length2+=v.length,h=h.substring(0,p)+v+h.substring(p);break;case r:u.length1+=v.length,u.diffs[d++]=c[g],h=h.substring(0,p)+h.substring(p+v.length);break;case a:v.length<=2*this.Patch_Margin&&d&&c.length!=g+1?(u.diffs[d++]=c[g],u.length1+=v.length,u.length2+=v.length):v.length>=2*this.Patch_Margin&&d&&(this.patch_addContext_(u,m),l.push(u),u=new n.patch_obj,d=0,m=h,f=p);break}_!==i&&(f+=v.length),_!==r&&(p+=v.length)}return d&&(this.patch_addContext_(u,m),l.push(u)),l},n.prototype.patch_deepCopy=function(e){for(var t=[],r=0;r<e.length;r++){var i=e[r],a=new n.patch_obj;a.diffs=[];for(var o=0;o<i.diffs.length;o++)a.diffs[o]=new n.Diff(i.diffs[o][0],i.diffs[o][1]);a.start1=i.start1,a.start2=i.start2,a.length1=i.length1,a.length2=i.length2,t[r]=a}return t},n.prototype.patch_apply=function(e,t){if(e.length==0)return[t,[]];e=this.patch_deepCopy(e);var n=this.patch_addPadding(e);t=n+t+n,this.patch_splitMax(e);for(var o=0,s=[],c=0;c<e.length;c++){var l=e[c].start2+o,u=this.diff_text1(e[c].diffs),d,f=-1;if(u.length>this.Match_MaxBits?(d=this.match_main(t,u.substring(0,this.Match_MaxBits),l),d!=-1&&(f=this.match_main(t,u.substring(u.length-this.Match_MaxBits),l+u.length-this.Match_MaxBits),(f==-1||d>=f)&&(d=-1))):d=this.match_main(t,u,l),d==-1)s[c]=!1,o-=e[c].length2-e[c].length1;else{s[c]=!0,o=d-l;var p=f==-1?t.substring(d,d+u.length):t.substring(d,f+this.Match_MaxBits);if(u==p)t=t.substring(0,d)+this.diff_text2(e[c].diffs)+t.substring(d+u.length);else{var m=this.diff_main(u,p,!1);if(u.length>this.Match_MaxBits&&this.diff_levenshtein(m)/u.length>this.Patch_DeleteThreshold)s[c]=!1;else{this.diff_cleanupSemanticLossless(m);for(var h=0,g,_=0;_<e[c].diffs.length;_++){var v=e[c].diffs[_];v[0]!==a&&(g=this.diff_xIndex(m,h)),v[0]===i?t=t.substring(0,d+g)+v[1]+t.substring(d+g):v[0]===r&&(t=t.substring(0,d+g)+t.substring(d+this.diff_xIndex(m,h+v[1].length))),v[0]!==r&&(h+=v[1].length)}}}}}return t=t.substring(n.length,t.length-n.length),[t,s]},n.prototype.patch_addPadding=function(e){for(var t=this.Patch_Margin,r=``,i=1;i<=t;i++)r+=String.fromCharCode(i);for(var i=0;i<e.length;i++)e[i].start1+=t,e[i].start2+=t;var o=e[0],s=o.diffs;if(s.length==0||s[0][0]!=a)s.unshift(new n.Diff(a,r)),o.start1-=t,o.start2-=t,o.length1+=t,o.length2+=t;else if(t>s[0][1].length){var c=t-s[0][1].length;s[0][1]=r.substring(s[0][1].length)+s[0][1],o.start1-=c,o.start2-=c,o.length1+=c,o.length2+=c}if(o=e[e.length-1],s=o.diffs,s.length==0||s[s.length-1][0]!=a)s.push(new n.Diff(a,r)),o.length1+=t,o.length2+=t;else if(t>s[s.length-1][1].length){var c=t-s[s.length-1][1].length;s[s.length-1][1]+=r.substring(0,c),o.length1+=c,o.length2+=c}return r},n.prototype.patch_splitMax=function(e){for(var t=this.Match_MaxBits,o=0;o<e.length;o++)if(!(e[o].length1<=t)){var s=e[o];e.splice(o--,1);for(var c=s.start1,l=s.start2,u=``;s.diffs.length!==0;){var d=new n.patch_obj,f=!0;for(d.start1=c-u.length,d.start2=l-u.length,u!==``&&(d.length1=d.length2=u.length,d.diffs.push(new n.Diff(a,u)));s.diffs.length!==0&&d.length1<t-this.Patch_Margin;){var p=s.diffs[0][0],m=s.diffs[0][1];p===i?(d.length2+=m.length,l+=m.length,d.diffs.push(s.diffs.shift()),f=!1):p===r&&d.diffs.length==1&&d.diffs[0][0]==a&&m.length>2*t?(d.length1+=m.length,c+=m.length,f=!1,d.diffs.push(new n.Diff(p,m)),s.diffs.shift()):(m=m.substring(0,t-d.length1-this.Patch_Margin),d.length1+=m.length,c+=m.length,p===a?(d.length2+=m.length,l+=m.length):f=!1,d.diffs.push(new n.Diff(p,m)),m==s.diffs[0][1]?s.diffs.shift():s.diffs[0][1]=s.diffs[0][1].substring(m.length))}u=this.diff_text2(d.diffs),u=u.substring(u.length-this.Patch_Margin);var h=this.diff_text1(s.diffs).substring(0,this.Patch_Margin);h!==``&&(d.length1+=h.length,d.length2+=h.length,d.diffs.length!==0&&d.diffs[d.diffs.length-1][0]===a?d.diffs[d.diffs.length-1][1]+=h:d.diffs.push(new n.Diff(a,h))),f||e.splice(++o,0,d)}}},n.prototype.patch_toText=function(e){for(var t=[],n=0;n<e.length;n++)t[n]=e[n];return t.join(``)},n.prototype.patch_fromText=function(e){var t=[];if(!e)return t;for(var o=e.split(`
282
282
  `),s=0,c=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;s<o.length;){var l=o[s].match(c);if(!l)throw Error(`Invalid patch string: `+o[s]);var u=new n.patch_obj;for(t.push(u),u.start1=parseInt(l[1],10),l[2]===``?(u.start1--,u.length1=1):l[2]==`0`?u.length1=0:(u.start1--,u.length1=parseInt(l[2],10)),u.start2=parseInt(l[3],10),l[4]===``?(u.start2--,u.length2=1):l[4]==`0`?u.length2=0:(u.start2--,u.length2=parseInt(l[4],10)),s++;s<o.length;){var d=o[s].charAt(0);try{var f=decodeURI(o[s].substring(1))}catch{throw Error(`Illegal escape in patch_fromText: `+f)}if(d==`-`)u.diffs.push(new n.Diff(r,f));else if(d==`+`)u.diffs.push(new n.Diff(i,f));else if(d==` `)u.diffs.push(new n.Diff(a,f));else if(d==`@`)break;else if(d!==``)throw Error(`Invalid patch mode "`+d+`" in: `+f);s++}}return t},n.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0},n.patch_obj.prototype.toString=function(){for(var e=this.length1===0?this.start1+`,0`:this.length1==1?this.start1+1:this.start1+1+`,`+this.length1,t=this.length2===0?this.start2+`,0`:this.length2==1?this.start2+1:this.start2+1+`,`+this.length2,n=[`@@ -`+e+` +`+t+` @@
283
283
  `],o,s=0;s<this.diffs.length;s++){switch(this.diffs[s][0]){case i:o=`+`;break;case r:o=`-`;break;case a:o=` `;break}n[s+1]=o+encodeURI(this.diffs[s][1])+`
284
- `}return n.join(``).replace(/%20/g,` `)},t.exports=n,t.exports.diff_match_patch=n,t.exports.DIFF_DELETE=r,t.exports.DIFF_INSERT=i,t.exports.DIFF_EQUAL=a}))(),1);const dZ=new uZ.default;function fZ(e,t){if(e===t)return[{value:e}];let{chars1:n,chars2:r,lineArray:i}=dZ.diff_linesToChars_(e,t),a=dZ.diff_main(n,r,!1);dZ.diff_charsToLines_(a,i);let o=[];for(let[e,t]of a){if(t.length===0)continue;let n=o[o.length-1],r=e===uZ.default.DIFF_DELETE,i=e===uZ.default.DIFF_INSERT;if(n&&!!n.removed===r&&!!n.added===i){n.value+=t;continue}r?o.push({value:t,removed:!0}):i?o.push({value:t,added:!0}):o.push({value:t})}return o}const pZ=256*1024;function mZ(e,t,n){if(t===n)return;let r=fZ(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 hZ(e,t,n){if(t===n)return;if(t.length>pZ||n.length>pZ){gZ(e,t,n);return}let r=fZ(t,n),i=0;for(let t of r)t.removed?e.delete(i,t.value.length):(t.added&&e.insert(i,t.value),i+=t.value.length)}function gZ(e,t,n){let r=0,i=Math.min(t.length,n.length);for(;r<i&&t.charCodeAt(r)===n.charCodeAt(r);)r++;r>0&&(r=t.lastIndexOf(`
284
+ `}return n.join(``).replace(/%20/g,` `)},t.exports=n,t.exports.diff_match_patch=n,t.exports.DIFF_DELETE=r,t.exports.DIFF_INSERT=i,t.exports.DIFF_EQUAL=a}))(),1);const fZ=new dZ.default;function pZ(e,t){if(e===t)return[{value:e}];let{chars1:n,chars2:r,lineArray:i}=fZ.diff_linesToChars_(e,t),a=fZ.diff_main(n,r,!1);fZ.diff_charsToLines_(a,i);let o=[];for(let[e,t]of a){if(t.length===0)continue;let n=o[o.length-1],r=e===dZ.default.DIFF_DELETE,i=e===dZ.default.DIFF_INSERT;if(n&&!!n.removed===r&&!!n.added===i){n.value+=t;continue}r?o.push({value:t,removed:!0}):i?o.push({value:t,added:!0}):o.push({value:t})}return o}const mZ=256*1024;function hZ(e,t,n){if(t===n)return;let r=pZ(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 gZ(e,t,n){if(t===n)return;if(t.length>mZ||n.length>mZ){_Z(e,t,n);return}let r=pZ(t,n),i=0;for(let t of r)t.removed?e.delete(i,t.value.length):(t.added&&e.insert(i,t.value),i+=t.value.length)}function _Z(e,t,n){let r=0,i=Math.min(t.length,n.length);for(;r<i&&t.charCodeAt(r)===n.charCodeAt(r);)r++;r>0&&(r=t.lastIndexOf(`
285
285
  `,r-1)+1);let a=0;for(;a<i-r&&t.charCodeAt(t.length-1-a)===n.charCodeAt(n.length-1-a);)a++;if(a>0){let e=t.length-a,r=n.length-a,i=e===0||t.charCodeAt(e-1)===10,o=r===0||n.charCodeAt(r-1)===10;if(!(i&&o)){let n=t.indexOf(`
286
- `,e);a=n===-1?0:t.length-(n+1)}}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 _Z=v({path:k(y([b(),A()])),message:b(),issueCode:b()});x(`code`,[v({code:_(`SCHEMA_INVALID`),issues:k(_Z)}),v({code:_(`WRITE_ERROR`),detail:b()})]);const vZ={defaultKeyType:`PLAIN`,defaultStringType:`PLAIN`,lineWidth:0};function yZ(e){if(e.trim()===``)return{doc:new ye.Document({}),map:{}};let t;try{t=(0,ye.parseDocument)(e)}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new ye.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=bq.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 bZ(e){return Object.keys(e).length===0?``:new ye.Document(e).toString(vZ)}function xZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function SZ(e,t,n){if(Array.isArray(n)){let r=e.createNode(n),i=(0,ye.isSeq)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}if(xZ(n)){let r=e.createNode(n),i=(0,ye.isMap)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}return n}function CZ(e){return e===``?``:`---\n${e.endsWith(`
287
- `)?e.slice(0,-1):e}\n---\n`}function wZ(e){let t=e.match(Ep);return t?{fenced:t[0],body:e.slice(t[0].length)}:{fenced:``,body:e}}function TZ(e){if(e.trim()===``)return{doc:new ye.Document({}),map:{}};let t;try{t=(0,ye.parseDocument)(e,{uniqueKeys:!1})}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new ye.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=bq.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 EZ(e){return e===``?{doc:new ye.Document({}),map:{}}:TZ(kp(e))}function DZ(e){let{fenced:t}=wZ(e),{map:n}=EZ(t);return n??{}}function OZ(e){if(e.contents==null||!(`items`in e.contents)){let t=e.createNode({});return e.contents=t,t}return e.contents}function kZ(e){let t=e.contents;return!t||!(`items`in t)||(t.items?.length??0)===0?``:CZ(e.toString(vZ))}function AZ(e){let t=new TextEncoder().encode(e).byteLength;return t>65536?{kind:`region_too_large`,bytes:t,limit:65536}:null}function jZ(e){let t=kZ(e),n=AZ(t);return n?{ok:!1,error:n}:{ok:!0,nextFenced:t}}function MZ(e,t){if(Object.hasOwn(t,`frontmatter`))return{ok:!1,error:{kind:`reserved_key`,key:`frontmatter`}};let{doc:n,map:r}=EZ(e);if(r===null)return{ok:!1,error:{kind:`parse_failed`,reason:`fm region unparseable`}};try{OZ(n);for(let[e,r]of Object.entries(t)){if(r===null){n.delete(e);continue}let t=vq.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,SZ(n,n.get(e,!0),t.data))}return jZ(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 NZ(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:de(e.ytextSnapshot),fragmentHash:de(e.fragmentMdSnapshot),redacted:!n,timestamp:r};return n?{...i,diff:e.unifiedDiff}:i}var PZ=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 FZ=/^(?:\r?\n)+/;function IZ(e){let{frontmatter:t,body:n}=Dp(e),r=n.match(FZ);if(!r)return{boundary:``,text:e};let i=n.slice(r[0].length);return t===``&&Ep.test(i)?{boundary:``,text:e}:{boundary:r[0],text:t+i}}function LZ(e,t){if(t===``)return e;let{frontmatter:n,body:r}=Dp(e);return n+t+r}function RZ(e){let t=IZ(e).text;return Dp(t).frontmatter===``?t:LZ(t,`
288
- `)}function zZ(e,t=16){let n=e.trim();return n.length<t?!1:!(n.startsWith(`<`)||n.startsWith("```")||n.startsWith(`|`))}function BZ(e,t=16){let n=new Map;for(let r of e.split(`
289
- `)){if(!zZ(r,t))continue;let e=r.trim();n.set(e,(n.get(e)??0)+1)}return n}function VZ(e,t,n=16){let r=BZ(t,n),i=[];for(let[t,a]of BZ(e,n))a>=2&&a>(r.get(t)??0)&&i.push(t);return i}function HZ(e,t){let n=Object.create(null);for(let e=0;e<t.length;e++){let r=t[e];n[r]?n[r].push(e):n[r]=[e]}let r=[{buffer1index:-1,buffer2index:-1,chain:null}];for(let t=0;t<e.length;t++){let i=n[e[t]]||[],a=0,o=r[0];for(let e of i){let n;for(n=a;n<r.length&&!(r[n].buffer2index<e&&(n===r.length-1||r[n+1].buffer2index>e));n++);if(n<r.length){let i={buffer1index:t,buffer2index:e,chain:r[n]};if(a===r.length?r.push(o):r[a]=o,a=n+1,o=i,a===r.length)break}}r[a]=o}return r[r.length-1]}function UZ(e,t){let n=HZ(e,t),r=[],i=e.length,a=t.length;for(let o=n;o!==null;o=o.chain){let n=i-o.buffer1index-1,s=a-o.buffer2index-1;i=o.buffer1index,a=o.buffer2index,(n||s)&&r.push({buffer1:[i+1,n],buffer1Content:e.slice(i+1,i+1+n),buffer2:[a+1,s],buffer2Content:t.slice(a+1,a+1+s)})}return r.reverse(),r}function WZ(e,t,n){let r=[];function i(e,t){r.push({ab:t,oStart:e.buffer1[0],oLength:e.buffer1[1],abStart:e.buffer2[0],abLength:e.buffer2[1]})}UZ(t,e).forEach(e=>i(e,`a`)),UZ(t,n).forEach(e=>i(e,`b`)),r.sort((e,t)=>e.oStart-t.oStart);let a=[],o=0;function s(e){e>o&&(a.push({stable:!0,buffer:`o`,bufferStart:o,bufferLength:e-o,bufferContent:t.slice(o,e)}),o=e)}for(;r.length;){let i=r.shift(),c=i.oStart,l=i.oStart+i.oLength,u=[i];for(s(c);r.length;){let e=r[0],t=e.oStart;if(t>l)break;l=Math.max(l,t+e.oLength),u.push(r.shift())}if(u.length===1){if(i.abLength>0){let t=i.ab===`a`?e:n;a.push({stable:!0,buffer:i.ab,bufferStart:i.abStart,bufferLength:i.abLength,bufferContent:t.slice(i.abStart,i.abStart+i.abLength)})}}else{let r={a:[e.length,-1,t.length,-1],b:[n.length,-1,t.length,-1]};for(;u.length;){i=u.shift();let e=i.oStart,t=e+i.oLength,n=i.abStart,a=n+i.abLength,o=r[i.ab];o[0]=Math.min(n,o[0]),o[1]=Math.max(a,o[1]),o[2]=Math.min(e,o[2]),o[3]=Math.max(t,o[3])}let o=r.a[0]+(c-r.a[2]),s=r.a[1]+(l-r.a[3]),d=r.b[0]+(c-r.b[2]),f=r.b[1]+(l-r.b[3]),p={stable:!1,aStart:o,aLength:s-o,aContent:e.slice(o,s),oStart:c,oLength:l-c,oContent:t.slice(c,l),bStart:d,bLength:f-d,bContent:n.slice(d,f)};a.push(p)}o=l}return s(t.length),a}function GZ(e,t,n,r){r=Object.assign({excludeFalseConflicts:!0,stringSeparator:/\s+/},r),typeof e==`string`&&(e=e.split(r.stringSeparator)),typeof t==`string`&&(t=t.split(r.stringSeparator)),typeof n==`string`&&(n=n.split(r.stringSeparator));let i=[],a=WZ(e,t,n),o=[];function s(){o.length&&i.push({ok:o}),o=[]}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return a.forEach(e=>{e.stable?o.push(...e.bufferContent):r.excludeFalseConflicts&&c(e.aContent,e.bContent)?o.push(...e.aContent):(s(),i.push({conflict:{a:e.aContent,aIndex:e.aStart,o:e.oContent,oIndex:e.oStart,b:e.bContent,bIndex:e.bStart}}))}),s(),i}const KZ=new uZ.default;KZ.Match_Threshold=.5;function qZ(e,t,n){let r=JZ(e,t,n);return eQ(e,t,n,r),r}function JZ(e,t,n){if(e===t)return n;if(e===n||t===n)return t;let r=GZ(t.split(`
286
+ `,e);a=n===-1?0:t.length-(n+1)}}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 vZ=v({path:k(y([b(),A()])),message:b(),issueCode:b()});x(`code`,[v({code:_(`SCHEMA_INVALID`),issues:k(vZ)}),v({code:_(`WRITE_ERROR`),detail:b()})]);const yZ={defaultKeyType:`PLAIN`,defaultStringType:`PLAIN`,lineWidth:0};function bZ(e){if(e.trim()===``)return{doc:new ye.Document({}),map:{}};let t;try{t=(0,ye.parseDocument)(e)}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new ye.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=bq.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 xZ(e){return Object.keys(e).length===0?``:new ye.Document(e).toString(yZ)}function SZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function CZ(e,t,n){if(Array.isArray(n)){let r=e.createNode(n),i=(0,ye.isSeq)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}if(SZ(n)){let r=e.createNode(n),i=(0,ye.isMap)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}return n}function wZ(e){return e===``?``:`---\n${e.endsWith(`
287
+ `)?e.slice(0,-1):e}\n---\n`}function TZ(e){let t=e.match(Ep);return t?{fenced:t[0],body:e.slice(t[0].length)}:{fenced:``,body:e}}function EZ(e){if(e.trim()===``)return{doc:new ye.Document({}),map:{}};let t;try{t=(0,ye.parseDocument)(e,{uniqueKeys:!1})}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new ye.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=bq.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 DZ(e){return e===``?{doc:new ye.Document({}),map:{}}:EZ(kp(e))}function OZ(e){let{fenced:t}=TZ(e),{map:n}=DZ(t);return n??{}}function kZ(e){if(e.contents==null||!(`items`in e.contents)){let t=e.createNode({});return e.contents=t,t}return e.contents}function AZ(e){let t=e.contents;return!t||!(`items`in t)||(t.items?.length??0)===0?``:wZ(e.toString(yZ))}function jZ(e){let t=new TextEncoder().encode(e).byteLength;return t>65536?{kind:`region_too_large`,bytes:t,limit:65536}:null}function MZ(e){let t=AZ(e),n=jZ(t);return n?{ok:!1,error:n}:{ok:!0,nextFenced:t}}function NZ(e,t){if(Object.hasOwn(t,`frontmatter`))return{ok:!1,error:{kind:`reserved_key`,key:`frontmatter`}};let{doc:n,map:r}=DZ(e);if(r===null)return{ok:!1,error:{kind:`parse_failed`,reason:`fm region unparseable`}};try{kZ(n);for(let[e,r]of Object.entries(t)){if(r===null){n.delete(e);continue}let t=vq.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,CZ(n,n.get(e,!0),t.data))}return MZ(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 PZ(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:de(e.ytextSnapshot),fragmentHash:de(e.fragmentMdSnapshot),redacted:!n,timestamp:r};return n?{...i,diff:e.unifiedDiff}:i}var FZ=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 IZ=/^(?:\r?\n)+/;function LZ(e){let{frontmatter:t,body:n}=Dp(e),r=n.match(IZ);if(!r)return{boundary:``,text:e};let i=n.slice(r[0].length);return t===``&&Ep.test(i)?{boundary:``,text:e}:{boundary:r[0],text:t+i}}function RZ(e,t){if(t===``)return e;let{frontmatter:n,body:r}=Dp(e);return n+t+r}function zZ(e){let t=LZ(e).text;return Dp(t).frontmatter===``?t:RZ(t,`
288
+ `)}function BZ(e,t=16){let n=e.trim();return n.length<t?!1:!(n.startsWith(`<`)||n.startsWith("```")||n.startsWith(`|`))}function VZ(e,t=16){let n=new Map;for(let r of e.split(`
289
+ `)){if(!BZ(r,t))continue;let e=r.trim();n.set(e,(n.get(e)??0)+1)}return n}function HZ(e,t,n=16){let r=VZ(t,n),i=[];for(let[t,a]of VZ(e,n))a>=2&&a>(r.get(t)??0)&&i.push(t);return i}function UZ(e,t){let n=Object.create(null);for(let e=0;e<t.length;e++){let r=t[e];n[r]?n[r].push(e):n[r]=[e]}let r=[{buffer1index:-1,buffer2index:-1,chain:null}];for(let t=0;t<e.length;t++){let i=n[e[t]]||[],a=0,o=r[0];for(let e of i){let n;for(n=a;n<r.length&&!(r[n].buffer2index<e&&(n===r.length-1||r[n+1].buffer2index>e));n++);if(n<r.length){let i={buffer1index:t,buffer2index:e,chain:r[n]};if(a===r.length?r.push(o):r[a]=o,a=n+1,o=i,a===r.length)break}}r[a]=o}return r[r.length-1]}function WZ(e,t){let n=UZ(e,t),r=[],i=e.length,a=t.length;for(let o=n;o!==null;o=o.chain){let n=i-o.buffer1index-1,s=a-o.buffer2index-1;i=o.buffer1index,a=o.buffer2index,(n||s)&&r.push({buffer1:[i+1,n],buffer1Content:e.slice(i+1,i+1+n),buffer2:[a+1,s],buffer2Content:t.slice(a+1,a+1+s)})}return r.reverse(),r}function GZ(e,t,n){let r=[];function i(e,t){r.push({ab:t,oStart:e.buffer1[0],oLength:e.buffer1[1],abStart:e.buffer2[0],abLength:e.buffer2[1]})}WZ(t,e).forEach(e=>i(e,`a`)),WZ(t,n).forEach(e=>i(e,`b`)),r.sort((e,t)=>e.oStart-t.oStart);let a=[],o=0;function s(e){e>o&&(a.push({stable:!0,buffer:`o`,bufferStart:o,bufferLength:e-o,bufferContent:t.slice(o,e)}),o=e)}for(;r.length;){let i=r.shift(),c=i.oStart,l=i.oStart+i.oLength,u=[i];for(s(c);r.length;){let e=r[0],t=e.oStart;if(t>l)break;l=Math.max(l,t+e.oLength),u.push(r.shift())}if(u.length===1){if(i.abLength>0){let t=i.ab===`a`?e:n;a.push({stable:!0,buffer:i.ab,bufferStart:i.abStart,bufferLength:i.abLength,bufferContent:t.slice(i.abStart,i.abStart+i.abLength)})}}else{let r={a:[e.length,-1,t.length,-1],b:[n.length,-1,t.length,-1]};for(;u.length;){i=u.shift();let e=i.oStart,t=e+i.oLength,n=i.abStart,a=n+i.abLength,o=r[i.ab];o[0]=Math.min(n,o[0]),o[1]=Math.max(a,o[1]),o[2]=Math.min(e,o[2]),o[3]=Math.max(t,o[3])}let o=r.a[0]+(c-r.a[2]),s=r.a[1]+(l-r.a[3]),d=r.b[0]+(c-r.b[2]),f=r.b[1]+(l-r.b[3]),p={stable:!1,aStart:o,aLength:s-o,aContent:e.slice(o,s),oStart:c,oLength:l-c,oContent:t.slice(c,l),bStart:d,bLength:f-d,bContent:n.slice(d,f)};a.push(p)}o=l}return s(t.length),a}function KZ(e,t,n,r){r=Object.assign({excludeFalseConflicts:!0,stringSeparator:/\s+/},r),typeof e==`string`&&(e=e.split(r.stringSeparator)),typeof t==`string`&&(t=t.split(r.stringSeparator)),typeof n==`string`&&(n=n.split(r.stringSeparator));let i=[],a=GZ(e,t,n),o=[];function s(){o.length&&i.push({ok:o}),o=[]}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return a.forEach(e=>{e.stable?o.push(...e.bufferContent):r.excludeFalseConflicts&&c(e.aContent,e.bContent)?o.push(...e.aContent):(s(),i.push({conflict:{a:e.aContent,aIndex:e.aStart,o:e.oContent,oIndex:e.oStart,b:e.bContent,bIndex:e.bStart}}))}),s(),i}const qZ=new dZ.default;qZ.Match_Threshold=.5;function JZ(e,t,n){let r=YZ(e,t,n);return tQ(e,t,n,r),r}function YZ(e,t,n){if(e===t)return n;if(e===n||t===n)return t;let r=KZ(t.split(`
290
290
  `),e.split(`
291
291
  `),n.split(`
292
292
  `)),i=[];for(let e=0;e<r.length;e++){let t=r[e];if(`ok`in t&&t.ok)i.push(t.ok.join(`
293
293
  `));else if(`conflict`in t&&t.conflict){let e=t.conflict.o.join(`
294
294
  `),n=t.conflict.a.join(`
295
295
  `),r=t.conflict.b.join(`
296
- `);i.push(tQ(e,n,r))}}return i.join(`
297
- `)}function YZ(e,t,n){if(e===t)return{clean:!0,merged:n};if(e===n||t===n)return{clean:!0,merged:t};let r=GZ(t.split(`
296
+ `);i.push(nQ(e,n,r))}}return i.join(`
297
+ `)}function XZ(e,t,n){if(e===t)return{clean:!0,merged:n};if(e===n||t===n)return{clean:!0,merged:t};let r=KZ(t.split(`
298
298
  `),e.split(`
299
299
  `),n.split(`
300
300
  `)),i=[];for(let e of r)if(`ok`in e&&e.ok)i.push(e.ok.join(`
301
301
  `));else return{clean:!1};let a=i.join(`
302
- `);try{eQ(e,t,n,a)}catch{return{clean:!1}}return{clean:!0,merged:a}}function XZ(e){return e.map(e=>({len:e.length,digest:de(e)}))}var ZZ=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:XZ(this.info.lostSubstrings),redacted:!t}}};function QZ(e,t){if(e===t)return[];let n=KZ.diff_main(e,t);KZ.diff_cleanupSemantic(n);let r=[];for(let[e,t]of n)if(e===1)for(let e of t.split(`
303
- `)){let t=e.trim();t.length!==0&&r.push(t)}return r}function $Z(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 eQ(e,t,n,r){let i=QZ(e,t),a=QZ(e,n),o=i.filter(e=>!r.includes(e));if(o.length>0)throw new ZZ({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 ZZ({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:s,which:`substring`,side:`agent`});let c=$Z(r,i);if(c!==null)throw new ZZ({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[c],which:`order`,side:`user`});let l=$Z(r,a);if(l!==null)throw new ZZ({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[l],which:`order`,side:`agent`});let u=BZ(e),d=BZ(t),f=BZ(n);for(let[i,a]of BZ(r))if(!(a<2)&&a>Math.max(u.get(i)??0,d.get(i)??0,f.get(i)??0))throw new ZZ({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[i],which:`growth`,side:`user`})}function tQ(e,t,n){if(t===``)return n;if(n===``)return t;let r=KZ.patch_make(e,t),[i,a]=KZ.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 nQ=/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g,rQ=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/,iQ=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/,aQ=/^\d+([.)])(?=\s)/,oQ=/\*\*\s*(`[^`]+`)\s*\*\*/g,sQ=/^(`{3,}|~{3,})/;function cQ(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r].trimEnd(),a=sQ.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||!rQ.test(i))continue;let o=e[r-1].trimEnd();if(!(!o.startsWith(`|`)||rQ.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 lQ(e){return e.slice(0,-1).trimEnd()}const uQ=/^(?:#{1,6}[ \t]|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function dQ(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 fQ=/^<\/?[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,pQ=/^<[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,mQ=/^<\/[A-Z][A-Za-z0-9.]*\s*>$/,hQ=/<\/?[A-Z]/;function gQ(e){let t=!1;for(let n=0;n<e.length;n++)if(hQ.test(e[n]??``)){t=!0;break}if(!t)return e;let n=dQ(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&&fQ.test(s));let l=c&&mQ.test(s),u=c&&!l&&pQ.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 _Q(e){let t=gQ(e.replace(/^/,``).replace(/\r/g,``).replace(nQ,`$1`).replace(oQ,`$1`).replace(/^\n+/,``).replace(/^[*-]{3,}(?=\n|$)/,`---`).replace(/(\n)([#>+-]|\d+[.)]|`{3,}|~{3,})/g,`
302
+ `);try{tQ(e,t,n,a)}catch{return{clean:!1}}return{clean:!0,merged:a}}function ZZ(e){return e.map(e=>({len:e.length,digest:de(e)}))}var QZ=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:ZZ(this.info.lostSubstrings),redacted:!t}}};function $Z(e,t){if(e===t)return[];let n=qZ.diff_main(e,t);qZ.diff_cleanupSemantic(n);let r=[];for(let[e,t]of n)if(e===1)for(let e of t.split(`
303
+ `)){let t=e.trim();t.length!==0&&r.push(t)}return r}function eQ(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 tQ(e,t,n,r){let i=$Z(e,t),a=$Z(e,n),o=i.filter(e=>!r.includes(e));if(o.length>0)throw new QZ({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 QZ({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:s,which:`substring`,side:`agent`});let c=eQ(r,i);if(c!==null)throw new QZ({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[c],which:`order`,side:`user`});let l=eQ(r,a);if(l!==null)throw new QZ({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[l],which:`order`,side:`agent`});let u=VZ(e),d=VZ(t),f=VZ(n);for(let[i,a]of VZ(r))if(!(a<2)&&a>Math.max(u.get(i)??0,d.get(i)??0,f.get(i)??0))throw new QZ({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[i],which:`growth`,side:`user`})}function nQ(e,t,n){if(t===``)return n;if(n===``)return t;let r=qZ.patch_make(e,t),[i,a]=qZ.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 rQ=/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g,iQ=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/,aQ=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/,oQ=/^\d+([.)])(?=\s)/,sQ=/\*\*\s*(`[^`]+`)\s*\*\*/g,cQ=/^(`{3,}|~{3,})/;function lQ(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r].trimEnd(),a=cQ.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||!iQ.test(i))continue;let o=e[r-1].trimEnd();if(!(!o.startsWith(`|`)||iQ.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 uQ(e){return e.slice(0,-1).trimEnd()}const dQ=/^(?:#{1,6}[ \t]|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function fQ(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 pQ=/^<\/?[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,mQ=/^<[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,hQ=/^<\/[A-Z][A-Za-z0-9.]*\s*>$/,gQ=/<\/?[A-Z]/;function _Q(e){let t=!1;for(let n=0;n<e.length;n++)if(gQ.test(e[n]??``)){t=!0;break}if(!t)return e;let n=fQ(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&&pQ.test(s));let l=c&&hQ.test(s),u=c&&!l&&mQ.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 vQ(e){let t=_Q(e.replace(/^/,``).replace(/\r/g,``).replace(rQ,`$1`).replace(sQ,`$1`).replace(/^\n+/,``).replace(/^[*-]{3,}(?=\n|$)/,`---`).replace(/(\n)([#>+-]|\d+[.)]|`{3,}|~{3,})/g,`
304
304
 
305
305
  $2`).replace(/^([#>+-].*|\d+[.)].*|`{3,}.*|~{3,}.*|<\/[A-Z][A-Za-z0-9]*>[ \t]*)\n([^\n])/gm,`$1
306
306
 
307
307
  $2`).split(`
308
- `)),n=cQ(t),r=dQ(t);return t.map((e,i)=>{let a=e.trimEnd();if(i>0&&!r.has(i)&&/^[ \t]+\S/.test(a)&&(t[i-1]??``).trim()!==``&&!iQ.test(a)&&!uQ.test(a.trimStart())){let e=(t[i-1]??``).trimStart();if(!uQ.test(e)&&!e.startsWith(`|`))return a.replace(/^[ \t]+/,``)}if(rQ.test(a)){let e=a.replace(/\s+/g,``);return n.has(i)&&e.length>1&&e.startsWith(`|`)&&e.endsWith(`|`)?lQ(e):e}let o=iQ.test(a)?a.replace(/^[ \t]+/,``):a;return n.has(i)&&o.length>1&&o.startsWith(`|`)&&o.endsWith(`|`)&&(o=lQ(o)),o.replace(aQ,`1$1`)}).join(`
308
+ `)),n=lQ(t),r=fQ(t);return t.map((e,i)=>{let a=e.trimEnd();if(i>0&&!r.has(i)&&/^[ \t]+\S/.test(a)&&(t[i-1]??``).trim()!==``&&!aQ.test(a)&&!dQ.test(a.trimStart())){let e=(t[i-1]??``).trimStart();if(!dQ.test(e)&&!e.startsWith(`|`))return a.replace(/^[ \t]+/,``)}if(iQ.test(a)){let e=a.replace(/\s+/g,``);return n.has(i)&&e.length>1&&e.startsWith(`|`)&&e.endsWith(`|`)?uQ(e):e}let o=aQ.test(a)?a.replace(/^[ \t]+/,``):a;return n.has(i)&&o.length>1&&o.startsWith(`|`)&&o.endsWith(`|`)&&(o=uQ(o)),o.replace(oQ,`1$1`)}).join(`
309
309
  `).replace(/\n{3,}/g,`
310
310
 
311
- `).replace(/\n+$/,``)}function vQ(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(`
311
+ `).replace(/\n+$/,``)}function yQ(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(`
312
312
  `)!==i.startsWith(`
313
313
  `)&&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,}.*|<\/[A-Z][A-Za-z0-9]*>[ \t]*)\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(`
314
314
  `),w=v.split(`
315
- `),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&fQ.test(n),a=n===``&&r!==``&&fQ.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(aQ,`1$1`),D=Math.min(C.length,w.length);for(let e=0;e<D;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(`
315
+ `),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&pQ.test(n),a=n===``&&r!==``&&pQ.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(oQ,`1$1`),D=Math.min(C.length,w.length);for(let e=0;e<D;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(`
316
316
  `)!==v.endsWith(`
317
- `)&&n.push(`trailing-newline`),n}const yQ=`parse-equivalence`;function bQ(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function xQ(e){return e.replace(/[ \t]+$/gm,``)}const SQ=/^([ \t]*)\d+([.)])(?=[ \t])/;function CQ(e){return e.split(`
318
- `).map(e=>e.replace(SQ,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const wQ=new Set;function TQ(e,t,n){let r=Dp(e),i=Dp(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 wQ.size<8&&!wQ.has(t)&&(wQ.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return bQ(xQ(a))===bQ(xQ(i.body))?nM(CQ(r.body),CQ(a)):!1}const EQ={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},DQ={"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 OQ(e){return DQ[e]}function kQ(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 AQ=null;function jQ(e){AQ=e}function MQ(e,t,n,r){if(!AQ||e.length===0)return;let i=kQ(t,n),a=new Date().toISOString();for(let t of e)AQ({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:OQ(t)})}const NQ=1e4,PQ=`last-spawn-error.log`,FQ=`last-server-exit.json`,IQ=`last-server-crash.json`;function LQ(e){let{frontmatter:t}=Dp(e);if(t===``)return null;let n;try{let e=(0,ye.parseDocument)(kp(t));if(e.errors.length>0)return null;n=e.toJS()}catch{return null}return typeof n!=`object`||!n||Array.isArray(n)?null:n}const RQ=/^[a-zA-Z0-9][\w/-]*$/;function zQ(e){return e.startsWith(`#`)?e.slice(1):e}function BQ(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function VQ(e){if(!e||e.trim()===``)return[];let{map:t}=yZ(e);if(!t)return[];let n=BQ(t.tags),r=[];for(let e of n){let t=zQ(e);RQ.test(t)&&r.push(t)}return r}const HQ=[`.ok`,`local`,`installed-skills.json`],UQ=d(Ae),WQ=w({hosts:k(b()),scope:UQ,scripts:E(),installedAt:ne()}),GQ=w({schema:_(1),skills:T(b(),WQ).default({})});function KQ(){return{schema:1,skills:{}}}function qQ(e){let t;try{t=JSON.parse(e)}catch{return null}let n=GQ.safeParse(t);return n.success?n.data:null}const JQ={arabic:`ar`,armenian:`am`,bulgarian:`bg`,czech:`cz`,danish:`dk`,dutch:`nl`,english:`en`,finnish:`fi`,french:`fr`,german:`de`,greek:`gr`,hungarian:`hu`,indian:`in`,indonesian:`id`,irish:`ie`,italian:`it`,lithuanian:`lt`,nepali:`np`,norwegian:`no`,portuguese:`pt`,romanian:`ro`,russian:`ru`,serbian:`rs`,slovenian:`ru`,spanish:`es`,swedish:`se`,tamil:`ta`,turkish:`tr`,ukrainian:`uk`,sanskrit:`sk`},YQ={dutch:/[^A-Za-zàèéìòóù0-9_'-]+/gim,english:/[^A-Za-zàèéìòóù0-9_'-]+/gim,french:/[^a-z0-9äâàéèëêïîöôùüûœç-]+/gim,italian:/[^A-Za-zàèéìòóù0-9_'-]+/gim,norwegian:/[^a-z0-9_æøåÆØÅäÄöÖüÜ]+/gim,portuguese:/[^a-z0-9à-úÀ-Ú]/gim,russian:/[^a-z0-9а-яА-ЯёЁ]+/gim,spanish:/[^a-z0-9A-Zá-úÁ-ÚñÑüÜ]+/gim,swedish:/[^a-z0-9_åÅäÄöÖüÜ-]+/gim,german:/[^a-z0-9A-ZäöüÄÖÜß]+/gim,finnish:/[^a-z0-9äöÄÖ]+/gim,danish:/[^a-z0-9æøåÆØÅ]+/gim,hungarian:/[^a-z0-9áéíóöőúüűÁÉÍÓÖŐÚÜŰ]+/gim,romanian:/[^a-z0-9ăâîșțĂÂÎȘȚ]+/gim,serbian:/[^a-z0-9čćžšđČĆŽŠĐ]+/gim,turkish:/[^a-z0-9çÇğĞıİöÖşŞüÜ]+/gim,lithuanian:/[^a-z0-9ąčęėįšųūžĄČĘĖĮŠŲŪŽ]+/gim,arabic:/[^a-z0-9أ-ي]+/gim,nepali:/[^a-z0-9अ-ह]+/gim,irish:/[^a-z0-9áéíóúÁÉÍÓÚ]+/gim,indian:/[^a-z0-9अ-ह]+/gim,armenian:/[^a-z0-9ա-ֆ]+/gim,greek:/[^a-z0-9α-ωά-ώ]+/gim,indonesian:/[^a-z0-9]+/gim,ukrainian:/[^a-z0-9а-яА-ЯіїєІЇЄ]+/gim,slovenian:/[^a-z0-9螚ȎŠ]+/gim,bulgarian:/[^a-z0-9а-яА-Я]+/gim,tamil:/[^a-z0-9அ-ஹ]+/gim,sanskrit:/[^a-z0-9A-Zāīūṛḷṃṁḥśṣṭḍṇṅñḻḹṝ]+/gim,czech:/[^A-Z0-9a-zěščřžýáíéúůóťďĚŠČŘŽÝÁÍÉÓÚŮŤĎ-]+/gim},XQ=Object.keys(JQ);function ZQ(e){return e!==void 0&&XQ.includes(e)?JQ[e]:void 0}const QQ=Date.now().toString().slice(5);let $Q=0;const e$=BigInt(1e3),t$=BigInt(1e6),n$=BigInt(1e9),r$=65535;function i$(e,t){if(t.length<65535)Array.prototype.push.apply(e,t);else{let n=t.length;for(let r=0;r<n;r+=r$)Array.prototype.push.apply(e,t.slice(r,r+r$))}}function a$(e,...t){return e.replace(/%(?:(?<position>\d+)\$)?(?<width>-?\d*\.?\d*)(?<type>[dfs])/g,function(...e){let{width:n,type:r,position:i}=e[e.length-1],a=i?t[Number.parseInt(i)-1]:t.shift(),o=n===``?0:Number.parseInt(n);switch(r){case`d`:return a.toString().padStart(o,`0`);case`f`:{let e=a,[t,r]=n.split(`.`).map(e=>Number.parseFloat(e));return typeof r==`number`&&r>=0&&(e=e.toFixed(r)),typeof t==`number`&&t>=0?e.toString().padStart(o,`0`):e.toString()}case`s`:return o<0?a.toString().padEnd(-o,` `):a.toString().padStart(o,` `);default:return a}})}function o$(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function s$(){return typeof process<`u`&&process.release&&process.release.name===`node`}function c$(){return BigInt(Math.floor(performance.now()*1e6))}function l$(e){return typeof e==`number`&&(e=BigInt(e)),e<e$?`${e}ns`:e<t$?`${e/e$}μs`:e<n$?`${e/t$}ms`:`${e/n$}s`}function u$(){return o$()?c$():s$()||typeof process<`u`&&typeof process?.hrtime?.bigint==`function`?process.hrtime.bigint():typeof performance<`u`?c$():BigInt(0)}function d$(){return`${QQ}-${$Q++}`}function f$(e,t){return Object.hasOwn===void 0?Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0:Object.hasOwn(e,t)?e[t]:void 0}function p$(e,t){return t[1]===e[1]?e[0]-t[0]:t[1]-e[1]}function m$(e){if(e.length===0)return[];if(e.length===1)return e[0];for(let t=1;t<e.length;t++)if(e[t].length<e[0].length){let n=e[0];e[0]=e[t],e[t]=n}let t=new Map;for(let n of e[0])t.set(n,1);for(let n=1;n<e.length;n++){let r=0;for(let i of e[n]){let e=t.get(i);e===n&&(t.set(i,e+1),r++)}if(r===0)return[]}return e[0].filter(n=>{let r=t.get(n);return r!==void 0&&t.set(n,0),r===e.length})}function h$(e,t){let n={},r=t.length;for(let i=0;i<r;i++){let r=t[i],a=r.split(`.`),o=e,s=a.length;for(let e=0;e<s;e++)if(o=o[a[e]],typeof o==`object`){if(o!==null&&`lat`in o&&`lon`in o&&typeof o.lat==`number`&&typeof o.lon==`number`){o=n[r]=o;break}else if(!Array.isArray(o)&&o!==null&&e===s-1){o=void 0;break}}else if((typeof o!=`object`||!o)&&e<s-1){o=void 0;break}o!==void 0&&(n[r]=o)}return n}function g$(e,t){return h$(e,[t])[t]}const _$={cm:.01,m:1,km:1e3,ft:.3048,yd:.9144,mi:1609.344};function v$(e,t){let n=_$[t];if(n===void 0)throw Error(O$(`INVALID_DISTANCE_SUFFIX`,e).message);return e*n}function y$(e,t){e.hits=e.hits.map(e=>({...e,document:{...e.document,...t.reduce((e,t)=>{let n=t.split(`.`),r=n.pop(),i=e;for(let e of n)i[e]=i[e]??{},i=i[e];return i[r]=null,e},e.document)}}))}function b$(e){return Array.isArray(e)?e.some(e=>b$(e)):e?.constructor?.name===`AsyncFunction`}const x$=`intersection`in new Set;function S$(...e){if(e.length===0)return new Set;if(e.length===1)return e[0];if(e.length===2){let t=e[0],n=e[1];if(x$)return t.intersection(n);let r=new Set,i=t.size<n.size?t:n,a=i===t?n:t;for(let e of i)a.has(e)&&r.add(e);return r}let t={index:0,size:e[0].size};for(let n=1;n<e.length;n++)e[n].size<t.size&&(t.index=n,t.size=e[n].size);if(x$){let n=e[t.index];for(let r=0;r<e.length;r++)r!==t.index&&(n=n.intersection(e[r]));return n}let n=e[t.index];for(let r=0;r<e.length;r++){if(r===t.index)continue;let i=e[r];for(let e of n)i.has(e)||n.delete(e)}return n}const C$=`union`in new Set;function w$(e,t){return C$?e?e.union(t):t:e?new Set([...e,...t]):new Set(t)}function T$(e,t){let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function E$(e){if(typeof SharedArrayBuffer<`u`&&typeof Atomics<`u`){let t=new Int32Array(new SharedArrayBuffer(4));if(!(e>0&&e<1/0))throw typeof e!=`number`&&typeof e!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);Atomics.wait(t,0,0,Number(e))}else{if(!(e>0&&e<1/0))throw typeof e!=`number`&&typeof e!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);let t=Date.now()+Number(e);for(;t>Date.now(););}}const D$={NO_LANGUAGE_WITH_CUSTOM_TOKENIZER:`Do not pass the language option to create when using a custom tokenizer.`,LANGUAGE_NOT_SUPPORTED:`Language "%s" is not supported.\nSupported languages are:\n - ${XQ.join(`
317
+ `)&&n.push(`trailing-newline`),n}const bQ=`parse-equivalence`;function xQ(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function SQ(e){return e.replace(/[ \t]+$/gm,``)}const CQ=/^([ \t]*)\d+([.)])(?=[ \t])/;function wQ(e){return e.split(`
318
+ `).map(e=>e.replace(CQ,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const TQ=new Set;function EQ(e,t,n){let r=Dp(e),i=Dp(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 TQ.size<8&&!TQ.has(t)&&(TQ.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return xQ(SQ(a))===xQ(SQ(i.body))?nM(wQ(r.body),wQ(a)):!1}const DQ={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},OQ={"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 kQ(e){return OQ[e]}function AQ(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 jQ=null;function MQ(e){jQ=e}function NQ(e,t,n,r){if(!jQ||e.length===0)return;let i=AQ(t,n),a=new Date().toISOString();for(let t of e)jQ({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:kQ(t)})}const PQ=1e4,FQ=`last-spawn-error.log`,IQ=`last-server-exit.json`,LQ=`last-server-crash.json`;function RQ(e){let{frontmatter:t}=Dp(e);if(t===``)return null;let n;try{let e=(0,ye.parseDocument)(kp(t));if(e.errors.length>0)return null;n=e.toJS()}catch{return null}return typeof n!=`object`||!n||Array.isArray(n)?null:n}const zQ=/^[a-zA-Z0-9][\w/-]*$/;function BQ(e){return e.startsWith(`#`)?e.slice(1):e}function VQ(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function HQ(e){if(!e||e.trim()===``)return[];let{map:t}=bZ(e);if(!t)return[];let n=VQ(t.tags),r=[];for(let e of n){let t=BQ(e);zQ.test(t)&&r.push(t)}return r}const UQ=[`.ok`,`local`,`installed-skills.json`],WQ=d(Ae),GQ=w({hosts:k(b()),scope:WQ,scripts:E(),installedAt:ne()}),KQ=w({schema:_(1),skills:T(b(),GQ).default({})});function qQ(){return{schema:1,skills:{}}}function JQ(e){let t;try{t=JSON.parse(e)}catch{return null}let n=KQ.safeParse(t);return n.success?n.data:null}const YQ={arabic:`ar`,armenian:`am`,bulgarian:`bg`,czech:`cz`,danish:`dk`,dutch:`nl`,english:`en`,finnish:`fi`,french:`fr`,german:`de`,greek:`gr`,hungarian:`hu`,indian:`in`,indonesian:`id`,irish:`ie`,italian:`it`,lithuanian:`lt`,nepali:`np`,norwegian:`no`,portuguese:`pt`,romanian:`ro`,russian:`ru`,serbian:`rs`,slovenian:`ru`,spanish:`es`,swedish:`se`,tamil:`ta`,turkish:`tr`,ukrainian:`uk`,sanskrit:`sk`},XQ={dutch:/[^A-Za-zàèéìòóù0-9_'-]+/gim,english:/[^A-Za-zàèéìòóù0-9_'-]+/gim,french:/[^a-z0-9äâàéèëêïîöôùüûœç-]+/gim,italian:/[^A-Za-zàèéìòóù0-9_'-]+/gim,norwegian:/[^a-z0-9_æøåÆØÅäÄöÖüÜ]+/gim,portuguese:/[^a-z0-9à-úÀ-Ú]/gim,russian:/[^a-z0-9а-яА-ЯёЁ]+/gim,spanish:/[^a-z0-9A-Zá-úÁ-ÚñÑüÜ]+/gim,swedish:/[^a-z0-9_åÅäÄöÖüÜ-]+/gim,german:/[^a-z0-9A-ZäöüÄÖÜß]+/gim,finnish:/[^a-z0-9äöÄÖ]+/gim,danish:/[^a-z0-9æøåÆØÅ]+/gim,hungarian:/[^a-z0-9áéíóöőúüűÁÉÍÓÖŐÚÜŰ]+/gim,romanian:/[^a-z0-9ăâîșțĂÂÎȘȚ]+/gim,serbian:/[^a-z0-9čćžšđČĆŽŠĐ]+/gim,turkish:/[^a-z0-9çÇğĞıİöÖşŞüÜ]+/gim,lithuanian:/[^a-z0-9ąčęėįšųūžĄČĘĖĮŠŲŪŽ]+/gim,arabic:/[^a-z0-9أ-ي]+/gim,nepali:/[^a-z0-9अ-ह]+/gim,irish:/[^a-z0-9áéíóúÁÉÍÓÚ]+/gim,indian:/[^a-z0-9अ-ह]+/gim,armenian:/[^a-z0-9ա-ֆ]+/gim,greek:/[^a-z0-9α-ωά-ώ]+/gim,indonesian:/[^a-z0-9]+/gim,ukrainian:/[^a-z0-9а-яА-ЯіїєІЇЄ]+/gim,slovenian:/[^a-z0-9螚ȎŠ]+/gim,bulgarian:/[^a-z0-9а-яА-Я]+/gim,tamil:/[^a-z0-9அ-ஹ]+/gim,sanskrit:/[^a-z0-9A-Zāīūṛḷṃṁḥśṣṭḍṇṅñḻḹṝ]+/gim,czech:/[^A-Z0-9a-zěščřžýáíéúůóťďĚŠČŘŽÝÁÍÉÓÚŮŤĎ-]+/gim},ZQ=Object.keys(YQ);function QQ(e){return e!==void 0&&ZQ.includes(e)?YQ[e]:void 0}const $Q=Date.now().toString().slice(5);let e$=0;const t$=BigInt(1e3),n$=BigInt(1e6),r$=BigInt(1e9),i$=65535;function a$(e,t){if(t.length<65535)Array.prototype.push.apply(e,t);else{let n=t.length;for(let r=0;r<n;r+=i$)Array.prototype.push.apply(e,t.slice(r,r+i$))}}function o$(e,...t){return e.replace(/%(?:(?<position>\d+)\$)?(?<width>-?\d*\.?\d*)(?<type>[dfs])/g,function(...e){let{width:n,type:r,position:i}=e[e.length-1],a=i?t[Number.parseInt(i)-1]:t.shift(),o=n===``?0:Number.parseInt(n);switch(r){case`d`:return a.toString().padStart(o,`0`);case`f`:{let e=a,[t,r]=n.split(`.`).map(e=>Number.parseFloat(e));return typeof r==`number`&&r>=0&&(e=e.toFixed(r)),typeof t==`number`&&t>=0?e.toString().padStart(o,`0`):e.toString()}case`s`:return o<0?a.toString().padEnd(-o,` `):a.toString().padStart(o,` `);default:return a}})}function s$(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function c$(){return typeof process<`u`&&process.release&&process.release.name===`node`}function l$(){return BigInt(Math.floor(performance.now()*1e6))}function u$(e){return typeof e==`number`&&(e=BigInt(e)),e<t$?`${e}ns`:e<n$?`${e/t$}μs`:e<r$?`${e/n$}ms`:`${e/r$}s`}function d$(){return s$()?l$():c$()||typeof process<`u`&&typeof process?.hrtime?.bigint==`function`?process.hrtime.bigint():typeof performance<`u`?l$():BigInt(0)}function f$(){return`${$Q}-${e$++}`}function p$(e,t){return Object.hasOwn===void 0?Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0:Object.hasOwn(e,t)?e[t]:void 0}function m$(e,t){return t[1]===e[1]?e[0]-t[0]:t[1]-e[1]}function h$(e){if(e.length===0)return[];if(e.length===1)return e[0];for(let t=1;t<e.length;t++)if(e[t].length<e[0].length){let n=e[0];e[0]=e[t],e[t]=n}let t=new Map;for(let n of e[0])t.set(n,1);for(let n=1;n<e.length;n++){let r=0;for(let i of e[n]){let e=t.get(i);e===n&&(t.set(i,e+1),r++)}if(r===0)return[]}return e[0].filter(n=>{let r=t.get(n);return r!==void 0&&t.set(n,0),r===e.length})}function g$(e,t){let n={},r=t.length;for(let i=0;i<r;i++){let r=t[i],a=r.split(`.`),o=e,s=a.length;for(let e=0;e<s;e++)if(o=o[a[e]],typeof o==`object`){if(o!==null&&`lat`in o&&`lon`in o&&typeof o.lat==`number`&&typeof o.lon==`number`){o=n[r]=o;break}else if(!Array.isArray(o)&&o!==null&&e===s-1){o=void 0;break}}else if((typeof o!=`object`||!o)&&e<s-1){o=void 0;break}o!==void 0&&(n[r]=o)}return n}function _$(e,t){return g$(e,[t])[t]}const v$={cm:.01,m:1,km:1e3,ft:.3048,yd:.9144,mi:1609.344};function y$(e,t){let n=v$[t];if(n===void 0)throw Error(k$(`INVALID_DISTANCE_SUFFIX`,e).message);return e*n}function b$(e,t){e.hits=e.hits.map(e=>({...e,document:{...e.document,...t.reduce((e,t)=>{let n=t.split(`.`),r=n.pop(),i=e;for(let e of n)i[e]=i[e]??{},i=i[e];return i[r]=null,e},e.document)}}))}function x$(e){return Array.isArray(e)?e.some(e=>x$(e)):e?.constructor?.name===`AsyncFunction`}const S$=`intersection`in new Set;function C$(...e){if(e.length===0)return new Set;if(e.length===1)return e[0];if(e.length===2){let t=e[0],n=e[1];if(S$)return t.intersection(n);let r=new Set,i=t.size<n.size?t:n,a=i===t?n:t;for(let e of i)a.has(e)&&r.add(e);return r}let t={index:0,size:e[0].size};for(let n=1;n<e.length;n++)e[n].size<t.size&&(t.index=n,t.size=e[n].size);if(S$){let n=e[t.index];for(let r=0;r<e.length;r++)r!==t.index&&(n=n.intersection(e[r]));return n}let n=e[t.index];for(let r=0;r<e.length;r++){if(r===t.index)continue;let i=e[r];for(let e of n)i.has(e)||n.delete(e)}return n}const w$=`union`in new Set;function T$(e,t){return w$?e?e.union(t):t:e?new Set([...e,...t]):new Set(t)}function E$(e,t){let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function D$(e){if(typeof SharedArrayBuffer<`u`&&typeof Atomics<`u`){let t=new Int32Array(new SharedArrayBuffer(4));if(!(e>0&&e<1/0))throw typeof e!=`number`&&typeof e!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);Atomics.wait(t,0,0,Number(e))}else{if(!(e>0&&e<1/0))throw typeof e!=`number`&&typeof e!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);let t=Date.now()+Number(e);for(;t>Date.now(););}}const O$={NO_LANGUAGE_WITH_CUSTOM_TOKENIZER:`Do not pass the language option to create when using a custom tokenizer.`,LANGUAGE_NOT_SUPPORTED:`Language "%s" is not supported.\nSupported languages are:\n - ${ZQ.join(`
319
319
  - `)}`,INVALID_STEMMER_FUNCTION_TYPE:`config.stemmer property must be a function.`,MISSING_STEMMER:`As of version 1.0.0 @orama/orama does not ship non English stemmers by default. To solve this, please explicitly import and specify the "%s" stemmer from the package @orama/stemmers. See https://docs.orama.com/docs/orama-js/text-analysis/stemming for more information.`,CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY:`Custom stop words array must only contain strings.`,UNSUPPORTED_COMPONENT:`Unsupported component "%s".`,COMPONENT_MUST_BE_FUNCTION:`The component "%s" must be a function.`,COMPONENT_MUST_BE_FUNCTION_OR_ARRAY_FUNCTIONS:`The component "%s" must be a function or an array of functions.`,INVALID_SCHEMA_TYPE:`Unsupported schema type "%s" at "%s". Expected "string", "boolean" or "number" or array of them.`,DOCUMENT_ID_MUST_BE_STRING:`Document id must be of type "string". Got "%s" instead.`,DOCUMENT_ALREADY_EXISTS:`A document with id "%s" already exists.`,DOCUMENT_DOES_NOT_EXIST:`A document with id "%s" does not exists.`,MISSING_DOCUMENT_PROPERTY:`Missing searchable property "%s".`,INVALID_DOCUMENT_PROPERTY:`Invalid document property "%s": expected "%s", got "%s"`,UNKNOWN_INDEX:`Invalid property name "%s". Expected a wildcard string ("*") or array containing one of the following properties: %s`,INVALID_BOOST_VALUE:`Boost value must be a number greater than, or less than 0.`,INVALID_FILTER_OPERATION:`You can only use one operation per filter, you requested %d.`,SCHEMA_VALIDATION_FAILURE:`Cannot insert document due schema validation failure on "%s" property.`,INVALID_SORT_SCHEMA_TYPE:`Unsupported sort schema type "%s" at "%s". Expected "string" or "number".`,CANNOT_SORT_BY_ARRAY:`Cannot configure sort for "%s" because it is an array (%s).`,UNABLE_TO_SORT_ON_UNKNOWN_FIELD:`Unable to sort on unknown field "%s". Allowed fields: %s`,SORT_DISABLED:`Sort is disabled. Please read the documentation at https://docs.orama.com/docs/orama-js for more information.`,UNKNOWN_GROUP_BY_PROPERTY:`Unknown groupBy property "%s".`,INVALID_GROUP_BY_PROPERTY:`Invalid groupBy property "%s". Allowed types: "%s", but given "%s".`,UNKNOWN_FILTER_PROPERTY:`Unknown filter property "%s".`,UNKNOWN_VECTOR_PROPERTY:`Unknown vector property "%s". Make sure the property exists in the schema and is configured as a vector.`,INVALID_VECTOR_SIZE:`Vector size must be a number greater than 0. Got "%s" instead.`,INVALID_VECTOR_VALUE:`Vector value must be a number greater than 0. Got "%s" instead.`,INVALID_INPUT_VECTOR:`Property "%s" was declared as a %s-dimensional vector, but got a %s-dimensional vector instead.
320
320
  Input vectors must be of the size declared in the schema, as calculating similarity between vectors of different sizes can lead to unexpected results.`,WRONG_SEARCH_PROPERTY_TYPE:`Property "%s" is not searchable. Only "string" properties are searchable.`,FACET_NOT_SUPPORTED:`Facet doens't support the type "%s".`,INVALID_DISTANCE_SUFFIX:`Invalid distance suffix "%s". Valid suffixes are: cm, m, km, mi, yd, ft.`,INVALID_SEARCH_MODE:`Invalid search mode "%s". Valid modes are: "fulltext", "vector", "hybrid".`,MISSING_VECTOR_AND_SECURE_PROXY:`No vector was provided and no secure proxy was configured. Please provide a vector or configure an Orama Secure Proxy to perform hybrid search.`,MISSING_TERM:`"term" is a required parameter when performing hybrid search. Please provide a search term.`,INVALID_VECTOR_INPUT:`Invalid "vector" property. Expected an object with "value" and "property" properties, but got "%s" instead.`,PLUGIN_CRASHED:`A plugin crashed during initialization. Please check the error message for more information:`,PLUGIN_SECURE_PROXY_NOT_FOUND:`Could not find '@orama/secure-proxy-plugin' installed in your Orama instance.
321
321
  Please install it before proceeding with creating an answer session.
@@ -323,8 +323,8 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
323
323
  `,PLUGIN_SECURE_PROXY_MISSING_CHAT_MODEL:`Could not find a chat model defined in the secure proxy plugin configuration.
324
324
  Please provide a chat model before proceeding with creating an answer session.
325
325
  Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#plugin-secure-proxy
326
- `,ANSWER_SESSION_LAST_MESSAGE_IS_NOT_ASSISTANT:`The last message in the session is not an assistant message. Cannot regenerate non-assistant messages.`,PLUGIN_COMPONENT_CONFLICT:`The component "%s" is already defined. The plugin "%s" is trying to redefine it.`};function O$(e,...t){let n=Error(a$(D$[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function k$(e){return{raw:Number(e),formatted:l$(e)}}function A$(e){if(e.id){if(typeof e.id!=`string`)throw O$(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return d$()}function j$(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(t!==void 0&&!(r===`geopoint`&&typeof t==`object`&&typeof t.lon==`number`&&typeof t.lat==`number`)&&!(r===`enum`&&(typeof t==`string`||typeof t==`number`))){if(r===`enum[]`&&Array.isArray(t)){let e=t.length;for(let r=0;r<e;r++)if(typeof t[r]!=`string`&&typeof t[r]!=`number`)return n+`.`+r;continue}if(F$(r)){let e=R$(r);if(!Array.isArray(t)||t.length!==e)throw O$(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(I$(r)){if(!Array.isArray(t))return n;let e=L$(r),i=t.length;for(let r=0;r<i;r++)if(typeof t[r]!==e)return n+`.`+r;continue}if(typeof r==`object`){if(!t||typeof t!=`object`)return n;let e=j$(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}const M$={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},N$={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function P$(e){return e===`geopoint`}function F$(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function I$(e){return typeof e==`string`&&M$[e]}function L$(e){return N$[e]}function R$(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw O$(`INVALID_VECTOR_VALUE`,e);case t<=0:throw O$(`INVALID_VECTOR_SIZE`,e);default:return t}}function z$(){return{idToInternalId:new Map,internalIdToId:[],save:B$,load:V$}}function B$(e){return{internalIdToId:e.internalIdToId}}function V$(e,t){let{internalIdToId:n}=t;e.internalDocumentIDStore.idToInternalId.clear(),e.internalDocumentIDStore.internalIdToId=[];let r=n.length;for(let t=0;t<r;t++){let r=n[t];e.internalDocumentIDStore.idToInternalId.set(r,t+1),e.internalDocumentIDStore.internalIdToId.push(r)}}function H$(e,t){if(typeof t==`string`){let n=e.idToInternalId.get(t);if(n)return n;let r=e.idToInternalId.size+1;return e.idToInternalId.set(t,r),e.internalIdToId.push(t),r}return t>e.internalIdToId.length?H$(e,t.toString()):t}function U$(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function W$(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function G$(e,t){let n=H$(e.sharedInternalDocumentStore,t);return e.docs[n]}function K$(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=H$(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function q$(e){return e.docs}function J$(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function Y$(e,t){let n=H$(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function X$(e){return e.count}function Z$(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function Q$(e){return{docs:e.docs,count:e.count}}function $$(){return{create:W$,get:G$,getMultiple:K$,getAll:q$,store:J$,remove:Y$,count:X$,load:Z$,save:Q$}}const e1=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function t1(e,t){let n=[],r=e.plugins?.length;if(!r)return n;for(let i=0;i<r;i++)try{let r=e.plugins[i];typeof r[t]==`function`&&n.push(r[t])}catch(e){throw console.error(`Caught error in getAllPluginsByHook:`,e),O$(`PLUGIN_CRASHED`)}return n}const n1=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],r1=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function i1(e,t,n,r){if(e.some(b$))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function a1(e,t,n){if(e.some(b$))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function o1(e,t,n,r,i){if(e.some(b$))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function s1(e,t,n,r){if(e.some(b$))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function c1(e,t){if(e.some(b$))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var l1=class e{k;v;l=null;r=null;h=1;constructor(e,t){this.k=e,this.v=new Set(t)}updateHeight(){this.h=Math.max(e.getHeight(this.l),e.getHeight(this.r))+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return e.getHeight(this.l)-e.getHeight(this.r)}rotateLeft(){let e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(t){let n=new e(t.k,t.v);return n.l=t.l?e.fromJSON(t.l):null,n.r=t.r?e.fromJSON(t.r):null,n.h=t.h,n}},u1=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new l1(e,t))}insert(e,t,n=1e3){this.root=this.insertNode(this.root,e,t,n)}insertMultiple(e,t,n=1e3){for(let r of t)this.insert(e,r,n)}rebalance(){this.root&&=this.rebalanceNode(this.root)}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(t){let n=new e;return n.root=t.root?l1.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new l1(t,[n]);let i=[],a=e,o=null;for(;a!==null;)if(i.push({parent:o,node:a}),t<a.k)if(a.l===null){a.l=new l1(t,[n]),i.push({parent:a,node:a.l});break}else o=a,a=a.l;else if(t>a.k)if(a.r===null){a.r=new l1(t,[n]),i.push({parent:a,node:a.r});break}else o=a,a=a.r;else return a.v.add(n),e;let s=!1;this.insertCount++%r===0&&(s=!0);for(let t=i.length-1;t>=0;t--){let{parent:n,node:r}=i[t];if(r.updateHeight(),s){let t=this.rebalanceNode(r);n?n.l===r?n.l=t:n.r===r&&(n.r=t):e=t}}return e}rebalanceNode(e){let t=e.getBalanceFactor();if(t>1){if(e.l&&e.l.getBalanceFactor()>=0)return e.rotateRight();if(e.l)return e.l=e.l.rotateLeft(),e.rotateRight()}if(t<-1){if(e.r&&e.r.getBalanceFactor()<=0)return e.rotateLeft();if(e.r)return e.r=e.r.rotateRight(),e.rotateLeft()}return e}find(e){let t=this.findNodeByKey(e);return t?t.v:null}contains(e){return this.find(e)!==null}getSize(){let e=0,t=[],n=this.root;for(;n||t.length>0;){for(;n;)t.push(n),n=n.l;n=t.pop(),e++,n=n.r}return e}isBalanced(){if(!this.root)return!0;let e=[this.root];for(;e.length>0;){let t=e.pop(),n=t.getBalanceFactor();if(Math.abs(n)>1)return!1;t.l&&e.push(t.l),t.r&&e.push(t.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,t){let n=this.findNodeByKey(e);n&&(n.v.size===1?this.root=this.removeNode(this.root,e):n.v=new Set([...n.v.values()].filter(e=>e!==t)))}findNodeByKey(e){let t=this.root;for(;t;)if(e<t.k)t=t.l;else if(e>t.k)t=t.r;else return t;return null}removeNode(e,t){if(e===null)return null;let n=[],r=e;for(;r!==null&&r.k!==t;)n.push(r),r=t<r.k?r.l:r.r;if(r===null)return e;if(r.l===null||r.r===null){let t=r.l?r.l:r.r;if(n.length===0)e=t;else{let e=n[n.length-1];e.l===r?e.l=t:e.r=t}}else{let e=r,t=r.r;for(;t.l!==null;)e=t,t=t.l;r.k=t.k,r.v=t.v,e.l===t?e.l=t.r:e.r=t.r,r=e}n.push(r);for(let t=n.length-1;t>=0;t--){let r=n[t];r.updateHeight();let i=this.rebalanceNode(r);if(t>0){let e=n[t-1];e.l===r?e.l=i:e.r===r&&(e.r=i)}else e=i}return e}rangeSearch(e,t){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),i.k>=e&&i.k<=t)for(let e of i.v)n.add(e);if(i.k>t)break;i=i.r}return n}greaterThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.r;if(i=r.pop(),t&&i.k>=e||!t&&i.k>e)for(let e of i.v)n.add(e);else if(i.k<=e)break;i=i.l}return n}lessThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),t&&i.k<=e||!t&&i.k<e)for(let e of i.v)n.add(e);else if(i.k>e)break;i=i.r}return n}},d1=class e{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,t){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(t):this.numberToDocumentId.set(e,new Set([t]))}find(e){let t=this.numberToDocumentId.get(e);return t?Array.from(t):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,t){let n=this.numberToDocumentId.get(t);n&&(n.delete(e),n.size===0&&this.numberToDocumentId.delete(t))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(let t of this.numberToDocumentId.values())e+=t.size;return e}filter(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`eq`:{let t=e[n],r=this.numberToDocumentId.get(t);return r?Array.from(r):[]}case`in`:{let t=e[n],r=new Set;for(let e of t){let t=this.numberToDocumentId.get(e);if(t)for(let e of t)r.add(e)}return Array.from(r)}case`nin`:{let t=new Set(e[n]),r=new Set;for(let[e,n]of this.numberToDocumentId.entries())if(!t.has(e))for(let e of n)r.add(e);return Array.from(r)}default:throw Error(`Invalid operation`)}}filterArr(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`containsAll`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e].filter(e=>t.has(e))));return Array.from(r)}case`containsAny`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e,...t]));return Array.from(r)}default:throw Error(`Invalid operation`)}}static fromJSON(t){if(!t.numberToDocumentId)throw Error(`Invalid Flat Tree JSON`);let n=new e;for(let[e,r]of t.numberToDocumentId)n.numberToDocumentId.set(e,new Set(r));return n}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,t])=>[e,Array.from(t)])}}};function f1(e,t,n){if(n<0)return-1;if(e===t)return 0;let r=e.length,i=t.length;if(r===0)return i<=n?i:-1;if(i===0)return r<=n?r:-1;let a=Math.abs(r-i);if(e.startsWith(t))return a<=n?a:-1;if(t.startsWith(e))return 0;if(a>n)return-1;let o=[];for(let e=0;e<=r;e++){o[e]=[e];for(let t=1;t<=i;t++)o[e][t]=e===0?t:0}for(let a=1;a<=r;a++){let r=1/0;for(let n=1;n<=i;n++)e[a-1]===t[n-1]?o[a][n]=o[a-1][n-1]:o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+1),r=Math.min(r,o[a][n]);if(r>n)return-1}return o[r][i]<=n?o[r][i]:-1}function p1(e,t,n){let r=f1(e,t,n);return{distance:r,isBounded:r>=0}}var m1=class e{k;s;c=new Map;d=new Set;e;w=``;constructor(e,t,n){this.k=e,this.s=t,this.e=n}updateParent(e){this.w=e.w+this.s}addDocument(e){this.d.add(e)}removeDocument(e){return this.d.delete(e)}findAllWords(e,t,n,r){let i=[this];for(;i.length>0;){let a=i.pop();if(a.e){let{w:i,d:o}=a;if(n&&i!==t)continue;if(f$(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&p1(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(f$(e,i)!=null&&o.size>0){let t=e[i];for(let e of o)t.includes(e)||t.push(e)}}a.c.size>0&&i.push(...a.c.values())}return e}insert(t,n){let r=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=r.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c){if(r=s,i+=l,i===a){s.e||=!0,s.addDocument(n);return}continue}let u=o.slice(0,l),d=o.slice(l),f=t.slice(i+l),p=new e(u[0],u,!1);if(r.c.set(u[0],p),p.updateParent(r),s.s=d,s.k=d[0],p.c.set(d[0],s),s.updateParent(p),f){let t=new e(f[0],f,!0);t.addDocument(n),p.c.set(f[0],t),t.updateParent(p)}else p.e=!0,p.addDocument(n);return}else{let a=new e(o,t.slice(i),!0);a.addDocument(n),r.c.set(o,a),a.updateParent(r);return}}r.e||=!0,r.addDocument(n)}_findLevenshtein(e,t,n,r,i){let a=[{node:this,index:t,tolerance:n}];for(;a.length>0;){let{node:t,index:n,tolerance:o}=a.pop();if(t.w.startsWith(e)){t.findAllWords(i,e,!1,0);continue}if(o<0)continue;if(t.e){let{w:n,d:a}=t;if(n&&(p1(e,n,r).isBounded&&(i[n]=[]),f$(i,n)!==void 0&&a.size>0)){let e=new Set(i[n]);for(let t of a)e.add(t);i[n]=Array.from(e)}}if(n>=e.length)continue;let s=e[n];if(t.c.has(s)){let e=t.c.get(s);a.push({node:e,index:n+1,tolerance:o})}a.push({node:t,index:n+1,tolerance:o-1});for(let[e,r]of t.c)a.push({node:r,index:n,tolerance:o-1}),e!==s&&a.push({node:r,index:n+1,tolerance:o-1})}}find(e){let{term:t,exact:n,tolerance:r}=e;if(r&&!n){let e={};return this._findLevenshtein(t,0,r,r,e),e}else{let e=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=e.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c)e=s,i+=l;else if(i+l===a)if(l===a-i){if(n)return{};{let e={};return s.findAllWords(e,t,n,r),e}}else return{};else return{}}else return{}}let o={};return e.findAllWords(o,t,n,r),o}}contains(e){let t=this,n=0,r=e.length;for(;n<r;){let i=e[n],a=t.c.get(i);if(a){let i=a.s,o=i.length,s=0;for(;s<o&&n+s<r&&i[s]===e[n+s];)s++;if(s<o)return!1;n+=o,t=a}else return!1}return!0}removeWord(e){if(!e)return!1;let t=this,n=e.length,r=[];for(let i=0;i<n;i++){let n=e[i];if(t.c.has(n)){let e=t.c.get(n);r.push({parent:t,character:n}),i+=e.s.length-1,t=e}else return!1}for(t.d.clear(),t.e=!1;r.length>0&&t.c.size===0&&!t.e&&t.d.size===0;){let{parent:e,character:n}=r.pop();e.c.delete(n),t=e}return!0}removeDocumentByWord(e,t,n=!0){if(!e)return!0;let r=this,i=e.length;for(let a=0;a<i;a++){let i=e[a];if(r.c.has(i)){let o=r.c.get(i);a+=o.s.length-1,r=o,n&&r.w!==e||r.removeDocument(t)}else return!1}return!0}static getCommonPrefix(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return e.slice(0,r)}toJSON(){return{w:this.w,s:this.s,e:this.e,k:this.k,d:Array.from(this.d),c:Array.from(this.c?.entries())?.map(([e,t])=>[e,t.toJSON()])}}static fromJSON(t){let n=new e(t.k,t.s,t.e);return n.w=t.w,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([t,n])=>[t,e.fromJSON(n)])||[]),n}},h1=class e extends m1{constructor(){super(``,``,!1)}static fromJSON(t){let n=new e;return n.w=t.w,n.s=t.s,n.e=t.e,n.k=t.k,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([e,t])=>[e,m1.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},g1=class e{point;docIDs;left;right;parent;constructor(e,t){this.point=e,this.docIDs=new Set(t),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(t,n=null){let r=new e(t.point,t.docIDs);return r.parent=n,t.left&&(r.left=e.fromJSON(t.left,r)),t.right&&(r.right=e.fromJSON(t.right,r)),r}},_1=class e{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return`${e.lon},${e.lat}`}insert(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);if(r){t.forEach(e=>r.docIDs.add(e));return}let i=new g1(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%2==0)if(e.lon<a.point.lon){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}else if(e.lat<a.point.lat){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}o++}}contains(e){let t=this.getPointKey(e);return this.nodeMap.has(t)}getDocIDsByCoordinates(e){let t=this.getPointKey(e),n=this.nodeMap.get(t);return n?Array.from(n.docIDs):null}removeDocByID(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);r&&(r.docIDs.delete(t),r.docIDs.size===0&&(this.nodeMap.delete(n),this.deleteNode(r)))}deleteNode(e){let t=e.parent,n=e.left?e.left:e.right;n&&(n.parent=t),t?t.left===e?t.left=n:t.right===e&&(t.right=n):(this.root=n,this.root&&(this.root.parent=null))}searchByRadius(t,n,r=!0,i=`asc`,a=!1){let o=a?e.vincentyDistance:e.haversineDistance,s=[{node:this.root,depth:0}],c=[];for(;s.length>0;){let{node:e,depth:i}=s.pop();if(e==null)continue;let a=o(t,e.point);(r?a<=n:a>n)&&c.push({point:e.point,docIDs:Array.from(e.docIDs)}),e.left!=null&&s.push({node:e.left,depth:i+1}),e.right!=null&&s.push({node:e.right,depth:i+1})}return i&&c.sort((e,n)=>{let r=o(t,e.point),a=o(t,n.point);return i.toLowerCase()===`asc`?r-a:a-r}),c}searchByPolygon(t,n=!0,r=null,i=!1){let a=[{node:this.root,depth:0}],o=[];for(;a.length>0;){let{node:r,depth:i}=a.pop();if(r==null)continue;r.left!=null&&a.push({node:r.left,depth:i+1}),r.right!=null&&a.push({node:r.right,depth:i+1});let s=e.isPointInPolygon(t,r.point);(s&&n||!s&&!n)&&o.push({point:r.point,docIDs:Array.from(r.docIDs)})}let s=e.calculatePolygonCentroid(t);if(r){let t=i?e.vincentyDistance:e.haversineDistance;o.sort((e,n)=>{let i=t(s,e.point),a=t(s,n.point);return r.toLowerCase()===`asc`?i-a:a-i})}return o}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(t){let n=new e;return t.root&&(n.root=g1.fromJSON(t.root),n.buildNodeMap(n.root)),n}buildNodeMap(e){if(e==null)return;let t=this.getPointKey(e.point);this.nodeMap.set(t,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static calculatePolygonCentroid(e){let t=0,n=0,r=0,i=e.length;for(let a=0,o=i-1;a<i;o=a++){let i=e[a].lon,s=e[a].lat,c=e[o].lon,l=e[o].lat,u=i*l-c*s;t+=u,n+=(i+c)*u,r+=(s+l)*u}t/=2;let a=6*t;return n/=a,r/=a,{lon:n,lat:r}}static isPointInPolygon(e,t){let n=!1,r=t.lon,i=t.lat,a=e.length;for(let t=0,o=a-1;t<a;o=t++){let a=e[t].lon,s=e[t].lat,c=e[o].lon,l=e[o].lat;s>i!=l>i&&r<(c-a)*(i-s)/(l-s)+a&&(n=!n)}return n}static haversineDistance(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=(t.lat-e.lat)*n,o=(t.lon-e.lon)*n,s=Math.sin(a/2)*Math.sin(a/2)+Math.cos(r)*Math.cos(i)*Math.sin(o/2)*Math.sin(o/2);return 6371e3*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}static vincentyDistance(e,t){let n=6378137,r=1/298.257223563,i=(1-r)*n,a=Math.PI/180,o=e.lat*a,s=t.lat*a,c=(t.lon-e.lon)*a,l=Math.atan((1-r)*Math.tan(o)),u=Math.atan((1-r)*Math.tan(s)),d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u),h=c,g,_=1e3,v,y,b,x,S,C;do{let e=Math.sin(h),t=Math.cos(h);if(v=Math.sqrt(m*e*(m*e)+(f*p-d*m*t)*(f*p-d*m*t)),v===0)return 0;y=d*p+f*m*t,b=Math.atan2(v,y),x=f*m*e/v,S=1-x*x,C=y-2*d*p/S,isNaN(C)&&(C=0);let n=r/16*S*(4+r*(4-3*S));g=h,h=c+(1-n)*r*x*(b+n*v*(C+n*y*(-1+2*C*C)))}while(Math.abs(h-g)>1e-12&&--_>0);if(_===0)return NaN;let w=S*(n*n-i*i)/(i*i),T=1+w/16384*(4096+w*(-768+w*(320-175*w))),E=w/1024*(256+w*(-128+w*(74-47*w))),D=E*v*(C+E/4*(y*(-1+2*C*C)-E/6*C*(-3+4*v*v)*(-3+4*C*C)));return i*T*(b-D)}},v1=class e{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,t){t?this.true.add(e):this.false.add(e)}delete(e,t){t?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(t){let n=new e;return n.true=new Set(t.true),n.false=new Set(t.false),n}};function y1(e,t,n,r,i,{k:a,b:o,d:s}){return Math.log(1+(n-t+.5)/(t+.5))*(s+e*(a+1))/(e+a*(1-o+o*r/i))}var b1=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=x1(t,this.size);this.vectors.set(e,[n,t])}remove(e){this.vectors.delete(e)}find(e,t,n){return e instanceof Float32Array||(e=new Float32Array(e)),S1(e,n,this.vectors,this.size,t)}toJSON(){let e=[];for(let[t,[n,r]]of this.vectors)e.push([t,[n,Array.from(r)]]);return{size:this.size,vectors:e}}static fromJSON(t){let n=t,r=new e(n.size);for(let[e,[t,i]]of n.vectors)r.vectors.set(e,[t,new Float32Array(i)]);return r}};function x1(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function S1(e,t,n,r,i){let a=x1(e,r),o=[],s=t||n.keys();for(let t of s){let s=n.get(t);if(!s)continue;let c=s[0],l=s[1],u=0;for(let t=0;t<r;t++)u+=e[t]*l[t];let d=u/(a*c);d>=i&&o.push([t,d])}return o}function C1(e,t,n,r,i){let a=H$(e.sharedInternalDocumentStore,n);e.avgFieldLength[t]=((e.avgFieldLength[t]??0)*(i-1)+r.length)/i,e.fieldLengths[t][a]=r.length,e.frequencies[t][a]={}}function w1(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=H$(e.sharedInternalDocumentStore,n),s=a/r.length;e.frequencies[t][o][i]=s,i in e.tokenOccurrences[t]||(e.tokenOccurrences[t][i]=0),e.tokenOccurrences[t][i]=(e.tokenOccurrences[t][i]??0)+1}function T1(e,t,n,r){let i=H$(e.sharedInternalDocumentStore,n);r>1?e.avgFieldLength[t]=(e.avgFieldLength[t]*r-e.fieldLengths[t][i])/(r-1):e.avgFieldLength[t]=void 0,e.fieldLengths[t][i]=void 0,e.frequencies[t][i]=void 0}function E1(e,t,n){e.tokenOccurrences[t][n]--}function D1(e,t,n,r,i=``){r||={sharedInternalDocumentStore:t,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}};for(let[a,o]of Object.entries(n)){let n=`${i}${i?`.`:``}${a}`;if(typeof o==`object`&&!Array.isArray(o)){D1(e,t,o,r,n);continue}if(F$(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new b1(R$(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new v1,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new u1(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new h1,isArray:e},r.avgFieldLength[n]=0,r.frequencies[n]={},r.tokenOccurrences[n]={},r.fieldLengths[n]={};break;case`enum`:case`enum[]`:r.indexes[n]={type:`Flat`,node:new d1,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new _1,isArray:e};break;default:throw O$(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function O1(e,t,n,r,i,a,o,s){return c=>{let{type:l,node:u}=t.indexes[n];switch(l){case`Bool`:u[c?`true`:`false`].add(r);break;case`AVL`:{let e=s?.avlRebalanceThreshold??1;u.insert(c,r,e);break}case`Radix`:{let s=a.tokenize(c,i,n,!1);e.insertDocumentScoreParameters(t,n,r,s,o);for(let i of s)e.insertTokenScoreParameters(t,n,r,s,i),u.insert(i,r);break}case`Flat`:u.insert(c,r);break;case`BKD`:u.insert(c,[r]);break}}}function k1(e,t,n,r,i,a,o,s,c,l,u){if(F$(o))return A1(t,n,a,r,i);let d=O1(e,t,n,i,s,c,l,u);if(!I$(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function A1(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function j1(e,t,n,r,i,a,o,s,c,l){if(F$(o))return t.vectorIndexes[n].node.remove(i),!0;let{type:u,node:d}=t.indexes[n];switch(u){case`AVL`:return d.removeDocument(a,i),!0;case`Bool`:return d[a?`true`:`false`].delete(i),!0;case`Radix`:{let o=c.tokenize(a,s,n);e.removeDocumentScoreParameters(t,n,r,l);for(let r of o)e.removeTokenScoreParameters(t,n,r),d.removeDocumentByWord(r,i);return!0}case`Flat`:return d.removeDocument(i,a),!0;case`BKD`:return d.removeDocByID(a,i),!1}}function M1(e,t,n,r,i,a,o,s,c,l){if(!I$(o))return j1(e,t,n,r,i,a,o,s,c,l);let u=L$(o),d=a,f=d.length;for(let a=0;a<f;a++)j1(e,t,n,r,i,d[a],u,s,c,l);return!0}function N1(e,t,n,r,i,a,o,s,c,l){let u=Array.from(r),d=e.avgFieldLength[t],f=e.fieldLengths[t],p=e.tokenOccurrences[t],m=e.frequencies[t],h=typeof p[n]==`number`?p[n]??0:0,g=u.length;for(let e=0;e<g;e++){let r=u[e];if(c&&!c.has(r))continue;l.has(r)||l.set(r,new Map);let p=l.get(r);p.set(t,(p.get(t)||0)+1);let g=y1(m?.[r]?.[n]??0,h,i,f[r],d,a);o.has(r)?o.set(r,o.get(r)+g*s):o.set(r,g*s)}}function P1(e,t,n,r,i,a,o,s,c,l,u,d=0){let f=n.tokenize(t,r),p=f.length||1,m=new Map,h=new Map,g=new Map;for(let n of i){if(!(n in e.indexes))continue;let r=e.indexes[n],{type:i}=r;if(i!==`Radix`)throw O$(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw O$(`INVALID_BOOST_VALUE`,d);f.length===0&&!t&&f.push(``);let p=f.length;for(let t=0;t<p;t++){let i=f[t],s=r.node.find({term:i,exact:a,tolerance:o}),p=Object.keys(s);p.length>0&&h.set(i,!0);let _=p.length;for(let t=0;t<_;t++){let r=p[t],i=s[r];N1(e,n,r,i,l,c,g,d,u,m)}}}let _=Array.from(g.entries()).map(([e,t])=>[e,t]).sort((e,t)=>t[1]-e[1]);if(_.length===0)return[];if(d===1)return _;if(d===0){if(p===1)return _;for(let e of f)if(!h.get(e))return[];return _.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1})}let v=_.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1});if(v.length>0){let e=_.filter(([e])=>!v.some(([t])=>t===e)),t=Math.ceil(e.length*d);return[...v,...e.slice(0,t)]}return _}function F1(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:S$(...i.map(n=>F1(e,t,n,r)))}if(`or`in n&&n.or&&Array.isArray(n.or)){let i=n.or;return i.length===0?new Set:i.map(n=>F1(e,t,n,r)).reduce((e,t)=>w$(e,t),new Set)}if(`not`in n&&n.not){let i=n.not,a=new Set,o=e.sharedInternalDocumentStore;for(let e=1;e<=o.internalIdToId.length;e++)a.add(e);return T$(a,F1(e,t,i,r))}let i=Object.keys(n),a=i.reduce((e,t)=>({[t]:new Set,...e}),{});for(let o of i){let i=n[o];if(e.indexes[o]===void 0)throw O$(`UNKNOWN_FILTER_PROPERTY`,o);let{node:s,type:c,isArray:l}=e.indexes[o];if(c===`Bool`){let e=s,t=i?e.true:e.false;a[o]=w$(a[o],t);continue}if(c===`BKD`){let e;if(`radius`in i)e=`radius`;else if(`polygon`in i)e=`polygon`;else throw Error(`Invalid operation ${i}`);if(e===`radius`){let{value:t,coordinates:n,unit:r=`m`,inside:c=!0,highPrecision:l=!1}=i[e],u=v$(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=V1(a[o],d)}else{let{coordinates:t,inside:n=!0,highPrecision:r=!1}=i[e],c=s.searchByPolygon(t,n,void 0,r);a[o]=V1(a[o],c)}continue}if(c===`Radix`&&(typeof i==`string`||Array.isArray(i))){for(let e of[i].flat()){let n=t.tokenize(e,r,o);for(let e of n){let t=s.find({term:e,exact:!0});a[o]=G1(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw O$(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=w$(a[o],e);continue}if(c===`AVL`){let e=u[0],t=i[e],n;switch(e){case`gt`:n=s.greaterThan(t,!1);break;case`gte`:n=s.greaterThan(t,!0);break;case`lt`:n=s.lessThan(t,!1);break;case`lte`:n=s.lessThan(t,!0);break;case`eq`:n=s.find(t)??new Set;break;case`between`:{let[e,r]=t;n=s.rangeSearch(e,r);break}default:throw O$(`INVALID_FILTER_OPERATION`,e)}a[o]=w$(a[o],n)}}return S$(...Object.values(a))}function I1(e){return e.searchableProperties}function L1(e){return e.searchablePropertiesWithTypes}function R1(e,t){let{indexes:n,vectorIndexes:r,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}=t,u={},d={};for(let e of Object.keys(n)){let{node:t,type:r,isArray:i}=n[e];switch(r){case`Radix`:u[e]={type:`Radix`,node:h1.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:d1.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:u1.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:_1.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:v1.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:b1.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function z1(e){let{indexes:t,vectorIndexes:n,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}=e,l={};for(let e of Object.keys(n))l[e]=n[e].node.toJSON();let u={};for(let e of Object.keys(t)){let{type:n,node:r,isArray:i}=t[e];n===`Flat`||n===`Radix`||n===`AVL`||n===`BKD`||n===`Bool`?u[e]={type:n,node:r.toJSON(),isArray:i}:(u[e]=t[e],u[e].node=u[e].node.toJSON())}return{indexes:u,vectorIndexes:l,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}}function B1(){return{create:D1,insert:k1,remove:M1,insertDocumentScoreParameters:C1,insertTokenScoreParameters:w1,removeDocumentScoreParameters:T1,removeTokenScoreParameters:E1,calculateResultScores:N1,search:P1,searchByWhereClause:F1,getSearchableProperties:I1,getSearchablePropertiesWithTypes:L1,load:R1,save:z1}}function V1(e,t){e||=new Set;let n=t.length;for(let r=0;r<n;r++){let n=t[r].docIDs,i=n.length;for(let t=0;t<i;t++)e.add(n[t])}return e}function H1(e,t,n=!1){let r=n?_1.vincentyDistance:_1.haversineDistance,i=[],a=[];for(let{point:n}of e)a.push(r(t,n));let o=Math.max(...a),s=0;for(let{docIDs:t}of e){let e=o-a[s]+1;for(let n of t)i.push([n,e]);s++}return i.sort((e,t)=>t[1]-e[1]),i}function U1(e,t){let n=Object.keys(e);if(n.length!==1)return{isGeoOnly:!1};let r=n[0],i=e[r];if(t.indexes[r]===void 0)return{isGeoOnly:!1};let{type:a}=t.indexes[r];return a===`BKD`&&i&&(`radius`in i||`polygon`in i)?{isGeoOnly:!0,geoProperty:r,geoOperation:i}:{isGeoOnly:!1}}function W1(e,t){let n=e,r=U1(t,n);if(!r.isGeoOnly||!r.geoProperty||!r.geoOperation)return null;let{node:i}=n.indexes[r.geoProperty],a=r.geoOperation,o=i,s;if(`radius`in a){let{value:e,coordinates:t,unit:n=`m`,inside:r=!0,highPrecision:i=!1}=a.radius,c=t,l=v$(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),H1(s,c,i)}else if(`polygon`in a){let{coordinates:e,inside:t=!0,highPrecision:n=!1}=a.polygon;s=o.searchByPolygon(e,t,`asc`,n);let r=_1.calculatePolygonCentroid(e);return H1(s,r,n)}return null}function G1(e,t){e||=new Set;let n=Object.keys(t),r=n.length;for(let i=0;i<r;i++){let r=t[n[i]],a=r.length;for(let t=0;t<a;t++)e.add(r[t])}return e}function K1(e,t,n,r,i){let a={language:e.tokenizer.language,sharedInternalDocumentStore:t,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(let[o,s]of Object.entries(n)){let n=`${i}${i?`.`:``}${o}`;if(!r.includes(n)){if(typeof s==`object`&&!Array.isArray(s)){let i=K1(e,t,s,r,n);i$(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!F$(s))switch(s){case`boolean`:case`number`:case`string`:a.sortableProperties.push(n),a.sortablePropertiesWithTypes[n]=s,a.sorts[n]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:s};break;case`geopoint`:case`enum`:continue;case`enum[]`:case`boolean[]`:case`number[]`:case`string[]`:continue;default:throw O$(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function q1(e,t,n,r){return r?.enabled===!1?{disabled:!0}:K1(e,t,n,(r||{}).unsortableProperties||[],``)}function J1(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=H$(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&t0(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function Y1(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)$1(e,n);e.isSorted=!0}function X1(e,t,n){return t[1].localeCompare(n[1],ZQ(e))}function Z1(e,t){return e[1]-t[1]}function Q1(e,t){return t[1]?-1:1}function $1(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=X1.bind(null,e.language);break;case`number`:r=Z1.bind(null);break;case`boolean`:r=Q1.bind(null);break}n.orderedDocs.sort(r);let i=n.orderedDocs.length;for(let e=0;e<i;e++){let t=n.orderedDocs[e][0];n.docs.set(t,e)}}function e0(e){let t=Object.keys(e.sorts);for(let n of t)t0(e,n)}function t0(e,t){let n=e.sorts[t];n.orderedDocsToRemove.size&&(n.orderedDocs=n.orderedDocs.filter(e=>!n.orderedDocsToRemove.has(e[0])),n.orderedDocsToRemove.clear())}function n0(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=H$(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function r0(e,t,n){if(!e.enabled)throw O$(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw O$(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return t0(e,r),Y1(e),t.sort((t,n)=>{let r=a.docs.get(H$(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(H$(e.sharedInternalDocumentStore,n[0])),s=r!==void 0,c=o!==void 0;return!s&&!c?0:s?c?i?o-r:r-o:-1:1}),t}function i0(e){return e.enabled?e.sortableProperties:[]}function a0(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function o0(e,t){let n=t;if(!n.enabled)return{enabled:!1};let r=Object.keys(n.sorts).reduce((e,t)=>{let{docs:r,orderedDocs:i,type:a}=n.sorts[t];return e[t]={docs:new Map(Object.entries(r).map(([e,t])=>[+e,t])),orderedDocsToRemove:new Map,orderedDocs:i,type:a},e},{});return{sharedInternalDocumentStore:e,language:n.language,sortableProperties:n.sortableProperties,sortablePropertiesWithTypes:n.sortablePropertiesWithTypes,sorts:r,enabled:!0,isSorted:n.isSorted}}function s0(e){if(!e.enabled)return{enabled:!1};e0(e),Y1(e);let t=Object.keys(e.sorts).reduce((t,n)=>{let{docs:r,orderedDocs:i,type:a}=e.sorts[n];return t[n]={docs:Object.fromEntries(r.entries()),orderedDocs:i,type:a},t},{});return{language:e.language,sortableProperties:e.sortableProperties,sortablePropertiesWithTypes:e.sortablePropertiesWithTypes,sorts:t,enabled:e.enabled,isSorted:e.isSorted}}function c0(){return{create:q1,insert:J1,remove:n0,save:s0,load:o0,sortBy:r0,getSortableProperties:i0,getSortablePropertiesWithTypes:a0}}const l0=[65,65,65,65,65,65,65,67,69,69,69,69,73,73,73,73,69,78,79,79,79,79,79,null,79,85,85,85,85,89,80,115,97,97,97,97,97,97,97,99,101,101,101,101,105,105,105,105,101,110,111,111,111,111,111,null,111,117,117,117,117,121,112,121,65,97,65,97,65,97,67,99,67,99,67,99,67,99,68,100,68,100,69,101,69,101,69,101,69,101,69,101,71,103,71,103,71,103,71,103,72,104,72,104,73,105,73,105,73,105,73,105,73,105,73,105,74,106,75,107,107,76,108,76,108,76,108,76,108,76,108,78,110,78,110,78,110,110,78,110,79,111,79,111,79,111,79,111,82,114,82,114,82,114,83,115,83,115,83,115,83,115,84,116,84,116,84,116,85,117,85,117,85,117,85,117,85,117,85,117,87,119,89,121,89,90,122,90,122,90,122,115];function u0(e){return e<192||e>383?e:l0[e-192]||e}function d0(e){let t=[];for(let n=0;n<e.length;n++)t[n]=u0(e.charCodeAt(n));return String.fromCharCode(...t)}const f0={ational:`ate`,tional:`tion`,enci:`ence`,anci:`ance`,izer:`ize`,bli:`ble`,alli:`al`,entli:`ent`,eli:`e`,ousli:`ous`,ization:`ize`,ation:`ate`,ator:`ate`,alism:`al`,iveness:`ive`,fulness:`ful`,ousness:`ous`,aliti:`al`,iviti:`ive`,biliti:`ble`,logi:`log`},p0={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},m0=`[aeiouy]`,h0=`[^aeiou][^aeiouy]*`;m0+``;const g0=`^(`+h0+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`;``+h0;const _0=`^(`+h0+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,v0=`^(`+h0+`)?[aeiouy]`;function y0(e){let t,n,r,i,a,o;if(e.length<3)return e;let s=e.substring(0,1);if(s==`y`&&(e=s.toUpperCase()+e.substring(1)),r=/^(.+?)(ss|i)es$/,i=/^(.+?)([^s])s$/,r.test(e)?e=e.replace(r,`$1$2`):i.test(e)&&(e=e.replace(i,`$1$2`)),r=/^(.+?)eed$/,i=/^(.+?)(ed|ing)$/,r.test(e)){let t=r.exec(e);r=new RegExp(g0),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(v0),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+h0+m0+`[^aeiouwxy]$`),i.test(e)?e+=`e`:a.test(e)?(r=/.$/,e=e.replace(r,``)):o.test(e)&&(e+=`e`)));if(r=/^(.+?)y$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(v0),t&&r.test(t)&&(e=t+`i`)),r=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(g0),t&&r.test(t)&&(e=t+f0[n])}if(r=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(g0),t&&r.test(t)&&(e=t+p0[n])}if(r=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,i=/^(.+?)(s|t)(ion)$/,r.test(e))t=r.exec(e)?.[1],r=new RegExp(_0),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(_0),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(_0),i=RegExp(`^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`),a=RegExp(`^`+h0+m0+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(_0),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function b0(e,t,n=!0){let r=`${this.language}:${e}:${t}`;return n&&this.normalizationCache.has(r)?this.normalizationCache.get(r):this.stopWords?.includes(t)?(n&&this.normalizationCache.set(r,``),``):(this.stemmer&&!this.stemmerSkipProperties.has(e)&&(t=this.stemmer(t)),t=d0(t),n&&this.normalizationCache.set(r,t),t)}function x0(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function S0(e,t,n,r=!0){if(t&&t!==this.language)throw O$(`LANGUAGE_NOT_SUPPORTED`,t);if(typeof e!=`string`)return[e];let i=this.normalizeToken.bind(this,n??``),a;if(n&&this.tokenizeSkipProperties.has(n))a=[i(e,r)];else{let t=YQ[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=x0(a);return this.allowDuplicates?o:Array.from(new Set(o))}function C0(e={}){if(!e.language)e.language=`english`;else if(!XQ.includes(e.language))throw O$(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw O$(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=y0;else throw O$(`MISSING_STEMMER`,e.language);let n;if(e.stopWords!==!1){if(n=[],Array.isArray(e.stopWords))n=e.stopWords;else if(typeof e.stopWords==`function`)n=e.stopWords(n);else if(e.stopWords)throw O$(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw O$(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw O$(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:S0,language:e.language,stemmer:t,stemmerSkipProperties:new Set(e.stemmerSkipProperties?[e.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(e.tokenizeSkipProperties?[e.tokenizeSkipProperties].flat():[]),stopWords:n,allowDuplicates:!!e.allowDuplicates,normalizeToken:b0,normalizationCache:new Map};return r.tokenize=S0.bind(r),r.normalizeToken=b0,r}function w0(e){return{sharedInternalDocumentStore:e,rules:new Map}}function T0(e,t){if(e.rules.has(t.id))throw Error(`PINNING_RULE_ALREADY_EXISTS: A pinning rule with id "${t.id}" already exists. Use updateRule to modify it.`);e.rules.set(t.id,t)}function E0(e,t){if(!e.rules.has(t.id))throw Error(`PINNING_RULE_NOT_FOUND: Cannot update pinning rule with id "${t.id}" because it does not exist. Use addRule to create it.`);e.rules.set(t.id,t)}function D0(e,t){return e.rules.delete(t)}function O0(e,t){return e.rules.get(t)}function k0(e){return Array.from(e.rules.values())}function A0(e,t){let n=e.toLowerCase().trim(),r=t.pattern.toLowerCase().trim();switch(t.anchoring){case`is`:return n===r;case`starts_with`:return n.startsWith(r);case`contains`:return n.includes(r);default:return!1}}function j0(e,t){return e?t.conditions.every(t=>A0(e,t)):!1}function M0(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())j0(t,r)&&n.push(r);return n}function N0(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function P0(e){return{rules:Array.from(e.rules.entries())}}function F0(){return{create:w0,addRule:T0,updateRule:E0,removeRule:D0,getRule:O0,getAllRules:k0,getMatchingRules:M0,load:N0,save:P0}}function I0(e){let t={formatElapsedTime:k$,getDocumentIndexId:A$,getDocumentProperties:h$,validateSchema:j$};for(let n of r1){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw O$(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!n1.includes(t)&&!r1.includes(t))throw O$(`UNSUPPORTED_COMPONENT`,t)}function L0({schema:e,sort:t,language:n,components:r,id:i,plugins:a}){r||={};for(let t of a??[]){if(!(`getComponents`in t)||typeof t.getComponents!=`function`)continue;let n=t.getComponents(e),i=Object.keys(n);for(let e of i)if(r[e])throw O$(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=d$();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:C0(o):C0({language:n??`english`}),r.tokenizer&&n)throw O$(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=z$();s||=B1(),l||=c0(),c||=$$(),u||=F0(),I0(r);let{getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,formatElapsedTime:h}=r,g={data:{},caches:{},schema:e,tokenizer:o,index:s,sorter:l,documentsStore:c,pinning:u,internalDocumentIDStore:d,getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,beforeInsert:[],afterInsert:[],beforeRemove:[],afterRemove:[],beforeUpdate:[],afterUpdate:[],beforeUpsert:[],afterUpsert:[],beforeSearch:[],afterSearch:[],beforeInsertMultiple:[],afterInsertMultiple:[],beforeRemoveMultiple:[],afterRemoveMultiple:[],beforeUpdateMultiple:[],afterUpdateMultiple:[],beforeUpsertMultiple:[],afterUpsertMultiple:[],afterCreate:[],formatElapsedTime:h,id:i,plugins:a,version:R0()};g.data={index:g.index.create(g,d,e),docs:g.documentsStore.create(g,d),sorting:g.sorter.create(g,d,e,t),pinning:g.pinning.create(d)};for(let e of e1)g[e]=(g[e]??[]).concat(t1(g,e));let _=g.afterCreate;return _&&c1(_,g),g}function R0(){return`{{VERSION}}`}function z0(e){return e.documentsStore.count(e.data.docs)}function B0(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw O$(`SCHEMA_VALIDATION_FAILURE`,a);return b$(e.beforeInsert)||b$(e.afterInsert)||b$(e.index.beforeInsert)||b$(e.index.insert)||b$(e.index.afterInsert)?U0(e,t,n,r,i):W0(e,t,n,r,i)}const V0=new Set([`enum`,`enum[]`]),H0=new Set([`string`,`number`]);async function U0(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw O$(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=H$(e.internalDocumentIDStore,s);if(r||await i1(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw O$(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];G0(n,r,e,t)}return await K0(e,s,u,f,l,n,t,i),r||await i1(e.afterInsert,e,s,t),s}function W0(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw O$(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=H$(e.internalDocumentIDStore,s);if(r||i1(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw O$(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];G0(n,r,e,t)}return q0(e,s,u,f,l,n,t,i),r||i1(e.afterInsert,e,s,t),s}function G0(e,t,n,r){if(!(P$(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(F$(t)&&Array.isArray(r))&&!(I$(t)&&Array.isArray(r))&&!(V0.has(t)&&H0.has(e))&&e!==t)throw O$(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function K0(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o];await e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i);let l=e.internalDocumentIDStore.idToInternalId.get(t);await e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),await e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function q0(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o],l=H$(e.internalDocumentIDStore,t);e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i),e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function J0(e,t,n,r,i,a){return b$(e.afterInsertMultiple)||b$(e.beforeInsertMultiple)||b$(e.index.beforeInsert)||b$(e.index.insert)||b$(e.index.afterInsert)?Y0(e,t,n,r,i,a):X0(e,t,n,r,i,a)}async function Y0(e,t,n=1e3,r,i,a=0){let o=[],s=async a=>{let s=Math.min(a+n,t.length),c=t.slice(a,s);for(let t of c){let n=await B0(e,t,r,i,{avlRebalanceThreshold:c.length});o.push(n)}return s};return await(async()=>{let e=0;for(;e<t.length;){let t=Date.now();if(e=await s(e),a>0){let e=a-(Date.now()-t);e>0&&E$(e)}}})(),i||await a1(e.afterInsertMultiple,e,t),o}function X0(e,t,n=1e3,r,i,a=0){let o=[],s=0;function c(){let a=t.slice(s*n,(s+1)*n);if(a.length===0)return!1;for(let t of a){let n=B0(e,t,r,i,{avlRebalanceThreshold:a.length});o.push(n)}return s++,!0}function l(){let e=Date.now();for(;c();)if(a>0){let t=Date.now()-e;if(t>=a){let e=a-t%a;e>0&&E$(e)}}}return l(),i||a1(e.afterInsertMultiple,e,t),o}function Z0(e,t,n,r){return b$(e.index.beforeRemove)||b$(e.index.remove)||b$(e.index.afterRemove)?Q0(e,t,n,r):$0(e,t,n,r)}async function Q0(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=H$(e.internalDocumentIDStore,t),l=U$(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||await i1(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];await e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),await e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),await e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=await e.sorter.getSortableProperties(e.data.sorting),h=await e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||await i1(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function $0(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=H$(e.internalDocumentIDStore,t),l=U$(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||i1(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=e.sorter.getSortableProperties(e.data.sorting),h=e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||i1(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function e2(e,t,n,r,i){return b$(e.index.beforeRemove)||b$(e.index.remove)||b$(e.index.afterRemove)||b$(e.beforeRemoveMultiple)||b$(e.afterRemoveMultiple)?t2(e,t,n,r,i):n2(e,t,n,r,i)}async function t2(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>U$(e.internalDocumentIDStore,H$(e.internalDocumentIDStore,t)));return i||await a1(e.beforeRemoveMultiple,e,o),await new Promise((o,s)=>{let c=0;async function l(){let u=t.slice(c*n,++c*n);if(!u.length)return o();for(let t of u)try{await Z0(e,t,r,i)&&a++}catch(e){s(e)}setTimeout(l,0)}setTimeout(l,0)}),i||await a1(e.afterRemoveMultiple,e,o),a}function n2(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>U$(e.internalDocumentIDStore,H$(e.internalDocumentIDStore,t)));i||a1(e.beforeRemoveMultiple,e,o);let s=0;function c(){let o=t.slice(s*n,++s*n);if(o.length){for(let t of o)Z0(e,t,r,i)&&a++;setTimeout(c,0)}}return c(),i||a1(e.afterRemoveMultiple,e,o),a}function r2(e,t){return e[1]-t[1]}function i2(e,t){return t[1]-e[1]}function a2(e=`desc`){return e.toLowerCase()===`asc`?r2:i2}function o2(e,t,n){let r={},i=t.map(([e])=>e),a=e.documentsStore.getMultiple(e.data.docs,i),o=Object.keys(n),s=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e of o){let t;if(s[e]===`number`){let{ranges:r}=n[e],i=r.length,a=Array.from({length:i});for(let e=0;e<i;e++){let t=r[e];a[e]=[`${t.from}-${t.to}`,0]}t=Object.fromEntries(a)}r[e]={count:0,values:t??{}}}let c=a.length;for(let e=0;e<c;e++){let t=a[e];for(let e of o){let i=e.includes(`.`)?g$(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;s2(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=s2(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:c2(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=c2(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw O$(`FACET_NOT_SUPPORTED`,a)}}}for(let e of o){let t=r[e];if(t.count=Object.keys(t.values).length,s[e]===`string`){let r=n[e],i=a2(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function s2(e,t,n){return r=>{for(let i of e){let e=`${i.from}-${i.to}`;n?.has(e)||r>=i.from&&r<=i.to&&(t[e]===void 0?t[e]=1:(t[e]++,n?.add(e)))}}}function c2(e,t,n){let r=t===`boolean`?`false`:``;return t=>{let i=t?.toString()??r;n?.has(i)||(e[i]=(e[i]??0)+1,n?.add(i))}}const l2={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},u2=[`string`,`number`,`boolean`];function d2(e,t,n){let r=n.properties,i=r.length,a=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e=0;e<i;e++){let t=r[e];if(a[t]===void 0)throw O$(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!u2.includes(a[t]))throw O$(`INVALID_GROUP_BY_PROPERTY`,t,u2.join(`, `),a[t])}let o=t.map(([t])=>U$(e.internalDocumentIDStore,t)),s=e.documentsStore.getMultiple(e.data.docs,o),c=s.length,l=n.maxResult||2**53-1,u=[],d={};for(let e=0;e<i;e++){let t=r[e],n={property:t,perValue:{}},i=new Set;for(let e=0;e<c;e++){let r=s[e],a=g$(r,t);if(a===void 0)continue;let o=typeof a==`boolean`?``+a:a,c=n.perValue[o]??{indexes:[],count:0};c.count>=l||(c.indexes.push(e),c.count++,n.perValue[o]=c,i.add(a))}u.push(Array.from(i)),d[t]=n}let f=f2(u),p=f.length,m=[];for(let e=0;e<p;e++){let t=f[e],n=t.length,i={values:[],indexes:[]},a=[];for(let e=0;e<n;e++){let n=t[e],o=r[e];a.push(d[o].perValue[typeof n==`boolean`?``+n:n].indexes),i.values.push(n)}i.indexes=m$(a).sort((e,t)=>e-t),i.indexes.length!==0&&m.push(i)}let h=m.length,g=Array.from({length:h});for(let e=0;e<h;e++){let r=m[e],i=n.reduce||l2,a=r.indexes.map(e=>({id:o[e],score:t[e][1],document:s[e]})),c=i.reducer.bind(null,r.values),l=i.getInitialValue(r.indexes.length),u=a.reduce(c,l);g[e]={values:r.values,result:u}}return g}function f2(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=f2(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];i$(n,t),i.push(n)}return i}function p2(e,t,n,r){let i=M0(t,r);if(i.length===0)return n;let a=i.flatMap(e=>e.consequence.promote);a.sort((e,t)=>e.position-t.position);let o=new Set,s=new Map,c=new Set;for(let t of a){let n=H$(e.internalDocumentIDStore,t.doc_id);if(n!==void 0){if(s.has(n)){let e=s.get(n);t.position<e&&s.set(n,t.position);continue}c.has(t.position)||(o.add(n),s.set(n,t.position),c.add(t.position))}}if(s.size===0)return n;let l=n.filter(([e])=>!o.has(e)),u=[];for(let[t,r]of s.entries())n.find(([e])=>e===t)?u.push([t,1e6-r]):e.documentsStore.get(e.data.docs,t)&&u.push([t,0]);u.sort((e,t)=>(s.get(e[0])??1/0)-(s.get(t[0])??1/0));let d=[],f=new Map;for(let e of u){let t=s.get(e[0]);f.set(t,e)}let p=0,m=0;for(;m<l.length+u.length;)if(f.has(m))d.push(f.get(m)),m++;else if(p<l.length)d.push(l[p]),p++,m++;else break;for(let[e,t]of f.entries())e>=d.length&&d.push(t);return d}function m2(e,t,n){let{term:r,properties:i}=t,a=e.data.index,o=e.caches.propertiesToSearch;if(!o){let t=e.index.getSearchablePropertiesWithTypes(a);o=e.index.getSearchableProperties(a),o=o.filter(e=>t[e].startsWith(`string`)),e.caches.propertiesToSearch=o}if(i&&i!==`*`){for(let e of i)if(!o.includes(e))throw O$(`UNKNOWN_INDEX`,e,o.join(`, `));o=o.filter(e=>i.includes(e))}let s=Object.keys(t.where??{}).length>0,c;s&&(c=e.index.searchByWhereClause(a,e.tokenizer,t.where,n));let l,u=t.threshold!==void 0&&t.threshold!==null?t.threshold:1;if(r||i){let i=z0(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},y2(t.relevance),i,c,u),t.exact&&r){let t=r.trim().split(/\s+/);l=l.filter(([n])=>{let r=e.documentsStore.get(e.data.docs,n);if(!r)return!1;for(let e of o){let n=g2(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${h2(e)}\\b`).test(n)))return!0}return!1})}}else l=s?W1(a,t.where)||(c?Array.from(c):[]).map(e=>[+e,0]):Object.keys(e.documentsStore.getAll(e.data.docs)).map(e=>[+e,0]);return l}function h2(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function g2(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return r}function _2(e,t,n){let r=u$();function i(){let i=Object.keys(e.data.index.vectorIndexes),a=t.facets&&Object.keys(t.facets).length>0,{limit:o=10,offset:s=0,distinctOn:c,includeVectors:l=!1}=t,u=t.preflight===!0,d=m2(e,t,n);if(t.sortBy)if(typeof t.sortBy==`function`){let n=d.map(([e])=>e),r=e.documentsStore.getMultiple(e.data.docs,n).map((e,t)=>[d[t][0],d[t][1],e]);r.sort(t.sortBy),d=r.map(([e,t])=>[e,t])}else d=e.sorter.sortBy(e.data.sorting,d,t.sortBy).map(([t,n])=>[H$(e.internalDocumentIDStore,t),n]);else d=d.sort(p$);d=p2(e,e.data.pinning,d,t.term);let f;u||(f=c?j2(e,d,s,o,c):M2(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||y$(p,i)),a&&(p.facets=o2(e,d,t.facets)),t.groupBy&&(p.groups=d2(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(u$()-r),p}async function a(){e.beforeSearch&&await s1(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await o1(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}const v2={k:1.2,b:.75,d:.5};function y2(e){let t=e??{};return t.k=t.k??v2.k,t.b=t.b??v2.b,t.d=t.d??v2.d,t}function b2(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw O$(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw O$(`UNKNOWN_VECTOR_PROPERTY`,r.property);let a=i.node.size;if(r?.value.length!==a)throw r?.property===void 0||r?.value.length===void 0?O$(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):O$(`INVALID_INPUT_VECTOR`,r.property,a,r.value.length);let o=e.data.index,s;return Object.keys(t.where??{}).length>0&&(s=e.index.searchByWhereClause(o,e.tokenizer,t.where,n)),i.node.find(r.value,t.similarity??.8,s)}function x2(e,t,n=`english`){let r=u$();function i(){let i=b2(e,t,n).sort(p$);i=p2(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=o2(e,i,t.facets));let o=t.vector.property,s=t.includeVectors??!1,c=t.limit??10,l=t.offset??0,u=Array.from({length:c});for(let t=0;t<c;t++){let n=i[t+l];if(!n)break;let r=e.data.docs.docs[n[0]];r&&(s||(r[o]=null),u[t]={id:U$(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=d2(e,i,t.groupBy));let f=u$()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:l$(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await s1(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await o1(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function S2(e,t,n){let r=T2(m2(e,t,n)),i=b2(e,t,n),a=t.hybridWeights;return O2(r,i,t.term??``,a)}function C2(e,t,n){let r=u$();function i(){let i=S2(e,t,n);i=p2(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=o2(e,i,t.facets));let o;t.groupBy&&(o=d2(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=M2(e,i,s,c).filter(Boolean),u=u$(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:l$(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||y$(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await s1(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await o1(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function w2(e){return e[1]}function T2(e){let t=Math.max.apply(Math,e.map(w2));return e.map(([e,n])=>[e,n/t])}function E2(e,t){return e/t}function D2(e,t){return(n,r)=>n*e+r*t}function O2(e,t,n,r){let i=Math.max.apply(Math,e.map(w2)),a=Math.max.apply(Math,t.map(w2)),{text:o,vector:s}=r&&r.text&&r.vector?r:k2(n),c=new Map,l=e.length,u=D2(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(E2(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=E2(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function k2(e){return{text:.5,vector:.5}}function A2(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return _2(e,t,n);if(r===`vector`)return x2(e,t);if(r===`hybrid`)return C2(e,t);throw O$(`INVALID_SEARCH_MODE`,r)}function j2(e,t,n,r,i){let a=e.data.docs,o=new Map,s=[],c=new Set,l=t.length,u=0;for(let d=0;d<l;d++){let l=t[d];if(l===void 0)continue;let[f,p]=l;if(c.has(f))continue;let m=e.documentsStore.get(a,f),h=g$(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:U$(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function M2(e,t,n,r){let i=e.data.docs,a=Array.from({length:r}),o=new Set;for(let s=n;s<r+n;s++){let n=t[s];if(n===void 0)break;let[r,c]=n;if(!o.has(r)){let t=e.documentsStore.get(i,r);a[s]={id:U$(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}const N2={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},P2=new WeakMap;function F2(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function I2(e){return e.trim().toLowerCase()}const L2=/\.(?:md|mdx)$/;function R2(e,t){if(t!==`page`)return e;let n=e.replace(L2,``);return n.length>0?n:e}function z2(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function B2(e){let t=z2(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 V2(e){let t=L0({schema:N2});return e.length>0&&J0(t,e),t}function H2(e){let t={documents:e};return P2.set(t,V2(e)),t}function U2(e){let t=P2.get(e);if(t)return t;let n=V2(e.documents);return P2.set(e,n),n}const W2=new WeakSet;function G2(e,t){return e===t||e.kind===t.kind&&e.path===t.path&&e.title===t.title&&e.name===t.name&&e.pathSegments===t.pathSegments&&e.modifiedTs===t.modifiedTs&&e.content===t.content}function K2(e,t){let n=e=>({corpus:H2(t),inserted:0,updated:0,removed:0,rebuilt:!0,rebuildReason:e}),r=P2.get(e);if(!r)return n(`no-index`);if(W2.has(e))return n(`stale-base`);let i=new Map(t.map(e=>[e.id,e]));if(i.size!==t.length)return n(`duplicate-id`);let a=[],o=[],s=0;for(let t of e.documents){let e=i.get(t.id);e?G2(t,e)||(a.push(t.id),o.push(e),s+=1):a.push(t.id)}let c=new Set(e.documents.map(e=>e.id));for(let e of t)c.has(e.id)||o.push(e);if(a.length+o.length>t.length)return n(`bulk-change`);W2.add(e);try{if(a.length>0&&e2(r,a),o.length>0&&J0(r,o),z0(r)!==t.length)throw Error(`Search index count ${z0(r)} diverged from document count ${t.length} after incremental update`)}catch{return n(`mutation-failed`)}let l={documents:t};return P2.set(l,r),{corpus:l,inserted:o.length-s,updated:s,removed:a.length-s,rebuilt:!1}}function q2(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function J2(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function Y2(e,t){let n=I2(t);if(!n)return 0;let r=R2(n,e.kind),i=I2(e.title),a=I2(e.name),o=I2(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 X2(e,t){let n=Y2(e,t);return n<=0?n:Zv(e.path)?n*.5:n}function Z2(e){return e===`file`?-60:0}function Q2(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 $2(e,t,n,r){return e+t*20+n+Z2(r)}function e4(e,t,n,r,i,a){return e===`relevance`?$2(t,n,r,i):Q2(t,n,r,i,a)}function t4(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function n4(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function r4(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 i4(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function a4(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 o4(e,t){return I2(t).length<4?0:+(e===`full_text`)}function s4(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function c4(e){let t=[],n=[],r=[];for(let i of e){let e=s4(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 l4(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=c4(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 u4(e,t,n={}){let r=n.intent??`omnibar`,i=t4(r,n.ranking),a=F2(n.limit),o=new Set(n.scopes??q2(r)),s=e.documents.filter(e=>J2(e,o)),c=I2(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=A2(U2(e),{term:c,properties:i4(r),boost:a4(r),tolerance:o4(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>J2(e.document,o)).map(e=>[e.document.id,e.score])),d=r4(s),f=new Map;for(let e of s)X2(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)J2(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=n4(f.values(),u);return l4([...f.values()].map(t=>{let n=Math.max(0,X2(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:e4(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 l4(f4({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function d4(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function f4(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=n4(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,X2(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?e4(o,t,n,s,e.kind,m):$2(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=d4(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)),_=d4(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),r=+(t.lexical>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}))}const p4=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),m4=globalThis;m4[p4]===void 0&&(m4[p4]=p());const h4=m4[p4],g4=[`.ok`,`skill-state.yml`],_4=[`claude-cowork`,`cli-hosts`],v4=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],y4=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,b4=w({version:b().regex(y4,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(h4,{description:`Recorded skill version for this target.`}),recordedAt:ne().register(h4,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:d(v4).register(h4,{description:`Install-source surface that recorded this entry.`}).optional()}),x4=w({enabled:E().register(h4,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:ne().register(h4,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),S4=w({schema:_(1).register(h4,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:w({"claude-cowork":b4.optional(),"cli-hosts":b4.optional()}).register(h4,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:T(b(),x4).register(h4,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function C4(e,t){return e??t.installedOnDisk}function w4(){return{schema:1,targets:{}}}const T4=`template`;function E4(e){if(e.trim()===``)return{};let t;try{t=(0,ye.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function D4(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function O4(e){let{frontmatter:t,body:n}=Dp(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:kp(t),markdown:n}}function k4(e){let t=e.split(`
327
- `);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=E4(n.join(`
328
- `))[T4];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
329
- `).replace(/\n+$/,``)}}function A4(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=Dp(t);if(n===``)return{identity:{},starterContent:t};let i=kp(n),a=k4(i);if(a)return{identity:a.identity,starterContent:D4(a.docFrontmatterText,r)};let{frontmatter:o}=Dp(r);if(o!==``)return{identity:E4(i),starterContent:r};let s=E4(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:D4(i,r)}}function j4(e,t){let{docFrontmatterText:n,markdown:r}=O4(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,ye.stringify)({[T4]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function M4(e){return A4(e).starterContent}const N4=`(agent thread)`;function P4(){let e=!1,t=``,n=0;return r=>{let i=F4(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 F4(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 I4=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],L4={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function R4(e,t=I4){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const z4={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function B4(e){return e?z4[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const V4={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function H4(e){let t=e?.trim();return t?V4[B4(t)]??t:`Agent`}function U4(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 W4=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function G4(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function K4(e){let t=e.trim();return W4.test(t)||t.startsWith(`//`)}function q4(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(K4(n))return{kind:`external`,url:n};let r=U4(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=G4(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function J4(e,t){let n=e.trim();if(!n)return null;if(K4(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=G4(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function Y4(e,t){let n=e.trim();if(!n||W4.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 X4(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function Z4(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Q4(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function $4(e){return e.split(`/`).filter(e=>e!==``)}function e3(e,t){let n=Q4(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function t3(e,t){let n=Q4(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:$4(r).length}function n3(e,t){let n=$4(e),r=$4(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function r3(){let e=new Map;function t(t){let n=X4(t);if(n===``)return;let r=Z4(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=X4(t),r=Z4(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=Q4(X4(n)),o=[],s=[];for(let e of i)e3(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=t3(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=t3(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=n3(a,Q4(t));for(let r=1;r<e.length;r++){let i=e[r],o=n3(a,Q4(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 i3(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 a3(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}export{NZ as $,je as $a,my as $i,$J as $n,iq as $r,YY as $t,KQ as A,nt as Aa,LV as Ai,rY as An,Qq as Ar,DX as At,EQ as B,Ke as Ba,By as Bi,mY as Bn,Tq as Br,vX as Bt,C4 as C,ut as Ca,fK as Ci,jY as Cn,fJ as Cr,QY as Ct,K2 as D,rt as Da,ZV as Di,kY as Dn,pJ as Dr,VX as Dt,u4 as E,st as Ea,tH as Ei,OY as En,lJ as Er,HX as Et,IQ as F,et as Fa,DN as Fi,cY as Fn,Kq as Fr,WX as Ft,ZZ as G,Ce as Ga,zy as Gi,zJ as Gn,Lq as Gr,PX as Gt,TQ as H,Se as Ha,Wy as Hi,bY as Hn,Bq as Hr,LX as Ht,FQ as I,Ze as Ia,bM as Ii,nY as In,qq as Ir,AX as It,VZ as J,Oe as Ja,jy as Ji,XJ as Jn,Pq as Jr,MX as Jt,qZ as K,Te as Ka,Oy as Ki,BJ as Kn,Sq as Kr,FX as Kt,PQ as L,$e as La,Ly as Li,dY as Ln,Mq as Lr,SX as Lt,VQ as M,Ye as Ma,uB as Mi,hY as Mn,Yq as Mr,EX as Mt,LQ as N,tt as Na,lB as Ni,gY as Nn,tJ as Nr,hX as Nt,HQ as O,it as Oa,QV as Oi,aY as On,sJ as Or,xX as Ot,NQ as P,Xe as Pa,rL as Pi,sY as Pn,iJ as Pr,kX as Pt,PZ as Q,xe as Qa,dy as Qi,ZJ as Qn,xq as Qr,pX as Qt,MQ as R,Qe as Ra,Uy as Ri,lY as Rn,wq as Rr,CX as Rt,w4 as S,lt as Sa,TK as Si,AY as Sn,dJ as Sr,ZY as St,B2 as T,ot as Ta,oH as Ti,DY as Tn,cJ as Tr,RX as Tt,vQ as U,De as Ua,Hy as Ui,_Y as Un,Uq as Ur,lX as Ut,yQ as V,Ge as Va,Fy as Vi,yY as Vn,zq as Vr,IX as Vt,_Q as W,Ee as Wa,Vy as Wi,vY as Wn,Cq as Wr,NX as Wt,LZ as X,Ae as Xa,sy as Xi,KJ as Xn,Gq as Xr,bX as Xt,RZ as Y,ke as Ya,iy as Yi,JJ as Yn,Wq as Yr,yX as Yt,IZ as Z,Me as Za,fy as Zi,GJ as Zn,vq as Zr,gX as Zt,A4 as _,oi as _a,mK as _i,FY as _n,vJ as _r,YX as _t,J4 as a,Ey as aa,GK as ai,sX as an,Fe as ao,EJ as ar,CZ as at,y4 as b,ft as ba,DK as bi,PY as bn,gJ as br,GX as bt,L4 as c,Yv as ca,jK as ci,rX as cn,pe as co,NJ as cr,iZ as ct,B4 as d,Wv as da,AK as di,UY as dn,de as do,kJ as dr,nZ as dt,gy as ea,pq as ei,qY as en,We as eo,WJ as er,MZ as et,P4 as f,Bv as fa,zK as fi,WY as fn,MJ as fr,tZ as ft,M4 as g,vd as ga,CK as gi,HY as gn,yJ as gr,KX as gt,j4 as h,kp as ha,vK as hi,BY as hn,xJ as hr,ZX as ht,q4 as i,yy as ia,KK as ii,aX as in,Ne as io,FJ as ir,bZ as it,qQ as j,Je as ja,SB as ji,iY as jn,Xq as jr,TX as jt,GQ as k,at as ka,BV as ki,oY as kn,$q as kr,OX as kt,R4 as l,qv as la,PK as li,tX as ln,me as lo,PJ as lr,lZ as lt,T4 as m,Dp as ma,_K as mi,KY as mn,TJ as mr,eZ as mt,a3 as n,Ny as na,QK as ni,eX as nn,He as no,UJ as nr,DZ as nt,Y4 as o,_y as oa,UK as oi,cX as on,Be as oo,DJ as or,hZ as ot,N4 as p,Op as pa,BK as pi,GY as pn,CJ as pr,$X as pt,YZ as q,we as qa,ky as qi,QJ as qn,Iq as qr,jX as qt,r3 as r,Ty as ra,XK as ri,iX as rn,Le as ro,VJ as rr,yZ as rt,U4 as s,Zv as sa,WK as si,nX as sn,be as so,OJ as sr,mZ as st,i3 as t,My as ta,mq as ti,oX as tn,ze as to,HJ as tr,wZ as tt,H4 as u,Kv as ua,OK as ui,fX as un,fe as uo,AJ as ur,QX as ut,g4 as v,I as va,SK as vi,IY as vn,SJ as vr,JX as vt,H2 as w,ct as wa,dK as wi,MY as wn,mJ as wr,uX as wt,S4 as x,dt as xa,gK as xi,NY as xn,_J as xr,XY as xt,_4 as y,pt as ya,EK as yi,zY as yn,hJ as yr,qX as yt,jQ as z,qe as za,Iy as zi,pY as zn,Rq as zr,_X as zt};
330
- //# sourceMappingURL=src-3SN72BHH.mjs.map
326
+ `,ANSWER_SESSION_LAST_MESSAGE_IS_NOT_ASSISTANT:`The last message in the session is not an assistant message. Cannot regenerate non-assistant messages.`,PLUGIN_COMPONENT_CONFLICT:`The component "%s" is already defined. The plugin "%s" is trying to redefine it.`};function k$(e,...t){let n=Error(o$(O$[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function A$(e){return{raw:Number(e),formatted:u$(e)}}function j$(e){if(e.id){if(typeof e.id!=`string`)throw k$(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return f$()}function M$(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(t!==void 0&&!(r===`geopoint`&&typeof t==`object`&&typeof t.lon==`number`&&typeof t.lat==`number`)&&!(r===`enum`&&(typeof t==`string`||typeof t==`number`))){if(r===`enum[]`&&Array.isArray(t)){let e=t.length;for(let r=0;r<e;r++)if(typeof t[r]!=`string`&&typeof t[r]!=`number`)return n+`.`+r;continue}if(I$(r)){let e=z$(r);if(!Array.isArray(t)||t.length!==e)throw k$(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(L$(r)){if(!Array.isArray(t))return n;let e=R$(r),i=t.length;for(let r=0;r<i;r++)if(typeof t[r]!==e)return n+`.`+r;continue}if(typeof r==`object`){if(!t||typeof t!=`object`)return n;let e=M$(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}const N$={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},P$={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function F$(e){return e===`geopoint`}function I$(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function L$(e){return typeof e==`string`&&N$[e]}function R$(e){return P$[e]}function z$(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw k$(`INVALID_VECTOR_VALUE`,e);case t<=0:throw k$(`INVALID_VECTOR_SIZE`,e);default:return t}}function B$(){return{idToInternalId:new Map,internalIdToId:[],save:V$,load:H$}}function V$(e){return{internalIdToId:e.internalIdToId}}function H$(e,t){let{internalIdToId:n}=t;e.internalDocumentIDStore.idToInternalId.clear(),e.internalDocumentIDStore.internalIdToId=[];let r=n.length;for(let t=0;t<r;t++){let r=n[t];e.internalDocumentIDStore.idToInternalId.set(r,t+1),e.internalDocumentIDStore.internalIdToId.push(r)}}function U$(e,t){if(typeof t==`string`){let n=e.idToInternalId.get(t);if(n)return n;let r=e.idToInternalId.size+1;return e.idToInternalId.set(t,r),e.internalIdToId.push(t),r}return t>e.internalIdToId.length?U$(e,t.toString()):t}function W$(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function G$(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function K$(e,t){let n=U$(e.sharedInternalDocumentStore,t);return e.docs[n]}function q$(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=U$(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function J$(e){return e.docs}function Y$(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function X$(e,t){let n=U$(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function Z$(e){return e.count}function Q$(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function $$(e){return{docs:e.docs,count:e.count}}function e1(){return{create:G$,get:K$,getMultiple:q$,getAll:J$,store:Y$,remove:X$,count:Z$,load:Q$,save:$$}}const t1=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function n1(e,t){let n=[],r=e.plugins?.length;if(!r)return n;for(let i=0;i<r;i++)try{let r=e.plugins[i];typeof r[t]==`function`&&n.push(r[t])}catch(e){throw console.error(`Caught error in getAllPluginsByHook:`,e),k$(`PLUGIN_CRASHED`)}return n}const r1=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],i1=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function a1(e,t,n,r){if(e.some(x$))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function o1(e,t,n){if(e.some(x$))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function s1(e,t,n,r,i){if(e.some(x$))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function c1(e,t,n,r){if(e.some(x$))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function l1(e,t){if(e.some(x$))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var u1=class e{k;v;l=null;r=null;h=1;constructor(e,t){this.k=e,this.v=new Set(t)}updateHeight(){this.h=Math.max(e.getHeight(this.l),e.getHeight(this.r))+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return e.getHeight(this.l)-e.getHeight(this.r)}rotateLeft(){let e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(t){let n=new e(t.k,t.v);return n.l=t.l?e.fromJSON(t.l):null,n.r=t.r?e.fromJSON(t.r):null,n.h=t.h,n}},d1=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new u1(e,t))}insert(e,t,n=1e3){this.root=this.insertNode(this.root,e,t,n)}insertMultiple(e,t,n=1e3){for(let r of t)this.insert(e,r,n)}rebalance(){this.root&&=this.rebalanceNode(this.root)}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(t){let n=new e;return n.root=t.root?u1.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new u1(t,[n]);let i=[],a=e,o=null;for(;a!==null;)if(i.push({parent:o,node:a}),t<a.k)if(a.l===null){a.l=new u1(t,[n]),i.push({parent:a,node:a.l});break}else o=a,a=a.l;else if(t>a.k)if(a.r===null){a.r=new u1(t,[n]),i.push({parent:a,node:a.r});break}else o=a,a=a.r;else return a.v.add(n),e;let s=!1;this.insertCount++%r===0&&(s=!0);for(let t=i.length-1;t>=0;t--){let{parent:n,node:r}=i[t];if(r.updateHeight(),s){let t=this.rebalanceNode(r);n?n.l===r?n.l=t:n.r===r&&(n.r=t):e=t}}return e}rebalanceNode(e){let t=e.getBalanceFactor();if(t>1){if(e.l&&e.l.getBalanceFactor()>=0)return e.rotateRight();if(e.l)return e.l=e.l.rotateLeft(),e.rotateRight()}if(t<-1){if(e.r&&e.r.getBalanceFactor()<=0)return e.rotateLeft();if(e.r)return e.r=e.r.rotateRight(),e.rotateLeft()}return e}find(e){let t=this.findNodeByKey(e);return t?t.v:null}contains(e){return this.find(e)!==null}getSize(){let e=0,t=[],n=this.root;for(;n||t.length>0;){for(;n;)t.push(n),n=n.l;n=t.pop(),e++,n=n.r}return e}isBalanced(){if(!this.root)return!0;let e=[this.root];for(;e.length>0;){let t=e.pop(),n=t.getBalanceFactor();if(Math.abs(n)>1)return!1;t.l&&e.push(t.l),t.r&&e.push(t.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,t){let n=this.findNodeByKey(e);n&&(n.v.size===1?this.root=this.removeNode(this.root,e):n.v=new Set([...n.v.values()].filter(e=>e!==t)))}findNodeByKey(e){let t=this.root;for(;t;)if(e<t.k)t=t.l;else if(e>t.k)t=t.r;else return t;return null}removeNode(e,t){if(e===null)return null;let n=[],r=e;for(;r!==null&&r.k!==t;)n.push(r),r=t<r.k?r.l:r.r;if(r===null)return e;if(r.l===null||r.r===null){let t=r.l?r.l:r.r;if(n.length===0)e=t;else{let e=n[n.length-1];e.l===r?e.l=t:e.r=t}}else{let e=r,t=r.r;for(;t.l!==null;)e=t,t=t.l;r.k=t.k,r.v=t.v,e.l===t?e.l=t.r:e.r=t.r,r=e}n.push(r);for(let t=n.length-1;t>=0;t--){let r=n[t];r.updateHeight();let i=this.rebalanceNode(r);if(t>0){let e=n[t-1];e.l===r?e.l=i:e.r===r&&(e.r=i)}else e=i}return e}rangeSearch(e,t){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),i.k>=e&&i.k<=t)for(let e of i.v)n.add(e);if(i.k>t)break;i=i.r}return n}greaterThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.r;if(i=r.pop(),t&&i.k>=e||!t&&i.k>e)for(let e of i.v)n.add(e);else if(i.k<=e)break;i=i.l}return n}lessThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),t&&i.k<=e||!t&&i.k<e)for(let e of i.v)n.add(e);else if(i.k>e)break;i=i.r}return n}},f1=class e{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,t){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(t):this.numberToDocumentId.set(e,new Set([t]))}find(e){let t=this.numberToDocumentId.get(e);return t?Array.from(t):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,t){let n=this.numberToDocumentId.get(t);n&&(n.delete(e),n.size===0&&this.numberToDocumentId.delete(t))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(let t of this.numberToDocumentId.values())e+=t.size;return e}filter(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`eq`:{let t=e[n],r=this.numberToDocumentId.get(t);return r?Array.from(r):[]}case`in`:{let t=e[n],r=new Set;for(let e of t){let t=this.numberToDocumentId.get(e);if(t)for(let e of t)r.add(e)}return Array.from(r)}case`nin`:{let t=new Set(e[n]),r=new Set;for(let[e,n]of this.numberToDocumentId.entries())if(!t.has(e))for(let e of n)r.add(e);return Array.from(r)}default:throw Error(`Invalid operation`)}}filterArr(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`containsAll`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e].filter(e=>t.has(e))));return Array.from(r)}case`containsAny`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e,...t]));return Array.from(r)}default:throw Error(`Invalid operation`)}}static fromJSON(t){if(!t.numberToDocumentId)throw Error(`Invalid Flat Tree JSON`);let n=new e;for(let[e,r]of t.numberToDocumentId)n.numberToDocumentId.set(e,new Set(r));return n}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,t])=>[e,Array.from(t)])}}};function p1(e,t,n){if(n<0)return-1;if(e===t)return 0;let r=e.length,i=t.length;if(r===0)return i<=n?i:-1;if(i===0)return r<=n?r:-1;let a=Math.abs(r-i);if(e.startsWith(t))return a<=n?a:-1;if(t.startsWith(e))return 0;if(a>n)return-1;let o=[];for(let e=0;e<=r;e++){o[e]=[e];for(let t=1;t<=i;t++)o[e][t]=e===0?t:0}for(let a=1;a<=r;a++){let r=1/0;for(let n=1;n<=i;n++)e[a-1]===t[n-1]?o[a][n]=o[a-1][n-1]:o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+1),r=Math.min(r,o[a][n]);if(r>n)return-1}return o[r][i]<=n?o[r][i]:-1}function m1(e,t,n){let r=p1(e,t,n);return{distance:r,isBounded:r>=0}}var h1=class e{k;s;c=new Map;d=new Set;e;w=``;constructor(e,t,n){this.k=e,this.s=t,this.e=n}updateParent(e){this.w=e.w+this.s}addDocument(e){this.d.add(e)}removeDocument(e){return this.d.delete(e)}findAllWords(e,t,n,r){let i=[this];for(;i.length>0;){let a=i.pop();if(a.e){let{w:i,d:o}=a;if(n&&i!==t)continue;if(p$(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&m1(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(p$(e,i)!=null&&o.size>0){let t=e[i];for(let e of o)t.includes(e)||t.push(e)}}a.c.size>0&&i.push(...a.c.values())}return e}insert(t,n){let r=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=r.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c){if(r=s,i+=l,i===a){s.e||=!0,s.addDocument(n);return}continue}let u=o.slice(0,l),d=o.slice(l),f=t.slice(i+l),p=new e(u[0],u,!1);if(r.c.set(u[0],p),p.updateParent(r),s.s=d,s.k=d[0],p.c.set(d[0],s),s.updateParent(p),f){let t=new e(f[0],f,!0);t.addDocument(n),p.c.set(f[0],t),t.updateParent(p)}else p.e=!0,p.addDocument(n);return}else{let a=new e(o,t.slice(i),!0);a.addDocument(n),r.c.set(o,a),a.updateParent(r);return}}r.e||=!0,r.addDocument(n)}_findLevenshtein(e,t,n,r,i){let a=[{node:this,index:t,tolerance:n}];for(;a.length>0;){let{node:t,index:n,tolerance:o}=a.pop();if(t.w.startsWith(e)){t.findAllWords(i,e,!1,0);continue}if(o<0)continue;if(t.e){let{w:n,d:a}=t;if(n&&(m1(e,n,r).isBounded&&(i[n]=[]),p$(i,n)!==void 0&&a.size>0)){let e=new Set(i[n]);for(let t of a)e.add(t);i[n]=Array.from(e)}}if(n>=e.length)continue;let s=e[n];if(t.c.has(s)){let e=t.c.get(s);a.push({node:e,index:n+1,tolerance:o})}a.push({node:t,index:n+1,tolerance:o-1});for(let[e,r]of t.c)a.push({node:r,index:n,tolerance:o-1}),e!==s&&a.push({node:r,index:n+1,tolerance:o-1})}}find(e){let{term:t,exact:n,tolerance:r}=e;if(r&&!n){let e={};return this._findLevenshtein(t,0,r,r,e),e}else{let e=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=e.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c)e=s,i+=l;else if(i+l===a)if(l===a-i){if(n)return{};{let e={};return s.findAllWords(e,t,n,r),e}}else return{};else return{}}else return{}}let o={};return e.findAllWords(o,t,n,r),o}}contains(e){let t=this,n=0,r=e.length;for(;n<r;){let i=e[n],a=t.c.get(i);if(a){let i=a.s,o=i.length,s=0;for(;s<o&&n+s<r&&i[s]===e[n+s];)s++;if(s<o)return!1;n+=o,t=a}else return!1}return!0}removeWord(e){if(!e)return!1;let t=this,n=e.length,r=[];for(let i=0;i<n;i++){let n=e[i];if(t.c.has(n)){let e=t.c.get(n);r.push({parent:t,character:n}),i+=e.s.length-1,t=e}else return!1}for(t.d.clear(),t.e=!1;r.length>0&&t.c.size===0&&!t.e&&t.d.size===0;){let{parent:e,character:n}=r.pop();e.c.delete(n),t=e}return!0}removeDocumentByWord(e,t,n=!0){if(!e)return!0;let r=this,i=e.length;for(let a=0;a<i;a++){let i=e[a];if(r.c.has(i)){let o=r.c.get(i);a+=o.s.length-1,r=o,n&&r.w!==e||r.removeDocument(t)}else return!1}return!0}static getCommonPrefix(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return e.slice(0,r)}toJSON(){return{w:this.w,s:this.s,e:this.e,k:this.k,d:Array.from(this.d),c:Array.from(this.c?.entries())?.map(([e,t])=>[e,t.toJSON()])}}static fromJSON(t){let n=new e(t.k,t.s,t.e);return n.w=t.w,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([t,n])=>[t,e.fromJSON(n)])||[]),n}},g1=class e extends h1{constructor(){super(``,``,!1)}static fromJSON(t){let n=new e;return n.w=t.w,n.s=t.s,n.e=t.e,n.k=t.k,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([e,t])=>[e,h1.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},_1=class e{point;docIDs;left;right;parent;constructor(e,t){this.point=e,this.docIDs=new Set(t),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(t,n=null){let r=new e(t.point,t.docIDs);return r.parent=n,t.left&&(r.left=e.fromJSON(t.left,r)),t.right&&(r.right=e.fromJSON(t.right,r)),r}},v1=class e{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return`${e.lon},${e.lat}`}insert(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);if(r){t.forEach(e=>r.docIDs.add(e));return}let i=new _1(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%2==0)if(e.lon<a.point.lon){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}else if(e.lat<a.point.lat){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}o++}}contains(e){let t=this.getPointKey(e);return this.nodeMap.has(t)}getDocIDsByCoordinates(e){let t=this.getPointKey(e),n=this.nodeMap.get(t);return n?Array.from(n.docIDs):null}removeDocByID(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);r&&(r.docIDs.delete(t),r.docIDs.size===0&&(this.nodeMap.delete(n),this.deleteNode(r)))}deleteNode(e){let t=e.parent,n=e.left?e.left:e.right;n&&(n.parent=t),t?t.left===e?t.left=n:t.right===e&&(t.right=n):(this.root=n,this.root&&(this.root.parent=null))}searchByRadius(t,n,r=!0,i=`asc`,a=!1){let o=a?e.vincentyDistance:e.haversineDistance,s=[{node:this.root,depth:0}],c=[];for(;s.length>0;){let{node:e,depth:i}=s.pop();if(e==null)continue;let a=o(t,e.point);(r?a<=n:a>n)&&c.push({point:e.point,docIDs:Array.from(e.docIDs)}),e.left!=null&&s.push({node:e.left,depth:i+1}),e.right!=null&&s.push({node:e.right,depth:i+1})}return i&&c.sort((e,n)=>{let r=o(t,e.point),a=o(t,n.point);return i.toLowerCase()===`asc`?r-a:a-r}),c}searchByPolygon(t,n=!0,r=null,i=!1){let a=[{node:this.root,depth:0}],o=[];for(;a.length>0;){let{node:r,depth:i}=a.pop();if(r==null)continue;r.left!=null&&a.push({node:r.left,depth:i+1}),r.right!=null&&a.push({node:r.right,depth:i+1});let s=e.isPointInPolygon(t,r.point);(s&&n||!s&&!n)&&o.push({point:r.point,docIDs:Array.from(r.docIDs)})}let s=e.calculatePolygonCentroid(t);if(r){let t=i?e.vincentyDistance:e.haversineDistance;o.sort((e,n)=>{let i=t(s,e.point),a=t(s,n.point);return r.toLowerCase()===`asc`?i-a:a-i})}return o}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(t){let n=new e;return t.root&&(n.root=_1.fromJSON(t.root),n.buildNodeMap(n.root)),n}buildNodeMap(e){if(e==null)return;let t=this.getPointKey(e.point);this.nodeMap.set(t,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static calculatePolygonCentroid(e){let t=0,n=0,r=0,i=e.length;for(let a=0,o=i-1;a<i;o=a++){let i=e[a].lon,s=e[a].lat,c=e[o].lon,l=e[o].lat,u=i*l-c*s;t+=u,n+=(i+c)*u,r+=(s+l)*u}t/=2;let a=6*t;return n/=a,r/=a,{lon:n,lat:r}}static isPointInPolygon(e,t){let n=!1,r=t.lon,i=t.lat,a=e.length;for(let t=0,o=a-1;t<a;o=t++){let a=e[t].lon,s=e[t].lat,c=e[o].lon,l=e[o].lat;s>i!=l>i&&r<(c-a)*(i-s)/(l-s)+a&&(n=!n)}return n}static haversineDistance(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=(t.lat-e.lat)*n,o=(t.lon-e.lon)*n,s=Math.sin(a/2)*Math.sin(a/2)+Math.cos(r)*Math.cos(i)*Math.sin(o/2)*Math.sin(o/2);return 6371e3*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}static vincentyDistance(e,t){let n=6378137,r=1/298.257223563,i=(1-r)*n,a=Math.PI/180,o=e.lat*a,s=t.lat*a,c=(t.lon-e.lon)*a,l=Math.atan((1-r)*Math.tan(o)),u=Math.atan((1-r)*Math.tan(s)),d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u),h=c,g,_=1e3,v,y,b,x,S,C;do{let e=Math.sin(h),t=Math.cos(h);if(v=Math.sqrt(m*e*(m*e)+(f*p-d*m*t)*(f*p-d*m*t)),v===0)return 0;y=d*p+f*m*t,b=Math.atan2(v,y),x=f*m*e/v,S=1-x*x,C=y-2*d*p/S,isNaN(C)&&(C=0);let n=r/16*S*(4+r*(4-3*S));g=h,h=c+(1-n)*r*x*(b+n*v*(C+n*y*(-1+2*C*C)))}while(Math.abs(h-g)>1e-12&&--_>0);if(_===0)return NaN;let w=S*(n*n-i*i)/(i*i),T=1+w/16384*(4096+w*(-768+w*(320-175*w))),E=w/1024*(256+w*(-128+w*(74-47*w))),D=E*v*(C+E/4*(y*(-1+2*C*C)-E/6*C*(-3+4*v*v)*(-3+4*C*C)));return i*T*(b-D)}},y1=class e{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,t){t?this.true.add(e):this.false.add(e)}delete(e,t){t?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(t){let n=new e;return n.true=new Set(t.true),n.false=new Set(t.false),n}};function b1(e,t,n,r,i,{k:a,b:o,d:s}){return Math.log(1+(n-t+.5)/(t+.5))*(s+e*(a+1))/(e+a*(1-o+o*r/i))}var x1=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=S1(t,this.size);this.vectors.set(e,[n,t])}remove(e){this.vectors.delete(e)}find(e,t,n){return e instanceof Float32Array||(e=new Float32Array(e)),C1(e,n,this.vectors,this.size,t)}toJSON(){let e=[];for(let[t,[n,r]]of this.vectors)e.push([t,[n,Array.from(r)]]);return{size:this.size,vectors:e}}static fromJSON(t){let n=t,r=new e(n.size);for(let[e,[t,i]]of n.vectors)r.vectors.set(e,[t,new Float32Array(i)]);return r}};function S1(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function C1(e,t,n,r,i){let a=S1(e,r),o=[],s=t||n.keys();for(let t of s){let s=n.get(t);if(!s)continue;let c=s[0],l=s[1],u=0;for(let t=0;t<r;t++)u+=e[t]*l[t];let d=u/(a*c);d>=i&&o.push([t,d])}return o}function w1(e,t,n,r,i){let a=U$(e.sharedInternalDocumentStore,n);e.avgFieldLength[t]=((e.avgFieldLength[t]??0)*(i-1)+r.length)/i,e.fieldLengths[t][a]=r.length,e.frequencies[t][a]={}}function T1(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=U$(e.sharedInternalDocumentStore,n),s=a/r.length;e.frequencies[t][o][i]=s,i in e.tokenOccurrences[t]||(e.tokenOccurrences[t][i]=0),e.tokenOccurrences[t][i]=(e.tokenOccurrences[t][i]??0)+1}function E1(e,t,n,r){let i=U$(e.sharedInternalDocumentStore,n);r>1?e.avgFieldLength[t]=(e.avgFieldLength[t]*r-e.fieldLengths[t][i])/(r-1):e.avgFieldLength[t]=void 0,e.fieldLengths[t][i]=void 0,e.frequencies[t][i]=void 0}function D1(e,t,n){e.tokenOccurrences[t][n]--}function O1(e,t,n,r,i=``){r||={sharedInternalDocumentStore:t,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}};for(let[a,o]of Object.entries(n)){let n=`${i}${i?`.`:``}${a}`;if(typeof o==`object`&&!Array.isArray(o)){O1(e,t,o,r,n);continue}if(I$(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new x1(z$(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new y1,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new d1(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new g1,isArray:e},r.avgFieldLength[n]=0,r.frequencies[n]={},r.tokenOccurrences[n]={},r.fieldLengths[n]={};break;case`enum`:case`enum[]`:r.indexes[n]={type:`Flat`,node:new f1,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new v1,isArray:e};break;default:throw k$(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function k1(e,t,n,r,i,a,o,s){return c=>{let{type:l,node:u}=t.indexes[n];switch(l){case`Bool`:u[c?`true`:`false`].add(r);break;case`AVL`:{let e=s?.avlRebalanceThreshold??1;u.insert(c,r,e);break}case`Radix`:{let s=a.tokenize(c,i,n,!1);e.insertDocumentScoreParameters(t,n,r,s,o);for(let i of s)e.insertTokenScoreParameters(t,n,r,s,i),u.insert(i,r);break}case`Flat`:u.insert(c,r);break;case`BKD`:u.insert(c,[r]);break}}}function A1(e,t,n,r,i,a,o,s,c,l,u){if(I$(o))return j1(t,n,a,r,i);let d=k1(e,t,n,i,s,c,l,u);if(!L$(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function j1(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function M1(e,t,n,r,i,a,o,s,c,l){if(I$(o))return t.vectorIndexes[n].node.remove(i),!0;let{type:u,node:d}=t.indexes[n];switch(u){case`AVL`:return d.removeDocument(a,i),!0;case`Bool`:return d[a?`true`:`false`].delete(i),!0;case`Radix`:{let o=c.tokenize(a,s,n);e.removeDocumentScoreParameters(t,n,r,l);for(let r of o)e.removeTokenScoreParameters(t,n,r),d.removeDocumentByWord(r,i);return!0}case`Flat`:return d.removeDocument(i,a),!0;case`BKD`:return d.removeDocByID(a,i),!1}}function N1(e,t,n,r,i,a,o,s,c,l){if(!L$(o))return M1(e,t,n,r,i,a,o,s,c,l);let u=R$(o),d=a,f=d.length;for(let a=0;a<f;a++)M1(e,t,n,r,i,d[a],u,s,c,l);return!0}function P1(e,t,n,r,i,a,o,s,c,l){let u=Array.from(r),d=e.avgFieldLength[t],f=e.fieldLengths[t],p=e.tokenOccurrences[t],m=e.frequencies[t],h=typeof p[n]==`number`?p[n]??0:0,g=u.length;for(let e=0;e<g;e++){let r=u[e];if(c&&!c.has(r))continue;l.has(r)||l.set(r,new Map);let p=l.get(r);p.set(t,(p.get(t)||0)+1);let g=b1(m?.[r]?.[n]??0,h,i,f[r],d,a);o.has(r)?o.set(r,o.get(r)+g*s):o.set(r,g*s)}}function F1(e,t,n,r,i,a,o,s,c,l,u,d=0){let f=n.tokenize(t,r),p=f.length||1,m=new Map,h=new Map,g=new Map;for(let n of i){if(!(n in e.indexes))continue;let r=e.indexes[n],{type:i}=r;if(i!==`Radix`)throw k$(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw k$(`INVALID_BOOST_VALUE`,d);f.length===0&&!t&&f.push(``);let p=f.length;for(let t=0;t<p;t++){let i=f[t],s=r.node.find({term:i,exact:a,tolerance:o}),p=Object.keys(s);p.length>0&&h.set(i,!0);let _=p.length;for(let t=0;t<_;t++){let r=p[t],i=s[r];P1(e,n,r,i,l,c,g,d,u,m)}}}let _=Array.from(g.entries()).map(([e,t])=>[e,t]).sort((e,t)=>t[1]-e[1]);if(_.length===0)return[];if(d===1)return _;if(d===0){if(p===1)return _;for(let e of f)if(!h.get(e))return[];return _.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1})}let v=_.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1});if(v.length>0){let e=_.filter(([e])=>!v.some(([t])=>t===e)),t=Math.ceil(e.length*d);return[...v,...e.slice(0,t)]}return _}function I1(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:C$(...i.map(n=>I1(e,t,n,r)))}if(`or`in n&&n.or&&Array.isArray(n.or)){let i=n.or;return i.length===0?new Set:i.map(n=>I1(e,t,n,r)).reduce((e,t)=>T$(e,t),new Set)}if(`not`in n&&n.not){let i=n.not,a=new Set,o=e.sharedInternalDocumentStore;for(let e=1;e<=o.internalIdToId.length;e++)a.add(e);return E$(a,I1(e,t,i,r))}let i=Object.keys(n),a=i.reduce((e,t)=>({[t]:new Set,...e}),{});for(let o of i){let i=n[o];if(e.indexes[o]===void 0)throw k$(`UNKNOWN_FILTER_PROPERTY`,o);let{node:s,type:c,isArray:l}=e.indexes[o];if(c===`Bool`){let e=s,t=i?e.true:e.false;a[o]=T$(a[o],t);continue}if(c===`BKD`){let e;if(`radius`in i)e=`radius`;else if(`polygon`in i)e=`polygon`;else throw Error(`Invalid operation ${i}`);if(e===`radius`){let{value:t,coordinates:n,unit:r=`m`,inside:c=!0,highPrecision:l=!1}=i[e],u=y$(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=H1(a[o],d)}else{let{coordinates:t,inside:n=!0,highPrecision:r=!1}=i[e],c=s.searchByPolygon(t,n,void 0,r);a[o]=H1(a[o],c)}continue}if(c===`Radix`&&(typeof i==`string`||Array.isArray(i))){for(let e of[i].flat()){let n=t.tokenize(e,r,o);for(let e of n){let t=s.find({term:e,exact:!0});a[o]=K1(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw k$(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=T$(a[o],e);continue}if(c===`AVL`){let e=u[0],t=i[e],n;switch(e){case`gt`:n=s.greaterThan(t,!1);break;case`gte`:n=s.greaterThan(t,!0);break;case`lt`:n=s.lessThan(t,!1);break;case`lte`:n=s.lessThan(t,!0);break;case`eq`:n=s.find(t)??new Set;break;case`between`:{let[e,r]=t;n=s.rangeSearch(e,r);break}default:throw k$(`INVALID_FILTER_OPERATION`,e)}a[o]=T$(a[o],n)}}return C$(...Object.values(a))}function L1(e){return e.searchableProperties}function R1(e){return e.searchablePropertiesWithTypes}function z1(e,t){let{indexes:n,vectorIndexes:r,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}=t,u={},d={};for(let e of Object.keys(n)){let{node:t,type:r,isArray:i}=n[e];switch(r){case`Radix`:u[e]={type:`Radix`,node:g1.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:f1.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:d1.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:v1.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:y1.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:x1.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function B1(e){let{indexes:t,vectorIndexes:n,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}=e,l={};for(let e of Object.keys(n))l[e]=n[e].node.toJSON();let u={};for(let e of Object.keys(t)){let{type:n,node:r,isArray:i}=t[e];n===`Flat`||n===`Radix`||n===`AVL`||n===`BKD`||n===`Bool`?u[e]={type:n,node:r.toJSON(),isArray:i}:(u[e]=t[e],u[e].node=u[e].node.toJSON())}return{indexes:u,vectorIndexes:l,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}}function V1(){return{create:O1,insert:A1,remove:N1,insertDocumentScoreParameters:w1,insertTokenScoreParameters:T1,removeDocumentScoreParameters:E1,removeTokenScoreParameters:D1,calculateResultScores:P1,search:F1,searchByWhereClause:I1,getSearchableProperties:L1,getSearchablePropertiesWithTypes:R1,load:z1,save:B1}}function H1(e,t){e||=new Set;let n=t.length;for(let r=0;r<n;r++){let n=t[r].docIDs,i=n.length;for(let t=0;t<i;t++)e.add(n[t])}return e}function U1(e,t,n=!1){let r=n?v1.vincentyDistance:v1.haversineDistance,i=[],a=[];for(let{point:n}of e)a.push(r(t,n));let o=Math.max(...a),s=0;for(let{docIDs:t}of e){let e=o-a[s]+1;for(let n of t)i.push([n,e]);s++}return i.sort((e,t)=>t[1]-e[1]),i}function W1(e,t){let n=Object.keys(e);if(n.length!==1)return{isGeoOnly:!1};let r=n[0],i=e[r];if(t.indexes[r]===void 0)return{isGeoOnly:!1};let{type:a}=t.indexes[r];return a===`BKD`&&i&&(`radius`in i||`polygon`in i)?{isGeoOnly:!0,geoProperty:r,geoOperation:i}:{isGeoOnly:!1}}function G1(e,t){let n=e,r=W1(t,n);if(!r.isGeoOnly||!r.geoProperty||!r.geoOperation)return null;let{node:i}=n.indexes[r.geoProperty],a=r.geoOperation,o=i,s;if(`radius`in a){let{value:e,coordinates:t,unit:n=`m`,inside:r=!0,highPrecision:i=!1}=a.radius,c=t,l=y$(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),U1(s,c,i)}else if(`polygon`in a){let{coordinates:e,inside:t=!0,highPrecision:n=!1}=a.polygon;s=o.searchByPolygon(e,t,`asc`,n);let r=v1.calculatePolygonCentroid(e);return U1(s,r,n)}return null}function K1(e,t){e||=new Set;let n=Object.keys(t),r=n.length;for(let i=0;i<r;i++){let r=t[n[i]],a=r.length;for(let t=0;t<a;t++)e.add(r[t])}return e}function q1(e,t,n,r,i){let a={language:e.tokenizer.language,sharedInternalDocumentStore:t,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(let[o,s]of Object.entries(n)){let n=`${i}${i?`.`:``}${o}`;if(!r.includes(n)){if(typeof s==`object`&&!Array.isArray(s)){let i=q1(e,t,s,r,n);a$(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!I$(s))switch(s){case`boolean`:case`number`:case`string`:a.sortableProperties.push(n),a.sortablePropertiesWithTypes[n]=s,a.sorts[n]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:s};break;case`geopoint`:case`enum`:continue;case`enum[]`:case`boolean[]`:case`number[]`:case`string[]`:continue;default:throw k$(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function J1(e,t,n,r){return r?.enabled===!1?{disabled:!0}:q1(e,t,n,(r||{}).unsortableProperties||[],``)}function Y1(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=U$(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&n0(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function X1(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)e0(e,n);e.isSorted=!0}function Z1(e,t,n){return t[1].localeCompare(n[1],QQ(e))}function Q1(e,t){return e[1]-t[1]}function $1(e,t){return t[1]?-1:1}function e0(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=Z1.bind(null,e.language);break;case`number`:r=Q1.bind(null);break;case`boolean`:r=$1.bind(null);break}n.orderedDocs.sort(r);let i=n.orderedDocs.length;for(let e=0;e<i;e++){let t=n.orderedDocs[e][0];n.docs.set(t,e)}}function t0(e){let t=Object.keys(e.sorts);for(let n of t)n0(e,n)}function n0(e,t){let n=e.sorts[t];n.orderedDocsToRemove.size&&(n.orderedDocs=n.orderedDocs.filter(e=>!n.orderedDocsToRemove.has(e[0])),n.orderedDocsToRemove.clear())}function r0(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=U$(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function i0(e,t,n){if(!e.enabled)throw k$(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw k$(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return n0(e,r),X1(e),t.sort((t,n)=>{let r=a.docs.get(U$(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(U$(e.sharedInternalDocumentStore,n[0])),s=r!==void 0,c=o!==void 0;return!s&&!c?0:s?c?i?o-r:r-o:-1:1}),t}function a0(e){return e.enabled?e.sortableProperties:[]}function o0(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function s0(e,t){let n=t;if(!n.enabled)return{enabled:!1};let r=Object.keys(n.sorts).reduce((e,t)=>{let{docs:r,orderedDocs:i,type:a}=n.sorts[t];return e[t]={docs:new Map(Object.entries(r).map(([e,t])=>[+e,t])),orderedDocsToRemove:new Map,orderedDocs:i,type:a},e},{});return{sharedInternalDocumentStore:e,language:n.language,sortableProperties:n.sortableProperties,sortablePropertiesWithTypes:n.sortablePropertiesWithTypes,sorts:r,enabled:!0,isSorted:n.isSorted}}function c0(e){if(!e.enabled)return{enabled:!1};t0(e),X1(e);let t=Object.keys(e.sorts).reduce((t,n)=>{let{docs:r,orderedDocs:i,type:a}=e.sorts[n];return t[n]={docs:Object.fromEntries(r.entries()),orderedDocs:i,type:a},t},{});return{language:e.language,sortableProperties:e.sortableProperties,sortablePropertiesWithTypes:e.sortablePropertiesWithTypes,sorts:t,enabled:e.enabled,isSorted:e.isSorted}}function l0(){return{create:J1,insert:Y1,remove:r0,save:c0,load:s0,sortBy:i0,getSortableProperties:a0,getSortablePropertiesWithTypes:o0}}const u0=[65,65,65,65,65,65,65,67,69,69,69,69,73,73,73,73,69,78,79,79,79,79,79,null,79,85,85,85,85,89,80,115,97,97,97,97,97,97,97,99,101,101,101,101,105,105,105,105,101,110,111,111,111,111,111,null,111,117,117,117,117,121,112,121,65,97,65,97,65,97,67,99,67,99,67,99,67,99,68,100,68,100,69,101,69,101,69,101,69,101,69,101,71,103,71,103,71,103,71,103,72,104,72,104,73,105,73,105,73,105,73,105,73,105,73,105,74,106,75,107,107,76,108,76,108,76,108,76,108,76,108,78,110,78,110,78,110,110,78,110,79,111,79,111,79,111,79,111,82,114,82,114,82,114,83,115,83,115,83,115,83,115,84,116,84,116,84,116,85,117,85,117,85,117,85,117,85,117,85,117,87,119,89,121,89,90,122,90,122,90,122,115];function d0(e){return e<192||e>383?e:u0[e-192]||e}function f0(e){let t=[];for(let n=0;n<e.length;n++)t[n]=d0(e.charCodeAt(n));return String.fromCharCode(...t)}const p0={ational:`ate`,tional:`tion`,enci:`ence`,anci:`ance`,izer:`ize`,bli:`ble`,alli:`al`,entli:`ent`,eli:`e`,ousli:`ous`,ization:`ize`,ation:`ate`,ator:`ate`,alism:`al`,iveness:`ive`,fulness:`ful`,ousness:`ous`,aliti:`al`,iviti:`ive`,biliti:`ble`,logi:`log`},m0={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},h0=`[aeiouy]`,g0=`[^aeiou][^aeiouy]*`;h0+``;const _0=`^(`+g0+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`;``+g0;const v0=`^(`+g0+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,y0=`^(`+g0+`)?[aeiouy]`;function b0(e){let t,n,r,i,a,o;if(e.length<3)return e;let s=e.substring(0,1);if(s==`y`&&(e=s.toUpperCase()+e.substring(1)),r=/^(.+?)(ss|i)es$/,i=/^(.+?)([^s])s$/,r.test(e)?e=e.replace(r,`$1$2`):i.test(e)&&(e=e.replace(i,`$1$2`)),r=/^(.+?)eed$/,i=/^(.+?)(ed|ing)$/,r.test(e)){let t=r.exec(e);r=new RegExp(_0),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(y0),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+g0+h0+`[^aeiouwxy]$`),i.test(e)?e+=`e`:a.test(e)?(r=/.$/,e=e.replace(r,``)):o.test(e)&&(e+=`e`)));if(r=/^(.+?)y$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(y0),t&&r.test(t)&&(e=t+`i`)),r=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(_0),t&&r.test(t)&&(e=t+p0[n])}if(r=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(_0),t&&r.test(t)&&(e=t+m0[n])}if(r=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,i=/^(.+?)(s|t)(ion)$/,r.test(e))t=r.exec(e)?.[1],r=new RegExp(v0),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(v0),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(v0),i=RegExp(`^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`),a=RegExp(`^`+g0+h0+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(v0),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function x0(e,t,n=!0){let r=`${this.language}:${e}:${t}`;return n&&this.normalizationCache.has(r)?this.normalizationCache.get(r):this.stopWords?.includes(t)?(n&&this.normalizationCache.set(r,``),``):(this.stemmer&&!this.stemmerSkipProperties.has(e)&&(t=this.stemmer(t)),t=f0(t),n&&this.normalizationCache.set(r,t),t)}function S0(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function C0(e,t,n,r=!0){if(t&&t!==this.language)throw k$(`LANGUAGE_NOT_SUPPORTED`,t);if(typeof e!=`string`)return[e];let i=this.normalizeToken.bind(this,n??``),a;if(n&&this.tokenizeSkipProperties.has(n))a=[i(e,r)];else{let t=XQ[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=S0(a);return this.allowDuplicates?o:Array.from(new Set(o))}function w0(e={}){if(!e.language)e.language=`english`;else if(!ZQ.includes(e.language))throw k$(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw k$(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=b0;else throw k$(`MISSING_STEMMER`,e.language);let n;if(e.stopWords!==!1){if(n=[],Array.isArray(e.stopWords))n=e.stopWords;else if(typeof e.stopWords==`function`)n=e.stopWords(n);else if(e.stopWords)throw k$(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw k$(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw k$(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:C0,language:e.language,stemmer:t,stemmerSkipProperties:new Set(e.stemmerSkipProperties?[e.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(e.tokenizeSkipProperties?[e.tokenizeSkipProperties].flat():[]),stopWords:n,allowDuplicates:!!e.allowDuplicates,normalizeToken:x0,normalizationCache:new Map};return r.tokenize=C0.bind(r),r.normalizeToken=x0,r}function T0(e){return{sharedInternalDocumentStore:e,rules:new Map}}function E0(e,t){if(e.rules.has(t.id))throw Error(`PINNING_RULE_ALREADY_EXISTS: A pinning rule with id "${t.id}" already exists. Use updateRule to modify it.`);e.rules.set(t.id,t)}function D0(e,t){if(!e.rules.has(t.id))throw Error(`PINNING_RULE_NOT_FOUND: Cannot update pinning rule with id "${t.id}" because it does not exist. Use addRule to create it.`);e.rules.set(t.id,t)}function O0(e,t){return e.rules.delete(t)}function k0(e,t){return e.rules.get(t)}function A0(e){return Array.from(e.rules.values())}function j0(e,t){let n=e.toLowerCase().trim(),r=t.pattern.toLowerCase().trim();switch(t.anchoring){case`is`:return n===r;case`starts_with`:return n.startsWith(r);case`contains`:return n.includes(r);default:return!1}}function M0(e,t){return e?t.conditions.every(t=>j0(e,t)):!1}function N0(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())M0(t,r)&&n.push(r);return n}function P0(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function F0(e){return{rules:Array.from(e.rules.entries())}}function I0(){return{create:T0,addRule:E0,updateRule:D0,removeRule:O0,getRule:k0,getAllRules:A0,getMatchingRules:N0,load:P0,save:F0}}function L0(e){let t={formatElapsedTime:A$,getDocumentIndexId:j$,getDocumentProperties:g$,validateSchema:M$};for(let n of i1){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw k$(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!r1.includes(t)&&!i1.includes(t))throw k$(`UNSUPPORTED_COMPONENT`,t)}function R0({schema:e,sort:t,language:n,components:r,id:i,plugins:a}){r||={};for(let t of a??[]){if(!(`getComponents`in t)||typeof t.getComponents!=`function`)continue;let n=t.getComponents(e),i=Object.keys(n);for(let e of i)if(r[e])throw k$(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=f$();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:w0(o):w0({language:n??`english`}),r.tokenizer&&n)throw k$(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=B$();s||=V1(),l||=l0(),c||=e1(),u||=I0(),L0(r);let{getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,formatElapsedTime:h}=r,g={data:{},caches:{},schema:e,tokenizer:o,index:s,sorter:l,documentsStore:c,pinning:u,internalDocumentIDStore:d,getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,beforeInsert:[],afterInsert:[],beforeRemove:[],afterRemove:[],beforeUpdate:[],afterUpdate:[],beforeUpsert:[],afterUpsert:[],beforeSearch:[],afterSearch:[],beforeInsertMultiple:[],afterInsertMultiple:[],beforeRemoveMultiple:[],afterRemoveMultiple:[],beforeUpdateMultiple:[],afterUpdateMultiple:[],beforeUpsertMultiple:[],afterUpsertMultiple:[],afterCreate:[],formatElapsedTime:h,id:i,plugins:a,version:z0()};g.data={index:g.index.create(g,d,e),docs:g.documentsStore.create(g,d),sorting:g.sorter.create(g,d,e,t),pinning:g.pinning.create(d)};for(let e of t1)g[e]=(g[e]??[]).concat(n1(g,e));let _=g.afterCreate;return _&&l1(_,g),g}function z0(){return`{{VERSION}}`}function B0(e){return e.documentsStore.count(e.data.docs)}function V0(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw k$(`SCHEMA_VALIDATION_FAILURE`,a);return x$(e.beforeInsert)||x$(e.afterInsert)||x$(e.index.beforeInsert)||x$(e.index.insert)||x$(e.index.afterInsert)?W0(e,t,n,r,i):G0(e,t,n,r,i)}const H0=new Set([`enum`,`enum[]`]),U0=new Set([`string`,`number`]);async function W0(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw k$(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=U$(e.internalDocumentIDStore,s);if(r||await a1(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw k$(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];K0(n,r,e,t)}return await q0(e,s,u,f,l,n,t,i),r||await a1(e.afterInsert,e,s,t),s}function G0(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw k$(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=U$(e.internalDocumentIDStore,s);if(r||a1(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw k$(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];K0(n,r,e,t)}return J0(e,s,u,f,l,n,t,i),r||a1(e.afterInsert,e,s,t),s}function K0(e,t,n,r){if(!(F$(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(I$(t)&&Array.isArray(r))&&!(L$(t)&&Array.isArray(r))&&!(H0.has(t)&&U0.has(e))&&e!==t)throw k$(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function q0(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o];await e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i);let l=e.internalDocumentIDStore.idToInternalId.get(t);await e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),await e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function J0(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o],l=U$(e.internalDocumentIDStore,t);e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i),e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function Y0(e,t,n,r,i,a){return x$(e.afterInsertMultiple)||x$(e.beforeInsertMultiple)||x$(e.index.beforeInsert)||x$(e.index.insert)||x$(e.index.afterInsert)?X0(e,t,n,r,i,a):Z0(e,t,n,r,i,a)}async function X0(e,t,n=1e3,r,i,a=0){let o=[],s=async a=>{let s=Math.min(a+n,t.length),c=t.slice(a,s);for(let t of c){let n=await V0(e,t,r,i,{avlRebalanceThreshold:c.length});o.push(n)}return s};return await(async()=>{let e=0;for(;e<t.length;){let t=Date.now();if(e=await s(e),a>0){let e=a-(Date.now()-t);e>0&&D$(e)}}})(),i||await o1(e.afterInsertMultiple,e,t),o}function Z0(e,t,n=1e3,r,i,a=0){let o=[],s=0;function c(){let a=t.slice(s*n,(s+1)*n);if(a.length===0)return!1;for(let t of a){let n=V0(e,t,r,i,{avlRebalanceThreshold:a.length});o.push(n)}return s++,!0}function l(){let e=Date.now();for(;c();)if(a>0){let t=Date.now()-e;if(t>=a){let e=a-t%a;e>0&&D$(e)}}}return l(),i||o1(e.afterInsertMultiple,e,t),o}function Q0(e,t,n,r){return x$(e.index.beforeRemove)||x$(e.index.remove)||x$(e.index.afterRemove)?$0(e,t,n,r):e2(e,t,n,r)}async function $0(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=U$(e.internalDocumentIDStore,t),l=W$(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||await a1(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];await e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),await e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),await e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=await e.sorter.getSortableProperties(e.data.sorting),h=await e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||await a1(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function e2(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=U$(e.internalDocumentIDStore,t),l=W$(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||a1(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=e.sorter.getSortableProperties(e.data.sorting),h=e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||a1(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function t2(e,t,n,r,i){return x$(e.index.beforeRemove)||x$(e.index.remove)||x$(e.index.afterRemove)||x$(e.beforeRemoveMultiple)||x$(e.afterRemoveMultiple)?n2(e,t,n,r,i):r2(e,t,n,r,i)}async function n2(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>W$(e.internalDocumentIDStore,U$(e.internalDocumentIDStore,t)));return i||await o1(e.beforeRemoveMultiple,e,o),await new Promise((o,s)=>{let c=0;async function l(){let u=t.slice(c*n,++c*n);if(!u.length)return o();for(let t of u)try{await Q0(e,t,r,i)&&a++}catch(e){s(e)}setTimeout(l,0)}setTimeout(l,0)}),i||await o1(e.afterRemoveMultiple,e,o),a}function r2(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>W$(e.internalDocumentIDStore,U$(e.internalDocumentIDStore,t)));i||o1(e.beforeRemoveMultiple,e,o);let s=0;function c(){let o=t.slice(s*n,++s*n);if(o.length){for(let t of o)Q0(e,t,r,i)&&a++;setTimeout(c,0)}}return c(),i||o1(e.afterRemoveMultiple,e,o),a}function i2(e,t){return e[1]-t[1]}function a2(e,t){return t[1]-e[1]}function o2(e=`desc`){return e.toLowerCase()===`asc`?i2:a2}function s2(e,t,n){let r={},i=t.map(([e])=>e),a=e.documentsStore.getMultiple(e.data.docs,i),o=Object.keys(n),s=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e of o){let t;if(s[e]===`number`){let{ranges:r}=n[e],i=r.length,a=Array.from({length:i});for(let e=0;e<i;e++){let t=r[e];a[e]=[`${t.from}-${t.to}`,0]}t=Object.fromEntries(a)}r[e]={count:0,values:t??{}}}let c=a.length;for(let e=0;e<c;e++){let t=a[e];for(let e of o){let i=e.includes(`.`)?_$(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;c2(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=c2(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:l2(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=l2(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw k$(`FACET_NOT_SUPPORTED`,a)}}}for(let e of o){let t=r[e];if(t.count=Object.keys(t.values).length,s[e]===`string`){let r=n[e],i=o2(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function c2(e,t,n){return r=>{for(let i of e){let e=`${i.from}-${i.to}`;n?.has(e)||r>=i.from&&r<=i.to&&(t[e]===void 0?t[e]=1:(t[e]++,n?.add(e)))}}}function l2(e,t,n){let r=t===`boolean`?`false`:``;return t=>{let i=t?.toString()??r;n?.has(i)||(e[i]=(e[i]??0)+1,n?.add(i))}}const u2={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},d2=[`string`,`number`,`boolean`];function f2(e,t,n){let r=n.properties,i=r.length,a=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e=0;e<i;e++){let t=r[e];if(a[t]===void 0)throw k$(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!d2.includes(a[t]))throw k$(`INVALID_GROUP_BY_PROPERTY`,t,d2.join(`, `),a[t])}let o=t.map(([t])=>W$(e.internalDocumentIDStore,t)),s=e.documentsStore.getMultiple(e.data.docs,o),c=s.length,l=n.maxResult||2**53-1,u=[],d={};for(let e=0;e<i;e++){let t=r[e],n={property:t,perValue:{}},i=new Set;for(let e=0;e<c;e++){let r=s[e],a=_$(r,t);if(a===void 0)continue;let o=typeof a==`boolean`?``+a:a,c=n.perValue[o]??{indexes:[],count:0};c.count>=l||(c.indexes.push(e),c.count++,n.perValue[o]=c,i.add(a))}u.push(Array.from(i)),d[t]=n}let f=p2(u),p=f.length,m=[];for(let e=0;e<p;e++){let t=f[e],n=t.length,i={values:[],indexes:[]},a=[];for(let e=0;e<n;e++){let n=t[e],o=r[e];a.push(d[o].perValue[typeof n==`boolean`?``+n:n].indexes),i.values.push(n)}i.indexes=h$(a).sort((e,t)=>e-t),i.indexes.length!==0&&m.push(i)}let h=m.length,g=Array.from({length:h});for(let e=0;e<h;e++){let r=m[e],i=n.reduce||u2,a=r.indexes.map(e=>({id:o[e],score:t[e][1],document:s[e]})),c=i.reducer.bind(null,r.values),l=i.getInitialValue(r.indexes.length),u=a.reduce(c,l);g[e]={values:r.values,result:u}}return g}function p2(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=p2(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];a$(n,t),i.push(n)}return i}function m2(e,t,n,r){let i=N0(t,r);if(i.length===0)return n;let a=i.flatMap(e=>e.consequence.promote);a.sort((e,t)=>e.position-t.position);let o=new Set,s=new Map,c=new Set;for(let t of a){let n=U$(e.internalDocumentIDStore,t.doc_id);if(n!==void 0){if(s.has(n)){let e=s.get(n);t.position<e&&s.set(n,t.position);continue}c.has(t.position)||(o.add(n),s.set(n,t.position),c.add(t.position))}}if(s.size===0)return n;let l=n.filter(([e])=>!o.has(e)),u=[];for(let[t,r]of s.entries())n.find(([e])=>e===t)?u.push([t,1e6-r]):e.documentsStore.get(e.data.docs,t)&&u.push([t,0]);u.sort((e,t)=>(s.get(e[0])??1/0)-(s.get(t[0])??1/0));let d=[],f=new Map;for(let e of u){let t=s.get(e[0]);f.set(t,e)}let p=0,m=0;for(;m<l.length+u.length;)if(f.has(m))d.push(f.get(m)),m++;else if(p<l.length)d.push(l[p]),p++,m++;else break;for(let[e,t]of f.entries())e>=d.length&&d.push(t);return d}function h2(e,t,n){let{term:r,properties:i}=t,a=e.data.index,o=e.caches.propertiesToSearch;if(!o){let t=e.index.getSearchablePropertiesWithTypes(a);o=e.index.getSearchableProperties(a),o=o.filter(e=>t[e].startsWith(`string`)),e.caches.propertiesToSearch=o}if(i&&i!==`*`){for(let e of i)if(!o.includes(e))throw k$(`UNKNOWN_INDEX`,e,o.join(`, `));o=o.filter(e=>i.includes(e))}let s=Object.keys(t.where??{}).length>0,c;s&&(c=e.index.searchByWhereClause(a,e.tokenizer,t.where,n));let l,u=t.threshold!==void 0&&t.threshold!==null?t.threshold:1;if(r||i){let i=B0(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},b2(t.relevance),i,c,u),t.exact&&r){let t=r.trim().split(/\s+/);l=l.filter(([n])=>{let r=e.documentsStore.get(e.data.docs,n);if(!r)return!1;for(let e of o){let n=_2(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${g2(e)}\\b`).test(n)))return!0}return!1})}}else l=s?G1(a,t.where)||(c?Array.from(c):[]).map(e=>[+e,0]):Object.keys(e.documentsStore.getAll(e.data.docs)).map(e=>[+e,0]);return l}function g2(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _2(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return r}function v2(e,t,n){let r=d$();function i(){let i=Object.keys(e.data.index.vectorIndexes),a=t.facets&&Object.keys(t.facets).length>0,{limit:o=10,offset:s=0,distinctOn:c,includeVectors:l=!1}=t,u=t.preflight===!0,d=h2(e,t,n);if(t.sortBy)if(typeof t.sortBy==`function`){let n=d.map(([e])=>e),r=e.documentsStore.getMultiple(e.data.docs,n).map((e,t)=>[d[t][0],d[t][1],e]);r.sort(t.sortBy),d=r.map(([e,t])=>[e,t])}else d=e.sorter.sortBy(e.data.sorting,d,t.sortBy).map(([t,n])=>[U$(e.internalDocumentIDStore,t),n]);else d=d.sort(m$);d=m2(e,e.data.pinning,d,t.term);let f;u||(f=c?M2(e,d,s,o,c):N2(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||b$(p,i)),a&&(p.facets=s2(e,d,t.facets)),t.groupBy&&(p.groups=f2(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(d$()-r),p}async function a(){e.beforeSearch&&await c1(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await s1(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}const y2={k:1.2,b:.75,d:.5};function b2(e){let t=e??{};return t.k=t.k??y2.k,t.b=t.b??y2.b,t.d=t.d??y2.d,t}function x2(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw k$(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw k$(`UNKNOWN_VECTOR_PROPERTY`,r.property);let a=i.node.size;if(r?.value.length!==a)throw r?.property===void 0||r?.value.length===void 0?k$(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):k$(`INVALID_INPUT_VECTOR`,r.property,a,r.value.length);let o=e.data.index,s;return Object.keys(t.where??{}).length>0&&(s=e.index.searchByWhereClause(o,e.tokenizer,t.where,n)),i.node.find(r.value,t.similarity??.8,s)}function S2(e,t,n=`english`){let r=d$();function i(){let i=x2(e,t,n).sort(m$);i=m2(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=s2(e,i,t.facets));let o=t.vector.property,s=t.includeVectors??!1,c=t.limit??10,l=t.offset??0,u=Array.from({length:c});for(let t=0;t<c;t++){let n=i[t+l];if(!n)break;let r=e.data.docs.docs[n[0]];r&&(s||(r[o]=null),u[t]={id:W$(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=f2(e,i,t.groupBy));let f=d$()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:u$(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await c1(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await s1(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function C2(e,t,n){let r=E2(h2(e,t,n)),i=x2(e,t,n),a=t.hybridWeights;return k2(r,i,t.term??``,a)}function w2(e,t,n){let r=d$();function i(){let i=C2(e,t,n);i=m2(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=s2(e,i,t.facets));let o;t.groupBy&&(o=f2(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=N2(e,i,s,c).filter(Boolean),u=d$(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:u$(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||b$(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await c1(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await s1(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function T2(e){return e[1]}function E2(e){let t=Math.max.apply(Math,e.map(T2));return e.map(([e,n])=>[e,n/t])}function D2(e,t){return e/t}function O2(e,t){return(n,r)=>n*e+r*t}function k2(e,t,n,r){let i=Math.max.apply(Math,e.map(T2)),a=Math.max.apply(Math,t.map(T2)),{text:o,vector:s}=r&&r.text&&r.vector?r:A2(n),c=new Map,l=e.length,u=O2(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(D2(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=D2(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function A2(e){return{text:.5,vector:.5}}function j2(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return v2(e,t,n);if(r===`vector`)return S2(e,t);if(r===`hybrid`)return w2(e,t);throw k$(`INVALID_SEARCH_MODE`,r)}function M2(e,t,n,r,i){let a=e.data.docs,o=new Map,s=[],c=new Set,l=t.length,u=0;for(let d=0;d<l;d++){let l=t[d];if(l===void 0)continue;let[f,p]=l;if(c.has(f))continue;let m=e.documentsStore.get(a,f),h=_$(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:W$(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function N2(e,t,n,r){let i=e.data.docs,a=Array.from({length:r}),o=new Set;for(let s=n;s<r+n;s++){let n=t[s];if(n===void 0)break;let[r,c]=n;if(!o.has(r)){let t=e.documentsStore.get(i,r);a[s]={id:W$(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}const P2={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},F2=new WeakMap;function I2(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function L2(e){return e.trim().toLowerCase()}const R2=/\.(?:md|mdx)$/;function z2(e,t){if(t!==`page`)return e;let n=e.replace(R2,``);return n.length>0?n:e}function B2(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function V2(e){let t=B2(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 H2(e){let t=R0({schema:P2});return e.length>0&&Y0(t,e),t}function U2(e){let t={documents:e};return F2.set(t,H2(e)),t}function W2(e){let t=F2.get(e);if(t)return t;let n=H2(e.documents);return F2.set(e,n),n}const G2=new WeakSet;function K2(e,t){return e===t||e.kind===t.kind&&e.path===t.path&&e.title===t.title&&e.name===t.name&&e.pathSegments===t.pathSegments&&e.modifiedTs===t.modifiedTs&&e.content===t.content}function q2(e,t){let n=e=>({corpus:U2(t),inserted:0,updated:0,removed:0,rebuilt:!0,rebuildReason:e}),r=F2.get(e);if(!r)return n(`no-index`);if(G2.has(e))return n(`stale-base`);let i=new Map(t.map(e=>[e.id,e]));if(i.size!==t.length)return n(`duplicate-id`);let a=[],o=[],s=0;for(let t of e.documents){let e=i.get(t.id);e?K2(t,e)||(a.push(t.id),o.push(e),s+=1):a.push(t.id)}let c=new Set(e.documents.map(e=>e.id));for(let e of t)c.has(e.id)||o.push(e);if(a.length+o.length>t.length)return n(`bulk-change`);G2.add(e);try{if(a.length>0&&t2(r,a),o.length>0&&Y0(r,o),B0(r)!==t.length)throw Error(`Search index count ${B0(r)} diverged from document count ${t.length} after incremental update`)}catch{return n(`mutation-failed`)}let l={documents:t};return F2.set(l,r),{corpus:l,inserted:o.length-s,updated:s,removed:a.length-s,rebuilt:!1}}function J2(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function Y2(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function X2(e,t){let n=L2(t);if(!n)return 0;let r=z2(n,e.kind),i=L2(e.title),a=L2(e.name),o=L2(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 Z2(e,t){let n=X2(e,t);return n<=0?n:Zv(e.path)?n*.5:n}function Q2(e){return e===`file`?-60:0}function $2(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 e4(e,t,n,r){return e+t*20+n+Q2(r)}function t4(e,t,n,r,i,a){return e===`relevance`?e4(t,n,r,i):$2(t,n,r,i,a)}function n4(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function r4(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function i4(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 a4(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function o4(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 s4(e,t){return L2(t).length<4?0:+(e===`full_text`)}function c4(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function l4(e){let t=[],n=[],r=[];for(let i of e){let e=c4(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 u4(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=l4(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 d4(e,t,n={}){let r=n.intent??`omnibar`,i=n4(r,n.ranking),a=I2(n.limit),o=new Set(n.scopes??J2(r)),s=e.documents.filter(e=>Y2(e,o)),c=L2(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=j2(W2(e),{term:c,properties:a4(r),boost:o4(r),tolerance:s4(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>Y2(e.document,o)).map(e=>[e.document.id,e.score])),d=i4(s),f=new Map;for(let e of s)Z2(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)Y2(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=r4(f.values(),u);return u4([...f.values()].map(t=>{let n=Math.max(0,Z2(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:t4(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 u4(p4({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function f4(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function p4(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=r4(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,Z2(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?t4(o,t,n,s,e.kind,m):e4(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=f4(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)),_=f4(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),r=+(t.lexical>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}))}const m4=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),h4=globalThis;h4[m4]===void 0&&(h4[m4]=p());const g4=h4[m4],_4=[`.ok`,`skill-state.yml`],v4=[`claude-cowork`,`cli-hosts`],y4=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],b4=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,x4=w({version:b().regex(b4,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(g4,{description:`Recorded skill version for this target.`}),recordedAt:ne().register(g4,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:d(y4).register(g4,{description:`Install-source surface that recorded this entry.`}).optional()}),S4=w({enabled:E().register(g4,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:ne().register(g4,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),C4=w({schema:_(1).register(g4,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:w({"claude-cowork":x4.optional(),"cli-hosts":x4.optional()}).register(g4,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:T(b(),S4).register(g4,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function w4(e,t){return e??t.installedOnDisk}function T4(){return{schema:1,targets:{}}}const E4=`template`;function D4(e){if(e.trim()===``)return{};let t;try{t=(0,ye.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function O4(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function k4(e){let{frontmatter:t,body:n}=Dp(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:kp(t),markdown:n}}function A4(e){let t=e.split(`
327
+ `);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=D4(n.join(`
328
+ `))[E4];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
329
+ `).replace(/\n+$/,``)}}function j4(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=Dp(t);if(n===``)return{identity:{},starterContent:t};let i=kp(n),a=A4(i);if(a)return{identity:a.identity,starterContent:O4(a.docFrontmatterText,r)};let{frontmatter:o}=Dp(r);if(o!==``)return{identity:D4(i),starterContent:r};let s=D4(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:O4(i,r)}}function M4(e,t){let{docFrontmatterText:n,markdown:r}=k4(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,ye.stringify)({[E4]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function N4(e){return j4(e).starterContent}const P4=`(agent thread)`;function F4(){let e=!1,t=``,n=0;return r=>{let i=I4(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 I4(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 L4=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],R4={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function z4(e,t=L4){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const B4={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function V4(e){return e?B4[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const H4={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function U4(e){let t=e?.trim();return t?H4[V4(t)]??t:`Agent`}function W4(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 G4=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function K4(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function q4(e){let t=e.trim();return G4.test(t)||t.startsWith(`//`)}function J4(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(q4(n))return{kind:`external`,url:n};let r=W4(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=K4(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function Y4(e,t){let n=e.trim();if(!n)return null;if(q4(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=K4(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function X4(e,t){let n=e.trim();if(!n||G4.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 Z4(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function Q4(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function $4(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function e3(e){return e.split(`/`).filter(e=>e!==``)}function t3(e,t){let n=$4(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function n3(e,t){let n=$4(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:e3(r).length}function r3(e,t){let n=e3(e),r=e3(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function i3(){let e=new Map;function t(t){let n=Z4(t);if(n===``)return;let r=Q4(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=Z4(t),r=Q4(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=$4(Z4(n)),o=[],s=[];for(let e of i)t3(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=n3(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=n3(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=r3(a,$4(t));for(let r=1;r<e.length;r++){let i=e[r],o=r3(a,$4(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 a3(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 o3(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}export{PZ as $,xe as $a,dy as $i,eY as $n,xq as $r,XY as $t,qQ as A,at as Aa,BV as Ai,iY as An,$q as Ar,OX as At,DQ as B,qe as Ba,Iy as Bi,hY as Bn,Rq as Br,yX as Bt,w4 as C,lt as Ca,TK as Ci,MY as Cn,dJ as Cr,$Y as Ct,q2 as D,st as Da,tH as Di,AY as Dn,lJ as Dr,HX as Dt,d4 as E,ot as Ea,oH as Ei,kY as En,cJ as Er,UX as Et,LQ as F,Xe as Fa,rL as Fi,lY as Fn,iJ as Fr,GX as Ft,QZ as G,Ee as Ga,Vy as Gi,BJ as Gn,Cq as Gr,FX as Gt,EQ as H,Ge as Ha,Fy as Hi,xY as Hn,zq as Hr,RX as Ht,IQ as I,et as Ia,DN as Ii,rY as In,Kq as Ir,jX as It,HZ as J,we as Ja,ky as Ji,ZJ as Jn,Iq as Jr,NX as Jt,JZ as K,Ce as Ka,zy as Ki,VJ as Kn,Lq as Kr,IX as Kt,FQ as L,Ze as La,bM as Li,fY as Ln,qq as Lr,CX as Lt,HQ as M,Je as Ma,SB as Mi,gY as Mn,Xq as Mr,DX as Mt,RQ as N,Ye as Na,uB as Ni,_Y as Nn,Yq as Nr,gX as Nt,UQ as O,rt as Oa,ZV as Oi,oY as On,pJ as Or,SX as Ot,PQ as P,tt as Pa,lB as Pi,cY as Pn,tJ as Pr,AX as Pt,FZ as Q,Me as Qa,fy as Qi,QJ as Qn,vq as Qr,mX as Qt,NQ as R,$e as Ra,Ly as Ri,uY as Rn,Mq as Rr,wX as Rt,T4 as S,dt as Sa,gK as Si,jY as Sn,_J as Sr,QY as St,V2 as T,ct as Ta,dK as Ti,OY as Tn,mJ as Tr,zX as Tt,yQ as U,Se as Ua,Wy as Ui,vY as Un,Bq as Ur,uX as Ut,bQ as V,Ke as Va,By as Vi,bY as Vn,Tq as Vr,LX as Vt,vQ as W,De as Wa,Hy as Wi,yY as Wn,Uq as Wr,PX as Wt,RZ as X,ke as Xa,iy as Xi,qJ as Xn,Wq as Xr,xX as Xt,zZ as Y,Oe as Ya,jy as Yi,YJ as Yn,Pq as Yr,bX as Yt,LZ as Z,Ae as Za,sy as Zi,KJ as Zn,Gq as Zr,_X as Zt,j4 as _,vd as _a,CK as _i,IY as _n,yJ as _r,XX as _t,Y4 as a,yy as aa,KK as ai,cX as an,Ne as ao,IJ as ar,wZ as at,b4 as b,pt as ba,EK as bi,FY as bn,hJ as br,KX as bt,R4 as c,Zv as ca,WK as ci,iX as cn,be as co,OJ as cr,aZ as ct,V4 as d,Kv as da,OK as di,WY as dn,fe as do,AJ as dr,rZ as dt,my as ea,iq as ei,JY as en,je as eo,GJ as er,NZ as et,F4 as f,Wv as fa,AK as fi,GY as fn,de as fo,kJ as fr,nZ as ft,N4 as g,kp as ga,vK as gi,UY as gn,xJ as gr,qX as gt,M4 as h,Dp as ha,_K as hi,VY as hn,TJ as hr,QX as ht,J4 as i,Ty as ia,XK as ii,oX as in,Le as io,FJ as ir,xZ as it,JQ as j,nt as ja,LV as ji,aY as jn,Qq as jr,EX as jt,KQ as k,it as ka,QV as ki,sY as kn,sJ as kr,kX as kt,z4 as l,Yv as la,jK as li,nX as ln,pe as lo,NJ as lr,uZ as lt,E4 as m,Op as ma,BK as mi,qY as mn,CJ as mr,tZ as mt,o3 as n,My as na,mq as ni,tX as nn,ze as no,WJ as nr,OZ as nt,X4 as o,Ey as oa,GK as oi,lX as on,Fe as oo,EJ as or,gZ as ot,P4 as p,Bv as pa,zK as pi,KY as pn,MJ as pr,eZ as pt,XZ as q,Te as qa,Oy as qi,$J as qn,Sq as qr,MX as qt,i3 as r,Ny as ra,QK as ri,aX as rn,He as ro,HJ as rr,bZ as rt,W4 as s,_y as sa,UK as si,rX as sn,Be as so,DJ as sr,hZ as st,a3 as t,gy as ta,pq as ti,sX as tn,We as to,UJ as tr,TZ as tt,U4 as u,qv as ua,PK as ui,pX as un,me as uo,PJ as ur,$X as ut,_4 as v,oi as va,mK as vi,LY as vn,vJ as vr,YX as vt,U2 as w,ut as wa,fK as wi,NY as wn,fJ as wr,dX as wt,C4 as x,ft as xa,DK as xi,PY as xn,gJ as xr,ZY as xt,v4 as y,I as ya,SK as yi,BY as yn,SJ as yr,JX as yt,MQ as z,Qe as za,Uy as zi,mY as zn,wq as zr,vX as zt};
330
+ //# sourceMappingURL=src-BTs5LPkM.mjs.map