@inkeep/open-knowledge 0.46.0-beta.4 → 0.46.0-beta.6

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 (112) hide show
  1. package/dist/{acp-harness-probe-BQ3_wze1.mjs → acp-harness-probe-Bhr8FI29.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 +16 -16
  5. package/dist/constants-CScYQw9V.mjs +2 -0
  6. package/dist/{git-handle-BnrTPYj_.mjs → git-handle-CK_JXuyw.mjs} +2 -2
  7. package/dist/git-handle-DyS9-xsk.mjs +1 -0
  8. package/dist/index.mjs +1 -1
  9. package/dist/init-BIInZq9o.mjs +1 -0
  10. package/dist/{init-D0wKKFay.mjs → init-DoPgyAbZ.mjs} +4 -4
  11. package/dist/{launch-json-removal-CmpnCINi.mjs → launch-json-removal-iD7o5ZhH.mjs} +2 -2
  12. package/dist/loader-BC9hZLNV.mjs +1 -0
  13. package/dist/{loader-Sk1Z2HXI.mjs → loader-doXjfQUX.mjs} +2 -2
  14. package/dist/md-manager-BWTSpVXC.mjs +2 -0
  15. package/dist/{open-browser-DZWA0mkS.mjs → open-browser-BHXl6F9O.mjs} +2 -2
  16. package/dist/parse-worker.mjs +1 -1
  17. package/dist/{preview-B4nElYVr.mjs → preview-C67jEM8C.mjs} +2 -2
  18. package/dist/preview-DrXnMxVX.mjs +1 -0
  19. package/dist/public/assets/{ActivityModeContent-DKkJMuA9.js → ActivityModeContent-BquAhT5x.js} +1 -1
  20. package/dist/public/assets/{AgentDiffPane-DkzTKjWa.js → AgentDiffPane-6bk9bV9U.js} +1 -1
  21. package/dist/public/assets/{AgentThreadClientBinder-BqONUtGD.js → AgentThreadClientBinder-u3ZVSSHE.js} +1 -1
  22. package/dist/public/assets/{CodeMirrorPropInput-CyIlgGaP.js → CodeMirrorPropInput-DOcEkWLX.js} +2 -2
  23. package/dist/public/assets/{DocumentContext-QeD0oigI.js → DocumentContext-uE-Jpe8-.js} +10 -10
  24. package/dist/public/assets/{EditorModeToggle-12SdK7ya.js → EditorModeToggle-DBmNyzRU.js} +1 -1
  25. package/dist/public/assets/{EnableSyncConfirmDialog-GUnrwfa0.js → EnableSyncConfirmDialog-Dufpw3Xm.js} +1 -1
  26. package/dist/public/assets/FeedbackForm-CuzqS5aL.js +1 -0
  27. package/dist/public/assets/{GraphPanel-DE5iijrO.js → GraphPanel-DZMLD8ni.js} +2 -2
  28. package/dist/public/assets/{LintConfigEditor-BNN0UkHw.js → LintConfigEditor-k9WOKYkq.js} +1 -1
  29. package/dist/public/assets/{ManagedArtifactProperties-Bab8809-.js → ManagedArtifactProperties-xXR4EKXf.js} +1 -1
  30. package/dist/public/assets/{McpConsentDialogBody-xnaSaj_X.js → McpConsentDialogBody-CHmK7aXE.js} +1 -1
  31. package/dist/public/assets/{MermaidDocEditor-Bw26glK9.js → MermaidDocEditor-CGsfhioE.js} +1 -1
  32. package/dist/public/assets/PropertyPanel-C0kyK4Hh.js +2 -0
  33. package/dist/public/assets/{ReportBugDialogBody-SYqc1dep.js → ReportBugDialogBody-CdEV6nCR.js} +1 -1
  34. package/dist/public/assets/{SchemaConfigEditor-RgV92dU4.js → SchemaConfigEditor-BFx4ZhVm.js} +1 -1
  35. package/dist/public/assets/{SettingsDialogBody-Bhk4NQJN.js → SettingsDialogBody-Chz13SZG.js} +3 -3
  36. package/dist/public/assets/{ShareBranchSwitchDialog-BXjj8rUu.js → ShareBranchSwitchDialog-jGb4KF7T.js} +1 -1
  37. package/dist/public/assets/{ShareReceiveDialog-CXqdzDYu.js → ShareReceiveDialog-C7_nVZOF.js} +1 -1
  38. package/dist/public/assets/{ShareReceiveMissDialog-BaHsueef.js → ShareReceiveMissDialog-Dv1nzqQa.js} +1 -1
  39. package/dist/public/assets/{SkillEditorActions-CDWxVAy1.js → SkillEditorActions-2WrfNbQp.js} +1 -1
  40. package/dist/public/assets/{SourceEditor-CZhPtXfy.js → SourceEditor-CmpVF187.js} +1 -1
  41. package/dist/public/assets/{TerminalPanel-DiVhC52x.js → TerminalPanel-BHN2VN4r.js} +1 -1
  42. package/dist/public/assets/{TerminalSessionsHost-8wTgxl0R.js → TerminalSessionsHost-Yz2cECTk.js} +2 -2
  43. package/dist/public/assets/{TerminalWindowApp-CQunMofw.js → TerminalWindowApp-CntBjoWb.js} +1 -1
  44. package/dist/public/assets/{ThreadView-BI4embLm.js → ThreadView-loAOfVAD.js} +1 -1
  45. package/dist/public/assets/{TimelineDiffPane-Dd-khPXZ.js → TimelineDiffPane-C5gRZMQN.js} +1 -1
  46. package/dist/public/assets/{agent-diff-store-CcwDxQK9.js → agent-diff-store-BvRAZqCN.js} +1 -1
  47. package/dist/public/assets/{agent-visibility-mwTztYpe.js → agent-visibility-DJ6Bc0aU.js} +1 -1
  48. package/dist/public/assets/{auth-state-cache-Bkm-5pQl.js → auth-state-cache-CEu3ZBI_.js} +1 -1
  49. package/dist/public/assets/{client-version-g_nEG2h2.js → client-version-MIkctMik.js} +1 -1
  50. package/dist/public/assets/{comment-chips--aitTdum.js → comment-chips-BYH7v5tl.js} +1 -1
  51. package/dist/public/assets/{config-provider-CedEU5Ch.js → config-provider-B9kQH9zn.js} +2 -2
  52. package/dist/public/assets/{dist-Cv2LF2DL.js → dist-DJbbCXtB.js} +183 -177
  53. package/dist/public/assets/{doc-hash-unBeSU8C.js → doc-hash-BbU2eA08.js} +1 -1
  54. package/dist/public/assets/{documents-events-DJXnk07Z.js → documents-events-C-mYs64z.js} +1 -1
  55. package/dist/public/assets/{file-tree-adapter-C9l0Uy9t.js → file-tree-adapter-c4ru9pmD.js} +1 -1
  56. package/dist/public/assets/{file-tree-utils-Cy6smqXE.js → file-tree-utils-Lc0SvgnU.js} +1 -1
  57. package/dist/public/assets/{index-BnCzVIZM.js → index-DVlIcKqo.js} +11 -11
  58. package/dist/public/assets/{lint-config-client-SBOLqEAH.js → lint-config-client-DJg7YDu3.js} +1 -1
  59. package/dist/public/assets/{markdownlint-rule-browser-u-niNZkQ.js → markdownlint-rule-browser-6yvn3dt6.js} +1 -1
  60. package/dist/public/assets/{navigation-targets-CRrgSRY3.js → navigation-targets-DwSgIIy0.js} +1 -1
  61. package/dist/public/assets/{open-managed-artifact-tab-DKpdEiZk.js → open-managed-artifact-tab-Dpz9X1m_.js} +1 -1
  62. package/dist/public/assets/{pending-receive-nav-store-EO01lM9G.js → pending-receive-nav-store-t5K6mYGs.js} +1 -1
  63. package/dist/public/assets/{prop-types-DDnDOUmp.js → prop-types-65NJPmd-.js} +1 -1
  64. package/dist/public/assets/{receive-store-CCj5OCl8.js → receive-store-C8NL_Ow-.js} +1 -1
  65. package/dist/public/assets/{selection-context-CsoqdVq1.js → selection-context-BNYOSYyM.js} +1 -1
  66. package/dist/public/assets/{skill-actions-4cV_4pjw.js → skill-actions-ByBHG3Gh.js} +1 -1
  67. package/dist/public/assets/{skills-api-141pFhWO.js → skills-api-DWPhWBud.js} +1 -1
  68. package/dist/public/assets/{src-0hFiTIuh.js → src-U1RHfo7d.js} +1 -1
  69. package/dist/public/assets/{tag-pill-input-C4VKdytg.js → tag-pill-input-BHj4spSb.js} +1 -1
  70. package/dist/public/assets/{target-navigation-intent-BzJodEAL.js → target-navigation-intent-B5jnqgZ_.js} +1 -1
  71. package/dist/public/assets/{terminal-launch-events-Bz4DL9DZ.js → terminal-launch-events-CtZeptxC.js} +1 -1
  72. package/dist/public/assets/{terminal-telemetry-CXqhqIkk.js → terminal-telemetry-CvNM4wYv.js} +1 -1
  73. package/dist/public/assets/typing-burst-detector-CZREoy8B.js +8 -0
  74. package/dist/public/assets/{uninstall-9ZXPO59t.js → uninstall-CA1cQCnA.js} +1 -1
  75. package/dist/public/assets/{use-activity-panel-BBGq_DFB.js → use-activity-panel-DWxDopZd.js} +1 -1
  76. package/dist/public/assets/{use-apply-config-color-theme-zM7Oux5u.js → use-apply-config-color-theme-DSCn9I0W.js} +1 -1
  77. package/dist/public/assets/{use-collab-url-81TC8Fvz.js → use-collab-url-CE02D4PJ.js} +1 -1
  78. package/dist/public/assets/{use-live-xterm-theme-DeW6SO6V.js → use-live-xterm-theme-B2MdP4nP.js} +1 -1
  79. package/dist/public/assets/{use-settings-route-KYTTaHV0.js → use-settings-route-BX1P2p9-.js} +1 -1
  80. package/dist/public/assets/{use-terminal-enabled-qjUlZ0f0.js → use-terminal-enabled-BlXFMDFQ.js} +1 -1
  81. package/dist/public/assets/{use-timeline-entry-diff-svkep662.js → use-timeline-entry-diff-BI1BVnmy.js} +1 -1
  82. package/dist/public/assets/{use-workspace-CNU53RmX.js → use-workspace-DcPrrukl.js} +1 -1
  83. package/dist/public/assets/{workspace-paths-DGKkpMQ9.js → workspace-paths-CU85-ZRd.js} +1 -1
  84. package/dist/public/index.html +36 -36
  85. package/dist/public/uninstall.html +2 -2
  86. package/dist/{repair-launch-json-B-4hsfw8.mjs → repair-launch-json-CvIvu8iY.mjs} +2 -2
  87. package/dist/{repair-mcp-configs--yGPDCBl.mjs → repair-mcp-configs-Bm9hjjRi.mjs} +2 -2
  88. package/dist/{repair-skills-CH8FwF78.mjs → repair-skills-BHY_AeM4.mjs} +2 -2
  89. package/dist/repair-skills-CUT1NbJx.mjs +1 -0
  90. package/dist/server-lock-CG809RrD.mjs +1 -0
  91. package/dist/{server-lock-D6rSSnhg.mjs → server-lock-D7crxuP7.mjs} +2 -2
  92. package/dist/{src-CwNOE4ri.mjs → src-D4iCDwsy.mjs} +1 -1
  93. package/dist/{src-y0VSl78g.mjs → src-DPfeLt-2.mjs} +4 -4
  94. package/dist/{src-2StQCkyf.mjs → src-DmtkLnli.mjs} +26 -20
  95. package/dist/src-T1lGYBC1.mjs +3275 -0
  96. package/dist/start-Bc8dmiQL.mjs +1 -0
  97. package/dist/{start-D-Yu2Dgc.mjs → start-CbJoa5l7.mjs} +3 -3
  98. package/dist/{write-project-skill-W6wm8WGO.mjs → write-project-skill-BzhJIXSv.mjs} +3 -3
  99. package/package.json +5 -5
  100. package/dist/constants-7P_R76Oj.mjs +0 -2
  101. package/dist/git-handle-CHFcUjId.mjs +0 -1
  102. package/dist/init-C9mmgvW-.mjs +0 -1
  103. package/dist/loader-D297fMOD.mjs +0 -1
  104. package/dist/md-manager-B9dAVpPF.mjs +0 -2
  105. package/dist/preview-DacomZcF.mjs +0 -1
  106. package/dist/public/assets/FeedbackForm-B34f3kZF.js +0 -1
  107. package/dist/public/assets/PropertyPanel-ANMzlUf0.js +0 -2
  108. package/dist/public/assets/typing-burst-detector-DuRvcTVz.js +0 -8
  109. package/dist/repair-skills-C40390Fl.mjs +0 -1
  110. package/dist/server-lock-RCr-Pegf.mjs +0 -1
  111. package/dist/src-DV_Dbu6a.mjs +0 -3275
  112. package/dist/start-Bc5XMp-q.mjs +0 -1
@@ -112,7 +112,10 @@ ${n}`}}),s}function xp(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants
112
112
  `);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
113
113
 
114
114
  `);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(ui.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[sp({find:Tp,type:this.type,getAttributes:e=>({language:e[1]})}),sp({find:Ep,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Ci({key:new Ei(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
115
- `));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(L.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}});const Op=Dp.extend({priority:60,addAttributes(){return{...this.parent?.(),fenceDelimiter:{default:"`"},fenceLength:{default:3},meta:{default:null},sourceStyle:{default:`fenced`},sourceClosingFenceLength:{default:null,rendered:!1},sourceUnclosedFence:{default:!1,rendered:!1},sourceFenceIndent:{default:null,rendered:!1},sourceInfoPadding:{default:null,rendered:!1},sourceIndents:{default:null,rendered:!1}}}});var kp=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},Ap=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,jp=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Mp=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Np=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Pp=Rf.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return kp(`strong`,{...Od(this.options.HTMLAttributes,e),children:kp(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ap({find:Ap,type:this.type}),ap({find:Mp,type:this.type})]},addPasteRules(){return[Cp({find:jp,type:this.type}),Cp({find:Np,type:this.type})]}}),Fp=Pp,Ip=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Lp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Rp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,zp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Bp=Rf.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,Od(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ap({find:Ip,type:this.type}),ap({find:Rp,type:this.type})]},addPasteRules(){return[Cp({find:Lp,type:this.type}),Cp({find:zp,type:this.type})]}});const Vp=Bp.extend({name:`emphasis`,priority:60,addAttributes(){return{...this.parent?.(),sourceDelimiter:{default:`*`}}},addInputRules(){return[ap({find:Ip,type:this.type,getAttributes:{sourceDelimiter:`*`}}),ap({find:Rp,type:this.type,getAttributes:{sourceDelimiter:`_`}})]}}),Hp=Fp.extend({name:`strong`,priority:60,addAttributes(){return{...this.parent?.(),sourceDelimiter:{default:`**`}}},addInputRules(){return[ap({find:Ap,type:this.type,getAttributes:{sourceDelimiter:`**`}}),ap({find:Mp,type:this.type,getAttributes:{sourceDelimiter:`__`}})]}}),Up=Rf.create({name:`escapeMark`,priority:10,excludes:``,inclusive:!1,parseHTML(){return[{tag:`span[data-escape-mark]`}]},renderHTML(){return[`span`,{"data-escape-mark":``},0]}}),Wp=Sp.create({name:`footnoteDefinition`,group:`block`,content:`block+`,defining:!0,priority:60,addAttributes(){return{identifier:{default:``},label:{default:null}}},parseHTML(){let e=e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-footnote-id`)||``;return{identifier:t,label:t||null}};return[{tag:`aside[data-footnote-def]`,getAttrs:e},{tag:`aside.footnote-def`,getAttrs:e}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.identifier??``);return[`aside`,{...t,"data-footnote-def":``,"data-footnote-id":n,id:`fn-${n}`,class:`footnote-def`},[`div`,{class:`footnote-body`},0],[`a`,{href:`#fnref-${n}`,class:`footnote-backref`,contentEditable:`false`,"aria-label":`Back to reference`},`↩`]]},addCommands(){return{insertFootnoteDefinition:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{identifier:e,label:e},content:[{type:`paragraph`}]})}}}),Gp=Sp.create({name:`footnoteReference`,marks:`_`,group:`inline`,inline:!0,atom:!0,selectable:!0,draggable:!1,priority:60,addAttributes(){return{identifier:{default:``},label:{default:null}}},parseHTML(){return[{tag:`sup[data-footnote-ref]`,getAttrs:e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-footnote-id`)||``;return{identifier:t,label:t||null}}}]},renderHTML({node:e}){let t=String(e.attrs.identifier??``);return[`sup`,{id:`fnref-${t}`,"data-footnote-ref":``,"data-footnote-id":t,class:`footnote-ref`},[`a`,{href:`#fn-${t}`,class:`footnote-ref-link`},`[${t}]`]]},addCommands(){return{insertFootnoteReference:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{identifier:e,label:e}})}}}),Kp=/^---[ \t]*\r?\n([\s\S]*?\r?\n)?---[ \t]*(\r?\n|$)/;function qp(e){let t=e.match(Kp);return t?{frontmatter:t[0],body:e.slice(t[0].length)}:{frontmatter:``,body:e}}function Jp(e,t){return e?e+t:t}function Yp(e){if(e===``)return``;let t=e.match(Kp);return t?(t[1]??``).replace(/\r?\n$/,``):e}var Xp=Sp.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,Od(this.options.HTMLAttributes,e)]},renderText(){return`
115
+ `));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(L.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}});const Op=Dp.extend({priority:60,addAttributes(){return{...this.parent?.(),fenceDelimiter:{default:"`"},fenceLength:{default:3},meta:{default:null},sourceStyle:{default:`fenced`},sourceClosingFenceLength:{default:null,rendered:!1},sourceUnclosedFence:{default:!1,rendered:!1},sourceFenceIndent:{default:null,rendered:!1},sourceInfoPadding:{default:null,rendered:!1},sourceIndents:{default:null,rendered:!1}}}});var kp=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},Ap=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,jp=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Mp=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Np=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Pp=Rf.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return kp(`strong`,{...Od(this.options.HTMLAttributes,e),children:kp(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ap({find:Ap,type:this.type}),ap({find:Mp,type:this.type})]},addPasteRules(){return[Cp({find:jp,type:this.type}),Cp({find:Np,type:this.type})]}}),Fp=Pp,Ip=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Lp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Rp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,zp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Bp=Rf.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,Od(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ap({find:Ip,type:this.type}),ap({find:Rp,type:this.type})]},addPasteRules(){return[Cp({find:Lp,type:this.type}),Cp({find:zp,type:this.type})]}});const Vp=Bp.extend({name:`emphasis`,priority:60,addAttributes(){return{...this.parent?.(),sourceDelimiter:{default:`*`}}},addInputRules(){return[ap({find:Ip,type:this.type,getAttributes:{sourceDelimiter:`*`}}),ap({find:Rp,type:this.type,getAttributes:{sourceDelimiter:`_`}})]}}),Hp=Fp.extend({name:`strong`,priority:60,addAttributes(){return{...this.parent?.(),sourceDelimiter:{default:`**`}}},addInputRules(){return[ap({find:Ap,type:this.type,getAttributes:{sourceDelimiter:`**`}}),ap({find:Mp,type:this.type,getAttributes:{sourceDelimiter:`__`}})]}}),Up=Rf.create({name:`escapeMark`,priority:10,excludes:``,inclusive:!1,parseHTML(){return[{tag:`span[data-escape-mark]`}]},renderHTML(){return[`span`,{"data-escape-mark":``},0]}}),Wp=Sp.create({name:`footnoteDefinition`,group:`block`,content:`block+`,defining:!0,priority:60,addAttributes(){return{identifier:{default:``},label:{default:null}}},parseHTML(){let e=e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-footnote-id`)||``;return{identifier:t,label:t||null}};return[{tag:`aside[data-footnote-def]`,getAttrs:e},{tag:`aside.footnote-def`,getAttrs:e}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.identifier??``);return[`aside`,{...t,"data-footnote-def":``,"data-footnote-id":n,id:`fn-${n}`,class:`footnote-def`},[`div`,{class:`footnote-body`},0],[`a`,{href:`#fnref-${n}`,class:`footnote-backref`,contentEditable:`false`,"aria-label":`Back to reference`},`↩`]]},addCommands(){return{insertFootnoteDefinition:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{identifier:e,label:e},content:[{type:`paragraph`}]})}}}),Gp=Sp.create({name:`footnoteReference`,marks:`_`,group:`inline`,inline:!0,atom:!0,selectable:!0,draggable:!1,priority:60,addAttributes(){return{identifier:{default:``},label:{default:null}}},parseHTML(){return[{tag:`sup[data-footnote-ref]`,getAttrs:e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-footnote-id`)||``;return{identifier:t,label:t||null}}}]},renderHTML({node:e}){let t=String(e.attrs.identifier??``);return[`sup`,{id:`fnref-${t}`,"data-footnote-ref":``,"data-footnote-id":t,class:`footnote-ref`},[`a`,{href:`#fn-${t}`,class:`footnote-ref-link`},`[${t}]`]]},addCommands(){return{insertFootnoteReference:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{identifier:e,label:e}})}}}),Kp=/^---[ \t]*\r?\n([\s\S]*?\r?\n)?---[ \t]*(\r?\n|$)/;function qp(e){let t=e.match(Kp);return t?{frontmatter:t[0],body:e.slice(t[0].length)}:{frontmatter:``,body:e}}function Jp(e,t){return e?t===``||/\r?\n$/.test(e)?e+t:e+(e.includes(`\r
116
+ `)?`\r
117
+ `:`
118
+ `)+t:t}function Yp(e){if(e===``)return``;let t=e.match(Kp);return t?(t[1]??``).replace(/\r?\n$/,``):e}var Xp=Sp.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,Od(this.options.HTMLAttributes,e)]},renderText(){return`
116
119
  `},renderMarkdown:()=>`
117
120
  `,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});const Zp=Xp.extend({marks:`_`,priority:60,addAttributes(){return{...this.parent?.(),hardBreakStyle:{default:`backslash`},sourceRaw:{default:null}}}});var Qp=Sp.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,Od(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>sp({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});const $p=Qp.extend({priority:60,addAttributes(){return{...this.parent?.(),headingStyle:{default:`atx`},sourceTrailingHashes:{default:null},sourceUnderlineLength:{default:null},sourceContiguousNext:{default:!1},sourceLeadingIndent:{default:null,rendered:!1},sourceInteriorSpacing:{default:null,rendered:!1}}}}),em=Sp.create({name:`htmlBlock`,group:`block`,atom:!0,priority:60,addAttributes(){return{content:{default:``}}},parseHTML(){return[{tag:`div[data-html-block]`}]},renderHTML({node:e}){return[`div`,{"data-html-block":``,class:`html-block`},e.attrs.content]}});var tm=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,nm=Sp.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,Od(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);Object.entries(o).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),c.src=o.src;let l=new up({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility=`hidden`,u.style.pointerEvents=`none`,c.onload=()=>{u.style.visibility=``,u.style.pointerEvents=``},l}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[op({find:tm,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function rm(e){if(typeof e!=`string`||!e.startsWith(`/`))return e;let t=globalThis.window?.okDesktop?.config?.apiOrigin;return typeof t==`string`&&t?t+e:e}const im=nm.extend({marks:`_`,priority:60,addAttributes(){return{...this.parent?.(),sourceUrl:{default:null,rendered:!1}}},renderHTML({HTMLAttributes:e}){let t=Od(this.options.HTMLAttributes,e);return typeof t.src==`string`&&(t.src=rm(t.src)),[`img`,t]}}),am=Sp.create({name:`jsxComponent`,group:`block`,atom:!1,content:`block*`,isolating:!0,selectable:!0,defining:!0,priority:60,addAttributes(){return{componentName:{default:``},kind:{default:`element`},attributes:{default:[]},sourceRaw:{default:``},sourceDirty:{default:!1},props:{default:{}}}},parseHTML(){return[{tag:`div[data-jsx-component]`,getAttrs:e=>typeof e==`string`?!1:{componentName:e.getAttribute(`data-component-name`)||``,sourceRaw:e.getAttribute(`data-source-raw`)||``}}]},renderHTML({HTMLAttributes:e}){return[`div`,{"data-jsx-component":``,"data-component-name":e.componentName,"data-source-raw":e.sourceRaw},0]},addCommands(){return{insertJsxComponent:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{sourceRaw:e}})}}}),om=Sp.create({name:`jsxInline`,group:`inline`,inline:!0,atom:!1,content:`text*`,isolating:!1,selectable:!0,priority:60,addAttributes(){return{}},parseHTML(){return[{tag:`span[data-jsx-inline]`}]},renderHTML(){return[`span`,{"data-jsx-inline":``},0]}});var sm=r((e=>{let t=`numeric`,n=`ascii`,r=`alpha`,i=`asciinumeric`,a=`alphanumeric`,o=`domain`,s=`emoji`,c=`whitespace`;function l(e,t){return e in t||(t[e]=[]),t[e]}function u(e,c,u){c[t]&&(c[i]=!0,c[a]=!0),c[n]&&(c[i]=!0,c[r]=!0),c[i]&&(c[a]=!0),c[r]&&(c[a]=!0),c[a]&&(c[o]=!0),c[s]&&(c[o]=!0);for(let t in c){let n=l(t,u);n.indexOf(e)<0&&n.push(e)}}function d(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function f(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}f.groups={},f.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=f.groups;let i;return t&&t.j?i=t:(i=new f(t),n&&r&&u(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=f.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new f,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new f,a&&(r&&(o.t&&typeof o.t==`string`?u(a,Object.assign(d(o.t,r),n),r):n&&u(a,n,r)),o.t=a),i.j[e]=o,o}};let p=(e,t,n,r,i)=>e.ta(t,n,r,i),m=(e,t,n,r,i)=>e.tr(t,n,r,i),h=(e,t,n,r,i)=>e.ts(t,n,r,i),g=(e,t,n,r,i)=>e.tt(t,n,r,i),_=`WORD`,v=`UWORD`,y=`ASCIINUMERICAL`,b=`ALPHANUMERICAL`,x=`LOCALHOST`,S=`UTLD`,C=`SCHEME`,w=`SLASH_SCHEME`,T=`OPENBRACE`,E=`CLOSEBRACE`,D=`OPENBRACKET`,O=`CLOSEBRACKET`,ee=`OPENPAREN`,te=`CLOSEPAREN`,ne=`OPENANGLEBRACKET`,k=`CLOSEANGLEBRACKET`,A=`FULLWIDTHLEFTPAREN`,re=`FULLWIDTHRIGHTPAREN`,ie=`LEFTCORNERBRACKET`,ae=`RIGHTCORNERBRACKET`,j=`LEFTWHITECORNERBRACKET`,oe=`RIGHTWHITECORNERBRACKET`,se=`FULLWIDTHLESSTHAN`,ce=`FULLWIDTHGREATERTHAN`,M=`AMPERSAND`,N=`APOSTROPHE`,le=`ASTERISK`,ue=`BACKSLASH`,de=`BACKTICK`,fe=`CARET`,pe=`COLON`,me=`COMMA`,he=`DOLLAR`,ge=`EQUALS`,_e=`EXCLAMATION`,P=`HYPHEN`,ve=`PERCENT`,ye=`PIPE`,be=`PLUS`,xe=`POUND`,Se=`QUERY`,Ce=`QUOTE`,we=`FULLWIDTHMIDDLEDOT`,Te=`SEMI`,Ee=`SLASH`,De=`TILDE`,Oe=`UNDERSCORE`,ke=`EMOJI`;var Ae=Object.freeze({__proto__:null,ALPHANUMERICAL:b,AMPERSAND:M,APOSTROPHE:N,ASCIINUMERICAL:y,ASTERISK:le,AT:`AT`,BACKSLASH:ue,BACKTICK:de,CARET:fe,CLOSEANGLEBRACKET:k,CLOSEBRACE:E,CLOSEBRACKET:O,CLOSEPAREN:te,COLON:pe,COMMA:me,DOLLAR:he,DOT:`DOT`,EMOJI:ke,EQUALS:ge,EXCLAMATION:_e,FULLWIDTHGREATERTHAN:ce,FULLWIDTHLEFTPAREN:A,FULLWIDTHLESSTHAN:se,FULLWIDTHMIDDLEDOT:we,FULLWIDTHRIGHTPAREN:re,HYPHEN:P,LEFTCORNERBRACKET:ie,LEFTWHITECORNERBRACKET:j,LOCALHOST:x,NL:`NL`,NUM:`NUM`,OPENANGLEBRACKET:ne,OPENBRACE:T,OPENBRACKET:D,OPENPAREN:ee,PERCENT:ve,PIPE:ye,PLUS:be,POUND:xe,QUERY:Se,QUOTE:Ce,RIGHTCORNERBRACKET:ae,RIGHTWHITECORNERBRACKET:oe,SCHEME:C,SEMI:Te,SLASH:Ee,SLASH_SCHEME:w,SYM:`SYM`,TILDE:De,TLD:`TLD`,UNDERSCORE:Oe,UTLD:S,UWORD:v,WORD:_,WS:`WS`});let je=/[a-z]/,Me=/\p{L}/u,Ne=/\p{Emoji}/u,Pe=/\d/,Fe=/\s/,Ie=null,Le=null;function Re(e=[]){let l={};f.groups=l;let d=new f;Ie??=He(`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`),Le??=He(`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`),g(d,`'`,N),g(d,`{`,T),g(d,`}`,E),g(d,`[`,D),g(d,`]`,O),g(d,`(`,ee),g(d,`)`,te),g(d,`<`,ne),g(d,`>`,k),g(d,`(`,A),g(d,`)`,re),g(d,`「`,ie),g(d,`」`,ae),g(d,`『`,j),g(d,`』`,oe),g(d,`<`,se),g(d,`>`,ce),g(d,`&`,M),g(d,`*`,le),g(d,`@`,`AT`),g(d,"`",de),g(d,`^`,fe),g(d,`:`,pe),g(d,`,`,me),g(d,`$`,he),g(d,`.`,`DOT`),g(d,`=`,ge),g(d,`!`,_e),g(d,`-`,P),g(d,`%`,ve),g(d,`|`,ye),g(d,`+`,be),g(d,`#`,xe),g(d,`?`,Se),g(d,`"`,Ce),g(d,`/`,Ee),g(d,`;`,Te),g(d,`~`,De),g(d,`_`,Oe),g(d,`\\`,ue),g(d,`・`,we);let p=m(d,Pe,`NUM`,{[t]:!0});m(p,Pe,p);let Re=m(p,je,y,{[i]:!0}),ze=m(p,Me,b,{[a]:!0}),Be=m(d,je,_,{[n]:!0});m(Be,Pe,Re),m(Be,je,Be),m(Re,Pe,Re),m(Re,je,Re);let Ue=m(d,Me,v,{[r]:!0});m(Ue,je),m(Ue,Pe,ze),m(Ue,Me,Ue),m(ze,Pe,ze),m(ze,je),m(ze,Me,ze);let We=g(d,`
118
121
  `,`NL`,{[c]:!0}),Ge=g(d,`\r`,`WS`,{[c]:!0}),Ke=m(d,Fe,`WS`,{[c]:!0});g(d,``,Ke),g(Ge,`
@@ -290,40 +293,43 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content:
290
293
  `],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])+`
291
294
  `}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 M$=new j$.default;function N$(e,t){if(e===t)return[{value:e}];let{chars1:n,chars2:r,lineArray:i}=M$.diff_linesToChars_(e,t),a=M$.diff_main(n,r,!1);M$.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===j$.default.DIFF_DELETE,i=e===j$.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 P$=256*1024;function F$(e,t,n){if(t===n)return;let r=N$(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 I$(e,t,n){if(t===n)return;if(t.length>P$||n.length>P$){L$(e,t,n);return}let r=N$(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 L$(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(`
292
295
  `,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(`
293
- `,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 R$=y({path:k(b([x(),A()])),message:x(),issueCode:x()});S(`code`,[y({code:v(`SCHEMA_INVALID`),issues:k(R$)}),y({code:v(`WRITE_ERROR`),detail:x()})]);const z$={defaultKeyType:`PLAIN`,defaultStringType:`PLAIN`,lineWidth:0};function B$(e){if(e.trim()===``)return{doc:new ze.Document({}),map:{}};let t;try{t=(0,ze.parseDocument)(e)}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new ze.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=TY.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 V$(e){return Object.keys(e).length===0?``:new ze.Document(e).toString(z$)}function H$(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function U$(e,t,n){if(Array.isArray(n)){let r=e.createNode(n),i=(0,ze.isSeq)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}if(H$(n)){let r=e.createNode(n),i=(0,ze.isMap)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}return n}function W$(e){return e===``?``:`---\n${e.endsWith(`
294
- `)?e.slice(0,-1):e}\n---\n`}function G$(e){let t=e.match(Kp);return t?{fenced:t[0],body:e.slice(t[0].length)}:{fenced:``,body:e}}function K$(e){if(e.trim()===``)return{doc:new ze.Document({}),map:{}};let t;try{t=(0,ze.parseDocument)(e,{uniqueKeys:!1})}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new ze.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=TY.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 q$(e){return e===``?{doc:new ze.Document({}),map:{}}:K$(Yp(e))}function J$(e){let{fenced:t}=G$(e),{map:n}=q$(t);return n??{}}function Y$(e){if(e.contents==null||!(`items`in e.contents)){let t=e.createNode({});return e.contents=t,t}return e.contents}function X$(e){let t=e.contents;return!t||!(`items`in t)||(t.items?.length??0)===0?``:W$(e.toString(z$))}function Z$(e){let t=new TextEncoder().encode(e).byteLength;return t>65536?{kind:`region_too_large`,bytes:t,limit:65536}:null}function Q$(e){let t=X$(e),n=Z$(t);return n?{ok:!1,error:n}:{ok:!0,nextFenced:t}}function $$(e,t){if(Object.hasOwn(t,`frontmatter`))return{ok:!1,error:{kind:`reserved_key`,key:`frontmatter`}};let{doc:n,map:r}=q$(e);if(r===null)return{ok:!1,error:{kind:`parse_failed`,reason:`fm region unparseable`}};try{Y$(n);for(let[e,r]of Object.entries(t)){if(r===null){n.delete(e);continue}let t=CY.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,U$(n,n.get(e,!0),t.data))}return Q$(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 e1(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:fe(e.ytextSnapshot),fragmentHash:fe(e.fragmentMdSnapshot),redacted:!n,timestamp:r};return n?{...i,diff:e.unifiedDiff}:i}var t1=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 n1=/^(?:\r?\n)+/;function r1(e){let{frontmatter:t,body:n}=qp(e),r=n.match(n1);if(!r)return{boundary:``,text:e};let i=n.slice(r[0].length);return t===``&&Kp.test(i)?{boundary:``,text:e}:{boundary:r[0],text:t+i}}function i1(e,t){if(t===``)return e;let{frontmatter:n,body:r}=qp(e);return n+t+r}function a1(e){let t=r1(e).text;return qp(t).frontmatter===``?t:i1(t,`
295
- `)}function o1(e,t=16){let n=e.trim();return n.length<t?!1:!(n.startsWith(`<`)||n.startsWith("```")||n.startsWith(`|`))}function s1(e,t=16){let n=new Map;for(let r of e.split(`
296
- `)){if(!o1(r,t))continue;let e=r.trim();n.set(e,(n.get(e)??0)+1)}return n}function c1(e,t,n=16){let r=s1(t,n),i=[];for(let[t,a]of s1(e,n))a>=2&&a>(r.get(t)??0)&&i.push(t);return i}function l1(e){let t=new Map;for(let n of e.split(`
297
- `))n.trim()!==``&&t.set(n,(t.get(n)??0)+1);return t}function u1(e,t,n){let r=l1(e),i=l1(t),a=l1(n);for(let[e,t]of r)if(t>(i.get(e)??0)&&t>(a.get(e)??0))return!0;return!1}function d1(e,t,n){let r=l1(e),i=l1(t),a=l1(n),o=[];for(let[e,t]of r)t>(i.get(e)??0)&&t>(a.get(e)??0)&&o.push(e);return o}function f1(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 p1(e,t){let n=f1(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 m1(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]})}p1(t,e).forEach(e=>i(e,`a`)),p1(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 h1(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=m1(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 g1=new j$.default;g1.Match_Threshold=.5;function _1(e,t,n){let r=v1(e,t,n);return w1(e,t,n,r),r}function v1(e,t,n){if(e===t)return n;if(e===n||t===n)return t;let r=h1(t.split(`
296
+ `,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 R$=y({path:k(b([x(),A()])),message:x(),issueCode:x()});S(`code`,[y({code:v(`SCHEMA_INVALID`),issues:k(R$)}),y({code:v(`WRITE_ERROR`),detail:x()})]);const z$=/^---[ \t]*\r?\n---[ \t]*(\r?\n|$)/,B$=/^---([ \t]*)(?=\r?\n|$)/,V$=e=>e.includes(`\r
297
+ `)?`\r
298
+ `:`
299
+ `,H$=e=>e.replace(B$,`***$1`),U$=e=>`---${e}${e}---${e}`;function W$(e,t){let n=Jp(e,t);return{md:n,frontmatter:n.slice(0,n.length-t.length)}}function G$(e,t){let{md:n,frontmatter:r}=W$(e,t),i=qp(n);return i.frontmatter===r&&i.body===t}function K$(e,t,n,r){let{md:i,frontmatter:a}=W$(t,n);return{md:i,frontmatter:a,body:n,adjusted:r===`none`&&a!==e?`frontmatter`:r}}function q$(e,t){if(G$(e,t))return K$(e,e,t,`none`);let n=H$(t);if(n!==t&&G$(e,n))return K$(e,e,n,`body`);if(z$.test(e)){let n=U$(V$(e));if(G$(n,t))return K$(e,n,t,`frontmatter`)}return K$(e,e,t,`unresolved`)}function J$(e,t){if(G$(e,t))return K$(e,e,t,`none`);let n=U$(V$(e||t));return(e===``||z$.test(e))&&G$(n,t)?K$(e,n,t,`frontmatter`):K$(e,e,t,`unresolved`)}const Y$={defaultKeyType:`PLAIN`,defaultStringType:`PLAIN`,lineWidth:0};function X$(e){if(e.trim()===``)return{doc:new ze.Document({}),map:{}};let t;try{t=(0,ze.parseDocument)(e)}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new ze.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=TY.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 Z$(e){return Object.keys(e).length===0?``:new ze.Document(e).toString(Y$)}function Q$(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $$(e,t,n){if(Array.isArray(n)){let r=e.createNode(n),i=(0,ze.isSeq)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}if(Q$(n)){let r=e.createNode(n),i=(0,ze.isMap)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}return n}function e1(e){return e===``?``:`---\n${e.endsWith(`
300
+ `)?e.slice(0,-1):e}\n---\n`}function t1(e){let t=e.match(Kp);return t?{fenced:t[0],body:e.slice(t[0].length)}:{fenced:``,body:e}}function n1(e){if(e.trim()===``)return{doc:new ze.Document({}),map:{}};let t;try{t=(0,ze.parseDocument)(e,{uniqueKeys:!1})}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new ze.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=TY.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 r1(e){return e===``?{doc:new ze.Document({}),map:{}}:n1(Yp(e))}function i1(e){let{fenced:t}=t1(e),{map:n}=r1(t);return n??{}}function a1(e){if(e.contents==null||!(`items`in e.contents)){let t=e.createNode({});return e.contents=t,t}return e.contents}function o1(e){let t=e.contents;return!t||!(`items`in t)||(t.items?.length??0)===0?``:e1(e.toString(Y$))}function s1(e){let t=new TextEncoder().encode(e).byteLength;return t>65536?{kind:`region_too_large`,bytes:t,limit:65536}:null}function c1(e){let t=o1(e),n=s1(t);return n?{ok:!1,error:n}:{ok:!0,nextFenced:t}}function l1(e,t){if(Object.hasOwn(t,`frontmatter`))return{ok:!1,error:{kind:`reserved_key`,key:`frontmatter`}};let{doc:n,map:r}=r1(e);if(r===null)return{ok:!1,error:{kind:`parse_failed`,reason:`fm region unparseable`}};try{a1(n);for(let[e,r]of Object.entries(t)){if(r===null){n.delete(e);continue}let t=CY.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,$$(n,n.get(e,!0),t.data))}return c1(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 u1(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:fe(e.ytextSnapshot),fragmentHash:fe(e.fragmentMdSnapshot),redacted:!n,timestamp:r};return n?{...i,diff:e.unifiedDiff}:i}var d1=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 f1=/^(?:\r?\n)+/;function p1(e){let{frontmatter:t,body:n}=qp(e),r=n.match(f1);if(!r)return{boundary:``,text:e};let i=n.slice(r[0].length);return t===``&&Kp.test(i)?{boundary:``,text:e}:{boundary:r[0],text:t+i}}function m1(e,t){if(t===``)return e;let{frontmatter:n,body:r}=qp(e);return n+t+r}function h1(e){let t=p1(e).text;return qp(t).frontmatter===``?t:m1(t,`
301
+ `)}function g1(e,t=16){let n=e.trim();return n.length<t?!1:!(n.startsWith(`<`)||n.startsWith("```")||n.startsWith(`|`))}function _1(e,t=16){let n=new Map;for(let r of e.split(`
302
+ `)){if(!g1(r,t))continue;let e=r.trim();n.set(e,(n.get(e)??0)+1)}return n}function v1(e,t,n=16){let r=_1(t,n),i=[];for(let[t,a]of _1(e,n))a>=2&&a>(r.get(t)??0)&&i.push(t);return i}function y1(e){let t=new Map;for(let n of e.split(`
303
+ `))n.trim()!==``&&t.set(n,(t.get(n)??0)+1);return t}function b1(e,t,n){let r=y1(e),i=y1(t),a=y1(n);for(let[e,t]of r)if(t>(i.get(e)??0)&&t>(a.get(e)??0))return!0;return!1}function x1(e,t,n){let r=y1(e),i=y1(t),a=y1(n),o=[];for(let[e,t]of r)t>(i.get(e)??0)&&t>(a.get(e)??0)&&o.push(e);return o}function S1(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 C1(e,t){let n=S1(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 w1(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]})}C1(t,e).forEach(e=>i(e,`a`)),C1(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 T1(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=w1(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 E1=new j$.default;E1.Match_Threshold=.5;function D1(e,t,n){let r=O1(e,t,n);return P1(e,t,n,r),r}function O1(e,t,n){if(e===t)return n;if(e===n||t===n)return t;let r=T1(t.split(`
298
304
  `),e.split(`
299
305
  `),n.split(`
300
306
  `)),i=[];for(let e=0;e<r.length;e++){let t=r[e];if(`ok`in t&&t.ok)i.push(t.ok.join(`
301
307
  `));else if(`conflict`in t&&t.conflict){let e=t.conflict.o.join(`
302
308
  `),n=t.conflict.a.join(`
303
309
  `),r=t.conflict.b.join(`
304
- `);i.push(E1(e,n,r))}}return i.join(`
305
- `)}function y1(e,t,n){if(e===t)return{clean:!0,merged:n};if(e===n||t===n)return{clean:!0,merged:t};let r=h1(t.split(`
310
+ `);i.push(I1(e,n,r))}}return i.join(`
311
+ `)}function k1(e,t,n){if(e===t)return{clean:!0,merged:n};if(e===n||t===n)return{clean:!0,merged:t};let r=T1(t.split(`
306
312
  `),e.split(`
307
313
  `),n.split(`
308
314
  `)),i=[];for(let e of r)if(`ok`in e&&e.ok)i.push(e.ok.join(`
309
315
  `));else return{clean:!1};let a=i.join(`
310
- `);try{w1(e,t,n,a)}catch{return{clean:!1}}return{clean:!0,merged:a}}function b1(e){return e.map(e=>({len:e.length,digest:fe(e)}))}var x1=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:b1(this.info.lostSubstrings),redacted:!t}}};function S1(e,t){if(e===t)return[];let n=g1.diff_main(e,t);g1.diff_cleanupSemantic(n);let r=[];for(let[e,t]of n)if(e===1)for(let e of t.split(`
311
- `)){let t=e.trim();t.length!==0&&r.push(t)}return r}function C1(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 w1(e,t,n,r){let i=S1(e,t),a=S1(e,n),o=i.filter(e=>!r.includes(e));if(o.length>0)throw new x1({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 x1({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:s,which:`substring`,side:`agent`});let c=C1(r,i);if(c!==null)throw new x1({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[c],which:`order`,side:`user`});let l=C1(r,a);if(l!==null)throw new x1({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[l],which:`order`,side:`agent`});let u=s1(e),d=s1(t),f=s1(n);for(let[i,a]of s1(r))if(!(a<2)&&a>Math.max(u.get(i)??0,d.get(i)??0,f.get(i)??0))throw new x1({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[i],which:`growth`,side:`user`})}function T1(e,t,n){let r=S1(t,e);return r.length===0?[]:r.filter(e=>!n.includes(e))}function E1(e,t,n){if(t===``)return n;if(n===``)return t;let r=g1.patch_make(e,t),[i,a]=g1.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 D1=/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g,O1=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/,k1=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/,A1=/^\d+([.)])(?=\s)/,j1=/\*\*\s*(`[^`]+`)\s*\*\*/g,M1=/^(`{3,}|~{3,})/;function N1(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r].trimEnd(),a=M1.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||!O1.test(i))continue;let o=e[r-1].trimEnd();if(!(!o.startsWith(`|`)||O1.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 P1(e){return e.slice(0,-1).trimEnd()}const F1=/^(?:#{1,6}[ \t]|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function I1(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 L1=/^<\/?[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,R1=/^<[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,z1=/^<\/[A-Z][A-Za-z0-9.]*\s*>$/,B1=/<\/?[A-Z]/;function V1(e){let t=!1;for(let n=0;n<e.length;n++)if(B1.test(e[n]??``)){t=!0;break}if(!t)return e;let n=I1(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&&L1.test(s));let l=c&&z1.test(s),u=c&&!l&&R1.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 H1(e){let t=V1(e.replace(/^/,``).replace(/\r/g,``).replace(D1,`$1`).replace(j1,`$1`).replace(/^\n+/,``).replace(/^[*-]{3,}(?=\n|$)/,`---`).replace(/(\n)([#>+-]|\d+[.)]|`{3,}|~{3,})/g,`
316
+ `);try{P1(e,t,n,a)}catch{return{clean:!1}}return{clean:!0,merged:a}}function A1(e){return e.map(e=>({len:e.length,digest:fe(e)}))}var j1=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:A1(this.info.lostSubstrings),redacted:!t}}};function M1(e,t){if(e===t)return[];let n=E1.diff_main(e,t);E1.diff_cleanupSemantic(n);let r=[];for(let[e,t]of n)if(e===1)for(let e of t.split(`
317
+ `)){let t=e.trim();t.length!==0&&r.push(t)}return r}function N1(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 P1(e,t,n,r){let i=M1(e,t),a=M1(e,n),o=i.filter(e=>!r.includes(e));if(o.length>0)throw new j1({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 j1({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:s,which:`substring`,side:`agent`});let c=N1(r,i);if(c!==null)throw new j1({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[c],which:`order`,side:`user`});let l=N1(r,a);if(l!==null)throw new j1({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[l],which:`order`,side:`agent`});let u=_1(e),d=_1(t),f=_1(n);for(let[i,a]of _1(r))if(!(a<2)&&a>Math.max(u.get(i)??0,d.get(i)??0,f.get(i)??0))throw new j1({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[i],which:`growth`,side:`user`})}function F1(e,t,n){let r=M1(t,e);return r.length===0?[]:r.filter(e=>!n.includes(e))}function I1(e,t,n){if(t===``)return n;if(n===``)return t;let r=E1.patch_make(e,t),[i,a]=E1.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 L1=/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g,R1=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/,z1=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/,B1=/^\d+([.)])(?=\s)/,V1=/\*\*\s*(`[^`]+`)\s*\*\*/g,H1=/^(`{3,}|~{3,})/;function U1(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r].trimEnd(),a=H1.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||!R1.test(i))continue;let o=e[r-1].trimEnd();if(!(!o.startsWith(`|`)||R1.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 W1(e){return e.slice(0,-1).trimEnd()}const G1=/^(?:#{1,6}[ \t]|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function K1(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 q1=/^<\/?[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,J1=/^<[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,Y1=/^<\/[A-Z][A-Za-z0-9.]*\s*>$/,X1=/<\/?[A-Z]/;function Z1(e){let t=!1;for(let n=0;n<e.length;n++)if(X1.test(e[n]??``)){t=!0;break}if(!t)return e;let n=K1(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&&q1.test(s));let l=c&&Y1.test(s),u=c&&!l&&J1.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 Q1(e){let t=Z1(e.replace(/^/,``).replace(/\r/g,``).replace(L1,`$1`).replace(V1,`$1`).replace(/^\n+/,``).replace(/^[*-]{3,}(?=\n|$)/,`---`).replace(/(\n)([#>+-]|\d+[.)]|`{3,}|~{3,})/g,`
312
318
 
313
319
  $2`).replace(/^([#>+-].*|\d+[.)].*|`{3,}.*|~{3,}.*|<\/[A-Z][A-Za-z0-9]*>[ \t]*)\n([^\n])/gm,`$1
314
320
 
315
321
  $2`).split(`
316
- `)),n=N1(t),r=I1(t);return t.map((e,i)=>{let a=e.trimEnd();if(i>0&&!r.has(i)&&/^[ \t]+\S/.test(a)&&(t[i-1]??``).trim()!==``&&!k1.test(a)&&!F1.test(a.trimStart())){let e=(t[i-1]??``).trimStart();if(!F1.test(e)&&!e.startsWith(`|`))return a.replace(/^[ \t]+/,``)}if(O1.test(a)){let e=a.replace(/\s+/g,``);return n.has(i)&&e.length>1&&e.startsWith(`|`)&&e.endsWith(`|`)?P1(e):e}let o=k1.test(a)?a.replace(/^[ \t]+/,``):a;return n.has(i)&&o.length>1&&o.startsWith(`|`)&&o.endsWith(`|`)&&(o=P1(o)),o.replace(A1,`1$1`)}).join(`
322
+ `)),n=U1(t),r=K1(t);return t.map((e,i)=>{let a=e.trimEnd();if(i>0&&!r.has(i)&&/^[ \t]+\S/.test(a)&&(t[i-1]??``).trim()!==``&&!z1.test(a)&&!G1.test(a.trimStart())){let e=(t[i-1]??``).trimStart();if(!G1.test(e)&&!e.startsWith(`|`))return a.replace(/^[ \t]+/,``)}if(R1.test(a)){let e=a.replace(/\s+/g,``);return n.has(i)&&e.length>1&&e.startsWith(`|`)&&e.endsWith(`|`)?W1(e):e}let o=z1.test(a)?a.replace(/^[ \t]+/,``):a;return n.has(i)&&o.length>1&&o.startsWith(`|`)&&o.endsWith(`|`)&&(o=W1(o)),o.replace(B1,`1$1`)}).join(`
317
323
  `).replace(/\n{3,}/g,`
318
324
 
319
- `).replace(/\n+$/,``)}function U1(e){return[...e.replace(/^\n+/,``).replace(/\n+$/,``).matchAll(/\n{2,}/g)].map(e=>e[0].length)}function W1(e,t){let n=U1(e),r=U1(t);return n.length===r.length?r.some((e,t)=>e>(n[t]??0)):!1}function G1(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(`
325
+ `).replace(/\n+$/,``)}function $1(e){return[...e.replace(/^\n+/,``).replace(/\n+$/,``).matchAll(/\n{2,}/g)].map(e=>e[0].length)}function e0(e,t){let n=$1(e),r=$1(t);return n.length===r.length?r.some((e,t)=>e>(n[t]??0)):!1}function t0(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(`
320
326
  `)!==i.startsWith(`
321
327
  `)&&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(`
322
328
  `),w=v.split(`
323
- `),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&L1.test(n),a=n===``&&r!==``&&L1.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(A1,`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(`
329
+ `),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&q1.test(n),a=n===``&&r!==``&&q1.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(B1,`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(`
324
330
  `)!==v.endsWith(`
325
- `)&&n.push(`trailing-newline`),n}const K1=`parse-equivalence`;function q1(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function J1(e){return e.replace(/[ \t]+$/gm,``)}const Y1=/^([ \t]*)\d+([.)])(?=[ \t])/;function X1(e){return e.split(`
326
- `).map(e=>e.replace(Y1,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const Z1=new Set;function Q1(e,t,n){let r=qp(e),i=qp(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 Z1.size<8&&!Z1.has(t)&&(Z1.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return q1(J1(a))===q1(J1(i.body))?EM(X1(r.body),X1(a)):!1}const $1={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},e0={"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 t0(e){return e0[e]}function n0(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 r0=null;function i0(e){r0=e}function a0(e,t,n,r){if(!r0||e.length===0)return;let i=n0(t,n),a=new Date().toISOString();for(let t of e)r0({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:t0(t)})}const o0=1e4,s0=`last-spawn-error.log`,c0=`last-server-exit.json`,l0=`last-server-crash.json`;function u0(e){let{frontmatter:t}=qp(e);if(t===``)return null;let n;try{let e=(0,ze.parseDocument)(Yp(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 d0=/^[a-zA-Z0-9][\w/-]*$/;function f0(e){return e.startsWith(`#`)?e.slice(1):e}function p0(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function m0(e){if(!e||e.trim()===``)return[];let{map:t}=B$(e);if(!t)return[];let n=p0(t.tags),r=[];for(let e of n){let t=f0(e);d0.test(t)&&r.push(t)}return r}const h0=[`.ok`,`local`,`installed-skills.json`],g0=f(Xe),_0=T({hosts:k(x()),scope:g0,scripts:D(),installedAt:g()}),v0=T({schema:v(1),skills:E(x(),_0).default({})});function y0(){return{schema:1,skills:{}}}function b0(e){let t;try{t=JSON.parse(e)}catch{return null}let n=v0.safeParse(t);return n.success?n.data:null}const x0={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`},S0={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},C0=Object.keys(x0);function w0(e){return e!==void 0&&C0.includes(e)?x0[e]:void 0}const T0=Date.now().toString().slice(5);let E0=0;const D0=BigInt(1e3),O0=BigInt(1e6),k0=BigInt(1e9),A0=65535;function j0(e,t){if(t.length<65535)Array.prototype.push.apply(e,t);else{let n=t.length;for(let r=0;r<n;r+=A0)Array.prototype.push.apply(e,t.slice(r,r+A0))}}function M0(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 N0(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function P0(){return typeof process<`u`&&process.release&&process.release.name===`node`}function F0(){return BigInt(Math.floor(performance.now()*1e6))}function I0(e){return typeof e==`number`&&(e=BigInt(e)),e<D0?`${e}ns`:e<O0?`${e/D0}μs`:e<k0?`${e/O0}ms`:`${e/k0}s`}function L0(){return N0()?F0():P0()||typeof process<`u`&&typeof process?.hrtime?.bigint==`function`?process.hrtime.bigint():typeof performance<`u`?F0():BigInt(0)}function R0(){return`${T0}-${E0++}`}function z0(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 B0(e,t){return t[1]===e[1]?e[0]-t[0]:t[1]-e[1]}function V0(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 H0(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 U0(e,t){return H0(e,[t])[t]}const W0={cm:.01,m:1,km:1e3,ft:.3048,yd:.9144,mi:1609.344};function G0(e,t){let n=W0[t];if(n===void 0)throw Error(t2(`INVALID_DISTANCE_SUFFIX`,e).message);return e*n}function K0(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 q0(e){return Array.isArray(e)?e.some(e=>q0(e)):e?.constructor?.name===`AsyncFunction`}const J0=`intersection`in new Set;function Y0(...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(J0)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(J0){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 X0=`union`in new Set;function Z0(e,t){return X0?e?e.union(t):t:e?new Set([...e,...t]):new Set(t)}function Q0(e,t){let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function $0(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 e2={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 - ${C0.join(`
331
+ `)&&n.push(`trailing-newline`),n}const n0=`parse-equivalence`;function r0(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function i0(e){return e.replace(/[ \t]+$/gm,``)}const a0=/^([ \t]*)\d+([.)])(?=[ \t])/;function o0(e){return e.split(`
332
+ `).map(e=>e.replace(a0,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const s0=new Set;function c0(e,t,n){let r=qp(e),i=qp(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 s0.size<8&&!s0.has(t)&&(s0.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return r0(i0(a))===r0(i0(i.body))?EM(o0(r.body),o0(a)):!1}const l0={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},u0={"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 d0(e){return u0[e]}function f0(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 p0=null;function m0(e){p0=e}function h0(e,t,n,r){if(!p0||e.length===0)return;let i=f0(t,n),a=new Date().toISOString();for(let t of e)p0({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:d0(t)})}const g0=1e4,_0=`last-spawn-error.log`,v0=`last-server-exit.json`,y0=`last-server-crash.json`;function b0(e){let{frontmatter:t}=qp(e);if(t===``)return null;let n;try{let e=(0,ze.parseDocument)(Yp(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 x0=/^[a-zA-Z0-9][\w/-]*$/;function S0(e){return e.startsWith(`#`)?e.slice(1):e}function C0(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function w0(e){if(!e||e.trim()===``)return[];let{map:t}=X$(e);if(!t)return[];let n=C0(t.tags),r=[];for(let e of n){let t=S0(e);x0.test(t)&&r.push(t)}return r}const T0=[`.ok`,`local`,`installed-skills.json`],E0=f(Xe),D0=T({hosts:k(x()),scope:E0,scripts:D(),installedAt:g()}),O0=T({schema:v(1),skills:E(x(),D0).default({})});function k0(){return{schema:1,skills:{}}}function A0(e){let t;try{t=JSON.parse(e)}catch{return null}let n=O0.safeParse(t);return n.success?n.data:null}const j0={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`},M0={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},N0=Object.keys(j0);function P0(e){return e!==void 0&&N0.includes(e)?j0[e]:void 0}const F0=Date.now().toString().slice(5);let I0=0;const L0=BigInt(1e3),R0=BigInt(1e6),z0=BigInt(1e9),B0=65535;function V0(e,t){if(t.length<65535)Array.prototype.push.apply(e,t);else{let n=t.length;for(let r=0;r<n;r+=B0)Array.prototype.push.apply(e,t.slice(r,r+B0))}}function H0(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 U0(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function W0(){return typeof process<`u`&&process.release&&process.release.name===`node`}function G0(){return BigInt(Math.floor(performance.now()*1e6))}function K0(e){return typeof e==`number`&&(e=BigInt(e)),e<L0?`${e}ns`:e<R0?`${e/L0}μs`:e<z0?`${e/R0}ms`:`${e/z0}s`}function q0(){return U0()?G0():W0()||typeof process<`u`&&typeof process?.hrtime?.bigint==`function`?process.hrtime.bigint():typeof performance<`u`?G0():BigInt(0)}function J0(){return`${F0}-${I0++}`}function Y0(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 X0(e,t){return t[1]===e[1]?e[0]-t[0]:t[1]-e[1]}function Z0(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 Q0(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 $0(e,t){return Q0(e,[t])[t]}const e2={cm:.01,m:1,km:1e3,ft:.3048,yd:.9144,mi:1609.344};function t2(e,t){let n=e2[t];if(n===void 0)throw Error(d2(`INVALID_DISTANCE_SUFFIX`,e).message);return e*n}function n2(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 r2(e){return Array.isArray(e)?e.some(e=>r2(e)):e?.constructor?.name===`AsyncFunction`}const i2=`intersection`in new Set;function a2(...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(i2)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(i2){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 o2=`union`in new Set;function s2(e,t){return o2?e?e.union(t):t:e?new Set([...e,...t]):new Set(t)}function c2(e,t){let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function l2(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 u2={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 - ${N0.join(`
327
333
  - `)}`,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.
328
334
  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.
329
335
  Please install it before proceeding with creating an answer session.
@@ -331,8 +337,8 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
331
337
  `,PLUGIN_SECURE_PROXY_MISSING_CHAT_MODEL:`Could not find a chat model defined in the secure proxy plugin configuration.
332
338
  Please provide a chat model before proceeding with creating an answer session.
333
339
  Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#plugin-secure-proxy
334
- `,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 t2(e,...t){let n=Error(M0(e2[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function n2(e){return{raw:Number(e),formatted:I0(e)}}function r2(e){if(e.id){if(typeof e.id!=`string`)throw t2(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return R0()}function i2(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(c2(r)){let e=d2(r);if(!Array.isArray(t)||t.length!==e)throw t2(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(l2(r)){if(!Array.isArray(t))return n;let e=u2(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=i2(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}const a2={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},o2={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function s2(e){return e===`geopoint`}function c2(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function l2(e){return typeof e==`string`&&a2[e]}function u2(e){return o2[e]}function d2(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw t2(`INVALID_VECTOR_VALUE`,e);case t<=0:throw t2(`INVALID_VECTOR_SIZE`,e);default:return t}}function f2(){return{idToInternalId:new Map,internalIdToId:[],save:p2,load:m2}}function p2(e){return{internalIdToId:e.internalIdToId}}function m2(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 h2(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?h2(e,t.toString()):t}function g2(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function _2(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function v2(e,t){let n=h2(e.sharedInternalDocumentStore,t);return e.docs[n]}function y2(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=h2(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function b2(e){return e.docs}function x2(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function S2(e,t){let n=h2(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function C2(e){return e.count}function w2(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function T2(e){return{docs:e.docs,count:e.count}}function E2(){return{create:_2,get:v2,getMultiple:y2,getAll:b2,store:x2,remove:S2,count:C2,load:w2,save:T2}}const D2=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function O2(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),t2(`PLUGIN_CRASHED`)}return n}const k2=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],A2=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function j2(e,t,n,r){if(e.some(q0))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function M2(e,t,n){if(e.some(q0))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function N2(e,t,n,r,i){if(e.some(q0))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function P2(e,t,n,r){if(e.some(q0))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function F2(e,t){if(e.some(q0))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var I2=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}},L2=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new I2(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?I2.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new I2(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 I2(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 I2(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}},R2=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 z2(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 B2(e,t,n){let r=z2(e,t,n);return{distance:r,isBounded:r>=0}}var V2=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(z0(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&B2(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(z0(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&&(B2(e,n,r).isBounded&&(i[n]=[]),z0(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}},H2=class e extends V2{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,V2.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},U2=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}},W2=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 U2(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=U2.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)}},G2=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 K2(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 q2=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=J2(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)),Y2(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 J2(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function Y2(e,t,n,r,i){let a=J2(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 X2(e,t,n,r,i){let a=h2(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 Z2(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=h2(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 Q2(e,t,n,r){let i=h2(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 $2(e,t,n){e.tokenOccurrences[t][n]--}function e4(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)){e4(e,t,o,r,n);continue}if(c2(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new q2(d2(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new G2,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new L2(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new H2,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 R2,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new W2,isArray:e};break;default:throw t2(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function t4(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 n4(e,t,n,r,i,a,o,s,c,l,u){if(c2(o))return r4(t,n,a,r,i);let d=t4(e,t,n,i,s,c,l,u);if(!l2(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function r4(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function i4(e,t,n,r,i,a,o,s,c,l){if(c2(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 a4(e,t,n,r,i,a,o,s,c,l){if(!l2(o))return i4(e,t,n,r,i,a,o,s,c,l);let u=u2(o),d=a,f=d.length;for(let a=0;a<f;a++)i4(e,t,n,r,i,d[a],u,s,c,l);return!0}function o4(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=K2(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 s4(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 t2(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw t2(`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];o4(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 c4(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:Y0(...i.map(n=>c4(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=>c4(e,t,n,r)).reduce((e,t)=>Z0(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 Q0(a,c4(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 t2(`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]=Z0(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=G0(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=m4(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]=m4(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]=v4(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw t2(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=Z0(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 t2(`INVALID_FILTER_OPERATION`,e)}a[o]=Z0(a[o],n)}}return Y0(...Object.values(a))}function l4(e){return e.searchableProperties}function u4(e){return e.searchablePropertiesWithTypes}function d4(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:H2.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:R2.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:L2.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:W2.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:G2.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:q2.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function f4(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 p4(){return{create:e4,insert:n4,remove:a4,insertDocumentScoreParameters:X2,insertTokenScoreParameters:Z2,removeDocumentScoreParameters:Q2,removeTokenScoreParameters:$2,calculateResultScores:o4,search:s4,searchByWhereClause:c4,getSearchableProperties:l4,getSearchablePropertiesWithTypes:u4,load:d4,save:f4}}function m4(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 h4(e,t,n=!1){let r=n?W2.vincentyDistance:W2.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 g4(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 _4(e,t){let n=e,r=g4(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=G0(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),h4(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=W2.calculatePolygonCentroid(e);return h4(s,r,n)}return null}function v4(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 y4(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=y4(e,t,s,r,n);j0(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!c2(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 t2(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function b4(e,t,n,r){return r?.enabled===!1?{disabled:!0}:y4(e,t,n,(r||{}).unsortableProperties||[],``)}function x4(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=h2(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&O4(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function S4(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)E4(e,n);e.isSorted=!0}function C4(e,t,n){return t[1].localeCompare(n[1],w0(e))}function w4(e,t){return e[1]-t[1]}function T4(e,t){return t[1]?-1:1}function E4(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=C4.bind(null,e.language);break;case`number`:r=w4.bind(null);break;case`boolean`:r=T4.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 D4(e){let t=Object.keys(e.sorts);for(let n of t)O4(e,n)}function O4(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 k4(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=h2(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function A4(e,t,n){if(!e.enabled)throw t2(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw t2(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return O4(e,r),S4(e),t.sort((t,n)=>{let r=a.docs.get(h2(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(h2(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 j4(e){return e.enabled?e.sortableProperties:[]}function M4(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function N4(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 P4(e){if(!e.enabled)return{enabled:!1};D4(e),S4(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 F4(){return{create:b4,insert:x4,remove:k4,save:P4,load:N4,sortBy:A4,getSortableProperties:j4,getSortablePropertiesWithTypes:M4}}const I4=[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 L4(e){return e<192||e>383?e:I4[e-192]||e}function R4(e){let t=[];for(let n=0;n<e.length;n++)t[n]=L4(e.charCodeAt(n));return String.fromCharCode(...t)}const z4={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`},B4={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},V4=`[aeiouy]`,H4=`[^aeiou][^aeiouy]*`;V4+``;const U4=`^(`+H4+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`;``+H4;const W4=`^(`+H4+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,G4=`^(`+H4+`)?[aeiouy]`;function K4(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(U4),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(G4),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+H4+V4+`[^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(G4),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(U4),t&&r.test(t)&&(e=t+z4[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(U4),t&&r.test(t)&&(e=t+B4[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(W4),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(W4),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(W4),i=RegExp(`^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`),a=RegExp(`^`+H4+V4+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(W4),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function q4(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=R4(t),n&&this.normalizationCache.set(r,t),t)}function J4(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function Y4(e,t,n,r=!0){if(t&&t!==this.language)throw t2(`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=S0[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=J4(a);return this.allowDuplicates?o:Array.from(new Set(o))}function X4(e={}){if(!e.language)e.language=`english`;else if(!C0.includes(e.language))throw t2(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw t2(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=K4;else throw t2(`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 t2(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw t2(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw t2(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:Y4,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:q4,normalizationCache:new Map};return r.tokenize=Y4.bind(r),r.normalizeToken=q4,r}function Z4(e){return{sharedInternalDocumentStore:e,rules:new Map}}function Q4(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 $4(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 e3(e,t){return e.rules.delete(t)}function t3(e,t){return e.rules.get(t)}function n3(e){return Array.from(e.rules.values())}function r3(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 i3(e,t){return e?t.conditions.every(t=>r3(e,t)):!1}function a3(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())i3(t,r)&&n.push(r);return n}function o3(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function s3(e){return{rules:Array.from(e.rules.entries())}}function c3(){return{create:Z4,addRule:Q4,updateRule:$4,removeRule:e3,getRule:t3,getAllRules:n3,getMatchingRules:a3,load:o3,save:s3}}function l3(e){let t={formatElapsedTime:n2,getDocumentIndexId:r2,getDocumentProperties:H0,validateSchema:i2};for(let n of A2){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw t2(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!k2.includes(t)&&!A2.includes(t))throw t2(`UNSUPPORTED_COMPONENT`,t)}function u3({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 t2(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=R0();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:X4(o):X4({language:n??`english`}),r.tokenizer&&n)throw t2(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=f2();s||=p4(),l||=F4(),c||=E2(),u||=c3(),l3(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:d3()};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 D2)g[e]=(g[e]??[]).concat(O2(g,e));let _=g.afterCreate;return _&&F2(_,g),g}function d3(){return`{{VERSION}}`}function f3(e){return e.documentsStore.count(e.data.docs)}function p3(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw t2(`SCHEMA_VALIDATION_FAILURE`,a);return q0(e.beforeInsert)||q0(e.afterInsert)||q0(e.index.beforeInsert)||q0(e.index.insert)||q0(e.index.afterInsert)?g3(e,t,n,r,i):_3(e,t,n,r,i)}const m3=new Set([`enum`,`enum[]`]),h3=new Set([`string`,`number`]);async function g3(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw t2(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=h2(e.internalDocumentIDStore,s);if(r||await j2(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw t2(`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];v3(n,r,e,t)}return await y3(e,s,u,f,l,n,t,i),r||await j2(e.afterInsert,e,s,t),s}function _3(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw t2(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=h2(e.internalDocumentIDStore,s);if(r||j2(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw t2(`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];v3(n,r,e,t)}return b3(e,s,u,f,l,n,t,i),r||j2(e.afterInsert,e,s,t),s}function v3(e,t,n,r){if(!(s2(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(c2(t)&&Array.isArray(r))&&!(l2(t)&&Array.isArray(r))&&!(m3.has(t)&&h3.has(e))&&e!==t)throw t2(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function y3(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 b3(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=h2(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 x3(e,t,n,r,i,a){return q0(e.afterInsertMultiple)||q0(e.beforeInsertMultiple)||q0(e.index.beforeInsert)||q0(e.index.insert)||q0(e.index.afterInsert)?S3(e,t,n,r,i,a):C3(e,t,n,r,i,a)}async function S3(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 p3(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&&$0(e)}}})(),i||await M2(e.afterInsertMultiple,e,t),o}function C3(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=p3(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&&$0(e)}}}return l(),i||M2(e.afterInsertMultiple,e,t),o}function w3(e,t,n,r){return q0(e.index.beforeRemove)||q0(e.index.remove)||q0(e.index.afterRemove)?T3(e,t,n,r):E3(e,t,n,r)}async function T3(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=h2(e.internalDocumentIDStore,t),l=g2(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||await j2(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 j2(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function E3(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=h2(e.internalDocumentIDStore,t),l=g2(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||j2(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||j2(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function D3(e,t,n,r,i){return q0(e.index.beforeRemove)||q0(e.index.remove)||q0(e.index.afterRemove)||q0(e.beforeRemoveMultiple)||q0(e.afterRemoveMultiple)?O3(e,t,n,r,i):k3(e,t,n,r,i)}async function O3(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>g2(e.internalDocumentIDStore,h2(e.internalDocumentIDStore,t)));return i||await M2(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 w3(e,t,r,i)&&a++}catch(e){s(e)}setTimeout(l,0)}setTimeout(l,0)}),i||await M2(e.afterRemoveMultiple,e,o),a}function k3(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>g2(e.internalDocumentIDStore,h2(e.internalDocumentIDStore,t)));i||M2(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)w3(e,t,r,i)&&a++;setTimeout(c,0)}}return c(),i||M2(e.afterRemoveMultiple,e,o),a}function A3(e,t){return e[1]-t[1]}function j3(e,t){return t[1]-e[1]}function M3(e=`desc`){return e.toLowerCase()===`asc`?A3:j3}function N3(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(`.`)?U0(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;P3(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=P3(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:F3(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=F3(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw t2(`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=M3(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function P3(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 F3(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 I3={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},L3=[`string`,`number`,`boolean`];function R3(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 t2(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!L3.includes(a[t]))throw t2(`INVALID_GROUP_BY_PROPERTY`,t,L3.join(`, `),a[t])}let o=t.map(([t])=>g2(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=U0(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=z3(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=V0(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||I3,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 z3(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=z3(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];j0(n,t),i.push(n)}return i}function B3(e,t,n,r){let i=a3(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=h2(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 V3(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 t2(`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=f3(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},K3(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=U3(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${H3(e)}\\b`).test(n)))return!0}return!1})}}else l=s?_4(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 H3(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function U3(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 W3(e,t,n){let r=L0();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=V3(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])=>[h2(e.internalDocumentIDStore,t),n]);else d=d.sort(B0);d=B3(e,e.data.pinning,d,t.term);let f;u||(f=c?i6(e,d,s,o,c):a6(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||K0(p,i)),a&&(p.facets=N3(e,d,t.facets)),t.groupBy&&(p.groups=R3(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(L0()-r),p}async function a(){e.beforeSearch&&await P2(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await N2(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}const G3={k:1.2,b:.75,d:.5};function K3(e){let t=e??{};return t.k=t.k??G3.k,t.b=t.b??G3.b,t.d=t.d??G3.d,t}function q3(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw t2(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw t2(`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?t2(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):t2(`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 J3(e,t,n=`english`){let r=L0();function i(){let i=q3(e,t,n).sort(B0);i=B3(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=N3(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:g2(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=R3(e,i,t.groupBy));let f=L0()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:I0(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await P2(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await N2(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function Y3(e,t,n){let r=Q3(V3(e,t,n)),i=q3(e,t,n),a=t.hybridWeights;return t6(r,i,t.term??``,a)}function X3(e,t,n){let r=L0();function i(){let i=Y3(e,t,n);i=B3(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=N3(e,i,t.facets));let o;t.groupBy&&(o=R3(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=a6(e,i,s,c).filter(Boolean),u=L0(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:I0(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||K0(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await P2(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await N2(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function Z3(e){return e[1]}function Q3(e){let t=Math.max.apply(Math,e.map(Z3));return e.map(([e,n])=>[e,n/t])}function $3(e,t){return e/t}function e6(e,t){return(n,r)=>n*e+r*t}function t6(e,t,n,r){let i=Math.max.apply(Math,e.map(Z3)),a=Math.max.apply(Math,t.map(Z3)),{text:o,vector:s}=r&&r.text&&r.vector?r:n6(n),c=new Map,l=e.length,u=e6(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u($3(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=$3(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function n6(e){return{text:.5,vector:.5}}function r6(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return W3(e,t,n);if(r===`vector`)return J3(e,t);if(r===`hybrid`)return X3(e,t);throw t2(`INVALID_SEARCH_MODE`,r)}function i6(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=U0(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:g2(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function a6(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:g2(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}const o6={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},s6=new WeakMap;function c6(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function l6(e){return e.trim().toLowerCase()}const u6=/\.(?:md|mdx)$/;function d6(e,t){if(t!==`page`)return e;let n=e.replace(u6,``);return n.length>0?n:e}function f6(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function p6(e){let t=f6(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 m6(e){let t=u3({schema:o6});return e.length>0&&x3(t,e),t}function h6(e){let t={documents:e};return s6.set(t,m6(e)),t}function g6(e){let t=s6.get(e);if(t)return t;let n=m6(e.documents);return s6.set(e,n),n}const _6=new WeakSet;function v6(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 y6(e,t){let n=e=>({corpus:h6(t),inserted:0,updated:0,removed:0,rebuilt:!0,rebuildReason:e}),r=s6.get(e);if(!r)return n(`no-index`);if(_6.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?v6(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`);_6.add(e);try{if(a.length>0&&D3(r,a),o.length>0&&x3(r,o),f3(r)!==t.length)throw Error(`Search index count ${f3(r)} diverged from document count ${t.length} after incremental update`)}catch{return n(`mutation-failed`)}let l={documents:t};return s6.set(l,r),{corpus:l,inserted:o.length-s,updated:s,removed:a.length-s,rebuilt:!1}}function b6(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function x6(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function S6(e,t){let n=l6(t);if(!n)return 0;let r=d6(n,e.kind),i=l6(e.title),a=l6(e.name),o=l6(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 C6(e,t){let n=S6(e,t);return n<=0?n:Sy(e.path)?n*.5:n}function w6(e){return e===`file`?-60:0}function T6(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 E6(e,t,n,r){return e+t*20+n+w6(r)}function D6(e,t,n,r,i,a){return e===`relevance`?E6(t,n,r,i):T6(t,n,r,i,a)}function O6(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function k6(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function A6(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 j6(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function M6(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 N6(e,t){return l6(t).length<4?0:+(e===`full_text`)}function P6(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function F6(e){let t=[],n=[],r=[];for(let i of e){let e=P6(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 I6(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=F6(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 L6(e,t,n={}){let r=n.intent??`omnibar`,i=O6(r,n.ranking),a=c6(n.limit),o=new Set(n.scopes??b6(r)),s=e.documents.filter(e=>x6(e,o)),c=l6(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=r6(g6(e),{term:c,properties:j6(r),boost:M6(r),tolerance:N6(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>x6(e.document,o)).map(e=>[e.document.id,e.score])),d=A6(s),f=new Map;for(let e of s)C6(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)x6(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=k6(f.values(),u);return I6([...f.values()].map(t=>{let n=Math.max(0,C6(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:D6(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 I6(z6({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function R6(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function z6(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=k6(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,C6(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?D6(o,t,n,s,e.kind,m):E6(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=R6(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)),_=R6(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 B6=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),V6=globalThis;V6[B6]===void 0&&(V6[B6]=o());const H6=V6[B6],U6=[`.ok`,`skill-state.yml`],W6=[`claude-cowork`,`cli-hosts`],G6=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],K6=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,q6=T({version:x().regex(K6,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(H6,{description:`Recorded skill version for this target.`}),recordedAt:g().register(H6,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:f(G6).register(H6,{description:`Install-source surface that recorded this entry.`}).optional()}),J6=T({enabled:D().register(H6,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:g().register(H6,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),Y6=T({schema:v(1).register(H6,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:T({"claude-cowork":q6.optional(),"cli-hosts":q6.optional()}).register(H6,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:E(x(),J6).register(H6,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function X6(e,t){return e??t.installedOnDisk}function Z6(){return{schema:1,targets:{}}}const Q6=`template`;function $6(e){if(e.trim()===``)return{};let t;try{t=(0,ze.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function e8(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function t8(e){let{frontmatter:t,body:n}=qp(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:Yp(t),markdown:n}}function n8(e){let t=e.split(`
335
- `);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=$6(n.join(`
336
- `))[Q6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
337
- `).replace(/\n+$/,``)}}function r8(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=qp(t);if(n===``)return{identity:{},starterContent:t};let i=Yp(n),a=n8(i);if(a)return{identity:a.identity,starterContent:e8(a.docFrontmatterText,r)};let{frontmatter:o}=qp(r);if(o!==``)return{identity:$6(i),starterContent:r};let s=$6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:e8(i,r)}}function i8(e,t){let{docFrontmatterText:n,markdown:r}=t8(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,ze.stringify)({[Q6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function a8(e){return r8(e).starterContent}const o8=`(agent thread)`;function s8(){let e=!1,t=``,n=0;return r=>{let i=c8(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 c8(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 l8=/^(#{1,6})\s+(.+)$/;function u8(e,t){let n=(e.endsWith(`\r`)?e.slice(0,-1):e).match(l8);if(!n)return null;let r=n[2].trim(),i=rY(r,t);return i?{level:n[1].length,text:r,slug:i}:null}const d8=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],f8={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function p8(e,t=d8){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const m8={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function h8(e){return e?m8[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const g8={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function _8(e){let t=e?.trim();return t?g8[h8(t)]??t:`Agent`}function v8(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 y8=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function b8(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function x8(e){let t=e.trim();return y8.test(t)||t.startsWith(`//`)}function S8(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(x8(n))return{kind:`external`,url:n};let r=v8(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=b8(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function C8(e,t){let n=e.trim();if(!n)return null;if(x8(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=b8(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function w8(e,t){let n=e.trim();if(!n||y8.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 T8(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function E8(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function D8(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function O8(e){return e.split(`/`).filter(e=>e!==``)}function k8(e,t){let n=D8(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function A8(e,t){let n=D8(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:O8(r).length}function j8(e,t){let n=O8(e),r=O8(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function M8(){let e=new Map;function t(t){let n=T8(t);if(n===``)return;let r=E8(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=T8(t),r=E8(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=D8(T8(n)),o=[],s=[];for(let e of i)k8(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=A8(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=A8(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=j8(a,D8(t));for(let r=1;r<e.length;r++){let i=e[r],o=j8(a,D8(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 N8(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 P8(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{c1 as $,xt as $a,QN as $i,_Z as $n,UY as $r,$Q as $t,v0 as A,hy as Aa,TJ as Ai,JZ as An,Ee as Ao,PX as Ar,a$ as At,i0 as B,Mt as Ba,JU as Bi,kZ as Bn,fe as Bo,xX as Br,d$ as Bt,Z6 as C,Wy as Ca,RJ as Ci,rQ as Cn,rt as Co,RX as Cr,h$ as Ct,L6 as D,by as Da,WJ as Di,ZZ as Dn,Be as Do,LX as Dr,vQ as Dt,p6 as E,Sy as Ea,UJ as Ei,eQ as En,ot as Eo,IX as Er,_Q as Et,o0 as F,Yp as Fa,vJ as Fi,wZ as Fn,ge as Fo,vX as Fr,JQ as Ft,G1 as G,Et as Ga,GU as Gi,FZ as Gn,dX as Gr,zQ as Gt,K1 as H,kt as Ha,YU as Hi,MZ as Hn,rX as Hr,UQ as Ht,l0 as I,Rd as Ia,kJ as Ii,TZ as In,he as Io,_X as Ir,KQ as It,T1 as J,wt as Ja,ZH as Ji,RZ as Jn,sX as Jr,AQ as Jt,H1 as K,Dt as Ka,KU as Ki,BZ as Kn,uX as Kr,r$ as Kt,c0 as L,Ei as La,DJ as Li,IZ as Ln,ve as Lo,yX as Lr,qQ as Lt,b0 as M,cy as Ma,wJ as Mi,XZ as Mn,Ce as Mo,kX as Mr,c$ as Mt,m0 as N,Jp as Na,AJ as Ni,EZ as Nn,xe as No,NX as Nr,HQ as Nt,y6 as O,vy as Oa,yJ as Oi,QZ as On,Re as Oo,jX as Or,yQ as Ot,u0 as P,qp as Pa,jJ as Pi,DZ as Pn,_e as Po,DX as Pr,YQ as Pt,d1 as Q,ht as Qa,oR as Qi,yZ as Qn,kY as Qr,QQ as Qt,s0 as R,F as Ra,mJ as Ri,LZ as Rn,P as Ro,hX as Rr,IQ as Rt,Y6 as S,Xy as Sa,FJ as Si,nQ as Sn,ct as So,zX as Sr,g$ as St,h6 as T,Hy as Ta,PJ as Ti,tQ as Tn,tt as To,FX as Tr,f$ as Tt,Q1 as U,At as Ua,cW as Ui,AZ as Un,fX as Ur,WQ as Ut,$1 as V,jt as Va,XU as Vi,CZ as Vn,wX as Vr,ZQ as Vt,W1 as W,Ot as Wa,eW as Wi,PZ as Wn,lX as Wr,RQ as Wt,y1 as X,St as Xa,wV as Xi,oZ as Xn,QY as Xr,t$ as Xt,_1 as Y,Tt as Ya,IV as Yi,zZ as Yn,ZY as Yr,e$ as Yt,u1 as Z,mt as Za,CV as Zi,sZ as Zn,LY as Zr,n$ as Zt,a8 as _,Iy as _a,ZJ as _i,dQ as _n,Qe as _o,YX as _r,S$ as _t,C8 as a,ob as aa,HY as ai,mQ as an,pt as ao,dZ as ar,$$ as at,W6 as b,rb as ba,qJ as bi,sQ as bn,ut as bo,GX as br,v$ as bt,f8 as c,fb as ca,zY as ci,TQ as cn,He as co,cZ as cr,B$ as ct,h8 as d,eb as da,CY as di,kQ as dn,Ue as do,KX as dr,I$ as dt,WM as ea,AY as ei,BQ as en,gt as eo,hZ as er,a1 as et,u8 as f,nb as fa,EY as fi,CQ as fn,Ge as fo,qX as fr,F$ as ft,i8 as g,Ly as ga,tY as gi,uQ as gn,Xe as go,XX as gr,C$ as gt,Q6 as h,jy as ha,yY as hi,NQ as hn,Ye as ho,eZ as hr,y$ as ht,S8 as i,db as ia,OY as ii,gQ as in,vt as io,bZ as ir,e1 as it,y0 as j,fy as ja,gJ as ji,YZ as jn,Se as jo,OX as jr,l$ as jt,h0 as k,_y as ka,bJ as ki,$Z as kn,Te as ko,MX as kr,jQ as kt,p8 as l,ub as la,YY as li,EQ as ln,qe as lo,tZ as lr,V$ as lt,o8 as m,My as ma,vY as mi,SQ as mn,Je as mo,$X as mr,A$ as mt,P8 as n,mb as na,GY as ni,LQ as nn,_t as no,fZ as nr,r1 as nt,w8 as o,hb as oa,DY as oi,DQ as on,ft as oo,lZ as or,G$ as ot,s8 as p,ky as pa,lY as pi,wQ as pn,We as po,JX as pr,T$ as pt,x1 as q,Ct as qa,MU as qi,VZ as qn,cX as qr,i$ as qt,M8 as r,sb as ra,JY as ri,PQ as rn,yt as ro,vZ as rr,t1 as rt,v8 as s,pb as sa,VY as si,xQ as sn,dt as so,uZ as sr,J$ as st,N8 as t,cb as ta,WY as ti,VQ as tn,bt as to,pZ as tr,i1 as tt,_8 as u,$y as ua,XY as ui,OQ as un,Ke as uo,nZ as ur,W$ as ut,r8 as v,zy as va,XJ as vi,fQ as vn,Ve as vo,QX as vr,b$ as vt,X6 as w,Zy as wa,MJ as wi,oQ as wn,$e as wo,HX as wr,m$ as wt,K6 as x,ib as xa,JJ as xi,lQ as xn,at as xo,VX as xr,p$ as xt,U6 as y,Vy as ya,YJ as yi,pQ as yn,Ze as yo,UX as yr,x$ as yt,a0 as z,Nt as za,pJ as zi,OZ as zn,me as zo,mX as zr,XQ as zt};
338
- //# sourceMappingURL=src-2StQCkyf.mjs.map
340
+ `,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 d2(e,...t){let n=Error(H0(u2[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function f2(e){return{raw:Number(e),formatted:K0(e)}}function p2(e){if(e.id){if(typeof e.id!=`string`)throw d2(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return J0()}function m2(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(v2(r)){let e=x2(r);if(!Array.isArray(t)||t.length!==e)throw d2(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(y2(r)){if(!Array.isArray(t))return n;let e=b2(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=m2(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}const h2={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},g2={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function _2(e){return e===`geopoint`}function v2(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function y2(e){return typeof e==`string`&&h2[e]}function b2(e){return g2[e]}function x2(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw d2(`INVALID_VECTOR_VALUE`,e);case t<=0:throw d2(`INVALID_VECTOR_SIZE`,e);default:return t}}function S2(){return{idToInternalId:new Map,internalIdToId:[],save:C2,load:w2}}function C2(e){return{internalIdToId:e.internalIdToId}}function w2(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 T2(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?T2(e,t.toString()):t}function E2(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function D2(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function O2(e,t){let n=T2(e.sharedInternalDocumentStore,t);return e.docs[n]}function k2(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=T2(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function A2(e){return e.docs}function j2(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function M2(e,t){let n=T2(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function N2(e){return e.count}function P2(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function F2(e){return{docs:e.docs,count:e.count}}function I2(){return{create:D2,get:O2,getMultiple:k2,getAll:A2,store:j2,remove:M2,count:N2,load:P2,save:F2}}const L2=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function R2(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),d2(`PLUGIN_CRASHED`)}return n}const z2=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],B2=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function V2(e,t,n,r){if(e.some(r2))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function H2(e,t,n){if(e.some(r2))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function U2(e,t,n,r,i){if(e.some(r2))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function W2(e,t,n,r){if(e.some(r2))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function G2(e,t){if(e.some(r2))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var K2=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}},q2=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new K2(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?K2.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new K2(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 K2(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 K2(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}},J2=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 Y2(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 X2(e,t,n){let r=Y2(e,t,n);return{distance:r,isBounded:r>=0}}var Z2=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(Y0(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&X2(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(Y0(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&&(X2(e,n,r).isBounded&&(i[n]=[]),Y0(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}},Q2=class e extends Z2{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,Z2.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},$2=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}},e4=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 $2(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=$2.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)}},t4=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 n4(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 r4=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=i4(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)),a4(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 i4(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function a4(e,t,n,r,i){let a=i4(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 o4(e,t,n,r,i){let a=T2(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 s4(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=T2(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 c4(e,t,n,r){let i=T2(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 l4(e,t,n){e.tokenOccurrences[t][n]--}function u4(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)){u4(e,t,o,r,n);continue}if(v2(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new r4(x2(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new t4,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new q2(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new Q2,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 J2,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new e4,isArray:e};break;default:throw d2(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function d4(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 f4(e,t,n,r,i,a,o,s,c,l,u){if(v2(o))return p4(t,n,a,r,i);let d=d4(e,t,n,i,s,c,l,u);if(!y2(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function p4(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function m4(e,t,n,r,i,a,o,s,c,l){if(v2(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 h4(e,t,n,r,i,a,o,s,c,l){if(!y2(o))return m4(e,t,n,r,i,a,o,s,c,l);let u=b2(o),d=a,f=d.length;for(let a=0;a<f;a++)m4(e,t,n,r,i,d[a],u,s,c,l);return!0}function g4(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=n4(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 _4(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 d2(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw d2(`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];g4(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 v4(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:a2(...i.map(n=>v4(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=>v4(e,t,n,r)).reduce((e,t)=>s2(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 c2(a,v4(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 d2(`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]=s2(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=t2(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=w4(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]=w4(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]=O4(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw d2(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=s2(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 d2(`INVALID_FILTER_OPERATION`,e)}a[o]=s2(a[o],n)}}return a2(...Object.values(a))}function y4(e){return e.searchableProperties}function b4(e){return e.searchablePropertiesWithTypes}function x4(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:Q2.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:J2.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:q2.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:e4.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:t4.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:r4.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function S4(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 C4(){return{create:u4,insert:f4,remove:h4,insertDocumentScoreParameters:o4,insertTokenScoreParameters:s4,removeDocumentScoreParameters:c4,removeTokenScoreParameters:l4,calculateResultScores:g4,search:_4,searchByWhereClause:v4,getSearchableProperties:y4,getSearchablePropertiesWithTypes:b4,load:x4,save:S4}}function w4(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 T4(e,t,n=!1){let r=n?e4.vincentyDistance:e4.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 E4(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 D4(e,t){let n=e,r=E4(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=t2(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),T4(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=e4.calculatePolygonCentroid(e);return T4(s,r,n)}return null}function O4(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 k4(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=k4(e,t,s,r,n);V0(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!v2(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 d2(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function A4(e,t,n,r){return r?.enabled===!1?{disabled:!0}:k4(e,t,n,(r||{}).unsortableProperties||[],``)}function j4(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=T2(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&R4(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function M4(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)I4(e,n);e.isSorted=!0}function N4(e,t,n){return t[1].localeCompare(n[1],P0(e))}function P4(e,t){return e[1]-t[1]}function F4(e,t){return t[1]?-1:1}function I4(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=N4.bind(null,e.language);break;case`number`:r=P4.bind(null);break;case`boolean`:r=F4.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 L4(e){let t=Object.keys(e.sorts);for(let n of t)R4(e,n)}function R4(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 z4(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=T2(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function B4(e,t,n){if(!e.enabled)throw d2(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw d2(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return R4(e,r),M4(e),t.sort((t,n)=>{let r=a.docs.get(T2(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(T2(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 V4(e){return e.enabled?e.sortableProperties:[]}function H4(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function U4(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 W4(e){if(!e.enabled)return{enabled:!1};L4(e),M4(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 G4(){return{create:A4,insert:j4,remove:z4,save:W4,load:U4,sortBy:B4,getSortableProperties:V4,getSortablePropertiesWithTypes:H4}}const K4=[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 q4(e){return e<192||e>383?e:K4[e-192]||e}function J4(e){let t=[];for(let n=0;n<e.length;n++)t[n]=q4(e.charCodeAt(n));return String.fromCharCode(...t)}const Y4={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`},X4={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},Z4=`[aeiouy]`,Q4=`[^aeiou][^aeiouy]*`;Z4+``;const $4=`^(`+Q4+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`;``+Q4;const e3=`^(`+Q4+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,t3=`^(`+Q4+`)?[aeiouy]`;function n3(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($4),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(t3),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+Q4+Z4+`[^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(t3),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($4),t&&r.test(t)&&(e=t+Y4[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($4),t&&r.test(t)&&(e=t+X4[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(e3),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(e3),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(e3),i=RegExp(`^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`),a=RegExp(`^`+Q4+Z4+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(e3),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function r3(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=J4(t),n&&this.normalizationCache.set(r,t),t)}function i3(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function a3(e,t,n,r=!0){if(t&&t!==this.language)throw d2(`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=M0[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=i3(a);return this.allowDuplicates?o:Array.from(new Set(o))}function o3(e={}){if(!e.language)e.language=`english`;else if(!N0.includes(e.language))throw d2(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw d2(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=n3;else throw d2(`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 d2(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw d2(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw d2(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:a3,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:r3,normalizationCache:new Map};return r.tokenize=a3.bind(r),r.normalizeToken=r3,r}function s3(e){return{sharedInternalDocumentStore:e,rules:new Map}}function c3(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 l3(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 u3(e,t){return e.rules.delete(t)}function d3(e,t){return e.rules.get(t)}function f3(e){return Array.from(e.rules.values())}function p3(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 m3(e,t){return e?t.conditions.every(t=>p3(e,t)):!1}function h3(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())m3(t,r)&&n.push(r);return n}function g3(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function _3(e){return{rules:Array.from(e.rules.entries())}}function v3(){return{create:s3,addRule:c3,updateRule:l3,removeRule:u3,getRule:d3,getAllRules:f3,getMatchingRules:h3,load:g3,save:_3}}function y3(e){let t={formatElapsedTime:f2,getDocumentIndexId:p2,getDocumentProperties:Q0,validateSchema:m2};for(let n of B2){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw d2(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!z2.includes(t)&&!B2.includes(t))throw d2(`UNSUPPORTED_COMPONENT`,t)}function b3({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 d2(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=J0();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:o3(o):o3({language:n??`english`}),r.tokenizer&&n)throw d2(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=S2();s||=C4(),l||=G4(),c||=I2(),u||=v3(),y3(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:x3()};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 L2)g[e]=(g[e]??[]).concat(R2(g,e));let _=g.afterCreate;return _&&G2(_,g),g}function x3(){return`{{VERSION}}`}function S3(e){return e.documentsStore.count(e.data.docs)}function C3(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw d2(`SCHEMA_VALIDATION_FAILURE`,a);return r2(e.beforeInsert)||r2(e.afterInsert)||r2(e.index.beforeInsert)||r2(e.index.insert)||r2(e.index.afterInsert)?E3(e,t,n,r,i):D3(e,t,n,r,i)}const w3=new Set([`enum`,`enum[]`]),T3=new Set([`string`,`number`]);async function E3(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw d2(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=T2(e.internalDocumentIDStore,s);if(r||await V2(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw d2(`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];O3(n,r,e,t)}return await k3(e,s,u,f,l,n,t,i),r||await V2(e.afterInsert,e,s,t),s}function D3(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw d2(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=T2(e.internalDocumentIDStore,s);if(r||V2(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw d2(`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];O3(n,r,e,t)}return A3(e,s,u,f,l,n,t,i),r||V2(e.afterInsert,e,s,t),s}function O3(e,t,n,r){if(!(_2(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(v2(t)&&Array.isArray(r))&&!(y2(t)&&Array.isArray(r))&&!(w3.has(t)&&T3.has(e))&&e!==t)throw d2(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function k3(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 A3(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=T2(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 j3(e,t,n,r,i,a){return r2(e.afterInsertMultiple)||r2(e.beforeInsertMultiple)||r2(e.index.beforeInsert)||r2(e.index.insert)||r2(e.index.afterInsert)?M3(e,t,n,r,i,a):N3(e,t,n,r,i,a)}async function M3(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 C3(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&&l2(e)}}})(),i||await H2(e.afterInsertMultiple,e,t),o}function N3(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=C3(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&&l2(e)}}}return l(),i||H2(e.afterInsertMultiple,e,t),o}function P3(e,t,n,r){return r2(e.index.beforeRemove)||r2(e.index.remove)||r2(e.index.afterRemove)?F3(e,t,n,r):I3(e,t,n,r)}async function F3(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=T2(e.internalDocumentIDStore,t),l=E2(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||await V2(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 V2(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function I3(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=T2(e.internalDocumentIDStore,t),l=E2(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||V2(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||V2(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function L3(e,t,n,r,i){return r2(e.index.beforeRemove)||r2(e.index.remove)||r2(e.index.afterRemove)||r2(e.beforeRemoveMultiple)||r2(e.afterRemoveMultiple)?R3(e,t,n,r,i):z3(e,t,n,r,i)}async function R3(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>E2(e.internalDocumentIDStore,T2(e.internalDocumentIDStore,t)));return i||await H2(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 P3(e,t,r,i)&&a++}catch(e){s(e)}setTimeout(l,0)}setTimeout(l,0)}),i||await H2(e.afterRemoveMultiple,e,o),a}function z3(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>E2(e.internalDocumentIDStore,T2(e.internalDocumentIDStore,t)));i||H2(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)P3(e,t,r,i)&&a++;setTimeout(c,0)}}return c(),i||H2(e.afterRemoveMultiple,e,o),a}function B3(e,t){return e[1]-t[1]}function V3(e,t){return t[1]-e[1]}function H3(e=`desc`){return e.toLowerCase()===`asc`?B3:V3}function U3(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(`.`)?$0(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;W3(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=W3(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:G3(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=G3(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw d2(`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=H3(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function W3(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 G3(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 K3={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},q3=[`string`,`number`,`boolean`];function J3(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 d2(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!q3.includes(a[t]))throw d2(`INVALID_GROUP_BY_PROPERTY`,t,q3.join(`, `),a[t])}let o=t.map(([t])=>E2(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=$0(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=Y3(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=Z0(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||K3,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 Y3(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=Y3(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];V0(n,t),i.push(n)}return i}function X3(e,t,n,r){let i=h3(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=T2(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 Z3(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 d2(`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=S3(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},n6(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=$3(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${Q3(e)}\\b`).test(n)))return!0}return!1})}}else l=s?D4(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 Q3(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function $3(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 e6(e,t,n){let r=q0();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=Z3(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])=>[T2(e.internalDocumentIDStore,t),n]);else d=d.sort(X0);d=X3(e,e.data.pinning,d,t.term);let f;u||(f=c?m6(e,d,s,o,c):h6(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||n2(p,i)),a&&(p.facets=U3(e,d,t.facets)),t.groupBy&&(p.groups=J3(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(q0()-r),p}async function a(){e.beforeSearch&&await W2(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await U2(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}const t6={k:1.2,b:.75,d:.5};function n6(e){let t=e??{};return t.k=t.k??t6.k,t.b=t.b??t6.b,t.d=t.d??t6.d,t}function r6(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw d2(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw d2(`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?d2(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):d2(`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 i6(e,t,n=`english`){let r=q0();function i(){let i=r6(e,t,n).sort(X0);i=X3(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=U3(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:E2(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=J3(e,i,t.groupBy));let f=q0()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:K0(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await W2(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await U2(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function a6(e,t,n){let r=c6(Z3(e,t,n)),i=r6(e,t,n),a=t.hybridWeights;return d6(r,i,t.term??``,a)}function o6(e,t,n){let r=q0();function i(){let i=a6(e,t,n);i=X3(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=U3(e,i,t.facets));let o;t.groupBy&&(o=J3(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=h6(e,i,s,c).filter(Boolean),u=q0(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:K0(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||n2(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await W2(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await U2(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function s6(e){return e[1]}function c6(e){let t=Math.max.apply(Math,e.map(s6));return e.map(([e,n])=>[e,n/t])}function l6(e,t){return e/t}function u6(e,t){return(n,r)=>n*e+r*t}function d6(e,t,n,r){let i=Math.max.apply(Math,e.map(s6)),a=Math.max.apply(Math,t.map(s6)),{text:o,vector:s}=r&&r.text&&r.vector?r:f6(n),c=new Map,l=e.length,u=u6(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(l6(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=l6(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function f6(e){return{text:.5,vector:.5}}function p6(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return e6(e,t,n);if(r===`vector`)return i6(e,t);if(r===`hybrid`)return o6(e,t);throw d2(`INVALID_SEARCH_MODE`,r)}function m6(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=$0(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:E2(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function h6(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:E2(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}const g6={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},_6=new WeakMap;function v6(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function y6(e){return e.trim().toLowerCase()}const b6=/\.(?:md|mdx)$/;function x6(e,t){if(t!==`page`)return e;let n=e.replace(b6,``);return n.length>0?n:e}function S6(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function C6(e){let t=S6(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 w6(e){let t=b3({schema:g6});return e.length>0&&j3(t,e),t}function T6(e){let t={documents:e};return _6.set(t,w6(e)),t}function E6(e){let t=_6.get(e);if(t)return t;let n=w6(e.documents);return _6.set(e,n),n}const D6=new WeakSet;function O6(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 k6(e,t){let n=e=>({corpus:T6(t),inserted:0,updated:0,removed:0,rebuilt:!0,rebuildReason:e}),r=_6.get(e);if(!r)return n(`no-index`);if(D6.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?O6(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`);D6.add(e);try{if(a.length>0&&L3(r,a),o.length>0&&j3(r,o),S3(r)!==t.length)throw Error(`Search index count ${S3(r)} diverged from document count ${t.length} after incremental update`)}catch{return n(`mutation-failed`)}let l={documents:t};return _6.set(l,r),{corpus:l,inserted:o.length-s,updated:s,removed:a.length-s,rebuilt:!1}}function A6(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function j6(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function M6(e,t){let n=y6(t);if(!n)return 0;let r=x6(n,e.kind),i=y6(e.title),a=y6(e.name),o=y6(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 N6(e,t){let n=M6(e,t);return n<=0?n:Sy(e.path)?n*.5:n}function P6(e){return e===`file`?-60:0}function F6(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 I6(e,t,n,r){return e+t*20+n+P6(r)}function L6(e,t,n,r,i,a){return e===`relevance`?I6(t,n,r,i):F6(t,n,r,i,a)}function R6(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function z6(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function B6(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function V6(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function H6(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 U6(e,t){return y6(t).length<4?0:+(e===`full_text`)}function W6(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function G6(e){let t=[],n=[],r=[];for(let i of e){let e=W6(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function K6(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=G6(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 q6(e,t,n={}){let r=n.intent??`omnibar`,i=R6(r,n.ranking),a=v6(n.limit),o=new Set(n.scopes??A6(r)),s=e.documents.filter(e=>j6(e,o)),c=y6(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=p6(E6(e),{term:c,properties:V6(r),boost:H6(r),tolerance:U6(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>j6(e.document,o)).map(e=>[e.document.id,e.score])),d=B6(s),f=new Map;for(let e of s)N6(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)j6(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=z6(f.values(),u);return K6([...f.values()].map(t=>{let n=Math.max(0,N6(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:L6(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 K6(Y6({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function J6(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function Y6(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=z6(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,N6(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?L6(o,t,n,s,e.kind,m):I6(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=J6(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)),_=J6(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 X6=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),Z6=globalThis;Z6[X6]===void 0&&(Z6[X6]=o());const Q6=Z6[X6],$6=[`.ok`,`skill-state.yml`],e8=[`claude-cowork`,`cli-hosts`],t8=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],n8=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,r8=T({version:x().regex(n8,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(Q6,{description:`Recorded skill version for this target.`}),recordedAt:g().register(Q6,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:f(t8).register(Q6,{description:`Install-source surface that recorded this entry.`}).optional()}),i8=T({enabled:D().register(Q6,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:g().register(Q6,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),a8=T({schema:v(1).register(Q6,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:T({"claude-cowork":r8.optional(),"cli-hosts":r8.optional()}).register(Q6,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:E(x(),i8).register(Q6,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function o8(e,t){return e??t.installedOnDisk}function s8(){return{schema:1,targets:{}}}const c8=`template`;function l8(e){if(e.trim()===``)return{};let t;try{t=(0,ze.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function u8(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function d8(e){let{frontmatter:t,body:n}=qp(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:Yp(t),markdown:n}}function f8(e){let t=e.split(`
341
+ `);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=l8(n.join(`
342
+ `))[c8];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
343
+ `).replace(/\n+$/,``)}}function p8(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=qp(t);if(n===``)return{identity:{},starterContent:t};let i=Yp(n),a=f8(i);if(a)return{identity:a.identity,starterContent:u8(a.docFrontmatterText,r)};let{frontmatter:o}=qp(r);if(o!==``)return{identity:l8(i),starterContent:r};let s=l8(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:u8(i,r)}}function m8(e,t){let{docFrontmatterText:n,markdown:r}=d8(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,ze.stringify)({[c8]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function h8(e){return p8(e).starterContent}const g8=`(agent thread)`;function _8(){let e=!1,t=``,n=0;return r=>{let i=v8(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 v8(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 y8=/^(#{1,6})\s+(.+)$/;function b8(e,t){let n=(e.endsWith(`\r`)?e.slice(0,-1):e).match(y8);if(!n)return null;let r=n[2].trim(),i=rY(r,t);return i?{level:n[1].length,text:r,slug:i}:null}const x8=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],S8={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function C8(e,t=x8){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const w8={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function T8(e){return e?w8[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const E8={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function D8(e){let t=e?.trim();return t?E8[T8(t)]??t:`Agent`}function O8(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const k8=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function A8(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function j8(e){let t=e.trim();return k8.test(t)||t.startsWith(`//`)}function M8(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(j8(n))return{kind:`external`,url:n};let r=O8(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=A8(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function N8(e,t){let n=e.trim();if(!n)return null;if(j8(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=A8(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function P8(e,t){let n=e.trim();if(!n||k8.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 F8(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function I8(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function L8(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function R8(e){return e.split(`/`).filter(e=>e!==``)}function z8(e,t){let n=L8(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function B8(e,t){let n=L8(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:R8(r).length}function V8(e,t){let n=R8(e),r=R8(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function H8(){let e=new Map;function t(t){let n=F8(t);if(n===``)return;let r=I8(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=F8(t),r=I8(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=L8(F8(n)),o=[],s=[];for(let e of i)z8(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=B8(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=B8(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=V8(a,L8(t));for(let r=1;r<e.length;r++){let i=e[r],o=V8(a,L8(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 U8(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 W8(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{v1 as $,mt as $a,CV as $i,sZ as $n,LY as $r,n$ as $t,O0 as A,vy as Aa,yJ as Ai,QZ as An,Re as Ao,jX as Ar,yQ as At,m0 as B,F as Ba,mJ as Bi,LZ as Bn,P as Bo,hX as Br,IQ as Bt,s8 as C,ib as Ca,JJ as Ci,lQ as Cn,at as Co,VX as Cr,p$ as Ct,q6 as D,Hy as Da,PJ as Di,tQ as Dn,tt as Do,FX as Dr,f$ as Dt,C6 as E,Zy as Ea,MJ as Ei,oQ as En,$e as Eo,HX as Er,m$ as Et,g0 as F,Jp as Fa,AJ as Fi,EZ as Fn,xe as Fo,NX as Fr,HQ as Ft,t0 as G,At as Ga,cW as Gi,AZ as Gn,fX as Gr,WQ as Gt,n0 as H,Mt as Ha,JU as Hi,kZ as Hn,fe as Ho,xX as Hr,d$ as Ht,y0 as I,qp as Ia,jJ as Ii,DZ as In,_e as Io,DX as Ir,YQ as It,F1 as J,Dt as Ja,KU as Ji,BZ as Jn,uX as Jr,r$ as Jt,Q1 as K,Ot as Ka,eW as Ki,PZ as Kn,lX as Kr,RQ as Kt,v0 as L,Yp as La,vJ as Li,wZ as Ln,ge as Lo,vX as Lr,JQ as Lt,A0 as M,hy as Ma,TJ as Mi,JZ as Mn,Ee as Mo,PX as Mr,a$ as Mt,w0 as N,fy as Na,gJ as Ni,YZ as Nn,Se as No,OX as Nr,l$ as Nt,k6 as O,Sy as Oa,UJ as Oi,eQ as On,ot as Oo,IX as Or,_Q as Ot,b0 as P,cy as Pa,wJ as Pi,XZ as Pn,Ce as Po,kX as Pr,c$ as Pt,x1 as Q,St as Qa,wV as Qi,oZ as Qn,QY as Qr,t$ as Qt,_0 as R,Rd as Ra,kJ as Ri,TZ as Rn,he as Ro,_X as Rr,KQ as Rt,a8 as S,rb as Sa,qJ as Si,sQ as Sn,ut as So,GX as Sr,v$ as St,T6 as T,Wy as Ta,RJ as Ti,rQ as Tn,rt as To,RX as Tr,h$ as Tt,c0 as U,jt as Ua,XU as Ui,CZ as Un,wX as Ur,ZQ as Ut,l0 as V,Nt as Va,pJ as Vi,OZ as Vn,me as Vo,mX as Vr,XQ as Vt,e0 as W,kt as Wa,YU as Wi,MZ as Wn,rX as Wr,UQ as Wt,k1 as X,wt as Xa,ZH as Xi,RZ as Xn,sX as Xr,AQ as Xt,D1 as Y,Ct as Ya,MU as Yi,VZ as Yn,cX as Yr,i$ as Yt,b1 as Z,Tt as Za,IV as Zi,zZ as Zn,ZY as Zr,e$ as Zt,h8 as _,jy as _a,yY as _i,NQ as _n,Ye as _o,eZ as _r,y$ as _t,N8 as a,sb as aa,JY as ai,PQ as an,yt as ao,vZ as ar,l1 as at,e8 as b,zy as ba,XJ as bi,fQ as bn,Ve as bo,QX as br,b$ as bt,S8 as c,hb as ca,DY as ci,DQ as cn,ft as co,lZ as cr,X$ as ct,T8 as d,ub as da,YY as di,EQ as dn,qe as do,tZ as dr,q$ as dt,oR as ea,kY as ei,QQ as en,ht as eo,yZ as er,h1 as et,b8 as f,$y as fa,XY as fi,OQ as fn,Ke as fo,nZ as fr,J$ as ft,m8 as g,My as ga,vY as gi,SQ as gn,Je as go,$X as gr,A$ as gt,c8 as h,ky as ha,lY as hi,wQ as hn,We as ho,JX as hr,T$ as ht,M8 as i,mb as ia,GY as ii,LQ as in,_t as io,fZ as ir,u1 as it,k0 as j,_y as ja,bJ as ji,$Z as jn,Te as jo,MX as jr,jQ as jt,T0 as k,by as ka,WJ as ki,ZZ as kn,Be as ko,LX as kr,vQ as kt,C8 as l,pb as la,VY as li,xQ as ln,dt as lo,uZ as lr,Z$ as lt,g8 as m,nb as ma,EY as mi,CQ as mn,Ge as mo,qX as mr,F$ as mt,W8 as n,WM as na,AY as ni,BQ as nn,gt as no,hZ as nr,p1 as nt,P8 as o,db as oa,OY as oi,gQ as on,vt as oo,bZ as or,t1 as ot,_8 as p,eb as pa,CY as pi,kQ as pn,Ue as po,KX as pr,I$ as pt,j1 as q,Et as qa,GU as qi,FZ as qn,dX as qr,zQ as qt,H8 as r,cb as ra,WY as ri,VQ as rn,bt as ro,pZ as rr,d1 as rt,O8 as s,ob as sa,HY as si,mQ as sn,pt as so,dZ as sr,i1 as st,U8 as t,QN as ta,UY as ti,$Q as tn,xt as to,_Z as tr,m1 as tt,D8 as u,fb as ua,zY as ui,TQ as un,He as uo,cZ as ur,e1 as ut,p8 as v,Ly as va,tY as vi,uQ as vn,Xe as vo,XX as vr,C$ as vt,o8 as w,Xy as wa,FJ as wi,nQ as wn,ct as wo,zX as wr,g$ as wt,n8 as x,Vy as xa,YJ as xi,pQ as xn,Ze as xo,UX as xr,x$ as xt,$6 as y,Iy as ya,ZJ as yi,dQ as yn,Qe as yo,YX as yr,S$ as yt,h0 as z,Ei as za,DJ as zi,IZ as zn,ve as zo,yX as zr,qQ as zt};
344
+ //# sourceMappingURL=src-DmtkLnli.mjs.map