@inkeep/open-knowledge 0.66.1 → 0.66.2

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 (132) hide show
  1. package/dist/{acp-harness-probe-Bk3Dz297.mjs → acp-harness-probe-C-bmwKC0.mjs} +2 -2
  2. package/dist/cli.mjs +6 -6
  3. package/dist/constants-m3Xu5_Pm.mjs +2 -0
  4. package/dist/{git-handle-C9RPCwJN.mjs → git-handle-CehgIzoK.mjs} +2 -2
  5. package/dist/git-handle-DEJ8aYeH.mjs +1 -0
  6. package/dist/index.mjs +2 -2
  7. package/dist/init-CkmKaAE9.mjs +1 -0
  8. package/dist/{init-DNQN84w4.mjs → init-DwE-82L_.mjs} +3 -3
  9. package/dist/{launch-json-removal-CsfA7Q9t.mjs → launch-json-removal-C5njpRMR.mjs} +2 -2
  10. package/dist/{loader-DOE8T0bD.mjs → loader-Da9QChC_.mjs} +2 -2
  11. package/dist/loader-Dt_OoEGe.mjs +1 -0
  12. package/dist/md-manager-BZCd3Vha.mjs +2 -0
  13. package/dist/{open-browser-Bzfc84xQ.mjs → open-browser-DIMVmm0o.mjs} +2 -2
  14. package/dist/parse-worker.mjs +1 -1
  15. package/dist/{preview-Doha4cmP.mjs → preview-BBdR6vmw.mjs} +2 -2
  16. package/dist/preview-oAaqMEbf.mjs +1 -0
  17. package/dist/public/assets/{ActivityModeContent-xON2KhOz.js → ActivityModeContent-B37XJHxx.js} +1 -1
  18. package/dist/public/assets/{AddPropertiesButton-CC1Bimpt.js → AddPropertiesButton-eMa8eBGf.js} +1 -1
  19. package/dist/public/assets/{AgentDiffPane-BPGzdN_g.js → AgentDiffPane-DHlBPg3c.js} +1 -1
  20. package/dist/public/assets/{AgentThreadClientBinder-Sg80UfOQ.js → AgentThreadClientBinder-lpLw9XDN.js} +1 -1
  21. package/dist/public/assets/{BugReportHistory-BOcChnxP.js → BugReportHistory-CuN8iDlA.js} +1 -1
  22. package/dist/public/assets/{BugReportHistoryDialog-BgcEcCCO.js → BugReportHistoryDialog-DGj_pTZf.js} +1 -1
  23. package/dist/public/assets/{CodeMirrorPropInput-Dp0ghtC3.js → CodeMirrorPropInput-Be4UuxHJ.js} +1 -1
  24. package/dist/public/assets/{ConsentDialogBody-DQlUb8Vu.js → ConsentDialogBody-XPmv8PGk.js} +1 -1
  25. package/dist/public/assets/{DocumentContext-Ak51fAXi.js → DocumentContext-CZ1LyjXH.js} +1 -1
  26. package/dist/public/assets/{EditorModeToggle-DpkS50Z0.js → EditorModeToggle-jAYPDv4d.js} +1 -1
  27. package/dist/public/assets/{EnableSyncConfirmDialog-DyPeGiVT.js → EnableSyncConfirmDialog-DGwynRzU.js} +1 -1
  28. package/dist/public/assets/{ExcalidrawDocEditor-BKndnS9g.js → ExcalidrawDocEditor-BWNQPfhq.js} +1 -1
  29. package/dist/public/assets/FeedbackForm-BAO3lafp.js +1 -0
  30. package/dist/public/assets/{GraphPanel-BdWJsnt-.js → GraphPanel-DDKxNmOr.js} +1 -1
  31. package/dist/public/assets/{ImportSkillDialog-C5f6Lj0b.js → ImportSkillDialog-D_3ApyBv.js} +1 -1
  32. package/dist/public/assets/{LintConfigEditor-C21DnP0H.js → LintConfigEditor-B3Gj07cI.js} +1 -1
  33. package/dist/public/assets/ManagedArtifactProperties-CV1Prpoj.js +1 -0
  34. package/dist/public/assets/{ManagedArtifactProperties-Dd9YEu9g.js → ManagedArtifactProperties-DeYta-00.js} +1 -1
  35. package/dist/public/assets/{MermaidDocEditor-CftOutDD.js → MermaidDocEditor-CiHzMRN9.js} +1 -1
  36. package/dist/public/assets/{PropertyDisplayRow-B3tLCY9W.js → PropertyDisplayRow-sm9qwuBw.js} +1 -1
  37. package/dist/public/assets/{ReportBugDialogBody-DRDozPGc.js → ReportBugDialogBody-DZA9GXnC.js} +1 -1
  38. package/dist/public/assets/{ReportBugMenuTrigger-Sbn4B06b.js → ReportBugMenuTrigger-D4qlc7zz.js} +2 -2
  39. package/dist/public/assets/{SchemaConfigEditor-DXhpWbEp.js → SchemaConfigEditor-D17w4XxC.js} +1 -1
  40. package/dist/public/assets/{SessionsHost-CGbrz5ge.js → SessionsHost-Cl-gIFYH.js} +2 -2
  41. package/dist/public/assets/{SettingsDialogBody-GRqpQyOX.js → SettingsDialogBody-Cqc-yl4k.js} +1 -1
  42. package/dist/public/assets/{ShareBranchSwitchDialog-DgKD1FWp.js → ShareBranchSwitchDialog-Ct4sBRfQ.js} +1 -1
  43. package/dist/public/assets/{ShareReceiveDialog-BsGWPO5t.js → ShareReceiveDialog-B92aqQEx.js} +1 -1
  44. package/dist/public/assets/{ShareReceiveMissDialog-DX4YDzpC.js → ShareReceiveMissDialog-C9VJyG_D.js} +1 -1
  45. package/dist/public/assets/{SkillCostValue-B4D7Ysdc.js → SkillCostValue-DLUxO68c.js} +1 -1
  46. package/dist/public/assets/{SkillEditBanner-BruoXTh-.js → SkillEditBanner-b0gL75iO.js} +1 -1
  47. package/dist/public/assets/{SkillInstallMenu-QBcuRLjh.js → SkillInstallMenu-BwbbztKY.js} +1 -1
  48. package/dist/public/assets/{SkillOriginInline-Dshp1Rdi.js → SkillOriginInline-DpPKdpar.js} +1 -1
  49. package/dist/public/assets/{SkillToolbarControls-BCXxl3_M.js → SkillToolbarControls-Bap6lIv8.js} +1 -1
  50. package/dist/public/assets/{SlidesToolbarControls-CJxgVynH.js → SlidesToolbarControls-BNqlGZ8e.js} +1 -1
  51. package/dist/public/assets/{SourceEditor-D9_q6g5_.js → SourceEditor-RCKX4Ohe.js} +1 -1
  52. package/dist/public/assets/{TerminalPanel-Lt1-XHX1.js → TerminalPanel-Zo-UDi-u.js} +1 -1
  53. package/dist/public/assets/{TerminalWindowApp-VUZguLdJ.js → TerminalWindowApp-DjRpidld.js} +1 -1
  54. package/dist/public/assets/{TextDocEditor-Cb7BPpJA.js → TextDocEditor--IKVxg88.js} +1 -1
  55. package/dist/public/assets/{ThreadView-Bf53-ggV.js → ThreadView-CUArcRSL.js} +1 -1
  56. package/dist/public/assets/{TimelineDiffPane-B1HLCcW9.js → TimelineDiffPane-D8HcBg2n.js} +1 -1
  57. package/dist/public/assets/{agent-diff-store-XWhp_hqN.js → agent-diff-store-DgFkR0kV.js} +1 -1
  58. package/dist/public/assets/{auth-state-cache-D22yWCCz.js → auth-state-cache-DNrEadrI.js} +1 -1
  59. package/dist/public/assets/{bug-report-send-manager-BBNXam8A.js → bug-report-send-manager-5nrn8Psu.js} +1 -1
  60. package/dist/public/assets/{client-version-B_H8duw7.js → client-version-DewpIoVp.js} +1 -1
  61. package/dist/public/assets/{comment-chips-D0prCEAx.js → comment-chips-mYvhrkxj.js} +1 -1
  62. package/dist/public/assets/{config-provider-D-Y4Wg0x.js → config-provider-DWieljqa.js} +1 -1
  63. package/dist/public/assets/{dist-D1GzYuCD.js → dist-As2x8uCt.js} +1 -1
  64. package/dist/public/assets/{doc-paths-ByyIE836.js → doc-paths-BkNaaTOB.js} +1 -1
  65. package/dist/public/assets/{documents-events-DPqTvBXn.js → documents-events-2g_OBjKU.js} +1 -1
  66. package/dist/public/assets/{file-tree-adapter-Ccbih42A.js → file-tree-adapter-Q4uvZiQM.js} +1 -1
  67. package/dist/public/assets/{file-tree-utils-Jz2v-e9t.js → file-tree-utils-Cy2QEG_5.js} +1 -1
  68. package/dist/public/assets/{folder-config-api-BddKQIga.js → folder-config-api-DhiWnWlS.js} +1 -1
  69. package/dist/public/assets/i18n-CpxzRV_v.js +1 -0
  70. package/dist/public/assets/{index-nJnxhQRq.js → index-DrzqbmWI.js} +7 -7
  71. package/dist/public/assets/{launcher-selection-CUAKUPGW.js → launcher-selection-DTBWt8s2.js} +1 -1
  72. package/dist/public/assets/{lint-config-client-DeGP10La.js → lint-config-client-CQNYXMfG.js} +1 -1
  73. package/dist/public/assets/{markdownlint-rule-browser-Bir8KkrK.js → markdownlint-rule-browser-BTovNATK.js} +1 -1
  74. package/dist/public/assets/{page-list-cache-D2OX_WDU.js → page-list-cache-AR7XhC2q.js} +1 -1
  75. package/dist/public/assets/{pending-receive-nav-store-sErL2uzl.js → pending-receive-nav-store-DXWRYoc_.js} +1 -1
  76. package/dist/public/assets/{progress-DfDRMpm4.js → progress-YLRB2n7w.js} +1 -1
  77. package/dist/public/assets/{project-paths-DX_YsFET.js → project-paths-BmMTa57i.js} +1 -1
  78. package/dist/public/assets/{prop-types-NHOECtyl.js → prop-types-CTZ-Zcfm.js} +1 -1
  79. package/dist/public/assets/{receive-store-6Dih24L8.js → receive-store-RexqPtVU.js} +1 -1
  80. package/dist/public/assets/{selection-context-C95IJZrT.js → selection-context-BcWEVrAI.js} +1 -1
  81. package/dist/public/assets/{skill-scope-4RF9DbEf.js → skill-scope-CauFSzAn.js} +1 -1
  82. package/dist/public/assets/{skills-api-D5W0J2dk.js → skills-api-KE9J-94z.js} +1 -1
  83. package/dist/public/assets/{src-qGi8ucyG.js → src-B5LNuYlK.js} +1 -1
  84. package/dist/public/assets/{startup-marks-Bvho0uc6.js → startup-marks-CUyZjhyC.js} +1 -1
  85. package/dist/public/assets/{tag-pill-input-CtA1wFQO.js → tag-pill-input-CcAyDLGe.js} +1 -1
  86. package/dist/public/assets/{target-navigation-intent-BFUFQkcA.js → target-navigation-intent-D6pgYTG-.js} +1 -1
  87. package/dist/public/assets/{telemetry-startup-C_zn8gFF.js → telemetry-startup-BFCbpnFp.js} +1 -1
  88. package/dist/public/assets/{terminal-cli-display-ZGFW9kw3.js → terminal-cli-display-C2L3vHWw.js} +1 -1
  89. package/dist/public/assets/{typing-burst-detector-B0lg7vla.js → typing-burst-detector-BO09cycJ.js} +1 -1
  90. package/dist/public/assets/{uninstall-BkDWS7iv.js → uninstall-DJhzaTa1.js} +1 -1
  91. package/dist/public/assets/{use-activity-panel-CuqTH-mx.js → use-activity-panel-BCJavN8T.js} +1 -1
  92. package/dist/public/assets/{use-apply-config-color-theme-Ba8Smkdy.js → use-apply-config-color-theme-CwClEWrd.js} +1 -1
  93. package/dist/public/assets/{use-collab-url-DFpuF-wX.js → use-collab-url-DHOOSaDb.js} +1 -1
  94. package/dist/public/assets/{use-live-xterm-theme-c1fyCaal.js → use-live-xterm-theme-_zomIp7z.js} +1 -1
  95. package/dist/public/assets/{use-open-skill-DJmjKHgr.js → use-open-skill-DzG96lKz.js} +1 -1
  96. package/dist/public/assets/{use-settings-route-BQW0aTo0.js → use-settings-route-Dq3eM_ye.js} +1 -1
  97. package/dist/public/assets/{use-skill-origin-WyyVjfzt.js → use-skill-origin-uUY8unvE.js} +1 -1
  98. package/dist/public/assets/{use-skills-BOMFaoLg.js → use-skills-RpG-BeVz.js} +1 -1
  99. package/dist/public/assets/{use-terminal-enabled-T9hbZCmo.js → use-terminal-enabled-DIQ4qqYj.js} +1 -1
  100. package/dist/public/assets/{use-timeline-entry-diff-Blkn7mx5.js → use-timeline-entry-diff-_fLA4Pt0.js} +1 -1
  101. package/dist/public/assets/{use-workspace-BeSzHXgL.js → use-workspace-DRylP9vX.js} +1 -1
  102. package/dist/public/index.html +47 -47
  103. package/dist/public/uninstall.html +3 -3
  104. package/dist/{repair-launch-json-AsKV5LiF.mjs → repair-launch-json-DO_3ABvq.mjs} +2 -2
  105. package/dist/{repair-mcp-configs-BYASBYNt.mjs → repair-mcp-configs-Bmw9_91L.mjs} +2 -2
  106. package/dist/{repair-skills-AGXJVKE-.mjs → repair-skills-BftHPTbX.mjs} +2 -2
  107. package/dist/repair-skills-CPy4iDny.mjs +1 -0
  108. package/dist/{resolve-project-root-XrNPFGNY.mjs → resolve-project-root-BCdGoKNz.mjs} +2 -2
  109. package/dist/{server-lock-DaOXwt6C.mjs → server-lock-CBDjdfxH.mjs} +2 -2
  110. package/dist/server-lock-xg5Njzvf.mjs +1 -0
  111. package/dist/{skill-teardown-BEnDXQv2.mjs → skill-teardown-Bxy5NV-V.mjs} +2 -2
  112. package/dist/src-B13TeG7U.mjs +1 -0
  113. package/dist/{src-BUfAkcnU.mjs → src-CP2xsmg5.mjs} +2 -2
  114. package/dist/{src-Gpb82U0M.mjs → src-D4A03H49.mjs} +2 -2
  115. package/dist/{src-D79M3x9g.mjs → src-DXJo3hyx.mjs} +1 -1
  116. package/dist/{src-Dyk9iCzv.mjs → src-HFlqeGnA.mjs} +4 -4
  117. package/dist/{start-hZ8_kSuC.mjs → start-7t3OZSc5.mjs} +3 -3
  118. package/dist/start-C1hXUjiR.mjs +1 -0
  119. package/package.json +4 -4
  120. package/dist/constants-DXEhJ197.mjs +0 -2
  121. package/dist/git-handle-pDdbSsMj.mjs +0 -1
  122. package/dist/init-D9KKXAfB.mjs +0 -1
  123. package/dist/loader-hcc6a20d.mjs +0 -1
  124. package/dist/md-manager-BUn7RZOJ.mjs +0 -2
  125. package/dist/preview-CHdEIdwL.mjs +0 -1
  126. package/dist/public/assets/FeedbackForm-BNeQXmJD.js +0 -1
  127. package/dist/public/assets/ManagedArtifactProperties-AGHZbLhh.js +0 -1
  128. package/dist/public/assets/i18n-BFtoQNCd.js +0 -1
  129. package/dist/repair-skills-DUxV_xLI.mjs +0 -1
  130. package/dist/server-lock-VtTnds5h.mjs +0 -1
  131. package/dist/src-s7hpfSip.mjs +0 -1
  132. package/dist/start-ky9sRyOI.mjs +0 -1
@@ -396,7 +396,7 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
396
396
  `,PLUGIN_SECURE_PROXY_MISSING_CHAT_MODEL:`Could not find a chat model defined in the secure proxy plugin configuration.
397
397
  Please provide a chat model before proceeding with creating an answer session.
398
398
  Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#plugin-secure-proxy
399
- `,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 AG(e,...t){let n=Error(sG(kG[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function jG(e){return{raw:Number(e),formatted:dG(e)}}function MG(e){if(e.id){if(typeof e.id!=`string`)throw AG(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return pG()}function NG(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(LG(r)){let e=BG(r);if(!Array.isArray(t)||t.length!==e)throw AG(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(RG(r)){if(!Array.isArray(t))return n;let e=zG(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=NG(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}var PG={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},FG={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function IG(e){return e===`geopoint`}function LG(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function RG(e){return typeof e==`string`&&PG[e]}function zG(e){return FG[e]}function BG(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw AG(`INVALID_VECTOR_VALUE`,e);case t<=0:throw AG(`INVALID_VECTOR_SIZE`,e);default:return t}}function VG(){return{idToInternalId:new Map,internalIdToId:[],save:HG,load:UG}}function HG(e){return{internalIdToId:e.internalIdToId}}function UG(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 WG(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?WG(e,t.toString()):t}function GG(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function KG(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function qG(e,t){let n=WG(e.sharedInternalDocumentStore,t);return e.docs[n]}function JG(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=WG(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function YG(e){return e.docs}function XG(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function ZG(e,t){let n=WG(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function QG(e){return e.count}function $G(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function eK(e){return{docs:e.docs,count:e.count}}function tK(){return{create:KG,get:qG,getMultiple:JG,getAll:YG,store:XG,remove:ZG,count:QG,load:$G,save:eK}}var nK=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function rK(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),AG(`PLUGIN_CRASHED`)}return n}var iK=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],aK=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function oK(e,t,n,r){if(e.some(SG))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function sK(e,t,n){if(e.some(SG))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function cK(e,t,n,r,i){if(e.some(SG))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function lK(e,t,n,r){if(e.some(SG))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function uK(e,t){if(e.some(SG))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var dK=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}},fK=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new dK(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?dK.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new dK(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 dK(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 dK(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}},pK=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 mK(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 hK(e,t,n){let r=mK(e,t,n);return{distance:r,isBounded:r>=0}}var gK=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(mG(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&hK(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(mG(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&&(hK(e,n,r).isBounded&&(i[n]=[]),mG(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}},_K=class e extends gK{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,gK.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},vK=2,yK=6371e3,bK=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}},xK=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 bK(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%vK===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=bK.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 yK*(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)}},SK=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 CK(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 wK=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=TK(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)),EK(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 TK(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function EK(e,t,n,r,i){let a=TK(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 DK(e,t,n,r,i){let a=WG(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 OK(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=WG(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 kK(e,t,n,r){let i=WG(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 AK(e,t,n){e.tokenOccurrences[t][n]--}function jK(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)){jK(e,t,o,r,n);continue}if(LG(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new wK(BG(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new SK,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new fK(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new _K,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 pK,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new xK,isArray:e};break;default:throw AG(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function MK(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 NK(e,t,n,r,i,a,o,s,c,l,u){if(LG(o))return PK(t,n,a,r,i);let d=MK(e,t,n,i,s,c,l,u);if(!RG(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function PK(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function FK(e,t,n,r,i,a,o,s,c,l){if(LG(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 IK(e,t,n,r,i,a,o,s,c,l){if(!RG(o))return FK(e,t,n,r,i,a,o,s,c,l);let u=zG(o),d=a,f=d.length;for(let a=0;a<f;a++)FK(e,t,n,r,i,d[a],u,s,c,l);return!0}function LK(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=CK(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 RK(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 AG(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw AG(`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];LK(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 zK(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:wG(...i.map(n=>zK(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=>zK(e,t,n,r)).reduce((e,t)=>EG(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 DG(a,zK(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 AG(`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]=EG(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=bG(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=GK(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]=GK(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]=YK(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw AG(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=EG(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 AG(`INVALID_FILTER_OPERATION`,e)}a[o]=EG(a[o],n)}}return wG(...Object.values(a))}function BK(e){return e.searchableProperties}function VK(e){return e.searchablePropertiesWithTypes}function HK(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:_K.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:pK.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:fK.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:xK.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:SK.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:wK.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function UK(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 WK(){return{create:jK,insert:NK,remove:IK,insertDocumentScoreParameters:DK,insertTokenScoreParameters:OK,removeDocumentScoreParameters:kK,removeTokenScoreParameters:AK,calculateResultScores:LK,search:RK,searchByWhereClause:zK,getSearchableProperties:BK,getSearchablePropertiesWithTypes:VK,load:HK,save:UK}}function GK(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 KK(e,t,n=!1){let r=n?xK.vincentyDistance:xK.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 qK(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 JK(e,t){let n=e,r=qK(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=bG(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),KK(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=xK.calculatePolygonCentroid(e);return KK(s,r,n)}return null}function YK(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 XK(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=XK(e,t,s,r,n);oG(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!LG(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 AG(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function ZK(e,t,n,r){return r?.enabled===!1?{disabled:!0}:XK(e,t,n,(r||{}).unsortableProperties||[],``)}function QK(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=WG(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&aq(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function $K(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)rq(e,n);e.isSorted=!0}function eq(e,t,n){return t[1].localeCompare(n[1],$W(e))}function tq(e,t){return e[1]-t[1]}function nq(e,t){return t[1]?-1:1}function rq(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=eq.bind(null,e.language);break;case`number`:r=tq.bind(null);break;case`boolean`:r=nq.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 iq(e){let t=Object.keys(e.sorts);for(let n of t)aq(e,n)}function aq(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 oq(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=WG(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function sq(e,t,n){if(!e.enabled)throw AG(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw AG(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return aq(e,r),$K(e),t.sort((t,n)=>{let r=a.docs.get(WG(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(WG(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 cq(e){return e.enabled?e.sortableProperties:[]}function lq(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function uq(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 dq(e){if(!e.enabled)return{enabled:!1};iq(e),$K(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 fq(){return{create:ZK,insert:QK,remove:oq,save:dq,load:uq,sortBy:sq,getSortableProperties:cq,getSortablePropertiesWithTypes:lq}}var pq=192,mq=383,hq=[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 gq(e){return e<pq||e>mq?e:hq[e-pq]||e}function _q(e){let t=[];for(let n=0;n<e.length;n++)t[n]=gq(e.charCodeAt(n));return String.fromCharCode(...t)}var vq={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`},yq={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},bq=`[^aeiou]`,xq=`[aeiouy]`,Sq=bq+`[^aeiouy]*`;xq+``;var Cq=`^(`+Sq+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,wq=`^(`+Sq+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`,Tq=`^(`+Sq+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,Eq=`^(`+Sq+`)?[aeiouy]`;function Dq(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(Cq),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(Eq),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+Sq+xq+`[^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(Eq),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(Cq),t&&r.test(t)&&(e=t+vq[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(Cq),t&&r.test(t)&&(e=t+yq[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(Tq),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(Tq),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(Tq),i=new RegExp(wq),a=RegExp(`^`+Sq+xq+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(Tq),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function Oq(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=_q(t),n&&this.normalizationCache.set(r,t),t)}function kq(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function Aq(e,t,n,r=!0){if(t&&t!==this.language)throw AG(`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=ZW[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=kq(a);return this.allowDuplicates?o:Array.from(new Set(o))}function jq(e={}){if(!e.language)e.language=`english`;else if(!QW.includes(e.language))throw AG(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw AG(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=Dq;else throw AG(`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 AG(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw AG(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw AG(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:Aq,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:Oq,normalizationCache:new Map};return r.tokenize=Aq.bind(r),r.normalizeToken=Oq,r}function Mq(e){return{sharedInternalDocumentStore:e,rules:new Map}}function Nq(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 Pq(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 Fq(e,t){return e.rules.delete(t)}function Iq(e,t){return e.rules.get(t)}function Lq(e){return Array.from(e.rules.values())}function Rq(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 zq(e,t){return e?t.conditions.every(t=>Rq(e,t)):!1}function Bq(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())zq(t,r)&&n.push(r);return n}function Vq(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function Hq(e){return{rules:Array.from(e.rules.entries())}}function Uq(){return{create:Mq,addRule:Nq,updateRule:Pq,removeRule:Fq,getRule:Iq,getAllRules:Lq,getMatchingRules:Bq,load:Vq,save:Hq}}function Wq(e){let t={formatElapsedTime:jG,getDocumentIndexId:MG,getDocumentProperties:_G,validateSchema:NG};for(let n of aK){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw AG(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!iK.includes(t)&&!aK.includes(t))throw AG(`UNSUPPORTED_COMPONENT`,t)}function Gq({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 AG(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=pG();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:jq(o):jq({language:n??`english`}),r.tokenizer&&n)throw AG(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=VG();s||=WK(),l||=fq(),c||=tK(),u||=Uq(),Wq(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:Kq()};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 nK)g[e]=(g[e]??[]).concat(rK(g,e));let _=g.afterCreate;return _&&uK(_,g),g}function Kq(){return`{{VERSION}}`}function qq(e){return e.documentsStore.count(e.data.docs)}function Jq(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw AG(`SCHEMA_VALIDATION_FAILURE`,a);return SG(e.beforeInsert)||SG(e.afterInsert)||SG(e.index.beforeInsert)||SG(e.index.insert)||SG(e.index.afterInsert)?Zq(e,t,n,r,i):Qq(e,t,n,r,i)}var Yq=new Set([`enum`,`enum[]`]),Xq=new Set([`string`,`number`]);async function Zq(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw AG(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=WG(e.internalDocumentIDStore,s);if(r||await oK(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw AG(`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];$q(n,r,e,t)}return await eJ(e,s,u,f,l,n,t,i),r||await oK(e.afterInsert,e,s,t),s}function Qq(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw AG(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=WG(e.internalDocumentIDStore,s);if(r||oK(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw AG(`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];$q(n,r,e,t)}return tJ(e,s,u,f,l,n,t,i),r||oK(e.afterInsert,e,s,t),s}function $q(e,t,n,r){if(!(IG(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(LG(t)&&Array.isArray(r))&&!(RG(t)&&Array.isArray(r))&&!(Yq.has(t)&&Xq.has(e))&&e!==t)throw AG(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function eJ(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 tJ(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=WG(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 nJ(e,t,n,r,i,a){return SG(e.afterInsertMultiple)||SG(e.beforeInsertMultiple)||SG(e.index.beforeInsert)||SG(e.index.insert)||SG(e.index.afterInsert)?rJ(e,t,n,r,i,a):iJ(e,t,n,r,i,a)}async function rJ(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 Jq(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&&OG(e)}}})(),i||await sK(e.afterInsertMultiple,e,t),o}function iJ(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=Jq(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&&OG(e)}}}return l(),i||sK(e.afterInsertMultiple,e,t),o}function aJ(e,t){return e[1]-t[1]}function oJ(e,t){return t[1]-e[1]}function sJ(e=`desc`){return e.toLowerCase()===`asc`?aJ:oJ}function cJ(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(`.`)?vG(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;lJ(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=lJ(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:uJ(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=uJ(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw AG(`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=sJ(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function lJ(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 uJ(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))}}var dJ={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},fJ=[`string`,`number`,`boolean`];function pJ(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 AG(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!fJ.includes(a[t]))throw AG(`INVALID_GROUP_BY_PROPERTY`,t,fJ.join(`, `),a[t])}let o=t.map(([t])=>GG(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=vG(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=mJ(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=gG(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||dJ,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 mJ(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=mJ(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];oG(n,t),i.push(n)}return i}function hJ(e,t,n,r){let i=Bq(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=WG(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 gJ(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 AG(`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=qq(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},xJ(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=vJ(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${_J(e)}\\b`).test(n)))return!0}return!1})}}else l=s?JK(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 _J(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function vJ(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 yJ(e,t,n){let r=fG();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=gJ(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])=>[WG(e.internalDocumentIDStore,t),n]);else d=d.sort(hG);d=hJ(e,e.data.pinning,d,t.term);let f;u||(f=c?NJ(e,d,s,o,c):PJ(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||xG(p,i)),a&&(p.facets=cJ(e,d,t.facets)),t.groupBy&&(p.groups=pJ(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(fG()-r),p}async function a(){e.beforeSearch&&await lK(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await cK(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}var bJ={k:1.2,b:.75,d:.5};function xJ(e){let t=e??{};return t.k=t.k??bJ.k,t.b=t.b??bJ.b,t.d=t.d??bJ.d,t}function SJ(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw AG(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw AG(`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?AG(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):AG(`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 CJ(e,t,n=`english`){let r=fG();function i(){let i=SJ(e,t,n).sort(hG);i=hJ(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=cJ(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:GG(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=pJ(e,i,t.groupBy));let f=fG()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:dG(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await lK(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await cK(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function wJ(e,t,n){let r=DJ(gJ(e,t,n)),i=SJ(e,t,n),a=t.hybridWeights;return AJ(r,i,t.term??``,a)}function TJ(e,t,n){let r=fG();function i(){let i=wJ(e,t,n);i=hJ(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=cJ(e,i,t.facets));let o;t.groupBy&&(o=pJ(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=PJ(e,i,s,c).filter(Boolean),u=fG(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:dG(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||xG(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await lK(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await cK(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function EJ(e){return e[1]}function DJ(e){let t=Math.max.apply(Math,e.map(EJ));return e.map(([e,n])=>[e,n/t])}function OJ(e,t){return e/t}function kJ(e,t){return(n,r)=>n*e+r*t}function AJ(e,t,n,r){let i=Math.max.apply(Math,e.map(EJ)),a=Math.max.apply(Math,t.map(EJ)),{text:o,vector:s}=r&&r.text&&r.vector?r:jJ(n),c=new Map,l=e.length,u=kJ(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(OJ(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=OJ(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function jJ(e){return{text:.5,vector:.5}}function MJ(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return yJ(e,t,n);if(r===`vector`)return CJ(e,t);if(r===`hybrid`)return TJ(e,t);throw AG(`INVALID_SEARCH_MODE`,r)}function NJ(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=vG(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:GG(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function PJ(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:GG(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}var FJ=r(YW(),1),IJ=/[\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF]/g;function LJ(e){return e.replace(IJ,``)}function RJ(e){return e.replace(/[\u0000-\u001F\u007F]/g,` `)}function zJ(e,t){if(e.length<=t)return e;let n=e.slice(0,t),r=n.charCodeAt(n.length-1);return r>=55296&&r<=56319?n.slice(0,-1):n}var BJ=R({at:N(),transport:N(),outcome:N(),reference:N().optional(),error:N().optional(),errorCode:N().optional()}),VJ=R({reason:N(),at:N(),errorCode:N().optional()});R({version:P().int().catch(1),id:N(),createdAt:N(),bundleLevel:N(),zipBytes:P().int().nonnegative().catch(0),zipDeleted:F().optional(),state:N(),systemWide:F().optional(),projectSlug:N().nullable().optional(),reference:N().optional(),lastError:VJ.optional(),attempts:I(BJ).optional(),note:N().optional()}),R({version:P().int().catch(1),id:N().optional(),sentAt:N().optional(),reference:N().optional()});var HJ=`0.0.0-unknown`,UJ={protocol:`x-ok-client-protocol`,runtime:`x-ok-client-runtime`,kind:`x-ok-client-kind`};function WJ({kind:e,runtimeVersion:t}){return{[UJ.protocol]:`2`,[UJ.runtime]:t,[UJ.kind]:e}}function GJ({kind:e,runtimeVersion:t}){return{clientProtocolVersion:2,clientRuntimeVersion:t,clientKind:e}}var KJ=`extra/screenshot.png`,qJ=[{name:`github-pat`,regex:/\b(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9]{36,}\b/g,replacement:`[REDACTED-GH-PAT]`},{name:`aws-access-key`,regex:/\b(AKIA|ASIA|ABIA)[A-Z2-7]{16}\b/g,replacement:`[REDACTED-AWS-KEY]`},{name:`anthropic-key`,regex:/\bsk-ant-api03-[A-Za-z0-9_-]{20,}\b/g,replacement:`[REDACTED-ANTHROPIC]`},{name:`openai-key`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g,replacement:`[REDACTED-OPENAI]`},{name:`bearer-token`,regex:/([Aa]uthorization:\s*[Bb]earer\s+)(?:\\"[^\s"\\]+\\"|"[A-Za-z0-9\-._~+/=]+"|[^\s"\\]+)/g,replacement:`$1[REDACTED]`},{name:`jwt`,regex:/eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,replacement:`[REDACTED-JWT]`},{name:`url-credentials`,regex:/:\/\/[^/\s:@"]+:[^/\s:@"]+@/g,replacement:`://[REDACTED]@`},{name:`github-pat-fine-grained`,regex:/\bgithub_pat_[0-9A-Za-z_]{20,}/g,replacement:`[REDACTED-GH-PAT]`},{name:`openai-key-modern`,regex:/\bsk-(?:proj|svcacct|admin|None)-[A-Za-z0-9_-]{20,}/g,replacement:`[REDACTED-OPENAI]`},{name:`slack-token`,regex:/\bxox[a-z]-[A-Za-z0-9-]{10,}/g,replacement:`[REDACTED-SLACK]`},{name:`google-api-key`,regex:/\bAIza[0-9A-Za-z_-]{35}/g,replacement:`[REDACTED-GOOGLE]`},{name:`stripe-secret-key`,regex:/\b(?:sk|rk)_live_[0-9A-Za-z]{16,}\b/g,replacement:`[REDACTED-STRIPE]`},{name:`gitlab-pat`,regex:/\bglpat-[0-9A-Za-z_-]{20,}/g,replacement:`[REDACTED-GITLAB]`},{name:`bearer-token-json`,regex:/("[Aa]uthorization"\s*:\s*"[Bb]earer\s+)(?:\\"[^"\\]+\\"|[^"\\]+)/g,replacement:`$1[REDACTED]`},{name:`macos-home-path`,regex:/\/Users\/[^/"]+\//g,replacement:`~/`},{name:`linux-home-path`,regex:/\/home\/[^/"]+\//g,replacement:`~/`}];qJ.map(e=>e.name);function JJ(e){let t=new Set,n=0;return{redacted:e.split(`
399
+ `,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 AG(e,...t){let n=Error(sG(kG[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function jG(e){return{raw:Number(e),formatted:dG(e)}}function MG(e){if(e.id){if(typeof e.id!=`string`)throw AG(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return pG()}function NG(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(LG(r)){let e=BG(r);if(!Array.isArray(t)||t.length!==e)throw AG(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(RG(r)){if(!Array.isArray(t))return n;let e=zG(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=NG(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}var PG={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},FG={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function IG(e){return e===`geopoint`}function LG(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function RG(e){return typeof e==`string`&&PG[e]}function zG(e){return FG[e]}function BG(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw AG(`INVALID_VECTOR_VALUE`,e);case t<=0:throw AG(`INVALID_VECTOR_SIZE`,e);default:return t}}function VG(){return{idToInternalId:new Map,internalIdToId:[],save:HG,load:UG}}function HG(e){return{internalIdToId:e.internalIdToId}}function UG(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 WG(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?WG(e,t.toString()):t}function GG(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function KG(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function qG(e,t){let n=WG(e.sharedInternalDocumentStore,t);return e.docs[n]}function JG(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=WG(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function YG(e){return e.docs}function XG(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function ZG(e,t){let n=WG(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function QG(e){return e.count}function $G(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function eK(e){return{docs:e.docs,count:e.count}}function tK(){return{create:KG,get:qG,getMultiple:JG,getAll:YG,store:XG,remove:ZG,count:QG,load:$G,save:eK}}var nK=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function rK(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),AG(`PLUGIN_CRASHED`)}return n}var iK=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],aK=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function oK(e,t,n,r){if(e.some(SG))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function sK(e,t,n){if(e.some(SG))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function cK(e,t,n,r,i){if(e.some(SG))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function lK(e,t,n,r){if(e.some(SG))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function uK(e,t){if(e.some(SG))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var dK=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}},fK=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new dK(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?dK.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new dK(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 dK(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 dK(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}},pK=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 mK(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 hK(e,t,n){let r=mK(e,t,n);return{distance:r,isBounded:r>=0}}var gK=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(mG(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&hK(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(mG(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&&(hK(e,n,r).isBounded&&(i[n]=[]),mG(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}},_K=class e extends gK{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,gK.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},vK=2,yK=6371e3,bK=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}},xK=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 bK(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%vK===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=bK.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 yK*(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)}},SK=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 CK(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 wK=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=TK(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)),EK(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 TK(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function EK(e,t,n,r,i){let a=TK(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 DK(e,t,n,r,i){let a=WG(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 OK(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=WG(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 kK(e,t,n,r){let i=WG(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 AK(e,t,n){e.tokenOccurrences[t][n]--}function jK(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)){jK(e,t,o,r,n);continue}if(LG(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new wK(BG(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new SK,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new fK(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new _K,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 pK,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new xK,isArray:e};break;default:throw AG(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function MK(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 NK(e,t,n,r,i,a,o,s,c,l,u){if(LG(o))return PK(t,n,a,r,i);let d=MK(e,t,n,i,s,c,l,u);if(!RG(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function PK(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function FK(e,t,n,r,i,a,o,s,c,l){if(LG(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 IK(e,t,n,r,i,a,o,s,c,l){if(!RG(o))return FK(e,t,n,r,i,a,o,s,c,l);let u=zG(o),d=a,f=d.length;for(let a=0;a<f;a++)FK(e,t,n,r,i,d[a],u,s,c,l);return!0}function LK(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=CK(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 RK(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 AG(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw AG(`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];LK(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 zK(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:wG(...i.map(n=>zK(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=>zK(e,t,n,r)).reduce((e,t)=>EG(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 DG(a,zK(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 AG(`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]=EG(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=bG(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=GK(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]=GK(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]=YK(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw AG(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=EG(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 AG(`INVALID_FILTER_OPERATION`,e)}a[o]=EG(a[o],n)}}return wG(...Object.values(a))}function BK(e){return e.searchableProperties}function VK(e){return e.searchablePropertiesWithTypes}function HK(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:_K.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:pK.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:fK.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:xK.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:SK.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:wK.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function UK(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 WK(){return{create:jK,insert:NK,remove:IK,insertDocumentScoreParameters:DK,insertTokenScoreParameters:OK,removeDocumentScoreParameters:kK,removeTokenScoreParameters:AK,calculateResultScores:LK,search:RK,searchByWhereClause:zK,getSearchableProperties:BK,getSearchablePropertiesWithTypes:VK,load:HK,save:UK}}function GK(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 KK(e,t,n=!1){let r=n?xK.vincentyDistance:xK.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 qK(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 JK(e,t){let n=e,r=qK(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=bG(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),KK(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=xK.calculatePolygonCentroid(e);return KK(s,r,n)}return null}function YK(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 XK(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=XK(e,t,s,r,n);oG(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!LG(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 AG(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function ZK(e,t,n,r){return r?.enabled===!1?{disabled:!0}:XK(e,t,n,(r||{}).unsortableProperties||[],``)}function QK(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=WG(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&aq(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function $K(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)rq(e,n);e.isSorted=!0}function eq(e,t,n){return t[1].localeCompare(n[1],$W(e))}function tq(e,t){return e[1]-t[1]}function nq(e,t){return t[1]?-1:1}function rq(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=eq.bind(null,e.language);break;case`number`:r=tq.bind(null);break;case`boolean`:r=nq.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 iq(e){let t=Object.keys(e.sorts);for(let n of t)aq(e,n)}function aq(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 oq(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=WG(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function sq(e,t,n){if(!e.enabled)throw AG(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw AG(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return aq(e,r),$K(e),t.sort((t,n)=>{let r=a.docs.get(WG(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(WG(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 cq(e){return e.enabled?e.sortableProperties:[]}function lq(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function uq(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 dq(e){if(!e.enabled)return{enabled:!1};iq(e),$K(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 fq(){return{create:ZK,insert:QK,remove:oq,save:dq,load:uq,sortBy:sq,getSortableProperties:cq,getSortablePropertiesWithTypes:lq}}var pq=192,mq=383,hq=[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 gq(e){return e<pq||e>mq?e:hq[e-pq]||e}function _q(e){let t=[];for(let n=0;n<e.length;n++)t[n]=gq(e.charCodeAt(n));return String.fromCharCode(...t)}var vq={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`},yq={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},bq=`[^aeiou]`,xq=`[aeiouy]`,Sq=bq+`[^aeiouy]*`;xq+``;var Cq=`^(`+Sq+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,wq=`^(`+Sq+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`,Tq=`^(`+Sq+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,Eq=`^(`+Sq+`)?[aeiouy]`;function Dq(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(Cq),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(Eq),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+Sq+xq+`[^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(Eq),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(Cq),t&&r.test(t)&&(e=t+vq[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(Cq),t&&r.test(t)&&(e=t+yq[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(Tq),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(Tq),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(Tq),i=new RegExp(wq),a=RegExp(`^`+Sq+xq+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(Tq),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function Oq(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=_q(t),n&&this.normalizationCache.set(r,t),t)}function kq(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function Aq(e,t,n,r=!0){if(t&&t!==this.language)throw AG(`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=ZW[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=kq(a);return this.allowDuplicates?o:Array.from(new Set(o))}function jq(e={}){if(!e.language)e.language=`english`;else if(!QW.includes(e.language))throw AG(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw AG(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=Dq;else throw AG(`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 AG(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw AG(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw AG(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:Aq,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:Oq,normalizationCache:new Map};return r.tokenize=Aq.bind(r),r.normalizeToken=Oq,r}function Mq(e){return{sharedInternalDocumentStore:e,rules:new Map}}function Nq(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 Pq(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 Fq(e,t){return e.rules.delete(t)}function Iq(e,t){return e.rules.get(t)}function Lq(e){return Array.from(e.rules.values())}function Rq(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 zq(e,t){return e?t.conditions.every(t=>Rq(e,t)):!1}function Bq(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())zq(t,r)&&n.push(r);return n}function Vq(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function Hq(e){return{rules:Array.from(e.rules.entries())}}function Uq(){return{create:Mq,addRule:Nq,updateRule:Pq,removeRule:Fq,getRule:Iq,getAllRules:Lq,getMatchingRules:Bq,load:Vq,save:Hq}}function Wq(e){let t={formatElapsedTime:jG,getDocumentIndexId:MG,getDocumentProperties:_G,validateSchema:NG};for(let n of aK){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw AG(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!iK.includes(t)&&!aK.includes(t))throw AG(`UNSUPPORTED_COMPONENT`,t)}function Gq({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 AG(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=pG();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:jq(o):jq({language:n??`english`}),r.tokenizer&&n)throw AG(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=VG();s||=WK(),l||=fq(),c||=tK(),u||=Uq(),Wq(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:Kq()};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 nK)g[e]=(g[e]??[]).concat(rK(g,e));let _=g.afterCreate;return _&&uK(_,g),g}function Kq(){return`{{VERSION}}`}function qq(e){return e.documentsStore.count(e.data.docs)}function Jq(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw AG(`SCHEMA_VALIDATION_FAILURE`,a);return SG(e.beforeInsert)||SG(e.afterInsert)||SG(e.index.beforeInsert)||SG(e.index.insert)||SG(e.index.afterInsert)?Zq(e,t,n,r,i):Qq(e,t,n,r,i)}var Yq=new Set([`enum`,`enum[]`]),Xq=new Set([`string`,`number`]);async function Zq(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw AG(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=WG(e.internalDocumentIDStore,s);if(r||await oK(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw AG(`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];$q(n,r,e,t)}return await eJ(e,s,u,f,l,n,t,i),r||await oK(e.afterInsert,e,s,t),s}function Qq(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw AG(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=WG(e.internalDocumentIDStore,s);if(r||oK(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw AG(`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];$q(n,r,e,t)}return tJ(e,s,u,f,l,n,t,i),r||oK(e.afterInsert,e,s,t),s}function $q(e,t,n,r){if(!(IG(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(LG(t)&&Array.isArray(r))&&!(RG(t)&&Array.isArray(r))&&!(Yq.has(t)&&Xq.has(e))&&e!==t)throw AG(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function eJ(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 tJ(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=WG(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 nJ(e,t,n,r,i,a){return SG(e.afterInsertMultiple)||SG(e.beforeInsertMultiple)||SG(e.index.beforeInsert)||SG(e.index.insert)||SG(e.index.afterInsert)?rJ(e,t,n,r,i,a):iJ(e,t,n,r,i,a)}async function rJ(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 Jq(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&&OG(e)}}})(),i||await sK(e.afterInsertMultiple,e,t),o}function iJ(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=Jq(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&&OG(e)}}}return l(),i||sK(e.afterInsertMultiple,e,t),o}function aJ(e,t){return e[1]-t[1]}function oJ(e,t){return t[1]-e[1]}function sJ(e=`desc`){return e.toLowerCase()===`asc`?aJ:oJ}function cJ(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(`.`)?vG(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;lJ(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=lJ(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:uJ(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=uJ(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw AG(`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=sJ(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function lJ(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 uJ(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))}}var dJ={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},fJ=[`string`,`number`,`boolean`];function pJ(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 AG(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!fJ.includes(a[t]))throw AG(`INVALID_GROUP_BY_PROPERTY`,t,fJ.join(`, `),a[t])}let o=t.map(([t])=>GG(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=vG(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=mJ(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=gG(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||dJ,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 mJ(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=mJ(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];oG(n,t),i.push(n)}return i}function hJ(e,t,n,r){let i=Bq(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=WG(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 gJ(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 AG(`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=qq(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},xJ(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=vJ(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${_J(e)}\\b`).test(n)))return!0}return!1})}}else l=s?JK(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 _J(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function vJ(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 yJ(e,t,n){let r=fG();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=gJ(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])=>[WG(e.internalDocumentIDStore,t),n]);else d=d.sort(hG);d=hJ(e,e.data.pinning,d,t.term);let f;u||(f=c?NJ(e,d,s,o,c):PJ(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||xG(p,i)),a&&(p.facets=cJ(e,d,t.facets)),t.groupBy&&(p.groups=pJ(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(fG()-r),p}async function a(){e.beforeSearch&&await lK(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await cK(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}var bJ={k:1.2,b:.75,d:.5};function xJ(e){let t=e??{};return t.k=t.k??bJ.k,t.b=t.b??bJ.b,t.d=t.d??bJ.d,t}function SJ(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw AG(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw AG(`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?AG(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):AG(`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 CJ(e,t,n=`english`){let r=fG();function i(){let i=SJ(e,t,n).sort(hG);i=hJ(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=cJ(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:GG(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=pJ(e,i,t.groupBy));let f=fG()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:dG(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await lK(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await cK(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function wJ(e,t,n){let r=DJ(gJ(e,t,n)),i=SJ(e,t,n),a=t.hybridWeights;return AJ(r,i,t.term??``,a)}function TJ(e,t,n){let r=fG();function i(){let i=wJ(e,t,n);i=hJ(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=cJ(e,i,t.facets));let o;t.groupBy&&(o=pJ(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=PJ(e,i,s,c).filter(Boolean),u=fG(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:dG(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||xG(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await lK(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await cK(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function EJ(e){return e[1]}function DJ(e){let t=Math.max.apply(Math,e.map(EJ));return e.map(([e,n])=>[e,n/t])}function OJ(e,t){return e/t}function kJ(e,t){return(n,r)=>n*e+r*t}function AJ(e,t,n,r){let i=Math.max.apply(Math,e.map(EJ)),a=Math.max.apply(Math,t.map(EJ)),{text:o,vector:s}=r&&r.text&&r.vector?r:jJ(n),c=new Map,l=e.length,u=kJ(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(OJ(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=OJ(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function jJ(e){return{text:.5,vector:.5}}function MJ(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return yJ(e,t,n);if(r===`vector`)return CJ(e,t);if(r===`hybrid`)return TJ(e,t);throw AG(`INVALID_SEARCH_MODE`,r)}function NJ(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=vG(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:GG(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function PJ(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:GG(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}var FJ=r(YW(),1),IJ=/[\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF]/g;function LJ(e){return e.replace(IJ,``)}function RJ(e){return e.replace(/[\u0000-\u001F\u007F]/g,` `)}function zJ(e,t){if(e.length<=t)return e;let n=e.slice(0,t),r=n.charCodeAt(n.length-1);return r>=55296&&r<=56319?n.slice(0,-1):n}var BJ=R({at:N(),transport:N(),outcome:N(),reference:N().optional(),error:N().optional(),errorCode:N().optional()}),VJ=R({reason:N(),at:N(),errorCode:N().optional()});R({version:P().int().catch(1),id:N(),createdAt:N(),bundleLevel:N(),zipBytes:P().int().nonnegative().catch(0),zipDeleted:F().optional(),state:N(),systemWide:F().optional(),projectSlug:N().nullable().optional(),reference:N().optional(),lastError:VJ.optional(),attempts:I(BJ).optional(),note:N().optional()}),R({version:P().int().catch(1),id:N().optional(),sentAt:N().optional(),reference:N().optional()});var HJ=`0.0.0-unknown`,UJ={protocol:`x-ok-client-protocol`,runtime:`x-ok-client-runtime`,kind:`x-ok-client-kind`};function WJ({kind:e,runtimeVersion:t}){return{[UJ.protocol]:`2`,[UJ.runtime]:t,[UJ.kind]:e}}function GJ({kind:e,runtimeVersion:t}){return{clientProtocolVersion:2,clientRuntimeVersion:t,clientKind:e}}var KJ=`extra/screenshot.png`,qJ=[{name:`github-pat`,regex:/\b(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9]{36,}\b/g,replacement:`[REDACTED-GH-PAT]`},{name:`aws-access-key`,regex:/\b(AKIA|ASIA|ABIA)[A-Z2-7]{16}\b/g,replacement:`[REDACTED-AWS-KEY]`},{name:`anthropic-key`,regex:/\bsk-ant-api03-[A-Za-z0-9_-]{20,}\b/g,replacement:`[REDACTED-ANTHROPIC]`},{name:`openai-key`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g,replacement:`[REDACTED-OPENAI]`},{name:`bearer-token`,regex:/([Aa]uthorization:\s*[Bb]earer\s+)(?:\\"[^\s"\\]+\\"|"[A-Za-z0-9\-._~+/=]+"|[^\s"\\]+)/g,replacement:`$1[REDACTED]`},{name:`jwt`,regex:/eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,replacement:`[REDACTED-JWT]`},{name:`url-credentials`,regex:/:\/\/[^/\s:@"]+:[^/\s:@"]+@/g,replacement:`://[REDACTED]@`},{name:`github-pat-fine-grained`,regex:/\bgithub_pat_[0-9A-Za-z_]{20,}/g,replacement:`[REDACTED-GH-PAT]`},{name:`openai-key-modern`,regex:/\bsk-(?:proj|svcacct|admin|None)-[A-Za-z0-9_-]{20,}/g,replacement:`[REDACTED-OPENAI]`},{name:`slack-token`,regex:/\bxox[a-z]-[A-Za-z0-9-]{10,}/g,replacement:`[REDACTED-SLACK]`},{name:`google-api-key`,regex:/\bAIza[0-9A-Za-z_-]{35}/g,replacement:`[REDACTED-GOOGLE]`},{name:`stripe-secret-key`,regex:/\b(?:sk|rk)_live_[0-9A-Za-z]{16,}\b/g,replacement:`[REDACTED-STRIPE]`},{name:`gitlab-pat`,regex:/\bglpat-[0-9A-Za-z_-]{20,}/g,replacement:`[REDACTED-GITLAB]`},{name:`bearer-token-json`,regex:/("[Aa]uthorization"\s*:\s*"[Bb]earer\s+)(?:\\"[^"\\]+\\"|[^"\\]+)/g,replacement:`$1[REDACTED]`},{name:`macos-home-path`,regex:/\/Users\/[^/"\r]*[^/"\r\\]/g,replacement:`~`},{name:`linux-home-path`,regex:/\/home\/[^/"\r]*[^/"\r\\]/g,replacement:`~`},{name:`windows-home-path`,regex:/[A-Za-z]:\\{1,2}Users\\{1,2}(?:(?![A-Za-z]:\\)[^\\"\r])+/gi,replacement:`~`}];qJ.map(e=>e.name);function JJ(e){let t=new Set,n=0;return{redacted:e.split(`
400
400
  `).map(e=>{let r=e,i=!1;for(let{name:e,regex:n,replacement:a}of qJ)n.lastIndex=0,n.test(r)&&(t.add(e),i=!0,n.lastIndex=0,r=r.replace(n,a));return i&&n++,r}).join(`
401
401
  `),patterns:[...t],lineCount:n}}function YJ(e){return JJ(e).redacted}var XJ=8192,ZJ=32768,QJ=`…[truncated]`,$J=[`level`,`time`,`pid`,`hostname`,`msg`,`name`,`runtime`,`subsystem`,`trace_id`,`span_id`,`trace_flags`];function eY(e){let t=YJ(e).trim();if(t.length===0||t[0]!==`{`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!=`object`||!n||Array.isArray(n))return null;let r=n;for(let e of $J)delete r[e];return{event:typeof r.event==`string`?r.event:void 0,fields:r}}function tY(e){return e.length<=8192?e:`${e.slice(0,XJ-12)}${QJ}`}function nY(e,t){return!(e.host===`desktop`&&t.host!==`desktop`||e.singleFileHidden&&t.singleFile||e.requiresTerminalCapability&&!t.terminalCapable||e.requiresTerminalLive&&!t.terminalLive||e.requiresCanExpandAll&&!t.canExpandAll||e.requiresCanCollapseAll&&!t.canCollapseAll||e.requiresActiveDoc&&!t.hasActiveDoc||e.requiresInstallSkill&&!t.showInstallSkill||e.requiresTargetKinds&&!e.requiresTargetKinds.includes(t.activeTargetKind))}var rY=[{id:`open-blob-run`,labelKey:`blobRun`,keywords:[`game`,`blob`,`runner`,`play`,`easter egg`,`dino`],availability:{},palette:{group:`app`,visibility:`search-only`}},{id:`navigate-back`,menuActionId:`navigate-back`,labelKey:`back`,keywords:[`previous history`,`go`],shortcutId:`navigate-back`,shortcutDesktopOnly:!0,availability:{host:`desktop`},palette:{group:`commands`,visibility:`search-only`},menu:[{section:`view-history`,order:0,platform:`mac`,accelerator:`Cmd+[`},{section:`view-history`,order:0,platform:`other`,accelerator:`Alt+Left`}]},{id:`navigate-forward`,menuActionId:`navigate-forward`,labelKey:`forward`,keywords:[`next history`,`go`],shortcutId:`navigate-forward`,shortcutDesktopOnly:!0,availability:{host:`desktop`},palette:{group:`commands`,visibility:`search-only`},menu:[{section:`view-history`,order:1,platform:`mac`,accelerator:`Cmd+]`},{section:`view-history`,order:1,platform:`other`,accelerator:`Alt+Right`}]},{id:`new-file`,menuActionId:`new-doc`,labelKey:`newFile`,keywords:[`create file`,`document`,`note`],shortcutId:`new-item`,availability:{},palette:{group:`commands`,visibility:`always`},menu:[{section:`file-create`,order:0,accelerator:`CmdOrCtrl+N`}]},{id:`new-folder`,menuActionId:`new-folder`,labelKey:`newFolder`,keywords:[`create folder`,`directory`],shortcutId:`new-folder`,shortcutDesktopOnly:!0,availability:{},palette:{group:`commands`,visibility:`always`},menu:[{section:`file-create`,order:1,accelerator:`CmdOrCtrl+Shift+N`}]},{id:`open-graph`,labelKey:`openGraph`,keywords:[`graph panel network`,`show`,`view`],availability:{requiresActiveDoc:!0},palette:{group:`commands`,visibility:`always`}},{id:`open-in-new-window`,labelKey:`openInNewWindow`,keywords:[`pop out`,`detach`,`separate window`,`second monitor`],availability:{host:`desktop`,requiresActiveDoc:!0,singleFileHidden:!0},palette:{group:`commands`,visibility:`always`},menu:[{section:`window`,order:0}]},{id:`initialize-starter-pack`,labelKey:`initializeStarterPack`,keywords:[`scaffold`,`seed`,`pack`,`starter`],availability:{},palette:{group:`commands`,visibility:`always`}},{id:`new-skill`,labelKey:`newSkill`,keywords:[`skill`,`create`,`author`,`new`],availability:{singleFileHidden:!0},palette:{group:`commands`,visibility:`always`}},{id:`new-project`,menuActionId:`new-project`,labelKey:`newProject`,keywords:[`create new project scaffold`],availability:{host:`desktop`},palette:{group:`project`,visibility:`always`},menu:[{section:`file-project`,order:0,ellipsis:!0}]},{id:`open-folder`,labelKey:`openFolderOnDisk`,keywords:[`project`,`folder`,`disk`],shortcutId:`open-folder`,availability:{host:`desktop`},palette:{group:`project`,visibility:`always`},menu:[{section:`file-project`,order:2,accelerator:`CmdOrCtrl+O`,ellipsis:!0,menuLabelKey:`openFolder`}]},{id:`open-file`,labelKey:`openFileOnDisk`,keywords:[`file`,`markdown`,`single`,`standalone`,`temporary`],shortcutId:`open-file`,availability:{host:`desktop`},palette:{group:`project`,visibility:`always`},menu:[{section:`file-project`,order:3,accelerator:`CmdOrCtrl+Shift+O`,ellipsis:!0,menuLabelKey:`openFile`}]},{id:`open-skills`,labelKey:`openSkills`,keywords:[`skills marketplace explore import discover`,`browse`,`install`,`open`],availability:{singleFileHidden:!0},palette:{group:`project`,visibility:`always`},menu:[]},{id:`switch-project`,labelKey:`switchProject`,keywords:[`switch project navigator projects`,`change`],shortcutId:`switch-project`,availability:{host:`desktop`,singleFileHidden:!0},palette:{group:`project`,visibility:`always`},menu:[{section:`file-project`,order:1,accelerator:`CmdOrCtrl+Shift+P`,ellipsis:!0}]},{id:`settings`,labelKey:`settings`,keywords:[`preferences config`,`open`],shortcutId:`settings`,availability:{singleFileHidden:!0},palette:{group:`project`,visibility:`always`},menu:[{section:`app-settings`,order:0,platform:`mac`,accelerator:`CmdOrCtrl+,`,ellipsis:!0},{section:`file-settings`,order:0,platform:`other`,accelerator:`CmdOrCtrl+,`,ellipsis:!0}]},{id:`install-claude-desktop`,labelKey:`installClaudeDesktop`,keywords:[`claude desktop install cowork`],availability:{requiresInstallSkill:!0},palette:{group:`project`,visibility:`always`},menu:[{section:`help-install`,order:0,ellipsis:!0,menuLabelText:`Install for Claude Chat & Cowork (desktop app)`}]},{id:`report-bug`,menuActionId:`report-bug`,labelKey:`reportBug`,keywords:[`bug report issue feedback problem`,`file`],shortcutId:`report-bug`,shortcutDesktopOnly:!0,availability:{host:`desktop`},palette:{group:`project`,visibility:`always`},menu:[{section:`help-links`,order:1,ellipsis:!0,accelerator:`CmdOrCtrl+Shift+D`}]},{id:`bug-report-history`,labelKey:`bugReportHistory`,keywords:[`bug report history previous reports past retry resend`],availability:{host:`desktop`},palette:{group:`project`,visibility:`always`}},{id:`send-feedback`,menuActionId:`send-feedback`,labelKey:`sendFeedback`,keywords:[`feedback`,`suggestion`,`idea`,`rate`,`survey`,`contact`,`give`],availability:{},palette:{group:`project`,visibility:`always`},menu:[{section:`help-links`,order:2,ellipsis:!0}]},{id:`new-from-template`,menuActionId:`new-from-template`,labelKey:`newFromTemplate`,keywords:[`template`,`create`,`new`],availability:{singleFileHidden:!0},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-create`,order:2,ellipsis:!0}]},{id:`rename`,menuActionId:`rename`,labelKey:`rename`,keywords:[`rename`,`file`,`folder`],availability:{host:`desktop`,requiresTargetKinds:[`doc`,`folder`,`asset`]},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-item`,order:1}]},{id:`duplicate`,menuActionId:`duplicate`,labelKey:`duplicate`,keywords:[`duplicate`,`copy`,`file`,`folder`],shortcutId:`file-tree-duplicate`,availability:{host:`desktop`,requiresTargetKinds:[`doc`,`folder`]},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-item`,order:0,accelerator:`CmdOrCtrl+D`}]},{id:`move-to-trash`,menuActionId:`move-to-trash`,labelKey:`moveToTrash`,keywords:[`delete`,`trash`,`remove`,`file`,`folder`],shortcutId:`file-tree-delete`,availability:{host:`desktop`,requiresTargetKinds:[`doc`,`folder`,`asset`]},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-item`,order:2,accelerator:`CmdOrCtrl+Delete`}]},{id:`reveal-in-finder`,menuActionId:`reveal-in-finder`,labelKey:`revealInFinder`,keywords:[`finder`,`reveal`,`show`,`file`,`folder`,`open`],availability:{host:`desktop`,requiresTargetKinds:[`doc`,`folder`,`asset`,`project`]},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-reveal`,order:0}]},{id:`send-to-ai`,menuActionId:`send-to-ai`,labelKey:`openWithAi`,keywords:[`ai`,`agent`,`handoff`],availability:{host:`desktop`,requiresTargetKinds:[`doc`,`folder`,`project`]},menu:[{section:`file-reveal`,order:1}]},{id:`copy-full-path`,menuActionId:`copy-full-path`,labelKey:`copyFullPath`,keywords:[`copy`,`path`,`absolute`,`full`],availability:{host:`desktop`,requiresTargetKinds:[`doc`,`folder`,`asset`,`project`]},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-copy-path`,order:0,menuLabelKey:`fullPath`}]},{id:`copy-relative-path`,menuActionId:`copy-relative-path`,labelKey:`copyRelativePath`,keywords:[`copy`,`path`,`relative`],availability:{host:`desktop`,requiresTargetKinds:[`doc`,`folder`,`asset`,`project`]},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-copy-path`,order:1,menuLabelKey:`relativePath`}]},{id:`close-tab`,menuActionId:`close-active-tab-or-window`,labelKey:`closeTab`,keywords:[`close`,`tab`,`window`],availability:{host:`desktop`},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-close`,order:0,platform:`mac`,accelerator:`CmdOrCtrl+W`}]},{id:`new-worktree`,menuActionId:`new-worktree`,labelKey:`newWorktree`,keywords:[`worktree`,`branch`,`new`,`create`],availability:{host:`desktop`},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-worktree`,order:0,ellipsis:!0}]},{id:`switch-worktree`,menuActionId:`switch-worktree`,labelKey:`switchWorktree`,keywords:[`worktree`,`switch`,`branch`,`change`,`checkout`],availability:{host:`desktop`},palette:{group:`file`,visibility:`search-only`},menu:[{section:`file-worktree`,order:1,ellipsis:!0}]},{id:`toggle-sidebar`,menuActionId:`toggle-sidebar`,labelKey:`sidebarHide`,keywords:[`sidebar`,`files`,`panel`,`toggle`,`show`,`hide`,`open`],shortcutId:`toggle-files-sidebar`,stateToggle:{showKey:`sidebarShow`,hideKey:`sidebarHide`,stateField:`sidebarVisible`,defaultVisible:!0},availability:{},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-panels`,order:0,accelerator:`CmdOrCtrl+Alt+S`}]},{id:`toggle-doc-panel`,menuActionId:`toggle-doc-panel`,labelKey:`docPanelHide`,keywords:[`document`,`panel`,`info`,`toggle`,`properties`,`show`,`hide`,`open`],shortcutId:`toggle-document-panel`,stateToggle:{showKey:`docPanelShow`,hideKey:`docPanelHide`,stateField:`docPanelVisible`,defaultVisible:!0},availability:{},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-panels`,order:1,accelerator:`CmdOrCtrl+Alt+B`}]},{id:`toggle-terminal`,menuActionId:`toggle-terminal`,labelKey:`terminalShow`,keywords:[`terminal`,`shell`,`console`,`panel`,`toggle terminal`,`toggle bottom dock`,`show terminal`,`hide terminal`,`close`,`open`],shortcutId:`toggle-terminal-panel`,stateToggle:{showKey:`terminalShow`,hideKey:`terminalHide`,stateField:`terminalVisible`,defaultVisible:!1},availability:{host:`desktop`,requiresTerminalCapability:!0},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-panels`,order:2,accelerator:`CmdOrCtrl+J`}]},{id:`toggle-agent-panel`,menuActionId:`toggle-agent-panel`,labelKey:`agentPanelShow`,keywords:[`agent`,`agents`,`chat`,`ai`,`ask`,`panel`,`toggle`,`open`,`show`,`hide`],shortcutId:`toggle-agent-panel`,stateToggle:{showKey:`agentPanelShow`,hideKey:`agentPanelHide`,stateField:`agentPanelVisible`,defaultVisible:!1,overrideKey:`agentPanelAskSelection`,overrideField:`hasEditorSelection`},availability:{},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-panels`,order:3,accelerator:`CmdOrCtrl+L`}]},{id:`toggle-show-hidden-files`,menuActionId:`toggle-show-hidden-files`,labelKey:`showHiddenFiles`,keywords:[`hidden`,`dotfiles`,`files`,`show`],checkField:`showHiddenFiles`,availability:{},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-visibility`,order:0,accelerator:`CmdOrCtrl+Shift+.`,checkbox:!0}]},{id:`toggle-show-ok-folders`,menuActionId:`toggle-show-ok-folders`,labelKey:`showOkFolders`,keywords:[`ok`,`folders`,`hidden`,`show`],checkField:`showOkFolders`,availability:{},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-visibility`,order:1,checkbox:!0}]},{id:`toggle-show-only-markdown-files`,menuActionId:`toggle-show-only-markdown-files`,labelKey:`showOnlyMarkdownFiles`,keywords:[`markdown`,`filter`,`files`,`only`],checkField:`showOnlyMarkdownFiles`,availability:{},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-visibility`,order:2,checkbox:!0}]},{id:`toggle-show-skills-section`,menuActionId:`toggle-show-skills-section`,labelKey:`showSkillsSection`,keywords:[`skills`,`section`,`sidebar`,`show`],checkField:`showSkillsSection`,availability:{},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-visibility`,order:3,checkbox:!0}]},{id:`expand-all-tree`,menuActionId:`expand-all-tree`,labelKey:`expandAll`,keywords:[`expand`,`tree`,`folders`,`all`],availability:{requiresCanExpandAll:!0},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-tree`,order:0,smartHide:!0}]},{id:`collapse-all-tree`,menuActionId:`collapse-all-tree`,labelKey:`collapseAll`,keywords:[`collapse`,`tree`,`folders`,`all`],availability:{requiresCanCollapseAll:!0},palette:{group:`view`,visibility:`search-only`},menu:[{section:`view-tree`,order:1,smartHide:!0}]},{id:`new-terminal`,menuActionId:`new-terminal`,labelKey:`newTerminal`,keywords:[`terminal`,`shell`,`new`,`tab`],availability:{host:`desktop`,requiresTerminalCapability:!0},palette:{group:`terminal`,visibility:`search-only`},menu:[{section:`terminal`,order:0}]},{id:`new-terminal-window`,keywords:[],availability:{host:`desktop`,requiresTerminalCapability:!0},menu:[{section:`terminal`,order:1,menuLabelText:`New Terminal Window`}]},{id:`move-terminal`,menuActionId:`move-terminal`,labelKey:`terminalMoveRight`,keywords:[`terminal`,`move`,`dock`,`right`,`bottom`,`placement`],placementToggle:{bottomKey:`terminalMoveRight`,rightKey:`terminalMoveBottom`},availability:{host:`desktop`,requiresTerminalCapability:!0},palette:{group:`terminal`,visibility:`search-only`},menu:[{section:`terminal`,order:2}]},{id:`kill-terminal`,menuActionId:`kill-terminal`,labelKey:`killTerminal`,keywords:[`terminal`,`kill`,`close`,`session`,`stop`],availability:{host:`desktop`,requiresTerminalCapability:!0,requiresTerminalLive:!0},palette:{group:`terminal`,visibility:`search-only`},menu:[{section:`terminal`,order:3}]},{id:`check-for-updates`,labelKey:`checkForUpdates`,keywords:[`update`,`upgrade`,`version`,`check`,`app`],availability:{host:`desktop`},palette:{group:`app`,visibility:`search-only`},menu:[{section:`app-updates`,order:0,platform:`mac`,ellipsis:!0},{section:`help-updates`,order:0,platform:`other`,ellipsis:!0}]},{id:`set-up-integrations`,labelKey:`setUpIntegrations`,keywords:[`integrations`,`mcp`,`setup`,`claude`,`configure`],availability:{host:`desktop`},palette:{group:`app`,visibility:`search-only`},menu:[{section:`file-integrations`,order:0,ellipsis:!0}]},{id:`toggle-spell-check`,labelKey:`checkSpelling`,keywords:[`spell`,`spelling`,`check`,`typing`],availability:{host:`desktop`},palette:{group:`app`,visibility:`search-only`},menu:[{section:`edit-spell`,order:0,checkbox:!0}]},{id:`open-github`,labelKey:`openOnGithub`,keywords:[`github`,`source`,`repository`,`code`,`view`],availability:{},palette:{group:`app`,visibility:`search-only`},menu:[{section:`help-links`,order:0}]},{id:`uninstall`,keywords:[],availability:{host:`desktop`},menu:[{section:`app-uninstall`,order:0,platform:`mac`,ellipsis:!0,menuLabelText:`Uninstall OpenKnowledge`}]}];function iY(e,t){let n=e.attrs[t];return typeof n==`string`?n:``}function aY(e,t){let n=e.attrs.props;if(typeof n!=`object`||!n)return``;let r=n[t];return typeof r==`string`?r:``}var oY=[`children`,`chart`,`formula`,`alt`,`name`,`alias`,`target`];function sY(e){for(let t of oY){let n=aY(e,t);if(n.length>0)return n}return iY(e,`sourceRaw`)}function cY(e){switch(e.type.name){case`wikiLink`:return iY(e,`alias`)||iY(e,`target`);case`wikiLinkEmbed`:return iY(e,`target`);case`tag`:return`#${iY(e,`value`)}`;case`mathInline`:return iY(e,`formula`);case`image`:case`imageReference`:return iY(e,`alt`);case`footnoteReference`:return iY(e,`label`)||iY(e,`identifier`);case`jsxComponent`:case`jsxInline`:return e.content.size===0?sY(e):``;default:return``}}function lY(e,t,n,r=`
402
402
  `,{inlineOnly:i=!1}={}){let a=``,o=!0;return e.nodesBetween(t,n,(e,s)=>{let c=e.isText?(e.text??``).slice(Math.max(t,s)-s,n-s):i&&e.isBlock?``:cY(e);return e.isBlock&&(e.isTextblock||c.length>0)&&r&&(o?o=!1:a+=r),a+=c,!0},0),a}var uY=new Map([[32,` `],[9,` `],[160,`\xA0`]]);function dY(e){let t=/^&#(x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);$/.exec(e);if(!t)return null;let n=t[1],r=n[0]===`x`||n[0]===`X`,i=Number.parseInt(r?n.slice(1):n,r?16:10);return Number.isNaN(i)?null:i}function fY(e){let t=dY(e);return t!==null&&uY.has(t)}function pY(e){let t=dY(e);return t===null?null:uY.get(t)??null}var mY=/&#(?:x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);/g;function hY(e){mY.lastIndex=0;let t=e.match(mY);if(t===null||t.join(``)!==e)return null;let n=``;for(let e of t){let t=pY(e);if(t===null)return null;n+=t}return n}var gY=new Set([`*`,`_`,"`",`~`,`\\`,`$`]),_Y=/^={2,}/,vY=/^<(?:[A-Za-z][A-Za-z0-9+.-]*:[^<>\s]*|[^\s<>@]+@[^\s<>]+)>/,yY=512;function bY(e,t){return vY.test(e.slice(t,t+yY))}function xY(e,t){let n=e.lastIndexOf(`<`,t);return n<0||t-n>yY?!1:vY.exec(e.slice(n,t+1))?.[0].length===t+1-n}var SY=/^<\/?[A-Za-z][A-Za-z0-9-]*(?:\s[^>]*?)?\/?>/,CY=512,wY=/^!(?=\[)/,TY=/^\[\^/,EY=/^\]\[[^\]]*\]/,DY=/^\[\[[^\][|]*\|/,OY=/^#[^\][|]*(?=\]\])/,kY=512,AY=/^\]\([^)]*\)/,jY=512,MY=/^(?:#{1,6}[ \t]+|>[ \t]?|(?:[-*+]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?)/,NY=32,PY=`|`,FY=/^(?:`{3,}[^`\n]*|~{3,}[^\n]*)$/,IY=/^(?:(?:[-*_][ \t]*){3,}|=+[ \t]*|[|\-: \t]*-[|\-: \t]*)$/,LY=1024;function RY(e,t){let n=e.indexOf(`
@@ -1 +1 @@
1
- import{yo as e}from"./dist-D1GzYuCD.js";function t(t){return e.includes(t)}function n(e){if(e.startsWith(b)||e.startsWith(w)||e.startsWith(T)||e.startsWith(D)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=x(t),r=n>=0?t.slice(0,n):t;if(!r)return null;try{return r.split(`/`).map(decodeURIComponent).join(`/`)}catch{return r}}function r(e){if(e.startsWith(b)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=t.indexOf(`#`);if(n<0)return null;let r=t.slice(n+1);if(!r)return null;try{return decodeURIComponent(r)}catch{return r}}var i=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function a(e){return encodeURIComponent(e.replace(i,`�`))}function o(e){return e.split(`/`).map(a).join(`/`)}function s(e,t){let n=`#/${o(e)}`;return t?`${n}#${a(t)}`:n}function c(e,t){return e===t||l(e)===l(t)}function l(e){try{return decodeURIComponent(e)}catch{return e}}var u=`__okHashHistoryEntry`;function d(e){return{...typeof e==`object`&&e?e:{},[u]:!0}}function f(e){return typeof e==`object`&&!!e&&e[u]===!0}function p(){f(window.history.state)||window.history.replaceState(d(window.history.state),``)}function m(e){let{pathname:t,search:n}=window.location;window.history.replaceState(d(window.history.state),``,`${t}${n}${e}`)}function h(e){if(c(window.location.hash,e))return;let{pathname:t,search:n}=window.location;window.history.pushState(d(window.history.state),``,`${t}${n}${e}`)}function g(e){return e.endsWith(`.mdx`)?e.slice(0,-4):e.endsWith(`.md`)?e.slice(0,-3):e}function _(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?`#/${o(n)}/`:`#/`;return t?`${r}#${a(t)}`:r}function v(e,t,n){if(e===`folder`)return _(t);let r=`#/${a(t)}`;return n==null||n===``?r:`${r}?branch=${a(n)}`}function y(e){if(e===`#/`)return!0;if(!e.startsWith(`#/`))return!1;let t=e.slice(2);return t.length>0&&t[0]===`?`}var b=`#/__asset__/`;function x(e){let t=e.indexOf(`?`),n=e.indexOf(`#`);return t<0?n:n<0?t:Math.min(t,n)}function S(e){if(!e.startsWith(b))return null;let t=e.slice(12);if(!t)return null;try{return t.split(`/`).map(decodeURIComponent).join(`/`)}catch{return t}}function C(e){return`${b}${o(e)}`}var w=`#/__skill-file__/`,T=`#/__skills__`;function E(e){return e===T||e.startsWith(`${T}/`)}var D=`#/__skill-preview__/`,O=[`explore`,`detected`,`builtin`,`foreign`,`linked`];function k(e){return e!==void 0&&O.includes(e)}var A=`project`;function j(e){return[e.flavor,e.source,e.name,e.subtitle,e.level??A].map(a).join(`/`)}function M(e){if(!e)return null;let n;try{n=e.split(`/`).map(decodeURIComponent)}catch{return null}if(n.length<4||n.length>6)return null;let[r,i,a,o,s,c]=n;return!k(r)||!i||!a?null:{flavor:r,source:i,name:a,subtitle:o??``,...s&&t(s)?{level:s}:{},...c?{path:c}:{}}}function N(e){let t=j(e);return e.path&&(t+=`/${a(e.path)}`),`${D}${t}`}function P(e){return e.startsWith(D)?M(e.slice(20)):null}var F=`:`;function I(e){let t=e.host===void 0?e.name:`${e.name}${F}${e.host}`;return`${w}${[e.scope,t].map(a).join(`/`)}/${o(e.path)}`}function L(e){if(!e.startsWith(w))return null;let n=e.slice(17);if(!n)return null;let r;try{r=n.split(`/`).map(decodeURIComponent)}catch{return null}if(r.length<3)return null;let[i,a,...o]=r,s=o.join(`/`);if(!i||!a||!s||!t(i))return null;let c=a.indexOf(F),l=c===-1?a:a.slice(0,c),u=c===-1?void 0:a.slice(c+1);return l?{scope:i,name:l,path:s,...u?{host:u}:{}}:null}var R=/\.(md|mdx)$/i;function z(e){return e.trim().replace(/^\.\/+/,``).replace(/^\/+/,``)}function B(e){return z(e).replace(R,``)}function V(e){let t=z(e);return t?R.test(t)?t:`${t}.md`:`untitled.md`}function H(e){let t=B(e),n=t.lastIndexOf(`/`);return{initialDir:n>0?t.slice(0,n):``,suggestedName:`${n>=0?t.slice(n+1):t||`untitled`}.md`}}export{P as C,L as S,f as _,S as a,h as b,v as c,C as d,s as f,y as g,N as h,r as i,j as l,I as m,V as n,M as o,_ as p,B as r,n as s,H as t,g as u,c as v,E as w,m as x,p as y};
1
+ import{yo as e}from"./dist-As2x8uCt.js";function t(t){return e.includes(t)}function n(e){if(e.startsWith(b)||e.startsWith(w)||e.startsWith(T)||e.startsWith(D)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=x(t),r=n>=0?t.slice(0,n):t;if(!r)return null;try{return r.split(`/`).map(decodeURIComponent).join(`/`)}catch{return r}}function r(e){if(e.startsWith(b)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=t.indexOf(`#`);if(n<0)return null;let r=t.slice(n+1);if(!r)return null;try{return decodeURIComponent(r)}catch{return r}}var i=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function a(e){return encodeURIComponent(e.replace(i,`�`))}function o(e){return e.split(`/`).map(a).join(`/`)}function s(e,t){let n=`#/${o(e)}`;return t?`${n}#${a(t)}`:n}function c(e,t){return e===t||l(e)===l(t)}function l(e){try{return decodeURIComponent(e)}catch{return e}}var u=`__okHashHistoryEntry`;function d(e){return{...typeof e==`object`&&e?e:{},[u]:!0}}function f(e){return typeof e==`object`&&!!e&&e[u]===!0}function p(){f(window.history.state)||window.history.replaceState(d(window.history.state),``)}function m(e){let{pathname:t,search:n}=window.location;window.history.replaceState(d(window.history.state),``,`${t}${n}${e}`)}function h(e){if(c(window.location.hash,e))return;let{pathname:t,search:n}=window.location;window.history.pushState(d(window.history.state),``,`${t}${n}${e}`)}function g(e){return e.endsWith(`.mdx`)?e.slice(0,-4):e.endsWith(`.md`)?e.slice(0,-3):e}function _(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?`#/${o(n)}/`:`#/`;return t?`${r}#${a(t)}`:r}function v(e,t,n){if(e===`folder`)return _(t);let r=`#/${a(t)}`;return n==null||n===``?r:`${r}?branch=${a(n)}`}function y(e){if(e===`#/`)return!0;if(!e.startsWith(`#/`))return!1;let t=e.slice(2);return t.length>0&&t[0]===`?`}var b=`#/__asset__/`;function x(e){let t=e.indexOf(`?`),n=e.indexOf(`#`);return t<0?n:n<0?t:Math.min(t,n)}function S(e){if(!e.startsWith(b))return null;let t=e.slice(12);if(!t)return null;try{return t.split(`/`).map(decodeURIComponent).join(`/`)}catch{return t}}function C(e){return`${b}${o(e)}`}var w=`#/__skill-file__/`,T=`#/__skills__`;function E(e){return e===T||e.startsWith(`${T}/`)}var D=`#/__skill-preview__/`,O=[`explore`,`detected`,`builtin`,`foreign`,`linked`];function k(e){return e!==void 0&&O.includes(e)}var A=`project`;function j(e){return[e.flavor,e.source,e.name,e.subtitle,e.level??A].map(a).join(`/`)}function M(e){if(!e)return null;let n;try{n=e.split(`/`).map(decodeURIComponent)}catch{return null}if(n.length<4||n.length>6)return null;let[r,i,a,o,s,c]=n;return!k(r)||!i||!a?null:{flavor:r,source:i,name:a,subtitle:o??``,...s&&t(s)?{level:s}:{},...c?{path:c}:{}}}function N(e){let t=j(e);return e.path&&(t+=`/${a(e.path)}`),`${D}${t}`}function P(e){return e.startsWith(D)?M(e.slice(20)):null}var F=`:`;function I(e){let t=e.host===void 0?e.name:`${e.name}${F}${e.host}`;return`${w}${[e.scope,t].map(a).join(`/`)}/${o(e.path)}`}function L(e){if(!e.startsWith(w))return null;let n=e.slice(17);if(!n)return null;let r;try{r=n.split(`/`).map(decodeURIComponent)}catch{return null}if(r.length<3)return null;let[i,a,...o]=r,s=o.join(`/`);if(!i||!a||!s||!t(i))return null;let c=a.indexOf(F),l=c===-1?a:a.slice(0,c),u=c===-1?void 0:a.slice(c+1);return l?{scope:i,name:l,path:s,...u?{host:u}:{}}:null}var R=/\.(md|mdx)$/i;function z(e){return e.trim().replace(/^\.\/+/,``).replace(/^\/+/,``)}function B(e){return z(e).replace(R,``)}function V(e){let t=z(e);return t?R.test(t)?t:`${t}.md`:`untitled.md`}function H(e){let t=B(e),n=t.lastIndexOf(`/`);return{initialDir:n>0?t.slice(0,n):``,suggestedName:`${n>=0?t.slice(n+1):t||`untitled`}.md`}}export{P as C,L as S,f as _,S as a,h as b,v as c,C as d,s as f,y as g,N as h,r as i,j as l,I as m,V as n,M as o,_ as p,B as r,n as s,H as t,g as u,c as v,E as w,m as x,p as y};
@@ -1 +1 @@
1
- import{A as e}from"./dist-D1GzYuCD.js";var t=`open-knowledge:documents-changed`,n=new Set(e.options);function r(e){return e===void 0||!Array.isArray(e)?[`files`]:[...new Set(e.filter(e=>n.has(e)))]}function i(e=[`files`]){window.dispatchEvent(new CustomEvent(t,{detail:{channels:r(e)}}))}function a(e){let n=t=>{e(r(t instanceof CustomEvent?t.detail?.channels:void 0))};return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}function o(e){return e.includes(`local-targets`)||e.includes(`files`)}var s=`open-knowledge:doc-persisted`;function c(e){window.dispatchEvent(new CustomEvent(s,{detail:{docName:e}}))}function l(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail?.docName;typeof n==`string`&&n.length>0&&e(n)};return window.addEventListener(s,t),()=>window.removeEventListener(s,t)}var u=`open-knowledge:branch-changed`;function d(e){window.dispatchEvent(new CustomEvent(u,{detail:{branch:e}}))}function f(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail;e(n?.branch??null)};return window.addEventListener(u,t),()=>window.removeEventListener(u,t)}var p=`open-knowledge:templates-changed`;function m(){window.dispatchEvent(new CustomEvent(p))}function h(e){let t=()=>e();return window.addEventListener(p,t),()=>window.removeEventListener(p,t)}var g=`open-knowledge:skills-changed`;function _(){window.dispatchEvent(new CustomEvent(g))}function v(e){let t=()=>e();return window.addEventListener(g,t),()=>window.removeEventListener(g,t)}var y=`open-knowledge:skill-scope-moved`;function b(e){window.dispatchEvent(new CustomEvent(y,{detail:e}))}function x(e){let t=t=>e(t.detail);return window.addEventListener(y,t),()=>window.removeEventListener(y,t)}var S=new Set,C=(e,t)=>`${e}\u0000${t}`;function w(e,t){S.add(C(e,t)),_()}function T(e,t){S.delete(C(e,t))&&_()}var E=new Map;function D(e,t){let n=C(e,t);E.set(n,(E.get(n)??0)+1),_()}function O(e,t){let n=C(e,t),r=E.get(n);r!==void 0&&(r<=1?E.delete(n):E.set(n,r-1),_())}function k(e,t){return E.has(C(e,t))}function A(){return[...E.keys()].sort().join(``)}function j(e,t){return S.has(C(e,t))}function M(e){return S.size===0?e:e.filter(e=>!S.has(C(e.scope,e.name)))}export{l as _,c as a,v as b,_ as c,O as d,o as f,f as g,A as h,d as i,m as l,k as m,w as n,i as o,j as p,D as r,b as s,M as t,T as u,a as v,h as x,x as y};
1
+ import{A as e}from"./dist-As2x8uCt.js";var t=`open-knowledge:documents-changed`,n=new Set(e.options);function r(e){return e===void 0||!Array.isArray(e)?[`files`]:[...new Set(e.filter(e=>n.has(e)))]}function i(e=[`files`]){window.dispatchEvent(new CustomEvent(t,{detail:{channels:r(e)}}))}function a(e){let n=t=>{e(r(t instanceof CustomEvent?t.detail?.channels:void 0))};return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}function o(e){return e.includes(`local-targets`)||e.includes(`files`)}var s=`open-knowledge:doc-persisted`;function c(e){window.dispatchEvent(new CustomEvent(s,{detail:{docName:e}}))}function l(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail?.docName;typeof n==`string`&&n.length>0&&e(n)};return window.addEventListener(s,t),()=>window.removeEventListener(s,t)}var u=`open-knowledge:branch-changed`;function d(e){window.dispatchEvent(new CustomEvent(u,{detail:{branch:e}}))}function f(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail;e(n?.branch??null)};return window.addEventListener(u,t),()=>window.removeEventListener(u,t)}var p=`open-knowledge:templates-changed`;function m(){window.dispatchEvent(new CustomEvent(p))}function h(e){let t=()=>e();return window.addEventListener(p,t),()=>window.removeEventListener(p,t)}var g=`open-knowledge:skills-changed`;function _(){window.dispatchEvent(new CustomEvent(g))}function v(e){let t=()=>e();return window.addEventListener(g,t),()=>window.removeEventListener(g,t)}var y=`open-knowledge:skill-scope-moved`;function b(e){window.dispatchEvent(new CustomEvent(y,{detail:e}))}function x(e){let t=t=>e(t.detail);return window.addEventListener(y,t),()=>window.removeEventListener(y,t)}var S=new Set,C=(e,t)=>`${e}\u0000${t}`;function w(e,t){S.add(C(e,t)),_()}function T(e,t){S.delete(C(e,t))&&_()}var E=new Map;function D(e,t){let n=C(e,t);E.set(n,(E.get(n)??0)+1),_()}function O(e,t){let n=C(e,t),r=E.get(n);r!==void 0&&(r<=1?E.delete(n):E.set(n,r-1),_())}function k(e,t){return E.has(C(e,t))}function A(){return[...E.keys()].sort().join(``)}function j(e,t){return S.has(C(e,t))}function M(e){return S.size===0?e:e.filter(e=>!S.has(C(e.scope,e.name)))}export{l as _,c as a,v as b,_ as c,O as d,o as f,f as g,A as h,d as i,m as l,k as m,w as n,i as o,j as p,D as r,b as s,M as t,T as u,a as v,h as x,x as y};
@@ -1 +1 @@
1
- import{Ds as e,Ns as t,Os as n,js as r}from"./dist-D1GzYuCD.js";import{d as i,f as a,p as o}from"./doc-paths-ByyIE836.js";import{c as s}from"./page-list-cache-D2OX_WDU.js";import{c,l,s as u}from"./file-tree-utils-Jz2v-e9t.js";import{t as d}from"./file-tree-rename-validation-B5TvPsC_.js";var f=`application/x-open-knowledge-sidebar-item+json`,p={image:!0,video:!0,audio:!0,pdf:!0,text:!0,mermaid:!0,excalidraw:!0};function m(e){return JSON.stringify(e)}function h(e){return e?Array.from(e.types).includes(f):!1}function ee(e){return e.kind===`folder`?{target:{kind:`folder`,target:e.folderPath,folderPath:e.folderPath},hash:o(e.folderPath)}:e.kind===`asset`?{target:{kind:`asset`,target:e.assetPath,assetPath:e.assetPath,mediaKind:e.mediaKind},hash:i(e.assetPath)}:{target:s(e.docName,e.size)??{kind:`doc`,target:e.docName,docName:e.docName},hash:a(e.docName)}}function g(e){if(!e||!h(e))return null;let t=e.getData(f);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!_(n)||n.v!==1||typeof n.kind!=`string`)return null;if(n.kind===`doc`){if(typeof n.docName!=`string`||n.docName.length===0)return null;let e=n.size;return e!==null&&typeof e!=`number`?null:{v:1,kind:`doc`,docName:n.docName,size:e}}if(n.kind===`folder`)return typeof n.folderPath==`string`?{v:1,kind:`folder`,folderPath:n.folderPath}:null;if(n.kind===`asset`){if(typeof n.assetPath!=`string`||n.assetPath.length===0)return null;let e=n.mediaKind;return e!==null&&!v(e)?null:{v:1,kind:`asset`,assetPath:n.assetPath,mediaKind:e}}return null}function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function v(e){return typeof e==`string`&&Object.hasOwn(p,e)}var y=`.md`,b=/\.(md|mdx)$/i;function x(t,i=y){return b.test(t)||r(t)||n(t)||e(t)?t:`${t}${i}`}function S(e){return $(e).replace(b,``)}function C(e,t){let n=$(e),r=k(t),i=t.find(e=>c(e)&&A(e,r)===n)??t.find(e=>c(e)&&T(e)===n);if(i)return i.docName;let a=S(n);return t.find(e=>{let t=T(e);return t!==n&&b.test(t)&&S(t)===a})&&b.test(n)?n:a}function w(e,t){let n=k(t);return t.find(t=>A(t,n)===e)??t.find(t=>T(t)===e)}function T(e){return l(e)?O(e.path):u(e)?e.path:x(e.docName,e.docExt)}function E(e){let t=$(e).match(b);return t?`.${t[1].toLowerCase()}`:void 0}function D(e){return $(e)}function O(e){let t=$(e.trim());return t?`${t}/`:``}function te(e){return e.endsWith(`/`)?D(e):S(e)}function k(e){let t=new Map;for(let n of e){if(!c(n))continue;let e=n.docName.match(b);if(!e)continue;let r=n.docName.slice(0,-e[0].length),i=t.get(r);i?i.add(e[0]):t.set(r,new Set([e[0]]))}return t}function A(e,t){let n=T(e);if(!c(e))return n;let r=e.docName.match(b);if(!r)return n;let i=e.docName.slice(0,-r[0].length);return(t.get(i)?.size??0)>1?n:`${e.docName}${e.docExt??y}`}function j(e){let t=k(e),n=new Set,r=[];for(let i of e){let e=A(i,t);n.has(e)||(n.add(e),r.push(e))}return r}function M(e){return[...e].sort().join(`\0`)}function N(e){return M(j(e))}function P(e,t={}){let n=new Set;for(let r of e){let e=(l(r)||u(r)?r.path:r.docName).split(`/`).filter(Boolean);if(!t.includeOkFolders&&e.includes(`.ok`))continue;if(l(r)){let e=O(r.path);e&&n.add(e)}let i=l(r)?e.length:e.length-1;for(let t=1;t<=i;t++)n.add(`${e.slice(0,t).join(`/`)}/`)}return[...n].sort()}function F(e){if(!e)return[];let t=$(e.replace(b,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function I(e,t,n){let r=E(e);if(r)return r;let i=n.find(e=>c(e)&&e.docName===t);return i?i.docExt??y:Q(e).includes(`.`)?void 0:y}function L(e,t){let n=e.lastIndexOf(`/`),r=n===-1?``:e.slice(0,n+1),i=n===-1?e:e.slice(n+1),a=t.filter(e=>{if(!u(e)||!e.path.startsWith(r))return!1;let t=e.path.slice(r.length);return!t.includes(`/`)&&t.startsWith(`${i}.`)});return a.length===1?a[0].path:null}function R(e,t,n){if(E(e))return null;let r=n.find(e=>u(e)&&e.path===t);return r?r.path:Q(e).includes(`.`)?t:L(t,n)}function z(e,t){let n=e.kind===`directory`,r=n?D(e.path):C(e.path,t);if(n)return{kind:`folder`,name:$(Q(e.path)).replace(b,``),path:r,treePath:V(e.path,!0)};let i=R(e.path,r,t);if(i)return{kind:`asset`,name:$(Q(i)),path:i,treePath:i};let a=I(e.path,r,t);return{kind:`file`,name:$(Q(e.path)).replace(b,``),path:r,treePath:V(e.path,!1),docExt:a}}function B(e){return e.kind===`directory`?D(e.path):e.path}function V(e,t){return t?O(e):b.test(e)?e:`${e}${y}`}function H(e,t,n){let r=O(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${y}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function U(e,t){return e===`file`?V(t,!1):`${D(t)}/index${y}`}function W(e,t){return t.kind===`root`||t.directoryPath==null?Q(e):`${t.directoryPath}${Q(e)}`}function G(e,t){if(t)return D(O(e));let n=S(e),r=n.lastIndexOf(`/`);return r===-1?``:n.slice(0,r)}function K(e,t){let n=D(O(e));return n?`${n}/${t}`:t}function q(e,t,n){e.append(`parentDocName`,K(t,n)),e.append(`placement`,`parent-dir`)}function J(e,t){return(t.path??K(e,t.src)).replace(/^\/+/,``)}function Y(e){let t=e.dataTransfer?.types;if(!t)return!1;let n=Array.from(t);return n.includes(`Files`)&&!n.includes(`application/x-open-knowledge-sidebar-item+json`)}function X(e){return Array.from(e.dataTransfer?.files??[]).filter(e=>e.name.length>0||e.size>0)}function Z(e,n){let r=d(e).toLowerCase();if(r===``)return null;let i=new Date().toISOString();if(r===`.md`||r===`.mdx`)return{kind:`document`,docName:S(e),docExt:r,modified:i,size:n.size};let a=r.startsWith(`.`)?r.slice(1):r;return{kind:`asset`,path:e,assetExt:a,mediaKind:t(a),modified:i,size:n.size}}function Q(e){let t=$(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function $(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{g as A,z as C,f as D,J as E,h as O,C as S,te as T,G as _,U as a,D as b,j as c,T as d,X as f,V as g,Y as h,W as i,m as j,ee as k,N as l,O as m,P as n,H as o,w as p,F as r,x as s,q as t,Z as u,B as v,M as w,S as x,L as y};
1
+ import{Ds as e,Ns as t,Os as n,js as r}from"./dist-As2x8uCt.js";import{d as i,f as a,p as o}from"./doc-paths-BkNaaTOB.js";import{c as s}from"./page-list-cache-AR7XhC2q.js";import{c,l,s as u}from"./file-tree-utils-Cy2QEG_5.js";import{t as d}from"./file-tree-rename-validation-B5TvPsC_.js";var f=`application/x-open-knowledge-sidebar-item+json`,p={image:!0,video:!0,audio:!0,pdf:!0,text:!0,mermaid:!0,excalidraw:!0};function m(e){return JSON.stringify(e)}function h(e){return e?Array.from(e.types).includes(f):!1}function ee(e){return e.kind===`folder`?{target:{kind:`folder`,target:e.folderPath,folderPath:e.folderPath},hash:o(e.folderPath)}:e.kind===`asset`?{target:{kind:`asset`,target:e.assetPath,assetPath:e.assetPath,mediaKind:e.mediaKind},hash:i(e.assetPath)}:{target:s(e.docName,e.size)??{kind:`doc`,target:e.docName,docName:e.docName},hash:a(e.docName)}}function g(e){if(!e||!h(e))return null;let t=e.getData(f);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!_(n)||n.v!==1||typeof n.kind!=`string`)return null;if(n.kind===`doc`){if(typeof n.docName!=`string`||n.docName.length===0)return null;let e=n.size;return e!==null&&typeof e!=`number`?null:{v:1,kind:`doc`,docName:n.docName,size:e}}if(n.kind===`folder`)return typeof n.folderPath==`string`?{v:1,kind:`folder`,folderPath:n.folderPath}:null;if(n.kind===`asset`){if(typeof n.assetPath!=`string`||n.assetPath.length===0)return null;let e=n.mediaKind;return e!==null&&!v(e)?null:{v:1,kind:`asset`,assetPath:n.assetPath,mediaKind:e}}return null}function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function v(e){return typeof e==`string`&&Object.hasOwn(p,e)}var y=`.md`,b=/\.(md|mdx)$/i;function x(t,i=y){return b.test(t)||r(t)||n(t)||e(t)?t:`${t}${i}`}function S(e){return $(e).replace(b,``)}function C(e,t){let n=$(e),r=k(t),i=t.find(e=>c(e)&&A(e,r)===n)??t.find(e=>c(e)&&T(e)===n);if(i)return i.docName;let a=S(n);return t.find(e=>{let t=T(e);return t!==n&&b.test(t)&&S(t)===a})&&b.test(n)?n:a}function w(e,t){let n=k(t);return t.find(t=>A(t,n)===e)??t.find(t=>T(t)===e)}function T(e){return l(e)?O(e.path):u(e)?e.path:x(e.docName,e.docExt)}function E(e){let t=$(e).match(b);return t?`.${t[1].toLowerCase()}`:void 0}function D(e){return $(e)}function O(e){let t=$(e.trim());return t?`${t}/`:``}function te(e){return e.endsWith(`/`)?D(e):S(e)}function k(e){let t=new Map;for(let n of e){if(!c(n))continue;let e=n.docName.match(b);if(!e)continue;let r=n.docName.slice(0,-e[0].length),i=t.get(r);i?i.add(e[0]):t.set(r,new Set([e[0]]))}return t}function A(e,t){let n=T(e);if(!c(e))return n;let r=e.docName.match(b);if(!r)return n;let i=e.docName.slice(0,-r[0].length);return(t.get(i)?.size??0)>1?n:`${e.docName}${e.docExt??y}`}function j(e){let t=k(e),n=new Set,r=[];for(let i of e){let e=A(i,t);n.has(e)||(n.add(e),r.push(e))}return r}function M(e){return[...e].sort().join(`\0`)}function N(e){return M(j(e))}function P(e,t={}){let n=new Set;for(let r of e){let e=(l(r)||u(r)?r.path:r.docName).split(`/`).filter(Boolean);if(!t.includeOkFolders&&e.includes(`.ok`))continue;if(l(r)){let e=O(r.path);e&&n.add(e)}let i=l(r)?e.length:e.length-1;for(let t=1;t<=i;t++)n.add(`${e.slice(0,t).join(`/`)}/`)}return[...n].sort()}function F(e){if(!e)return[];let t=$(e.replace(b,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function I(e,t,n){let r=E(e);if(r)return r;let i=n.find(e=>c(e)&&e.docName===t);return i?i.docExt??y:Q(e).includes(`.`)?void 0:y}function L(e,t){let n=e.lastIndexOf(`/`),r=n===-1?``:e.slice(0,n+1),i=n===-1?e:e.slice(n+1),a=t.filter(e=>{if(!u(e)||!e.path.startsWith(r))return!1;let t=e.path.slice(r.length);return!t.includes(`/`)&&t.startsWith(`${i}.`)});return a.length===1?a[0].path:null}function R(e,t,n){if(E(e))return null;let r=n.find(e=>u(e)&&e.path===t);return r?r.path:Q(e).includes(`.`)?t:L(t,n)}function z(e,t){let n=e.kind===`directory`,r=n?D(e.path):C(e.path,t);if(n)return{kind:`folder`,name:$(Q(e.path)).replace(b,``),path:r,treePath:V(e.path,!0)};let i=R(e.path,r,t);if(i)return{kind:`asset`,name:$(Q(i)),path:i,treePath:i};let a=I(e.path,r,t);return{kind:`file`,name:$(Q(e.path)).replace(b,``),path:r,treePath:V(e.path,!1),docExt:a}}function B(e){return e.kind===`directory`?D(e.path):e.path}function V(e,t){return t?O(e):b.test(e)?e:`${e}${y}`}function H(e,t,n){let r=O(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${y}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function U(e,t){return e===`file`?V(t,!1):`${D(t)}/index${y}`}function W(e,t){return t.kind===`root`||t.directoryPath==null?Q(e):`${t.directoryPath}${Q(e)}`}function G(e,t){if(t)return D(O(e));let n=S(e),r=n.lastIndexOf(`/`);return r===-1?``:n.slice(0,r)}function K(e,t){let n=D(O(e));return n?`${n}/${t}`:t}function q(e,t,n){e.append(`parentDocName`,K(t,n)),e.append(`placement`,`parent-dir`)}function J(e,t){return(t.path??K(e,t.src)).replace(/^\/+/,``)}function Y(e){let t=e.dataTransfer?.types;if(!t)return!1;let n=Array.from(t);return n.includes(`Files`)&&!n.includes(`application/x-open-knowledge-sidebar-item+json`)}function X(e){return Array.from(e.dataTransfer?.files??[]).filter(e=>e.name.length>0||e.size>0)}function Z(e,n){let r=d(e).toLowerCase();if(r===``)return null;let i=new Date().toISOString();if(r===`.md`||r===`.mdx`)return{kind:`document`,docName:S(e),docExt:r,modified:i,size:n.size};let a=r.startsWith(`.`)?r.slice(1):r;return{kind:`asset`,path:e,assetExt:a,mediaKind:t(a),modified:i,size:n.size}}function Q(e){let t=$(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function $(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{g as A,z as C,f as D,J as E,h as O,C as S,te as T,G as _,U as a,D as b,j as c,T as d,X as f,V as g,Y as h,W as i,m as j,ee as k,N as l,O as m,P as n,H as o,w as p,F as r,x as s,q as t,Z as u,B as v,M as w,S as x,L as y};
@@ -1 +1 @@
1
- import{$r as e,No as t,qr as n}from"./dist-D1GzYuCD.js";function r(e){return e.kind===`asset`}function i(e){return e.kind===`document`}function a(e){return e.kind===`folder`}function o(e){let t=[],n=0;for(let r of e)switch(r.kind){case`document`:if(r.docName===void 0){n+=1;break}t.push({kind:`document`,docName:r.docName,docExt:r.docExt,size:r.size,modified:r.modified,isSymlink:r.isSymlink,canonicalDocName:r.canonicalDocName,targetPath:r.targetPath});break;case`asset`:if(r.path===void 0||r.assetExt===void 0){n+=1;break}t.push({kind:`asset`,path:r.path,assetExt:r.assetExt,mediaKind:r.mediaKind??null,size:r.size,modified:r.modified,referencedBy:r.referencedBy});break;case`file`:if(r.path===void 0){n+=1;break}t.push({kind:`asset`,path:r.path,assetExt:r.assetExt??s(r.path),mediaKind:null,size:r.size,modified:r.modified,referencedBy:[]});break;case`folder`:if(r.path===void 0){n+=1;break}t.push({kind:`folder`,path:r.path,size:r.size,modified:r.modified,hasChildren:r.hasChildren,isSymlink:r.isSymlink,targetPath:r.targetPath});break;default:r.kind;break}return n>0&&console.warn(`[file-tree-utils] dropped ${n} listing entries missing variant identity fields`),t}function s(e){let t=e.includes(`/`)?e.split(`/`).pop()??e:e,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?t.slice(n+1).toLowerCase():t.startsWith(`.`)&&t.length>1?t.slice(1).toLowerCase():`file`}function c(e){if(!e)return[];let t=e.split(`/`).filter(Boolean),n=[];for(let e=1;e<t.length;e++)n.push(t.slice(0,e).join(`/`));return n}function l(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t>0?e.slice(0,t):``}function u(e){return e.split(`/`).some(e=>e.toLowerCase()===`.ok`)}function d(e,t){return t&&e!==`document`&&e!==`folder`}function f(e,t){return!t&&n(e)}function p(t,r={}){let{showHiddenFiles:i=!1,showOnlyMarkdownFiles:a=!1,showOkFolders:o=!1}=r;return t.filter(t=>{let r=t.docName??t.path??``;if(r===``||d(t.kind,a))return!1;let s=r.split(`/`),c=s.indexOf(`.ok`);if(c!==-1){if(!o)return!1;let e=s.slice(0,c).join(`/`);return i||e===``||!n(e)}return e(r)?!1:!f(r,i)})}function m(n,r={}){let{showHiddenFiles:i=!1,showOnlyMarkdownFiles:a=!1}=r,o=n.docName??n.path??``;return o===``||t(o)||e(o)||u(o)?{hiddenFiles:!1,onlyMarkdownFiles:!1}:{hiddenFiles:f(o,i),onlyMarkdownFiles:d(n.kind,a)}}function h(e){let{visibility:t={},unfilteredRootEntryCount:n,knownPageCount:r}=e;return(n>0||r>0)&&(t.showOnlyMarkdownFiles??!1)?`filtered-to-zero`:`true-empty`}export{p as a,i as c,o as d,l as i,a as l,h as n,u as o,c as r,r as s,m as t,s as u};
1
+ import{$r as e,No as t,qr as n}from"./dist-As2x8uCt.js";function r(e){return e.kind===`asset`}function i(e){return e.kind===`document`}function a(e){return e.kind===`folder`}function o(e){let t=[],n=0;for(let r of e)switch(r.kind){case`document`:if(r.docName===void 0){n+=1;break}t.push({kind:`document`,docName:r.docName,docExt:r.docExt,size:r.size,modified:r.modified,isSymlink:r.isSymlink,canonicalDocName:r.canonicalDocName,targetPath:r.targetPath});break;case`asset`:if(r.path===void 0||r.assetExt===void 0){n+=1;break}t.push({kind:`asset`,path:r.path,assetExt:r.assetExt,mediaKind:r.mediaKind??null,size:r.size,modified:r.modified,referencedBy:r.referencedBy});break;case`file`:if(r.path===void 0){n+=1;break}t.push({kind:`asset`,path:r.path,assetExt:r.assetExt??s(r.path),mediaKind:null,size:r.size,modified:r.modified,referencedBy:[]});break;case`folder`:if(r.path===void 0){n+=1;break}t.push({kind:`folder`,path:r.path,size:r.size,modified:r.modified,hasChildren:r.hasChildren,isSymlink:r.isSymlink,targetPath:r.targetPath});break;default:r.kind;break}return n>0&&console.warn(`[file-tree-utils] dropped ${n} listing entries missing variant identity fields`),t}function s(e){let t=e.includes(`/`)?e.split(`/`).pop()??e:e,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?t.slice(n+1).toLowerCase():t.startsWith(`.`)&&t.length>1?t.slice(1).toLowerCase():`file`}function c(e){if(!e)return[];let t=e.split(`/`).filter(Boolean),n=[];for(let e=1;e<t.length;e++)n.push(t.slice(0,e).join(`/`));return n}function l(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t>0?e.slice(0,t):``}function u(e){return e.split(`/`).some(e=>e.toLowerCase()===`.ok`)}function d(e,t){return t&&e!==`document`&&e!==`folder`}function f(e,t){return!t&&n(e)}function p(t,r={}){let{showHiddenFiles:i=!1,showOnlyMarkdownFiles:a=!1,showOkFolders:o=!1}=r;return t.filter(t=>{let r=t.docName??t.path??``;if(r===``||d(t.kind,a))return!1;let s=r.split(`/`),c=s.indexOf(`.ok`);if(c!==-1){if(!o)return!1;let e=s.slice(0,c).join(`/`);return i||e===``||!n(e)}return e(r)?!1:!f(r,i)})}function m(n,r={}){let{showHiddenFiles:i=!1,showOnlyMarkdownFiles:a=!1}=r,o=n.docName??n.path??``;return o===``||t(o)||e(o)||u(o)?{hiddenFiles:!1,onlyMarkdownFiles:!1}:{hiddenFiles:f(o,i),onlyMarkdownFiles:d(n.kind,a)}}function h(e){let{visibility:t={},unfilteredRootEntryCount:n,knownPageCount:r}=e;return(n>0||r>0)&&(t.showOnlyMarkdownFiles??!1)?`filtered-to-zero`:`true-empty`}export{p as a,i as c,o as d,l as i,a as l,h as n,u as o,c as r,r as s,m as t,s as u};
@@ -1 +1 @@
1
- import{l as e}from"./documents-events-DPqTvBXn.js";import{t}from"./parse-api-error-Dd8VI2eu.js";import{t as n}from"./createLucideIcon-BulbvLvN.js";var r=n(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]);async function i(e){return t(await e.json().catch(()=>null))??`HTTP ${e.status}`}async function a(e,t){try{let n=await fetch(`/api/folder-config`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e,frontmatter:t})});return n.ok?{ok:!0}:{ok:!1,error:await i(n)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function o(t){try{let n=await fetch(`/api/template`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)return{ok:!1,error:await i(n)};let r=await n.json().catch(()=>null);return e(),{ok:!0,created:r?.created??!1,warnings:r?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function s(t,n){try{let r=`?folder=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}`,a=await fetch(`/api/template${r}`,{method:`DELETE`});if(!a.ok)return{ok:!1,error:await i(a)};let o=await a.json().catch(()=>null);return e(),{ok:!0,existed:o?.existed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function c(t){try{let n=await fetch(`/api/template`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)return{ok:!1,error:await i(n)};let r=await n.json().catch(()=>null);return e(),{ok:!0,committed:r?.committed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function l(t){try{let n=await fetch(`/api/template/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)return{ok:!1,error:await i(n)};let r=await n.json().catch(()=>null);return e(),{ok:!0,path:r?.path??``,created:r?.created??!1,warnings:r?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}export{o as a,a as i,l as n,r as o,c as r,s as t};
1
+ import{l as e}from"./documents-events-2g_OBjKU.js";import{t}from"./parse-api-error-Dd8VI2eu.js";import{t as n}from"./createLucideIcon-BulbvLvN.js";var r=n(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]);async function i(e){return t(await e.json().catch(()=>null))??`HTTP ${e.status}`}async function a(e,t){try{let n=await fetch(`/api/folder-config`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e,frontmatter:t})});return n.ok?{ok:!0}:{ok:!1,error:await i(n)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function o(t){try{let n=await fetch(`/api/template`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)return{ok:!1,error:await i(n)};let r=await n.json().catch(()=>null);return e(),{ok:!0,created:r?.created??!1,warnings:r?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function s(t,n){try{let r=`?folder=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}`,a=await fetch(`/api/template${r}`,{method:`DELETE`});if(!a.ok)return{ok:!1,error:await i(a)};let o=await a.json().catch(()=>null);return e(),{ok:!0,existed:o?.existed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function c(t){try{let n=await fetch(`/api/template`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)return{ok:!1,error:await i(n)};let r=await n.json().catch(()=>null);return e(),{ok:!0,committed:r?.committed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function l(t){try{let n=await fetch(`/api/template/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)return{ok:!1,error:await i(n)};let r=await n.json().catch(()=>null);return e(),{ok:!0,path:r?.path??``,created:r?.created??!1,warnings:r?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}export{o as a,a as i,l as n,r as o,c as r,s as t};
@@ -0,0 +1 @@
1
+ import"./dist-As2x8uCt.js";import{t as e}from"./dist-Cr4-nBVI.js";import{t}from"./messages-B2mYVhA4.js";e.load(`en`,t.messages),e.activate(`en`);