@inkeep/open-knowledge 0.83.0-beta.5 → 0.83.0-beta.7

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 (183) hide show
  1. package/dist/assets/skills/project/references/linking.md +1 -1
  2. package/dist/cli.mjs +60 -60
  3. package/dist/constants-CCYsBRvI.mjs +1 -0
  4. package/dist/dist-DMhyZWXW.mjs +2198 -0
  5. package/dist/{dist-ByQ8IZXo.mjs → dist-ObUBLmuL.mjs} +1 -1
  6. package/dist/index.d.mts +7 -0
  7. package/dist/index.mjs +236 -234
  8. package/dist/{init-CrjTf1pi.mjs → init-B4K69pZS.mjs} +36 -36
  9. package/dist/init-DORmPVEO.mjs +1 -0
  10. package/dist/{launch-json-removal-BEKplNGY.mjs → launch-json-removal-CT0i-3-W.mjs} +1 -1
  11. package/dist/loader-BQnA36qb.mjs +1 -0
  12. package/dist/{loader-CrmSAWIW.mjs → loader-DZHqBHXr.mjs} +1 -1
  13. package/dist/{md-manager-BGnqyqi1-DsBy1Dky.mjs → md-manager-BGnqyqi1-B1QSgyMJ.mjs} +158 -156
  14. package/dist/{open-browser-CJogphTe.mjs → open-browser-B-7x1MTL.mjs} +1 -1
  15. package/dist/parse-worker.mjs +1 -1
  16. package/dist/preview-BWmm6t1q.mjs +1 -0
  17. package/dist/{preview-B2beHnfh.mjs → preview-BdmlMCtY.mjs} +1 -1
  18. package/dist/public/assets/{AccountSection-Droiytue.js → AccountSection-DJh9iLbq.js} +1 -1
  19. package/dist/public/assets/{ActivityModeContent-CbnLPTIH.js → ActivityModeContent-BAm_Sv3o.js} +1 -1
  20. package/dist/public/assets/{AddPropertiesButton-KfKILXo9.js → AddPropertiesButton-B1mRaQFw.js} +2 -2
  21. package/dist/public/assets/{AgentConnectionsSection-CJhM0Oqw.js → AgentConnectionsSection-D_gmSJG4.js} +1 -1
  22. package/dist/public/assets/{AgentDiffPane-B0odJ1aT.js → AgentDiffPane-rX7T_Ooo.js} +1 -1
  23. package/dist/public/assets/{AttachmentsSection-Mw0-ZVyb.js → AttachmentsSection-FLGDe3pX.js} +1 -1
  24. package/dist/public/assets/{AuthModal-DcixDUcD.js → AuthModal-CkHLmy_N.js} +1 -1
  25. package/dist/public/assets/CodeMirrorPropInput-BuFeADVI.js +166 -0
  26. package/dist/public/assets/{ContentRulesSection-Bss4zUDP.js → ContentRulesSection-DZmyRVa0.js} +1 -1
  27. package/dist/public/assets/{DiffViewBoundary-B5VRWFoq.js → DiffViewBoundary-BVzts2c4.js} +1 -1
  28. package/dist/public/assets/DocumentContext-C8ape_2m.js +108 -0
  29. package/dist/public/assets/{EditorModeToggle-DPAypJvm.js → EditorModeToggle-DS_xfOtT.js} +1 -1
  30. package/dist/public/assets/{ExcalidrawDocEditor-C_j2ekRK.js → ExcalidrawDocEditor-DWd6a8Sl.js} +1 -1
  31. package/dist/public/assets/FeedbackForm-MbJXUGuy.js +1 -0
  32. package/dist/public/assets/{GraphPanel-ZgCaGJ14.js → GraphPanel-COpuyFxT.js} +1 -1
  33. package/dist/public/assets/{ImageAttachments-ChGavHQ_.js → ImageAttachments-By1ZcRNT.js} +1 -1
  34. package/dist/public/assets/{ImportSkillDialog-CYgy5v1q.js → ImportSkillDialog-C2_Su5XJ.js} +1 -1
  35. package/dist/public/assets/{LinkPreviewsSection-uXIP-dp3.js → LinkPreviewsSection-ChJ4iMSL.js} +1 -1
  36. package/dist/public/assets/{LintConfigEditor-BFYDnPot.js → LintConfigEditor-BbSzjMFm.js} +1 -1
  37. package/dist/public/assets/LintingSection-4HBYSeJr.js +1 -0
  38. package/dist/public/assets/{ManagedArtifactProperties-oK6vCr7C.js → ManagedArtifactProperties-2ky67bIe.js} +1 -1
  39. package/dist/public/assets/ManagedArtifactProperties-CatYQWAb.js +1 -0
  40. package/dist/public/assets/{MermaidDocEditor-7zbWvNHd.js → MermaidDocEditor-CA7gNCDw.js} +1 -1
  41. package/dist/public/assets/{NetworkAccessSection-Bn8H6wuf.js → NetworkAccessSection-OcPnmrqG.js} +1 -1
  42. package/dist/public/assets/{OkignoreSection-B6lKSJGD.js → OkignoreSection-DUIPj4Vl.js} +1 -1
  43. package/dist/public/assets/PageListContext-CYKNvec7.js +1 -0
  44. package/dist/public/assets/{ProjectTemplatesSection-Cf5bgyHk.js → ProjectTemplatesSection-Ctdx9_AL.js} +1 -1
  45. package/dist/public/assets/{PropertyDisplayRow-DtQD10NU.js → PropertyDisplayRow-BvC-5Aoc.js} +1 -1
  46. package/dist/public/assets/{PublishToGitHubDialog-Bi_yfoyq.js → PublishToGitHubDialog-BAs3Rgt6.js} +1 -1
  47. package/dist/public/assets/{RegisteredAgentIcon-jysj1Acv.js → RegisteredAgentIcon-Begcc-nC.js} +1 -1
  48. package/dist/public/assets/{ReportBugDialogBody-CW-yLP7E.js → ReportBugDialogBody-CPjEs_zr.js} +1 -1
  49. package/dist/public/assets/{ReportBugMenuTrigger-D2RpbMHk.js → ReportBugMenuTrigger-DwuaKFu1.js} +1 -1
  50. package/dist/public/assets/{SchemaConfigEditor-CmvHbYD0.js → SchemaConfigEditor-_iycEDNg.js} +1 -1
  51. package/dist/public/assets/{SearchSection-NRyXWfQ3.js → SearchSection-BXFLBgQF.js} +1 -1
  52. package/dist/public/assets/{SessionsHost-Cc2oV3dV.js → SessionsHost-YR8a-CBs.js} +2 -2
  53. package/dist/public/assets/{SettingsDialogBody-CWnpUal4.js → SettingsDialogBody-FXTDyHIp.js} +2 -2
  54. package/dist/public/assets/{ShareReceiveMissDialog-ChcdZosR.js → ShareReceiveMissDialog-D0feG-ij.js} +1 -1
  55. package/dist/public/assets/{SkillCostValue-Bgy3wkjV.js → SkillCostValue-Bajv3P86.js} +1 -1
  56. package/dist/public/assets/{SkillForkDialog-CwCSC6Z0.js → SkillForkDialog-BKGY1iRx.js} +1 -1
  57. package/dist/public/assets/{SkillInstallMenu-BIs2wAUZ.js → SkillInstallMenu-CuOKJ4_n.js} +1 -1
  58. package/dist/public/assets/{SkillOriginInline-Dr1zcAGa.js → SkillOriginInline-BrUb4Fgy.js} +1 -1
  59. package/dist/public/assets/{SkillToolbarControls-BXSkUGmd.js → SkillToolbarControls-BOtPYfa8.js} +1 -1
  60. package/dist/public/assets/{SkillsManagerSection-CiaThXM_.js → SkillsManagerSection-dqXRCM3C.js} +1 -1
  61. package/dist/public/assets/{SlidesToolbarControls-BpGxFSJu.js → SlidesToolbarControls-D-0pa5F-.js} +1 -1
  62. package/dist/public/assets/{SourceEditor-AolrPcnF.js → SourceEditor-ZhZtt3fQ.js} +1 -1
  63. package/dist/public/assets/{SpellingSettings-Bp5WJ0V7.js → SpellingSettings-DaGy2fT9.js} +1 -1
  64. package/dist/public/assets/{SyncSection-DN4BNjYi.js → SyncSection-B17cmijr.js} +1 -1
  65. package/dist/public/assets/{SyncStatusBadge-BO6CFavL.js → SyncStatusBadge-DckHbstF.js} +1 -1
  66. package/dist/public/assets/{TemplateRow-Bj4hpJ-E.js → TemplateRow-C8tLmbrb.js} +1 -1
  67. package/dist/public/assets/{TerminalLaunchContext-kR8NUVFa.js → TerminalLaunchContext-58PQDilg.js} +1 -1
  68. package/dist/public/assets/{TerminalPanel-CBpH9VnO.js → TerminalPanel-DOYDhObX.js} +1 -1
  69. package/dist/public/assets/{TerminalSection-DnexOFJv.js → TerminalSection-CWS2W27g.js} +1 -1
  70. package/dist/public/assets/{TerminalWindowApp-CYOc89Z0.js → TerminalWindowApp-0S4powU1.js} +1 -1
  71. package/dist/public/assets/{TextDocEditor-DcTmh_sa.js → TextDocEditor-DIsBDCjZ.js} +1 -1
  72. package/dist/public/assets/{ThemePluginSection-DOCAYKOj.js → ThemePluginSection-0b67foiM.js} +1 -1
  73. package/dist/public/assets/{ThreadView-H4YeUz_6.js → ThreadView-KbVr8sEz.js} +3 -3
  74. package/dist/public/assets/{TimelineDiffPane-DBRzt5of.js → TimelineDiffPane-PhDxCy33.js} +1 -1
  75. package/dist/public/assets/{agent-connections-BmjcmCOh.js → agent-connections-Bc1t_U_m.js} +1 -1
  76. package/dist/public/assets/{agent-registry--47SG0kt.js → agent-registry-3ko3YkCm.js} +1 -1
  77. package/dist/public/assets/{bridge-njD5PB6P.js → bridge-BqL-1MyE.js} +1 -1
  78. package/dist/public/assets/{card-BsBNZHzU.js → card-CHd8wMSS.js} +1 -1
  79. package/dist/public/assets/{catalog-DtlAjcAT.js → catalog-nXBoyoEn.js} +1 -1
  80. package/dist/public/assets/{client-version-Bhpi7gms.js → client-version-C-aFlRsC.js} +1 -1
  81. package/dist/public/assets/{comment-chips-CO_v36hx.js → comment-chips-DOajrkhR.js} +3 -3
  82. package/dist/public/assets/{config-provider-DYjwca1V.js → config-provider-Dp4Rfq0I.js} +1 -1
  83. package/dist/public/assets/config-schema-8zesQqFR.js +1 -0
  84. package/dist/public/assets/{css-color-to-hex-vFOfC-Pa.js → css-color-to-hex-Dk3DSeEK.js} +1 -1
  85. package/dist/public/assets/{doc-undo-manager-Dn9t2Iwn.js → doc-undo-manager-ahQPlK9S.js} +1 -1
  86. package/dist/public/assets/field-controls-D4Q9aSAc.js +1 -0
  87. package/dist/public/assets/{field-controls-CAjZIoxe.js → field-controls-c03mLOtp.js} +1 -1
  88. package/dist/public/assets/{file-tree-adapter-B1gVPdEq.js → file-tree-adapter-BeSKxnyg.js} +1 -1
  89. package/dist/public/assets/{frontmatter-tags-B-pVcI4P.js → frontmatter-tags-B7FS--Ga.js} +1 -1
  90. package/dist/public/assets/{index-jj7AN3ys.js → index-CWM5nCtw.js} +11 -11
  91. package/dist/public/assets/{lint-config-client-DRl_GTbs.js → lint-config-client-DBaQUIFB.js} +1 -1
  92. package/dist/public/assets/{lint-plugins-DQC4DG_-.js → lint-plugins-B7BcnvBQ.js} +1 -1
  93. package/dist/public/assets/{markdown-lint-C_9h2J3z.js → markdown-lint-CciVlHiz.js} +1 -1
  94. package/dist/public/assets/{markdownlint-rule-browser-BShldaY9.js → markdownlint-rule-browser-CV8JXarL.js} +1 -1
  95. package/dist/public/assets/messages-7VNu1LEh.js +1 -0
  96. package/dist/public/assets/messages-BoIpsnrB.js +1 -0
  97. package/dist/public/assets/messages-BtoWyWp4.js +1 -0
  98. package/dist/public/assets/messages-CAWZbzxC.js +1 -0
  99. package/dist/public/assets/messages-CGY-qBkm.js +1 -0
  100. package/dist/public/assets/messages-CI6bk3ZZ.js +1 -0
  101. package/dist/public/assets/messages-CKSKVChp.js +1 -0
  102. package/dist/public/assets/messages-CVkIPXvF.js +1 -0
  103. package/dist/public/assets/messages-CpkkpjCc.js +1 -0
  104. package/dist/public/assets/messages-DP2kzUjm.js +1 -0
  105. package/dist/public/assets/messages-DUncwHK7.js +1 -0
  106. package/dist/public/assets/messages-WS5AYLW5.js +1 -0
  107. package/dist/public/assets/messages-yosQwPO3.js +1 -0
  108. package/dist/public/assets/navigation-targets-DTSxcGor.js +1 -0
  109. package/dist/public/assets/{page-list-cache-s0lTSAFU.js → page-list-cache-BNFVKu-D.js} +1 -1
  110. package/dist/public/assets/{pending-receive-nav-store-DIU-Po1C.js → pending-receive-nav-store-Ji-MjcTi.js} +1 -1
  111. package/dist/public/assets/{preferred-session-events-Ayg96deM.js → preferred-session-events-DZS0rMoL.js} +1 -1
  112. package/dist/public/assets/{progress-BpdOUTnu.js → progress-RYUnJ5Yy.js} +4 -4
  113. package/dist/public/assets/{saved-themes-client-BdzXiLZg.js → saved-themes-client-C0V8gWns.js} +1 -1
  114. package/dist/public/assets/{schema-section-AjQemGau.js → schema-section-BEhtY3tq.js} +1 -1
  115. package/dist/public/assets/{schemas-api-C4CP1G39.js → schemas-api-BM3O7zA1.js} +1 -1
  116. package/dist/public/assets/{selection-context-Dj_iPBku.js → selection-context-DFzIaDVr.js} +1 -1
  117. package/dist/public/assets/{skills-api-BUVVp6gv.js → skills-api-Cwv39pKK.js} +1 -1
  118. package/dist/public/assets/{src-CS5ZPUzW.js → src-Cc4wFWWl.js} +1 -1
  119. package/dist/public/assets/storage-scope-67lIepq6.js +1 -0
  120. package/dist/public/assets/{tag-pill-input-BoyxN9pC.js → tag-pill-input-DoehfrBo.js} +1 -1
  121. package/dist/public/assets/{target-navigation-intent-DAN5F8dH.js → target-navigation-intent-D7IZjXLN.js} +1 -1
  122. package/dist/public/assets/{telemetry-impl-m7aO3jDl.js → telemetry-impl-DChsPrpQ.js} +1 -1
  123. package/dist/public/assets/{telemetry-startup-74CCPsgN.js → telemetry-startup-B9nVffXq.js} +1 -1
  124. package/dist/public/assets/{terminal-launch-events-Cy8GAcTt.js → terminal-launch-events-vPUm3fxK.js} +1 -1
  125. package/dist/public/assets/typing-burst-detector-D_B94C2V.js +8 -0
  126. package/dist/public/assets/{uninstall-D609kB1N.js → uninstall-SlWuPbLL.js} +1 -1
  127. package/dist/public/assets/{use-activity-panel-I5AELaRz.js → use-activity-panel-BynfAds7.js} +1 -1
  128. package/dist/public/assets/{use-apply-config-color-theme-lLFWDFMc.js → use-apply-config-color-theme-DsCyuU3O.js} +1 -1
  129. package/dist/public/assets/{use-apply-config-language-C0m8OLaJ.js → use-apply-config-language-CNWS2YSn.js} +2 -2
  130. package/dist/public/assets/{use-conflicts-B0yvUiLf.js → use-conflicts-CpABgIGI.js} +1 -1
  131. package/dist/public/assets/{use-installed-clis-4inF6O-n.js → use-installed-clis-CXwm5pk2.js} +2 -2
  132. package/dist/public/assets/{use-live-xterm-theme-BIzA-mu0.js → use-live-xterm-theme-CkVAs5Ql.js} +1 -1
  133. package/dist/public/assets/{use-open-skill-Bro5-8rY.js → use-open-skill-oBbTNCkY.js} +1 -1
  134. package/dist/public/assets/{use-semantic-search-status-CGPJyDjj.js → use-semantic-search-status-BYu4PoVz.js} +1 -1
  135. package/dist/public/assets/{use-skill-origin-Cv_S5gSq.js → use-skill-origin-Be1NTkgW.js} +1 -1
  136. package/dist/public/assets/{use-skill-targets-D-Tfz8TQ.js → use-skill-targets-Cf23drqO.js} +1 -1
  137. package/dist/public/assets/{use-skills-CRuEYkjM.js → use-skills-gbn1t63C.js} +1 -1
  138. package/dist/public/assets/{use-terminal-enabled-DASwB3kR.js → use-terminal-enabled-DZ-JhCyV.js} +1 -1
  139. package/dist/public/assets/{use-timeline-entry-diff-DePScbzI.js → use-timeline-entry-diff-3gupsEXJ.js} +2 -2
  140. package/dist/public/assets/{use-workspace-Bf2VHQrp.js → use-workspace-BafUpQnS.js} +1 -1
  141. package/dist/public/index.html +56 -56
  142. package/dist/public/uninstall.html +3 -3
  143. package/dist/{registry-probes-CtY_1ly1.mjs → registry-probes-D6HyJ_8R.mjs} +3 -3
  144. package/dist/{removal-file-path-CNIqq13J.mjs → removal-file-path-DpI99hTo.mjs} +1 -1
  145. package/dist/{repair-launch-json-CJpZgLgO.mjs → repair-launch-json--_R-76cC.mjs} +1 -1
  146. package/dist/{repair-mcp-configs-DlqDZ1Q-.mjs → repair-mcp-configs-CZSnWHtM.mjs} +1 -1
  147. package/dist/src-BrQpMSWu.mjs +11 -0
  148. package/dist/src-CY1smm1s.mjs +1 -0
  149. package/dist/{start-UcVINga1.mjs → start-CDnYOrHP.mjs} +3 -3
  150. package/dist/start-Pg-N_eC0.mjs +1 -0
  151. package/package.json +4 -4
  152. package/dist/constants-DPhkbJXs.mjs +0 -1
  153. package/dist/dist-BHg9XI3A.mjs +0 -2198
  154. package/dist/init-Kw-TosnB.mjs +0 -1
  155. package/dist/loader-CwZvWeL0.mjs +0 -1
  156. package/dist/preview-AWnyLtzP.mjs +0 -1
  157. package/dist/public/assets/CodeMirrorPropInput-CJK_-B_x.js +0 -164
  158. package/dist/public/assets/DocumentContext-Bsl186nT.js +0 -108
  159. package/dist/public/assets/FeedbackForm-CQ0MZzAX.js +0 -1
  160. package/dist/public/assets/LintingSection-CKk0R2XV.js +0 -1
  161. package/dist/public/assets/ManagedArtifactProperties-D4nKksLq.js +0 -1
  162. package/dist/public/assets/PageListContext-OHnhzUbe.js +0 -1
  163. package/dist/public/assets/config-schema-CjObvyCB.js +0 -1
  164. package/dist/public/assets/field-controls-23rf_c2g.js +0 -1
  165. package/dist/public/assets/messages-6qDi59f7.js +0 -1
  166. package/dist/public/assets/messages-BEvT9Nwy.js +0 -1
  167. package/dist/public/assets/messages-BSK33k09.js +0 -1
  168. package/dist/public/assets/messages-BWfEJjWl.js +0 -1
  169. package/dist/public/assets/messages-BlGEL1N1.js +0 -1
  170. package/dist/public/assets/messages-Bq95Bcqm.js +0 -1
  171. package/dist/public/assets/messages-BvpXmuCB.js +0 -1
  172. package/dist/public/assets/messages-Cw5_--PV.js +0 -1
  173. package/dist/public/assets/messages-D456hKdc.js +0 -1
  174. package/dist/public/assets/messages-F1g5PrYW.js +0 -1
  175. package/dist/public/assets/messages-_PYN_xve.js +0 -1
  176. package/dist/public/assets/messages-gEPZ_37y.js +0 -1
  177. package/dist/public/assets/messages-vtPav911.js +0 -1
  178. package/dist/public/assets/navigation-targets-BVafzc0v.js +0 -1
  179. package/dist/public/assets/storage-scope-DRWogX35.js +0 -1
  180. package/dist/public/assets/typing-burst-detector-Clq1sSnx.js +0 -8
  181. package/dist/src-CnRhVti_.mjs +0 -11
  182. package/dist/src-lCnJgf0p.mjs +0 -1
  183. package/dist/start-CIrEb03P.mjs +0 -1
@@ -1 +0,0 @@
1
- import{g as e,h as t,p as n,y as r}from"./constants-upload-CVKO8P4d.js";import{C as i,S as a,_ as o,b as s,d as c,g as l,h as u,m as d,v as f,w as p,x as m,y as h}from"./constants-cc1-Bt4QPTUe.js";import{t as g}from"./doc-extensions-CcO7K8uD-B004ggqh.js";import{r as _}from"./doc-paths-cEiFVCxr.js";import{o as v,r as ee}from"./file-tree-utils-DUpeRMj2.js";var y=524288;function b(e,t=y){return typeof e==`number`&&Number.isFinite(e)&&e>t}var te=10485760,x=/\p{M}+/gu,ne=/[^\p{L}\p{N}]+/gu,re=/^-+|-+$/g;function S(e){return e.trim().normalize(`NFKD`).replace(x,``).toLowerCase().replace(ne,`-`).replace(re,``)}function C(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function w(e,t){let n=S(e);return n?C(n,t):``}function T(e,t){let n=S(e);return t?`#${n}-${S(t)}`:`#${n}`}function E(e){if(!e.includes(`%`))return e;let t;try{t=decodeURIComponent(e)}catch{return e}return t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`)||t.includes(`\0`)?e:t}function ie(e){return e===`.`||e===`..`?e:encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.codePointAt(0)?.toString(16).toUpperCase()}`)}function ae(e){return e.split(`/`).map(ie).join(`/`)}function D(e){return e.split(`/`).map(E).join(`/`)}function O(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),a=r>=0?n.slice(0,r):n,o=r>=0?n.slice(r+1):null,s=(a.split(`?`)[0]??``).trim();if(!s)return null;let c=E(s.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(c){let e=`.${(c[1]??``).toLowerCase()}`;if(!g.includes(e))return null}let l=s.startsWith(`/`),u=l?s.slice(1):s,d=l?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[],f=u.split(`/`),p=f.length-1;for(let e=0;e<f.length;e++){let t=E(f[e]??``);if(e===p&&(t=i(t)),t===`..`){if(d.length===0)return null;d.pop()}else t!==`.`&&t!==``&&d.push(t)}return d.length===0?null:{docName:d.join(`/`),anchor:o||null}}function oe(e){throw Error(`Unhandled ClassifiedLinkTarget variant: ${JSON.stringify(e)}`)}var k=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function A(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function j(e){return e.split(`/`).filter(Boolean)}function M(e){let t=e.trim();return k.test(t)||t.startsWith(`//`)}function se(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(M(n))return{kind:`external`,url:n};let r=n.indexOf(`#`),i=D(r<0?n:n.slice(0,r)),a=h(i,t);if(a)return{kind:`doc`,docName:a,anchor:r<0?null:n.slice(r+1)};let o=s(i,t);if(o)return{kind:`doc`,docName:o,anchor:r<0?null:n.slice(r+1)};let c=O(n,t);if(c)return{kind:`doc`,docName:c.docName,anchor:c.anchor};let l=A(i);return l&&l!==`md`&&l!==`mdx`?{kind:`asset`,url:n,ext:l,literal:!1}:null}function ce(e,t){let n=e.trim();if(!n)return null;if(M(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=A(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r,literal:!0}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function le(e,t,n){let r=e.trim();if(!r||k.test(r)||r.startsWith(`//`)||r.startsWith(`#`))return null;let i=r.indexOf(`#`),a=((i>=0?r.slice(0,i):r).split(`?`)[0]??``).trim();if(!a)return null;let o=a.startsWith(`/`),s=o?a.slice(1):a,c=o?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of s.split(`/`))if(e===`..`){if(c.length===0)return null;c.pop()}else e!==`.`&&e!==``&&c.push(n.literal?e:E(e));return c.length===0?null:c.join(`/`)}function ue(e,t,n=null,r=`.md`){let i=j(e);i.pop();let a=j(t),o=0;for(;o<i.length&&o<a.length&&i[o]===a[o];)o+=1;let s=i.slice(o).map(()=>`..`),c=a.slice(o),l=[...s,...c].join(`/`);return l||=a.at(-1)??t,!l.startsWith(`./`)&&!l.startsWith(`../`)&&(l=`./${l}`),`${ae(l)}${r}${n?`#${n}`:``}`}function N(e){return`pagesBySlug`in e}function P(e){return N(e)?e.pages:e}function F(e,t){return N(e)?e.assetPaths??new Set:t??new Set}function I(e,t){return N(e)?e.filePaths??new Set:t??new Set}function L(e,t){return e<t?-1:+(e>t)}function R(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);e&&(i===void 0||L(r,i)<0)&&n.set(e,r)}return n}function z(e,t){let n=new Map,r=[...e].sort(L);for(let e of r){let r=e.lastIndexOf(`/`),i=t(r===-1?e:e.slice(r+1));i&&!n.has(i)&&n.set(i,e)}return n}function B(e,t){let n=S(e);if(!n)return;if(N(t))return t.pagesBySlug.get(n);let r;for(let e of t)S(e)===n&&(r===void 0||L(e,r)<0)&&(r=e);return r}function V(e,t){if(e.includes(`/`))return;let n=S(e);if(!n)return;if(N(t))return t.pagesByBasename?.get(n);let r;for(let e of t){let t=e.lastIndexOf(`/`);S(t===-1?e:e.slice(t+1))===n&&(r===void 0||L(e,r)<0)&&(r=e)}return r}function H(e){let t=e.trim();if(!t)return[];let n=S(t);return n.length>0&&n!==t?[n]:[]}function U(e,t){let n=e.trim();if(!n)return;if(P(t).has(n))return n;let r=n.replace(/\.(md|mdx)$/i,``);if(r!==n){let e=W(r,t);if(e!==void 0)return e}return W(n,t)}function W(e,t){let n=e.trim();if(!n)return;let r=P(t);if(r.has(n))return n;let i=B(n,t);if(i)return i;for(let e of H(n))if(r.has(e))return e;return de(n,r)||V(n,t)}function de(e,t){let n=`${e}/index`;if(t.has(n))return n;let r=e.lastIndexOf(`/`),i=r===-1?e:e.slice(r+1),a=i?`${e}/${i}`:null;if(a&&t.has(a))return a}function G(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function K(e,t,n){let r=G(e);if(!r)return null;let i=r.toLowerCase(),a=n?[t,n]:[t];for(let e of a){if(e.has(r))return r;for(let t of e)if(t.toLowerCase()===i)return t}if(r.includes(`/`))return null;let o=[];for(let e of a)for(let t of e){let e=t.lastIndexOf(`/`);(e===-1?t:t.slice(e+1)).toLowerCase()===i&&o.push(t)}return o.length===0?null:o.sort(L)[0]??null}function fe(...e){let t=new Set;for(let n of e)for(let e of n){let n=e.toLowerCase();t.add(`path:${n}`),t.add(`basename:${n.slice(n.lastIndexOf(`/`)+1)}`)}return t}function pe(e,t,n,r){let i=e.trim();if(!i)return!1;let a=G(i).toLowerCase(),o=N(t)?t.assetTargetKeys:void 0;if(o!==void 0){if(o.has(`path:${a}`)||!a.includes(`/`)&&o.has(`basename:${a}`))return!0}else if(K(i,F(t,n),I(t,r)))return!0;return U(i,t)!==void 0}function me(e,t,n){let r=ce(e,t);return r===null||r.kind!==`asset`||K(r.url,F(n),I(n))!==null||U(e,n)===void 0?r:{kind:`doc`,docName:e.trim(),anchor:t?.trim()||null}}function he(e){return e.scope===`project`?i(q(e)):a(e.scope,e.name,e.hostQualifier)}function q(e){return e.canonicalPath??e.path}function ge(e,t){return e.scope===`project`?`${q(e).replace(/\/SKILL\.mdx?$/i,``)}/${i(t)}`:m(e.scope,e.name,t,e.hostQualifier)}function J(e){let t=l(e);return t?.kind===`skill`?t.name:null}function Y(e){let t=e.trim();return{normalizedTarget:t.replace(/^\.\/+/,``).replace(/^\/+/,``).replace(/\/+$/g,``),expectsFolder:/\/+$/.test(t)}}function _e(e){return _(e).replace(/\/+$/g,``)}var X=/\.(md|mdx)$/i;function ve(e,t){let{normalizedTarget:n,expectsFolder:r}=Y(e);return r||!X.test(n)||t.has(n)?e:n.replace(X,``)}function Z(e){let t=new Set;for(let n of e)for(let e of ee(n))t.add(e);return t}function ye(e,t){return t?`${e}${t}`:(e.split(`/`).pop()??``).lastIndexOf(`.`)>0?e:`${e}.md`}function Q(t,n){if(!v(t)||o(t)||n.pages.has(t))return null;let r=ye(t,n.docExt);return{kind:`asset`,target:r,assetPath:r,mediaKind:e(r.slice(r.lastIndexOf(`.`)+1))}}function be(e,i){let a=e,s=ve(a,i.pages);if(c(s)){let e=u(s);if(e?.kind===`skill`&&e.scope===`project`){let t=f(e.name);return{kind:`doc`,target:t,docName:t}}let t=d(s);if(t){let e=p(t.folder,t.name);return{kind:`doc`,target:e,docName:e}}return{kind:`doc`,target:s,docName:s}}if(J(s))return{kind:`doc`,target:s,docName:s};let l=o(s);if(l){let e=p(l.folder,l.name);return{kind:`doc`,target:e,docName:e}}let{normalizedTarget:m,expectsFolder:h}=Y(a);if(!m)return{kind:`missing`,target:m};if(!h&&(t(m)||n(m)||r(m)))return{kind:`doc`,target:m,docName:m};let g=_e(a),_=h?void 0:U(m,{pages:i.pages,pagesBySlug:i.pagesBySlug??new Map,pagesByBasename:i.pagesByBasename}),v=h?[g]:[m,g];for(let e of v){let t=`${e}/index`;if(h?i.pages.has(t):_===t)return{kind:`folder-index`,target:e,folderPath:e,docName:t,noteKind:`canonical-index`};let n=e.split(`/`).pop(),r=n?`${e}/${n}`:null;if(r&&(h?i.pages.has(r):_===r))return{kind:`folder-index`,target:e,folderPath:e,docName:r,noteKind:`legacy-folder-note`}}if(_!==void 0)return{kind:`doc`,target:_,docName:_};if((i.folderPaths??Z(i.pages)).has(g))return{kind:`folder`,target:g,folderPath:g};if(!h){let e=Q(m,i);if(e)return e}return{kind:`missing`,target:g||m}}function xe(e){return e.kind===`folder-index`?{kind:`folder`,target:e.folderPath,folderPath:e.folderPath}:e}function $(e,t,n=y){return typeof t!=`number`||!b(t,n)?null:{kind:`large-file`,target:e,docName:e,size:t,limit:n}}function Se(e,t,n=y){return e.kind!==`doc`&&e.kind!==`folder-index`?e:$(e.docName,t.get(e.docName)?.size,n)??e}function Ce(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return e.docName;case`missing`:return e.target;case`asset`:case`skill-file`:case`skills`:case`skill-preview`:case`folder`:return null}}export{te as A,M as C,w as D,O as E,S as O,A as S,D as T,me as _,Q as a,ue as b,J as c,z as d,R as f,K as g,pe as h,$ as i,b as j,T as k,ge as l,H as m,Ce as n,be as o,fe as p,xe as r,Se as s,Z as t,he as u,U as v,le as w,se as x,oe as y};
@@ -1 +0,0 @@
1
- import{o as e}from"./bridge-njD5PB6P.js";function t(e,t){return t===null?e:`${e}:${n(t)}`}function n(t){return e(t)}export{t as n,n as t};
@@ -1,8 +0,0 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{L as n,Nn as r,Rn as i,Rt as a,Xn as o,fr as s,i as c,kn as l,pn as u,si as d,ui as f,vr as p,zt as m}from"./DocumentContext-Bsl186nT.js";import{t as h}from"./react-f2sANaYj.js";import{n as g,r as _}from"./dist-Nvb76hAm.js";import{r as v,t as y}from"./useQuery-ZeEDLtxh.js";import{t as b}from"./compiler-runtime-BfE3aGVn.js";import{t as x}from"./utils-CPqDy6Hr.js";import{i as S,n as C,t as w}from"./tooltip-DBqLYfio.js";import{n as T,r as E,t as D}from"./collapsible-BKbszYZV.js";import{n as O,t as k}from"./toggle-group-B7p69Qfd.js";import{t as A}from"./button-DzgjsZzC.js";import{y as j}from"./constants-upload-CVKO8P4d.js";import{n as M}from"./dist-BGzUo_18.js";import{t as N}from"./dist-C_FzPxEX2.js";import{d as P}from"./constants-cc1-Bt4QPTUe.js";import{f as F,v as I}from"./documents-events-C04vpPEp.js";import{C as L,ht as ee,vt as R}from"./schemas-api-C4CP1G39.js";import{n as z}from"./_envelope-Dwl6i2K9-DPqJ_Q4W.js";import{t as B}from"./note-window-mode-CI3Yju9B.js";import{t as V}from"./createLucideIcon-DdBzwsHe.js";import{t as H}from"./chevron-right-Bofu4lib.js";import{n as U,t as te}from"./lint-plugin-meta-CtDE2R0v.js";import{t as W}from"./circle-alert-eBm4JPxY.js";import{S as G,Un as K,Vn as q,ar as J,ct as ne,dt as Y,nn as X,sr as re,tt as ie,ur as ae}from"./CodeMirrorPropInput-CJK_-B_x.js";import{t as oe}from"./info-CyR0W2SK.js";import{t as se}from"./refresh-cw-CC7UZEnZ.js";import{t as ce}from"./sparkles-BS2TX_Um.js";import{t as le}from"./triangle-alert-BXrUEeRU.js";import{t as ue}from"./wrench-DqFwoSdV.js";import{t as de}from"./badge-DmdA1C7r.js";import{c as fe}from"./use-settings-route-DT86DJkF.js";import{l as pe,s as me}from"./doc-hash-BJkweiX9.js";import{t as he}from"./diagnostic-breadcrumb-Cr0C15nJ.js";import{n as ge,t as _e}from"./perf-DZJpLc5j.js";import{D as ve}from"./navigation-targets-BVafzc0v.js";import{C as ye,y as be}from"./config-provider-DYjwca1V.js";import{J as xe,K as Se,Mt as Ce,Nt as we,X as Te,wt as Ee}from"./dist-D2SphF3p.js";import{n as De,r as Oe}from"./PageListContext-OHnhzUbe.js";import{a as ke,c as Ae,i as je,n as Me,r as Ne,s as Pe,t as Fe}from"./panel-My61A8fk.js";import{d as Ie,h as Le,u as Re,y as ze}from"./markdown-lint-C_9h2J3z.js";import{t as Be}from"./skeleton-BPb29aFG.js";import{a as Ve,c as He,d as Ue}from"./lint-config-client-DRl_GTbs.js";var We=V(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Ge=56,Ke=2,qe=150,Je=2e3;function Ye(e,t,n){return e.top+e.height/2-(n+t)/2}function Xe(e,t){let n=Math.max(0,t.scrollHeight-t.clientHeight);return Math.max(0,Math.min(e,n))}function Ze(e){let{docName:t,container:n,measureTarget:a,placement:o,intent:s,grade:c,landedMode:u,transition:d,onOutcome:f,onDiscardQueuedTarget:p,toolbarOffset:m=Ge,driftThresholdPx:h=Ke,quietMs:g=qe,abandonAfterMs:_=Je}=e,v=e.contentColumn??n.firstElementChild,y=l(t,`landing`),b=r(t,{yieldsToNavigation:s===`toggle`,supersede:()=>P(`superseded`)}),x=n.style.overflowAnchor;n.style.overflowAnchor=`none`,d&&ge(`ok/mode-switch/transition`,{from:d.from,to:d.to,grade:c});let S=!1,C=null,w,T,E=0,D,O=()=>{let e=a();return e===null?null:Xe(o===`center`?Ye(e,n.clientHeight,m):e.top-m,n)},k=()=>{let e=O();if(e===null)return{measurable:!1,moved:!1};C=e;let t=Math.abs(n.scrollTop-e)>h;return t&&(n.scrollTop=e),{measurable:!0,moved:t}},A=()=>n.scrollTop-(O()??C??n.scrollTop),j=()=>{w&&clearTimeout(w),T&&clearTimeout(T),E&&cancelAnimationFrame(E),D?.disconnect(),n.removeEventListener(`wheel`,I),n.removeEventListener(`touchstart`,I),n.removeEventListener(`contentvisibilityautostatechange`,L,!0),n.style.overflowAnchor=x,y.release(),b.release()},M=()=>{if(S)return;S=!0;let e;try{k(),e=A(),C!==null&&i({docName:t,container:n,targetScrollTop:n.scrollTop,mode:u})}finally{j()}ge(`ok/landing/land`,{grade:c,delta:e}),f?.({status:`landed`,delta:e})},N=()=>{if(S)return;S=!0;let e=C??n.scrollTop,t;try{t=A()}finally{j()}ge(`ok/landing/abandoned`,{grade:c,target:e,delta:t}),f?.({status:`abandoned`,delta:t})},P=e=>{S||(S=!0,j(),e===`mode-flip`&&p?.(),f?.({status:`cancelled`,reason:e}))},F=()=>{w&&clearTimeout(w),w=setTimeout(M,g)};function I(){P(`user-scroll`)}function L(){if(S)return;let{measurable:e,moved:t}=k();e&&(t||w===void 0)&&F()}try{k().measurable&&F(),n.addEventListener(`contentvisibilityautostatechange`,L,!0),n.addEventListener(`wheel`,I,{passive:!0}),n.addEventListener(`touchstart`,I,{passive:!0}),typeof ResizeObserver<`u`&&v&&(D=new ResizeObserver(L),D.observe(v)),E=requestAnimationFrame(L),T=setTimeout(N,_)}catch(e){throw S=!0,j(),e}return{cancel:P}}function Qe(e){switch(e){case`bulletList`:case`orderedList`:case`taskList`:case`list`:return`list`;case`codeBlock`:case`code`:return`code`;case`horizontalRule`:case`thematicBreak`:return`thematicBreak`;case`jsxComponent`:case`mdxJsxFlowElement`:case`mdxJsxTextElement`:return`jsx`;case`htmlBlock`:case`html`:return`html`;default:return e}}function $e(e){return typeof e!=`object`||!e?``:`value`in e&&typeof e.value==`string`?e.value:`children`in e&&Array.isArray(e.children)?e.children.map($e).join(``):``}function et(e,t){let{frontmatter:n,body:r}=R(e),i=n===``?0:n.split(`
2
- `).length-1;try{return{blocks:t.parseToEditorMdast(r).children.map(e=>({start:(e.position?.start.line??1/0)+i,end:(e.position?.end.line??-1/0)+i,kind:Qe(e.type),text:$e(e)})),fmLineCount:i}}catch{return performance.mark(`ok/block-spans/parse-failed`),{blocks:[],fmLineCount:i}}}function tt(e,t){let{blocks:n,fmLineCount:r}=et(e,t);return{spans:n.map(e=>({start:e.start,end:e.end})),fmLineCount:r}}function nt(e,t){if(e.length===0)return null;let n=0,r=e.length-1,i=e.length-1;for(;n<=r;){let a=n+r>>1,o=e[a];o!==void 0&&o.end>=t?(i=a,r=a-1):n=a+1}return i}function rt(e){let t=0;for(let n=e.childCount-1;n>=0;n--){let r=e.child(n);if(r.type.name!==`paragraph`||r.content.size!==0)break;t++}return t===e.childCount?0:e.childCount}function it(e,t,n){let r=e.childCount,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));if(a<=i)return null;let o=0;for(let t=0;t<i;t++)o+=e.child(t).nodeSize;let s=o;for(let t=i;t<a;t++)o+=e.child(t).nodeSize;let c=o,l=e.content.size,u=Math.max(0,Math.min(s,l)),d=Math.max(u,Math.min(c,l));return d<=u?null:{from:u,to:d}}function at(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
3
- `&&t.push(n+1);return t}function ot(e,t,n){return t<=1?0:t-1>=e.length?n:e[t-1]??n}function st(e,t){let n=0,r=e.length-1,i=1;for(;n<=r;){let a=n+r>>1;(e[a]??0)<=t?(i=a+1,n=a+1):r=a-1}return i}function ct(e,t,n){return Math.max(t,Math.min(e,n))}function lt(e,t){let n=e=>e.replace(/\s+/g,` `).trim();return n(e)===n(t)}function ut(e,t){return t.inRange?t.tripwireOk?lt(e.content,t.text)?`exact`:e.kind===t.kind?`same-type-ordinal`:`ordinal`:`ordinal`:`clamped`}function dt(e){let t=null,n=null;function r(r){return n!==null&&t===r?n:(n={blocks:et(r,e).blocks,lineStarts:at(r)},t=r,n)}return{captureFromWysiwyg(e,t,n){if(e.childCount===0)return null;let r=ct(t,0,e.content.size),i=0,a=e.childCount-1,o=0;for(let t=0;t<e.childCount;t++){let n=e.child(t).nodeSize;if(r<i+n){a=t,o=i+1;break}i+=n,o=i+1}let s=e.child(a),c={blockIndex:a,kind:Qe(s.type.name),content:s.textContent};return n?.refine&&(c.selectionInBlock=Math.max(0,r-o)),c},captureFromSource(e,t,n){let{blocks:i,lineStarts:a}=r(e);if(i.length===0)return null;let o=ct(t,0,e.length),s=nt(i,st(a,o));if(s===null)return null;let c=i[s];if(!c)return null;let l={blockIndex:s,kind:c.kind,content:c.text};if(n?.refine){let t=ot(a,c.start,e.length);l.selectionInBlock=Math.max(0,o-t)}return l},resolveInSource(e,{source:t,doc:n}){let{blocks:i,lineStarts:a}=r(t);if(i.length===0)return null;let o=e.blockIndex>=0&&e.blockIndex<i.length,s=rt(n)===i.length,c=i[ct(e.blockIndex,0,i.length-1)],l=ot(a,c.start,t.length),u=Math.min(ot(a,c.end+1,t.length),t.length),d=ut(e,{inRange:o,tripwireOk:s,kind:c.kind,text:c.text}),f=l;return d===`exact`&&e.selectionInBlock!==void 0&&(f=ct(l+e.selectionInBlock,l,u)),{blockStart:l,blockEnd:u,point:f,confidence:d}},resolveInWysiwyg(e,{source:t,doc:n}){let i=rt(n);if(i===0)return null;let{blocks:a}=r(t),o=e.blockIndex>=0&&e.blockIndex<i,s=i===a.length,c=ct(e.blockIndex,0,i-1),l=it(n,c,c+1);if(l===null)return null;let u=n.child(c),d=ut(e,{inRange:o,tripwireOk:s,kind:Qe(u.type.name),text:u.textContent});return{blockStart:l.from,blockEnd:l.to,point:l.from,confidence:d}}}}var ft=Ce.define(),pt=Ce.define(),mt=Se.mark({class:a}),ht=we.define({create(){return Se.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(ft)?n=Se.set([mt.range(e.value.from,e.value.to)]):e.is(pt)&&(n=Se.none);return n},provide:e=>xe.decorations.from(e)}),gt=new WeakMap,_t=Te.define(e=>({destroy(){let t=gt.get(e);t!==void 0&&(clearTimeout(t),gt.delete(e))}}));function vt(e,t,n,r){let i=m(e.state.doc.length,t,n,r);if(!i)return;e.dispatch({effects:ft.of(i)});let a=gt.get(e);a!==void 0&&clearTimeout(a);let o=setTimeout(()=>{gt.delete(e),e.dispatch({effects:pt.of(null)})},ne);gt.set(e,o)}function yt(){return[ht,_t]}var bt=3e4;function xt(){let e=new Map,t=e=>e?Date.now()-e.rememberedAt>bt?null:e.navigation:null;return{remember(t,n){e.set(t,{navigation:n,rememberedAt:Date.now()})},peek(n){return t(e.get(n))},consume(n){let r=e.get(n);return e.delete(n),t(r)},clear(t){e.delete(t)},clearForTest(){e.clear()}}}var St=xt(),Ct=xt(),wt=St.remember,Tt=St.peek,Et=St.consume,Dt=St.clear;St.clearForTest;var Ot=Ct.remember,kt=Ct.peek,At=Ct.consume,jt=Ct.clear;Ct.clearForTest;function Mt(e,t,n){return{start:ye(e,t),end:ye(e,n)}}function Nt(e,t){let n=be(e.start,t),r=be(e.end,t);return n===null||r===null||r.index<=n.index?null:n.index}var Pt=`open-knowledge:view-in-source`,Ft=null;function It(){return Ft??=dt(ie()),Ft}function Lt(e,t,n,r,i=`toggle`){let a=r.captureFromWysiwyg(e,t,{refine:i===`jump`});if(!a)return null;let o=r.resolveInSource(a,{source:n.toString(),doc:e});return{kind:`selection-offset`,intent:i,anchor:a,pin:o?Mt(n,o.blockStart,o.blockEnd):void 0}}function Rt(e){let{editor:t,docName:n,ytext:r}=e,i=J(t);if(!i)return;let a=i.state.selection.from,o=Lt(i.state.doc,a,r,It(),`jump`);o&&wt(n,o),window.dispatchEvent(new CustomEvent(Pt,{detail:{docName:n}}))}function zt(e,t,n,r,i){let a=r.captureFromSource(e,t);if(!a)return null;let o=i?r.resolveInSource(a,{source:e,doc:i}):null;return{kind:`selection-offset`,anchor:a,pin:o?Mt(n,o.blockStart,o.blockEnd):void 0}}function Bt(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=Nt(e.pin,i);if(t===null){let t=a.resolveInWysiwyg(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInWysiwyg(o,{source:n,doc:r})}return a.resolveInWysiwyg(e.anchor,{source:n,doc:r})}function Vt(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=Nt(e.pin,i);if(t===null){let t=a.resolveInSource(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInSource(o,{source:n,doc:r})}return a.resolveInSource(e.anchor,{source:n,doc:r})}function Ht(e,t){try{return e.coordsAtPos(t)}catch{return null}}function Ut(e,t,n){let r=Math.max(0,Math.min(n,e.state.doc.length)),i=t.getBoundingClientRect().top,a=Ht(e,r);if(a)return{top:a.top-i+t.scrollTop,height:a.bottom-a.top};try{let n=e.lineBlockAt(r);return{top:e.documentTop-i+t.scrollTop+n.top,height:n.height}}catch{return null}}function Wt(e,t){if(e.isDestroyed)return null;try{let n=e.nodeDOM(t);if(n instanceof HTMLElement)return n;let{node:r}=e.domAtPos(t);return r instanceof HTMLElement?r:r.parentElement}catch{return null}}function Gt(e,t,n){if(e.isDestroyed)return null;let r=Wt(e,Math.max(0,Math.min(n,e.state.doc.content.size)));if(!r)return null;let i=r.getBoundingClientRect(),a=t.getBoundingClientRect().top;return{top:i.top-a+t.scrollTop,height:i.height}}function Kt(){return typeof document>`u`?null:u()}function qt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=G();for(let t of[i+1,i+12,i+40]){let i=e.posAtCoords({left:r,top:n.top+t});if(i)return i.pos}return null}function Jt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=G();for(let t of[i+1,i+12,i+40]){let i=e.posAtCoords({x:r,y:n.top+t});if(i!==null)return i}return null}function Yt(e){let{from:t,to:n,docName:r,ytext:i}=e;t===`wysiwyg`&&n===`source`?Xt(r,i):t===`source`&&n===`wysiwyg`&&Zt(r,i)}function Xt(e,t){let n=Tt(e);if(n&&n.kind!==`selection-offset`)return;let r=o(e);if(!r)return;let i=J(r);if(!i)return;let a=Kt();if(!a)return;let s=qt(i,a);if(s===null)return;let c=Lt(i.state.doc,s,t,It());c&&wt(e,c)}function Zt(e,t){let n=q(e);if(!n)return;let r=Kt();if(!r)return;let i=Jt(n,r);if(i===null)return;let a=o(e),s=a?J(a)?.state.doc:void 0,c=zt(t.toString(),i,t,It(),s);c&&Ot(e,c)}function Qt(e){let{view:t,docName:n,navigation:i,ydoc:a,transition:s}=e,c=o(n),l=c?J(c)?.state.doc:void 0;if(!l)return null;let u=Vt(i,{source:t.state.doc.toString(),pmDoc:l,ydoc:a,resolver:It()});if(!u)return null;let d=Kt();if(!d)return null;let f=u,p=i.intent===`jump`,m=p?f.point:f.blockStart;t.dispatch({effects:xe.scrollIntoView(m,{y:`start`})});let h=!1,g=null,_=r(n,{yieldsToNavigation:!p,supersede:()=>{h=!0,_.release()}}),v=e=>{if(!h){if(Ht(t,m)===null&&e<8){requestAnimationFrame(()=>v(e+1));return}try{p&&(t.dispatch({selection:Ee.cursor(m)}),t.focus())}finally{_.release()}g=Ze({docName:n,container:d,contentColumn:t.contentDOM,measureTarget:()=>Ut(t,d,m),placement:p?`center`:`top`,intent:p?`jump`:`toggle`,grade:f.confidence,landedMode:`source`,transition:s,toolbarOffset:G(),onOutcome:p?e=>{e.status===`landed`&&vt(t,f.blockStart,f.blockEnd,f.confidence)}:void 0,onDiscardQueuedTarget:()=>Dt(n)})}};return v(0),{cancel:e=>{h=!0,_.release(),g?.cancel(e)}}}function $t(e){let{editor:t,docName:n,navigation:r,ydoc:i,transition:a}=e,o=J(t);if(!o)return null;let s=Bt(r,{source:i.getText(`source`).toString(),pmDoc:o.state.doc,ydoc:i,resolver:It()});if(!s)return null;let c=Kt();if(!c)return null;let l=s;return Ze({docName:n,container:c,contentColumn:o.dom,measureTarget:()=>Gt(o,c,l.point),placement:`top`,intent:`toggle`,grade:l.confidence,landedMode:`wysiwyg`,transition:a,toolbarOffset:G(),onDiscardQueuedTarget:()=>jt(n)})}var en={words:0,chars:0,tokens:0},tn=/[ -〿぀-ゟ゠-ヿ㐀-䶿一-鿿豈-﫿＀-￯฀-๿ក-៿]/,nn=/[\p{L}\p{N}]/u,rn=new Set([`text`,`inlineCode`,`code`,`tag`]),an=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),on=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function sn(e,t){if(!e)return;let n=e.type;if(!an.has(n)){if(rn.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
4
- `));return}if(n===`wikiLink`||n===`wikiLinkEmbed`){let n=e.data?.alias??e.value??``;n&&t.push(n);return}if(Array.isArray(e.children)){for(let n of e.children)sn(n,t);if(on.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
5
- `)&&t.push(`
6
- `)}}}}function cn(e){try{let t=ie().parseToMdast(e),n=[];return sn(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function ln(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))nn.test(n)&&t++;return t}function un(e){let t=globalThis.Intl.Segmenter;if(!t)return ln(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function dn(e){let t=tn.test(e)?1.5:4;return Math.ceil(e.length/t)}function fn(e){return e?{words:tn.test(e)?un(e):ln(e),chars:e.length,tokens:dn(e)}:{words:0,chars:0,tokens:0}}function pn(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=R(e);return t.trim()?fn(cn(t)):{words:0,chars:0,tokens:0}}function mn(e){return fn(e)}function hn(e,{isMarkdown:t}){let n=e.trim();return n?fn(t?cn(e):n):en}function gn(e,t){return e!==null&&j(e)?`source`:t}var _n=new Map,vn=new Set,yn=(e,t)=>`${t}:${e}`;function bn(){for(let e of vn)e()}function xn(e,t,n){let r=yn(e,t);if(n===null){_n.delete(r)&&bn();return}let i=_n.get(r);i&&i.words===n.words&&i.chars===n.chars&&i.tokens===n.tokens||(_n.set(r,n),bn())}function Sn(e,t){return e===null?null:_n.get(yn(e,t))??null}function Cn(e){return vn.add(e),()=>{vn.delete(e)}}function wn(e){let{from:t,to:n,empty:r}=e.state.selection;if(r)return null;let i=e.state.doc.textBetween(t,n,`
7
- `,` `);return i.trim()?hn(i,{isMarkdown:!1}):null}function Tn(e){let t=[];for(let n of e.state.selection.ranges)n.empty||t.push(e.state.sliceDoc(n.from,n.to));if(t.length===0)return null;let n=t.join(`
8
- `);return n.trim()?hn(n,{isMarkdown:!0}):null}var Z=e(h(),1),Q=b(),$=t();function En(e){let t=(0,Q.c)(14),{scope:n,onScopeChange:r,projectLabel:i}=e,{_:a}=_(),o;t[0]===r?o=t[1]:(o=e=>{e&&r(e)},t[0]=r,t[1]=o);let s;t[2]===a?s=t[3]:(s=a({id:`aBgwis`}),t[2]=a,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(O,{value:`doc`,className:`flex-1`,"data-testid":`panel-scope-doc`,children:(0,$.jsx)(g,{id:`UpCz01`})}),t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i??(0,$.jsx)(g,{id:`ZWyHmq`}),t[5]=i,t[6]=l);let u;t[7]===l?u=t[8]:(u=(0,$.jsx)(O,{value:`project`,className:`flex-1`,"data-testid":`panel-scope-project`,children:l}),t[7]=l,t[8]=u);let d;return t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,$.jsx)(`div`,{className:`shrink-0 px-4 pb-2`,children:(0,$.jsxs)(k,{type:`single`,variant:`segmented`,size:`sm`,spacing:1,value:n,onValueChange:o,"aria-label":s,className:`w-full rounded-md bg-muted p-0.5 dark:bg-background`,children:[c,u]})}),t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}function Dn(e){let t=e.localTarget;if(e.source!==`links`||t===void 0)return e.message;let n=t.resolvedTarget??t.href;return t.reason===`unresolvable`?t.role===`image`?N._({id:`W5qdI_`,values:{shown:n}}):N._({id:`bpMVIA`,values:{shown:n}}):t.targetKind===`file`?t.role===`image`?N._({id:`iSWh95`,values:{shown:n}}):N._({id:`fOzzSV`,values:{shown:n}}):N._({id:`XBBZnv`,values:{shown:n}})}var On=`audit-superseded`;async function kn(e={kind:`project`},t){return jn(e,Ie,!1,t)}async function An(e={kind:`project`},t){return jn(e,Re,!0,t)}async function jn(e,t,n,r){try{let i=new URLSearchParams;e.kind===`path`?i.set(`path`,e.path):e.kind===`doc`&&i.set(`doc`,e.docName),n&&i.set(`counts`,`1`);let a=i.size===0?``:`?${i}`,o=await fetch(`/api/audit${a}`,r===void 0?void 0:{signal:r});if(!o.ok)return o.status===409?On:(console.warn(`[audit] request failed`,o.status,o.statusText),null);let s;try{s=await o.json()}catch{return r?.aborted===!0||console.warn(`[audit] response body is not valid JSON`),null}let c=t.safeParse(s);return c.success?c.data:(console.warn(`[audit] response failed schema validation`,c.error.issues),null)}catch(e){return r?.aborted===!0||console.warn(`[audit] fetch threw`,e),null}}function Mn(e,t){let n=!1,r=!1,i=!1,a=[],o,s=null,c=()=>({findings:a,...o===void 0?{}:{brokenLinkSuppression:o}}),l=()=>{if(r){i=!0;return}r=!0,s=new AbortController,t({status:`loading`,...c()}),kn({kind:`doc`,docName:e},s.signal).then(e=>{if(!(n||s?.signal.aborted===!0)){if(e===null){t({status:`failed`,...c()});return}if(e===`audit-superseded`){i=!0;return}i||(a=e.files.flatMap(e=>e.diagnostics).filter(e=>e.source===`links`),o=e.brokenLinkSuppression,t({status:`loaded`,...c()}))}}).finally(()=>{n||(r=!1,s=null,i&&(i=!1,l()))})};l();let u=I(e=>{(e.includes(`backlinks`)||F(e))&&l()}),d=He(l);return()=>{n=!0,s?.abort(),u(),d()}}function Nn(e){let t=(0,Q.c)(6),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={docName:null,state:{status:`idle`,findings:[]}},t[0]=n):n=t[0];let[r,i]=(0,Z.useState)(n),a,o;if(t[1]===e?(a=t[2],o=t[3]):(a=()=>{if(e===null){i({docName:null,state:{status:`idle`,findings:[]}});return}return i({docName:e,state:{status:`loading`,findings:[]}}),Mn(e,t=>i({docName:e,state:t}))},o=[e],t[1]=e,t[2]=a,t[3]=o),(0,Z.useEffect)(a,o),r.docName!==e){let n;return t[4]===e?n=t[5]:(n=e===null?{status:`idle`,findings:[]}:{status:`loading`,findings:[]},t[4]=e,t[5]=n),n}return r.state}function Pn(e){return Math.min(50,Math.max(1,Math.ceil(e/10)))}function Fn(e,t){return e===t||e%Pn(t)===0}var In=[250,500,1e3,2e3,4e3];function Ln(e){return e.status===503&&e.problemType===`urn:ok:error:too-many-agent-sessions`}async function Rn(e,t){let n=await t.fixItem(e);for(let r of In){if(n.ok||!Ln(n)||!t.shouldContinue()||(console.debug(`[sweep] capacity refusal, backing off %dms`,r),await t.sleep(r),!t.shouldContinue()))break;n=await t.fixItem(e)}return n}async function zn(e){let t=e.items.length,n=[];for(let[r,i]of e.items.entries()){if(r>0&&(await e.sleep(15),!e.shouldContinue()))return{failures:n,cancelled:!0};let a=await Rn(i,e);if(a.ok||n.push({item:i,detail:a.errorDetail}),!e.shouldContinue())return{failures:n,cancelled:!0};let o=r+1;Fn(o,t)&&e.onProgress(o,t)}return{failures:n,cancelled:!1}}function Bn(e){return new Promise(t=>setTimeout(t,e))}var Vn=null,Hn=!1,Un=new Set,Wn=new Set;function Gn(e){Vn=e;for(let e of Un)e()}function Kn(e){return Un.add(e),()=>{Un.delete(e)}}function qn(){return Vn}function Jn(){return(0,Z.useSyncExternalStore)(Kn,qn,qn)}function Yn(e){return Wn.add(e),()=>{Wn.delete(e)}}function Xn(){Hn=!0}function Zn(e,t,n){if(e.length>0&&(console.warn(`[lint] fix-all: ${e.length} of ${n} files failed`,e.map(e=>({file:e.item.file,detail:e.detail}))),!t)){let t=e[0];M.error(N._({id:`se-tU0`,values:{0:e.length,total:n}}),{description:t===void 0?void 0:`${t.item.file}${t.detail===null?``:` — ${t.detail}`}`})}if(t){M.info(N._({id:`H1TmTu`}));return}e.length===0&&M.success(N._({id:`SWX1O7`,values:{total:n}}))}async function Qn({items:e,fixItem:t,sleep:n=Bn}){if(Vn!==null||e.length===0)return;let r=e.length;Hn=!1,Gn({done:0,total:r});let i=[],a=!1,o=!1;try{let o=await zn({items:e,fixItem:t,sleep:n,onProgress:e=>Gn({done:e,total:r}),shouldContinue:()=>!Hn});i=o.failures,a=o.cancelled}catch(e){console.warn(`[lint] fix-all: sweep threw`,e),o=!0}finally{Gn(null)}try{o?M.error(N._({id:`vwV-kH`})):Zn(i,a,r)}finally{for(let e of Wn)e()}}var $n={errorCount:0,warningCount:0},er=new Map,tr=new Set,nr=new Map;function rr(){let e=new Map;for(let[t,n]of er){let r=n.lint.errorCount+n.links.errorCount,i=n.lint.warningCount+n.links.warningCount;r===0&&i===0||e.set(t,{errorCount:r,warningCount:i})}nr=e;for(let e of tr)e()}var ir=Le;function ar(e){return tr.add(e),()=>{tr.delete(e)}}function or(){return nr}function sr(e){er.clear();for(let t of e)er.set(me(t.file),ir(t.diagnostics));rr()}function cr(e){er.clear();for(let t of e)er.set(me(t.file),{lint:t.lint,links:t.links});rr()}function lr(e,t){er.set(e,ir(t)),rr()}function ur(e,t,n){let r=er.get(e)??{lint:$n,links:$n},i=r[t];i.errorCount===n.errorCount&&i.warningCount===n.warningCount||(er.set(e,{...r,[t]:n}),rr())}var dr=`open-knowledge:lint-nav`;function fr(e,t){return e.range.start.line-t.range.start.line||e.range.start.character-t.range.start.character}function pr(e,t){return{docName:e,line:t.range.start.line+1,column:t.range.start.character+1,source:t.source,...t.frontmatterScope===void 0?{}:{frontmatterScope:t.frontmatterScope}}}function mr(e){if(e.source!==`links`)return null;let t=e.localTarget;return t===void 0?`document`:t.role===`image`?`image`:t.targetKind===`file`?`file`:t.targetKind===`document`?`document`:`unresolvable`}var hr={document:s,file:p,image:re,unresolvable:s};function gr(e){return e.linkTarget!==void 0&&mr(e)===`document`}function _r(e){let t=(0,Q.c)(40),{diagnostic:n,instanceCount:r}=e,{_:i}=_(),a=n.severity===`error`?W:le,o=n.range.start.line+1,s;t[0]===n?s=t[1]:(s=mr(n),t[0]=n,t[1]=s);let c=s,l=c===null?null:hr[c],u=r!==void 0&&r>1,d=n.severity===`error`?`text-destructive`:`text-amber-500`,f;t[2]===d?f=t[3]:(f=x(`mt-0.5 size-3.5 shrink-0`,d),t[2]=d,t[3]=f);let p;t[4]!==a||t[5]!==f?(p=(0,$.jsx)(a,{"aria-hidden":`true`,className:f}),t[4]=a,t[5]=f,t[6]=p):p=t[6];let m;t[7]===n?m=t[8]:(m=Dn(n),t[7]=n,t[8]=m);let h;t[9]===m?h=t[10]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:m}),t[9]=m,t[10]=h);let v;t[11]!==u||t[12]!==r?(v=u?(0,$.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(de,{variant:`gray`,"data-testid":`problems-instance-count`,className:`h-4 px-1 font-sans text-[10px] leading-none`,children:(0,$.jsx)(g,{id:`iZCZmF`,values:{instanceCount:r}})}),(0,$.jsx)(H,{"aria-hidden":`true`,className:`size-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none`})]}):null,t[11]=u,t[12]=r,t[13]=v):v=t[13];let y;t[14]!==p||t[15]!==h||t[16]!==v?(y=(0,$.jsxs)(`span`,{className:`flex items-start gap-1.5 text-sm`,children:[p,h,v]}),t[14]=p,t[15]=h,t[16]=v,t[17]=y):y=t[17];let b=c??void 0,S=l!==null&&`gap-0.5`,C;t[18]===S?C=t[19]:(C=x(`h-4 shrink-0 px-1 font-sans text-[10px] uppercase leading-none`,S),t[18]=S,t[19]=C);let w;t[20]===l?w=t[21]:(w=l===null?null:(0,$.jsx)(l,{"aria-hidden":`true`,className:`size-2.5`}),t[20]=l,t[21]=w);let T;t[22]!==n.source||t[23]!==C||t[24]!==w||t[25]!==b?(T=(0,$.jsxs)(de,{variant:`gray`,"data-testid":`problems-source-tag`,"data-target-kind":b,className:C,children:[w,n.source]}),t[22]=n.source,t[23]=C,t[24]=w,t[25]=b,t[26]=T):T=t[26];let E;t[27]!==i||t[28]!==n.code||t[29]!==o||t[30]!==u?(E=u?n.code:`${n.code} · ${i({id:`enPTnx`,values:{displayLine:o}})}`,t[27]=i,t[28]=n.code,t[29]=o,t[30]=u,t[31]=E):E=t[31];let D;t[32]===E?D=t[33]:(D=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:E}),t[32]=E,t[33]=D);let O;t[34]!==T||t[35]!==D?(O=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 ps-5 font-mono text-xs text-muted-foreground`,children:[T,D]}),t[34]=T,t[35]=D,t[36]=O):O=t[36];let k;return t[37]!==O||t[38]!==y?(k=(0,$.jsxs)($.Fragment,{children:[y,O]}),t[37]=O,t[38]=y,t[39]=k):k=t[39],k}function vr(e){let t=new Map;for(let n of e){let e=`${n.source}/${n.code}\u0000${n.linkTarget??``}\u0000${n.message}`,r=t.get(e);r===void 0?t.set(e,{key:e,instances:[n]}):r.instances.push(n)}return[...t.values()]}function yr(e){let t=(0,Q.c)(63),{group:n,onNavigate:r,navTitle:i,renderActions:a}=e,{_:o}=_(),s=n.instances[0],c,l,u,d,f,p,m,h;if(t[0]!==o||t[1]!==s||t[2]!==n.instances.length||t[3]!==i||t[4]!==r||t[5]!==a){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Dn(s);if(n.instances.length===1){let e;t[14]!==s||t[15]!==a?(e=a(s),t[14]=s,t[15]=a,t[16]=e):e=t[16];let n=e,o;t[17]!==s||t[18]!==r?(o=()=>r(s),t[17]=s,t[18]=r,t[19]=o):o=t[19];let c;t[20]!==s||t[21]!==i?(c=i(s),t[20]=s,t[21]=i,t[22]=c):c=t[22];let l;t[23]===s?l=t[24]:(l=(0,$.jsx)(_r,{diagnostic:s}),t[23]=s,t[24]=l);let u;t[25]!==l||t[26]!==o||t[27]!==c?(u=(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left`,title:c,children:l}),t[25]=l,t[26]=o,t[27]=c,t[28]=u):u=t[28];let d;t[29]===n?d=t[30]:(d=n===null?null:(0,$.jsx)(`div`,{className:`absolute bottom-1 right-1 flex items-center gap-1 rounded bg-muted opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none`,children:n}),t[29]=n,t[30]=d);let f;t[31]!==u||t[32]!==d?(f=(0,$.jsxs)(`li`,{className:`group relative rounded transition-colors hover:bg-muted`,children:[u,d]}),t[31]=u,t[32]=d,t[33]=f):f=t[33],h=f;break bb0}p=`rounded`,m=`problems-duplicate-group`,l=D,t[34]!==s||t[35]!==n.instances.length?(f=(0,$.jsx)(E,{className:`group flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,children:(0,$.jsx)(_r,{diagnostic:s,instanceCount:n.instances.length})}),t[34]=s,t[35]=n.instances.length,t[36]=f):f=t[36],c=T,d=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in] motion-reduce:animate-none`,u=o({id:`_Bix3-`,values:{localizedFirstMessage:e}})}t[0]=o,t[1]=s,t[2]=n.instances.length,t[3]=i,t[4]=r,t[5]=a,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h}else c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let g;if(t[37]!==o||t[38]!==n.instances||t[39]!==i||t[40]!==r||t[41]!==a){let e;t[43]!==o||t[44]!==i||t[45]!==r||t[46]!==a?(e=e=>{let t=a(e),n=e.range.start.line+1,s=Dn(e);return(0,$.jsxs)(`li`,{className:`group relative rounded transition-colors hover:bg-muted`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`flex w-full cursor-pointer rounded px-2 py-1 text-left font-mono text-xs text-muted-foreground`,title:i(e),"aria-label":o({id:`txUHO8`,values:{localizedMessage:s,displayLine:n}}),children:o({id:`enPTnx`,values:{displayLine:n}})}),t===null?null:(0,$.jsx)(`div`,{className:`absolute bottom-0.5 right-1 flex items-center gap-1 rounded bg-muted opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none`,children:t})]},br(e))},t[43]=o,t[44]=i,t[45]=r,t[46]=a,t[47]=e):e=t[47],g=n.instances.map(e),t[37]=o,t[38]=n.instances,t[39]=i,t[40]=r,t[41]=a,t[42]=g}else g=t[42];let v;t[48]!==u||t[49]!==g?(v=(0,$.jsx)(`ul`,{"aria-label":u,className:`flex flex-col gap-0.5 pb-1 ps-5`,"data-testid":`problems-duplicate-instances`,children:g}),t[48]=u,t[49]=g,t[50]=v):v=t[50];let y;t[51]!==c||t[52]!==d||t[53]!==v?(y=(0,$.jsx)(c,{className:d,children:v}),t[51]=c,t[52]=d,t[53]=v,t[54]=y):y=t[54];let b;t[55]!==l||t[56]!==f||t[57]!==y?(b=(0,$.jsxs)(l,{children:[f,y]}),t[55]=l,t[56]=f,t[57]=y,t[58]=b):b=t[58];let x;return t[59]!==b||t[60]!==p||t[61]!==m?(x=(0,$.jsx)(`li`,{className:p,"data-testid":m,children:b}),t[59]=b,t[60]=p,t[61]=m,t[62]=x):x=t[62],x}function br(e){return`${e.source}/${e.code}-${e.range.start.line}-${e.range.start.character}-${e.message}`}function xr(e){return e.reduce((e,t)=>e+ +((t.fixes?.length??0)>0),0)}function Sr(e){let t=(0,Q.c)(11),{target:n,creating:r,disabled:i,onCreate:a}=e,{_:o}=_(),s;t[0]!==o||t[1]!==n?(s=o({id:`oWsZk8`,values:{target:n}}),t[0]=o,t[1]=n,t[2]=s):s=t[2];let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(ae,{"aria-hidden":`true`,className:`size-3`}),t[3]=c):c=t[3];let l;t[4]===r?l=t[5]:(l=r?(0,$.jsx)(g,{id:`E9bKSA`}):(0,$.jsx)(g,{id:`XRuL0i`}),t[4]=r,t[5]=l);let u;return t[6]!==i||t[7]!==a||t[8]!==s||t[9]!==l?(u=(0,$.jsxs)(A,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:i,onClick:a,"aria-label":s,"data-testid":`problems-create-page`,children:[c,l]}),t[6]=i,t[7]=a,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function Cr(e){let t=(0,Q.c)(8),{tip:n,testId:r,children:i}=e,a;t[0]===i?a=t[1]:(a=(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0`,children:i})}),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==n?(o=(0,$.jsx)(C,{"data-testid":r,children:n}),t[2]=r,t[3]=n,t[4]=o):o=t[4];let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(w,{children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function wr(e){let t=(0,Q.c)(21),{count:n,problemCount:r,aiAvailable:i,disabled:a,onClick:o,children:s}=e,{_:c}=_(),l;t[0]!==i||t[1]!==n||t[2]!==r?(l=n>0?(0,$.jsx)(g,{id:`vjwsDi`,values:{count:n}}):r===0?(0,$.jsx)(g,{id:`gAhHu7`}):i?(0,$.jsx)(g,{id:`zA9zRL`}):(0,$.jsx)(g,{id:`X3MMeA`}),t[0]=i,t[1]=n,t[2]=r,t[3]=l):l=t[3];let u;t[4]!==c||t[5]!==s||t[6]!==n||t[7]!==r?(u=s===void 0?r===0?c({id:`4m-xuX`}):n===0?c({id:`SqIoy_`}):void 0:void 0,t[4]=c,t[5]=s,t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(ue,{"aria-hidden":`true`,className:`size-3`}),t[9]=d):d=t[9];let f;t[10]!==s||t[11]!==n?(f=s??(0,$.jsx)(g,{id:`RZXTlY`,values:{count:n}}),t[10]=s,t[11]=n,t[12]=f):f=t[12];let p;t[13]!==a||t[14]!==o||t[15]!==u||t[16]!==f?(p=(0,$.jsxs)(A,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:a,onClick:o,"aria-label":u,"data-testid":`problems-auto-fix`,children:[d,f]}),t[13]=a,t[14]=o,t[15]=u,t[16]=f,t[17]=p):p=t[17];let m;return t[18]!==l||t[19]!==p?(m=(0,$.jsx)(Cr,{testId:`problems-auto-fix-tip`,tip:l,children:p}),t[18]=l,t[19]=p,t[20]=m):m=t[20],m}function Tr(e){let t=(0,Q.c)(12),{count:n,disabled:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(g,{id:`mgDKWS`,values:{count:n}}),t[0]=n,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(ce,{"aria-hidden":`true`,className:`size-3`}),t[2]=o):o=t[2];let s;t[3]===n?s=t[4]:(s=(0,$.jsx)(g,{id:`gyHDWC`,values:{count:n}}),t[3]=n,t[4]=s);let c;t[5]!==r||t[6]!==i||t[7]!==s?(c=(0,$.jsxs)(A,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:r,onClick:i,"data-testid":`problems-fix-with-ai`,children:[o,s]}),t[5]=r,t[6]=i,t[7]=s,t[8]=c):c=t[8];let l;return t[9]!==a||t[10]!==c?(l=(0,$.jsx)(Cr,{testId:`problems-fix-with-ai-tip`,tip:a,children:c}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l}function Er(e){let t=(0,Q.c)(59),{docName:r,diagnostics:i,linkFindingsStatus:a,brokenLinkSuppression:o,onFix:s,onAutoFix:c,onAskAi:l,onFixWithAi:u}=e,p=a===void 0?`loaded`:a,{_:m}=_(),h=(0,Z.useRef)(null),v=(0,Z.useId)(),[y,b]=(0,Z.useState)(`doc`),x;t[0]===r?x=t[1]:(x=j(r),t[0]=r,t[1]=x);let T=!x,{data:E}=Ue(),D=E===null?null:E.effective.enabled?te.filter(e=>E.effective.plugins[e.id].enabled):[],O=D!==null&&D.length===0,k=o!==void 0,N=(y===`project`||T)&&D!==null&&D.length>0,P;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(P={status:`idle`},t[2]=P):P=t[2];let[L,ee]=(0,Z.useState)(P),R=Jn(),z=De(),[B,V]=(0,Z.useState)(null),H=(0,Z.useRef)(!0),U,W;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>(H.current=!0,()=>{H.current=!1}),W=[],t[3]=U,t[4]=W):(U=t[3],W=t[4]),(0,Z.useEffect)(U,W);let G=(0,Z.useRef)(Pr),K=(0,Z.useRef)(Nr),q;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(q={status:`idle`},t[5]=q):q=t[5];let J=(0,Z.useRef)(q),ne;t[6]===L?ne=t[7]:(ne=()=>{L.status!==`loading`&&(J.current=L)},t[6]=L,t[7]=ne),(0,Z.useEffect)(ne);let Y=(0,Z.useRef)(0),X=[...i].sort(fr),re=xr(X),ie;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(ie=async function(){Y.current+=1;let e=Y.current,t=J.current;ee({status:`loading`});let n=await kn();if(n===`audit-superseded`){Y.current===e&&H.current&&ee(t.status===`idle`?{status:`failed`}:t);return}n!==null&&sr(n.files),H.current&&ee(n===null?{status:`failed`}:{status:`loaded`,result:n})},t[8]=ie):ie=t[8];let ae=ie,oe;t[9]!==m||t[10]!==L.status||t[11]!==B||t[12]!==z?(oe=async function(e){let t=e.linkTarget;if(!(t===void 0||B!==null||z===null)){V(t);try{await n({initialDir:``,suggestedName:t},{addPage:z.addPage})}catch(e){let t=e;M.error(t instanceof Error?t.message:m({id:`tfi40B`})),H.current&&V(null);return}M.success(m({id:`EWCJFu`,values:{target:t}})),H.current&&V(null),H.current&&L.status===`loaded`&&await ae()}},t[9]=m,t[10]=L.status,t[11]=B,t[12]=z,t[13]=oe):oe=t[13];let se=oe,le=L.status===`loaded`?L.result.files.filter(jr):[],de=function(){Qn({items:le,fixItem:Ar})},he;t[14]===L.status?he=t[15]:(he=function(e){b(e),e===`project`&&L.status===`idle`&&ae()},t[14]=L.status,t[15]=he);let ge=he,_e;t[16]===L.status?_e=t[17]:(_e=()=>{G.current=()=>{L.status===`idle`||L.status===`failed`||ae()}},t[16]=L.status,t[17]=_e),(0,Z.useEffect)(_e);let ve,ye;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ve=()=>He(()=>G.current()),ye=[],t[18]=ve,t[19]=ye):(ve=t[18],ye=t[19]),(0,Z.useEffect)(ve,ye);let be,xe;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>I(e=>{F(e)&&G.current()}),xe=[],t[20]=be,t[21]=xe):(be=t[20],xe=t[21]),(0,Z.useEffect)(be,xe);let Se;t[22]===ge?Se=t[23]:(Se=(e,t)=>{e===`problems`&&(d(`problems`),t.scope!==void 0&&ge(t.scope),t.focus===`panel`&&h.current?.focus({preventScroll:!0}))},t[22]=ge,t[23]=Se);let Ce=(0,Z.useEffectEvent)(Se),we;t[24]===Ce?we=t[25]:(we=()=>{let e=d(`problems`);return e!==null&&Ce(`problems`,e),f(Ce)},t[24]=Ce,t[25]=we);let Te;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Te=[],t[26]=Te):Te=t[26],(0,Z.useEffect)(we,Te);let Ee;t[27]===L.status?Ee=t[28]:(Ee=()=>{K.current=()=>{L.status===`idle`||L.status===`failed`||ae().catch(e=>{console.warn(`[lint] post-sweep re-audit failed`,e),H.current&&ee({status:`failed`})})}},t[27]=L.status,t[28]=Ee),(0,Z.useEffect)(Ee);let Oe,Ie;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=()=>Yn(()=>K.current()),Ie=[],t[29]=Oe,t[30]=Ie):(Oe=t[29],Ie=t[30]),(0,Z.useEffect)(Oe,Ie);let Le;t[31]===r?Le=t[32]:(Le=function(e){let t=pr(r,e);wt(r,{kind:`lint`,detail:t}),window.dispatchEvent(new CustomEvent(dr,{detail:t}))},t[31]=r,t[32]=Le);let Re=Le,ze;t[33]!==r||t[34]!==Re?(ze=function(e,t){let n=me(e);if(n===r){Re(t);return}wt(n,{kind:`lint`,detail:pr(n,t)}),window.location.hash=pe(n)},t[33]=r,t[34]=Re,t[35]=ze):ze=t[35];let Be=ze,Ve;t[36]!==m||t[37]!==se||t[38]!==B||t[39]!==l||t[40]!==s||t[41]!==z?(Ve=function(e){let t=s!==void 0&&(e.fixes?.length??0)>0,n=gr(e)&&z!==null;if(!t&&!n&&l===void 0)return null;let r=`${e.source}/${e.code}`;return(0,$.jsxs)($.Fragment,{children:[n?(0,$.jsx)(Sr,{target:e.linkTarget??``,creating:B===e.linkTarget,disabled:B!==null,onCreate:()=>void se(e)}):null,t?(0,$.jsxs)(A,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>s?.(e),"aria-label":m({id:`fZj9em`,values:{flatId:r}}),"data-testid":`problems-fix`,children:[(0,$.jsx)(ue,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(g,{id:`c4fVUV`})]}):null,l===void 0?null:(0,$.jsxs)(A,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>l(e),"aria-label":m({id:`hh4mVC`,values:{flatId:r}}),"data-testid":`problems-ask-ai`,children:[(0,$.jsx)(ce,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(g,{id:`xWEvuo`})]})]})},t[36]=m,t[37]=se,t[38]=B,t[39]=l,t[40]=s,t[41]=z,t[42]=Ve):Ve=t[42];let We=Ve,Ge=Fe,Ke;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,$.jsx)(g,{id:`OXdGnd`}),t[43]=Ke):Ke=t[43];let qe;t[44]===v?qe=t[45]:(qe=(0,$.jsx)(Ae,{id:v,children:Ke}),t[44]=v,t[45]=qe);let Je=y===`doc`&&X.length>0&&(0,$.jsx)(Ne,{children:X.length}),Ye=N&&(0,$.jsxs)(w,{children:[(0,$.jsx)(S,{className:`shrink-0 cursor-default rounded-md bg-muted-foreground/5 px-2 py-1 font-mono text-xs text-muted-foreground`,"data-testid":`problems-active-plugins`,children:(0,$.jsx)(g,{id:`yxF19Y`,values:{0:D.length}})}),(0,$.jsx)(C,{"data-testid":`problems-active-plugins-tooltip`,children:(0,$.jsx)(g,{id:`ws5o1F`,values:{0:D.map(kr).join(`, `)}})})]}),Xe;t[46]!==qe||t[47]!==Je||t[48]!==Ye?(Xe=(0,$.jsx)(Pe,{children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[qe,Je,Ye]})}),t[46]=qe,t[47]=Je,t[48]=Ye,t[49]=Xe):Xe=t[49];let Ze;t[50]!==ge||t[51]!==y?(Ze=(0,$.jsx)(En,{scope:y,onScopeChange:ge}),t[50]=ge,t[51]=y,t[52]=Ze):Ze=t[52];let Qe=y===`doc`?(0,$.jsxs)(Me,{className:`px-2 py-2`,children:[p===`idle`||p===`loading`?(0,$.jsx)(je,{className:`px-2 pb-2`,role:`status`,"aria-live":`polite`,"data-testid":`problems-links-loading`,children:(0,$.jsx)(g,{id:`W9NSe0`})}):p===`failed`?(0,$.jsx)(ke,{className:`px-2 pb-2`,role:`status`,"data-testid":`problems-links-failed`,children:X.length>0||k?(0,$.jsx)(g,{id:`IoHQYP`}):(0,$.jsx)(g,{id:`gpbKxw`})}):null,k&&(0,$.jsx)(zr,{suppression:o}),X.length===0?p===`loaded`?T?O?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(je,{className:`px-2`,"data-testid":`problems-no-plugins`,children:k?(0,$.jsx)(g,{id:`mI1KPS`}):(0,$.jsx)(g,{id:`Hngy37`})}),(0,$.jsx)(`div`,{className:`px-2 pt-2`,children:(0,$.jsx)(A,{variant:`outline`,size:`sm`,onClick:fe,"data-testid":`problems-enable-plugins`,children:(0,$.jsx)(g,{id:`rnX-1S`})})})]}):k?null:(0,$.jsx)(je,{className:`px-2`,children:(0,$.jsx)(g,{id:`ZI8uvA`})}):(0,$.jsx)(je,{className:`px-2`,"data-testid":`problems-markdown-not-applicable`,children:(0,$.jsx)(g,{id:`Kdvukk`})}):null:(0,$.jsxs)($.Fragment,{children:[c!==void 0||u!==void 0?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1 px-2 pb-1`,children:[c!==void 0&&(0,$.jsx)(wr,{count:re,problemCount:X.length,aiAvailable:u!==void 0,disabled:re===0,onClick:c}),u!==void 0&&(0,$.jsx)(Tr,{count:X.length,disabled:!1,onClick:()=>u(`doc`)})]}):null,(0,$.jsx)(`ul`,{"aria-label":m({id:`OXdGnd`}),className:`flex flex-col gap-0.5`,children:vr(X).map(e=>(0,$.jsx)(yr,{group:e,onNavigate:Re,navTitle:e=>m({id:`vbMHjo`,values:{0:e.range.start.line+1}}),renderActions:We},e.key))})]})]}):(0,$.jsx)(Fr,{audit:L,onRefresh:()=>void ae(),onNavigate:Be,fixableCount:le.reduce(Or,0),problemCount:L.status===`loaded`?L.result.files.reduce(Dr,0):0,fixing:R,onAutoFix:de,onCancelFix:Xn,onFixWithAi:u===void 0||L.status!==`loaded`?void 0:()=>u(`project`),onCreateTarget:z===null?void 0:e=>void se(e),creatingTarget:B}),$e;return t[53]!==Ge||t[54]!==v||t[55]!==Xe||t[56]!==Ze||t[57]!==Qe?($e=(0,$.jsxs)(Ge,{ref:h,tabIndex:-1,"aria-labelledby":v,"data-testid":`problems-panel`,children:[Xe,Ze,Qe]}),t[53]=Ge,t[54]=v,t[55]=Xe,t[56]=Ze,t[57]=Qe,t[58]=$e):$e=t[58],$e}function Dr(e,t){return e+t.diagnostics.length}function Or(e,t){return e+xr(t.diagnostics)}function kr(e){return e.label}function Ar(e){return Ve(me(e.file))}function jr(e){return e.diagnostics.some(Mr)}function Mr(e){return(e.fixes?.length??0)>0}function Nr(){}function Pr(){}function Fr(e){let t=(0,Q.c)(81),{audit:n,onRefresh:r,onNavigate:i,fixableCount:a,problemCount:o,fixing:s,onAutoFix:c,onCancelFix:l,onFixWithAi:u,onCreateTarget:d,creatingTarget:f}=e,{_:p}=_(),m=n.status===`loading`||n.status===`idle`,h;t[0]!==n.result||t[1]!==n.status?(h=n.status===`loaded`?n.result.files:[],t[0]=n.result,t[1]=n.status,t[2]=h):h=t[2];let v=h,[y,b]=(0,Z.useState)(Rr),x;t[3]!==y||t[4]!==v?(x=v.length>0&&v.every(e=>y.has(e.file)),t[3]=y,t[4]=v,t[5]=x):x=t[5];let T=x,E;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(E=function(e,t){b(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},t[6]=E):E=t[6];let D=E,O;t[7]!==T||t[8]!==v?(O=function(){b(T?new Set:new Set(v.map(Lr)))},t[7]=T,t[8]=v,t[9]=O):O=t[9];let k=O,j;t[10]!==n.result||t[11]!==n.status?(j=n.status===`loaded`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{id:`DsDwR-`,values:{0:n.result.errorCount}}),` · `,(0,$.jsx)(g,{id:`W1SI2K`,values:{0:n.result.warningCount}})]}),t[10]=n.result,t[11]=n.status,t[12]=j):j=t[12];let M;t[13]===j?M=t[14]:(M=(0,$.jsx)(`p`,{className:`min-w-0 truncate text-xs text-muted-foreground`,"data-testid":`problems-audit-summary`,children:j}),t[13]=j,t[14]=M);let N;t[15]!==p||t[16]!==T||t[17]!==v.length||t[18]!==k?(N=v.length>0?(0,$.jsxs)(w,{children:[(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(A,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":p(T?{id:`I4LGsH`}:{id:`Ugvy4O`}),"data-testid":`problems-audit-expand-toggle`,onClick:k,children:T?(0,$.jsx)(We,{"aria-hidden":`true`,className:`size-3.5`}):(0,$.jsx)(U,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,$.jsx)(C,{"data-testid":`problems-audit-expand-toggle-tooltip`,children:T?(0,$.jsx)(g,{id:`I4LGsH`}):(0,$.jsx)(g,{id:`Ugvy4O`})})]}):null,t[15]=p,t[16]=T,t[17]=v.length,t[18]=k,t[19]=N):N=t[19];let P;t[20]===p?P=t[21]:(P=p({id:`I7y_vn`}),t[20]=p,t[21]=P);let F=m||s!==null,I;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(se,{"aria-hidden":`true`,className:`size-3.5`}),t[22]=I):I=t[22];let L;t[23]!==r||t[24]!==P||t[25]!==F?(L=(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(A,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":P,"data-testid":`problems-audit-refresh`,disabled:F,onClick:r,children:I})}),t[23]=r,t[24]=P,t[25]=F,t[26]=L):L=t[26];let ee;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(C,{"data-testid":`problems-audit-refresh-tooltip`,children:(0,$.jsx)(g,{id:`I7y_vn`})}),t[27]=ee):ee=t[27];let R;t[28]===L?R=t[29]:(R=(0,$.jsxs)(w,{children:[L,ee]}),t[28]=L,t[29]=R);let z;t[30]!==R||t[31]!==N?(z=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[N,R]}),t[30]=R,t[31]=N,t[32]=z):z=t[32];let B;t[33]!==z||t[34]!==M?(B=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[M,z]}),t[33]=z,t[34]=M,t[35]=B):B=t[35];let V;t[36]!==p||t[37]!==s?(V=s===null?null:(0,$.jsx)(`span`,{className:`sr-only`,role:`status`,children:p({id:`gZElfU`,values:{0:s.done,1:s.total}})}),t[36]=p,t[37]=s,t[38]=V):V=t[38];let H;t[39]!==p||t[40]!==s||t[41]!==l?(H=s===null?null:(0,$.jsxs)(w,{children:[(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(A,{variant:`ghost`,size:`sm`,className:`h-6 shrink-0 px-2 text-muted-foreground`,"aria-label":p({id:`q2cLM6`}),"data-testid":`problems-cancel-fix`,onClick:l,children:(0,$.jsx)(g,{id:`ygCKqB`})})}),(0,$.jsx)(C,{"data-testid":`problems-cancel-fix-tooltip`,children:(0,$.jsx)(g,{id:`yvSAuM`})})]}),t[39]=p,t[40]=s,t[41]=l,t[42]=H):H=t[42];let te=u!==void 0,W=m||s!==null||a===0,G;t[43]===s?G=t[44]:(G=s===null?void 0:(0,$.jsx)(g,{id:`S9t1PI`,values:{0:s.done,1:s.total}}),t[43]=s,t[44]=G);let K;t[45]!==a||t[46]!==c||t[47]!==o||t[48]!==te||t[49]!==W||t[50]!==G?(K=(0,$.jsx)(wr,{count:a,problemCount:o,aiAvailable:te,disabled:W,onClick:c,children:G}),t[45]=a,t[46]=c,t[47]=o,t[48]=te,t[49]=W,t[50]=G,t[51]=K):K=t[51];let q;t[52]!==s||t[53]!==u||t[54]!==o?(q=u!==void 0&&o>0?(0,$.jsx)(Tr,{count:o,disabled:s!==null,onClick:u}):null,t[52]=s,t[53]=u,t[54]=o,t[55]=q):q=t[55];let J;t[56]!==V||t[57]!==H||t[58]!==K||t[59]!==q?(J=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[V,H,K,q]}),t[56]=V,t[57]=H,t[58]=K,t[59]=q,t[60]=J):J=t[60];let ne;t[61]!==B||t[62]!==J?(ne=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-2 pb-1`,children:[B,J]}),t[61]=B,t[62]=J,t[63]=ne):ne=t[63];let Y;t[64]!==p||t[65]!==m?(Y=m&&(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,role:`status`,"aria-busy":`true`,"aria-label":p({id:`dx-TwN`}),children:[1,2,3].map(Ir)}),t[64]=p,t[65]=m,t[66]=Y):Y=t[66];let X;t[67]===n.status?X=t[68]:(X=n.status===`failed`&&(0,$.jsx)(ke,{className:`px-2 text-xs`,children:(0,$.jsx)(g,{id:`IFezUv`})}),t[67]=n.status,t[68]=X);let re;t[69]!==n.result||t[70]!==n.status||t[71]!==f||t[72]!==y||t[73]!==d||t[74]!==i?(re=n.status===`loaded`&&(0,$.jsx)(Br,{result:n.result,onNavigate:i,onCreateTarget:d,creatingTarget:f,expandedFiles:y,onToggleFile:D}),t[69]=n.result,t[70]=n.status,t[71]=f,t[72]=y,t[73]=d,t[74]=i,t[75]=re):re=t[75];let ie;return t[76]!==ne||t[77]!==Y||t[78]!==X||t[79]!==re?(ie=(0,$.jsxs)(Me,{className:`px-2 py-2`,"data-testid":`problems-project-scope`,children:[ne,Y,X,re]}),t[76]=ne,t[77]=Y,t[78]=X,t[79]=re,t[80]=ie):ie=t[80],ie}function Ir(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2 py-1.5`,children:[(0,$.jsx)(Be,{className:`mt-0.5 size-3.5 shrink-0 rounded`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(Be,{className:`h-3 w-28`}),(0,$.jsx)(Be,{className:`h-3 w-40`})]})]},e)}function Lr(e){return e.file}function Rr(){return new Set}function zr(e){let t=(0,Q.c)(6),{suppression:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(oe,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),t[0]=r):r=t[0];let i;t[1]===n.count?i=t[2]:(i=(0,$.jsx)(g,{id:`gi9c0-`,values:{0:n.count}}),t[1]=n.count,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(g,{id:`l91IVc`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,$.jsxs)(`div`,{role:`note`,"aria-live":`polite`,"data-testid":`problems-broken-link-suppression`,className:`mx-2 mb-1 flex items-start gap-1.5 rounded-md border border-border/70 bg-muted/40 px-2 py-1.5 text-xs text-muted-foreground`,children:[r,(0,$.jsxs)(`span`,{className:`min-w-0`,children:[i,` `,a]})]}),t[4]=i,t[5]=o),o}function Br(e){let t=(0,Q.c)(24),{result:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,expandedFiles:o,onToggleFile:s}=e,{_:c}=_(),l,u,d,f;if(t[0]!==c||t[1]!==n.warnings){let e=n.warnings.filter(Ur);l=n.warnings.filter(ze),u=`flex flex-col gap-1`,d=e.length>0&&(0,$.jsx)(`ul`,{"aria-label":c({id:`Rsdhj9`}),className:`flex flex-col gap-0.5 pb-1`,children:e.map(Hr)}),f=l.map(Vr),t[0]=c,t[1]=n.warnings,t[2]=l,t[3]=u,t[4]=d,t[5]=f}else l=t[2],u=t[3],d=t[4],f=t[5];let p;t[6]===n.brokenLinkSuppression?p=t[7]:(p=n.brokenLinkSuppression!==void 0&&(0,$.jsx)(zr,{suppression:n.brokenLinkSuppression}),t[6]=n.brokenLinkSuppression,t[7]=p);let m;t[8]!==a||t[9]!==l||t[10]!==o||t[11]!==i||t[12]!==r||t[13]!==s||t[14]!==n.brokenLinkSuppression||t[15]!==n.fileCount||t[16]!==n.files?(m=n.files.length===0?n.brokenLinkSuppression===void 0&&l.length===0?(0,$.jsx)(je,{className:`px-2`,children:(0,$.jsx)(g,{id:`k_Dqw1`,values:{0:n.fileCount}})}):null:n.files.map(e=>(0,$.jsx)(Wr,{file:e,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o.has(e.file),onOpenChange:t=>s(e.file,t)},e.file)),t[8]=a,t[9]=l,t[10]=o,t[11]=i,t[12]=r,t[13]=s,t[14]=n.brokenLinkSuppression,t[15]=n.fileCount,t[16]=n.files,t[17]=m):m=t[17];let h;return t[18]!==u||t[19]!==d||t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[d,f,p,m]}),t[18]=u,t[19]=d,t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23],h}function Vr(e){return(0,$.jsxs)(`div`,{role:`status`,className:`flex items-start gap-1.5 px-2 text-xs`,children:[(0,$.jsx)(oe,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`min-w-0 text-foreground`,children:e})]},e)}function Hr(e,t){return(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 px-2 text-xs`,children:[(0,$.jsx)(le,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-amber-500`}),(0,$.jsx)(`span`,{className:`min-w-0 text-foreground`,children:e})]},`${t}-${e}`)}function Ur(e){return!ze(e)}function Wr(e){let t=(0,Q.c)(45),{file:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o,onOpenChange:s}=e,{_:c}=_(),l,u,d,f,p,m,h,g,v,y;if(t[0]!==c||t[1]!==a||t[2]!==n.diagnostics||t[3]!==n.file||t[4]!==i||t[5]!==r||t[6]!==s||t[7]!==o){let e=[...n.diagnostics].sort(fr);u=D,h=o,g=s,v=`problems-audit-group`;let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(H,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none`}),t[18]=_):_=t[18];let b;t[19]===n.file?b=t[20]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,title:n.file,children:n.file}),t[19]=n.file,t[20]=b),y=(0,$.jsxs)(E,{className:`group flex w-full cursor-pointer items-center gap-1.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,children:[_,b,(0,$.jsx)(de,{variant:`gray`,"data-testid":`problems-audit-file-count`,className:`shrink-0`,children:e.length})]}),l=T,m=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in] motion-reduce:animate-none`,t[21]!==c||t[22]!==n.file?(d=c({id:`zAJzIg`,values:{0:n.file}}),t[21]=c,t[22]=n.file,t[23]=d):d=t[23],f=`flex flex-col gap-0.5 pb-1 ps-3`;let x;t[24]!==c||t[25]!==a||t[26]!==n.file||t[27]!==i||t[28]!==r?(x=e=>(0,$.jsx)(yr,{group:e,onNavigate:e=>r(n.file,e),navTitle:e=>c({id:`xKDsGS`,values:{0:e.range.start.line+1,1:n.file}}),renderActions:e=>!gr(e)||i===void 0?null:(0,$.jsx)(Sr,{target:e.linkTarget??``,creating:a===e.linkTarget,disabled:a!==null,onCreate:()=>i(e)})},e.key),t[24]=c,t[25]=a,t[26]=n.file,t[27]=i,t[28]=r,t[29]=x):x=t[29],p=vr(e).map(x),t[0]=c,t[1]=a,t[2]=n.diagnostics,t[3]=n.file,t[4]=i,t[5]=r,t[6]=s,t[7]=o,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=v,t[17]=y}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],v=t[16],y=t[17];let b;t[30]!==d||t[31]!==f||t[32]!==p?(b=(0,$.jsx)(`ul`,{"aria-label":d,className:f,children:p}),t[30]=d,t[31]=f,t[32]=p,t[33]=b):b=t[33];let x;t[34]!==l||t[35]!==m||t[36]!==b?(x=(0,$.jsx)(l,{className:m,children:b}),t[34]=l,t[35]=m,t[36]=b,t[37]=x):x=t[37];let S;return t[38]!==u||t[39]!==x||t[40]!==h||t[41]!==g||t[42]!==v||t[43]!==y?(S=(0,$.jsxs)(u,{open:h,onOpenChange:g,"data-testid":v,children:[y,x]}),t[38]=u,t[39]=x,t[40]=h,t[41]=g,t[42]=v,t[43]=y,t[44]=S):S=t[44],S}function Gr(e,t){return e.has(t)||P(t)}var Kr=/^(#{1,6})\s+(.+)$/;function qr(e,t){let n=(e.endsWith(`\r`)?e.slice(0,-1):e).match(Kr);if(!n)return null;let r=n[2].trim(),i=ve(r,t);return i?{level:n[1].length,text:r,slug:i}:null}var Jr=null,Yr=[];function Xr(e){if(e===Jr)return Yr;let t=Zr(e);return Jr=e,Yr=t,t}function Zr(e){let t=[],n=new Map,r=X();for(let i=Qr(e);i<=e.lines;i++){let a=e.line(i);if(r(a.text))continue;let o=qr(a.text,n);o&&t.push({slug:o.slug,from:a.from})}return t}function Qr(e){if(!$r(e.line(1).text))return 1;for(let t=2;t<=e.lines;t++)if($r(e.line(t).text))return t+1;return 1}function $r(e){return ee.test(e.endsWith(`\r`)?e.slice(0,-1):e)}function ei(e){let t=document.getElementById(e);return t?t.getBoundingClientRect().top:null}function ti(e){let t=new Map;for(let n of Xr(e.state.doc))t.set(n.slug,n.from);let n=e.documentTop;return r=>{let i=t.get(r);return i===void 0?null:n+e.lineBlockAt(i).top}}function ni(e,t){let n=(0,Q.c)(9),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{isSourceMode:i,docName:a}=r,o=i===void 0?!1:i,[s,c]=(0,Z.useState)(void 0),l=(0,Z.useRef)(null),u;n[2]===a?u=n[3]:(u=()=>a?q(a):null,n[2]=a,n[3]=u);let d=(0,Z.useSyncExternalStore)(K,u,ri),f,p;return n[4]!==o||n[5]!==e||n[6]!==d?(f=()=>{if(e.length===0||o&&!d){c(void 0);return}let t=function(){let t=o&&d?ti(d):ei,n=window.innerHeight/2,r,i;for(let a of e){let e=t(a);e!==null&&(e<0?r=a:i===void 0&&e<n&&(i=a))}c(i??r??e[0])},n=function(){l.current===null&&(l.current=requestAnimationFrame(()=>{l.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},p=[e,o,d],n[4]=o,n[5]=e,n[6]=d,n[7]=f,n[8]=p):(f=n[7],p=n[8]),(0,Z.useEffect)(f,p),s}function ri(){return null}var ii=300;async function ai(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new Y(N._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=z.safeParse(n);throw e.success?Error(e.data.title):new Y(N._({id:`zlErBl`}),{status:t.status})}let r=L.safeParse(n);if(!r.success)throw new Y(N._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var oi=32,si=12,ci=6,li=`open-knowledge:outline-nav`,ui=`ok-outline-nav`,di=`ok-outline-nav-dispatch`,fi=`ok-outline-nav-settled`;function pi(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(_e,{name:`outline-panel`,children:(0,$.jsx)(mi,{...e})}),t[0]=e,t[1]=n),n}function mi(e){let t=(0,Q.c)(65),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{_:o}=_(),{pages:s,loading:l,error:u}=Oe(),d=v(),{activeProvider:f,activeDocName:p}=c(),m;t[0]!==n||t[1]!==s?(m=Gr(s,n),t[0]=n,t[1]=s,t[2]=m):m=t[2];let h=m,b;t[3]!==n||t[4]!==d?(b=d.getQueryState([`page-headings`,n]),t[3]=n,t[4]=d,t[5]=b):b=t[5];let S=!l&&u===null&&!h&&b!==void 0,C,w;t[6]===n?(C=t[7],w=t[8]):(C=[`page-headings`,n],w=()=>ai(n),t[6]=n,t[7]=C,t[8]=w);let T=!l&&h,E;t[9]!==C||t[10]!==w||t[11]!==T?(E={queryKey:C,queryFn:w,enabled:T,staleTime:1/0},t[9]=C,t[10]=w,t[11]=T,t[12]=E):E=t[12];let{data:D,isLoading:O,error:k}=y(E),A;t[13]===D?A=t[14]:(A=D===void 0?[]:D,t[13]=D,t[14]=A);let j=A,M,N;t[15]!==n||t[16]!==S||t[17]!==d?(M=()=>{S&&d.resetQueries({queryKey:[`page-headings`,n]})},N=[S,n,d],t[15]=n,t[16]=S,t[17]=d,t[18]=M,t[19]=N):(M=t[18],N=t[19]),(0,Z.useEffect)(M,N);let P,F;t[20]!==p||t[21]!==f||t[22]!==n||t[23]!==d?(P=()=>{if(!f||p!==n)return;let e=f.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,d.invalidateQueries({queryKey:[`page-headings`,n]})},ii)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},F=[f,p,n,d],t[20]=p,t[21]=f,t[22]=n,t[23]=d,t[24]=P,t[25]=F):(P=t[24],F=t[25]),(0,Z.useEffect)(P,F);let I=l||O,L;t[26]===j?L=t[27]:(L=j.map(hi),t[26]=j,t[27]=L);let ee=L,R;t[28]!==n||t[29]!==r?(R={isSourceMode:r,docName:n},t[28]=n,t[29]=r,t[30]=R):R=t[30];let z=ni(ee,R),B,V,H,U,te,W,G;if(t[31]!==o||t[32]!==z||t[33]!==a||t[34]!==n||t[35]!==k||t[36]!==j||t[37]!==I||t[38]!==r||t[39]!==S){let e=z?j.findIndex(e=>e.slug===z):-1,i=function(t,i){let a={docName:n,index:t,slug:i,mode:r?`source`:`wysiwyg`};a.mode===`source`&&wt(n,{kind:`outline`,detail:a}),he(di,{docName:n,index:t,mode:a.mode,outlineCount:j.length,headingLevel:j[t]?.level,activeIndex:e}),window.dispatchEvent(new CustomEvent(li,{detail:a}))},s=((e>=0?j[e].level:1)-1)*si+(si-ci)/2,c=e*oi+(oi-ci)/2;V=Fe,W=a;let l;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ae,{children:(0,$.jsx)(g,{id:`dD7NPy`})}),t[47]=l):l=t[47];let u;t[48]!==k||t[49]!==j.length||t[50]!==I||t[51]!==S?(u=!I&&!k&&!S&&(0,$.jsx)(Ne,{children:j.length}),t[48]=k,t[49]=j.length,t[50]=I,t[51]=S,t[52]=u):u=t[52],t[53]===u?G=t[54]:(G=(0,$.jsx)(Pe,{children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[l,u]})}),t[53]=u,t[54]=G),B=Me,H=`px-3 py-2`,U=I,te=S?(0,$.jsx)(je,{className:`px-2`,role:`status`,children:(0,$.jsx)(g,{id:`0x9smA`})}):k?(0,$.jsx)(ke,{className:`px-2`,children:k instanceof Error?k.message:o({id:`GuqOb1`})}):j.length===0&&!I?(0,$.jsx)(je,{className:`px-2`,children:(0,$.jsx)(g,{id:`0BB9ID`})}):(0,$.jsxs)(`nav`,{"aria-label":o({id:`BymzO4`}),className:`relative`,children:[e>=0&&(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:ci,height:ci,transform:`translate(${s}px, ${c}px)`}}),j.map((e,t)=>{let n=e.slug===z;return(0,$.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>i(t,e.slug),className:x(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*si+20}px`},title:e.text,children:e.text},t)})]}),t[31]=o,t[32]=z,t[33]=a,t[34]=n,t[35]=k,t[36]=j,t[37]=I,t[38]=r,t[39]=S,t[40]=B,t[41]=V,t[42]=H,t[43]=U,t[44]=te,t[45]=W,t[46]=G}else B=t[40],V=t[41],H=t[42],U=t[43],te=t[44],W=t[45],G=t[46];let K;t[55]!==B||t[56]!==H||t[57]!==U||t[58]!==te?(K=(0,$.jsx)(B,{className:H,"aria-busy":U,children:te}),t[55]=B,t[56]=H,t[57]=U,t[58]=te,t[59]=K):K=t[59];let q;return t[60]!==V||t[61]!==W||t[62]!==G||t[63]!==K?(q=(0,$.jsxs)(V,{className:W,children:[G,K]}),t[60]=V,t[61]=W,t[62]=G,t[63]=K,t[64]=q):q=t[64],q}function hi(e){return e.slug}var gi=!1;function _i(){return gi||!B()?!1:(gi=!0,!0)}export{mn as A,kt as B,Sn as C,Cn as D,wn as E,Pt as F,rt as G,yt as H,Dt as I,tt as K,Et as L,Rt as M,Qt as N,en as O,$t as P,At as R,gn as S,Tn as T,nt as U,wt as V,it as W,An as _,pi as a,Dn as b,dr as c,lr as d,ur as f,kn as g,On as h,fi as i,Yt as j,pn as k,Er as l,ar as m,ui as n,Xr as o,cr as p,li as r,Gr as s,_i as t,or as u,Mn as v,xn as w,En as x,Nn as y,Tt as z};
@@ -1,11 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Ac as t,B as n,H as r,Nc as i,Pc as a,V as o,Yd as s,aa as c,af as l,bl as u,cf as d,ku as f,l as p,oa as m,rf as h,u as ee,xl as g}from"./md-manager-BGnqyqi1-DsBy1Dky.mjs";import{$o as _,Dt as v,Mi as y,Ni as b,Qo as x,Sr as S,Xo as C,Yn as w,_i as T,ar as E,ba as D,es as O,gi as te,hi as ne,li as re,lr as k,m as A,ri as j,wo as M,ys as N}from"./dist-BHg9XI3A.mjs";import{t as P}from"./yazl-BBz29IQN.mjs";import{Ct as F,ot as I,st as ie}from"./init-CrjTf1pi.mjs";import{l as ae,x as oe}from"./registry-probes-CtY_1ly1.mjs";import{c as se}from"./colors-r_owlCuY.mjs";import{t as ce}from"./is-object-BGze3w87.mjs";import{n as le}from"./constants-DPhkbJXs.mjs";import"./loader-CrmSAWIW.mjs";import"./preview-B2beHnfh.mjs";import{execSync as ue,spawnSync as de}from"node:child_process";import{basename as L,dirname as R,isAbsolute as fe,join as z,relative as pe,resolve as B,sep as V}from"node:path";import{closeSync as me,cpSync as he,createWriteStream as ge,existsSync as H,lstatSync as _e,mkdirSync as U,mkdtempSync as ve,openSync as ye,readFileSync as W,readSync as be,readdirSync as G,readlinkSync as xe,realpathSync as Se,rmSync as K,rmdirSync as Ce,statSync as we,writeFileSync as q}from"node:fs";import{arch as Te,freemem as Ee,homedir as J,hostname as De,platform as Oe,release as ke,tmpdir as Ae,totalmem as je,type as Me,uptime as Ne}from"node:os";import"node:fs/promises";import{createHash as Pe}from"node:crypto";function Fe(e,t){let n=t.map(e=>[N(e),e]);for(let t of e){let e=N(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function Ie(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=Fe([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=Fe(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function Le(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const Re=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function ze(e,t,n=k){if(e!==void 0&&!Re.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Be=null;function Ve(e){Be=e}function He(){return Be??process.cwd()}const Ue=`Open Knowledge`;function We(e={}){let t=e.platformName??process.platform,n=e.productName??h().productName;return I(t).join(ie({...e,platformName:t}),n)}function Ge(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=I(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`${h().packageName.replaceAll(`/`,``)}-updater`)}function Ke(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function qe(e){let t=z(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Ke(n)??[]}function Je(e){let t=z(e,`state.json`);if(!H(t))return!1;try{return Ke(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Ye=8192;function Xe(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function Ze(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Qe=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function $e(e){return e.replace(Qe,`$1"[REDACTED-DEVICE-ID]"`)}function et(e){return $e(Ze(e))}const tt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function nt(e){if(typeof e!=`string`)return null;let t=tt.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function rt(e){let t=ye(e,`r`);try{let e=Buffer.alloc(Ye),n=0,r=!1;for(;n<Ye;){let i=be(t,e,n,Ye-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{me(t)}}function it(e){try{let t=rt(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:nt(a)}}catch{return{kind:`unreadable`}}}function at(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function ot(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=z(e,t.name),r;try{r=we(n).mtimeMs}catch{continue}if(r<i)continue;let c=it(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!at(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}function st(){return z(C(),`bug-reports`)}function ct(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=st(),r=`${t}-bugreport`,i=z(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=z(n,`${r}-${e}.zip`);return i}function lt(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function ut(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let e=W(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return H(z(e,`.ok`))?Pe(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function dt(){let e={timestamp:new Date().toISOString(),platform:Oe(),osType:Me(),osRelease:ke(),hostname:`[redacted]`,uptime:Ne(),freeMem:Ee(),totalMem:je(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ue(`sw_vers -productVersion 2>/dev/null`,M({encoding:`utf8`})).trim()}catch{}try{let t=z(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const ft=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function pt(e){let t=L(e);return ft.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function mt(e,t){return vt(e,t).files}const ht=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function gt(e,t=ae){let n=z(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return ht.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>z(n,e.entry)))}function _t(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-p.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>z(e,t))}catch{return[]}}function vt(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>z(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(pt),i=[],a=r.filter(t=>{try{return W(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!pt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function yt(e){let n=z(e,`.ok`,`local`);return H(n)?{files:[`server.lock`,`last-spawn-error.log`,i,t].map(e=>z(n,e)).filter(e=>H(e))}:{files:[]}}function bt(e){let t=z(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function xt(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Pe(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function St(e){let t=e.revealDocNames?e.content:xt(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=m(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function Y(e){for(let t of e.files)try{let n=W(t,`utf8`);St({zipfile:e.zipfile,name:`${e.prefix}/${L(t)}`,content:t.endsWith(`.ips`)?et(n):n,redact:e.redact,revealDocNames:e.revealDocNames,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Ct(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??z(C(),`logs`),s=t.projectDir?ut(t.projectDir,i):null;U(R(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let l=dt();l.desktop=t.desktop??null,l.language=t.language??null;let{files:u,excludedByProjectSlug:d}=vt(s,o),{files:f}=t.projectDir?yt(t.projectDir):{files:[]},{files:p}=t.projectDir?bt(t.projectDir):{files:[]},m=t.shipItLogFiles??[],h=t.diagnosticReports?.files??[];i?.info({logFileCount:u.length,logFilesExcludedByProjectSlug:d,lockFileCount:f.length,localSinkFileCount:p.length,shipItLogFileCount:m.length,diagnosticReportCount:h.length},`files collected`);let g=[],_=[],{ZipFile:v}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),y=new v;Y({zipfile:y,files:[...u,...m],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),Y({zipfile:y,files:f,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),Y({zipfile:y,files:p,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),Y({zipfile:y,files:t.bugReportLedgerFiles??[],prefix:ee,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),Y({zipfile:y,files:h,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??L(e.sourcePath)}`;y.addBuffer(t,n),_.push(n);let r=lt(e,n);r!==null&&g.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&St({zipfile:y,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:_,redactions:g});let b=new Set(h.map(e=>`diagnostic-reports/${L(e)}`)),x=_.filter(e=>b.has(e)),S=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Xe(t.diagnosticReports,x.length);y.addBuffer(Buffer.from(`${S}\n`,`utf8`),`state/diagnostic-reports-status.txt`),_.push(`state/diagnostic-reports-status.txt`);let w=JSON.stringify(l,null,2);y.addBuffer(Buffer.from(w,`utf8`),`sysinfo.json`),_.push(`sysinfo.json`);let T={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:_,redactions:g,sysinfo:l};y.addBuffer(Buffer.from(JSON.stringify(T,null,2),`utf8`),`MANIFEST.json`);let E=g.reduce((e,t)=>e+t.lineCount,0),D=new Set(m.map(e=>`logs/${L(e)}`)),O=_.filter(e=>D.has(e)),te=new Set((t.bugReportLedgerFiles??[]).map(e=>`${ee}/${L(e)}`)),ne=_.filter(e=>te.has(e)),re=s?_.filter(e=>e.startsWith(`logs/`)&&!pt(e)&&!D.has(e)):[],k=x.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],A=k.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...k]:[`Redaction was disabled for this bundle; file contents are unmodified.`],j=[`# Bug Report Bundle`,``,`Generated: ${T.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${T.disciplineVersion}`,``,`## Contents`,``,..._.map(e=>`- ${e}`),``,`## Privacy`,``,...re.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...re.map(e=>`- ${e}`),``]:[],...O.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...O.map(e=>`- ${e}`),``]:[],...x.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...x.map(e=>`- ${e}`),``]:[],...ne.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...ne.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${c.join(`, `)}`,E>0?`${E} line(s) were scrubbed across ${g.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...k,``,`This bundle is safe to attach to a GitHub issue.`]:A].join(`
2
- `);y.addBuffer(Buffer.from(j,`utf8`),`README.md`),y.end();let M=ge(r);return y.outputStream.pipe(M),await new Promise((e,t)=>{M.on(`close`,e),M.on(`error`,t)}),i?.info({bundlePath:r,fileCount:_.length,redactionCount:E},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:_,redactions:g,redactedLineCount:E,generatedAt:T.generatedAt}}}var wt=f(),Tt=e(P(),1),X=e(se(),1);function Et(e){let t=O(`user`,e,e);return x({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Dt({home:e=J(),env:t=process.env}={}){let n=Et(e),{override:r,preferenceList:i}=_(t),{locale:a,source:o}=Ie({override:r,storedPreference:n,supportedLocales:g,preferenceList:i,autoDetectableLocales:u});return{preference:n,locale:a,source:o,systemLanguages:i}}function Ot(e){let t=new Set([e]);try{t.add(Se.native(e))}catch{return[e].filter(e=>e.length>0)}return[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length)}function kt(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function At(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function jt(e,t){if(typeof e==`string`)return kt(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>jt(e,t));if(!At(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=jt(i,t);return n}function Mt(e,t){let n=W(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
3
- `),i=n.split(`
4
- `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=jt(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
5
- `)}\n`:a.join(`
6
- `);q(e,o)}function Nt(e,t){let n=W(e,`utf-8`);if(n.trim().length!==0)try{let r=jt(JSON.parse(n),t),i=n.endsWith(`
7
- `)?`
8
- `:``;q(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=kt(n,t.contentDirSpellings);r!==n&&q(e,r)}}function Pt(e,t){let n=W(e,`utf-8`),r=kt(n,t.contentDirSpellings);r!==n&&q(e,r)}function Ft(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>z(e,t.name))}catch{return[]}}const It=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Lt(e){return/\.log\.\d+$/.test(e)}function Rt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Lt(e)}const zt=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Bt(e){let t={contentDirSpellings:Ot(e.contentDir)};for(let n of zt)for(let r of Ft(z(e.stagingDir,n)))Rt(r)?Mt(r,t):r.endsWith(`.json`)?Nt(r,t):Pt(r,t);for(let n of Ft(z(e.stagingDir,`state`))){let e=L(n);n.endsWith(`.jsonl`)?Mt(n,t):It.has(e)?Nt(n,t):Pt(n,t)}}const Vt=[`.ok`,`local`,`telemetry`],Ht=[`.ok`,`local`,`logs`],Ut=[`.ok`,`local`,`loss-capture`],Wt=`spans-current.jsonl`,Gt=`spans-prev.jsonl`,Kt=`server-current.jsonl`,qt=`server-prev.jsonl`,Jt=`loss-current.jsonl`,Yt=`loss-prev.jsonl`;function Xt(e){return z(e,...Vt,Wt)}function Zt(e){return z(e,...Vt,Gt)}function Qt(e){return z(e,...Ht,Kt)}function $t(e){return z(e,...Ht,qt)}function en(e){return z(e,...Ut,Jt)}function tn(e){return z(e,...Ut,Yt)}const nn=1e3;async function rn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(nn)});return t.ok?await t.text():null}catch{return null}}async function an(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(nn)});return t.ok?await t.text():null}catch{return null}}async function on(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(nn)});return t.ok?await t.text():null}catch{return null}}function sn(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
9
- `)}\n`:null}catch{return null}}function cn(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=de(`git`,[`-C`,t,`log`,`--oneline`,`-50`],M({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ln(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=de(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],M({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function un(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function dn(){return{nodeVersion:process.version,platform:Oe(),arch:Te()}}function fn(){return process.env.OTEL_SDK_DISABLED===`false`}function pn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function mn(e){if(!H(e))return{};let t;try{t=(0,wt.parse)(W(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!pn(t))return{};let n=t.telemetry;if(!pn(n))return{};let r=n.localSink;return pn(r)?r:{}}function hn(e){return typeof e==`boolean`?e:void 0}function gn(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Z(e){if(pn(e))return gn(e.maxBytes)}function _n(e){let t=mn(O(`project`,e)),n=mn(O(`project-local`,e));return{enabled:hn(n.enabled)??hn(t.enabled)??!0,spansMaxBytes:Z(n.spans)??Z(t.spans)??52428800,logsMaxBytes:Z(n.logs)??Z(t.logs)??26214400}}function vn(e){return Pe(`sha256`).update(e).digest(`hex`)}function yn(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const bn=[`"doc.name"`,`"docName"`];function xn(e){let t=W(e,`utf-8`),n=0;for(let e of bn){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!H(e))return!1;try{return U(R(t),{recursive:!0}),e.endsWith(`.ips`)?q(t,et(W(e,`utf-8`))):he(e,t),!0}catch{return!1}}function Sn(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=z(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Cn=new Set([`.jsonl`]);function wn(e){let t=e.lastIndexOf(`.`);return t!==-1&&Cn.has(e.slice(t))}const Tn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function En(e){if(Lt(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Tn.has(e.slice(t))}function Dn(e){let t=[];for(let n of Sn(e)){let r=On(e,n);if(!En(r))continue;let{redacted:i,patterns:a,lineCount:o}=m(W(n,`utf-8`));a.length!==0&&(q(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function On(e,t){return pe(e,t).split(V).join(`/`)}async function kn(e){let n=B(e.contentDir),r=B(e.projectDir??e.contentDir),o=e.deps??{},s=o.fetchAgentPresence??rn,c=o.fetchAgentEffects??an,l=o.fetchWatcherRecent??on,u=o.readShadowHead??cn,d=o.readCheckpointRefs??ln,f=o.now??(()=>new Date),p=o.okVersion??(()=>le),m=o.readDesktopEnv??un,h=o.readLanguage??Dt,g=o.readRuntime??dn,_=o.isOtlpPushEnabled??fn,v=ve(z(Ae(),`ok-bundle-`));try{U(z(v,`telemetry`),{recursive:!0}),U(z(v,`logs`),{recursive:!0}),U(z(v,`state`),{recursive:!0}),Q(Xt(r),z(v,`telemetry`,Wt)),Q(Zt(r),z(v,`telemetry`,Gt)),Q(Qt(r),z(v,`logs`,Kt)),Q($t(r),z(v,`logs`,qt));for(let t of e.userLogFiles??[])Q(t,z(v,`logs`,L(t)));for(let t of e.userStateFiles??[])Q(t,z(v,ee,L(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Q(t,z(v,`diagnostic-reports`,L(t)))&&(y+=1);let b=z(r,`.ok`,`local`),x=z(b,`server.lock`),S=`not-running`,C=`no server.lock`,w=null;if(H(x)){Q(x,z(v,`state`,`server.lock`));try{let e=W(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?w=t.port:C=`lock present but no port`}catch{C=`lock present but unparseable`}}if(w!==null){let e=await s(w);e===null?C=`agent-presence endpoint at :${w} unreachable`:(q(z(v,`state`,`agent-presence.json`),e),S=`running`,C=``);let t=await c(w);t!==null&&q(z(v,`state`,`agent-effects.json`),t);let n=await l(w);if(n!==null){let e=sn(n);e!==null&&q(z(v,`state`,`watcher-recent.jsonl`),e)}}let T=u(n);T!==null&&q(z(v,`state`,`shadow-head.txt`),T);let E=d(n);E!==null&&q(z(v,`state`,`checkpoint-refs.txt`),E),Q(en(r),z(v,`state`,Jt)),Q(tn(r),z(v,`state`,Yt)),Q(z(b,`last-spawn-error.log`),z(v,`state`,`last-spawn-error.log`)),Q(z(b,a),z(v,`state`,a)),Q(z(b,i),z(v,`state`,i)),Q(z(b,t),z(v,`state`,t));let D=g(),O=m(),te=h(),ne={ok:{version:p(),nodeVersion:D.nodeVersion,platform:D.platform,arch:D.arch},host:{desktop:O,language:te}};q(z(v,`state`,`runtime.json`),`${JSON.stringify(ne,null,2)}\n`);let re=S===`running`?`running
10
- `:`not-running (${C})\n`;q(z(v,`state`,`server-status.txt`),re);let k=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Xe(e.diagnosticReports,y);if(q(z(v,`state`,`diagnostic-reports-status.txt`),`${k}\n`),e.processDir&&H(e.processDir)){let t=z(v,`process`);U(t,{recursive:!0}),he(e.processDir,t,{recursive:!0})}let A=e.redact===!0;A&&Bt({stagingDir:v,contentDir:n}),e.note&&q(z(v,`note.txt`),e.note);let j=null;e.scrubSecrets===!0&&(j=Dn(v));for(let t of e.extraFiles??[]){let e=t.zipName??L(t.sourcePath);if(!Q(t.sourcePath,z(v,`extra`,e))){o.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=lt(t,`extra/${e}`);n!==null&&(j??={redactions:[],redactedLineCount:0},j.redactions.push(n),j.redactedLineCount+=n.lineCount)}let M=_n(r),N=Sn(v),P=[],F=0,I=0;for(let e of N){let t=On(v,e),n=we(e).size,r=wn(t)?yn(e):0;P.push({path:t,bytes:n,lines:r}),F+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(I+=xn(e))}let ie={applied:A};j!==null&&(ie.secretScrub=j);let ae={schemaVersion:2,createdAt:f().toISOString(),ok:{version:p(),nodeVersion:D.nodeVersion,platform:D.platform,arch:D.arch},host:{desktop:O,language:te},contentDir:{pathSha256:vn(n),absolutePath:A?`<CONTENT_DIR>`:n},telemetry:{localSink:M,otlpPushEnabled:_()},redaction:ie,serverStatus:S,files:P};q(z(v,`manifest.json`),`${JSON.stringify(ae,null,2)}\n`);let oe=Ot(n),se=N.some(e=>{try{let t=W(e,`utf-8`);return oe.some(e=>t.includes(e))}catch{return!1}}),ce={stagedDiagnosticReports:y,totalBytes:F,fileCount:P.length,docNameCount:I,contentDirVisible:se,redacted:A},le=!1;return{stagingDir:v,manifest:ae,summary:ce,cleanup:()=>{le||(le=!0,K(v,{recursive:!0,force:!0}))}}}catch(e){throw K(v,{recursive:!0,force:!0}),e}}async function An(e){let{collected:t,outputPath:n}=e,r=R(n);if(!H(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Tt.ZipFile,a=Sn(t.stagingDir);for(let e of a){let n=On(t.stagingDir,e);i.addFile(e,n)}i.end();let o=ge(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function jn(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,wt.parse)(W(n,`utf-8`)),r=ce(t)?t.content:void 0,i=ce(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return B(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return B(e)}async function Mn(e,t,n,r,i){let a=ut(t,e.logger),o=await kn({contentDir:jn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...mt(a,e.userLogsDir??z(C(),`logs`)),...gt(e.cachesDir??z(J(),`Library`,`Caches`))],userStateFiles:_t(e.bugReportsDir??st()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(R(e.outputPath),{recursive:!0}),await An({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function Nn(e){let{projectDir:t}=e,n=e.readDesktopEnv??un,r=e.readLanguage??Dt,i=()=>ot(e.diagnosticReportsDir??z(J(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Mn(e,t,n,r,i());let{zipPath:a,summary:o}=await Ct({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:gt(e.cachesDir??z(J(),`Library`,`Caches`)),bugReportLedgerFiles:_t(e.bugReportsDir??st()),diagnosticReports:e.level===`full`?i():void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=T(e,t),i;try{i=W(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??S()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??De());if(!a||typeof a!=`object`||!re(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??j)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function Pn(e){return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${e.lockPath} does not record its owning machine, and its recorded process ${e.pid} is still running on this machine. Check whether process ${e.pid} is an OpenKnowledge server. If it is, stop it and retry. Do not remove the lock file while that process is running.`:`Cannot verify shutdown: the server lock at ${e.lockPath} belongs to another machine. Stop OpenKnowledge on the owning machine. Confirm that no OpenKnowledge server is using this directory on the owning machine or any other machine sharing it. Only then remove the stale lock file at ${e.lockPath} and retry cleanup.`}function Fn(e){return e.replace(/:\d+$/,``)}function In(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Fn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Fn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Fn(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const Ln=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Rn(e){return r(d(),e)}function zn(){return o(d())}function Bn(){let e=d();if(e===`stable`)return Ln;let t=n(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const Vn={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>_e(e),readlinkSync:e=>xe(e)};function Hn(e,t=Vn){let n=Rn(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function Un(e){let t=e.replace(Bn(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Wn(e,t,n=Vn){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const Gn=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],Kn=[...v.map(e=>A[e]),`open-knowledge`];function qn(e){if(!fe(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||R(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Jn(e,t){let n=pe(e,t);if(n.startsWith(`..`)||fe(n))return!1;let r=e;for(let e of n.split(V)){r=z(r,e);try{if(!_e(r).isDirectory())return!1}catch{return!1}}return!0}function Yn(e,t){try{return G(e).every(n=>t.has(z(e,n)))}catch{return!1}}function Xn(e){let t=qn(e),n=[],r=[],i=new Set;for(let e of Gn){let a=z(t,e.hostDir,`skills`);if(!Jn(t,a))continue;let o=Kn.map(e=>z(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=z(t,e.pruneRoot),c=a;for(;Yn(c,i)&&(r.push(c),i.add(c),c!==s);){let e=R(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Zn(e){try{if(!_e(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Qn(e){let t=new Set,n=new Set;for(let r of Gn){let i=z(e,r.hostDir,`skills`);for(let e of Kn)t.add(z(i,e));let a=z(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=R(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function $n(e,t){let n=qn(e),r=Qn(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(Jn(n,e)&&Zn(e))try{K(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Jn(n,e))try{Ce(e),a.push(e)}catch{}return a}function er(e){let t=qn(e),n=[];for(let e of v){let r=A[e];n.push({path:z(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of s)n.push({path:z(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function tr(e,t){let n=[];for(let r of er(e))if(r.bundleId===t)try{K(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function nr(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function rr(e,t=Date.now()){if(e===null)return`—`;let n=Le(e,t);return n===`unknown`?`—`:n}function ir(e){let t=R(e);return L(e)===`local`&&L(t)===`.ok`?R(t):L(e)===`.ok`?t:null}function ar(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:ir(e),server:{port:null,status:t.status,pid:t.pid,startedAt:null,usage:null},ui:null,hostname:null,lockPath:t.lockPath,binary:null,command:null,isDesktop:!1};let i=t.lock,a=t.status===`alive`&&ne(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:E(n),command:n,isDesktop:nr(n)}}function or(e){let t=e.server.status;switch(t){case`unverified-owner`:return`unverified`;case`alive`:return e.isDesktop?`desktop`:`running`;case`foreign-host`:return e.isDesktop?`desktop`:`foreign`;case`dead-pid`:return`stale`;default:return t}}const sr=new Set([`running`,`desktop`,`foreign`,`unverified`]);function cr(e){switch(e){case`running`:return X.default.green(e);case`desktop`:return X.default.blue(e);case`foreign`:return X.default.cyan(e);case`unverified`:case`stale`:return X.default.yellow(e)}}function lr(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ur(e){return`${lr(e.server.usage)} | ${lr(e.ui?.usage??null)}`}function dr(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function fr(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>[e.directory??`—`,dr(e),ur(e),or(e),String(e.server.pid),rr(e.server.startedAt),e.binary??`—`]),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=cr(or(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=X.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
11
- `)}async function pr(e={}){let t=e.discover??w,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??y,a=e.resolveUsage??b,o=await t(),s=[];for(let e of o){let t=n(e),r=ar(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:or(e)}));r(JSON.stringify(e,null,2));return}r(fr(e.all?s:s.filter(e=>sr.has(or(e)))))}function mr(){return new F(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale entries (foreign and unverified entries already show)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await pr({all:t.all===!0||e===`all`,json:t.json===!0})})}async function hr(e,t=oe()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=te(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function gr(e,t={}){return{targets:yr(e,t.isAlive??j)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}function _r(e){try{return d()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function vr(e){let t=e.inspect??(()=>$(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??hr,o=e.logger??oe(),s=t(),c=gr(s,{isAlive:e.isAlive});if(c.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let u=s.status===`alive`||s.status===`foreign-host`?s.lock.channel:void 0;if(e.force!==!0&&typeof u==`string`&&u.length>0){let t=e.selfChannel??_r(o);if(t!==void 0&&u!==t)return i(`Not stopping: the server at ${e.lockDir} belongs to ${l(u)}. Stop it from that app or its CLI, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,holderChannel:u,selfChannel:t,pids:c.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:u}}}if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:c.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let d=[],f=[];for(let e of c.targets)try{n(e.pid,`SIGTERM`),d.push(e)}catch(t){f.push({target:e,error:t instanceof Error?t.message:String(t)})}return d.length>0&&r(`Stopped: ${d.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:d.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:f.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),f.length>0&&i(`Failed to stop: ${f.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:d,failed:f,hadTargets:!0}}function yr(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function br(e,t=j){let n=await w(),r=null;for(let i of n){let n=$(i,`server`);if(yr(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function xr(e,t){let n=await vr({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function Sr(e,t,n={}){return t===0?`Nothing was running for ${e}, and no other open-knowledge servers are running.`:`Nothing was running for ${e}. ${t} other open-knowledge server${t===1?` is`:`s are`} running${n.listingFollows===!0?``:" — run `ok ps` to list them"}.`}async function Cr(e){let t=await w(),n=0;for(let r of t)r!==e&&yr($(r,`server`),j)&&n++;return n}function wr(e){return new F(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the enclosing project — run it from anywhere inside the project. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).option(`--force`,`Stop even when the server belongs to another OpenKnowledge app (Stable or Beta) or editor windows or agents are still connected to it`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=D(process.cwd()),n=await vr({lockDir:t,force:r,log:()=>{}});if(n.hadTargets){if(n.stopped.length>0){let e=n.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1)}else{let e=await Cr(t);console.log(Sr(process.cwd(),e,{listingFollows:e>0})),e>0&&await pr({})}return}if(i===`all`){let e=await w();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)yr($(n,`server`),j)&&(await xr(n,r),t++);t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(i)){let e=Number.parseInt(i,10),t=await br(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await xr(t,r);return}let a=B(He(),i),o=D(a),s=[],c=await vr({lockDir:o,force:r,log:e=>s.push(e)});if((c.failed.length>0||c.declined!==void 0)&&(process.exitCode=1),c.hadTargets)for(let e of s)console.log(e);else console.log(Sr(a,await Cr(o)))})}export{He as A,ot as C,We as D,Ge as E,ze as M,qe as O,st as S,Ue as T,$ as _,$n as a,An as b,er as c,Rn as d,zn as f,Pn as g,In as h,mr as i,Ve as j,Je as k,Ln as l,Un as m,vr as n,Xn as o,Hn as p,wr as r,tr as s,hr as t,Wn as u,Nn as v,Xe as w,ct as x,kn as y};
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-DsBy1Dky.mjs";import"./src-CnRhVti_.mjs";import"./init-CrjTf1pi.mjs";import"./registry-probes-CtY_1ly1.mjs";import"./start-UcVINga1.mjs";import{n as e}from"./loader-CrmSAWIW.mjs";import"./preview-B2beHnfh.mjs";import"./repair-mcp-configs-DlqDZ1Q-.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{S as e,m as t,p as n,r}from"./start-UcVINga1.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};