@inkeep/open-knowledge 0.71.2-beta.2 → 0.71.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/project/SKILL.md +3 -3
- package/dist/cli.mjs +54 -54
- package/dist/constants-CxlUP1NI.mjs +1 -0
- package/dist/dist-7-8deSgu.mjs +2098 -0
- package/dist/{dist-DaZTzrgH.mjs → dist-BkEwTwBP.mjs} +1 -1
- package/dist/index.mjs +202 -202
- package/dist/{init-BS8pi6aE.mjs → init-DFG0cPU3.mjs} +7 -7
- package/dist/init-gZpp7hP8.mjs +1 -0
- package/dist/{launch-json-removal-iYhWhAkh.mjs → launch-json-removal-DlPTMQpi.mjs} +1 -1
- package/dist/loader-Bv3pkUD5.mjs +1 -0
- package/dist/{loader-CEM2DZT5.mjs → loader-CRKeTl44.mjs} +1 -1
- package/dist/{md-manager-BGnqyqi1-C0-0a_4T.mjs → md-manager-BGnqyqi1-I1w3knRG.mjs} +159 -159
- package/dist/{open-browser-DOj8e8TD.mjs → open-browser-DH2Q-O-G.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-D-IkQ9O4.mjs +1 -0
- package/dist/{preview-BqT0WT0X.mjs → preview-e8KJ4I5m.mjs} +1 -1
- package/dist/public/assets/{ActivityModeContent-BbKjbMiA.js → ActivityModeContent-DAKAqxIi.js} +1 -1
- package/dist/public/assets/AddPropertiesButton-yHSN2vhg.js +2 -0
- package/dist/public/assets/{AgentDiffPane-BjhQ5oT2.js → AgentDiffPane-DOSD-XwJ.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-Cpxd_y8o.js → AgentThreadClientBinder-CcixiWZP.js} +1 -1
- package/dist/public/assets/{BugReportHistory-BFBxSZGO.js → BugReportHistory-1xBoxjRe.js} +1 -1
- package/dist/public/assets/{BugReportHistoryDialog-B9iSu7kb.js → BugReportHistoryDialog-B98PsL3_.js} +1 -1
- package/dist/public/assets/CodeMirrorPropInput-DM1hoPWp.js +3 -0
- package/dist/public/assets/{ConsentDialogBody-Da3QcM9i.js → ConsentDialogBody-CvvS7sW_.js} +1 -1
- package/dist/public/assets/{DiffViewBoundary-DoYnI8ZQ.js → DiffViewBoundary-D6P65lBv.js} +1 -1
- package/dist/public/assets/DocumentContext-C_rO0daK.js +38 -0
- package/dist/public/assets/{EditorModeToggle-SZE7OX5H.js → EditorModeToggle-BQ97dqMf.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-DZwVI77M.js → EnableSyncConfirmDialog-38WbAEim.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-BD82jzXA.js → ExcalidrawDocEditor-BNcCZJzL.js} +1 -1
- package/dist/public/assets/FeedbackForm-oIACnHI6.js +1 -0
- package/dist/public/assets/{GraphPanel-bSfesBVN.js → GraphPanel-Riqs8zY_.js} +1 -1
- package/dist/public/assets/{ImageAttachments-DCnmCMwy.js → ImageAttachments-DYcvX-9j.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-CC7FYOAx.js → ImportSkillDialog-p7rRnnmp.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-B7lZsXeL.js → LintConfigEditor-MDUfxECD.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-CDHe-m3B.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-DS1dvCFC.js → ManagedArtifactProperties-Cj06oTUL.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-Bt0B02Vg.js → MermaidDocEditor-CCHqgQcn.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-DT9DybGq.js → PropertyDisplayRow-DFVAoKF0.js} +1 -1
- package/dist/public/assets/{RegisteredAgentIcon-uzdinNgX.js → RegisteredAgentIcon-1u8OPkzG.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-E6Fob_yR.js → ReportBugDialogBody-BIvbsbMW.js} +2 -2
- package/dist/public/assets/{ReportBugMenuTrigger-vfXhqEcn.js → ReportBugMenuTrigger-4rfqK2yi.js} +2 -2
- package/dist/public/assets/{SchemaConfigEditor-DKOJ8BWG.js → SchemaConfigEditor-BeW7jMFy.js} +1 -1
- package/dist/public/assets/{SessionsHost-DdgAh7KC.js → SessionsHost-CyzsCjbr.js} +2 -2
- package/dist/public/assets/SettingsDialogBody-Fy43OGeZ.js +12 -0
- package/dist/public/assets/{ShareBranchSwitchDialog-gKoCKNmm.js → ShareBranchSwitchDialog-CeS2pq46.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-ZNb37P07.js → ShareReceiveDialog-ClHpnUYc.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-CYTNwQ0R.js → ShareReceiveMissDialog-DgKoeP9a.js} +1 -1
- package/dist/public/assets/{SkillCostValue-Bz5nwKsQ.js → SkillCostValue-CBjvYNMu.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-BCuondXM.js → SkillEditBanner-BsHna4Hf.js} +1 -1
- package/dist/public/assets/{SkillForkDialog-DuMxFnIM.js → SkillForkDialog-CMuFvog_.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-Dt9XoTzF.js → SkillInstallMenu-C59UVjLg.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-DeZR5fKf.js → SkillOriginInline-CSk_F2pn.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-becH_mip.js → SkillToolbarControls-0BgZQA3x.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-BL0Efw2b.js → SlidesToolbarControls-B_8qlRKc.js} +1 -1
- package/dist/public/assets/SourceEditor-HbxdekXO.js +1 -0
- package/dist/public/assets/{TerminalPanel-B8KnX1Qb.js → TerminalPanel-D8MvMzrY.js} +3 -3
- package/dist/public/assets/{TerminalWindowApp-BehY2GEl.js → TerminalWindowApp-BnLvN1Xj.js} +1 -1
- package/dist/public/assets/{TextDocEditor-CYxCP2r5.js → TextDocEditor-CflttJ_1.js} +1 -1
- package/dist/public/assets/{ThreadView-h4TWd7hW.js → ThreadView-DCpWDNwL.js} +3 -3
- package/dist/public/assets/{TimelineDiffPane-DcOGwDoz.js → TimelineDiffPane-DSLj5Z1h.js} +1 -1
- package/dist/public/assets/{agent-diff-store-Bz1uC7Vg.js → agent-diff-store-CsbFOqGp.js} +1 -1
- package/dist/public/assets/{auth-state-cache-DDsVxErS.js → auth-state-cache-Cw8sizke.js} +4 -4
- package/dist/public/assets/{bug-report-send-manager-MWas6qro.js → bug-report-send-manager-D0BmAaF4.js} +1 -1
- package/dist/public/assets/client-version-CPuNy1Sx.js +1 -0
- package/dist/public/assets/{comment-chips-CwAPmedw.js → comment-chips-BBeKpnLn.js} +1 -1
- package/dist/public/assets/{config-provider-CAlJf_RJ.js → config-provider-DwxBhKta.js} +3 -3
- package/dist/public/assets/{css-color-to-hex-DTpyOuFo.js → css-color-to-hex-B1xnsn4W.js} +1 -1
- package/dist/public/assets/{dist-DyIzmB4e.js → dist-CKA2_wgb.js} +100 -100
- package/dist/public/assets/{doc-hash-lEZL1-60.js → doc-hash-BwLoJO7y.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-DibYDt_n.js → doc-undo-manager-a9XoJkem.js} +1 -1
- package/dist/public/assets/{documents-events-BhD4StGH.js → documents-events-Ceh_cp-f.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-BW1mzcZg.js → file-tree-adapter-qcduIPf8.js} +1 -1
- package/dist/public/assets/{file-tree-utils-PzrGlJAG.js → file-tree-utils-BNJ3ROpz.js} +1 -1
- package/dist/public/assets/{folder-config-api-DnX5Sb8v.js → folder-config-api-D-7YhE42.js} +1 -1
- package/dist/public/assets/i18n-C59x9sec.js +1 -0
- package/dist/public/assets/index-BcmM8WMg.js +2205 -0
- package/dist/public/assets/{launcher-selection-C_llHRjt.js → launcher-selection-DTogNqZQ.js} +1 -1
- package/dist/public/assets/{lint-config-client-BWUce3vG.js → lint-config-client-4uUvkVug.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-ElUlIFqV.js → markdownlint-rule-browser-EGFSJU47.js} +1 -1
- package/dist/public/assets/messages-Bl9zNYXZ.js +1 -0
- package/dist/public/assets/messages-CC9zekFL.js +1 -0
- package/dist/public/assets/messages-CEvM7K61.js +1 -0
- package/dist/public/assets/messages-CaXLQsR1.js +1 -0
- package/dist/public/assets/messages-DEZS0xwS.js +1 -0
- package/dist/public/assets/messages-DOOCOiOK.js +1 -0
- package/dist/public/assets/messages-DjzrsPDj.js +1 -0
- package/dist/public/assets/messages-DsUGWxjP.js +1 -0
- package/dist/public/assets/messages-Nh73KzC1.js +1 -0
- package/dist/public/assets/messages-Q0vAhMus.js +1 -0
- package/dist/public/assets/messages-UsePQeMV.js +1 -0
- package/dist/public/assets/messages-Wag_mfpX.js +1 -0
- package/dist/public/assets/navigation-targets-CNqjrVcs.js +1 -0
- package/dist/public/assets/{page-list-cache-BMYenCYz.js → page-list-cache-B6WtCC89.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-B0WaT5YS.js → pending-receive-nav-store-CRef1TLe.js} +1 -1
- package/dist/public/assets/progress-B-kn1lP5.js +9 -0
- package/dist/public/assets/{project-paths-Doyo5LKO.js → project-paths-ByU0abNG.js} +1 -1
- package/dist/public/assets/{prop-types-BIbPZaOa.js → prop-types-BYV_mZe-.js} +1 -1
- package/dist/public/assets/{receive-store-DlTlJ5XT.js → receive-store-CUo7D3Xg.js} +1 -1
- package/dist/public/assets/{selection-context-CWFsKNpl.js → selection-context-cWsVlgmw.js} +1 -1
- package/dist/public/assets/{skill-scope-DUOFVFOe.js → skill-scope-B5R2BWWQ.js} +1 -1
- package/dist/public/assets/skills-api-B6xK8Waz.js +1 -0
- package/dist/public/assets/{src-CqpVBr8K.js → src-C9oM7BtR.js} +1 -1
- package/dist/public/assets/{startup-marks-BltEnhgt.js → startup-marks-RiT1uPCY.js} +1 -1
- package/dist/public/assets/{tag-pill-input-DW91XTBS.js → tag-pill-input-vnQTl5Dh.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-fdxlfpay.js → target-navigation-intent-CzpSqGnJ.js} +1 -1
- package/dist/public/assets/{telemetry-impl-k9dxXFAA.js → telemetry-impl-CqtA3NJO.js} +1 -1
- package/dist/public/assets/{telemetry-startup-XR9DKXgQ.js → telemetry-startup-DLnRwTx_.js} +1 -1
- package/dist/public/assets/{terminal-cli-display-DEakOmBF.js → terminal-cli-display-NSjvCThF.js} +1 -1
- package/dist/public/assets/{terminal-command-events-C6UXBdNc.js → terminal-command-events-DPijQAJx.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-D03uka1-.js → terminal-telemetry-CRxhTPje.js} +1 -1
- package/dist/public/assets/typing-burst-detector-CpYrXqpH.js +8 -0
- package/dist/public/assets/{uninstall-DBe4o9pX.js → uninstall-B_uZBJon.js} +1 -1
- package/dist/public/assets/{use-activity-panel-BEYTKIoo.js → use-activity-panel-BaHUMVcc.js} +1 -1
- package/dist/public/assets/{use-collab-url-Bu5itY1E.js → use-collab-url-CW1NMjbl.js} +1 -1
- package/dist/public/assets/{use-conflicts-mW2O3q7A.js → use-conflicts-CSAQWQnv.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-BPZA1eWT.js → use-live-xterm-theme-DJkq2DHU.js} +1 -1
- package/dist/public/assets/{use-open-skill-Q8DHnwW6.js → use-open-skill-wC_Rmtcn.js} +1 -1
- package/dist/public/assets/{use-settings-route-BCi5InHC.js → use-settings-route-DEECvMaD.js} +1 -1
- package/dist/public/assets/{use-skill-origin-Cs9rE0v_.js → use-skill-origin-Diow_PUB.js} +1 -1
- package/dist/public/assets/{use-skills-CgQB8nRT.js → use-skills-BQB8u19K.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-BdQOqH8G.js → use-terminal-enabled-CSrpUMXQ.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-CPG3aGDO.js → use-timeline-entry-diff-DJr-Ambx.js} +4 -4
- package/dist/public/assets/{use-workspace-BrVq04zg.js → use-workspace-Bk-cOozB.js} +1 -1
- package/dist/public/index.html +54 -54
- package/dist/public/uninstall.html +4 -4
- package/dist/{registry-probes-C76k8nXQ.mjs → registry-probes-BWwjsSPu.mjs} +2 -2
- package/dist/{removal-file-path-D62fA-37.mjs → removal-file-path-lnsrCN6L.mjs} +1 -1
- package/dist/{repair-launch-json-D05O991w.mjs → repair-launch-json-B3T_CUvH.mjs} +1 -1
- package/dist/{repair-mcp-configs-CHfth2Jm.mjs → repair-mcp-configs-0q6lAgXj.mjs} +1 -1
- package/dist/src-D9I28lG-.mjs +1 -0
- package/dist/src-Dv5ZXx4S.mjs +11 -0
- package/dist/{start-BYKbGiT_.mjs → start-DtSuBz0E.mjs} +3 -3
- package/dist/start-Z8dLkTxl.mjs +1 -0
- package/package.json +4 -4
- package/dist/constants-CDtlxNjm.mjs +0 -1
- package/dist/dist-9e6NmrQK.mjs +0 -2097
- package/dist/init-BqJ0_3DH.mjs +0 -1
- package/dist/loader-BhG6F89Z.mjs +0 -1
- package/dist/preview-C8mnnE3O.mjs +0 -1
- package/dist/public/assets/AddPropertiesButton-DhB8fBpO.js +0 -2
- package/dist/public/assets/CodeMirrorPropInput-DJMpl51W.js +0 -3
- package/dist/public/assets/DocumentContext-BdT4QvCj.js +0 -38
- package/dist/public/assets/FeedbackForm-BbB3RMo3.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-DcW-auIg.js +0 -1
- package/dist/public/assets/SettingsDialogBody-CHW54FiV.js +0 -12
- package/dist/public/assets/SourceEditor-BwY6mSBP.js +0 -1
- package/dist/public/assets/client-version-BrzB3ZFz.js +0 -1
- package/dist/public/assets/i18n-6dHpFTP1.js +0 -1
- package/dist/public/assets/index-CvLeHMQf.js +0 -2205
- package/dist/public/assets/messages-BNcdAJdj.js +0 -1
- package/dist/public/assets/messages-BQW2dr4q.js +0 -1
- package/dist/public/assets/messages-CC4OPnXO.js +0 -1
- package/dist/public/assets/messages-CZ6CbfUL.js +0 -1
- package/dist/public/assets/messages-CgcohXjC.js +0 -1
- package/dist/public/assets/messages-CwHjht3E.js +0 -1
- package/dist/public/assets/messages-DDMCaNZg.js +0 -1
- package/dist/public/assets/messages-DhU_MMo_.js +0 -1
- package/dist/public/assets/messages-DxTTA4B9.js +0 -1
- package/dist/public/assets/messages-l-GCh3wD.js +0 -1
- package/dist/public/assets/messages-p3H-WbVc.js +0 -1
- package/dist/public/assets/messages-upO1XdxK.js +0 -1
- package/dist/public/assets/navigation-targets-DfspBQqI.js +0 -1
- package/dist/public/assets/progress-BGIMEH8l.js +0 -9
- package/dist/public/assets/skills-api-CQ5y7Hxj.js +0 -1
- package/dist/public/assets/typing-burst-detector-DvNzlvB9.js +0 -8
- package/dist/src-B_zXHjLH.mjs +0 -1
- package/dist/src-DmJzOo1w.mjs +0 -11
- package/dist/start-CvIALlUf.mjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$o as e,A as t,Bs as n,Fs as r,Gs as i,Jr as a,Ko as o,Ks as s,Us as c,Vs as l,Ws as u,Xs as d,Ys as f,Zo as p,na as m,qo as h,zs as g}from"./dist-DyIzmB4e.js";import{r as _}from"./doc-paths-QmJhuuNf.js";import{o as v,r as y}from"./file-tree-utils-PzrGlJAG.js";function b(e){return e.scope===`project`?f(x(e)):s(e.scope,e.name,e.hostQualifier)}function x(e){return e.canonicalPath??e.path}function S(e,t){return e.scope===`project`?`${x(e).replace(/\/SKILL\.mdx?$/i,``)}/${f(t)}`:i(e.scope,e.name,t,e.hostQualifier)}function C(e){let t=l(e);return t?.kind===`skill`?t.name:null}function w(e){let t=e.trim();return{normalizedTarget:t.replace(/^\.\/+/,``).replace(/^\/+/,``).replace(/\/+$/g,``),expectsFolder:/\/+$/.test(t)}}function T(e){return _(e).replace(/\/+$/g,``)}var E=/\.(md|mdx)$/i;function D(e){let t=e;for(;E.test(t);){let e=t.replace(E,``);if(!e)return t;t=e}return t}function O(e,t){let{normalizedTarget:n,expectsFolder:r}=w(e);if(r||!E.test(n))return e;let i=D(n);return t.has(n)&&!t.has(i)?e:i}function k(e){let t=new Set;for(let n of e)for(let e of y(n))t.add(e);return t}function A(e,t){if(!t)return;let n=m(e);if(n)return t.get(n)}function j(e,t){if(!t||e.includes(`/`))return;let n=m(e);if(n)return t.get(n)}function M(e,t){return t?`${e}${t}`:(e.split(`/`).pop()??``).lastIndexOf(`.`)>0?e:`${e}.md`}function N(t,n){if(!v(t)||c(t)||n.pages.has(t))return null;let r=M(t,n.docExt);return{kind:`asset`,target:r,assetPath:r,mediaKind:e(r.slice(r.lastIndexOf(`.`)+1))}}function P(e,t){let i=O(e,t.pages);if(r(i)){let e=n(i);if(e?.kind===`skill`&&e.scope===`project`){let t=u(e.name);return{kind:`doc`,target:t,docName:t}}let t=g(i);if(t){let e=d(t.folder,t.name);return{kind:`doc`,target:e,docName:e}}return{kind:`doc`,target:i,docName:i}}if(C(i))return{kind:`doc`,target:i,docName:i};let a=c(i);if(a){let e=d(a.folder,a.name);return{kind:`doc`,target:e,docName:e}}let{normalizedTarget:s,expectsFolder:l}=w(i);if(!s)return{kind:`missing`,target:s};if(!l&&(p(s)||h(s)||o(s)))return{kind:`doc`,target:s,docName:s};let f=T(i);if(!l&&f!==s&&t.pages.has(f))return{kind:`doc`,target:f,docName:f};if(!l&&t.pages.has(s))return{kind:`doc`,target:s,docName:s};if(!l){let e=A(f,t.pagesBySlug);if(e)return{kind:`doc`,target:e,docName:e}}let m=`${f}/index`;if(t.pages.has(m))return{kind:`folder-index`,target:f,folderPath:f,docName:m,noteKind:`canonical-index`};let _=f.split(`/`).pop(),v=_?`${f}/${_}`:null;if(v&&t.pages.has(v))return{kind:`folder-index`,target:f,folderPath:f,docName:v,noteKind:`legacy-folder-note`};if(!l){let e=j(f,t.pagesByBasename);if(e)return{kind:`doc`,target:e,docName:e}}if((t.folderPaths??k(t.pages)).has(f))return{kind:`folder`,target:f,folderPath:f};if(!l){let e=N(s,t);if(e)return e}return{kind:`missing`,target:f||s}}function F(e){return e.kind===`folder-index`?{kind:`folder`,target:e.folderPath,folderPath:e.folderPath}:e}function I(e,n,r=t){return typeof n!=`number`||!a(n,r)?null:{kind:`large-file`,target:e,docName:e,size:n,limit:r}}function L(e,n,r=t){return e.kind!==`doc`&&e.kind!==`folder-index`?e:I(e.docName,n.get(e.docName)?.size,r)??e}function R(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{N as a,C as c,I as i,S as l,R as n,P as o,F as r,L as s,k as t,b as u};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{L as n,P as r,R as i}from"./DocumentContext-BdT4QvCj.js";import{t as a}from"./react-f2sANaYj.js";import{r as o}from"./dist-Nvb76hAm.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{t as c}from"./utils-CPqDy6Hr.js";import{r as l,t as u}from"./button-Cym3gapE.js";import{c as d,l as f}from"./dist-BcvirUWL.js";import{i as p,n as m,t as h}from"./tooltip-DttaCTqz.js";import"./separator-BVHriA5I.js";import{Ba as g,Ca as _,Ga as v,Ka as y,Wa as b,Xa as ee,Za as x,ba as te,ca as ne,da as S,la as re,rc as ie,ua as C}from"./dist-DyIzmB4e.js";import{t as w}from"./dist-Cr4-nBVI.js";import{i as ae}from"./local-menu-action-bus-4I1Xm40D.js";import{t as T}from"./workspace-paths-Dczkx4vn.js";import{t as oe}from"./createLucideIcon-B6ULg5PN.js";import{J as se,K as ce,O as le,V as ue,f as E,g as de,h as D,k as O,l as k,m as A,p as j,u as fe}from"./CodeMirrorPropInput-DJMpl51W.js";import{t as M}from"./spinner-Bp2_BYkl.js";import{t as N}from"./x-CnGRb1ER.js";import{h as pe}from"./file-tree-adapter-BW1mzcZg.js";var P=e(a(),1),F=t(),I=`Progress`,L=100,[me,he]=d(I),[ge,R]=me(I),z=P.forwardRef((e,t)=>{let{__scopeProgress:n,value:r=null,max:i,getValueLabel:a=H,...o}=e;(i||i===0)&&!G(i)&&console.error(_e(`${i}`,`Progress`));let s=G(i)?i:L;r!==null&&!K(r,s)&&console.error(q(`${r}`,`Progress`));let c=K(r,s)?r:null,l=W(c)?a(c,s):void 0;return(0,F.jsx)(ge,{scope:n,value:c,max:s,children:(0,F.jsx)(f.div,{"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":W(c)?c:void 0,"aria-valuetext":l,role:`progressbar`,"data-state":U(c,s),"data-value":c??void 0,"data-max":s,...o,ref:t})})});z.displayName=I;var B=`ProgressIndicator`,V=P.forwardRef((e,t)=>{let{__scopeProgress:n,...r}=e,i=R(B,n);return(0,F.jsx)(f.div,{"data-state":U(i.value,i.max),"data-value":i.value??void 0,"data-max":i.max,...r,ref:t})});V.displayName=B;function H(e,t){return`${Math.round(e/t*100)}%`}function U(e,t){return e==null?`indeterminate`:e===t?`complete`:`loading`}function W(e){return typeof e==`number`}function G(e){return W(e)&&!isNaN(e)&&e>0}function K(e,t){return W(e)&&!isNaN(e)&&e<=t&&e>=0}function _e(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${L}\`.`}function q(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
2
|
-
- a positive number
|
|
3
|
-
- less than the value passed to \`max\` (or ${L} if no \`max\` prop is set)
|
|
4
|
-
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
5
|
-
|
|
6
|
-
Defaulting to \`null\`.`}var J=z,Y=V,ve=oe(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),X=s(),ye=l(`group/button-group flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg!`,vertical:`flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg!`}},defaultVariants:{orientation:`horizontal`}});function be(e){let t=(0,X.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==r?(a=c(ye({orientation:r}),n),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o;return t[7]!==r||t[8]!==i||t[9]!==a?(o=(0,F.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":r,className:a,...i}),t[7]=r,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}var xe=`ok-ask-ai-draft-v2`,Se={doc:null,dismissed:!1};function Ce(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}var we=null,Te=new Set;function Ee(e){if(e===null)return!0;let t=e.content;return!Array.isArray(t)||t.length===0?!0:t.every(e=>{let t=e.content;return!Array.isArray(t)||t.length===0})}function De(){let e=Ce();if(!e)return Se;try{let t=e.getItem(xe);if(!t)return Se;let n=JSON.parse(t);return typeof n!=`object`||!n||Array.isArray(n)?Se:{doc:n,dismissed:!1}}catch(e){return console.warn(`failed to parse stored draft — clearing`,e),Se}}function Oe(){return we===null&&(we=De()),we}function ke(e){let t=Ce();if(t)try{e&&!Ee(e)?t.setItem(xe,JSON.stringify(e)):t.removeItem(xe)}catch{}}function Ae(){for(let e of Te)e()}function je(){return Oe()}function Me(e){let t=e&&!Ee(e)?e:null;we={...Oe(),doc:t},ke(t),Ae()}function Ne(){Me(null)}var Pe=ne;function Fe(e){let t=le(e).kind;return t===`folder`||t===`asset`?t:`page`}function Ie(e){let t=(0,X.c)(14),{items:n,query:i,selectedIndex:a,onSelect:s,loading:c,error:l,hasMore:u}=e,d=c===void 0?!1:c,f=l===void 0?!1:l,p=u===void 0?!1:u,{_:m}=o(),h=(0,P.useId)(),g=(0,P.useRef)(null),_,v;t[0]===a?(_=t[1],v=t[2]):(_=()=>{(g.current?.querySelectorAll(`[role="option"]`))?.item(a)?.scrollIntoView({block:`nearest`})},v=[a],t[0]=a,t[1]=_,t[2]=v),(0,P.useEffect)(_,v);let y=a>=0&&a<n.length?n[a]:null,b;return t[3]!==m||t[4]!==f||t[5]!==p||t[6]!==n||t[7]!==h||t[8]!==d||t[9]!==s||t[10]!==i||t[11]!==a||t[12]!==y?(b=(0,F.jsx)(`div`,{ref:g,className:`w-80 max-w-[min(28rem,90vw)] overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-md`,children:d?(0,F.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,"aria-live":`polite`,children:m({id:`3m2GBo`})}):f?(0,F.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,"aria-live":`assertive`,children:m({id:`weP6me`})}):n.length===0?(0,F.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,"aria-live":`polite`,children:i.trim()===``?m({id:`0E9DR6`}):m({id:`yQyglE`})}):(0,F.jsxs)(`div`,{role:`listbox`,id:h,"aria-label":m({id:`05n5wS`}),tabIndex:-1,className:`max-h-64 overflow-y-auto overscroll-contain subtle-scrollbar`,children:[(0,F.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:y?y.title:``}),n.map((e,t)=>{let n=t===a,i=Fe(e.path),o=i===`folder`,c=o?`${e.path}/`:e.path;return(0,F.jsxs)(`button`,{id:`${h}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-active":n,"data-mention-kind":i,"data-testid":`composer-mention-option-${e.docName}`,className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),s(e)},children:[(0,F.jsx)(r,{path:e.path,className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,F.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,children:[(0,F.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title}),o?(0,F.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:m({id:`kNqMMd`})}):null]}),(0,F.jsx)(`span`,{className:`line-clamp-2 break-all text-xs text-muted-foreground`,children:c})]})]},e.docName)}),p?(0,F.jsx)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,"aria-hidden":!0,children:m({id:`F1T9y_`})}):null]})}),t[3]=m,t[4]=f,t[5]=p,t[6]=n,t[7]=h,t[8]=d,t[9]=s,t[10]=i,t[11]=a,t[12]=y,t[13]=b):b=t[13],b}function Le(e){let t=(0,X.c)(12),{items:n,query:r,selectedIndex:i,onSelect:a,commandsKnown:s}=e,{_:c}=o(),l=(0,P.useId)(),u=(0,P.useRef)(null),d,f;t[0]===i?(d=t[1],f=t[2]):(d=()=>{(u.current?.querySelectorAll(`[role="option"]`))?.item(i)?.scrollIntoView({block:`nearest`})},f=[i],t[0]=i,t[1]=d,t[2]=f),(0,P.useEffect)(d,f);let p=i>=0&&i<n.length?n[i]:null,m;return t[3]!==c||t[4]!==s||t[5]!==n||t[6]!==l||t[7]!==a||t[8]!==r||t[9]!==i||t[10]!==p?(m=(0,F.jsx)(`div`,{ref:u,"data-testid":`composer-slash-menu`,className:`w-[42rem] max-w-[min(42rem,90vw)] overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-md`,children:n.length===0?(0,F.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,"aria-live":`polite`,children:s?r.trim()===``?c({id:`QohqVL`}):c({id:`odYWGJ`}):c({id:`9OPs7U`})}):(0,F.jsxs)(`div`,{role:`listbox`,id:l,"aria-label":c({id:`67Dpmh`}),tabIndex:-1,className:`max-h-64 overflow-y-auto overscroll-contain subtle-scrollbar`,children:[(0,F.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:p?`/${p.name}`:``}),n.map((e,t)=>{let n=t===i;return(0,F.jsxs)(`button`,{id:`${l}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-active":n,"data-testid":`composer-slash-option-${e.name}`,className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5 text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-sm font-medium`,children:[`/`,e.name]}),(0,F.jsx)(`span`,{className:`line-clamp-2 min-w-0 flex-1 text-xs text-muted-foreground`,children:e.description})]},e.name)})]})}),t[3]=c,t[4]=s,t[5]=n,t[6]=l,t[7]=a,t[8]=r,t[9]=i,t[10]=p,t[11]=m):m=t[11],m}var Re=new x(`composerSlashSuggestion`),ze=_.create({name:`composerCommand`,group:`inline`,inline:!0,atom:!0,selectable:!1,addAttributes(){return{name:{default:``},description:{default:``},hint:{default:``}}},parseHTML(){return[{tag:`span[data-composer-command]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.name??``);return[`span`,g(t,{"data-composer-command":n,class:`composer-slash-token composer-slash-token-known`}),`/${n}`]},renderText({node:e}){return`/${e.attrs.name}`}}),Be=new x(`composerSlashToken`),Ve=`composerSlashCommand`;function He(e){return e.storage[Ve]}function Ue(e){return He(e)?.commands??null}function We(e,t){let n=He(e);return n===void 0||n.commands===t?!1:(n.commands=t,!0)}function Ge(e,t){let n=t.trim().toLowerCase();if(n===``)return[...e];let r=[],i=[],a=[];for(let t of e){let e=t.name.toLowerCase();e.startsWith(n)?r.push(t):e.includes(n)?i.push(t):t.description.toLowerCase().includes(n)&&a.push(t)}return[...r,...i,...a]}function Ke(e){let t=/^\/(\S+)/.exec(e);return t===null?null:{name:t[1]??``,length:t[0].length}}function qe(e,t){let n=Ke(e);if(n===null||t===null)return null;let r=t.find(e=>e.name===n.name);return r===void 0?{kind:`unknown`,name:n.name,agentHasCommands:t.length>0}:{kind:`known`,name:r.name,description:r.description}}function Je(e){return Ye(e.state.doc.firstChild)}function Ye(e){let t=e?.firstChild??null;return t?.isText?t.text??``:``}function Xe(e,t){let n=e.firstChild,r=n?.firstChild??null;if(r!==null&&r.type.name===`composerCommand`){if(!$e(e))return y.empty;let t=String(r.attrs.hint??``),i=String(r.attrs.description??``),a=t===``?i===``?``:`— ${i}`:t;return a===``?y.empty:y.create(e,[Ze(1+(n?.content.size??0),a,String(r.attrs.name))])}if(t===null)return y.empty;let i=Ke(Ye(e.firstChild));if(i===null)return y.empty;let a=t.find(e=>e.name===i.name),o=[v.inline(1,1+i.length,{class:a===void 0?`composer-slash-token composer-slash-token-unknown`:`composer-slash-token composer-slash-token-known`})];if(a!==void 0&&Qe(e,i.length)){let t=a.input?.hint!=null&&a.input.hint!==``?a.input.hint:`— ${a.description}`;(a.description!==``||a.input?.hint)&&o.push(Ze(1+(e.firstChild?.firstChild?.nodeSize??0),t,a.name))}return y.create(e,o)}function Ze(e,t,n){return v.widget(e,()=>{let e=document.createElement(`span`);return e.className=`composer-slash-ghost`,e.setAttribute(`aria-hidden`,`true`),e.textContent=t,e},{side:1,key:`slash-ghost:${n}`})}function Qe(e,t){if(e.childCount!==1)return!1;let n=e.firstChild;if(n===null||n.childCount!==1)return!1;let r=n.firstChild;if(r===null||!r.isText)return!1;let i=r.text??``;return i.length<=t+1&&(i.length===t||i.endsWith(` `))}function $e(e){if(e.childCount!==1)return!1;let t=e.firstChild;if(t===null)return!1;if(t.childCount===1)return!0;if(t.childCount!==2)return!1;let n=t.child(1);return n.isText&&/^\s*$/.test(n.text??``)}var et=te.create({name:Ve,addOptions(){return{commands:null}},addStorage(){return{commands:this.options.commands}},addProseMirrorPlugins(){let e=this.storage,t=()=>e.commands??null;return[new ee({key:Be,state:{init:(e,n)=>Xe(n.doc,t()),apply:e=>Xe(e.doc,t())},props:{decorations(e){return this.getState(e)}}}),O({editor:this.editor,pluginKey:Re,char:`/`,startOfLine:!0,allow:({range:e})=>e.from===1,items:({query:e})=>{let n=t();return n===null||n.length===0?[]:Ge(n,e)},command:({editor:e,range:t,props:n})=>{let r=e.state.doc.firstChild?.firstChild??null,i=r?.isText?Ke(r.text??``)?.length??0:0;try{e.chain().focus().deleteRange({from:t.from,to:Math.max(t.to,1+i)}).insertContent([{type:`composerCommand`,attrs:{name:n.name,description:n.description,hint:n.input?.hint??``}},{type:`text`,text:` `}]).run()}catch(e){console.error(`[composer-slash-command] insert failed`,{item:n,range:t},e)}},render:()=>{let e=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=null,s=e=>{n?.command(e)},c=e=>{o=e.editor.view,D(o,(e.items??[]).length)},l=e=>({items:e.items??[],query:e.query??``,selectedIndex:r,onSelect:s,commandsKnown:t()!==null}),u=()=>{!e||!n||e.updateProps(l(n))};return{onBeforeStart(t){n=t,r=0,c(t);let o=j(()=>n,`composer-slash`);i.popup=o.popup,a=o.doPosition,e=new ce(Le,{props:l(t),editor:t.editor}),o.popup.appendChild(e.element),i.stopAutoUpdate=o.startAutoUpdate(),o.reveal()},onStart(e){n=e,r=0,c(e),u()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),c(e),u(),a?.()},onKeyDown({event:e}){if(!n)return!1;let t=n.items;if(e.key===`ArrowDown`)return t.length===0?!1:(r=(r+1)%t.length,u(),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(r=(r-1+t.length)%t.length,u(),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e?(n.command(e),!0):!1}return!1},onExit(){A(i),a=null,e?.destroy(),e=null,n=null,r=0,o!==null&&(E(o),o=null)}}}})]}}),tt=8,nt=new x(`composerMentionSuggestion`);function rt(e){return e.kind===`asset`?e.docName.replace(/^\//,``):e.kind===`folder`?e.docName:T(e.docName)}var it=_.create({name:`doc`,topNode:!0,content:`paragraph+`}),at=_.create({name:`paragraph`,group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML(){return[`p`,0]}}),ot=_.create({name:`text`,group:`inline`}),st=_.create({name:`hardBreak`,group:`inline`,inline:!0,selectable:!1,parseHTML(){return[{tag:`br`}]},renderHTML(){return[`br`]},addKeyboardShortcuts(){return{"Shift-Enter":()=>this.editor.commands.insertContent({type:`hardBreak`})}}}),ct=te.create({name:`composerHistory`,addProseMirrorPlugins(){return[re(),b({"Mod-z":S,"Mod-y":C,"Shift-Mod-z":C})]}}),lt=_.create({name:`composerMention`,group:`inline`,inline:!0,atom:!0,selectable:!0,addAttributes(){return{path:{default:``},label:{default:``},mentionKind:{default:`file`}}},parseHTML(){return[{tag:`span[data-composer-mention]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.label||e.attrs.path);return[`span`,g(t,{"data-composer-mention":String(e.attrs.path??``),class:`composer-mention-chip`}),`@${n}`]},renderText({node:e}){return`@${e.attrs.path}`},addNodeView(){return({node:e,editor:t,getPos:r})=>{let a=String(e.attrs.path??``),o=String(e.attrs.label||e.attrs.path),s=document.createElement(`span`);s.className=`composer-mention-chip group/mention`,s.setAttribute(`data-composer-mention`,a),s.title=o;let c=document.createElement(`button`);c.type=`button`,c.className=`composer-mention-icon`,c.setAttribute(`aria-label`,w._({id:`Xzy0s0`,values:{fullLabel:o}}));let l=document.createElement(`span`);l.className=`composer-mention-glyph composer-mention-glyph-icon`,l.setAttribute(`aria-hidden`,`true`),l.innerHTML=n(a),c.appendChild(l);let u=document.createElement(`span`);u.className=`composer-mention-glyph composer-mention-glyph-x`,u.setAttribute(`aria-hidden`,`true`),u.innerHTML=i(N),c.appendChild(u),c.addEventListener(`mousedown`,e=>e.preventDefault()),c.addEventListener(`click`,n=>{n.preventDefault();let i=typeof r==`function`?r():null;i!=null&&t.chain().focus().deleteRange({from:i,to:i+e.nodeSize}).run()}),s.appendChild(c);let d=document.createElement(`span`);return d.className=`composer-mention-label`,d.textContent=o,s.appendChild(d),{dom:s}}},addProseMirrorPlugins(){return[ft(this.editor)]}});function ut(e){return[it,at,ot,st,ct,lt,ze,...e?.slashCommands===void 0?[]:[et.configure({commands:e.slashCommands})],...e?.placeholder?[Pe.configure({placeholder:e.placeholder,showOnlyWhenEditable:!1})]:[]]}function dt(e=()=>k({includeFolders:!0})){let t=[],n=!1,r=null,i=!1;return{snapshot(){return{loaded:n,error:i}},async getItems(a){if(!n){r||=e();try{t=await r,n=!0,i=!1}catch(e){console.error(`[composer-mention] failed to fetch pages`,e),t=[],i=!0}finally{r=null}}return fe(t,a).map(e=>({docName:e.docName,title:e.title,path:rt(e),kind:e.kind===`folder`?`folder`:`file`})).filter(e=>e.path!==``)},reset(){t=[],n=!1,r=null,i=!1}}}function ft(e){let t=dt();return O({editor:e,pluginKey:nt,char:`@`,items:({query:e})=>t.getItems(e),command:({editor:e,range:t,props:n})=>{try{e.chain().focus().deleteRange(t).insertContent([{type:`composerMention`,attrs:{path:n.path,label:n.title,mentionKind:n.kind}},{type:`text`,text:` `}]).run()}catch(e){console.error(`[composer-mention] insert failed`,{item:n,range:t},e)}},render:()=>{let e=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=null,s=null,c=e=>{n?.command(e)},l=e=>{s=e.editor.view,D(s,(e.items??[]).length)},u=e=>{let n=e.items??[],{loaded:i,error:a}=t.snapshot();return{items:n,query:e.query??``,selectedIndex:r,onSelect:c,loading:!i&&!a,error:a,hasMore:n.length>=tt}},d=()=>{!e||!n||e.updateProps(u(n))};return{onBeforeStart(t){n=t,r=0,l(t);let s=j(()=>n,`composer-mention`);i.popup=s.popup,a=s.doPosition,o=s.reveal,e=new ce(Ie,{props:u(t),editor:t.editor}),s.popup.appendChild(e.element),i.stopAutoUpdate=s.startAutoUpdate()},onStart(e){n=e,r=0,l(e),d(),o?.()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),l(e),d(),a?.()},onKeyDown({event:e}){if(!n)return!1;let t=n.items;if(e.key===`ArrowDown`)return t.length===0?!1:(r=(r+1)%t.length,d(),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(r=(r-1+t.length)%t.length,d(),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e?(n.command(e),!0):!1}return!1},onExit(){A(i),a=null,o=null,e?.destroy(),e=null,n=null,r=0,s!==null&&(E(s),s=null),t.reset()}}}})}function Z(e){let t=[],n=[],r=new Set,i=[];return e.state.doc.forEach(e=>{let a=``;e.forEach(e=>{if(e.type.name===`composerMention`){let i=String(e.attrs.path??``);if(i!==``&&(a+=`@${i}`,!r.has(i))){r.add(i),t.push(i);let a=String(e.attrs.label??``),o=e.attrs.mentionKind===`folder`?`folder`:`file`;n.push({kind:o,path:i,name:a===``?i:a})}}else e.type.name===`composerCommand`?a+=`/${String(e.attrs.name??``)}`:e.isText?a+=e.text??``:e.type.name===`hardBreak`&&(a+=`
|
|
7
|
-
`)}),i.push(a)}),{instruction:i.join(`
|
|
8
|
-
`).trim(),mentions:t,attachments:n}}function Q(e){let{instruction:t,mentions:n}=Z(e);return t===``&&n.length===0}var pt=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),mt=700*1024,ht=mt,gt=mt;function _t(e){return e.kind!==`image`&&e.kind!==`blob`?0:e.sizeBytes??e.data.length}function vt(e){return e.reduce((e,t)=>e+_t(t),0)}function yt(){return Math.round(gt/1024)}function bt(e){if(e.kind===`unsupported-type`){let t=e.mimeType;if(t.startsWith(`image/`))return w._({id:`FqMKq2`,values:{mimeType:t}});let n=t||`unknown`;return w._({id:`9gu0n7`,values:{fileType:n}})}if(e.kind===`outside-workspace`){let t=e.name;return w._({id:`K9ViCA`,values:{name:t}})}if(e.kind===`unknown-path`){let t=e.name;return w._({id:`q8tKSU`,values:{name:t}})}let t=Math.round(e.limitBytes/1024),n=Math.round(e.sizeBytes/1024);return w._({id:`Kb08WL`,values:{sizeKb:n,limitKb:t}})}async function xt(e){let t=await new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`FileReader failed`)),r.onload=()=>{let e=r.result;if(typeof e!=`string`){n(Error(`FileReader returned non-string result`));return}t(e)},r.readAsDataURL(e)}),n=t.indexOf(`,`);return{data:n>=0?t.slice(n+1):t,mimeType:e.type||`application/octet-stream`,name:e.name||`image`,sizeBytes:e.size}}async function St(e){let t=e.type||``;if(!pt.has(t))return{ok:!1,error:{kind:`unsupported-type`,mimeType:t}};if(e.size>716800)return{ok:!1,error:{kind:`too-large`,sizeBytes:e.size,limitBytes:ht}};let n=await xt(e);return{ok:!0,part:{kind:`image`,data:n.data,mimeType:n.mimeType,name:n.name,sizeBytes:n.sizeBytes}}}function Ct(e){return Tt(e,e=>e.type.startsWith(`image/`))}function wt(e){return Tt(e,e=>e.size>0)}function Tt(e,t){if(e===null)return[];let n=[],r=e=>{e!==null&&t(e)&&n.push(e)},i=!1,a=e.items;if(a)for(let e=0;e<a.length;e+=1){let t=a[e];if(t?.kind!==`file`)continue;let n=t.getAsFile();n!==null&&(i=!0,r(n))}if(!i){let t=e.files;if(t)for(let e=0;e<t.length;e+=1)r(t[e]??null)}return n}function Et(e,t,n){let r=n===`\\`?e.toLowerCase():e,i=n===`\\`?t.toLowerCase():t,a=i.endsWith(n)?i:`${i}${n}`;if(r===i)return``;if(!r.startsWith(a))return null;let o=e.slice(a.length);return n===`\\`?o.replaceAll(`\\`,`/`):o}async function Dt(e,t={}){if((e.type||``).startsWith(`image/`))return St(e);let n=t.absPathOf,r=t.workspaceContentDir,i=t.pathSeparator??`/`,a=e.name||`attachment`;if(n===void 0||r===void 0||r===``)return{ok:!1,error:{kind:`unknown-path`,name:a}};let o=n(e);if(o===null||o===``)return{ok:!1,error:{kind:`unknown-path`,name:a}};let s=Et(o,r,i);return s===null?{ok:!1,error:{kind:`outside-workspace`,name:a}}:{ok:!0,part:{kind:`file`,path:s,name:a}}}function Ot(e){let t=e?.content;return!Array.isArray(t)||t.length===0?!1:t.some(e=>Array.isArray(e.content)&&e.content.length>0)}function kt(e){return e.split(`
|
|
9
|
-
`).map(e=>({type:`paragraph`,content:e===``?[]:[{type:`text`,text:e}]}))}function At(e){let t=(0,X.c)(67),{ref:n,ariaLabel:r,onEmptyChange:i,onContentChange:a,onMentionsChange:s,onSubmit:l,onEscape:u,className:d,placeholder:f,initialDoc:p,disabled:m,testId:h,slashCommands:g,attachmentDrop:_}=e,v=m===void 0?!1:m,{_:y}=o(),[b,ee]=(0,P.useState)(null),[x,te]=(0,P.useState)(null),ne=(0,P.useRef)(0),S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{ne.current+=1,te({text:e,id:ne.current})},t[0]=S):S=t[0];let re=S,ie,C;t[1]===x?(ie=t[2],C=t[3]):(ie=()=>{if(x===null)return;let e=setTimeout(()=>te(null),4e3);return()=>clearTimeout(e)},C=[x],t[1]=x,t[2]=ie,t[3]=C),(0,P.useEffect)(ie,C);let w=(0,P.useRef)(i),ae=(0,P.useRef)(a),T=(0,P.useRef)(s),oe=(0,P.useRef)(l),ce=(0,P.useRef)(u),le;t[4]!==a||t[5]!==i||t[6]!==u||t[7]!==s||t[8]!==l?(le=()=>{w.current=i,ae.current=a,T.current=s,oe.current=l,ce.current=u},t[4]=a,t[5]=i,t[6]=u,t[7]=s,t[8]=l,t[9]=le):le=t[9],(0,P.useEffect)(le);let E;t[10]!==f||t[11]!==g?(E=ut({placeholder:f,slashCommands:g}),t[10]=f,t[11]=g,t[12]=E):E=t[12];let D=p??void 0,O=!v,k;t[13]===h?k=t[14]:(k=h===void 0?{}:{"data-testid":h},t[13]=h,t[14]=k);let A;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(A=c(`composer-prosemirror py-1 outline-none`),t[15]=A):A=t[15];let j;t[16]!==r||t[17]!==k?(j={role:`textbox`,"aria-label":r,"aria-multiline":`true`,...k,class:A},t[16]=r,t[17]=k,t[18]=j):j=t[18];let fe;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(e,t)=>t.key===`Escape`?nt.getState(e.state)?.active||Re.getState(e.state)?.active?!1:ce.current===void 0?(e.dom.blur(),!0):(ce.current(),!0):t.key===`Enter`&&!t.shiftKey&&!t.isComposing&&!e.composing?(nt.getState(e.state)?.active||Re.getState(e.state)?.active)&&de(e)?!1:(oe.current(),!0):!1,t[19]=fe):fe=t[19];let M;t[20]===j?M=t[21]:(M={attributes:j,handleKeyDown:fe},t[20]=j,t[21]=M);let N;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{let{editor:t}=e;w.current(Q(t)),ae.current?.(t.getJSON()),T.current?.(Z(t).mentions),ee(qe(Je(t),Ue(t)))},t[22]=N):N=t[22];let I;t[23]!==M||t[24]!==E||t[25]!==D||t[26]!==O?(I={extensions:E,content:D,immediatelyRender:!0,editable:O,editorProps:M,onUpdate:N},t[23]=M,t[24]=E,t[25]=D,t[26]=O,t[27]=I):I=t[27];let L=se(I),me,he;t[28]!==r||t[29]!==L||t[30]!==f?(me=()=>{if(!L||L.isDestroyed)return;let e=L.extensionManager.extensions.find(Nt);e&&(e.options.placeholder=f??``);let t=L.editorView;t&&(t.dom.setAttribute(`aria-label`,r??``),t.dispatch(L.state.tr.setMeta(`addToHistory`,!1)))},he=[L,f,r],t[28]=r,t[29]=L,t[30]=f,t[31]=me,t[32]=he):(me=t[31],he=t[32]),(0,P.useEffect)(me,he);let ge,R;t[33]!==v||t[34]!==L?(ge=()=>{if(!L||L.isDestroyed)return;let e=!v;L.isEditable!==e&&L.setEditable(e,!1);let t=L.editorView;t&&(v?t.dom.setAttribute(`aria-disabled`,`true`):t.dom.removeAttribute(`aria-disabled`))},R=[L,v],t[33]=v,t[34]=L,t[35]=ge,t[36]=R):(ge=t[35],R=t[36]),(0,P.useEffect)(ge,R);let z,B;t[37]!==L||t[38]!==g?(z=()=>{if(!(!L||L.isDestroyed)){if(We(L,g??null)){let e=L.editorView;e&&e.dispatch(L.state.tr.setMeta(`addToHistory`,!1))}ee(qe(Je(L),Ue(L)))}},B=[L,g],t[37]=L,t[38]=g,t[39]=z,t[40]=B):(z=t[39],B=t[40]),(0,P.useEffect)(z,B);let V;t[41]!==L||t[42]!==p?(V=()=>{L&&(Q(L)&&Ot(p)&&(console.warn(`composer draft was incompatible with the current schema — clearing it`),Ne()),w.current(Q(L)),T.current?.(Z(L).mentions))},t[41]=L,t[42]=p,t[43]=V):V=t[43];let H;t[44]===L?H=t[45]:(H=[L],t[44]=L,t[45]=H),(0,P.useEffect)(V,H);let U,W;t[46]===L?(U=t[47],W=t[48]):(U=()=>({focus:()=>L?.commands.focus(),refuseDrop:e=>{ne.current+=1,te({text:e,id:ne.current})},focusEnd:()=>L?.commands.focus(`end`),blur:()=>L?.commands.blur(),clear:()=>L?.commands.clearContent(!0),setText:e=>{L&&(L.commands.setContent(kt(e)),w.current(Q(L)),ae.current?.(L.getJSON()),T.current?.(Z(L).mentions),ee(qe(Je(L),Ue(L))))},appendText:e=>{!L||e===``||(Q(L)?L.commands.setContent(kt(e)):L.commands.insertContentAt(L.state.doc.content.size,[{type:`paragraph`,content:[]},...kt(e)]),w.current(Q(L)),ae.current?.(L.getJSON()),T.current?.(Z(L).mentions),ee(qe(Je(L),Ue(L))))},getContent:()=>L?Z(L):{instruction:``,mentions:[],attachments:[]},openMentionPicker:()=>{L&&L.chain().focus().insertContent(`@`).run()}}),W=[L],t[46]=L,t[47]=U,t[48]=W),(0,P.useImperativeHandle)(n,U,W);let G=_,K;t[49]!==y||t[50]!==G?(K=G.kind===`host`?{}:{onDragEnter:Mt,onDragOver:jt,onDrop:e=>{if(!pe(e))return;e.preventDefault(),e.stopPropagation();let t=wt(e.dataTransfer);if(t.length===0){re(y({id:`rNi1kZ`}));return}if(G.kind===`accept`){G.onFiles(t);return}re(G.reason??y({id:`SgAFuo`}))}},t[49]=y,t[50]=G,t[51]=K):K=t[51];let _e=K,q;t[52]!==d||t[53]!==_e||t[54]!==L?(q=(0,F.jsx)(ue,{editor:L,className:d,..._e}),t[52]=d,t[53]=_e,t[54]=L,t[55]=q):q=t[55];let J;t[56]!==G.kind||t[57]!==x?(J=G.kind===`host`?null:(0,F.jsx)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`composer-drop-refusal`,children:x===null?null:(0,F.jsx)(`p`,{className:`px-2.5 py-1 text-muted-foreground text-xs`,children:x.text},x.id)}),t[56]=G.kind,t[57]=x,t[58]=J):J=t[58];let Y;t[59]!==y||t[60]!==g||t[61]!==b?(Y=g===void 0?null:(0,F.jsx)(`p`,{className:c(`truncate px-2.5 text-xs text-muted-foreground`,b?.kind===`unknown`&&`pb-1`),"aria-live":`polite`,"aria-atomic":`true`,"data-testid":`composer-slash-hint`,children:b?.kind===`unknown`?b.agentHasCommands?y({id:`mBK8zm`,values:{0:b.name}}):y({id:`Q9AxTM`}):null}),t[59]=y,t[60]=g,t[61]=b,t[62]=Y):Y=t[62];let ve;return t[63]!==q||t[64]!==J||t[65]!==Y?(ve=(0,F.jsxs)(F.Fragment,{children:[q,J,Y]}),t[63]=q,t[64]=J,t[65]=Y,t[66]=ve):ve=t[66],ve}function jt(e){pe(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}function Mt(e){pe(e)&&e.preventDefault()}function Nt(e){return e.name===`placeholder`}function Pt(e){let t=(0,X.c)(20),{onFiles:n,referencesOnly:r,testId:i}=e,a=r===void 0?!1:r,{_:s}=o(),c;t[0]===n?c=t[1]:(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.addEventListener(`change`,()=>{let t=Array.from(e.files??[]);t.length>0&&n(t)}),e.click()},t[0]=n,t[1]=c);let l=c,d;t[2]===s?d=t[3]:(d=s({id:`tCyvAw`}),t[2]=s,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,F.jsx)(ae,{className:`size-4`,"aria-hidden":`true`}),t[4]=f):f=t[4];let g;t[5]!==l||t[6]!==d||t[7]!==i?(g=(0,F.jsx)(p,{asChild:!0,children:(0,F.jsx)(u,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`rounded-lg`,onClick:l,"aria-label":d,"data-testid":i,children:f})}),t[5]=l,t[6]=d,t[7]=i,t[8]=g):g=t[8];let _;t[9]===s?_=t[10]:(_=s({id:`tCyvAw`}),t[9]=s,t[10]=_);let v;t[11]!==s||t[12]!==a?(v=a?s({id:`LZe2vX`}):null,t[11]=s,t[12]=a,t[13]=v):v=t[13];let y;t[14]!==_||t[15]!==v?(y=(0,F.jsxs)(m,{side:`top`,children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;return t[17]!==g||t[18]!==y?(b=(0,F.jsxs)(h,{children:[g,y]}),t[17]=g,t[18]=y,t[19]=b):b=t[19],b}var Ft=(0,P.createContext)(null);function It(e,t){let n=e.lastIndexOf(`.`);if(n>0&&n<e.length-1)return e.slice(n+1).toLowerCase();let r=t.lastIndexOf(`/`);return r>0&&r<t.length-1?t.slice(r+1).toLowerCase():`file`}function Lt(e){let t=(0,X.c)(23),{testIdPrefix:n,images:r,uploads:i,onRemove:a}=e,{_:s}=o(),c=(0,P.use)(Ft),l=i.length>0,d=`${n}-pending-images`,f;if(t[0]!==s||t[1]!==r||t[2]!==a||t[3]!==c||t[4]!==n){let e;t[6]!==s||t[7]!==a||t[8]!==c||t[9]!==n?(e=(e,t)=>{let r=e.kind===`image`||e.kind===`blob`?`${t}:${e.name}:${e.data.slice(0,24)}`:`${t}:${e.name}:${e.path}`,i=e.kind===`image`?`data:${e.mimeType};base64,${e.data}`:null,o=e.kind===`file`||e.kind===`folder`?It(e.name,``):It(e.name,e.mimeType);return(0,F.jsxs)(`div`,{className:`group relative inline-flex size-14`,title:e.name,children:[i!==null&&c!==null?(0,F.jsx)(u,{type:`button`,variant:`ghost`,onClick:()=>c({src:i,name:e.name}),className:`size-full items-center justify-center overflow-hidden rounded-md border border-input bg-muted p-0 hover:bg-muted`,"aria-label":e.name,"data-testid":`${n}-pending-image-preview`,children:(0,F.jsx)(`img`,{src:i,alt:e.name,className:`h-full w-full object-cover`,draggable:!1})}):(0,F.jsx)(`div`,{className:`inline-flex size-full items-center justify-center overflow-hidden rounded-md border border-input bg-muted`,children:i===null?(0,F.jsx)(`span`,{className:`text-muted-foreground text-xs uppercase`,children:o}):(0,F.jsx)(`img`,{src:i,alt:e.name,className:`h-full w-full object-cover`,draggable:!1})}),(0,F.jsx)(u,{type:`button`,size:`icon`,variant:`secondary`,onClick:e=>{e.stopPropagation(),a(t)},"aria-label":s({id:`w61W3L`,values:{0:e.name}}),className:`absolute top-0.5 end-0.5 size-5 rounded-full border border-border bg-background/80 p-0 shadow-sm opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 focus-visible:opacity-100`,"data-testid":`${n}-pending-image-remove`,children:(0,F.jsx)(N,{className:`size-3`,"aria-hidden":`true`})})]},r)},t[6]=s,t[7]=a,t[8]=c,t[9]=n,t[10]=e):e=t[10],f=r.map(e),t[0]=s,t[1]=r,t[2]=a,t[3]=c,t[4]=n,t[5]=f}else f=t[5];let p;if(t[11]!==s||t[12]!==n||t[13]!==i){let e;t[15]!==s||t[16]!==n?(e=e=>{let t=e.name;return(0,F.jsx)(`div`,{role:`img`,"aria-label":s({id:`KDuPiY`,values:{fileName:t}}),className:`relative inline-flex size-14 items-center justify-center overflow-hidden rounded-md border border-input bg-muted`,title:e.name,"data-testid":`${n}-pending-upload`,children:(0,F.jsx)(M,{className:`size-4 text-muted-foreground`,"aria-hidden":`true`})},e.id)},t[15]=s,t[16]=n,t[17]=e):e=t[17],p=i.map(e),t[11]=s,t[12]=n,t[13]=i,t[14]=p}else p=t[14];let m;return t[18]!==l||t[19]!==d||t[20]!==f||t[21]!==p?(m=(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-2 pb-1`,"aria-busy":l,"data-testid":d,children:[f,p]}),t[18]=l,t[19]=d,t[20]=f,t[21]=p,t[22]=m):m=t[22],m}var Rt=`button, a[href], [role="menuitem"], [role="button"], input, textarea, select, [contenteditable="true"]`;function zt(e,t){if(!(e.target instanceof HTMLElement)||!(e.currentTarget instanceof HTMLElement)||!e.currentTarget.contains(e.target)||e.target.closest(Rt))return;e.preventDefault();let n=t.current;n!==null&&(n.focusEnd===void 0?n.focus():n.focusEnd())}function Bt(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function Vt(e){let t=(0,X.c)(21),{path:n,onRemove:i}=e,{_:a}=o(),s,c;t[0]!==a||t[1]!==n?(s=Bt(n),c=a({id:`hnq8fP`,values:{label:s}}),t[0]=a,t[1]=n,t[2]=s,t[3]=c):(s=t[2],c=t[3]);let l=c,d=`composer-context-chip-file-${n}`,f;t[4]===i?f=t[5]:(f=e=>{(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),i())},t[4]=i,t[5]=f);let p;t[6]===n?p=t[7]:(p=(0,F.jsx)(`span`,{className:`absolute top-1/2 left-1/2 inline-flex size-3 -translate-x-1/2 -translate-y-1/2 opacity-100 transition-opacity duration-150 ease-out group-hover/chip:opacity-0 group-focus-within/chip:opacity-0 motion-reduce:transition-none`,children:(0,F.jsx)(r,{path:n,className:`size-3`,showExtensionBadge:!1})}),t[6]=n,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,F.jsx)(N,{className:`absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-150 ease-out group-hover/chip:opacity-100 group-focus-within/chip:opacity-100 motion-reduce:transition-none`,"aria-hidden":!0}),t[8]=m):m=t[8];let h;t[9]!==i||t[10]!==l||t[11]!==f||t[12]!==p?(h=(0,F.jsxs)(u,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":l,onClick:i,onKeyDown:f,className:`group/remove relative size-3.5 shrink-0 rounded-sm text-muted-foreground/80 hover:text-foreground`,children:[p,m]}),t[9]=i,t[10]=l,t[11]=f,t[12]=p,t[13]=h):h=t[13];let g;t[14]===s?g=t[15]:(g=(0,F.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),t[14]=s,t[15]=g);let _;return t[16]!==n||t[17]!==d||t[18]!==h||t[19]!==g?(_=(0,F.jsxs)(`span`,{"data-testid":d,title:n,className:`group/chip inline-flex max-w-[14rem] items-center gap-1 rounded-md border bg-muted/40 py-0.5 pr-1.5 pl-1 text-muted-foreground text-xs`,children:[h,g]}),t[16]=n,t[17]=d,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Ht(e){let t=(0,X.c)(13),{files:n,onRemoveFile:r,className:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n===void 0?[]:n,t[0]=n,t[1]=o);let s=o;if(s.length===0&&P.Children.toArray(a).length===0)return null;let l;t[2]===i?l=t[3]:(l=c(`flex flex-wrap items-center gap-1`,i),t[2]=i,t[3]=l);let u;if(t[4]!==s||t[5]!==r){let e;t[7]===r?e=t[8]:(e=e=>(0,F.jsx)(Vt,{path:e,onRemove:()=>r?.(e)},e),t[7]=r,t[8]=e),u=s.map(e),t[4]=s,t[5]=r,t[6]=u}else u=t[6];let d;return t[9]!==a||t[10]!==l||t[11]!==u?(d=(0,F.jsxs)(`div`,{className:l,"data-testid":`composer-context-chips`,children:[u,a]}),t[9]=a,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function $(e,t){let n=e[t];return typeof n==`string`&&n!==``?n:null}function Ut(e){if(typeof e!=`object`||!e)return null;let t=e,n=$(t,`tool`)??$(t,`name`),r=t;if(typeof t.arguments==`object`&&t.arguments!==null)r=t.arguments;else if(typeof t.arguments==`string`)try{let e=JSON.parse(t.arguments);typeof e==`object`&&e&&(r=e)}catch{}return{tool:n,args:r}}var Wt=`ok-acp-follow-file-v1`;function Gt(){try{return localStorage.getItem(Wt)!==`0`}catch{return!0}}function Kt(e){try{localStorage.setItem(Wt,e?`1`:`0`)}catch{}}function qt(e){return e===``||e.startsWith(`/`)||e.startsWith(`\\`)||e.split(`/`).some(e=>e===``||e.startsWith(`.`))?null:e}function Jt(e,t){let n=t.pathSeparator,r=e=>n===`\\`?e.replaceAll(`\\`,`/`):e,i=r(t.contentDir).replace(/\/$/,``),a=r(e);if(!a.startsWith(`${i}/`))return null;let o=a.slice(i.length+1),s=/\.(md|mdx)$/.exec(o);return s===null?null:qt(o.slice(0,-s[0].length))}var Yt=new Set(ie);function Xt(e,t,n){let r=Ut(e);if(r===null)return null;let{tool:i,args:a}=r;if(i===`delete`||i===null&&/\bdelete\b/i.test(t))return null;let o=typeof a.document==`object`&&a.document!==null?a.document:null,s=null;if(Array.isArray(a.documents))for(let e=a.documents.length-1;e>=0;e--){let t=a.documents[e];if(typeof t==`object`&&t){s=t;break}}let c=(o===null?null:$(o,`path`))??(s===null?null:$(s,`path`))??$(a,`to`);if(c!==null)return qt(c.replace(/\.(md|mdx)$/,``));let l=$(a,`docName`);return l===null||!(i!==null&&Yt.has(i))&&!(n===`edit`||n===`move`)?null:qt(l.replace(/\.(md|mdx)$/,``))}function Zt(e,t){if(e.toolKind===`delete`)return null;let n=Xt(e.rawInput,e.title,e.toolKind);if(n!==null)return n;if(t===null||e.toolKind!==`edit`&&e.toolKind!==`move`)return null;for(let n=e.locations.length-1;n>=0;n--){let r=e.locations[n];if(r===void 0)continue;let i=Jt(r.path,t);if(i!==null)return i}return null}var Qt={lastFollowed:null,yielded:!1,reArmed:!1};function $t(e,t,n){if(e===null||n.lastFollowed===e)return{navigateTo:null,state:n};if(n.lastFollowed!==null&&t!==null&&t!==n.lastFollowed&&t!==e&&!n.reArmed)return{navigateTo:null,state:{...n,yielded:!0}};if(n.yielded&&!n.reArmed)return{navigateTo:null,state:n};let r={lastFollowed:e,yielded:!1,reArmed:!1};return t===e?{navigateTo:null,state:r}:{navigateTo:e,state:r}}function en(e,t){let n=null;for(let r of e){if(r.kind!==`tool_call`)continue;let e=Zt(r,t);e!==null&&(n=e)}return n}function tn(e){let t=(0,X.c)(16),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,value:o,max:i,indeterminateFillPercent:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=typeof i==`number`&&i>0?i:100,l=typeof o==`number`&&o>=0&&o<=s?o/s*100:r??0,u=Math.min(100,Math.max(0,l)),d;t[6]===n?d=t[7]:(d=c(`relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted`,n),t[6]=n,t[7]=d);let f=`translateX(-${100-u}%)`,p;t[8]===f?p=t[9]:(p=(0,F.jsx)(Y,{"data-slot":`progress-indicator`,className:`size-full flex-1 bg-primary transition-all motion-reduce:transition-none`,style:{transform:f}}),t[8]=f,t[9]=p);let m;return t[10]!==i||t[11]!==a||t[12]!==d||t[13]!==p||t[14]!==o?(m=(0,F.jsx)(J,{"data-slot":`progress`,value:o,max:i,className:d,...a,children:p}),t[10]=i,t[11]=a,t[12]=d,t[13]=p,t[14]=o,t[15]=m):m=t[15],m}export{ve as A,Dt as C,je as D,Ne as E,Me as O,_t as S,Pe as T,gt as _,en as a,Ct as b,Kt as c,Ht as d,zt as f,At as g,Pt as h,Jt as i,be as k,$ as l,Lt as m,Qt as n,Gt as o,Ft as p,$t as r,qt as s,tn as t,Ut as u,yt as v,vt as w,bt as x,wt as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Xt as e,en as t}from"./dist-DyIzmB4e.js";import{t as n}from"./dist-Cr4-nBVI.js";import{c as r,s as i}from"./documents-events-BhD4StGH.js";import{t as a}from"./parse-api-error-BtEdpaFC.js";async function o(e){return a(await e.json().catch(()=>null))??`HTTP ${e.status}`}async function s(e,t){try{let n=await fetch(e,t?{signal:t}:void 0);return n.ok?{ok:!0,...await n.json()}:{ok:!1,error:await o(n)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function c(e,t,n){try{let r=await fetch(e,{method:t,...n===void 0?{}:{headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}});return r.ok?{ok:!0,...await r.json().catch(()=>null)??{}}:{ok:!1,error:await o(r)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function l(e){let t=e.trim();return t.length<2?{ok:!0,results:[],backend:`skills.sh`,degraded:!1}:s(`/api/skills/search?q=${encodeURIComponent(t)}`)}async function u(e){let t=await c(`/api/seed/install-pack-skill`,`POST`,{packId:e});return t.ok&&r(),t}async function d(){return s(`/api/skills/popular?limit=24`)}async function f(e,r){let i=await s(e?`/api/skills?scope=${e}`:`/api/skills`,r);if(!i.ok)return i;let{ok:a,...o}=i,c=t.safeParse(o);return c.success?{ok:!0,skills:c.data.skills}:{ok:!1,error:n._({id:`iXs0kt`})}}async function p(e){return s(`/api/skills/detail?${new URLSearchParams({source:e.source,name:e.name}).toString()}`)}async function m(e,t){return s(`/api/skills/preview?${new URLSearchParams({source:e.source,name:e.name}).toString()}`,t)}async function h(e,t){return s(`/api/skills/resolve-ref?${new URLSearchParams({ref:e.ref,scope:e.scope,from:e.from}).toString()}`,t)}async function g(e){return s(`/api/skills/publisher?source=${encodeURIComponent(e)}`)}async function _(e,t){return s(`/api/skills/discover?source=${encodeURIComponent(e)}`,t)}async function v(){return s(`/api/skills/installed`)}async function y(e){try{let t=await fetch(`/api/skill/edit-external`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let r=await t.json().catch(()=>null);return!r||typeof r.docName!=`string`?{ok:!1,error:n._({id:`iBVgIQ`})}:{ok:!0,docName:r.docName}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function b(e){try{let t=await fetch(`/api/skill`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let n=await t.json().catch(()=>null);return r(),{ok:!0,created:n?.created??!1,warnings:n?.warnings??[],...typeof n?.path==`string`?{path:n.path}:{}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function x(e){try{let t=await fetch(`/api/skill/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null),n=a(e)??`HTTP ${t.status}`,r=typeof e?.detail==`string`&&/multiple skills/i.test(String(e?.title??``))?String(e.detail).split(`, `).map(e=>e.trim()).filter(Boolean):void 0;return r?{ok:!1,error:n,skills:r}:{ok:!1,error:n}}let i=await t.json().catch(()=>null);return!i||typeof i.name!=`string`?{ok:!1,error:n._({id:`HLoO-Z`})}:(r(),{ok:!0,name:i.name,...typeof i.path==`string`&&i.alreadyImported!==!0?{path:i.path}:{},alreadyImported:i?.alreadyImported??!1,collisionRenamedFrom:i?.collisionRenamedFrom,warnings:i?.warnings??[]})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function S(e){try{let t=await fetch(`/api/skills/import-bulk`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let i=await t.json().catch(()=>null);return!i||!Array.isArray(i.results)?{ok:!1,error:n._({id:`HLoO-Z`})}:(r(),{ok:!0,...i})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function C(e,t){try{let i=await fetch(`/api/skill-upload?scope=${encodeURIComponent(t)}`,{method:`POST`,body:e});if(!i.ok)return{ok:!1,error:await o(i)};let a=await i.json().catch(()=>null);return!a||typeof a.name!=`string`?{ok:!1,error:n._({id:`iodl3p`})}:(r(),{ok:!0,name:a.name,alreadyImported:a?.alreadyImported??!1,collisionRenamedFrom:a?.collisionRenamedFrom,warnings:a?.warnings??[]})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}function w(e,t){let n=`${e}-copy`;if(!t.has(n))return n;for(let n=2;n<1e3;n+=1){let r=`${e}-copy-${n}`;if(!t.has(r))return r}return`${e}-copy-${t.size+1}`}async function T(e){try{let t=w(e.name,e.existingNames),i=await fetch(`/api/skill/duplicate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({scope:e.scope,name:e.name,toName:t})});if(!i.ok)return{ok:!1,error:await o(i)};let a=await i.json().catch(()=>null);return typeof a?.name==`string`?(r(),{ok:!0,name:a.name}):{ok:!1,error:n._({id:`emMrXQ`})}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function E(e){let{name:t,fromScope:n,toScope:a}=e;if(n===a)return{ok:!0,scope:a};try{let e=await fetch(`/api/skill/move-scope`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t,fromScope:n,toScope:a})});if(!e.ok)return{ok:!1,error:await o(e)};let s=await e.json().catch(()=>null);return i({name:t,fromScope:n,toScope:a}),r(),{ok:!0,scope:a,...typeof s?.path==`string`?{path:s.path}:{}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function D(e){try{let t=await fetch(`/api/skill/track-in-git`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let n=await t.json().catch(()=>null);return e.apply===!0&&r(),{ok:!0,line:n?.line??``,gitignorePath:n?.gitignorePath??`.gitignore`,applied:n?.applied===!0}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function O(e){try{let t=await fetch(`/api/skill`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let n=await t.json().catch(()=>null);return r(),{ok:!0,committed:n?.committed??!1,...typeof n?.to==`string`?{to:n.to}:{}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function k(e,t){try{let n=new URLSearchParams({name:t,scope:e}),r=await fetch(`/api/skill?${n.toString()}`);if(!r.ok)return null;let i=await r.json().catch(()=>null);return typeof i?.skill?.path==`string`?i.skill.path:null}catch{return null}}async function A(e,t,n){try{let i=`?name=${encodeURIComponent(t)}&scope=${encodeURIComponent(e)}${n?`&host=${encodeURIComponent(n)}`:``}`,a=await fetch(`/api/skill${i}`,{method:`DELETE`});if(!a.ok)return{ok:!1,error:await o(a)};let s=await a.json().catch(()=>null);return r(),{ok:!0,existed:s?.existed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function j(e){let t=await c(`/api/skill/install`,`POST`,{scope:e.scope,name:e.name,fork:{editor:e.editor,action:e.action,...e.toName===void 0?{}:{toName:e.toName}}});return t.ok?(r(),{ok:!0}):t}async function M(e){try{let t=await fetch(`/api/skill-file`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let n=await t.json().catch(()=>null);return r(),{ok:!0,path:n?.path??e.path}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function N(e){try{let t=await fetch(`/api/skill-file/rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let n=await t.json().catch(()=>null);return r(),{ok:!0,from:n?.from??e.from,to:n?.to??e.to,...n?.fromDocName===void 0?{}:{fromDocName:n.fromDocName},...n?.toDocName===void 0?{}:{toDocName:n.toDocName}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function P(e){try{let t=new URLSearchParams({scope:e.scope,name:e.name,path:e.path}),n=await fetch(`/api/skill-file?${t.toString()}`,{method:`DELETE`});if(!n.ok)return{ok:!1,error:await o(n)};let i=await n.json().catch(()=>null);return r(),{ok:!0,existed:i?.existed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function F(e){try{let t=new URLSearchParams({name:e.name,scope:e.scope,path:e.path,...e.host?{host:e.host}:{}}),n=await fetch(`/api/skill-file?${t.toString()}`,{signal:e.signal});if(!n.ok)return{ok:!1,status:n.status,error:await o(n)};let r=await n.json().catch(()=>null);return typeof r?.text==`string`?{ok:!0,text:r.text}:{ok:!1,status:n.status,error:`HTTP ${n.status}`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}function I(e,t){return F({...e,signal:t}).then(e=>e.ok?{ok:!0,text:e.text}:{ok:!1,status:e.status})}async function L(e){try{let t=await fetch(`/api/skill/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let n=await t.json().catch(()=>null);return r(),{ok:!0,hosts:n?.hosts??[],scripts:n?.scripts??!1,warnings:n?.warnings??[],warningCodes:n?.warningCodes??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function R(e){try{let t=await fetch(`/api/skill/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({scope:e.scope,name:e.name,place:{dir:e.dir,mode:e.mode}})});if(!t.ok)return{ok:!1,error:await o(t)};let n=await t.json().catch(()=>null);return r(),{ok:!0,placedAt:n?.placedAt??e.dir}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function z(e){let t=await c(`/api/skill/install`,`POST`,{scope:e.scope,name:e.name,unplace:{path:e.path}});return t.ok?(r(),{ok:!0}):t}async function B(e){let t=await c(`/api/skill/install`,`POST`,{scope:e.scope,name:e.name,setSource:e.target});return t.ok?(r(),{ok:!0}):t}async function V(e){let t=await c(`/api/skill/install`,`POST`,{scope:e.scope,name:e.name,convert:{target:e.target,mode:e.mode}});return t.ok?(r(),{ok:!0}):t}async function H(t){try{let r=await fetch(`/api/skill-targets`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({folderAction:t})});if(!r.ok)return{ok:!1,error:await o(r)};if(!t.preview)return{ok:!0};let i=await r.json().catch(()=>null),a=typeof i==`object`&&i&&`preview`in i?i.preview:void 0,s=e.safeParse(a);return s.success?{ok:!0,preview:s.data}:{ok:!1,error:n._({id:`iBVgIQ`})}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function U(e){try{let t=await fetch(`/api/skill/reimport`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let n=await t.json().catch(()=>null);return e.dryRun||r(),{ok:!0,updated:n?.updated??!1,source:n?.source??``,localBody:n?.localBody,upstreamBody:n?.upstreamBody,...n?.gitTracked===void 0?{}:{gitTracked:n.gitTracked},warnings:n?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function W(e){try{let t=await fetch(`/api/skills/reimport-bulk`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let i=await t.json().catch(()=>null);return!i||!Array.isArray(i.results)?{ok:!1,error:n._({id:`kmPvKZ`})}:(r(),{ok:!0,...i})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function G(e){try{let t=await fetch(`/api/skill/revert`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await o(t)};let n=await t.json().catch(()=>null);return r(),{ok:!0,warnings:n?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}export{l as A,U as C,h as D,j as E,M as F,D as M,z as N,G as O,C as P,H as S,N as T,f as _,T as a,E as b,g as c,k as d,x as f,v as g,L as h,_ as i,B as j,b as k,p as l,u as m,A as n,y as o,S as p,P as r,d as s,V as t,m as u,I as v,W as w,R as x,O as y};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{Dn as n,In as r,Kn as i,Mt as a,Nt as o,ci as s,di as c,fr as l,gn as u,i as d,jn as f,sn as p,tr as m,vn as h,vr as g,z as _}from"./DocumentContext-BdT4QvCj.js";import{t as v}from"./react-f2sANaYj.js";import{n as y,r as b}from"./dist-Nvb76hAm.js";import{r as x,t as S}from"./useQuery-ZeEDLtxh.js";import{t as C}from"./compiler-runtime-BfE3aGVn.js";import{t as w}from"./utils-CPqDy6Hr.js";import{t as T}from"./button-Cym3gapE.js";import{i as E,n as D,t as O}from"./tooltip-DttaCTqz.js";import{n as k,r as A,t as j}from"./collapsible-DYySK8La.js";import{n as M,t as N}from"./toggle-group-C2_37kV5.js";import{Ct as P,Dt as F,Fs as I,Js as L,Ko as ee,R,Ui as z,ir as B,ln as V,rr as H,un as U,xs as W}from"./dist-DyIzmB4e.js";import{n as G}from"./dist-CJhtNlOm2.js";import{s as K}from"./use-settings-route-BCi5InHC.js";import{t as q}from"./dist-Cr4-nBVI.js";import{f as J,v as te}from"./documents-events-BhD4StGH.js";import{t as ne}from"./note-window-mode-CsmLTxU_.js";import{t as Y}from"./createLucideIcon-B6ULg5PN.js";import{t as X}from"./chevron-right-C-g4JuT4.js";import{n as re,t as ie}from"./lint-plugin-meta-zA9wHIBR.js";import{n as ae}from"./upload-DGQJhdiQ.js";import{i as oe,r as se}from"./prop-types-BIbPZaOa.js";import{Et as ce,Ot as le,S as ue,X as de,jt as fe,rt as pe}from"./CodeMirrorPropInput-DJMpl51W.js";import{t as me}from"./info-CilGMBpP.js";import{t as he}from"./refresh-cw-DgTHxKWl.js";import{t as ge}from"./triangle-alert-1CPkv6zu.js";import{t as _e}from"./wrench-BFRDKz2A.js";import{l as ve,s as ye}from"./doc-hash-lEZL1-60.js";import{a as be,i as xe,s as Se}from"./startup-marks-BltEnhgt.js";import{C as Ce,D as we}from"./config-provider-CAlJf_RJ.js";import{J as Te,K as Ee,Mt as De,Nt as Oe,X as ke,wt as Ae}from"./dist-DlsJ2gMP.js";import{t as je}from"./badge-C0BAzyS2.js";import{a as Me,c as Ne,i as Pe,n as Fe,r as Ie,s as Le,t as Re}from"./panel-CbOtoy34.js";import{t as ze}from"./skeleton-BXRgs_K0.js";import{a as Be,c as Ve,d as He}from"./lint-config-client-BWUce3vG.js";var Ue=Y(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),We=56,Ge=2,Ke=150,qe=2e3;function Je(e,t,n){return e.top+e.height/2-(n+t)/2}function Ye(e,t){let n=Math.max(0,t.scrollHeight-t.clientHeight);return Math.max(0,Math.min(e,n))}function Xe(e){let{docName:t,container:i,measureTarget:a,placement:o,intent:s,grade:c,landedMode:l,transition:u,onOutcome:d,onDiscardQueuedTarget:p,toolbarOffset:m=We,driftThresholdPx:h=Ge,quietMs:g=Ke,abandonAfterMs:_=qe}=e,v=e.contentColumn??i.firstElementChild,y=n(t,`landing`),b=f(t,{yieldsToNavigation:s===`toggle`,supersede:()=>P(`superseded`)}),x=i.style.overflowAnchor;i.style.overflowAnchor=`none`,u&&be(`ok/mode-switch/transition`,{from:u.from,to:u.to,grade:c});let S=!1,C=null,w,T,E=0,D,O=()=>{let e=a();return e===null?null:Ye(o===`center`?Je(e,i.clientHeight,m):e.top-m,i)},k=()=>{let e=O();if(e===null)return{measurable:!1,moved:!1};C=e;let t=Math.abs(i.scrollTop-e)>h;return t&&(i.scrollTop=e),{measurable:!0,moved:t}},A=()=>i.scrollTop-(O()??C??i.scrollTop),j=()=>{w&&clearTimeout(w),T&&clearTimeout(T),E&&cancelAnimationFrame(E),D?.disconnect(),i.removeEventListener(`wheel`,I),i.removeEventListener(`touchstart`,I),i.removeEventListener(`contentvisibilityautostatechange`,L,!0),i.style.overflowAnchor=x,y.release(),b.release()},M=()=>{if(S)return;S=!0;let e;try{k(),e=A(),C!==null&&r({docName:t,container:i,targetScrollTop:i.scrollTop,mode:l})}finally{j()}be(`ok/landing/land`,{grade:c,delta:e}),d?.({status:`landed`,delta:e})},N=()=>{if(S)return;S=!0;let e=C??i.scrollTop,t;try{t=A()}finally{j()}be(`ok/landing/abandoned`,{grade:c,target:e,delta:t}),d?.({status:`abandoned`,delta:t})},P=e=>{S||(S=!0,j(),e===`mode-flip`&&p?.(),d?.({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(),i.addEventListener(`contentvisibilityautostatechange`,L,!0),i.addEventListener(`wheel`,I,{passive:!0}),i.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 Ze(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 Qe(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(Qe).join(``):``}function $e(e,t){let{frontmatter:n,body:r}=L(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:Ze(e.type),text:Qe(e)})),fmLineCount:i}}catch{return performance.mark(`ok/block-spans/parse-failed`),{blocks:[],fmLineCount:i}}}function et(e,t){let{blocks:n,fmLineCount:r}=$e(e,t);return{spans:n.map(e=>({start:e.start,end:e.end})),fmLineCount:r}}function tt(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 nt(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 rt(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 it(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
3
|
-
`&&t.push(n+1);return t}function at(e,t,n){return t<=1?0:t-1>=e.length?n:e[t-1]??n}function ot(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 st(e,t,n){return Math.max(t,Math.min(e,n))}function ct(e,t){let n=e=>e.replace(/\s+/g,` `).trim();return n(e)===n(t)}function lt(e,t){return t.inRange?t.tripwireOk?ct(e.content,t.text)?`exact`:e.kind===t.kind?`same-type-ordinal`:`ordinal`:`ordinal`:`clamped`}function ut(e){let t=null,n=null;function r(r){return n!==null&&t===r?n:(n={blocks:$e(r,e).blocks,lineStarts:it(r)},t=r,n)}return{captureFromWysiwyg(e,t,n){if(e.childCount===0)return null;let r=st(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:Ze(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=st(t,0,e.length),s=tt(i,ot(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=at(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=nt(n)===i.length,c=i[st(e.blockIndex,0,i.length-1)],l=at(a,c.start,t.length),u=Math.min(at(a,c.end+1,t.length),t.length),d=lt(e,{inRange:o,tripwireOk:s,kind:c.kind,text:c.text}),f=l;return d===`exact`&&e.selectionInBlock!==void 0&&(f=st(l+e.selectionInBlock,l,u)),{blockStart:l,blockEnd:u,point:f,confidence:d}},resolveInWysiwyg(e,{source:t,doc:n}){let i=nt(n);if(i===0)return null;let{blocks:a}=r(t),o=e.blockIndex>=0&&e.blockIndex<i,s=i===a.length,c=st(e.blockIndex,0,i-1),l=rt(n,c,c+1);if(l===null)return null;let u=n.child(c),d=lt(e,{inRange:o,tripwireOk:s,kind:Ze(u.type.name),text:u.textContent});return{blockStart:l.from,blockEnd:l.to,point:l.from,confidence:d}}}}var dt=De.define(),ft=De.define(),pt=Ee.mark({class:a}),mt=Oe.define({create(){return Ee.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(dt)?n=Ee.set([pt.range(e.value.from,e.value.to)]):e.is(ft)&&(n=Ee.none);return n},provide:e=>Te.decorations.from(e)}),ht=new WeakMap,gt=ke.define(e=>({destroy(){let t=ht.get(e);t!==void 0&&(clearTimeout(t),ht.delete(e))}}));function _t(e,t,n,r){let i=o(e.state.doc.length,t,n,r);if(!i)return;e.dispatch({effects:dt.of(i)});let a=ht.get(e);a!==void 0&&clearTimeout(a);let s=setTimeout(()=>{ht.delete(e),e.dispatch({effects:ft.of(null)})},R);ht.set(e,s)}function vt(){return[mt,gt]}var yt=3e4;function bt(){let e=new Map,t=e=>e?Date.now()-e.rememberedAt>yt?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 xt=bt(),St=bt(),Ct=xt.remember,wt=xt.peek,Tt=xt.consume,Et=xt.clear;xt.clearForTest;var Dt=St.remember,Ot=St.peek,kt=St.consume,At=St.clear;St.clearForTest;function jt(e,t,n){return{start:we(e,t),end:we(e,n)}}function Mt(e,t){let n=Ce(e.start,t),r=Ce(e.end,t);return n===null||r===null||r.index<=n.index?null:n.index}var Nt=`open-knowledge:view-in-source`,Pt=null;function Ft(){return Pt??=ut(de()),Pt}function It(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?jt(n,o.blockStart,o.blockEnd):void 0}}function Lt(e){let{editor:t,docName:n,ytext:r}=e,i=ce(t);if(!i)return;let a=i.state.selection.from,o=It(i.state.doc,a,r,Ft(),`jump`);o&&Ct(n,o),window.dispatchEvent(new CustomEvent(Nt,{detail:{docName:n}}))}function Rt(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?jt(n,o.blockStart,o.blockEnd):void 0}}function zt(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=Mt(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 Bt(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=Mt(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 Vt(e,t){try{return e.coordsAtPos(t)}catch{return null}}function Ht(e,t,n){let r=Math.max(0,Math.min(n,e.state.doc.length)),i=t.getBoundingClientRect().top,a=Vt(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 Ut(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 Wt(e,t,n){if(e.isDestroyed)return null;let r=Ut(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 Gt(){return typeof document>`u`?null:p()}function Kt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=ue();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 qt(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=ue();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 Jt(e){let{from:t,to:n,docName:r,ytext:i}=e;t===`wysiwyg`&&n===`source`?Yt(r,i):t===`source`&&n===`wysiwyg`&&Xt(r,i)}function Yt(e,t){let n=wt(e);if(n&&n.kind!==`selection-offset`)return;let r=i(e);if(!r)return;let a=ce(r);if(!a)return;let o=Gt();if(!o)return;let s=Kt(a,o);if(s===null)return;let c=It(a.state.doc,s,t,Ft());c&&Ct(e,c)}function Xt(e,t){let n=u(e);if(!n)return;let r=Gt();if(!r)return;let a=qt(n,r);if(a===null)return;let o=i(e),s=o?ce(o)?.state.doc:void 0,c=Rt(t.toString(),a,t,Ft(),s);c&&Dt(e,c)}function Zt(e){let{view:t,docName:n,navigation:r,ydoc:a,transition:o}=e,s=i(n),c=s?ce(s)?.state.doc:void 0;if(!c)return null;let l=Bt(r,{source:t.state.doc.toString(),pmDoc:c,ydoc:a,resolver:Ft()});if(!l)return null;let u=Gt();if(!u)return null;let d=l,p=r.intent===`jump`,m=p?d.point:d.blockStart;t.dispatch({effects:Te.scrollIntoView(m,{y:`start`})});let h=!1,g=null,_=f(n,{yieldsToNavigation:!p,supersede:()=>{h=!0,_.release()}}),v=e=>{if(!h){if(Vt(t,m)===null&&e<8){requestAnimationFrame(()=>v(e+1));return}try{p&&(t.dispatch({selection:Ae.cursor(m)}),t.focus())}finally{_.release()}g=Xe({docName:n,container:u,contentColumn:t.contentDOM,measureTarget:()=>Ht(t,u,m),placement:p?`center`:`top`,intent:p?`jump`:`toggle`,grade:d.confidence,landedMode:`source`,transition:o,toolbarOffset:ue(),onOutcome:p?e=>{e.status===`landed`&&_t(t,d.blockStart,d.blockEnd,d.confidence)}:void 0,onDiscardQueuedTarget:()=>Et(n)})}};return v(0),{cancel:e=>{h=!0,_.release(),g?.cancel(e)}}}function Qt(e){let{editor:t,docName:n,navigation:r,ydoc:i,transition:a}=e,o=ce(t);if(!o)return null;let s=zt(r,{source:i.getText(`source`).toString(),pmDoc:o.state.doc,ydoc:i,resolver:Ft()});if(!s)return null;let c=Gt();if(!c)return null;let l=s;return Xe({docName:n,container:c,contentColumn:o.dom,measureTarget:()=>Wt(o,c,l.point),placement:`top`,intent:`toggle`,grade:l.confidence,landedMode:`wysiwyg`,transition:a,toolbarOffset:ue(),onDiscardQueuedTarget:()=>At(n)})}var $t={words:0,chars:0,tokens:0},en=/[ -〿-ゟ゠-ヿ㐀-䶿一-鿿豈---ក-]/,tn=/[\p{L}\p{N}]/u,nn=new Set([`text`,`inlineCode`,`code`,`tag`]),rn=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),an=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function on(e,t){if(!e)return;let n=e.type;if(!rn.has(n)){if(nn.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)on(n,t);if(an.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
|
|
5
|
-
`)&&t.push(`
|
|
6
|
-
`)}}}}function sn(e){try{let t=de().parseToMdast(e),n=[];return on(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function cn(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))tn.test(n)&&t++;return t}function ln(e){let t=globalThis.Intl.Segmenter;if(!t)return cn(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function un(e){let t=en.test(e)?1.5:4;return Math.ceil(e.length/t)}function dn(e){return e?{words:en.test(e)?ln(e):cn(e),chars:e.length,tokens:un(e)}:{words:0,chars:0,tokens:0}}function fn(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=L(e);return t.trim()?dn(sn(t)):{words:0,chars:0,tokens:0}}function pn(e){return dn(e)}function mn(e,{isMarkdown:t}){let n=e.trim();return n?dn(t?sn(e):n):$t}function hn(e,t){return e!==null&&ee(e)?`source`:t}var gn=new Map,_n=new Set,vn=(e,t)=>`${t}:${e}`;function yn(){for(let e of _n)e()}function bn(e,t,n){let r=vn(e,t);if(n===null){gn.delete(r)&&yn();return}let i=gn.get(r);i&&i.words===n.words&&i.chars===n.chars&&i.tokens===n.tokens||(gn.set(r,n),yn())}function xn(e,t){return e===null?null:gn.get(vn(e,t))??null}function Sn(e){return _n.add(e),()=>{_n.delete(e)}}function Cn(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()?mn(i,{isMarkdown:!1}):null}function wn(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()?mn(n,{isMarkdown:!0}):null}var Z=e(v(),1),Q=C(),$=t();function Tn(e){let t=(0,Q.c)(14),{scope:n,onScopeChange:r,projectLabel:i}=e,{_:a}=b(),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)(M,{value:`doc`,className:`flex-1`,"data-testid":`panel-scope-doc`,children:(0,$.jsx)(y,{id:`UpCz01`})}),t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i??(0,$.jsx)(y,{id:`ZWyHmq`}),t[5]=i,t[6]=l);let u;t[7]===l?u=t[8]:(u=(0,$.jsx)(M,{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)(N,{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 En(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`?q._({id:`W5qdI_`,values:{shown:n}}):q._({id:`bpMVIA`,values:{shown:n}}):t.targetKind===`file`?t.role===`image`?q._({id:`iSWh95`,values:{shown:n}}):q._({id:`fOzzSV`,values:{shown:n}}):q._({id:`XBBZnv`,values:{shown:n}})}var Dn=`audit-superseded`;async function On(e={kind:`project`},t){return An(e,U,!1,t)}async function kn(e={kind:`project`},t){return An(e,V,!0,t)}async function An(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?Dn:(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 jn(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()}),On({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=te(e=>{(e.includes(`backlinks`)||J(e))&&l()}),d=Ve(l);return()=>{n=!0,s?.abort(),u(),d()}}function Mn(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:[]}}),jn(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 Nn(e){return Math.min(50,Math.max(1,Math.ceil(e/10)))}function Pn(e,t){return e===t||e%Nn(t)===0}var Fn=[250,500,1e3,2e3,4e3];function In(e){return e.status===503&&e.problemType===`urn:ok:error:too-many-agent-sessions`}async function Ln(e,t){let n=await t.fixItem(e);for(let r of Fn){if(n.ok||!In(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 Rn(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 Ln(i,e);if(a.ok||n.push({item:i,detail:a.errorDetail}),!e.shouldContinue())return{failures:n,cancelled:!0};let o=r+1;Pn(o,t)&&e.onProgress(o,t)}return{failures:n,cancelled:!1}}function zn(e){return new Promise(t=>setTimeout(t,e))}var Bn=null,Vn=!1,Hn=new Set,Un=new Set;function Wn(e){Bn=e;for(let e of Hn)e()}function Gn(e){return Hn.add(e),()=>{Hn.delete(e)}}function Kn(){return Bn}function qn(){return(0,Z.useSyncExternalStore)(Gn,Kn,Kn)}function Jn(e){return Un.add(e),()=>{Un.delete(e)}}function Yn(){Vn=!0}function Xn(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];G.error(q._({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){G.info(q._({id:`H1TmTu`}));return}e.length===0&&G.success(q._({id:`SWX1O7`,values:{total:n}}))}async function Zn({items:e,fixItem:t,sleep:n=zn}){if(Bn!==null||e.length===0)return;let r=e.length;Vn=!1,Wn({done:0,total:r});let i=[],a=!1,o=!1;try{let o=await Rn({items:e,fixItem:t,sleep:n,onProgress:e=>Wn({done:e,total:r}),shouldContinue:()=>!Vn});i=o.failures,a=o.cancelled}catch(e){console.warn(`[lint] fix-all: sweep threw`,e),o=!0}finally{Wn(null)}try{o?G.error(q._({id:`vwV-kH`})):Xn(i,a,r)}finally{for(let e of Un)e()}}var Qn={errorCount:0,warningCount:0},$n=new Map,er=new Set,tr=new Map;function nr(){let e=new Map;for(let[t,n]of $n){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})}tr=e;for(let e of er)e()}var rr=H;function ir(e){return er.add(e),()=>{er.delete(e)}}function ar(){return tr}function or(e){$n.clear();for(let t of e)$n.set(ye(t.file),rr(t.diagnostics));nr()}function sr(e){$n.clear();for(let t of e)$n.set(ye(t.file),{lint:t.lint,links:t.links});nr()}function cr(e,t){$n.set(e,rr(t)),nr()}function lr(e,t,n){let r=$n.get(e)??{lint:Qn,links:Qn},i=r[t];i.errorCount===n.errorCount&&i.warningCount===n.warningCount||($n.set(e,{...r,[t]:n}),nr())}var ur=`open-knowledge:lint-nav`;function dr(e,t){return e.range.start.line-t.range.start.line||e.range.start.character-t.range.start.character}function fr(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 pr(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 mr={document:l,file:g,image:le,unresolvable:l};function hr(e){return e.linkTarget!==void 0&&pr(e)===`document`}function gr(e){let t=(0,Q.c)(40),{diagnostic:n,instanceCount:r}=e,{_:i}=b(),a=n.severity===`error`?ae:ge,o=n.range.start.line+1,s;t[0]===n?s=t[1]:(s=pr(n),t[0]=n,t[1]=s);let c=s,l=c===null?null:mr[c],u=r!==void 0&&r>1,d=n.severity===`error`?`text-destructive`:`text-amber-500`,f;t[2]===d?f=t[3]:(f=w(`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=En(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 g;t[11]!==u||t[12]!==r?(g=u?(0,$.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(je,{variant:`gray`,"data-testid":`problems-instance-count`,className:`h-4 px-1 font-sans text-[10px] leading-none`,children:(0,$.jsx)(y,{id:`iZCZmF`,values:{instanceCount:r}})}),(0,$.jsx)(X,{"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]=g):g=t[13];let _;t[14]!==p||t[15]!==h||t[16]!==g?(_=(0,$.jsxs)(`span`,{className:`flex items-start gap-1.5 text-sm`,children:[p,h,g]}),t[14]=p,t[15]=h,t[16]=g,t[17]=_):_=t[17];let v=c??void 0,x=l!==null&&`gap-0.5`,S;t[18]===x?S=t[19]:(S=w(`h-4 shrink-0 px-1 font-sans text-[10px] uppercase leading-none`,x),t[18]=x,t[19]=S);let C;t[20]===l?C=t[21]:(C=l===null?null:(0,$.jsx)(l,{"aria-hidden":`true`,className:`size-2.5`}),t[20]=l,t[21]=C);let T;t[22]!==n.source||t[23]!==S||t[24]!==C||t[25]!==v?(T=(0,$.jsxs)(je,{variant:`gray`,"data-testid":`problems-source-tag`,"data-target-kind":v,className:S,children:[C,n.source]}),t[22]=n.source,t[23]=S,t[24]=C,t[25]=v,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]!==_?(k=(0,$.jsxs)($.Fragment,{children:[_,O]}),t[37]=O,t[38]=_,t[39]=k):k=t[39],k}function _r(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 vr(e){let t=(0,Q.c)(63),{group:n,onNavigate:r,navTitle:i,renderActions:a}=e,{_:o}=b(),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=En(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)(gr,{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=j,t[34]!==s||t[35]!==n.instances.length?(f=(0,$.jsx)(A,{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)(gr,{diagnostic:s,instanceCount:n.instances.length})}),t[34]=s,t[35]=n.instances.length,t[36]=f):f=t[36],c=k,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=En(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})]},yr(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 _;t[48]!==u||t[49]!==g?(_=(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]=_):_=t[50];let v;t[51]!==c||t[52]!==d||t[53]!==_?(v=(0,$.jsx)(c,{className:d,children:_}),t[51]=c,t[52]=d,t[53]=_,t[54]=v):v=t[54];let y;t[55]!==l||t[56]!==f||t[57]!==v?(y=(0,$.jsxs)(l,{children:[f,v]}),t[55]=l,t[56]=f,t[57]=v,t[58]=y):y=t[58];let x;return t[59]!==y||t[60]!==p||t[61]!==m?(x=(0,$.jsx)(`li`,{className:p,"data-testid":m,children:y}),t[59]=y,t[60]=p,t[61]=m,t[62]=x):x=t[62],x}function yr(e){return`${e.source}/${e.code}-${e.range.start.line}-${e.range.start.character}-${e.message}`}function br(e){return e.reduce((e,t)=>e+ +((t.fixes?.length??0)>0),0)}function xr(e){let t=(0,Q.c)(11),{target:n,creating:r,disabled:i,onCreate:a}=e,{_:o}=b(),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)(fe,{"aria-hidden":`true`,className:`size-3`}),t[3]=c):c=t[3];let l;t[4]===r?l=t[5]:(l=r?(0,$.jsx)(y,{id:`E9bKSA`}):(0,$.jsx)(y,{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)(T,{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 Sr(e){let t=(0,Q.c)(8),{tip:n,testId:r,children:i}=e,a;t[0]===i?a=t[1]:(a=(0,$.jsx)(E,{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)(D,{"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)(O,{children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Cr(e){let t=(0,Q.c)(21),{count:n,problemCount:r,aiAvailable:i,disabled:a,onClick:o,children:s}=e,{_:c}=b(),l;t[0]!==i||t[1]!==n||t[2]!==r?(l=n>0?(0,$.jsx)(y,{id:`vjwsDi`,values:{count:n}}):r===0?(0,$.jsx)(y,{id:`gAhHu7`}):i?(0,$.jsx)(y,{id:`zA9zRL`}):(0,$.jsx)(y,{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)(_e,{"aria-hidden":`true`,className:`size-3`}),t[9]=d):d=t[9];let f;t[10]!==s||t[11]!==n?(f=s??(0,$.jsx)(y,{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)(T,{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)(Sr,{testId:`problems-auto-fix-tip`,tip:l,children:p}),t[18]=l,t[19]=p,t[20]=m):m=t[20],m}function wr(e){let t=(0,Q.c)(12),{count:n,disabled:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(y,{id:`mgDKWS`,values:{count:n}}),t[0]=n,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(m,{"aria-hidden":`true`,className:`size-3`}),t[2]=o):o=t[2];let s;t[3]===n?s=t[4]:(s=(0,$.jsx)(y,{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)(T,{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)(Sr,{testId:`problems-fix-with-ai-tip`,tip:a,children:c}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l}function Tr(e){let t=(0,Q.c)(61),{docName:n,diagnostics:r,linkFindingsStatus:i,brokenLinkSuppression:a,onFix:o,onAutoFix:l,onAskAi:u,onFixWithAi:d}=e,f=i===void 0?`loaded`:i,{_:p}=b(),h=(0,Z.useRef)(null),g=(0,Z.useId)(),[v,x]=(0,Z.useState)(`doc`),S;t[0]===n?S=t[1]:(S=ee(n),t[0]=n,t[1]=S);let C=!S,{data:w}=He(),k=w===null?null:w.effective.enabled?ie.filter(e=>w.effective.plugins[e.id].enabled):[],A=k!==null&&k.length===0,j=a!==void 0,M=(v===`project`||C)&&k!==null&&k.length>0,N;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(N={status:`idle`},t[2]=N):N=t[2];let[P,F]=(0,Z.useState)(N),I=qn(),L=se(),[R,z]=(0,Z.useState)(null),B=(0,Z.useRef)(!0),V,H;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>(B.current=!0,()=>{B.current=!1}),H=[],t[3]=V,t[4]=H):(V=t[3],H=t[4]),(0,Z.useEffect)(V,H);let U=(0,Z.useRef)(Nr),W=(0,Z.useRef)(Mr),q;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(q={status:`idle`},t[5]=q):q=t[5];let ne=(0,Z.useRef)(q),Y;t[6]===P?Y=t[7]:(Y=()=>{P.status!==`loading`&&(ne.current=P)},t[6]=P,t[7]=Y),(0,Z.useEffect)(Y);let X=(0,Z.useRef)(0),re=[...r].sort(dr),ae=br(re),oe;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(oe=async function(){X.current+=1;let e=X.current,t=ne.current;F({status:`loading`});let n=await On();if(n===`audit-superseded`){X.current===e&&B.current&&F(t.status===`idle`?{status:`failed`}:t);return}n!==null&&or(n.files),B.current&&F(n===null?{status:`failed`}:{status:`loaded`,result:n})},t[8]=oe):oe=t[8];let ce=oe,le;t[9]!==p||t[10]!==P.status||t[11]!==R||t[12]!==L?(le=async function(e){let t=e.linkTarget;if(!(t===void 0||R!==null||L===null)){z(t);try{await _({initialDir:``,suggestedName:t},{addPage:L.addPage})}catch(e){let t=e;G.error(t instanceof Error?t.message:p({id:`tfi40B`})),B.current&&z(null);return}G.success(p({id:`EWCJFu`,values:{target:t}})),B.current&&z(null),B.current&&P.status===`loaded`&&await ce()}},t[9]=p,t[10]=P.status,t[11]=R,t[12]=L,t[13]=le):le=t[13];let ue=le,de=P.status===`loaded`?P.result.files.filter(Ar):[],fe=function(){Zn({items:de,fixItem:kr})},pe;t[14]===P.status?pe=t[15]:(pe=function(e){x(e),e===`project`&&P.status===`idle`&&ce()},t[14]=P.status,t[15]=pe);let me=pe,he;t[16]===P.status?he=t[17]:(he=()=>{U.current=()=>{P.status===`idle`||P.status===`failed`||ce()}},t[16]=P.status,t[17]=he),(0,Z.useEffect)(he);let ge,be;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>Ve(()=>U.current()),be=[],t[18]=ge,t[19]=be):(ge=t[18],be=t[19]),(0,Z.useEffect)(ge,be);let xe,Se;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>te(e=>{J(e)&&U.current()}),Se=[],t[20]=xe,t[21]=Se):(xe=t[20],Se=t[21]),(0,Z.useEffect)(xe,Se);let Ce;t[22]===me?Ce=t[23]:(Ce=(e,t)=>{e===`problems`&&(s(`problems`),t.scope!==void 0&&me(t.scope),t.focus===`panel`&&h.current?.focus({preventScroll:!0}))},t[22]=me,t[23]=Ce);let we=(0,Z.useEffectEvent)(Ce),Te;t[24]===we?Te=t[25]:(Te=()=>{let e=s(`problems`);return e!==null&&we(`problems`,e),c(we)},t[24]=we,t[25]=Te);let Ee;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=[],t[26]=Ee):Ee=t[26],(0,Z.useEffect)(Te,Ee);let De;t[27]===P.status?De=t[28]:(De=()=>{W.current=()=>{P.status===`idle`||P.status===`failed`||ce().catch(e=>{console.warn(`[lint] post-sweep re-audit failed`,e),B.current&&F({status:`failed`})})}},t[27]=P.status,t[28]=De),(0,Z.useEffect)(De);let Oe,ke;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=()=>Jn(()=>W.current()),ke=[],t[29]=Oe,t[30]=ke):(Oe=t[29],ke=t[30]),(0,Z.useEffect)(Oe,ke);let Ae;t[31]===n?Ae=t[32]:(Ae=function(e){let t=fr(n,e);Ct(n,{kind:`lint`,detail:t}),window.dispatchEvent(new CustomEvent(ur,{detail:t}))},t[31]=n,t[32]=Ae);let je=Ae,ze;t[33]!==n||t[34]!==je?(ze=function(e,t){let r=ye(e);if(r===n){je(t);return}Ct(r,{kind:`lint`,detail:fr(r,t)}),window.location.hash=ve(r)},t[33]=n,t[34]=je,t[35]=ze):ze=t[35];let Be=ze,Ue;t[36]!==p||t[37]!==ue||t[38]!==R||t[39]!==u||t[40]!==o||t[41]!==L?(Ue=function(e){let t=o!==void 0&&(e.fixes?.length??0)>0,n=hr(e)&&L!==null;if(!t&&!n&&u===void 0)return null;let r=`${e.source}/${e.code}`;return(0,$.jsxs)($.Fragment,{children:[n?(0,$.jsx)(xr,{target:e.linkTarget??``,creating:R===e.linkTarget,disabled:R!==null,onCreate:()=>void ue(e)}):null,t?(0,$.jsxs)(T,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>o?.(e),"aria-label":p({id:`fZj9em`,values:{flatId:r}}),"data-testid":`problems-fix`,children:[(0,$.jsx)(_e,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(y,{id:`c4fVUV`})]}):null,u===void 0?null:(0,$.jsxs)(T,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>u(e),"aria-label":p({id:`hh4mVC`,values:{flatId:r}}),"data-testid":`problems-ask-ai`,children:[(0,$.jsx)(m,{"aria-hidden":`true`,className:`size-3`}),(0,$.jsx)(y,{id:`xWEvuo`})]})]})},t[36]=p,t[37]=ue,t[38]=R,t[39]=u,t[40]=o,t[41]=L,t[42]=Ue):Ue=t[42];let We=Ue,Ge=Re,Ke;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,$.jsx)(y,{id:`OXdGnd`}),t[43]=Ke):Ke=t[43];let qe;t[44]===g?qe=t[45]:(qe=(0,$.jsx)(Ne,{id:g,children:Ke}),t[44]=g,t[45]=qe);let Je=M&&(0,$.jsxs)(O,{children:[(0,$.jsx)(E,{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)(y,{id:`yxF19Y`,values:{0:k.length}})}),(0,$.jsx)(D,{"data-testid":`problems-active-plugins-tooltip`,children:(0,$.jsx)(y,{id:`ws5o1F`,values:{0:k.map(Or).join(`, `)}})})]}),Ye;t[46]!==qe||t[47]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[qe,Je]}),t[46]=qe,t[47]=Je,t[48]=Ye):Ye=t[48];let Xe=v===`doc`&&re.length>0&&(0,$.jsx)(Ie,{children:re.length}),Ze;t[49]!==Ye||t[50]!==Xe?(Ze=(0,$.jsxs)(Le,{children:[Ye,Xe]}),t[49]=Ye,t[50]=Xe,t[51]=Ze):Ze=t[51];let Qe;t[52]!==me||t[53]!==v?(Qe=(0,$.jsx)(Tn,{scope:v,onScopeChange:me}),t[52]=me,t[53]=v,t[54]=Qe):Qe=t[54];let $e=v===`doc`?(0,$.jsxs)(Fe,{className:`px-2 py-2`,children:[f===`idle`||f===`loading`?(0,$.jsx)(Pe,{className:`px-2 pb-2`,role:`status`,"aria-live":`polite`,"data-testid":`problems-links-loading`,children:(0,$.jsx)(y,{id:`W9NSe0`})}):f===`failed`?(0,$.jsx)(Me,{className:`px-2 pb-2`,role:`status`,"data-testid":`problems-links-failed`,children:re.length>0||j?(0,$.jsx)(y,{id:`IoHQYP`}):(0,$.jsx)(y,{id:`gpbKxw`})}):null,j&&(0,$.jsx)(Rr,{suppression:a}),re.length===0?f===`loaded`?C?A?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pe,{className:`px-2`,"data-testid":`problems-no-plugins`,children:j?(0,$.jsx)(y,{id:`mI1KPS`}):(0,$.jsx)(y,{id:`Hngy37`})}),(0,$.jsx)(`div`,{className:`px-2 pt-2`,children:(0,$.jsx)(T,{variant:`outline`,size:`sm`,onClick:K,"data-testid":`problems-enable-plugins`,children:(0,$.jsx)(y,{id:`rnX-1S`})})})]}):j?null:(0,$.jsx)(Pe,{className:`px-2`,children:(0,$.jsx)(y,{id:`ZI8uvA`})}):(0,$.jsx)(Pe,{className:`px-2`,"data-testid":`problems-markdown-not-applicable`,children:(0,$.jsx)(y,{id:`Kdvukk`})}):null:(0,$.jsxs)($.Fragment,{children:[l!==void 0||d!==void 0?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1 px-2 pb-1`,children:[l!==void 0&&(0,$.jsx)(Cr,{count:ae,problemCount:re.length,aiAvailable:d!==void 0,disabled:ae===0,onClick:l}),d!==void 0&&(0,$.jsx)(wr,{count:re.length,disabled:!1,onClick:()=>d(`doc`)})]}):null,(0,$.jsx)(`ul`,{"aria-label":p({id:`OXdGnd`}),className:`flex flex-col gap-0.5`,children:_r(re).map(e=>(0,$.jsx)(vr,{group:e,onNavigate:je,navTitle:e=>p({id:`vbMHjo`,values:{0:e.range.start.line+1}}),renderActions:We},e.key))})]})]}):(0,$.jsx)(Pr,{audit:P,onRefresh:()=>void ce(),onNavigate:Be,fixableCount:de.reduce(Dr,0),problemCount:P.status===`loaded`?P.result.files.reduce(Er,0):0,fixing:I,onAutoFix:fe,onCancelFix:Yn,onFixWithAi:d===void 0||P.status!==`loaded`?void 0:()=>d(`project`),onCreateTarget:L===null?void 0:e=>void ue(e),creatingTarget:R}),et;return t[55]!==Ge||t[56]!==g||t[57]!==Ze||t[58]!==Qe||t[59]!==$e?(et=(0,$.jsxs)(Ge,{ref:h,tabIndex:-1,"aria-labelledby":g,"data-testid":`problems-panel`,children:[Ze,Qe,$e]}),t[55]=Ge,t[56]=g,t[57]=Ze,t[58]=Qe,t[59]=$e,t[60]=et):et=t[60],et}function Er(e,t){return e+t.diagnostics.length}function Dr(e,t){return e+br(t.diagnostics)}function Or(e){return e.label}function kr(e){return Be(ye(e.file))}function Ar(e){return e.diagnostics.some(jr)}function jr(e){return(e.fixes?.length??0)>0}function Mr(){}function Nr(){}function Pr(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}=b(),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 g=h,[_,v]=(0,Z.useState)(Lr),x;t[3]!==_||t[4]!==g?(x=g.length>0&&g.every(e=>_.has(e.file)),t[3]=_,t[4]=g,t[5]=x):x=t[5];let S=x,C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=function(e,t){v(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},t[6]=C):C=t[6];let w=C,k;t[7]!==S||t[8]!==g?(k=function(){v(S?new Set:new Set(g.map(Ir)))},t[7]=S,t[8]=g,t[9]=k):k=t[9];let A=k,j;t[10]!==n.result||t[11]!==n.status?(j=n.status===`loaded`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{id:`DsDwR-`,values:{0:n.result.errorCount}}),` · `,(0,$.jsx)(y,{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]!==S||t[17]!==g.length||t[18]!==A?(N=g.length>0?(0,$.jsxs)(O,{children:[(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(T,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":p(S?{id:`I4LGsH`}:{id:`Ugvy4O`}),"data-testid":`problems-audit-expand-toggle`,onClick:A,children:S?(0,$.jsx)(Ue,{"aria-hidden":`true`,className:`size-3.5`}):(0,$.jsx)(re,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,$.jsx)(D,{"data-testid":`problems-audit-expand-toggle-tooltip`,children:S?(0,$.jsx)(y,{id:`I4LGsH`}):(0,$.jsx)(y,{id:`Ugvy4O`})})]}):null,t[15]=p,t[16]=S,t[17]=g.length,t[18]=A,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)(he,{"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)(E,{asChild:!0,children:(0,$.jsx)(T,{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)(D,{"data-testid":`problems-audit-refresh-tooltip`,children:(0,$.jsx)(y,{id:`I7y_vn`})}),t[27]=ee):ee=t[27];let R;t[28]===L?R=t[29]:(R=(0,$.jsxs)(O,{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)(O,{children:[(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(T,{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)(y,{id:`ygCKqB`})})}),(0,$.jsx)(D,{"data-testid":`problems-cancel-fix-tooltip`,children:(0,$.jsx)(y,{id:`yvSAuM`})})]}),t[39]=p,t[40]=s,t[41]=l,t[42]=H):H=t[42];let U=u!==void 0,W=m||s!==null||a===0,G;t[43]===s?G=t[44]:(G=s===null?void 0:(0,$.jsx)(y,{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]!==U||t[49]!==W||t[50]!==G?(K=(0,$.jsx)(Cr,{count:a,problemCount:o,aiAvailable:U,disabled:W,onClick:c,children:G}),t[45]=a,t[46]=c,t[47]=o,t[48]=U,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)(wr,{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 te;t[61]!==B||t[62]!==J?(te=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-2 pb-1`,children:[B,J]}),t[61]=B,t[62]=J,t[63]=te):te=t[63];let ne;t[64]!==p||t[65]!==m?(ne=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(Fr)}),t[64]=p,t[65]=m,t[66]=ne):ne=t[66];let Y;t[67]===n.status?Y=t[68]:(Y=n.status===`failed`&&(0,$.jsx)(Me,{className:`px-2 text-xs`,children:(0,$.jsx)(y,{id:`IFezUv`})}),t[67]=n.status,t[68]=Y);let X;t[69]!==n.result||t[70]!==n.status||t[71]!==f||t[72]!==_||t[73]!==d||t[74]!==i?(X=n.status===`loaded`&&(0,$.jsx)(zr,{result:n.result,onNavigate:i,onCreateTarget:d,creatingTarget:f,expandedFiles:_,onToggleFile:w}),t[69]=n.result,t[70]=n.status,t[71]=f,t[72]=_,t[73]=d,t[74]=i,t[75]=X):X=t[75];let ie;return t[76]!==te||t[77]!==ne||t[78]!==Y||t[79]!==X?(ie=(0,$.jsxs)(Fe,{className:`px-2 py-2`,"data-testid":`problems-project-scope`,children:[te,ne,Y,X]}),t[76]=te,t[77]=ne,t[78]=Y,t[79]=X,t[80]=ie):ie=t[80],ie}function Fr(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2 py-1.5`,children:[(0,$.jsx)(ze,{className:`mt-0.5 size-3.5 shrink-0 rounded`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(ze,{className:`h-3 w-28`}),(0,$.jsx)(ze,{className:`h-3 w-40`})]})]},e)}function Ir(e){return e.file}function Lr(){return new Set}function Rr(e){let t=(0,Q.c)(6),{suppression:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(me,{"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)(y,{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)(y,{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 zr(e){let t=(0,Q.c)(18),{result:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,expandedFiles:o,onToggleFile:s}=e,{_:c}=b(),l;t[0]!==c||t[1]!==n.warnings?(l=n.warnings.length>0&&(0,$.jsx)(`ul`,{"aria-label":c({id:`Rsdhj9`}),className:`flex flex-col gap-0.5 pb-1`,children:n.warnings.map(Br)}),t[0]=c,t[1]=n.warnings,t[2]=l):l=t[2];let u;t[3]===n.brokenLinkSuppression?u=t[4]:(u=n.brokenLinkSuppression!==void 0&&(0,$.jsx)(Rr,{suppression:n.brokenLinkSuppression}),t[3]=n.brokenLinkSuppression,t[4]=u);let d;t[5]!==a||t[6]!==o||t[7]!==i||t[8]!==r||t[9]!==s||t[10]!==n.brokenLinkSuppression||t[11]!==n.fileCount||t[12]!==n.files?(d=n.files.length===0?n.brokenLinkSuppression===void 0?(0,$.jsx)(Pe,{className:`px-2`,children:(0,$.jsx)(y,{id:`k_Dqw1`,values:{0:n.fileCount}})}):null:n.files.map(e=>(0,$.jsx)(Vr,{file:e,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o.has(e.file),onOpenChange:t=>s(e.file,t)},e.file)),t[5]=a,t[6]=o,t[7]=i,t[8]=r,t[9]=s,t[10]=n.brokenLinkSuppression,t[11]=n.fileCount,t[12]=n.files,t[13]=d):d=t[13];let f;return t[14]!==l||t[15]!==u||t[16]!==d?(f=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,u,d]}),t[14]=l,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Br(e,t){return(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 px-2 text-xs`,children:[(0,$.jsx)(ge,{"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 Vr(e){let t=(0,Q.c)(45),{file:n,onNavigate:r,onCreateTarget:i,creatingTarget:a,open:o,onOpenChange:s}=e,{_:c}=b(),l,u,d,f,p,m,h,g,_,v;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(dr);u=j,h=o,g=s,_=`problems-audit-group`;let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(X,{"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]=y):y=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),v=(0,$.jsxs)(A,{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:[y,b,(0,$.jsx)(je,{variant:`gray`,"data-testid":`problems-audit-file-count`,className:`shrink-0`,children:e.length})]}),l=k,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)(vr,{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=>!hr(e)||i===void 0?null:(0,$.jsx)(xr,{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=_r(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]=_,t[17]=v}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],_=t[16],v=t[17];let y;t[30]!==d||t[31]!==f||t[32]!==p?(y=(0,$.jsx)(`ul`,{"aria-label":d,className:f,children:p}),t[30]=d,t[31]=f,t[32]=p,t[33]=y):y=t[33];let x;t[34]!==l||t[35]!==m||t[36]!==y?(x=(0,$.jsx)(l,{className:m,children:y}),t[34]=l,t[35]=m,t[36]=y,t[37]=x):x=t[37];let S;return t[38]!==u||t[39]!==x||t[40]!==h||t[41]!==g||t[42]!==_||t[43]!==v?(S=(0,$.jsxs)(u,{open:h,onOpenChange:g,"data-testid":_,children:[v,x]}),t[38]=u,t[39]=x,t[40]=h,t[41]=g,t[42]=_,t[43]=v,t[44]=S):S=t[44],S}function Hr(e,t){return e.has(t)||I(t)}var Ur=null,Wr=[];function Gr(e){if(e===Ur)return Wr;let t=Kr(e);return Ur=e,Wr=t,t}function Kr(e){let t=[],n=new Map,r=B();for(let i=qr(e);i<=e.lines;i++){let a=e.line(i);if(r(a.text))continue;let o=z(a.text,n);o&&t.push({slug:o.slug,from:a.from})}return t}function qr(e){if(!Jr(e.line(1).text))return 1;for(let t=2;t<=e.lines;t++)if(Jr(e.line(t).text))return t+1;return 1}function Jr(e){return W.test(e.endsWith(`\r`)?e.slice(0,-1):e)}function Yr(e){let t=document.getElementById(e);return t?t.getBoundingClientRect().top:null}function Xr(e){let t=new Map;for(let n of Gr(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 Zr(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),d;n[2]===a?d=n[3]:(d=()=>a?u(a):null,n[2]=a,n[3]=d);let f=(0,Z.useSyncExternalStore)(h,d,Qr),p,m;return n[4]!==o||n[5]!==e||n[6]!==f?(p=()=>{if(e.length===0||o&&!f){c(void 0);return}let t=function(){let t=o&&f?Xr(f):Yr,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)}},m=[e,o,f],n[4]=o,n[5]=e,n[6]=f,n[7]=p,n[8]=m):(p=n[7],m=n[8]),(0,Z.useEffect)(p,m),s}function Qr(){return null}var $r=300;async function ei(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new pe(q._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=F.safeParse(n);throw e.success?Error(e.data.title):new pe(q._({id:`zlErBl`}),{status:t.status})}let r=P.safeParse(n);if(!r.success)throw new pe(q._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var ti=32,ni=12,ri=6,ii=`open-knowledge:outline-nav`,ai=`ok-outline-nav`,oi=`ok-outline-nav-dispatch`,si=`ok-outline-nav-settled`;function ci(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(xe,{name:`outline-panel`,children:(0,$.jsx)(li,{...e})}),t[0]=e,t[1]=n),n}function li(e){let t=(0,Q.c)(65),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{_:o}=b(),{pages:s,loading:c,error:l}=oe(),u=x(),{activeProvider:f,activeDocName:p}=d(),m;t[0]!==n||t[1]!==s?(m=Hr(s,n),t[0]=n,t[1]=s,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==u?(g=u.getQueryState([`page-headings`,n]),t[3]=n,t[4]=u,t[5]=g):g=t[5];let _=!c&&l===null&&!h&&g!==void 0,v,C;t[6]===n?(v=t[7],C=t[8]):(v=[`page-headings`,n],C=()=>ei(n),t[6]=n,t[7]=v,t[8]=C);let T=!c&&h,E;t[9]!==v||t[10]!==C||t[11]!==T?(E={queryKey:v,queryFn:C,enabled:T,staleTime:1/0},t[9]=v,t[10]=C,t[11]=T,t[12]=E):E=t[12];let{data:D,isLoading:O,error:k}=S(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]!==_||t[17]!==u?(M=()=>{_&&u.resetQueries({queryKey:[`page-headings`,n]})},N=[_,n,u],t[15]=n,t[16]=_,t[17]=u,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]!==u?(P=()=>{if(!f||p!==n)return;let e=f.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,u.invalidateQueries({queryKey:[`page-headings`,n]})},$r)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},F=[f,p,n,u],t[20]=p,t[21]=f,t[22]=n,t[23]=u,t[24]=P,t[25]=F):(P=t[24],F=t[25]),(0,Z.useEffect)(P,F);let I=c||O,L;t[26]===j?L=t[27]:(L=j.map(ui),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=Zr(ee,R),B,V,H,U,W,G,K;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]!==_){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`&&Ct(n,{kind:`outline`,detail:a}),Se(oi,{docName:n,index:t,mode:a.mode,outlineCount:j.length,headingLevel:j[t]?.level,activeIndex:e}),window.dispatchEvent(new CustomEvent(ii,{detail:a}))},s=((e>=0?j[e].level:1)-1)*ni+(ni-ri)/2,c=e*ti+(ti-ri)/2;V=Re,G=a;let l;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ne,{children:(0,$.jsx)(y,{id:`dD7NPy`})}),t[47]=l):l=t[47];let u;t[48]!==k||t[49]!==j.length||t[50]!==I||t[51]!==_?(u=!I&&!k&&!_&&(0,$.jsx)(Ie,{children:j.length}),t[48]=k,t[49]=j.length,t[50]=I,t[51]=_,t[52]=u):u=t[52],t[53]===u?K=t[54]:(K=(0,$.jsxs)(Le,{children:[l,u]}),t[53]=u,t[54]=K),B=Fe,H=`px-3 py-2`,U=I,W=_?(0,$.jsx)(Pe,{className:`px-2`,role:`status`,children:(0,$.jsx)(y,{id:`0x9smA`})}):k?(0,$.jsx)(Me,{className:`px-2`,children:k instanceof Error?k.message:o({id:`GuqOb1`})}):j.length===0&&!I?(0,$.jsx)(Pe,{className:`px-2`,children:(0,$.jsx)(y,{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:ri,height:ri,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:w(`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)*ni+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]=_,t[40]=B,t[41]=V,t[42]=H,t[43]=U,t[44]=W,t[45]=G,t[46]=K}else B=t[40],V=t[41],H=t[42],U=t[43],W=t[44],G=t[45],K=t[46];let q;t[55]!==B||t[56]!==H||t[57]!==U||t[58]!==W?(q=(0,$.jsx)(B,{className:H,"aria-busy":U,children:W}),t[55]=B,t[56]=H,t[57]=U,t[58]=W,t[59]=q):q=t[59];let J;return t[60]!==V||t[61]!==G||t[62]!==K||t[63]!==q?(J=(0,$.jsxs)(V,{className:G,children:[K,q]}),t[60]=V,t[61]=G,t[62]=K,t[63]=q,t[64]=J):J=t[64],J}function ui(e){return e.slug}var di=!1;function fi(){return di||!ne()?!1:(di=!0,!0)}export{pn as A,Ot as B,xn as C,Sn as D,Cn as E,Nt as F,nt as G,vt as H,Et as I,et as K,Tt as L,Lt as M,Zt as N,$t as O,Qt as P,kt as R,hn as S,wn as T,tt as U,Ct as V,rt as W,kn as _,ci as a,En as b,ur as c,cr as d,lr as f,On as g,Dn as h,si as i,Jt as j,fn as k,Tr as l,ir as m,ai as n,Gr as o,sr as p,ii as r,Hr as s,fi as t,ar as u,jn as v,bn as w,Tn as x,Mn as y,wt as z};
|
package/dist/src-B_zXHjLH.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-C0-0a_4T.mjs";import"./init-BS8pi6aE.mjs";import"./registry-probes-C76k8nXQ.mjs";import"./src-DmJzOo1w.mjs";import"./start-BYKbGiT_.mjs";import{n as e}from"./loader-CEM2DZT5.mjs";import"./preview-BqT0WT0X.mjs";import"./cli.mjs";import"./repair-mcp-configs-CHfth2Jm.mjs";export{e as loadConfig};
|
package/dist/src-DmJzOo1w.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{An as t,Gs as n,_c as r,_s as i,fo as a,hc as o,jn as s,ld as c,mc as l,os as u,tu as ee,zn as te}from"./md-manager-BGnqyqi1-C0-0a_4T.mjs";import{$r as d,Co as ne,Ct as f,Fn as p,Gn as m,Gr as h,Qa as g,Qr as _,To as v,Xi as y,Yn as b,Zr as x,cr as S,gi as C,hi as w,m as T,wo as E,zr as D}from"./dist-9e6NmrQK.mjs";import{t as O}from"./yazl-BBz29IQN.mjs";import{at as k,ot as A,vt as j}from"./init-BS8pi6aE.mjs";import{b as M,l as re}from"./registry-probes-C76k8nXQ.mjs";import{c as N}from"./colors-r_owlCuY.mjs";import{t as ie}from"./is-object-BGze3w87.mjs";import{n as ae}from"./constants-CDtlxNjm.mjs";import"./loader-CEM2DZT5.mjs";import"./preview-BqT0WT0X.mjs";import{execSync as oe,spawnSync as se}from"node:child_process";import{basename as P,dirname as F,isAbsolute as ce,join as I,relative as L,resolve as R,sep as z}from"node:path";import{closeSync as le,cpSync as ue,createWriteStream as de,existsSync as B,lstatSync as fe,mkdirSync as V,mkdtempSync as pe,openSync as me,readFileSync as H,readSync as he,readdirSync as U,rmSync as W,rmdirSync as ge,statSync as _e,writeFileSync as G}from"node:fs";import{arch as ve,freemem as ye,homedir as K,hostname as be,platform as xe,release as Se,tmpdir as Ce,totalmem as we,type as Te,uptime as Ee}from"node:os";import"node:fs/promises";import{createHash as De}from"node:crypto";const Oe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ke(e,t,n=b){if(e!==void 0&&!Oe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ae=null;function je(e){Ae=e}function Me(){return Ae??process.cwd()}const Ne=`Open Knowledge`;function Pe(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return k(t).join(A({...e,platformName:t}),n)}function Fe(e={}){let t=e.platformName??process.platform,n=e.home??K(),r=e.env??process.env,i=k(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,`@inkeepopen-knowledge-desktop-updater`)}function Ie(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 Le(e){let t=I(e,`state.json`);if(!B(t))return[];let n;try{n=JSON.parse(H(t,`utf-8`))}catch{return[]}return Ie(n)??[]}function Re(e){let t=I(e,`state.json`);if(!B(t))return!1;try{return Ie(JSON.parse(H(t,`utf-8`)))!==null}catch{return!1}}const ze=8192;function Be(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 Ve(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const He=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function Ue(e){return e.replace(He,`$1"[REDACTED-DEVICE-ID]"`)}function We(e){return Ue(Ve(e))}const Ge=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Ke(e){if(typeof e!=`string`)return null;let t=Ge.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 qe(e){let t=me(e,`r`);try{let e=Buffer.alloc(ze),n=0,r=!1;for(;n<ze;){let i=he(t,e,n,ze-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{le(t)}}function Je(e){try{let t=qe(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:Ke(a)}}catch{return{kind:`unreadable`}}}function Ye(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Xe(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=U(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=I(e,t.name),r;try{r=_e(n).mtimeMs}catch{continue}if(r<i)continue;let c=Je(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Ye(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 q(){return I(K(),`.ok`,`bug-reports`)}function Ze(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=q(),r=`${t}-bugreport`,i=I(n,`${r}.zip`);for(let e=2;B(i);e+=1)i=I(n,`${r}-${e}.zip`);return i}function Qe(e,t){let n=I(e,`.ok`,`config.yml`);if(B(n))try{let e=H(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 B(I(e,`.ok`))?De(`sha256`).update(R(e)).digest(`hex`).slice(0,12):null}function $e(){let e={timestamp:new Date().toISOString(),platform:xe(),osType:Te(),osRelease:Se(),hostname:`[redacted]`,uptime:Ee(),freeMem:ye(),totalMem:we(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=oe(`sw_vers -productVersion 2>/dev/null`,g({encoding:`utf8`})).trim()}catch{}try{let t=I(__dirname,`..`,`..`,`package.json`);B(t)&&(e.okVersion=JSON.parse(H(t,`utf8`)).version)}catch{}return e}const et=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function tt(e){let t=P(e);return et.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function nt(e,t){return ot(e,t).files}const rt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function it(e,t=re){let n=I(e,`${t}.ShipIt`);if(!B(n))return[];let r;try{r=U(n)}catch{return[]}return rt.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=>I(n,e.entry)))}function at(e){if(!B(e))return[];try{let n=new Map;for(let r of U(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=r.endsWith(`.sent.yaml`)?r.slice(0,-t.length):r.slice(0,-5),i=n.get(e);i===void 0?n.set(e,[r]):i.push(r)}return[...n.values()].slice(-25).flat().map(t=>I(e,t))}catch{return[]}}function ot(e,t){if(!B(t))return{files:[],excludedByProjectSlug:0};let n=U(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>I(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(tt),i=[],a=r.filter(t=>{try{return H(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=>!tt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function st(e){let t=I(e,`.ok`,`local`);return B(t)?{files:[`server.lock`,`last-spawn-error.log`,l].map(e=>I(t,e)).filter(e=>B(e))}:{files:[]}}function ct(e){let t=I(e,`.ok`,`local`,`logs`);return B(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>I(t,e)).filter(e=>B(e))}:{files:[]}}function lt(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#${De(`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 ut(e){let t=e.revealDocNames?e.content:lt(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=u(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 J(e){for(let t of e.files)try{let n=H(t,`utf8`);ut({zipfile:e.zipfile,name:`${e.prefix}/${P(t)}`,content:t.endsWith(`.ips`)?We(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 dt(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??I(K(),`.ok`,`logs`),c=t.projectDir?Qe(t.projectDir,i):null;V(F(r),{recursive:!0}),i?.info({projectSlug:c},`gathering diagnostic data`);let l=$e();l.desktop=t.desktop??null,l.language=t.language??null;let{files:u,excludedByProjectSlug:ee}=ot(c,o),{files:d}=t.projectDir?st(t.projectDir):{files:[]},{files:ne}=t.projectDir?ct(t.projectDir):{files:[]},f=t.shipItLogFiles??[],p=t.diagnosticReports?.files??[];i?.info({logFileCount:u.length,logFilesExcludedByProjectSlug:ee,lockFileCount:d.length,localSinkFileCount:ne.length,shipItLogFileCount:f.length,diagnosticReportCount:p.length},`files collected`);let m=[],h=[],{ZipFile:g}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),_=new g;J({zipfile:_,files:[...u,...f],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:h,redactions:m,logger:i}),J({zipfile:_,files:d,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:h,redactions:m,logger:i}),J({zipfile:_,files:ne,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:h,redactions:m,logger:i}),J({zipfile:_,files:t.bugReportLedgerFiles??[],prefix:s,redact:n,revealDocNames:a,bundleFiles:h,redactions:m,logger:i}),J({zipfile:_,files:p,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=H(e.sourcePath),n=`extra/${e.zipName??P(e.sourcePath)}`;_.addBuffer(t,n),h.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&ut({zipfile:_,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:h,redactions:m});let v=new Set(p.map(e=>`diagnostic-reports/${P(e)}`)),y=h.filter(e=>v.has(e)),b=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Be(t.diagnosticReports,y.length);_.addBuffer(Buffer.from(`${b}\n`,`utf8`),`state/diagnostic-reports-status.txt`),h.push(`state/diagnostic-reports-status.txt`);let x=JSON.stringify(l,null,2);_.addBuffer(Buffer.from(x,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let S={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:c,files:h,redactions:m,sysinfo:l};_.addBuffer(Buffer.from(JSON.stringify(S,null,2),`utf8`),`MANIFEST.json`);let C=m.reduce((e,t)=>e+t.lineCount,0),w=new Set(f.map(e=>`logs/${P(e)}`)),T=h.filter(e=>w.has(e)),E=new Set((t.bugReportLedgerFiles??[]).map(e=>`${s}/${P(e)}`)),D=h.filter(e=>E.has(e)),O=c?h.filter(e=>e.startsWith(`logs/`)&&!tt(e)&&!w.has(e)):[],k=y.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: ${S.generatedAt}`,`Project: ${c??`(unscoped)`}`,`Discipline version: ${S.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...O.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:`,...O.map(e=>`- ${e}`),``]:[],...T.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:`,...T.map(e=>`- ${e}`),``]:[],...y.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:`,...y.map(e=>`- ${e}`),``]:[],...D.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:`,...D.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${te.join(`, `)}`,C>0?`${C} line(s) were scrubbed across ${m.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
|
-
`);_.addBuffer(Buffer.from(j,`utf8`),`README.md`),_.end();let M=de(r);return _.outputStream.pipe(M),await new Promise((e,t)=>{M.on(`close`,e),M.on(`error`,t)}),i?.info({bundlePath:r,fileCount:h.length,redactionCount:C},`bundle written`),{zipPath:r,summary:{projectSlug:c,files:h,redactions:m,redactedLineCount:C,generatedAt:S.generatedAt}}}var ft=ee(),pt=e(O(),1),Y=e(N(),1);function mt(e){let t=v(`user`,e,e);return ne({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function ht({home:e=K(),env:t=process.env}={}){let a=mt(e),{override:o,preferenceList:s}=E(t),{locale:c,source:l}=i({override:o,storedPreference:a,supportedLocales:r,preferenceList:s,autoDetectableLocales:n});return{preference:a,locale:c,source:l,systemLanguages:s}}function gt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function _t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e,t){if(typeof e==`string`)return gt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>X(e,t));if(!_t(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}function vt(e,t){let n=H(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=X(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
5
|
-
`)}\n`:a.join(`
|
|
6
|
-
`);G(e,o)}function yt(e,t){let n=H(e,`utf-8`);if(n.trim().length!==0)try{let r=X(JSON.parse(n),t),i=n.endsWith(`
|
|
7
|
-
`)?`
|
|
8
|
-
`:``;G(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=gt(n,t.contentDir);r!==n&&G(e,r)}}function bt(e,t){let n=H(e,`utf-8`),r=gt(n,t.contentDir);r!==n&&G(e,r)}function xt(e){try{return U(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>I(e,t.name))}catch{return[]}}const St=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Ct(e){return/\.log\.\d+$/.test(e)}function wt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Ct(e)}const Tt=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Et(e){let t={contentDir:e.contentDir};for(let n of Tt)for(let r of xt(I(e.stagingDir,n)))wt(r)?vt(r,t):r.endsWith(`.json`)?yt(r,t):bt(r,t);for(let n of xt(I(e.stagingDir,`state`))){let e=P(n);n.endsWith(`.jsonl`)?vt(n,t):St.has(e)?yt(n,t):bt(n,t)}}const Dt=[`.ok`,`local`,`telemetry`],Ot=[`.ok`,`local`,`logs`],kt=[`.ok`,`local`,`loss-capture`],At=`spans-current.jsonl`,jt=`spans-prev.jsonl`,Mt=`server-current.jsonl`,Nt=`server-prev.jsonl`,Pt=`loss-current.jsonl`,Ft=`loss-prev.jsonl`;function It(e){return I(e,...Dt,At)}function Lt(e){return I(e,...Dt,jt)}function Rt(e){return I(e,...Ot,Mt)}function zt(e){return I(e,...Ot,Nt)}function Bt(e){return I(e,...kt,Pt)}function Vt(e){return I(e,...kt,Ft)}const Ht=1e3;async function Ut(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Ht)});return t.ok?await t.text():null}catch{return null}}async function Wt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Ht)});return t.ok?await t.text():null}catch{return null}}async function Gt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Ht)});return t.ok?await t.text():null}catch{return null}}function Kt(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 qt(e){let t=I(e,`.git`,`ok`);if(!B(t))return null;let n=se(`git`,[`-C`,t,`log`,`--oneline`,`-50`],g({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Jt(e){let t=I(e,`.git`,`ok`);if(!B(t))return null;let n=se(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],g({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Yt(){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 Xt(){return{nodeVersion:process.version,platform:xe(),arch:ve()}}function Zt(){return process.env.OTEL_SDK_DISABLED===`false`}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Qt(e){if(!B(e))return{};let t;try{t=(0,ft.parse)(H(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(!Z(t))return{};let n=t.telemetry;if(!Z(n))return{};let r=n.localSink;return Z(r)?r:{}}function $t(e){return typeof e==`boolean`?e:void 0}function en(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function tn(e){if(Z(e))return en(e.maxBytes)}function nn(e){let t=Qt(v(`project`,e)),n=Qt(v(`project-local`,e));return{enabled:$t(n.enabled)??$t(t.enabled)??!0,spansMaxBytes:tn(n.spans)??tn(t.spans)??52428800,logsMaxBytes:tn(n.logs)??tn(t.logs)??26214400}}function rn(e){return De(`sha256`).update(e).digest(`hex`)}function an(e){let t=H(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const on=[`"doc.name"`,`"docName"`];function sn(e){let t=H(e,`utf-8`),n=0;for(let e of on){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!B(e))return!1;try{return V(F(t),{recursive:!0}),e.endsWith(`.ips`)?G(t,We(H(e,`utf-8`))):ue(e,t),!0}catch{return!1}}function cn(e){let t=[],n=e=>{let r=U(e,{withFileTypes:!0});for(let i of r){let r=I(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const ln=new Set([`.jsonl`]);function un(e){let t=e.lastIndexOf(`.`);return t!==-1&&ln.has(e.slice(t))}const dn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function fn(e){if(Ct(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&dn.has(e.slice(t))}function pn(e){let t=[];for(let n of cn(e)){let r=mn(e,n);if(!fn(r))continue;let{redacted:i,patterns:a,lineCount:o}=u(H(n,`utf-8`));a.length!==0&&(G(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function mn(e,t){return L(e,t).split(z).join(`/`)}async function hn(e){let t=R(e.contentDir),n=R(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Ut,a=r.fetchAgentEffects??Wt,c=r.fetchWatcherRecent??Gt,u=r.readShadowHead??qt,ee=r.readCheckpointRefs??Jt,te=r.now??(()=>new Date),d=r.okVersion??(()=>ae),ne=r.readDesktopEnv??Yt,f=r.readLanguage??ht,p=r.readRuntime??Xt,m=r.isOtlpPushEnabled??Zt,h=pe(I(Ce(),`ok-bundle-`));try{V(I(h,`telemetry`),{recursive:!0}),V(I(h,`logs`),{recursive:!0}),V(I(h,`state`),{recursive:!0}),Q(It(n),I(h,`telemetry`,At)),Q(Lt(n),I(h,`telemetry`,jt)),Q(Rt(n),I(h,`logs`,Mt)),Q(zt(n),I(h,`logs`,Nt));for(let t of e.userLogFiles??[])Q(t,I(h,`logs`,P(t)));for(let t of e.userStateFiles??[])Q(t,I(h,s,P(t)));let g=0;for(let t of e.diagnosticReports?.files??[])Q(t,I(h,`diagnostic-reports`,P(t)))&&(g+=1);let _=I(n,`.ok`,`local`),v=I(_,`server.lock`),y=`not-running`,b=`no server.lock`,x=null;if(B(v)){Q(v,I(h,`state`,`server.lock`));try{let e=H(v,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?x=t.port:b=`lock present but no port`}catch{b=`lock present but unparseable`}}if(x!==null){let e=await i(x);e===null?b=`agent-presence endpoint at :${x} unreachable`:(G(I(h,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await a(x);t!==null&&G(I(h,`state`,`agent-effects.json`),t);let n=await c(x);if(n!==null){let e=Kt(n);e!==null&&G(I(h,`state`,`watcher-recent.jsonl`),e)}}let S=u(t);S!==null&&G(I(h,`state`,`shadow-head.txt`),S);let C=ee(t);C!==null&&G(I(h,`state`,`checkpoint-refs.txt`),C),Q(Bt(n),I(h,`state`,Pt)),Q(Vt(n),I(h,`state`,Ft)),Q(I(_,`last-spawn-error.log`),I(h,`state`,`last-spawn-error.log`)),Q(I(_,o),I(h,`state`,o)),Q(I(_,l),I(h,`state`,l));let w=p(),T=ne(),E=f(),D={ok:{version:d(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T,language:E}};G(I(h,`state`,`runtime.json`),`${JSON.stringify(D,null,2)}\n`);let O=y===`running`?`running
|
|
10
|
-
`:`not-running (${b})\n`;G(I(h,`state`,`server-status.txt`),O);let k=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Be(e.diagnosticReports,g);if(G(I(h,`state`,`diagnostic-reports-status.txt`),`${k}\n`),e.processDir&&B(e.processDir)){let t=I(h,`process`);V(t,{recursive:!0}),ue(e.processDir,t,{recursive:!0})}let A=e.redact===!0;A&&Et({stagingDir:h,contentDir:t}),e.note&&G(I(h,`note.txt`),e.note);let j=null;e.scrubSecrets===!0&&(j=pn(h));for(let t of e.extraFiles??[])Q(t.sourcePath,I(h,`extra`,t.zipName??P(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let M=nn(n),re=cn(h),N=[],ie=0,ae=0;for(let e of re){let t=mn(h,e),n=_e(e).size,r=un(t)?an(e):0;N.push({path:t,bytes:n,lines:r}),ie+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(ae+=sn(e))}let oe={applied:A};j!==null&&(oe.secretScrub=j);let se={schemaVersion:2,createdAt:te().toISOString(),ok:{version:d(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T,language:E},contentDir:{pathSha256:rn(t),absolutePath:A?`<CONTENT_DIR>`:t},telemetry:{localSink:M,otlpPushEnabled:m()},redaction:oe,serverStatus:y,files:N};G(I(h,`manifest.json`),`${JSON.stringify(se,null,2)}\n`);let F=re.some(e=>{try{return H(e,`utf-8`).includes(t)}catch{return!1}}),ce={stagedDiagnosticReports:g,totalBytes:ie,fileCount:N.length,docNameCount:ae,contentDirVisible:F,redacted:A},L=!1;return{stagingDir:h,manifest:se,summary:ce,cleanup:()=>{L||(L=!0,W(h,{recursive:!0,force:!0}))}}}catch(e){throw W(h,{recursive:!0,force:!0}),e}}async function gn(e){let{collected:t,outputPath:n}=e,r=F(n);if(!B(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new pt.ZipFile,a=cn(t.stagingDir);for(let e of a){let n=mn(t.stagingDir,e);i.addFile(e,n)}i.end();let o=de(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 _n(e,t){let n=I(e,`.ok`,`config.yml`);if(B(n))try{let t=(0,ft.parse)(H(n,`utf-8`)),r=ie(t)?t.content:void 0,i=ie(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return R(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 R(e)}async function vn(e,t,n,r,i){let a=Qe(t,e.logger),o=await hn({contentDir:_n(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...nt(a,e.userLogsDir??I(K(),`.ok`,`logs`)),...it(e.cachesDir??I(K(),`Library`,`Caches`))],userStateFiles:at(e.bugReportsDir??q()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{V(F(e.outputPath),{recursive:!0}),await gn({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 yn(e){let{projectDir:t}=e,n=e.readDesktopEnv??Yt,r=e.readLanguage??ht,i=()=>Xe(e.diagnosticReportsDir??I(K(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return vn(e,t,n,r,i());let{zipPath:a,summary:o}=await dt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:it(e.cachesDir??I(K(),`Library`,`Caches`)),bugReportLedgerFiles:at(e.bugReportsDir??q()),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=d(e,t);if(!B(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(H(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!h(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??D)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??S())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??be();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function bn(e){return e.replace(/:\d+$/,``)}function xn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:bn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:bn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:bn(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 Sn=[{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`}],Cn=[...f.map(e=>T[e]),`open-knowledge`];function wn(e){if(!ce(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=R(e);if(t===z||F(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Tn(e,t){let n=L(e,t);if(n.startsWith(`..`)||ce(n))return!1;let r=e;for(let e of n.split(z)){r=I(r,e);try{if(!fe(r).isDirectory())return!1}catch{return!1}}return!0}function En(e,t){try{return U(e).every(n=>t.has(I(e,n)))}catch{return!1}}function Dn(e){let t=wn(e),n=[],r=[],i=new Set;for(let e of Sn){let a=I(t,e.hostDir,`skills`);if(!Tn(t,a))continue;let o=Cn.map(e=>I(a,e)).filter(e=>B(e));n.push(...o);for(let e of o)i.add(e);let s=I(t,e.pruneRoot),c=a;for(;En(c,i)&&(r.push(c),i.add(c),c!==s);){let e=F(c);if(e===c||e===t||!e.startsWith(t+z))break;c=e}}return{skillDirs:n,emptyDirs:r}}function On(e){try{if(!fe(e).isDirectory())return!1;let t=U(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function kn(e){let t=new Set,n=new Set;for(let r of Sn){let i=I(e,r.hostDir,`skills`);for(let e of Cn)t.add(I(i,e));let a=I(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=F(o);if(t===o||t===e||!t.startsWith(e+z))break;o=t}}return{skillDirs:t,emptyDirs:n}}function An(e,t){let n=wn(e),r=kn(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(Tn(n,e)&&On(e))try{W(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Tn(n,e))try{ge(e),a.push(e)}catch{}return a}function jn(e){let t=wn(e),n=[];for(let e of f){let r=T[e];n.push({path:I(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of c)n.push({path:I(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Mn(e,t){let n=[];for(let r of jn(e))if(r.bundleId===t)try{W(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 Nn(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Pn(e,t=Date.now()){let n=a(e,t);return n===`unknown`?`—`:n}function Fn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;let i=t.lock,a=t.status===`alive`&&x(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:m(n),command:n,isDesktop:Nn(n)}}function In(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const Ln=new Set([`running`,`desktop`,`foreign`]);function Rn(e){switch(e){case`running`:return Y.default.green(e);case`desktop`:return Y.default.blue(e);case`foreign`:return Y.default.cyan(e);case`stale`:return Y.default.yellow(e)}}function zn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Bn(e){return`${zn(e.server.usage)} | ${zn(e.ui?.usage??null)}`}function Vn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Hn(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,Vn(e),Bn(e),In(e),String(e.server.pid),Pn(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=Rn(In(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=Y.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
11
|
-
`)}async function Un(e={}){let t=e.discover??p,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??w,a=e.resolveUsage??C,o=await t(),s=[];for(let e of o){let t=n(e),r=Fn(e,t,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:In(e)}));r(JSON.stringify(e,null,2));return}r(Hn(e.all?s:s.filter(e=>Ln.has(In(e)))))}function Wn(){return new j(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await Un({all:t.all===!0||e===`all`,json:t.json===!0})})}async function Gn(e,t=M()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=_(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500)});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 Kn(e,t={}){return{targets:Jn(e,t.isAlive??D)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function qn(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??Gn,o=e.logger??M(),s=Kn(t(),{isAlive:e.isAlive});if(s.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};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:s.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let c=[],l=[];for(let e of s.targets)try{n(e.pid,`SIGTERM`),c.push(e)}catch(t){l.push({target:e,error:t instanceof Error?t.message:String(t)})}return c.length>0&&r(`Stopped: ${c.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:c.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:l.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),l.length>0&&i(`Failed to stop: ${l.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:c,failed:l,hadTargets:!0}}function Jn(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function Yn(e,t=D){let n=await p(),r=null;for(let i of n){let n=$(i,`server`);if(Jn(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function Xn(e,t){let n=await qn({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function Zn(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 Qn(e){let t=await p(),n=0;for(let r of t)r!==e&&Jn($(r,`server`),D)&&n++;return n}function $n(e){return new j(`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 editor windows or agents are still connected to the server`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=y(process.cwd()),n=await qn({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 Qn(t);console.log(Zn(process.cwd(),e,{listingFollows:e>0})),e>0&&await Un({})}return}if(i===`all`){let e=await p();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)Jn($(n,`server`),D)&&(await Xn(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 Yn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await Xn(t,r);return}let a=R(Me(),i),o=y(a),s=[],c=await qn({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(Zn(a,await Qn(o)))})}export{Me as C,Re as S,ke as T,Be as _,An as a,Pe as b,jn as c,yn as d,hn as f,Xe as g,q as h,Wn as i,xn as l,Ze as m,qn as n,Dn as o,gn as p,$n as r,Mn as s,Gn as t,$ as u,Ne as v,je as w,Le as x,Fe as y};
|
package/dist/start-CvIALlUf.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,m as t,p as n,r}from"./start-BYKbGiT_.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|