orc-ai 0.1.52 → 0.1.53
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/index.js +477 -477
- package/dist/web/assets/{Agents-DLu7phP7.js → Agents-D71JHI2H.js} +2 -2
- package/dist/web/assets/Attention-C_LKxdwf.js +2 -0
- package/dist/web/assets/{Audit-nUBNwvkU.js → Audit-BWh52YwS.js} +1 -1
- package/dist/web/assets/{ConfirmDialog-BGZ6sd6E.js → ConfirmDialog-D25Wf6Nc.js} +1 -1
- package/dist/web/assets/{Dashboard-Bhsm-LF4.js → Dashboard-DmYJjKna.js} +1 -1
- package/dist/web/assets/{DocumentWorkspace-C1HAVy0v.js → DocumentWorkspace-CW6S2i4-.js} +1 -1
- package/dist/web/assets/{ErrorState-B0KI2D4y.js → ErrorState-BoQqdsym.js} +1 -1
- package/dist/web/assets/FileEditor-_z3t0Dbd.js +1 -0
- package/dist/web/assets/JobWebhooks-Z4MXZNvH.js +1 -0
- package/dist/web/assets/Jobs-B-7i16mV.js +1 -0
- package/dist/web/assets/Knowledge-DX3nwzng.js +1 -0
- package/dist/web/assets/Markdown-BYChkZ3Z.js +2 -0
- package/dist/web/assets/{MarkdownEditor-BM9COcIb.js → MarkdownEditor-BMQq1cAY.js} +2 -2
- package/dist/web/assets/{MarkdownRenderer-C3UcCxdl.js → MarkdownRenderer-B5esWp7J.js} +96 -96
- package/dist/web/assets/PackageCatalog-CYF3tX8J.js +8 -0
- package/dist/web/assets/{PackageRunDialog-D3kvHk8o.js → PackageRunDialog-DxUs3Qnc.js} +2 -2
- package/dist/web/assets/{Pager-CMsNCI1_.js → Pager-DQCWHQWA.js} +1 -1
- package/dist/web/assets/PriorityBadge-ADp-pD5B.js +1 -0
- package/dist/web/assets/{Projects-BmfdCEv3.js → Projects-C2Ei5Q8Q.js} +2 -2
- package/dist/web/assets/QueryClientProvider-DlPztvhd.js +1 -0
- package/dist/web/assets/{RemoteFolderBrowser-ClOOMU0_.js → RemoteFolderBrowser-Btryj6gG.js} +1 -1
- package/dist/web/assets/{ResumeActions-gVze1Xjw.js → ResumeActions-1gJa3nsX.js} +1 -1
- package/dist/web/assets/{Rules-BMqF79Mt.js → Rules-CZvA-Eis.js} +4 -4
- package/dist/web/assets/ScratchpadDiagramEditor-D44NiVP_.js +159 -0
- package/dist/web/assets/Scratchpads-DP_v2hc8.js +10 -0
- package/dist/web/assets/Sessions-Ctd49sC9.js +3 -0
- package/dist/web/assets/{Settings-Dh7H43-p.js → Settings-BmbdT6Mp.js} +5 -5
- package/dist/web/assets/Skills-C_bBvy92.js +8 -0
- package/dist/web/assets/{SourceEditor-DlC3qNcT.js → SourceEditor-B5CtJBt0.js} +1 -1
- package/dist/web/assets/StatusBadge-CTFDUHuw.js +1 -0
- package/dist/web/assets/TagInput-T6rDuQ7O.js +1 -0
- package/dist/web/assets/TaskDetailSheet-BiIQ82AG.js +1 -0
- package/dist/web/assets/Tasks-OQmOaNqh.js +24 -0
- package/dist/web/assets/Terminals-DVu5OtGU.js +3 -0
- package/dist/web/assets/{ViewHeader-CX02p2eb.js → ViewHeader-DHM9SSkD.js} +1 -1
- package/dist/web/assets/{Webhooks-DUB9var7.js → Webhooks-CDNv5fUD.js} +1 -1
- package/dist/web/assets/{ar-SA-G6X2FPQ2-Br_n6QDe.js → ar-SA-G6X2FPQ2-9uLW-Aib.js} +1 -1
- package/dist/web/assets/{az-AZ-76LH7QW2-QyHk3dvA.js → az-AZ-76LH7QW2-DOqqo97y.js} +1 -1
- package/dist/web/assets/{bg-BG-XCXSNQG7-C6nlcNp_.js → bg-BG-XCXSNQG7-BHUaosi9.js} +1 -1
- package/dist/web/assets/{bn-BD-2XOGV67Q-4ptCYf5W.js → bn-BD-2XOGV67Q-_-LDSkWx.js} +1 -1
- package/dist/web/assets/button-BHKbOsmj.js +1 -0
- package/dist/web/assets/{ca-ES-6MX7JW3Y-Cgoa8y8g.js → ca-ES-6MX7JW3Y-D00wQc68.js} +1 -1
- package/dist/web/assets/{chunk-EIO257PC-D5rz2EHY.js → chunk-EIO257PC-BfeJ3EDs.js} +1 -1
- package/dist/web/assets/{client-BEiLQQ-F.js → client-BwhkVepQ.js} +1 -1
- package/dist/web/assets/{cs-CZ-2BRQDIVT-TiBX7ffm.js → cs-CZ-2BRQDIVT-EB-m3ztC.js} +1 -1
- package/dist/web/assets/{da-DK-5WZEPLOC-qeFhKopb.js → da-DK-5WZEPLOC-DWYR6cGM.js} +1 -1
- package/dist/web/assets/{de-DE-XR44H4JA-m_mVoRik.js → de-DE-XR44H4JA-Ck6sMUnJ.js} +1 -1
- package/dist/web/assets/{dist-EENe35AZ.js → dist-B9K53eWS.js} +1 -1
- package/dist/web/assets/{dist-BqZPrSfD.js → dist-ClOxCp9t.js} +1 -1
- package/dist/web/assets/{dist-C5yPNRzG.js → dist-D3PXSw6Q.js} +1 -1
- package/dist/web/assets/{dist-DcKneJwp.js → dist-HH469UWY.js} +1 -1
- package/dist/web/assets/{el-GR-BZB4AONW-BkZEWwVO.js → el-GR-BZB4AONW-DTkIqoGp.js} +1 -1
- package/dist/web/assets/{en-B4ZKOASM-DZ61I4Io.js → en-B4ZKOASM-Boq12EIA.js} +1 -1
- package/dist/web/assets/{es-ES-U4NZUMDT-N6PHqPGp.js → es-ES-U4NZUMDT-DY7ipP7c.js} +1 -1
- package/dist/web/assets/{eu-ES-A7QVB2H4-B0v57KpC.js → eu-ES-A7QVB2H4-D4Y6LEUc.js} +1 -1
- package/dist/web/assets/{fa-IR-HGAKTJCU-DRM3hyQI.js → fa-IR-HGAKTJCU-BlO1bnpc.js} +1 -1
- package/dist/web/assets/{fi-FI-Z5N7JZ37-BBhjlkHm.js → fi-FI-Z5N7JZ37-CQlPsyFJ.js} +1 -1
- package/dist/web/assets/{fr-FR-RHASNOE6-C6Ekm99g.js → fr-FR-RHASNOE6-DsyF_chP.js} +1 -1
- package/dist/web/assets/{gl-ES-HMX3MZ6V-BVrGslVP.js → gl-ES-HMX3MZ6V-BGAJPW2y.js} +1 -1
- package/dist/web/assets/{he-IL-6SHJWFNN-GiN2vY9l.js → he-IL-6SHJWFNN-BCFUF5Bi.js} +1 -1
- package/dist/web/assets/{hi-IN-IWLTKZ5I-tPRQ0szT.js → hi-IN-IWLTKZ5I-CWKeCfbn.js} +1 -1
- package/dist/web/assets/{highlighted-body-JLMTFACH-R4J_nfqS.js → highlighted-body-JLMTFACH-CYOy6uZ1.js} +1 -1
- package/dist/web/assets/{hu-HU-A5ZG7DT2-CkV1DDWQ.js → hu-HU-A5ZG7DT2-fqogn_m9.js} +1 -1
- package/dist/web/assets/{id-ID-SAP4L64H-DpzooQVd.js → id-ID-SAP4L64H-XFT4nLO5.js} +1 -1
- package/dist/web/assets/{image-GAAHSSAO-D7XRYD-a.js → image-GAAHSSAO-CtqEtsMw.js} +1 -1
- package/dist/web/assets/index-BCGI8JzG.css +1 -0
- package/dist/web/assets/{index-Ck-SDgTR.js → index-CMRGRbC9.js} +27 -28
- package/dist/web/assets/{it-IT-JPQ66NNP-C6oBozob.js → it-IT-JPQ66NNP-CjvUp5j1.js} +1 -1
- package/dist/web/assets/{ja-JP-DBVTYXUO-BG7OaLPP.js → ja-JP-DBVTYXUO-WaxwOOp1.js} +1 -1
- package/dist/web/assets/{kaa-6HZHGXH3-oYKKAQ51.js → kaa-6HZHGXH3-BABl6rMV.js} +1 -1
- package/dist/web/assets/{kab-KAB-ZGHBKWFO-B7LjxWHx.js → kab-KAB-ZGHBKWFO-vrrKDhKa.js} +1 -1
- package/dist/web/assets/{kk-KZ-P5N5QNE5-BjKAAAQx.js → kk-KZ-P5N5QNE5-DV0HT-Fa.js} +1 -1
- package/dist/web/assets/{km-KH-HSX4SM5Z-CP5JVtE5.js → km-KH-HSX4SM5Z-CMzRvYB5.js} +1 -1
- package/dist/web/assets/{ko-KR-MTYHY66A-skmsixpS.js → ko-KR-MTYHY66A-7XqecPXy.js} +1 -1
- package/dist/web/assets/{ku-TR-6OUDTVRD-BQGbWbVU.js → ku-TR-6OUDTVRD-D8O0bwyA.js} +1 -1
- package/dist/web/assets/label-BQ1Lr4sA.js +1 -0
- package/dist/web/assets/{lt-LT-XHIRWOB4-jPcUmdv0.js → lt-LT-XHIRWOB4-DrK90jMT.js} +1 -1
- package/dist/web/assets/{lv-LV-5QDEKY6T-BJimFBjM.js → lv-LV-5QDEKY6T-D7Xl2RRC.js} +1 -1
- package/dist/web/assets/mermaid-WFAXDIZX-CiFtUZlz.js +1 -0
- package/dist/web/assets/{mr-IN-CRQNXWMA-BJCZe-ef.js → mr-IN-CRQNXWMA-CjH1Q3x7.js} +1 -1
- package/dist/web/assets/{my-MM-5M5IBNSE-CzqI7mKR.js → my-MM-5M5IBNSE-CvdwmXcF.js} +1 -1
- package/dist/web/assets/{nb-NO-T6EIAALU-DOipNzcK.js → nb-NO-T6EIAALU-BWMKi1Br.js} +1 -1
- package/dist/web/assets/{nl-NL-IS3SIHDZ-m_uDUlnM.js → nl-NL-IS3SIHDZ-D5A6sC_f.js} +1 -1
- package/dist/web/assets/{nn-NO-6E72VCQL-ChLlN8eQ.js → nn-NO-6E72VCQL-D-p6QrsB.js} +1 -1
- package/dist/web/assets/{oc-FR-POXYY2M6-BJLoLhGq.js → oc-FR-POXYY2M6-6fyqLMv5.js} +1 -1
- package/dist/web/assets/{pa-IN-N4M65BXN-uYfxnmgm.js → pa-IN-N4M65BXN-D99Vs_Tb.js} +1 -1
- package/dist/web/assets/{percentages-BXMCSKIN--kwJevql.js → percentages-BXMCSKIN-B0BZzQvB.js} +1 -1
- package/dist/web/assets/{pl-PL-T2D74RX3-CDCLDsvJ.js → pl-PL-T2D74RX3-cl5WZaGT.js} +1 -1
- package/dist/web/assets/{pt-BR-5N22H2LF-CIrdrTZX.js → pt-BR-5N22H2LF-T6l12jm6.js} +1 -1
- package/dist/web/assets/{pt-PT-UZXXM6DQ-4Aps73mI.js → pt-PT-UZXXM6DQ-DnxUMvhO.js} +1 -1
- package/dist/web/assets/{ro-RO-JPDTUUEW-fgJWBuSP.js → ro-RO-JPDTUUEW-w6wCZHtR.js} +1 -1
- package/dist/web/assets/{ru-RU-B4JR7IUQ-D98t4_hW.js → ru-RU-B4JR7IUQ-DMaA4CQ-.js} +1 -1
- package/dist/web/assets/scratchpad-routes-B75DnNPp.js +1 -0
- package/dist/web/assets/scroll-area-DMjOmHf5.js +1 -0
- package/dist/web/assets/select-CBHDS40x.js +1 -0
- package/dist/web/assets/{si-LK-N5RQ5JYF-DNwP7Qip.js → si-LK-N5RQ5JYF-Coe9-5Yb.js} +1 -1
- package/dist/web/assets/{sk-SK-C5VTKIMK-BfncC8rh.js → sk-SK-C5VTKIMK-Bq23BXvP.js} +1 -1
- package/dist/web/assets/{sl-SI-NN7IZMDC-IXH265Xx.js → sl-SI-NN7IZMDC-WZEKy1qu.js} +1 -1
- package/dist/web/assets/subset-shared.chunk-CAD0Eg6H.js +1 -0
- package/dist/web/assets/{subset-worker.chunk-BNdMWEQD.js → subset-worker.chunk-CAbfOFrS.js} +1 -1
- package/dist/web/assets/{sv-SE-XGPEYMSR-CWjE7XZA.js → sv-SE-XGPEYMSR-p1gc_GrE.js} +1 -1
- package/dist/web/assets/{ta-IN-2NMHFXQM-mzDgApaO.js → ta-IN-2NMHFXQM-o8J0vNj1.js} +1 -1
- package/dist/web/assets/table-ByS-sgsb.js +1 -0
- package/dist/web/assets/tabs-DltQVo38.js +1 -0
- package/dist/web/assets/{th-TH-HPSO5L25-sCRbUk4w.js → th-TH-HPSO5L25-pt7Zt9xm.js} +1 -1
- package/dist/web/assets/{tr-TR-DEFEU3FU-BJVVhuUn.js → tr-TR-DEFEU3FU-BENdvVvp.js} +1 -1
- package/dist/web/assets/{uk-UA-QMV73CPH-CoaqtD6Z.js → uk-UA-QMV73CPH-CenI2hX1.js} +1 -1
- package/dist/web/assets/useDetailRoute-C8xQeILG.js +1 -0
- package/dist/web/assets/useJobs-CCQUWZt3.js +1 -0
- package/dist/web/assets/useKnowledge-DbjT1a0E.js +1 -0
- package/dist/web/assets/{useListSelection-DcULI867.js → useListSelection-CgpNqqAb.js} +1 -1
- package/dist/web/assets/useMemories-D0tEN20z.js +1 -0
- package/dist/web/assets/useMutation-HX90wI4L.js +1 -0
- package/dist/web/assets/useProjectScope-CZEfU9mq.js +1 -0
- package/dist/web/assets/useSessions-C2GU4FkG.js +1 -0
- package/dist/web/assets/{vi-VN-M7AON7JQ-C_1RRSxn.js → vi-VN-M7AON7JQ-REgvRLzg.js} +1 -1
- package/dist/web/assets/{view-params-DNioxw0G.js → view-params-BqRwdnv0.js} +1 -1
- package/dist/web/assets/{x-CtXhMM9g.js → x-BKorzD7S.js} +1 -1
- package/dist/web/assets/{zh-CN-LNUGB5OW-BRsIz_fP.js → zh-CN-LNUGB5OW-Ceo4z5r5.js} +1 -1
- package/dist/web/assets/{zh-HK-E62DVLB3-DwjC6Cwv.js → zh-HK-E62DVLB3-CFQOn9E1.js} +1 -1
- package/dist/web/assets/{zh-TW-RAJ6MFWO-DrD43hHv.js → zh-TW-RAJ6MFWO-GpxYPogk.js} +1 -1
- package/dist/web/index.html +16 -16
- package/package.json +1 -1
- package/dist/web/assets/Attention-D80Q2fL4.js +0 -2
- package/dist/web/assets/FileEditor-B1pLaZil.js +0 -1
- package/dist/web/assets/JobWebhooks-DIfKugwY.js +0 -1
- package/dist/web/assets/Jobs-0VP8O03Z.js +0 -1
- package/dist/web/assets/Knowledge-DCsSHLqC.js +0 -1
- package/dist/web/assets/Markdown-CenDHcGi.js +0 -2
- package/dist/web/assets/PackageCatalog-oQ9U4WEt.js +0 -8
- package/dist/web/assets/PriorityBadge-_KMVnMst.js +0 -1
- package/dist/web/assets/ScratchpadDiagramEditor-BtuYQvFc.js +0 -159
- package/dist/web/assets/Scratchpads-D98SMUv3.js +0 -10
- package/dist/web/assets/Sessions-CLDdpR36.js +0 -3
- package/dist/web/assets/Skills-B5OEYsYx.js +0 -8
- package/dist/web/assets/StatusBadge-CZQsVLgL.js +0 -1
- package/dist/web/assets/TagInput-D7ZsM-Dr.js +0 -1
- package/dist/web/assets/TaskDetailSheet-0hZx_-me.js +0 -1
- package/dist/web/assets/Tasks-c1HlLJhH.js +0 -24
- package/dist/web/assets/Terminals-DQ8HWVlI.js +0 -3
- package/dist/web/assets/button-PNx108iL.js +0 -1
- package/dist/web/assets/index-Bpb-AzH6.css +0 -1
- package/dist/web/assets/label-Ce3QFsX5.js +0 -1
- package/dist/web/assets/mermaid-WFAXDIZX-DmWpYePv.js +0 -1
- package/dist/web/assets/pencil-BPI6pWhy.js +0 -1
- package/dist/web/assets/scratchpad-routes-BwYHUs6J.js +0 -1
- package/dist/web/assets/scroll-area-Alw_ieLV.js +0 -1
- package/dist/web/assets/select-Cg0xEvji.js +0 -1
- package/dist/web/assets/subset-shared.chunk-BJl1UMhd.js +0 -1
- package/dist/web/assets/table-DC8IBMHg.js +0 -1
- package/dist/web/assets/tabs-DWq5oObc.js +0 -1
- package/dist/web/assets/trash-D7o9t0-a.js +0 -1
- package/dist/web/assets/useDetailRoute-1i4Z0-d5.js +0 -1
- package/dist/web/assets/useJobs-B2MCCWKa.js +0 -1
- package/dist/web/assets/useKnowledge-oAVI1FoA.js +0 -1
- package/dist/web/assets/useMemories-CcDhzt2Y.js +0 -1
- package/dist/web/assets/useMutation-DDLZlpLS.js +0 -1
- package/dist/web/assets/useProjectScope-C7yZQa4i.js +0 -1
- package/dist/web/assets/useSessions-Bx-Bw75y.js +0 -1
- package/dist/web/assets/utils-Q1DAuYRG.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{a as i,i as a,r as o,t as s}from"./button-BHKbOsmj.js";import{a as c,c as l,i as u,l as d,n as f,o as p,s as m,t as h}from"./x-BKorzD7S.js";import{a as g,i as _,n as v,r as y,t as b}from"./select-CBHDS40x.js";import{t as x}from"./label-BQ1Lr4sA.js";import{t as S}from"./createLucideIcon-jLuHkL03.js";import{t as C}from"./arrow-left-Czr-LF4l.js";import{t as w}from"./download-WG9NKrMe.js";import{n as T,t as E}from"./folder-open-D5XA0mXE.js";import{t as D}from"./MarkdownEditor-BMQq1cAY.js";import{t as O}from"./upload-Djrxq3zy.js";import{n as k}from"./client-BwhkVepQ.js";import{$t as A,An as j,At as M,Cn as ee,Dn as te,Et as N,G as ne,Ht as P,Jt as F,K as re,Kt as I,Nt as L,On as ie,Ot as R,Sn as z,T as B,Tn as ae,Tt as V,U as H,Ut as oe,Vt as U,W as se,Wt as ce,X as le,Xt as ue,Y as de,Yt as W,Zt as fe,_n as pe,_t as me,an as he,bn as ge,en as _e,ft as ve,in as ye,kn as be,kt as xe,l as Se,ln as Ce,lt as we,mn as Te,nn as Ee,on as De,pn as Oe,qt as G,sn as ke,st as Ae,w as je,wn as Me,wt as K,xn as Ne,yn as Pe,zt as Fe}from"./index-CMRGRbC9.js";import{n as Ie}from"./wiki-links-A52THGx_.js";import{t as Le}from"./save-file-3ZpJah8W.js";import{t as Re}from"./ConfirmDialog-D25Wf6Nc.js";import{t as ze}from"./ErrorState-BoQqdsym.js";import{t as Be}from"./ViewHeader-DHM9SSkD.js";import{t as Ve}from"./view-params-BqRwdnv0.js";import{t as He}from"./EmptyState-YM4VSLR9.js";import{a as Ue,i as We,n as Ge,o as Ke,r as qe,t as Je}from"./table-ByS-sgsb.js";import{t as Ye}from"./useProjectScope-CZEfU9mq.js";import{a as Xe,c as Ze,i as Qe,n as $e,o as et,r as tt,s as nt,t as rt}from"./useMemories-D0tEN20z.js";import{n as it,t as at}from"./DocumentWorkspace-CW6S2i4-.js";import{_ as ot,a as st,c as ct,d as lt,f as ut,g as dt,h as ft,i as pt,l as mt,n as q,o as ht,p as gt,r as _t,s as vt,t as yt,u as bt}from"./useKnowledge-DbjT1a0E.js";import{t as xt}from"./TagInput-T6rDuQ7O.js";var St={name:`file-down`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]};St.node;var Ct=S(St),wt={name:`file-plus`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]};wt.node;var Tt=S(wt),Et={name:`file-up`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]};Et.node;var Dt=S(Et),Ot={name:`folder-sync`,size:24,node:[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5`,key:`1dkoa9`}],[`path`,{d:`M12 10v4h4`,key:`1czhmt`}],[`path`,{d:`m12 14 1.535-1.605a5 5 0 0 1 8 1.5`,key:`lvuxfi`}],[`path`,{d:`M22 22v-4h-4`,key:`1ewp4q`}],[`path`,{d:`m22 18-1.535 1.605a5 5 0 0 1-8-1.5`,key:`14ync0`}]]};Ot.node;var kt=S(Ot),At={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};At.node;var jt=S(At),J=e(t(),1),Y=[`mcp`,`api`,`cli`,`ui`],Mt=[`fetch`,`cited`,`search_hit`],Nt=W().trim().min(1).max(120),Pt=U(Fe(Y)).max(Y.length).transform(e=>Y.filter(t=>e.includes(t)));G({name:Nt,description:W().trim().max(2e3).default(``),project_id:W().min(1).nullable(),editable_by:Pt.default([...Y]),parser:W().min(1).max(40).nullable().default(null)}).strict(),G({name:Nt.optional(),description:W().trim().max(2e3).optional(),editable_by:Pt.optional(),parser:W().min(1).max(40).nullable().optional()}).strict();var Ft=[`default`,`project`,`global`,`all`],It=W().trim().min(1).max(500).refine(e=>!e.startsWith(`/`)&&!e.includes(`\\`)&&!e.includes(`:`)&&!e.includes(`\0`)&&e.split(`/`).every(e=>e&&e!==`.`&&e!==`..`),`Use a relative path with / separators and no . or .. segments`),Lt=U(W().trim().min(1).max(60)).max(30),Rt=2097152;G({title:W().trim().min(1).max(300),path:It.optional(),description:W().trim().max(2e3).optional(),labels:Lt.default([]),content:W().max(Rt),note:W().trim().max(1e3).optional(),derived_from:U(W().min(1)).max(50).default([])}).strict(),G({expected_revision:I().int().min(1),title:W().trim().min(1).max(300).optional(),path:It.optional(),description:W().trim().max(2e3).optional(),labels:Lt.optional(),content:W().max(Rt).optional(),note:W().trim().max(1e3).optional(),derived_from:U(W().min(1)).max(50).optional()}).strict();var zt=G({kind:Fe([`heading`,`paragraph`,`list_item`,`table`,`code`]),text:W(),level:I().int().min(1).max(6).optional(),rows:U(U(W())).optional(),heading_path:U(W()),locator:G({page:I().int().min(1).optional(),sheet:W().optional(),bbox:U(I()).length(4).optional()}).optional()});G({schema_version:ce(1),parser:G({id:W(),version:W(),options:F(W(),fe())}),source_sha256:W().regex(/^[0-9a-f]{64}$/),status:Fe([`ok`,`partial`,`failed`]),language:W().optional(),blocks:U(zt),markdown:W(),warnings:U(W()),timings_ms:F(W(),I()).optional(),peak_rss_mb:I().optional()});var Bt=[`auto`,`lexical`,`semantic`,`hybrid`];G({query:W().trim().min(1).max(2e3),scope:Fe(Ft).default(`default`),kb_ids:U(W().min(1)).max(50).optional(),labels:U(W().min(1)).max(20).optional(),media_types:U(W().min(1)).max(20).optional(),mode:Fe(Bt).default(`auto`),limit:I().int().min(1).max(50).default(10)}).strict().omit({limit:!0,mode:!0}).extend({mode:Fe(Bt).default(`auto`),token_budget:I().int().min(500).max(32e3).default(6e3),max_per_document:I().int().min(1).max(10).default(3)}).strict();var Vt=G({old:W().min(1).max(Rt),new:W().max(Rt),replace_all:P().optional()}).strict(),Ht=G({start_line:I().int().min(1),end_line:I().int().min(0),new:W().max(Rt)}).strict();G({expected_revision:I().int().min(1),edits:U(ue([Vt,Ht])).min(1).max(50),note:W().trim().min(1).max(1e3)}).strict();var Ut=[`open`,`resolved`,`dismissed`];G({document_id:W().min(1).nullable().optional(),body:W().trim().min(1).max(1e4)}).strict(),G({status:Fe([`resolved`,`dismissed`]),reply:W().trim().min(1).max(4e3)}).strict();var Wt=oe(`type`,[G({type:ce(`cron`),cron:W().trim().min(1).max(120)}).strict(),G({type:ce(`manual`)}).strict()]);G({instructions:W().trim().min(1).max(2e4).optional(),backend:W().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/).optional(),schedule:Wt.optional(),enabled:P().optional(),timeout_secs:I().int().min(60).max(7200).optional()}).strict();var Gt=`0 3 * * *`,X=n();function Kt({title:e,testId:t,toggleTestId:n,summary:r,actions:i,expanded:a=!1,onExpandedChange:s,heading:c=`h3`,compact:l=!1,children:u}){let d=(0,J.useId)(),f=u!==void 0&&s!==void 0;return(0,X.jsxs)(`section`,{"data-testid":t,"data-expanded":f?a:void 0,"aria-labelledby":`${d}-heading`,className:`min-w-0 text-sm`,children:[(0,X.jsxs)(`div`,{className:o(`grid min-h-12 min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-0.5 py-1.5`,!l&&`sm:grid-cols-[9rem_minmax(0,1fr)_auto]`),children:[(0,X.jsx)(c,{id:`${d}-heading`,className:`min-w-0 font-medium`,children:f?(0,X.jsxs)(`button`,{type:`button`,"data-testid":n,"aria-expanded":a,"aria-controls":d,className:`-ml-1 flex min-h-9 items-center gap-1.5 rounded px-1 text-left hover:bg-surface-high`,onClick:()=>s(!a),children:[(0,X.jsx)(Te,{size:14,"aria-hidden":!0,className:o(`shrink-0 text-outline transition-transform`,a&&`rotate-90`)}),e]}):(0,X.jsx)(`span`,{className:`flex min-h-9 items-center pl-5`,children:e})}),(0,X.jsx)(`div`,{className:o(`col-span-2 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-5`,!l&&`sm:col-span-1 sm:col-start-2 sm:row-start-1 sm:pl-0`),children:r}),(0,X.jsx)(`div`,{className:o(`col-start-2 row-start-1 flex items-center justify-end gap-1`,!l&&`sm:col-start-3`),children:i})]}),f&&a&&(0,X.jsx)(`div`,{id:d,className:`min-w-0 pb-4 pl-5 pt-1`,children:u})]})}function Z({tone:e}){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:o(`size-1.5 shrink-0 rounded-full`,e===`ok`&&`bg-secondary`,e===`warning`&&`bg-warning`,e===`error`&&`bg-error`,e===`off`&&`bg-muted-foreground`,e===`progress`&&`bg-progress`)})}var qt=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Jt=/^\d+$/,Yt=e=>e.padStart(2,`0`),Xt=e=>/^\*\/(\d+)$/.exec(e)?.[1],Zt=(e,t)=>e===`1`?`Every ${t}`:`Every ${e} ${t}s`;function Qt(e){let[t=``,n=``,r,i,a=``,...o]=e.trim().split(/\s+/);if(o.length||r!==`*`||i!==`*`)return e;if(n===`*`&&a===`*`){if(t===`*`)return`Every minute`;let n=Xt(t);return n?Zt(n,`minute`):Jt.test(t)?Number(t)?`Every hour at :${Yt(t)}`:`Every hour`:e}if(!Jt.test(t))return e;let s=Xt(n);if(s&&a===`*`)return`${Zt(s,`hour`)}${Number(t)?` at :${Yt(t)}`:``}`;if(!Jt.test(n))return e;let c=`${Yt(n)}:${Yt(t)}`;return a===`*`?`Daily at ${c}`:a===`1-5`?`Weekdays at ${c}`:a===`0,6`||a===`6,0`?`Weekends at ${c}`:/^[0-7]$/.test(a)?`${qt[Number(a)%7]}s at ${c}`:e}var $t=[{name:`minute`,min:0,max:59,names:[]},{name:`hour`,min:0,max:23,names:[]},{name:`day of month`,min:1,max:31,names:[]},{name:`month`,min:1,max:12,names:[`JAN`,`FEB`,`MAR`,`APR`,`MAY`,`JUN`,`JUL`,`AUG`,`SEP`,`OCT`,`NOV`,`DEC`]},{name:`weekday`,min:0,max:7,names:[`SUN`,`MON`,`TUE`,`WED`,`THU`,`FRI`,`SAT`]}];function en(e,t){let n=e=>{let n=t.names.indexOf(e.toUpperCase()),r=n>=0?n+ +(t.min===1):Jt.test(e)?Number(e):NaN;return r>=t.min&&r<=t.max?r:NaN};return e.split(`,`).every(e=>{let t=/^(\*|[a-z0-9]+(?:-[a-z0-9]+)?)(?:\/(\d+))?$/i.exec(e);if(!t?.[1]||t[2]!==void 0&&Number(t[2])<1)return!1;if(t[1]===`*`)return!0;let[r=``,i]=t[1].split(`-`);return i===void 0?!Number.isNaN(n(r)):n(r)<=n(i)})}function tn(e){let t=e.trim().split(/\s+/).filter(Boolean);if(!t.length)return`Enter a cron expression.`;if(t.length!==5)return`A cron expression has 5 fields (minute hour day month weekday); this one has ${t.length}.`;for(let[e,n]of $t.entries()){let r=t[e]??``;if(!en(r,n))return`The ${n.name} field "${r}" is not valid. Use a number from ${n.min} to ${n.max}, *, a range (1-5), a list (1,3) or a step (*/2).`}return null}function nn(e){let t=Math.max(0,Math.round((e-Date.now())/1e3));if(t<60)return`in under a minute`;if(t<3600)return`in ${Math.round(t/60)}m`;if(t<86400)return`in ${Math.round(t/3600)}h`;let n=new Date(e);return`${qt[n.getDay()]?.slice(0,3)} ${Yt(String(n.getHours()))}:${Yt(String(n.getMinutes()))}`}function rn(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`just now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function an(e){let t=e.last_run?.status;return t===`running`?`progress`:e.schedule.type===`cron`&&!e.enabled?`off`:t===`failed`?`error`:t===`completed`?`ok`:`off`}function on({kb:e}){let t=pt(e.id),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(!1),o=t.data;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Kt,{title:`Digest`,testId:`kb-digest`,toggleTestId:`kb-digest-expand`,expanded:i,onExpandedChange:a,summary:t.error?(0,X.jsx)(`span`,{role:`alert`,className:`text-error`,children:t.error.message}):t.isLoading?(0,X.jsx)(`span`,{className:`text-outline`,children:`Loading…`}):o?(0,X.jsx)(sn,{digest:o}):(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-outline`,"data-testid":`kb-digest-off`,children:[(0,X.jsx)(Z,{tone:`off`}),`Off, documents change only when someone edits them`]}),actions:o?(0,X.jsx)(cn,{kb:e,digest:o,onStarted:()=>a(!0)}):t.data===null?(0,X.jsx)(s,{size:`sm`,variant:`outline`,"data-testid":`kb-digest-add`,onClick:()=>r(`edit`),children:`Set up`}):null,children:o?(0,X.jsx)(ln,{kb:e,digest:o,onEdit:()=>r(`edit`)}):(0,X.jsx)(`p`,{className:`max-w-prose text-outline`,children:`A digest is an agent that reads new memories, sessions and open comments, then keeps the documents in this knowledge base current. It can run on a schedule or only when you start it.`})}),n===`edit`&&(0,X.jsx)(Nn,{kb:e,digest:o??null,onClose:()=>r(null),onRemove:()=>r(`remove`)}),n===`remove`&&(0,X.jsx)(Pn,{kb:e,onClose:()=>r(null)})]})}function sn({digest:e}){let t=e.last_run,n=e.schedule.type===`manual`||e.enabled;return(0,X.jsxs)(`span`,{"data-testid":`kb-digest-summary`,className:`inline-flex min-w-0 flex-wrap items-center gap-x-1.5`,children:[(0,X.jsx)(Z,{tone:an(e)}),(0,X.jsx)(`span`,{"data-testid":`kb-digest-enabled`,children:n?`On`:`Paused`}),(0,X.jsxs)(`span`,{children:[`·`,` `,e.schedule.type===`manual`?`runs when you start it`:(0,X.jsx)(`span`,{title:e.schedule.cron,children:Qt(e.schedule.cron)})]}),e.next_run_at!==null&&(0,X.jsxs)(`span`,{className:`text-outline`,"data-testid":`kb-digest-next-run`,children:[`·`,` `,(0,X.jsxs)(`span`,{title:new Date(e.next_run_at).toLocaleString(),children:[`next run `,nn(e.next_run_at)]})]}),(0,X.jsxs)(`span`,{className:`text-outline`,"data-testid":`kb-digest-last-run`,"data-status":t?.status??`never`,children:[`·`,` `,t?t.status===`running`?`running now`:(0,X.jsxs)(`span`,{title:new Date(t.at).toLocaleString(),children:[`last run`,` `,(0,X.jsx)(`span`,{className:t.status===`failed`?`text-error`:void 0,children:t.status===`completed`?`succeeded`:t.status}),` `,rn(t.at)]}):`not run yet`]})]})}function cn({kb:e,digest:t,onStarted:n}){let r=q(),i=Q(),a=t.last_run?.status===`running`;async function o(){await i.run(()=>k.kb.runDigest(e.id))&&(n(),await r())}return(0,X.jsxs)(X.Fragment,{children:[i.error&&(0,X.jsx)(`span`,{role:`alert`,className:`text-error`,"data-testid":`kb-digest-error`,children:i.error}),(0,X.jsx)(s,{size:`sm`,variant:`outline`,"data-testid":`kb-digest-run`,onClick:o,disabled:i.pending||a,children:a?`Running…`:`Run now`})]})}function ln({kb:e,digest:t,onEdit:n}){let r=q(),i=Q(),a=st(e.id,t);async function o(){await i.run(()=>k.kb.setDigest(e.id,{enabled:!t.enabled}))&&await r()}return(0,X.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,X.jsxs)(`p`,{className:`max-w-prose text-outline`,children:[`The `,(0,X.jsx)(`span`,{className:`font-mono text-on-surface`,children:t.backend}),` agent reads new memories, sessions and open comments, then updates documents here.`,` `,(0,X.jsx)(`span`,{"data-testid":`kb-digest-open-comments`,children:t.open_comments}),` open`,` `,t.open_comments===1?`comment waits`:`comments wait`,` for the next run.`]}),(0,X.jsxs)(`div`,{className:`-ml-2 flex flex-wrap items-center gap-1`,children:[(0,X.jsx)(s,{size:`sm`,variant:`ghost`,"data-testid":`kb-digest-edit`,onClick:n,children:`Edit instructions and schedule`}),t.schedule.type===`cron`&&(0,X.jsx)(s,{size:`sm`,variant:`ghost`,"data-testid":`kb-digest-toggle`,onClick:o,disabled:i.pending,children:t.enabled?`Pause schedule`:`Resume schedule`}),(0,X.jsx)(s,{size:`sm`,variant:`ghost`,asChild:!0,children:(0,X.jsx)(ae,{to:`/jobs/${encodeURIComponent(t.job_id)}`,"data-testid":`kb-digest-job`,children:`Job history`})})]}),i.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-error`,"data-testid":`kb-digest-error`,children:i.error}),(0,X.jsx)(dn,{runs:a.data??[]})]})}var un={failed:`error`,success:`ok`,running:`progress`};function dn({runs:e}){return e.length?(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`h4`,{className:`text-xs font-medium text-outline`,children:`Recent runs`}),(0,X.jsx)(`ol`,{"data-testid":`kb-digest-runs`,className:`divide-y divide-outline-variant`,children:e.map(e=>(0,X.jsxs)(`li`,{"data-testid":`kb-digest-run-row`,"data-status":e.status,className:`min-w-0 wrap-break-word py-1.5`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(Z,{tone:un[e.status]??`off`}),e.status]}),(0,X.jsxs)(`span`,{className:`text-outline`,children:[` · `,e.started_at?(0,X.jsx)(`span`,{title:new Date(e.started_at).toLocaleString(),children:rn(e.started_at)}):`not started`,e.trigger_by?` · ${e.trigger_by}`:``]}),e.session_id&&(0,X.jsx)(ae,{to:`/audit/${encodeURIComponent(e.session_id)}`,className:`ml-2 text-primary hover:underline`,children:`Session`}),(e.error||e.summary)&&(0,X.jsx)(`span`,{className:`block truncate text-xs text-outline`,title:e.error??e.summary??``,children:e.error??e.summary})]},e.run_id))})]}):(0,X.jsx)(`p`,{className:`text-outline`,children:`No runs yet.`})}var fn=`__global__`,pn=`__auto__`;function mn(e){return e instanceof Error?e.message:`Request failed`}function Q(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(null);async function i(e){t(!0),r(null);try{return await e()}catch(e){r(mn(e));return}finally{t(!1)}}return{pending:e,error:n,run:i,setError:r}}function $({label:e,children:t,hint:n}){return(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(x,{className:`text-sm text-muted-foreground`,children:e}),t,n&&(0,X.jsx)(`p`,{className:`text-xs text-outline`,children:n})]})}function hn({error:e}){return e?(0,X.jsx)(`p`,{role:`alert`,"data-testid":`kb-dialog-error`,className:`text-sm text-error`,children:e}):null}function gn({open:e,onClose:t,title:n,wide:r,size:i,children:a}){return(0,X.jsx)(V,{open:e,onOpenChange:e=>!e&&t(),children:(0,X.jsxs)(N,{className:`bg-surface border-outline-variant ${i===`xl`?`w-[calc(100%-1rem)] max-w-4xl`:r?`max-w-3xl`:`max-w-md`}`,children:[(0,X.jsx)(xe,{children:(0,X.jsx)(M,{className:`text-base text-on-surface`,children:n})}),a]})})}function _n({value:e,onChange:t}){let n=lt();return(0,X.jsxs)(b,{value:e??pn,onValueChange:e=>t(e===pn?null:e),children:[(0,X.jsx)(_,{"aria-label":`Parser`,"data-testid":`kb-parser-select`,children:(0,X.jsx)(g,{})}),(0,X.jsxs)(v,{children:[(0,X.jsx)(y,{value:pn,children:`Workspace default`}),(n.data?.parsers??[]).map(e=>(0,X.jsxs)(y,{value:e.id,disabled:!e.installed,children:[e.label,e.installed?``:` (not installed)`]},e.id))]})]})}var vn={ui:`Web UI`,cli:`CLI`,api:`REST API`,mcp:`Agents (MCP)`};function yn({value:e,onChange:t}){return(0,X.jsxs)(`fieldset`,{className:`space-y-2 rounded-md border border-outline-variant p-3`,children:[(0,X.jsx)(`legend`,{className:`px-1 text-sm text-muted-foreground`,children:`Who can change documents`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,children:Y.map(n=>(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(`input`,{type:`checkbox`,"data-testid":`kb-editable-${n}`,checked:e.includes(n),onChange:r=>t(Y.filter(t=>t===n?r.target.checked:e.includes(t)))}),vn[n]]},n))}),(0,X.jsx)(`p`,{className:`text-xs text-outline`,children:`Every source can read and search. Knowledge base settings change only from the UI, CLI or API.`})]})}function bn({open:e,projectId:t,onClose:n,onCreated:r}){let i=me(),a=q(),o=Q(),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(t??fn),[m,h]=(0,J.useState)([...Y]),[x,S]=(0,J.useState)(null);async function C(e){e.preventDefault();let t=await o.run(()=>k.kb.create({name:c.trim(),description:u.trim(),project_id:f===fn?null:f,editable_by:m,parser:x}));t&&(await a(),r(t))}return(0,X.jsx)(gn,{open:e,onClose:n,title:`New knowledge base`,children:(0,X.jsxs)(`form`,{onSubmit:C,className:`space-y-4`,children:[(0,X.jsx)($,{label:`Name`,children:(0,X.jsx)(K,{"aria-label":`Name`,"data-testid":`kb-name-input`,value:c,onChange:e=>l(e.target.value),placeholder:`e.g. Runbooks`,autoFocus:!0})}),(0,X.jsx)($,{label:`Description`,children:(0,X.jsx)(L,{"aria-label":`Description`,value:u,onChange:e=>d(e.target.value),rows:2})}),(0,X.jsx)($,{label:`Belongs to`,hint:`Project knowledge bases are visible in that project; global ones in every project.`,children:(0,X.jsxs)(b,{value:f,onValueChange:p,children:[(0,X.jsx)(_,{"aria-label":`Belongs to`,"data-testid":`kb-owner-select`,children:(0,X.jsx)(g,{})}),(0,X.jsxs)(v,{children:[(0,X.jsx)(y,{value:fn,children:`Global (all projects)`}),(i.data??[]).map(e=>(0,X.jsx)(y,{value:e.id,children:e.name},e.id))]})]})}),(0,X.jsx)(yn,{value:m,onChange:h}),(0,X.jsx)($,{label:`Parser for uploads`,children:(0,X.jsx)(_n,{value:x,onChange:S})}),(0,X.jsx)(hn,{error:o.error}),(0,X.jsxs)(R,{children:[(0,X.jsx)(s,{type:`button`,variant:`ghost`,onClick:n,children:`Cancel`}),(0,X.jsx)(s,{type:`submit`,"data-testid":`kb-create-submit`,disabled:!c.trim()||o.pending,children:o.pending?`Creating…`:`Create`})]})]})})}function xn({kb:e,onClose:t,onDeleted:n}){let r=me(),i=q(),a=Q(),[o,c]=(0,J.useState)(e.name),[l,u]=(0,J.useState)(e.description),[d,f]=(0,J.useState)(e.editable_by),[p,m]=(0,J.useState)(e.parser),[h,g]=(0,J.useState)(!1);async function _(n){n.preventDefault(),await a.run(()=>k.kb.update(e.id,{name:o.trim(),description:l.trim(),editable_by:d,parser:p}))&&(await i(),t())}return(0,X.jsxs)(gn,{open:!0,onClose:t,title:`Knowledge base settings`,children:[(0,X.jsxs)(`form`,{onSubmit:_,className:`space-y-4`,children:[(0,X.jsx)($,{label:`Name`,children:(0,X.jsx)(K,{"aria-label":`Name`,"data-testid":`kb-name-input`,value:o,onChange:e=>c(e.target.value)})}),(0,X.jsx)($,{label:`Description`,children:(0,X.jsx)(L,{"aria-label":`Description`,value:l,onChange:e=>u(e.target.value),rows:2})}),(0,X.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Belongs to`}),(0,X.jsxs)(`p`,{className:`text-outline`,"data-testid":`kb-settings-owner`,children:[e.project_id===null?`Global, visible in every project`:`${r.data?.find(t=>t.id===e.project_id)?.name??`A project`}, visible in that project`,`. Set when the knowledge base is created.`]})]}),(0,X.jsx)(yn,{value:d,onChange:f}),(0,X.jsx)($,{label:`Parser for uploads`,hint:`Applies to new uploads and reparses.`,children:(0,X.jsx)(_n,{value:p,onChange:m})}),(0,X.jsx)(hn,{error:a.error}),(0,X.jsxs)(R,{className:`gap-2 sm:justify-between`,children:[(0,X.jsxs)(s,{type:`button`,variant:`ghost`,className:`text-error`,"data-testid":`kb-delete`,onClick:()=>g(!0),children:[(0,X.jsx)(_e,{size:14}),`Delete`]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(s,{type:`button`,variant:`ghost`,onClick:t,children:`Cancel`}),(0,X.jsx)(s,{type:`submit`,"data-testid":`kb-settings-save`,disabled:!o.trim()||a.pending,children:`Save`})]})]})]}),(0,X.jsx)(Re,{open:h,title:`Delete knowledge base`,description:`Delete "${e.name}" with its ${e.document_count} documents, revisions and uploaded files? Registered folders on disk are not touched.`,isPending:a.pending,onCancel:()=>g(!1),onConfirm:async()=>{let t=await a.run(()=>k.kb.remove(e.id));g(!1),t!==void 0&&(await i(),n())}})]})}function Sn(e){return`${e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`untitled`}.md`}function Cn(e){return e.match(/^#\s+(.+?)\s*#*\s*$/m)?.[1]?.trim()??``}var wn=/\.(md|markdown|txt)$/i;function Tn({kb:e,initialFile:t,onClose:n,onCreated:r,onUploadMany:i}){let o=q(),c=Q(),l=mt(e.id),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(``),[m,g]=(0,J.useState)(``),[_,v]=(0,J.useState)([]),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),C=(0,J.useRef)(null),w=y?``:Cn(f),T=u.trim()||w,E=y?y.name:Sn(T),A=y!==null||f.trim()!==``;async function j(e){let t=e.name.replace(/\.[^.]+$/,``);if(!wn.test(e.name)){b(e),d(t),g(``);return}S(!0);let n=await c.run(()=>e.text());S(!1),n!==void 0&&(b(null),p(n),d(Cn(n)||t),g(/\.txt$/i.test(e.name)?Sn(t):e.name))}function M(e){let t=[...e??[]];t.length>1?i(t):t[0]&&j(t[0])}(0,J.useEffect)(()=>{t&&j(t)},[]);async function ee(t){t.preventDefault();let n=await c.run(()=>y?k.kb.upload(e.id,{file:y,title:T,path:m.trim()||void 0,labels:_}):k.kb.createDocument(e.id,{title:T,path:m.trim()||E,labels:_,content:A?f:`# ${T}\n\n`}));n&&(await o(),r(n,A))}return(0,X.jsx)(gn,{open:!0,onClose:n,title:`New document in ${e.name}`,size:`xl`,children:(0,X.jsxs)(`form`,{onSubmit:ee,className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm text-outline`,children:[(0,X.jsx)(`span`,{children:`Write or paste below, or start from a file.`}),(0,X.jsxs)(s,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`kb-doc-choose-file`,disabled:x||c.pending,onClick:()=>C.current?.click(),children:[(0,X.jsx)(O,{size:16}),x?`Reading…`:`Upload file`]}),(0,X.jsx)(`input`,{ref:C,type:`file`,multiple:!0,hidden:!0,"data-testid":`kb-doc-file-input`,onChange:e=>{M(e.target.files),e.target.value=``}})]}),(0,X.jsx)($,{label:`Title`,hint:w&&!u.trim()?`Taken from the first heading.`:void 0,children:(0,X.jsx)(K,{"aria-label":`Title`,"data-testid":`kb-doc-title-input`,value:u,onChange:e=>d(e.target.value),placeholder:w||`e.g. Deploy runbook`,autoFocus:!0})}),y?(0,X.jsx)($,{label:`File`,hint:`Converted to searchable text after it is added. The original file is kept.`,children:(0,X.jsxs)(`div`,{"data-testid":`kb-doc-file`,className:`flex items-center gap-3 rounded-md border border-surface-highest bg-surface p-3`,children:[(0,X.jsx)(Oe,{size:20,className:`shrink-0 text-outline`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,title:y.name,children:y.name}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-outline`,children:a(y.size)}),(0,X.jsx)(s,{type:`button`,size:`icon`,variant:`ghost`,"aria-label":`Remove ${y.name}`,"data-testid":`kb-doc-file-remove`,onClick:()=>{b(null),d(``)},children:(0,X.jsx)(h,{size:16})})]})}):(0,X.jsx)($,{label:`Content`,hint:`Markdown. Leave empty to start writing in the editor.`,children:(0,X.jsx)(D,{path:m.trim()||E,value:f,onChange:p,testId:`kb-doc-content-input`,label:`Content`,placeholder:`Write or paste Markdown`,initialMode:`edit`,height:`45vh`})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)($,{label:`Labels`,hint:`Enter, comma or space adds a label.`,children:(0,X.jsx)(xt,{"aria-label":`Labels`,"data-testid":`kb-doc-labels-input`,value:_,onChange:v,suggestions:l.data?.labels.map(e=>e.label)})}),(0,X.jsx)($,{label:`Path`,hint:`Optional. Folders come from the path, e.g. guides/setup.md.`,children:(0,X.jsx)(K,{"aria-label":`Path`,"data-testid":`kb-doc-path-input`,value:m,onChange:e=>g(e.target.value),placeholder:E,className:`font-mono text-sm`})})]}),(0,X.jsx)(hn,{error:c.error}),(0,X.jsxs)(R,{children:[(0,X.jsx)(s,{type:`button`,variant:`ghost`,onClick:n,children:`Cancel`}),(0,X.jsx)(s,{type:`submit`,"data-testid":`kb-doc-create-submit`,disabled:!T||c.pending,children:`Create`})]})]})})}function En({doc:e,linkedFrom:t,onClose:n,onSaved:r}){let i=q(),a=Q(),[o,c]=(0,J.useState)(e.title),[l,u]=(0,J.useState)(e.path),d=mt(e.kb_id),[f,p]=(0,J.useState)(e.labels),[m,h]=(0,J.useState)(e.description),g=o.trim()!==e.title||l.trim()!==e.path;async function _(t){t.preventDefault(),await a.run(()=>k.kb.updateDocument(e.id,{expected_revision:e.revision,title:o.trim(),path:l.trim(),labels:f,description:m.trim()}))&&(await i(),r())}return(0,X.jsx)(gn,{open:!0,onClose:n,title:`Document properties`,children:(0,X.jsxs)(`form`,{onSubmit:_,className:`space-y-4`,children:[(0,X.jsx)($,{label:`Title`,children:(0,X.jsx)(K,{"aria-label":`Title`,"data-testid":`kb-doc-title-input`,value:o,onChange:e=>c(e.target.value)})}),(0,X.jsx)($,{label:`Path`,children:(0,X.jsx)(K,{"aria-label":`Path`,"data-testid":`kb-doc-path-input`,value:l,onChange:e=>u(e.target.value),className:`font-mono text-sm`})}),(0,X.jsx)($,{label:`Labels`,hint:`Enter, comma or space adds a label.`,children:(0,X.jsx)(xt,{"aria-label":`Labels`,"data-testid":`kb-doc-labels-input`,value:f,onChange:p,suggestions:d.data?.labels.map(e=>e.label)})}),(0,X.jsx)($,{label:`Description`,children:(0,X.jsx)(L,{"aria-label":`Description`,value:m,onChange:e=>h(e.target.value),rows:2})}),g&&t>0&&(0,X.jsxs)(`p`,{role:`status`,className:`text-sm text-warning`,"data-testid":`kb-rename-warning`,children:[t===1?`1 document links`:`${t} documents link`,` to this document. Links that use the old title or path will show as missing.`]}),(0,X.jsx)(hn,{error:a.error}),(0,X.jsxs)(R,{children:[(0,X.jsx)(s,{type:`button`,variant:`ghost`,onClick:n,children:`Cancel`}),(0,X.jsx)(s,{type:`submit`,"data-testid":`kb-doc-properties-save`,disabled:!o.trim()||a.pending,children:`Save`})]})]})})}var Dn={daily:`Every day`,weekly:`Once a week`,custom:`Custom cron`,manual:`Manual only`};function On(e){let t=e.type===`cron`?e.cron:Gt,n={plan:`custom`,time:`03:00`,day:`1`,cron:t},r=/^(\d{1,2}) (\d{1,2}) \* \* (\*|[0-6])$/.exec(t.trim().split(/\s+/).join(` `)),[i,a]=[Number(r?.[1]),Number(r?.[2])],o=r&&i<=59&&a<=23?`${String(a).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:null;return e.type===`manual`?{...n,plan:`manual`,time:o??n.time}:!r?.[3]||!o?n:r[3]===`*`?{...n,plan:`daily`,time:o}:{...n,plan:`weekly`,time:o,day:r[3]}}function kn({plan:e,time:t,day:n,cron:r}){if(e===`manual`)return null;if(e===`custom`)return r.trim();let[i,a]=t.split(`:`).map(Number);return`${a} ${i} * * ${e===`weekly`?n:`*`}`}function An(e){return e.plan===`manual`?null:e.plan===`custom`?tn(e.cron):/^\d{2}:\d{2}$/.test(e.time)?null:`Pick a time.`}function jn(e){let t=Qt(e);return t===e?`Runs on this cron schedule`:qt.some(e=>t.startsWith(e))?`Runs ${t}`:`Runs ${t.charAt(0).toLowerCase()}${t.slice(1)}`}function Mn({value:e,onChange:t}){let n=kn(e),r=An(e),i=n=>t({...e,...n});return(0,X.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-outline-variant p-3`,children:[(0,X.jsx)(`legend`,{className:`px-1 text-sm text-muted-foreground`,children:`When it runs`}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,X.jsx)($,{label:`Schedule`,children:(0,X.jsxs)(b,{value:e.plan,onValueChange:e=>i({plan:e,...e===`custom`&&n?{cron:n}:{}}),children:[(0,X.jsx)(_,{"aria-label":`Schedule`,"data-testid":`kb-digest-schedule`,children:(0,X.jsx)(g,{})}),(0,X.jsx)(v,{children:Object.keys(Dn).map(e=>(0,X.jsx)(y,{value:e,children:Dn[e]},e))})]})}),e.plan===`weekly`&&(0,X.jsx)($,{label:`Day`,children:(0,X.jsxs)(b,{value:e.day,onValueChange:e=>i({day:e}),children:[(0,X.jsx)(_,{"aria-label":`Day`,"data-testid":`kb-digest-day`,children:(0,X.jsx)(g,{})}),(0,X.jsx)(v,{children:qt.map((e,t)=>(0,X.jsx)(y,{value:String(t),children:e},e))})]})}),(e.plan===`daily`||e.plan===`weekly`)&&(0,X.jsx)($,{label:`Time`,children:(0,X.jsx)(K,{type:`time`,"aria-label":`Time`,"data-testid":`kb-digest-time`,value:e.time,onChange:e=>i({time:e.target.value})})}),e.plan===`custom`&&(0,X.jsx)(`div`,{className:`sm:col-span-2`,children:(0,X.jsx)($,{label:`Cron expression`,hint:`minute hour day month weekday, e.g. 0 */6 * * *`,children:(0,X.jsx)(K,{"aria-label":`Cron expression`,"aria-invalid":r!==null,"data-testid":`kb-digest-cron`,value:e.cron,onChange:e=>i({cron:e.target.value}),className:`font-mono`,autoComplete:`off`})})})]}),(0,X.jsx)(`p`,{"aria-live":`polite`,"data-testid":`kb-digest-schedule-preview`,"data-valid":r===null,className:`text-sm ${r?`text-error`:`text-outline`}`,children:r||(n?(0,X.jsxs)(X.Fragment,{children:[jn(n),` `,(0,X.jsxs)(`span`,{className:`font-mono text-xs`,children:[`(`,n,`)`]}),`, in the ORC server's time zone.`]}):`Runs only when you start it.`)})]})}function Nn({kb:e,digest:t,onClose:n,onRemove:r}){let i=q(),a=Q(),o=ve(),c=ht(!t),[l,u]=(0,J.useState)(t?.instructions??null),[d,f]=(0,J.useState)(t?.backend??`__default__`),[p,m]=(0,J.useState)(()=>On(t?.schedule??{type:`cron`,cron:`0 3 * * *`}));(0,J.useEffect)(()=>{l===null&&c.data&&u(c.data.instructions)},[l,c.data]);let h=An(p);async function g(t){if(t.preventDefault(),h)return a.setError(h);let r=d===`__default__`?o.data?.default_backend:d,s=kn(p);await a.run(()=>k.kb.setDigest(e.id,{instructions:l?.trim()??``,...r?{backend:r}:{},schedule:s?{type:`cron`,cron:s}:{type:`manual`}}))&&(await i(),n())}let _=l!==null;return(0,X.jsx)(gn,{open:!0,onClose:n,title:t?`Digest settings`:`Set up a digest`,wide:!0,children:(0,X.jsxs)(`form`,{onSubmit:g,className:`min-w-0 space-y-4`,children:[!e.editable_by.includes(`mcp`)&&(0,X.jsx)(`p`,{className:`text-sm text-warning`,"data-testid":`kb-digest-mcp-hint`,children:`The digest writes through MCP. Allow Agents (MCP) in this knowledge base's settings first.`}),(0,X.jsx)(Mn,{value:p,onChange:m}),(0,X.jsx)(we,{value:d,onChange:f,testId:`kb-digest-backend`}),(0,X.jsx)($,{label:`Instructions`,children:_?(0,X.jsx)(D,{path:`digest.md`,value:l,onChange:u,testId:`kb-digest-instructions`,label:`Instructions`,initialMode:`edit`,height:320}):c.error?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:mn(c.error)}):(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`Loading template…`})}),(0,X.jsx)(hn,{error:a.error}),(0,X.jsxs)(R,{className:`gap-2 sm:justify-between`,children:[t&&r?(0,X.jsxs)(s,{type:`button`,variant:`ghost`,className:`text-error`,"data-testid":`kb-digest-remove`,onClick:r,children:[(0,X.jsx)(_e,{size:14}),`Remove digest`]}):(0,X.jsx)(`span`,{}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(s,{type:`button`,variant:`ghost`,onClick:n,children:`Cancel`}),(0,X.jsx)(s,{type:`submit`,"data-testid":`kb-digest-save`,disabled:!_||!l?.trim()||h!==null||a.pending,children:a.pending?`Saving…`:`Save`})]})]})]})})}function Pn({kb:e,onClose:t}){let n=r(),i=Q();async function a(){await i.run(()=>k.kb.removeDigest(e.id,e.name))!==void 0&&(n.setQueryData([yt,e.id],{digest:null}),await n.invalidateQueries({queryKey:[`kb`]}),t())}return(0,X.jsx)(gn,{open:!0,onClose:t,title:`Remove digest?`,children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`p`,{className:`text-sm text-outline`,children:`Documents and comments stay. The digest's instructions, schedule, job and run history are removed.`}),(0,X.jsx)(hn,{error:i.error}),(0,X.jsxs)(R,{children:[(0,X.jsx)(s,{type:`button`,variant:`ghost`,onClick:t,children:`Cancel`}),(0,X.jsx)(s,{type:`button`,variant:`destructive`,"data-testid":`kb-digest-remove-confirm`,onClick:a,disabled:i.pending,autoFocus:!0,children:i.pending?`Removing…`:`Remove digest`})]})]})})}var Fn=i(`inline-flex items-center rounded-full border border-border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-primary focus:ring-offset-2 `,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground hover:bg-primary/80 `,secondary:`border-transparent bg-muted text-foreground hover:bg-muted/80 `,destructive:`border-transparent bg-error text-primary-foreground hover:bg-error/80 `,outline:`text-foreground `}},defaultVariants:{variant:`default`}});function In({className:e,variant:t,...n}){return(0,X.jsx)(`div`,{className:o(Fn({variant:t}),e),...n})}var Ln={open:`bg-warning`,resolved:`bg-secondary`,dismissed:`bg-muted-foreground`};function Rn({status:e}){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:o(`size-1.5 shrink-0 rounded-full`,Ln[e])})}function zn({kbId:e,documentId:t,onOpenDocument:n,heading:r=`h3`,compact:i=!1}){let[a,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),u=_t(e,{...t?{document_id:t}:{},...c?{status:c}:{}}),d=u.data?.counts,f=d?d.open+d.resolved+d.dismissed:0;function p(e){l(a&&c===e?null:e),s(!0)}return(0,X.jsx)(Kt,{title:`Comments`,testId:`kb-comments`,toggleTestId:`kb-comments-toggle`,heading:r,compact:i,expanded:a,onExpandedChange:s,summary:(0,X.jsxs)(X.Fragment,{children:[d&&f===0&&(0,X.jsx)(`span`,{className:`text-outline`,"data-testid":`kb-comments-none`,children:`None yet`}),d&&Ut.filter(e=>d[e]>0).map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-comments-count-${e}`,"aria-pressed":a&&c===e,"aria-label":`${d[e]} ${e} ${d[e]===1?`comment`:`comments`}`,className:o(`inline-flex min-h-8 items-center gap-1.5 rounded px-1.5`,a&&c===e?`bg-surface-highest text-on-surface`:`text-outline hover:bg-surface-high`),onClick:()=>p(e),children:[(0,X.jsx)(Rn,{status:e}),(0,X.jsx)(`span`,{className:`tabular-nums text-on-surface`,children:d[e]}),e]},e)),u.error&&(0,X.jsx)(`span`,{role:`alert`,className:`text-error`,"data-testid":`kb-comments-error`,children:u.error.message})]}),children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(Bn,{kbId:e,documentId:t}),c&&u.data?.comments.length===0&&(0,X.jsxs)(`p`,{className:`text-outline`,"data-testid":`kb-comments-empty`,children:[`No `,c,` comments.`]}),(0,X.jsx)(`ul`,{className:`divide-y divide-outline-variant`,children:u.data?.comments.map(e=>(0,X.jsx)(Vn,{comment:e,showDocument:!t,onOpenDocument:n},e.id))})]})})}function Bn({kbId:e,documentId:t}){let n=q(),r=Q(),[i,a]=(0,J.useState)(``);async function o(o){o.preventDefault(),await r.run(()=>k.kb.addComment(e,{body:i.trim(),...t?{document_id:t}:{}}))&&(a(``),await n())}return(0,X.jsxs)(`form`,{onSubmit:o,className:`space-y-2`,children:[(0,X.jsx)(L,{"aria-label":t?`Comment on this document`:`Comment on this knowledge base`,placeholder:t?`Ask for a change to this document`:`Ask for a change`,"data-testid":`kb-comment-input`,value:i,onChange:e=>a(e.target.value),rows:2,maxLength:1e4}),i.trim()&&(0,X.jsx)(s,{type:`submit`,size:`sm`,variant:`outline`,"data-testid":`kb-comment-add`,disabled:r.pending,children:`Add comment`}),r.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-error`,"data-testid":`kb-comment-add-error`,children:r.error})]})}function Vn({comment:e,showDocument:t,onOpenDocument:n}){let r=q(),i=Q(),[a,o]=(0,J.useState)(null),[c,l]=(0,J.useState)(``);async function u(t){if(t.preventDefault(),!a)return;let n=a;await i.run(()=>k.kb.closeComment(e.id,{status:n,reply:c.trim()}))&&(o(null),l(``),await r())}async function d(){await i.run(()=>k.kb.reopenComment(e.id))&&await r()}return(0,X.jsxs)(`li`,{"data-testid":`kb-comment`,"data-status":e.status,className:`min-w-0 space-y-1 py-2`,children:[(0,X.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 text-xs text-outline`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-on-surface`,children:[(0,X.jsx)(Rn,{status:e.status}),(0,X.jsx)(`span`,{"data-testid":`kb-comment-status`,children:e.status})]}),(0,X.jsxs)(`span`,{className:`min-w-0 wrap-break-word`,children:[e.source===e.author?e.author:`${e.author} via ${e.source}`,` ·`,` `,new Date(e.created_at).toLocaleString(),t&&e.document_id&&(0,X.jsxs)(X.Fragment,{children:[` · on `,n?(0,X.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>e.document_id&&n(e.document_id),children:e.document_title??`a deleted document`}):e.document_title??`a deleted document`]})]})]}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap wrap-break-word`,children:e.body}),e.reply&&(0,X.jsxs)(`p`,{className:`wrap-break-word text-xs`,"data-testid":`kb-comment-reply-text`,children:[(0,X.jsxs)(`span`,{className:`text-outline`,children:[e.status===`dismissed`?`Dismissed`:`Resolved`,e.resolved_by?` by ${e.resolved_by}`:``,`:`]}),` `,e.reply]}),a?(0,X.jsxs)(`form`,{onSubmit:u,className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(K,{"aria-label":a===`resolved`?`Resolution reply`:`Reason for dismissing`,placeholder:a===`resolved`?`What changed`:`Why not`,"data-testid":`kb-comment-reply`,value:c,onChange:e=>l(e.target.value),maxLength:4e3,autoFocus:!0,className:`min-w-0 flex-1 basis-48`}),(0,X.jsx)(s,{type:`submit`,size:`sm`,"data-testid":`kb-comment-close-submit`,disabled:!c.trim()||i.pending,children:a===`resolved`?`Resolve`:`Dismiss`}),(0,X.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{o(null),l(``),i.setError(null)},children:`Cancel`})]}):e.status===`open`?(0,X.jsxs)(`div`,{className:`-ml-2 flex flex-wrap`,children:[(0,X.jsx)(s,{size:`sm`,variant:`ghost`,"data-testid":`kb-comment-resolve`,onClick:()=>o(`resolved`),children:`Resolve`}),(0,X.jsx)(s,{size:`sm`,variant:`ghost`,"data-testid":`kb-comment-dismiss`,onClick:()=>o(`dismissed`),children:`Dismiss`})]}):(0,X.jsx)(s,{size:`sm`,variant:`ghost`,className:`-ml-2`,"data-testid":`kb-comment-reopen`,onClick:d,disabled:i.pending,children:`Reopen`}),i.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-error`,"data-testid":`kb-comment-error`,children:i.error})]})}var Hn=e=>`kb:${e}`,Un={pending:`Processing`,partial:`Partially parsed`,failed:`Failed`,lexical_ready:`Keyword search ready`,semantic_pending:`Embedding`,semantic_ready:`Semantic search ready`};function Wn(e){let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]:not(:disabled)`)],n=t.indexOf(document.activeElement),r=e.key===`ArrowDown`?(n+1)%t.length:e.key===`ArrowUp`?(n-1+t.length)%t.length:e.key===`Home`?0:e.key===`End`?t.length-1:null;r!==null&&t.length&&(e.preventDefault(),t[r]?.focus())}function Gn({usage:e,testId:t}){return(0,X.jsxs)(`div`,{"data-testid":t,className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`text-sm`,children:[(0,X.jsx)(`span`,{"data-testid":`${t}-reads`,className:`font-medium`,children:e.reads}),` `,`reads · `,e.exposures,` search appearances · `,e.distinct_sessions,` sessions`]}),(0,X.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`text-outline`,children:[(0,X.jsx)(`th`,{className:`py-1 text-left font-normal`,children:`Source`}),Mt.map(e=>(0,X.jsx)(`th`,{className:`py-1 text-right font-normal`,children:e===`search_hit`?`listed`:e},e))]})}),(0,X.jsx)(`tbody`,{children:Y.map(n=>(0,X.jsxs)(`tr`,{"data-testid":`${t}-${n}`,className:`border-t border-outline-variant/50`,children:[(0,X.jsx)(`td`,{className:`py-1 uppercase`,children:n}),Mt.map(t=>(0,X.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:e.totals[n][t]},t))]},n))})]}),(0,X.jsxs)(`div`,{className:`text-xs text-outline`,children:[`Last 7 days `,e.window.days_7,` · last 30 days `,e.window.days_30]})]})}function Kn({kb:e,doc:t,onHome:n,onOpen:r,onDeleted:i,onReplaceFile:c,detailsOpen:l,onDetailsOpenChange:u}){let d=q(),[f]=j(),p=f.get(`editorMode`),m=_t(t.kb_id,{document_id:t.id}).data?.counts.open??0,[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(!1),x=Se(`lg`),[S,C]=(0,J.useState)(null),E=(0,J.useRef)(null),[D,O]=(0,J.useState)(null),[M,te]=(0,J.useState)(!1),N=(0,J.useRef)(null),P=(0,J.useRef)(t.revision),F=new Map(t.links.filter(e=>e.document_id).map(e=>[Ie(e.target),e.document_id])),I={slugs:[...F.keys()],select:e=>{let t=F.get(e);t&&r(t)}};async function L(e){te(!0),O(null);try{return await e(),await d(),!0}catch(e){return O(e instanceof Error?e.message:`Request failed`),!1}finally{te(!1)}}async function ie(){await L(async()=>Le(await k.kb.original(t.id),t.original_name??t.path.split(`/`).pop()??`document`))}function R(){let e=(t.path.split(`/`).pop()??`document`).replace(/\.(md|markdown)$/i,``);Le(new Blob([t.content],{type:`text/markdown;charset=utf-8`}),`${e}.md`)}let B=t.origin===`upload`,ae=B||t.origin===`external`&&!t.editable,V=S?.backlinks.filter(e=>!t.backlinks.some(t=>t.document_id===e.document_id))??[],H=(e,t,n,r,i=!1)=>(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":e,disabled:M,className:o(`flex min-h-9 w-full items-center gap-2 rounded px-2 text-left text-sm outline-hidden hover:bg-surface-highest focus-visible:bg-surface-highest disabled:opacity-50`,i&&`text-error`),onClick:()=>{b(!1),r()},children:[t,n]});return(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,X.jsx)(`article`,{"data-testid":`kb-document`,className:`min-w-0 lg:min-h-0 lg:flex-1 lg:overflow-y-auto`,children:(0,X.jsxs)(`div`,{className:`w-full min-w-0 px-4 pb-16 pt-4 sm:px-8 sm:pt-6`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,X.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 flex-1 basis-48 items-center gap-1 text-sm text-outline`,children:[(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-breadcrumb-kb`,className:`min-w-0 max-w-[60%] truncate hover:text-on-surface hover:underline`,onClick:n,children:e.name}),(0,X.jsx)(Te,{size:14,className:`shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,"data-testid":`kb-document-path`,title:t.path,children:t.path})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,X.jsxs)(s,{size:`sm`,variant:l?`secondary`:`ghost`,"aria-pressed":l,"data-testid":`kb-details-toggle`,onClick:()=>u(!l),children:[(0,X.jsx)(jt,{size:14}),`Details`,m>0&&(0,X.jsxs)(`span`,{"data-testid":`kb-details-open-comments`,title:`${m} open ${m===1?`comment`:`comments`}`,className:`inline-flex items-center gap-1 text-xs tabular-nums text-outline`,children:[(0,X.jsx)(Z,{tone:`warning`}),m]})]}),(0,X.jsxs)(Ne,{open:y,onOpenChange:b,children:[(0,X.jsx)(Me,{asChild:!0,children:(0,X.jsx)(s,{size:`icon`,variant:`ghost`,"aria-label":`Document actions`,"aria-haspopup":`menu`,"data-testid":`kb-doc-menu`,children:(0,X.jsx)(T,{size:16})})}),(0,X.jsx)(ee,{children:(0,X.jsxs)(z,{align:`end`,sideOffset:4,collisionPadding:8,role:`menu`,"aria-label":`Document actions`,className:`z-50 w-52 rounded-md border border-outline-variant bg-surface-high p-1 shadow-lg`,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus()},onKeyDown:Wn,children:[H(`kb-doc-properties`,(0,X.jsx)(ke,{size:14}),`Title and labels`,()=>{E.current={title:t.title,backlinks:t.backlinks},g(!0)}),!ae&&H(`kb-doc-download-markdown`,(0,X.jsx)(Ct,{size:14}),`Download Markdown`,R),ae&&H(`kb-doc-download`,(0,X.jsx)(w,{size:14}),`Download original`,()=>void ie()),B&&H(`kb-doc-reparse`,(0,X.jsx)(he,{size:14}),`Parse again`,()=>void L(()=>k.kb.reparse(t.id))),B&&H(`kb-doc-replace`,(0,X.jsx)(Dt,{size:14}),`Replace file`,()=>N.current?.click()),t.origin!==`external`&&H(`kb-doc-delete`,(0,X.jsx)(_e,{size:14}),`Delete document`,()=>v(!0),!0)]})})]})]})]}),(0,X.jsxs)(`header`,{className:`mb-2 mt-4 space-y-2`,children:[(0,X.jsx)(`h1`,{"data-testid":`kb-document-title`,className:`wrap-break-word text-3xl font-medium`,children:t.title}),t.description&&(0,X.jsx)(`p`,{className:`text-outline`,children:t.description}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-outline`,children:[t.labels.length>0&&(0,X.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:t.labels.map(e=>(0,X.jsx)(In,{variant:`secondary`,"data-testid":`kb-document-label`,children:e},e))}),t.parse_state!==`ok`&&(0,X.jsxs)(`span`,{className:o(`inline-flex items-center gap-1.5`,t.parse_state===`failed`&&`text-error`),children:[(0,X.jsx)(Z,{tone:t.parse_state===`failed`?`error`:t.parse_state===`partial`?`warning`:`progress`}),(0,X.jsx)(`span`,{"data-testid":`kb-parse-state`,children:Un[t.parse_state]})]}),t.folder_sync&&(0,X.jsx)(`span`,{"data-testid":`kb-folder-sync`,title:t.folder_sync===`following`?`Copied from a synced folder; scans pick up changes to the file`:`Edited in ORC; scans no longer change this copy`,children:t.folder_sync===`following`?`Follows folder file`:`Edited, no longer synced`}),t.stale&&(0,X.jsx)(`span`,{className:`text-warning`,"data-testid":`kb-document-stale`,children:`Stale: a source changed`}),(0,X.jsxs)(`span`,{children:[`Updated `,new Date(t.updated_at).toLocaleDateString(),` by `,t.updated_by]})]})]}),t.warnings.length>0&&(0,X.jsx)(`ul`,{"data-testid":`kb-document-warnings`,className:`mb-2 space-y-1 text-sm text-warning`,children:t.warnings.map(e=>(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsx)(A,{size:14,className:`mt-0.5 shrink-0`}),e]},e))}),B&&(0,X.jsxs)(`p`,{className:`mb-2 text-sm text-outline`,children:[`Text parsed from `,t.original_name??`the upload`,` (`,a(t.size_bytes),t.parser?`, ${t.parser.id} ${t.parser.version}`:``,`). Replace the file to change it.`]}),t.folder_sync===`following`&&(p===`edit`||p===`split`)&&(0,X.jsx)(`p`,{role:`status`,"data-testid":`kb-folder-sync-warning`,className:`mb-2 text-sm text-warning`,children:`This copy follows a file in a synced folder. Saving here stops it following that file; later changes to the file will not reach it.`}),D&&(0,X.jsx)(`p`,{role:`alert`,"data-testid":`kb-document-error`,className:`mb-2 text-sm text-error`,children:D}),S&&V.length>0&&(0,X.jsxs)(`div`,{role:`status`,"data-testid":`kb-rename-broken-links`,className:`mb-2 flex flex-wrap items-center gap-x-2 text-sm text-warning`,children:[(0,X.jsx)(A,{size:14,className:`shrink-0`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[V.length===1?`1 document`:`${V.length} documents`,` linked to “`,S.title,`” by its old title or path; those links now show as missing:`,` `,V.map((e,t)=>(0,X.jsxs)(`span`,{children:[t>0&&`, `,(0,X.jsx)(`button`,{type:`button`,className:`underline underline-offset-2 hover:text-on-surface`,onClick:()=>r(e.document_id),children:e.title})]},e.document_id))]}),(0,X.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>C(null),children:`Dismiss`})]}),(0,X.jsx)(at,{documentId:Hn(t.id),path:t.editable?t.path:`${t.path}.md`,content:t.content,wikiLinks:I,testId:`kb-document-content`,layout:`page`,pageTitle:t.title,hideFrontmatter:!0,onSave:t.editable?async(e,n)=>{try{let r=await k.kb.updateDocument(t.id,{expected_revision:n===t.content?t.revision:P.current,content:e});return P.current=r.revision,e}finally{await d()}}:void 0},Hn(t.id))]})}),l&&x&&(0,X.jsx)(Jn,{doc:t,onOpen:r}),!x&&(0,X.jsx)(se,{open:l,onOpenChange:u,children:(0,X.jsxs)(re,{defaultWidth:360,resizeKey:`kb-properties`,"aria-describedby":void 0,children:[(0,X.jsx)(de,{className:`py-3`,children:(0,X.jsx)(le,{children:`Details`})}),(0,X.jsx)(ne,{className:`p-0 sm:p-0`,children:(0,X.jsx)(Jn,{doc:t,onOpen:(e,t)=>{u(!1),r(e,t)}})})]})}),(0,X.jsx)(`input`,{ref:N,type:`file`,hidden:!0,"data-testid":`kb-doc-replace-input`,onChange:e=>{let t=e.target.files?.[0];t&&c(t),e.target.value=``}}),h&&(0,X.jsx)(En,{doc:t,linkedFrom:t.backlinks.length,onClose:()=>g(!1),onSaved:()=>{g(!1),C(E.current)}}),(0,X.jsx)(Re,{open:_,title:`Delete document`,description:`Delete "${t.title}" and its revision history${B?` and uploaded file`:``}?`,isPending:M,onCancel:()=>v(!1),onConfirm:async()=>{v(!1),await L(()=>k.kb.removeDocument(t.id))&&i()}})]})}function qn({title:e,children:t}){return(0,X.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-medium text-outline`,children:e}),t]})}function Jn({doc:e,onOpen:t}){let n=ct(e.id),r=ut(e.id),i=`block min-h-8 w-full wrap-break-word text-left text-primary hover:underline`;return(0,X.jsxs)(`aside`,{"data-testid":`kb-document-details`,"aria-label":`Document details`,className:`w-full shrink-0 space-y-6 p-4 text-sm lg:min-h-0 lg:w-80 lg:overflow-y-auto lg:border-l lg:border-outline-variant`,children:[e.outline.length>0&&(0,X.jsx)(qn,{title:`On this page`,children:(0,X.jsx)(`nav`,{"aria-label":`Outline`,className:`space-y-0.5`,children:e.outline.map(n=>(0,X.jsx)(`button`,{type:`button`,className:`block min-h-7 w-full truncate text-left text-outline hover:text-on-surface`,style:{paddingLeft:`${(n.level-1)*.75}rem`},onClick:()=>t(e.id,n.text),children:n.text},`${n.block}-${n.text}`))})}),e.links.length>0&&(0,X.jsx)(qn,{title:`Links to (${e.links.length})`,children:e.links.map(e=>e.document_id?(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-outgoing-link`,className:i,onClick:()=>t(e.document_id),children:e.title??e.target},e.target):(0,X.jsxs)(`p`,{className:`py-1 text-outline`,"data-testid":`kb-unresolved-link`,children:[e.target,` `,(0,X.jsx)(`span`,{className:`text-xs`,children:`(no such document)`})]},e.target))}),e.backlinks.length>0&&(0,X.jsx)(qn,{title:`Linked from (${e.backlinks.length})`,children:e.backlinks.map(e=>(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-backlink`,className:i,onClick:()=>t(e.document_id),children:e.title},e.document_id))}),(0,X.jsx)(`div`,{className:`border-y border-outline-variant`,children:(0,X.jsx)(zn,{kbId:e.kb_id,documentId:e.id,heading:`h2`,compact:!0})}),(0,X.jsxs)(`details`,{"data-testid":`kb-doc-history`,className:`group`,children:[(0,X.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center gap-1.5 font-medium [&::-webkit-details-marker]:hidden`,children:[(0,X.jsx)(Te,{size:14,"aria-hidden":!0,className:`text-outline transition-transform group-open:rotate-90`}),`Usage and history`]}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-5 pl-5`,children:[n.data?(0,X.jsx)(Gn,{usage:n.data,testId:`kb-doc-usage`}):(0,X.jsx)(`p`,{className:`text-outline`,children:n.error?`Usage unavailable`:`Loading…`}),(0,X.jsx)(`ol`,{className:`space-y-2`,"data-testid":`kb-revisions`,children:r.data?.map(e=>(0,X.jsxs)(`li`,{"data-testid":`kb-revision`,children:[(0,X.jsxs)(`div`,{children:[`Revision `,e.revision,` · `,e.actor,(0,X.jsxs)(`span`,{className:`text-outline`,children:[` via `,e.source]})]}),(0,X.jsxs)(`div`,{className:`text-xs text-outline`,children:[new Date(e.created_at).toLocaleString(),e.note?` · ${e.note}`:``]})]},e.revision))}),(0,X.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs text-outline`,children:[(0,X.jsx)(`dt`,{children:`Search`}),(0,X.jsx)(`dd`,{"data-testid":`kb-index-state`,children:Un[e.index_state]??e.index_state}),(0,X.jsx)(`dt`,{children:`Origin`}),(0,X.jsx)(`dd`,{children:e.origin}),(0,X.jsx)(`dt`,{children:`Type`}),(0,X.jsx)(`dd`,{children:e.media_type}),(0,X.jsx)(`dt`,{children:`Size`}),(0,X.jsx)(`dd`,{children:a(e.size_bytes)}),(0,X.jsx)(`dt`,{children:`Updated`}),(0,X.jsxs)(`dd`,{children:[new Date(e.updated_at).toLocaleString(),` by `,e.updated_by]}),(0,X.jsx)(`dt`,{children:`ID`}),(0,X.jsx)(`dd`,{className:`break-all font-mono`,children:e.id})]})]})]})]})}function Yn(e){return`${e.added} added · ${e.updated} updated · ${e.missing} missing${e.errors.length?` · ${e.errors.length} errors: ${e.errors.slice(0,3).join(`; `)}`:``}`}var Xn=(e,t,n)=>`${e} ${e===1?t:n}`;function Zn(){return/win/i.test(navigator.platform)?`Choose a folder or type its full path, e.g. C:\\notes`:/mac/i.test(navigator.platform)?`Choose a folder or type its full path, e.g. /Users/you/notes`:`Choose a folder or type its full path, e.g. /home/you/notes`}function Qn(e){let t=e.document_count-e.edited_count,n=t?`${Xn(t,`synced copy is`,`synced copies are`)} removed from this knowledge base`:`No synced copies are removed`,r=e.edited_count?`; ${Xn(e.edited_count,`edited copy is`,`edited copies are`)} kept as documents`:``;return`Stop syncing ${e.root_path}? ${n}${r}. Files on disk are not touched.`}function $n(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e}function er({kb:e}){let t=ft(e.id),n=q(),r=Q(),[i,a]=(0,J.useState)(!1),[o,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(`**/*.md`),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(!1),y=t.data??[],b=y.filter(e=>e.last_error).length,x=y.reduce((e,t)=>e+t.document_count,0);function S(){a(!0),g(!0)}function C(){g(!1),c(``),r.setError(null),y.length===0&&a(!1)}async function w(){v(!0),r.setError(null);try{let{path:e}=await k.terminals.pickFolder(o.trim()||void 0);e&&c(e)}catch(e){r.setError(e instanceof Error?e.message:String(e))}finally{v(!1)}}async function T(t){t.preventDefault();let i=await r.run(()=>k.kb.addSource(e.id,{root_path:o.trim(),pattern:l.trim()||`**/*.md`}));i&&(c(``),g(!1),f(Yn(i.scan)),await n())}return(0,X.jsxs)(Kt,{title:`Synced folders`,testId:`kb-folders`,toggleTestId:`kb-sources`,expanded:i,onExpandedChange:e=>{a(e),g(e&&y.length===0)},summary:t.isLoading?(0,X.jsx)(`span`,{className:`text-outline`,children:`Loading…`}):y.length===0?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-outline`,"data-testid":`kb-folders-none`,children:[(0,X.jsx)(Z,{tone:`off`}),`None`]}):(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5`,"data-testid":`kb-folders-summary`,children:[(0,X.jsx)(Z,{tone:b?`error`:`ok`}),y.length===1?(0,X.jsx)(`span`,{className:`min-w-0 truncate`,title:y[0]?.root_path,children:$n(y[0]?.root_path??``)}):`${y.length} folders`,(0,X.jsxs)(`span`,{className:`shrink-0 text-outline`,children:[`· `,x,` `,x===1?`document`:`documents`,b?` · ${b} failing`:``]})]}),actions:y.length===0&&!i?(0,X.jsx)(s,{size:`sm`,variant:`outline`,"data-testid":`kb-folders-add`,onClick:S,children:`Add folder`}):null,children:[(0,X.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,X.jsx)(`p`,{className:`max-w-prose text-outline`,children:`Matching files are copied in and kept in sync: ORC rescans every minute while the daemon runs, or when you choose Scan now. A copy you edit here stops following its file. ORC never writes to the folder.`}),y.length>0&&(0,X.jsx)(`ul`,{className:`divide-y divide-outline-variant`,"data-testid":`kb-sources-list`,children:y.map(e=>(0,X.jsxs)(`li`,{"data-testid":`kb-source-row`,className:`flex min-w-0 flex-wrap items-center gap-2 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,X.jsx)(`div`,{className:`font-medium`,children:$n(e.root_path)}),(0,X.jsx)(`div`,{className:`break-all font-mono text-xs text-outline`,children:e.root_path}),(0,X.jsxs)(`div`,{className:`text-xs text-outline`,children:[e.pattern,` · `,Xn(e.document_count,`document`,`documents`),e.edited_count?` (${e.edited_count} edited)`:``,` ·`,` `,e.last_scan_at?(0,X.jsxs)(`span`,{title:new Date(e.last_scan_at).toLocaleString(),children:[`scanned `,rn(e.last_scan_at)]}):`not scanned yet`]}),e.last_error&&(0,X.jsx)(`div`,{className:`text-xs text-error`,children:e.last_error})]}),(0,X.jsxs)(s,{variant:`ghost`,size:`sm`,"data-testid":`kb-source-scan`,disabled:r.pending,onClick:async()=>{let t=await r.run(()=>k.kb.scanSource(e.id));t&&f(Yn(t)),await n()},children:[(0,X.jsx)(kt,{size:14}),`Scan now`]}),(0,X.jsx)(s,{variant:`ghost`,size:`sm`,title:`Stop syncing ${e.root_path}`,"data-testid":`kb-source-remove`,onClick:()=>m(e),children:`Stop syncing`})]},e.id))}),d&&(0,X.jsx)(`p`,{role:`status`,"data-testid":`kb-source-result`,className:`text-outline`,children:d}),h?(0,X.jsxs)(`form`,{onSubmit:T,className:`min-w-0 space-y-3`,"data-testid":`kb-source-form`,children:[(0,X.jsxs)(`div`,{className:`grid min-w-0 gap-3 sm:grid-cols-[minmax(0,1fr)_12rem]`,children:[(0,X.jsx)($,{label:`Folder path`,hint:Zn(),children:(0,X.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,X.jsx)(K,{"aria-label":`Folder path`,"data-testid":`kb-source-path-input`,value:o,onChange:e=>c(e.target.value),className:`min-w-0 font-mono text-sm`,autoFocus:!0}),(0,X.jsxs)(s,{type:`button`,variant:`outline`,"data-testid":`kb-source-choose-folder`,onClick:w,disabled:_,className:`shrink-0`,children:[(0,X.jsx)(E,{size:14}),_?`Choosing…`:`Choose folder`]})]})}),(0,X.jsx)($,{label:`File pattern`,hint:`e.g. *.md, **/*.md`,children:(0,X.jsx)(K,{"aria-label":`File pattern`,"data-testid":`kb-source-pattern-input`,value:l,onChange:e=>u(e.target.value),className:`font-mono text-sm`})})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(s,{type:`submit`,size:`sm`,variant:`outline`,"data-testid":`kb-source-add`,disabled:!o.trim()||r.pending,children:`Add folder`}),(0,X.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`kb-source-cancel`,onClick:C,children:`Cancel`})]})]}):y.length>0&&(0,X.jsxs)(s,{size:`sm`,variant:`ghost`,className:`-ml-2`,"data-testid":`kb-folders-add-another`,onClick:()=>g(!0),children:[(0,X.jsx)(De,{size:14}),`Add another folder`]}),(0,X.jsx)(hn,{error:r.error})]}),(0,X.jsx)(Re,{open:p!==null,title:`Stop syncing folder`,description:p?Qn(p):``,confirmLabel:`Stop syncing`,variant:`warning`,isPending:r.pending,onCancel:()=>m(null),onConfirm:async()=>{let e=p;m(null),e&&await r.run(()=>k.kb.removeSource(e.id)),await n()}})]})}var tr=8;function nr(e,t,n){return n===`title`?e.title.localeCompare(t.title):n===`updated`?e.updated_at-t.updated_at:e.reads-t.reads}function rr(e,t){if(e.key===t)return e.desc?`descending`:`ascending`}function ir(e){let t=new Date(e);return t.toDateString()===new Date().toDateString()?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):t.toLocaleDateString([],{month:`short`,day:`numeric`,year:`numeric`})}function ar({kb:e,owner:t,listing:n,label:r,onLabel:i,onOpen:a,onNewDocument:o,onSettings:c}){let l=e.editable_by.includes(`mcp`);return(0,X.jsxs)(`div`,{"data-testid":`kb-overview`,className:`w-full min-w-0 space-y-8 p-4 sm:p-8`,children:[(0,X.jsxs)(`header`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`h2`,{className:`wrap-break-word text-2xl font-medium`,"data-testid":`kb-overview-name`,children:e.name}),e.description&&(0,X.jsx)(`p`,{className:`max-w-prose text-outline`,children:e.description}),(0,X.jsxs)(`p`,{className:`text-sm text-outline`,"data-testid":`kb-overview-meta`,children:[t,` · `,e.document_count,` `,e.document_count===1?`document`:`documents`,` ·`,` `,l?`agents can edit`:`agents read only`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(s,{size:`sm`,"data-testid":`kb-new-document`,onClick:o,children:[(0,X.jsx)(Tt,{size:16}),`New document`]}),(0,X.jsxs)(s,{size:`sm`,variant:`ghost`,"data-testid":`kb-settings`,onClick:c,children:[(0,X.jsx)(Ee,{size:16}),`Settings`]})]})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`kb-setup-heading`,className:`space-y-1`,children:[(0,X.jsx)(`h3`,{id:`kb-setup-heading`,className:`text-sm font-medium text-outline`,children:`Setup`}),(0,X.jsxs)(`div`,{className:`divide-y divide-outline-variant border-y border-outline-variant`,children:[(0,X.jsx)(on,{kb:e}),(0,X.jsx)(er,{kb:e}),(0,X.jsx)(or,{kb:e,onSettings:c}),(0,X.jsx)(sr,{kb:e,onSettings:c}),(0,X.jsx)(zn,{kbId:e.id,onOpenDocument:a})]})]}),(0,X.jsx)(lr,{kbId:e.id,onOpen:a}),(0,X.jsx)(cr,{listing:n,total:e.document_count,label:r,onLabel:i,onOpen:a,onNewDocument:o})]})}function or({kb:e,onSettings:t}){let n=e.editable_by.includes(`mcp`);return(0,X.jsx)(Kt,{title:`Who can edit`,testId:`kb-access`,summary:(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-wrap items-center gap-x-1.5`,children:[(0,X.jsx)(Z,{tone:n?`ok`:`off`}),n?`Agents can edit`:`Agents read only`,(0,X.jsxs)(`span`,{className:`text-outline`,children:[`·`,` `,e.editable_by.length?e.editable_by.map(e=>vn[e]).join(`, `):`nobody, read only everywhere`]})]}),actions:(0,X.jsx)(s,{size:`sm`,variant:`ghost`,"data-testid":`kb-access-change`,onClick:t,children:`Change`})})}function sr({kb:e,onSettings:t}){let n=lt(),r=e.parser?n.data?.parsers.find(t=>t.id===e.parser)?.label??e.parser:`Workspace default parser`;return(0,X.jsx)(Kt,{title:`Uploads`,testId:`kb-uploads-setup`,summary:(0,X.jsxs)(`span`,{className:`text-outline`,"data-testid":`kb-uploads-parser`,children:[r,` · `,`PDF, Word, PowerPoint, Excel, HTML, Markdown and text become Markdown`]}),actions:(0,X.jsx)(s,{size:`sm`,variant:`ghost`,"data-testid":`kb-parser-change`,onClick:t,children:`Change`})})}function cr({listing:e,total:t,label:n,onLabel:r,onOpen:i,onNewDocument:a}){let[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)({key:`updated`,desc:!0}),m=c.trim().toLowerCase(),h=(e?.documents??[]).filter(e=>(!n||e.labels.includes(n))&&(!m||e.title.toLowerCase().includes(m)||e.path.toLowerCase().includes(m)||e.labels.some(e=>e.toLowerCase().includes(m)))).sort((e,t)=>nr(e,t,f.key)*(f.desc?-1:1));function g(e){p(t=>t.key===e?{key:e,desc:!t.desc}:{key:e,desc:e!==`title`})}function _(e,t){let n=f.desc?ge:Pe;return(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-sort-${e}`,className:`inline-flex min-h-8 items-center gap-1 hover:text-on-surface`,onClick:()=>g(e),children:[t,f.key===e&&(0,X.jsx)(n,{size:12,"aria-hidden":!0})]})}let v=[...e?.labels??[]].sort((e,t)=>t.count-e.count),y=u?v:v.filter((e,t)=>t<tr||e.label===n),b=v.length-y.length;return(0,X.jsxs)(`section`,{"aria-labelledby":`kb-documents-heading`,"data-testid":`kb-documents`,className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsxs)(`h3`,{id:`kb-documents-heading`,className:`mr-auto text-sm font-medium text-outline`,children:[`Documents`,n?` labelled ${n}`:``]}),t>0&&(0,X.jsx)(K,{"aria-label":`Filter documents`,"data-testid":`kb-documents-filter`,placeholder:`Filter by title, path or label`,value:c,onChange:e=>l(e.target.value),className:`h-9 w-full sm:w-64`})]}),y.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`kb-labels`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-xs text-outline`,children:`Label`}),y.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-label-filter`,"aria-pressed":n===e.label,className:o(`min-h-8 rounded-full border px-2.5 text-xs`,n===e.label?`border-primary bg-primary/10 text-primary`:`border-outline-variant text-outline hover:text-on-surface`),onClick:()=>r(n===e.label?null:e.label),children:[e.label,` `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.count})]},e.label)),(b>0||u)&&v.length>tr&&(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-labels-more`,className:`min-h-8 px-2 text-xs text-primary hover:underline`,onClick:()=>d(!u),children:u?`Fewer labels`:`${b} more`})]}),t===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-dashed border-outline-variant px-6 py-10 text-center text-sm text-outline`,children:[(0,X.jsx)(O,{size:22,className:`text-primary`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:`This knowledge base is empty. Drop PDF, Word, PowerPoint, Excel, HTML, Markdown or text files here, or`}),(0,X.jsx)(s,{size:`sm`,variant:`outline`,onClick:a,"data-testid":`kb-overview-new-document`,children:`add a document`})]}):(0,X.jsxs)(X.Fragment,{children:[h.length===0&&e&&(0,X.jsxs)(`p`,{className:`py-4 text-sm text-outline`,"data-testid":`kb-documents-empty`,children:[`No documents match.`,` `,(0,X.jsx)(`button`,{type:`button`,"data-testid":`kb-documents-clear`,className:`text-primary hover:underline`,onClick:()=>{l(``),r(null)},children:`Clear filters`})]}),h.length>0&&(0,X.jsxs)(`table`,{className:`w-full table-fixed text-sm`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-outline-variant text-left text-xs text-outline`,children:[(0,X.jsx)(`th`,{className:`py-1 pr-3 font-normal`,"aria-sort":rr(f,`title`),children:_(`title`,`Title`)}),(0,X.jsx)(`th`,{className:`hidden w-[30%] py-2 pr-3 font-normal md:table-cell`,children:`Labels`}),(0,X.jsx)(`th`,{className:`w-24 py-1 pr-3 font-normal sm:w-28`,"aria-sort":rr(f,`updated`),children:_(`updated`,`Updated`)}),(0,X.jsx)(`th`,{className:`hidden w-16 py-1 text-right font-normal sm:table-cell`,"aria-sort":rr(f,`reads`),children:_(`reads`,`Reads`)})]})}),(0,X.jsx)(`tbody`,{children:h.map(e=>(0,X.jsxs)(`tr`,{className:`cursor-pointer border-b border-outline-variant/60 align-top hover:bg-surface-high`,onClick:()=>i(e.id),children:[(0,X.jsxs)(`td`,{className:`min-w-0 py-2 pr-3`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-document-row`,"data-document-title":e.title,className:`flex w-full min-w-0 items-center gap-1.5 text-left font-medium hover:text-primary`,onClick:t=>{t.stopPropagation(),i(e.id)},children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),e.origin===`external`&&(0,X.jsx)(kt,{size:13,className:`shrink-0 text-outline`,"aria-label":`From a synced folder`})]}),(0,X.jsx)(`span`,{className:`block truncate font-mono text-xs text-outline`,children:e.path}),(e.parse_state===`pending`||e.parse_state===`failed`)&&(0,X.jsx)(`span`,{className:o(`text-xs`,e.parse_state===`failed`?`text-error`:`text-outline`),children:e.parse_state===`failed`?`Parsing failed`:`Parsing…`})]}),(0,X.jsx)(`td`,{className:`hidden py-2 pr-3 text-xs text-outline md:table-cell`,children:(0,X.jsx)(`span`,{className:`line-clamp-2`,children:e.labels.join(`, `)})}),(0,X.jsx)(`td`,{className:`py-2 pr-3 text-xs text-outline tabular-nums`,children:ir(e.updated_at)}),(0,X.jsx)(`td`,{className:`hidden py-2 text-right text-xs text-outline tabular-nums sm:table-cell`,children:e.reads||``})]},e.id))})]}),(0,X.jsx)(`p`,{className:`text-xs text-outline`,children:`Drop files anywhere on this page to upload.`})]})]})}function lr({kbId:e,onOpen:t}){let n=bt(e).data;return!n||!(n.stale.length||n.failed.length||n.unresolved_links.length)?null:(0,X.jsxs)(`section`,{"data-testid":`kb-maintenance`,className:`space-y-1 text-sm`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-outline`,children:`Needs attention`}),(0,X.jsxs)(`ul`,{className:`space-y-1`,children:[n.failed.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`text-left text-error hover:underline`,onClick:()=>t(e.id),children:[`Parsing failed: `,e.title]})},e.id)),n.stale.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`text-left text-warning hover:underline`,onClick:()=>t(e.id),children:[`Stale summary: `,e.title]})},e.id)),n.unresolved_links.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`text-left text-outline hover:underline`,onClick:()=>t(e.document_id),children:[`[[`,e.target,`]] in `,e.title,` has no target`]})},`${e.document_id}-${e.target}`))]})]})}function ur(){let e=q(),[t,n]=(0,J.useState)([]),r=(0,J.useRef)(1),i=(e,t)=>n(n=>n.map(n=>n.id===e?{...n,...t}:n));async function a(t){i(t.id,{status:`uploading`,progress:0,error:void 0});try{let n=await k.kb.upload(t.kbId,{file:t.file,...t.replace},e=>i(t.id,{progress:e}));i(t.id,{status:`done`,progress:1,document:n}),await e()}catch(e){i(t.id,{status:`failed`,error:e instanceof Error?e.message:`Upload failed`})}}function o(e,t,i={}){let o=t.map(t=>({id:r.current++,kbId:e,file:t,...i.replace?{replace:i.replace}:{},progress:0,status:`uploading`}));n(e=>[...e,...o]);for(let e of o)a(e)}return{uploads:t,add:o,retry:e=>{let n=t.find(t=>t.id===e);n&&a(n)},clearFinished:()=>n(e=>e.filter(e=>e.status===`uploading`))}}var dr=`all`,fr=200,pr=[{value:`reads`,label:`Most read`},{value:`recent`,label:`Recent`},{value:`priority`,label:`Priority`}];function mr(e){return new Date(e*1e3).toLocaleString()}function hr({projectId:e}){let t=ie(),n=te(),{memoryProject:r,memoryName:i}=be(),[a,o]=Ve(`project`,e),[c,l]=Ve(`memoryQuery`,``),[u,d]=Ve(`memorySort`,`reads`,pr.map(e=>e.value)),[f,p]=(0,J.useState)(c);(0,J.useEffect)(()=>p(c),[c]);let[m,h]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),{data:C}=me({status:`active`}),w=$e(),T=a===`unassigned`,E=a===dr,D=tt({project_id:E?void 0:a,q:c||void 0,sort:u,limit:fr},{enabled:!T}),O=D.data?.memories??[],k=e=>C?.find(t=>t.id===e)?.name??e,A=O.find(e=>e.project_id===r&&e.name===i),j=e=>t(`${B(e.project_id,e.name)}${n.search}`),M=()=>t(`${je}${n.search}`);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(Be,{title:`Memories`,meta:D.data?`${D.data.total} ${D.data.total===1?`memory`:`memories`}`:void 0,action:(0,X.jsxs)(s,{"data-testid":`new-memory-button`,size:`sm`,onClick:()=>h(`new`),className:`font-label text-sm`,children:[(0,X.jsx)(De,{size:12,className:`mr-1`}),` New memory`]})}),(0,X.jsx)(`p`,{className:`mb-4 text-sm leading-relaxed text-muted-foreground`,children:`Short project facts agents load next session: ports, conventions, gotchas, decisions. Longer procedures belong in a skill.`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,X.jsxs)(b,{value:a,onValueChange:e=>o(e),children:[(0,X.jsx)(_,{"aria-label":`Project`,"data-testid":`memory-project-filter`,className:`h-9 w-48 bg-background text-on-surface font-body text-sm`,children:(0,X.jsx)(g,{})}),(0,X.jsxs)(v,{className:`bg-surface border-outline-variant`,children:[(0,X.jsx)(y,{value:dr,className:`font-body text-sm`,children:`All projects`}),T&&(0,X.jsx)(y,{value:`unassigned`,className:`font-body text-sm`,children:`Unassigned`}),C?.map(e=>(0,X.jsx)(y,{value:e.id,"data-testid":`memory-project-option-${e.id}`,className:`font-body text-sm`,children:e.name},e.id))]})]}),(0,X.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:pr.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(e.value),"data-testid":`memory-sort-${e.value}`,"aria-pressed":u===e.value,className:`font-label text-sm px-3 py-1.5 border transition-colors ${u===e.value?`bg-surface-highest text-on-surface border-transparent`:`bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface`}`,children:e.label},e.value))}),(0,X.jsxs)(`div`,{className:`relative min-w-[160px] flex-1`,children:[(0,X.jsx)(ye,{size:12,className:`absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground`}),(0,X.jsx)(K,{"aria-label":`Search memories`,"data-testid":`memory-search-input`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>e.key===`Enter`&&l(e.currentTarget.value),placeholder:`Search memories...`,className:`pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground`})]}),(0,X.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>l(f),className:`font-label text-sm`,children:`Search`})]}),T?(0,X.jsx)(He,{message:`Memories belong to a project. Choose a project to see its memories.`}):D.error?(0,X.jsx)(ze,{message:D.error.message,onRetry:()=>void D.refetch()}):D.isLoading?(0,X.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,X.jsx)(H,{className:`h-10 w-full bg-surface-highest`},t))}):O.length===0?(0,X.jsx)(He,{message:c?`No memories match your search`:`No memories yet`}):(0,X.jsx)(`div`,{className:`overflow-hidden`,children:(0,X.jsxs)(Je,{children:[(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ke,{className:`border-b border-outline-variant hover:bg-transparent`,children:[(0,X.jsx)(We,{className:`font-label text-sm text-muted-foreground`,children:`Name`}),(0,X.jsx)(We,{className:`font-label text-sm text-muted-foreground`,children:`Description`}),E&&(0,X.jsx)(We,{className:`font-label text-sm text-muted-foreground`,children:`Project`}),(0,X.jsx)(We,{className:`font-label text-sm text-muted-foreground w-20`,children:`Priority`}),(0,X.jsx)(We,{className:`font-label text-sm text-muted-foreground w-16`,children:`Reads`}),(0,X.jsx)(We,{className:`font-label text-sm text-muted-foreground w-44`,children:`Updated`})]})}),(0,X.jsx)(Ge,{children:O.map(e=>(0,X.jsxs)(Ke,{"data-testid":`memory-row`,"data-memory-name":e.name,"data-memory-project":e.project_id,className:`border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer`,onClick:()=>j(e),children:[(0,X.jsx)(qe,{className:`font-body text-sm font-medium text-on-surface`,children:(0,X.jsx)(`button`,{type:`button`,className:`min-h-11 text-left hover:text-primary`,onClick:t=>{t.stopPropagation(),j(e)},children:e.name})}),(0,X.jsx)(qe,{className:`font-body text-sm text-muted-foreground max-w-md truncate`,children:e.description}),E&&(0,X.jsx)(qe,{className:`font-body text-sm text-muted-foreground`,children:k(e.project_id)}),(0,X.jsx)(qe,{children:(0,X.jsx)(_r,{priority:e.priority})}),(0,X.jsx)(qe,{"data-testid":`memory-read-count`,className:`font-label text-sm text-muted-foreground`,title:gr(e),children:e.read_count}),(0,X.jsx)(qe,{className:`font-label text-sm text-muted-foreground`,children:mr(e.updated_at)})]},e.key))})]})}),r&&i&&(0,X.jsx)(vr,{projectId:r,name:i,projectName:k(r),listItem:A,onClose:M,onEdit:h,onDelete:S},`${r}/${i}`),m&&(0,X.jsx)(Cr,{memory:m===`new`?null:m,defaultProjectId:E||T?``:a,onClose:()=>h(null),onCreated:e=>j(e)}),x&&(0,X.jsx)(Re,{open:!0,title:`Delete memory`,description:`Delete "${x.name}"? It can be restored from its history.`,confirmLabel:`Delete`,variant:`destructive`,isPending:w.isPending,onConfirm:()=>w.mutate({projectId:x.project_id,name:x.name},{onSuccess:()=>{S(null),M()}}),onCancel:()=>S(null)}),w.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive mt-2`,children:w.error.message})]})}function gr(e){let{mcp:t,cli:n,api:r,ui:i}=e.reads_by_source;return`mcp ${t} · cli ${n} · api ${r} · ui ${i}${e.last_read_at?` · last read ${mr(e.last_read_at)}`:``}`}function _r({priority:e}){return e===null?(0,X.jsx)(`span`,{"data-testid":`memory-priority`,className:`font-label text-xs text-outline`,children:`Unscored`}):(0,X.jsxs)(`span`,{"data-testid":`memory-priority`,className:`font-label text-xs text-primary`,children:[`P`,e]})}function vr({projectId:e,name:t,projectName:n,listItem:r,onClose:i,onEdit:a,onDelete:o}){let{data:c,isLoading:l,error:u,refetch:d}=Qe(e,t);return(0,X.jsx)(se,{open:!0,onOpenChange:e=>!e&&i(),children:(0,X.jsxs)(re,{"data-testid":`memory-detail`,defaultWidth:860,resizeKey:`memories`,children:[(0,X.jsxs)(de,{children:[(0,X.jsx)(le,{children:t}),c&&(0,X.jsx)(`p`,{"data-testid":`memory-detail-description`,className:`font-body text-sm text-muted-foreground mt-1`,children:c.description})]}),(0,X.jsx)(ne,{children:u?(0,X.jsx)(ze,{message:u.message,onRetry:()=>void d()}):l||!c?(0,X.jsx)(`div`,{className:`space-y-3`,children:[...[,,,,]].map((e,t)=>(0,X.jsx)(H,{className:`h-8 w-full bg-surface-highest`},t))}):(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(s,{"data-testid":`memory-edit`,size:`sm`,variant:`outline`,onClick:()=>a(c),children:[(0,X.jsx)(ke,{size:12,className:`mr-1`}),` Edit`]}),(0,X.jsxs)(s,{"data-testid":`memory-delete`,size:`sm`,variant:`outline`,onClick:()=>o(c),children:[(0,X.jsx)(_e,{size:12,className:`mr-1`}),` Delete`]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,X.jsx)(Ae,{label:`Project`,children:n}),(0,X.jsx)(Ae,{label:`Priority`,children:(0,X.jsx)(_r,{priority:c.priority})}),(0,X.jsx)(Ae,{label:`Reads`,children:r?(0,X.jsx)(`span`,{title:gr(r),children:r.read_count}):`—`}),(0,X.jsx)(Ae,{label:`Author`,children:(0,X.jsx)(`span`,{"data-testid":`memory-detail-author`,children:c.author})}),(0,X.jsx)(Ae,{label:`Session`,children:(0,X.jsx)(`code`,{className:`font-mono text-xs break-all`,children:c.session_id??`—`})}),(0,X.jsx)(Ae,{label:`Updated`,children:mr(c.updated_at)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-label text-sm text-muted-foreground mb-2`,children:`Content`}),(0,X.jsx)(`div`,{"data-testid":`memory-detail-content`,className:`whitespace-pre-wrap wrap-break-word font-body text-sm text-on-surface border border-outline-variant p-3`,children:c.content})]}),(0,X.jsx)(br,{projectId:e,name:t,onDeleted:i})]})})]})})}function yr({label:e,snapshot:t}){return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-xs text-outline mt-2`,children:e}),t?(0,X.jsxs)(`div`,{className:`text-xs space-y-1`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`text-outline`,children:`Priority:`}),` `,t.priority===null?`unscored`:t.priority]}),(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`span`,{className:`text-outline`,children:`Description:`}),` `,t.description]}),(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:t.content})]}):(0,X.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:`(none)`})]})}function br({projectId:e,name:t,onDeleted:n}){let r=Xe(e,t),i=nt(),[a,o]=(0,J.useState)(``),c=r.data?.changes??[],l=c[0];return(0,X.jsxs)(`section`,{"data-testid":`memory-history-panel`,className:`space-y-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:`History`}),r.error&&(0,X.jsx)(`p`,{role:`alert`,children:r.error.message}),i.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:i.error.message}),c.length>1&&(0,X.jsx)(K,{"data-testid":`memory-revert-reason`,"aria-label":`Reason for reverting`,value:a,onChange:e=>o(e.target.value),placeholder:`Reason for reverting...`}),c.map(r=>(0,X.jsxs)(`details`,{"data-testid":`memory-history-change`,className:`border-b border-outline-variant p-3`,children:[(0,X.jsxs)(`summary`,{className:`text-xs cursor-pointer`,children:[r.action.replace(`memory.`,``),` · `,mr(r.created_at),` ·`,` `,r.author,r.session_id?` · ${r.session_id}`:``,r.reason?` · ${r.reason}`:``]}),(0,X.jsx)(yr,{label:`Before`,snapshot:r.previous}),(0,X.jsx)(yr,{label:`After`,snapshot:r.current}),l&&r.previous&&(0,X.jsx)(s,{"data-testid":`memory-revert-change`,size:`sm`,variant:`outline`,className:`mt-2`,disabled:!a.trim()||i.isPending,onClick:()=>i.mutate({name:t,project_id:e,change_id:r.id,expected_change_id:l.id,reason:a.trim()},{onSuccess:({memory:e})=>{o(``),e||n()}}),children:`Restore state before this change`})]},r.id))]})}function xr(e){return[...e].length}function Sr({value:e,max:t,testId:n}){let r=xr(e);return(0,X.jsx)(`span`,{"data-testid":n,className:`text-xs ${t!==void 0&&r>t?`text-destructive`:`text-muted-foreground`}`,children:t===void 0?r:`${r}/${t}`})}function Cr({memory:e,defaultProjectId:t,onClose:n,onCreated:r}){let{data:i}=me({status:`active`}),[a,o]=(0,J.useState)(e?.project_id??t),[c,l]=(0,J.useState)(e?.name??``),[u,d]=(0,J.useState)(e?.description??``),[f,p]=(0,J.useState)(e?.content??``),[m,h]=(0,J.useState)(e?.priority===null||e?.priority===void 0?``:String(e.priority)),[S,C]=(0,J.useState)(``),w=rt(),T=Ze(),E=et().data?.content_max,D=e?T:w,O=m.trim()===``?null:Number(m),k=O===null||Number.isInteger(O)&&O>=0&&O<=100,A=!!a&&!!c.trim()&&!!u.trim()&&xr(u)<=300&&!!f.trim()&&(E===void 0||xr(f)<=E)&&k;function j(){if(!A||D.isPending)return;if(!e){w.mutate({project_id:a,name:c.trim(),description:u.trim(),content:f.trim(),priority:O},{onSuccess:e=>{n(),r(e)}});return}let t={...u.trim()!==e.description&&{description:u.trim()},...f.trim()!==e.content&&{content:f.trim()},...O!==e.priority&&{priority:O}};Object.keys(t).length===0?n():T.mutate({name:e.name,project_id:e.project_id,...t,...S.trim()&&{reason:S.trim()}},{onSuccess:n})}return(0,X.jsx)(V,{open:!0,onOpenChange:e=>!e&&!D.isPending&&n(),children:(0,X.jsxs)(N,{"data-testid":`memory-form-dialog`,className:`bg-surface border-outline-variant w-[calc(100%-1rem)] max-w-2xl max-h-[94dvh] overflow-y-auto`,children:[(0,X.jsx)(xe,{children:(0,X.jsx)(M,{className:`font-headline text-base text-on-surface`,children:e?`Edit ${e.name}`:`New memory`})}),(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),j()},className:`space-y-3 mt-2`,children:[!e&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(x,{className:`font-label text-sm text-muted-foreground`,children:`Project *`}),(0,X.jsxs)(b,{value:a,onValueChange:o,children:[(0,X.jsx)(_,{"aria-label":`Memory project`,"data-testid":`memory-project-select`,className:`bg-background text-on-surface font-body text-sm h-9`,children:(0,X.jsx)(g,{placeholder:`Choose a project`})}),(0,X.jsx)(v,{className:`bg-surface border-outline-variant`,children:i?.map(e=>(0,X.jsx)(y,{value:e.id,className:`font-body text-sm`,children:e.name},e.id))})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(x,{className:`font-label text-sm text-muted-foreground`,children:`Name *`}),(0,X.jsx)(K,{"aria-label":`Name`,"data-testid":`memory-name-input`,value:c,onChange:e=>l(e.target.value),placeholder:`api-port`,maxLength:64,className:`bg-background text-on-surface font-body text-sm`,autoFocus:!0}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase words joined by hyphens, unique in the project.`})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(x,{className:`font-label text-sm text-muted-foreground`,children:`Description *`}),(0,X.jsx)(Sr,{value:u,max:300,testId:`memory-description-count`})]}),(0,X.jsx)(L,{"aria-label":`Description`,"data-testid":`memory-description-input`,value:u,onChange:e=>d(e.target.value),placeholder:`One line agents see in lists and context`,className:`bg-background text-on-surface font-body text-sm resize-none`,rows:2})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(x,{className:`font-label text-sm text-muted-foreground`,children:`Content *`}),(0,X.jsx)(Sr,{value:f,max:E,testId:`memory-content-count`})]}),(0,X.jsx)(L,{"aria-label":`Content`,"data-testid":`memory-content-input`,value:f,onChange:e=>p(e.target.value),placeholder:`The fact itself. Longer guidance belongs in a skill.`,className:`bg-background text-on-surface font-body text-sm`,rows:6})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(x,{className:`font-label text-sm text-muted-foreground`,children:[`Priority (0-`,100,`, empty = unscored)`]}),(0,X.jsx)(K,{"aria-label":`Priority`,"data-testid":`memory-priority-input`,type:`number`,min:0,max:100,step:1,value:m,onChange:e=>h(e.target.value),className:`w-32 bg-background text-on-surface font-body text-sm`}),!k&&(0,X.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Priority must be a whole number from 0 to `,100,`.`]})]}),e&&(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(x,{className:`font-label text-sm text-muted-foreground`,children:`Reason`}),(0,X.jsx)(K,{"aria-label":`Reason`,"data-testid":`memory-reason-input`,value:S,onChange:e=>C(e.target.value),placeholder:`Why this changed (optional)`,className:`bg-background text-on-surface font-body text-sm`})]}),D.error&&(0,X.jsx)(`p`,{role:`alert`,"data-testid":`memory-form-error`,className:`text-sm text-destructive`,children:D.error.message}),(0,X.jsxs)(R,{children:[(0,X.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,disabled:D.isPending,className:`font-label text-sm text-muted-foreground`,children:`Cancel`}),(0,X.jsx)(s,{"data-testid":`memory-submit`,type:`submit`,size:`sm`,disabled:!A||D.isPending,className:`font-label text-sm`,children:D.isPending?`Saving...`:e?`Save`:`Create`})]})]})]})})}function wr({projectId:e}){let t=Ye(e),{pathname:n}=te();return n.startsWith(`/knowledge/memories`)?(0,X.jsx)(`div`,{"data-testid":`knowledge-base-view`,children:(0,X.jsx)(hr,{projectId:e,embedded:!0})}):(0,X.jsx)(`div`,{"data-testid":`knowledge-base-view`,className:`flex min-h-0 min-w-0 flex-1`,children:(0,X.jsx)(Dr,{projectId:t===`all`||t===`unassigned`?void 0:t},t)})}function Tr(e){return e.replace(/```[\w-]*/g,` `).replace(/<\/?[a-z][^>]*>/gi,` `).replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/(^|\s)#{1,6}\s+/g,`$1`).replace(/(^|\n)\s*(?:>\s*)+/g,`$1`).replace(/(^|\n)\s*(?:[-*+]|\d+[.)])\s+/g,`$1`).replace(/\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?/g,` `).replace(/(^|\s)(?:\*{3,}|_{3,})(?=\s|$)/g,`$1`).replace(/`/g,``).replace(/(^|[\s(«])[*_~]+(?=\S)/g,`$1`).replace(/(\S)[*_~]+(?=$|[\s).,;:!?»])/g,`$1`).replace(/\s*\|[\s|]*/g,` · `).replace(/\s+/g,` `).replace(/^ · | · $/g,``).trim()}function Er({text:e}){let t=Tr(e).split(/«([^»]*)»/g);return(0,X.jsx)(X.Fragment,{children:t.map((e,t)=>t%2?(0,X.jsx)(`mark`,{className:`rounded-xs bg-primary/20 px-0.5 text-on-surface`,children:e},t):(0,X.jsx)(J.Fragment,{children:e},t))})}function Dr({projectId:e}){let[t,n]=j(),r=t.get(`kb`),i=t.get(`document`),a=t.get(`label`)??``,g=t.get(`q`)??``,_=t.get(`searchAll`)===`1`,[v,y]=(0,J.useState)(g);(0,J.useEffect)(()=>y(g),[g]);let[b,x]=(0,J.useState)(null),[S,w]=(0,J.useState)(!1),T=Se(`lg`),[E,D]=(0,J.useState)(()=>typeof window<`u`&&window.innerWidth>=1600),[O,k]=(0,J.useState)(!1),[A,M]=(0,J.useState)(null),[ee,te]=(0,J.useState)();function N(){x(null),te(void 0)}let ne=me(),P=ot(e),F=P.data?.find(e=>e.id===r)??null,re=mt(F?.id??null),I=vt(i),L=P.data!==void 0&&(F!==null||P.data.length===0),ie=gt(g&&L?{query:g,...F&&!_?{kb_ids:[F.id]}:{},scope:e?`default`:`all`,limit:20}:null,e),R=ur();function z(e,t=!1){n(()=>{let t=new URLSearchParams(window.location.search);for(let[n,r]of Object.entries(e))r?t.set(n,r):t.delete(n);return t},{replace:t})}let B=()=>!i||it(Hn(i));function ae(e){w(!1),(e!==r||i||g)&&B()&&(e!==r&&R.clearFinished(),z({kb:e,document:null,label:null,q:null}))}function V(e,t){w(!1),(e===i||B())&&(z({document:e,q:null}),M(t??null))}function oe(e,t){z({document:e}),M(t??null)}function U(){w(!1);let e=v.trim();if(!e)return z({q:null});B()&&z({q:e,document:null})}(0,J.useEffect)(()=>{T&&w(!1)},[T]),(0,J.useEffect)(()=>{P.data&&(r&&!P.data.some(e=>e.id===r)&&!i?z({kb:null},!0):!r&&P.data[0]&&z({kb:P.data[0].id},!0))}),(0,J.useEffect)(()=>{I.data&&I.data.kb_id!==r&&P.data?.some(e=>e.id===I.data.kb_id)&&z({kb:I.data.kb_id,label:null},!0)}),(0,J.useEffect)(()=>{if(!A||!I.data)return;let e=[...document.querySelector(`[data-testid="kb-document"]`)?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]].find(e=>e.textContent?.trim()===A);e&&(e.scrollIntoView({block:`start`}),M(null))});function se(e){e.preventDefault(),k(!1);let t=[...e.dataTransfer.files];F&&t.length!==0&&(t.length>1?R.add(F.id,t):(te(t[0]),x(`new-document`)))}let ce=e=>e===null?`Global`:ne.data?.find(t=>t.id===e)?.name??`Project`;if(P.error)return(0,X.jsx)(ze,{message:P.error.message,onRetry:()=>P.refetch()});let le=i?I.data&&F?(0,X.jsx)(Kn,{kb:F,doc:I.data,detailsOpen:E,onDetailsOpenChange:D,onHome:()=>ae(F.id),onOpen:V,onDeleted:()=>z({document:null}),onReplaceFile:e=>I.data&&R.add(I.data.kb_id,[e],{replace:{document_id:I.data.id,expected_revision:I.data.revision}})},I.data.id):I.error?(0,X.jsxs)(jr,{children:[(0,X.jsx)(`p`,{role:`alert`,"data-testid":`kb-document-error`,className:`text-sm text-error`,children:I.error.message}),(0,X.jsx)(s,{variant:`outline`,onClick:()=>z({document:null}),children:`Back`})]}):(0,X.jsx)(jr,{children:(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`Loading document…`})}):g?(0,X.jsx)(Ar,{children:(0,X.jsx)(Mr,{query:g,search:ie,onOpen:oe,onClear:()=>z({q:null})})}):F?(0,X.jsx)(Ar,{children:(0,X.jsx)(ar,{kb:F,owner:ce(F.project_id),listing:re.data,label:a,onLabel:e=>z({label:e}),onOpen:V,onNewDocument:()=>x(`new-document`),onSettings:()=>x(`settings`)})}):P.data?.length===0?(0,X.jsxs)(jr,{testId:`empty-state`,children:[(0,X.jsx)(pe,{size:28,className:`text-primary`}),(0,X.jsx)(`h2`,{className:`text-xl font-medium`,children:`Build a knowledge base`}),(0,X.jsx)(`p`,{className:`max-w-md text-outline`,children:`Upload documents, write Markdown or sync a folder. Agents search it with citations through MCP, the CLI and the API, and you can see what they read.`}),(0,X.jsxs)(s,{"data-testid":`kb-empty-create`,onClick:()=>x(`create`),children:[(0,X.jsx)(De,{size:16}),`New knowledge base`]})]}):null,ue=(0,X.jsxs)(`nav`,{id:`kb-sidebar-panel`,"aria-label":`Knowledge bases`,"data-testid":`kb-sidebar`,className:`flex h-full min-h-0 flex-col border-outline-variant bg-background lg:w-72 lg:shrink-0 lg:border-r`,children:[(0,X.jsxs)(`form`,{className:`flex shrink-0 items-center gap-1.5 border-b border-outline-variant p-3`,onSubmit:e=>{e.preventDefault(),U()},children:[(0,X.jsx)(K,{"aria-label":`Search knowledge`,"data-testid":`kb-search-input`,value:v,onChange:e=>y(e.target.value),placeholder:F&&!_?`Search ${F.name}`:`Search everything`,className:`h-9 min-w-0 flex-1`}),(0,X.jsx)(s,{type:`submit`,size:`icon`,variant:`ghost`,"data-testid":`kb-search-submit`,"aria-label":`Search`,children:(0,X.jsx)(ye,{size:16})}),S&&(0,X.jsx)(s,{type:`button`,size:`icon`,variant:`ghost`,"data-testid":`kb-browser-close`,"aria-label":`Close knowledge browser`,onClick:()=>w(!1),children:(0,X.jsx)(h,{size:16})})]}),F&&(0,X.jsxs)(`label`,{className:`flex shrink-0 items-center gap-2 border-b border-outline-variant px-3 py-2 text-xs text-outline`,children:[(0,X.jsx)(`input`,{type:`checkbox`,"data-testid":`kb-search-all`,checked:_,onChange:e=>z({searchAll:e.target.checked?`1`:null})}),`Search all knowledge bases`]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-2 pb-1`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-medium text-outline`,children:`Knowledge bases`}),(0,X.jsx)(s,{size:`icon`,variant:`ghost`,"aria-label":`New knowledge base`,"data-testid":`kb-create`,onClick:()=>x(`create`),children:(0,X.jsx)(De,{size:16})})]}),P.isLoading&&(0,X.jsx)(H,{className:`mx-2 h-9`}),(0,X.jsx)(Or,{bases:P.data??[],projectName:ce,kbId:r,documentId:i,documents:re.data?.documents??[],onSelectKb:ae,onOpenDocument:V})]}),(0,X.jsx)(kr,{})]});return(0,X.jsx)(f,{open:S&&!T,onOpenChange:w,children:(0,X.jsxs)(`div`,{"data-testid":`knowledge-bases`,className:`relative flex min-h-0 min-w-0 flex-1`,children:[(0,X.jsx)(`h1`,{"data-testid":`view-title`,className:`sr-only`,children:`Knowledge bases`}),T&&ue,!T&&(0,X.jsxs)(m,{children:[(0,X.jsx)(p,{className:`fixed inset-0 z-50 bg-black/70`}),(0,X.jsxs)(u,{"data-testid":`kb-mobile-browser`,className:`viewport-sheet fixed inset-x-0 z-50 bg-background`,children:[(0,X.jsx)(l,{className:`sr-only`,children:`Browse knowledge`}),(0,X.jsx)(c,{className:`sr-only`,children:`Search knowledge bases and choose a document`}),ue]})]}),(0,X.jsxs)(`div`,{"data-testid":`kb-dropzone`,className:o(`relative flex min-h-0 min-w-0 flex-1 flex-col`,O&&`outline-2 -outline-offset-4 outline-dashed outline-primary`),onDragOver:e=>{F&&(e.preventDefault(),k(!0))},onDragLeave:()=>k(!1),onDrop:se,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-outline-variant px-3 py-2 lg:hidden`,children:[(0,X.jsx)(d,{asChild:!0,children:(0,X.jsxs)(s,{"data-testid":`kb-browser-open`,variant:`ghost`,size:`sm`,"aria-expanded":S,"aria-controls":`kb-sidebar-panel`,onClick:()=>w(!0),children:[(0,X.jsx)(Ce,{size:16}),`Browse`]})}),F&&(0,X.jsx)(`span`,{className:`min-w-0 truncate text-sm text-outline`,children:F.name})]}),i&&g&&(0,X.jsx)(`div`,{className:`flex shrink-0 items-center border-b border-outline-variant px-3 py-1`,children:(0,X.jsxs)(s,{variant:`ghost`,size:`sm`,"data-testid":`kb-search-back`,className:`min-w-0`,onClick:()=>B()&&z({document:null}),children:[(0,X.jsx)(C,{size:14}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`Back to results for “`,g,`”`]})]})}),(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:le}),(0,X.jsx)(Nr,{uploads:R,onOpen:V})]}),b===`create`&&(0,X.jsx)(bn,{open:!0,projectId:e,onClose:()=>x(null),onCreated:e=>{x(null),w(!1),z({kb:e.id,document:null,label:null,q:null})}}),b===`settings`&&F&&(0,X.jsx)(xn,{kb:F,onClose:()=>x(null),onDeleted:()=>{x(null),z({kb:null,document:null,label:null})}}),b===`new-document`&&F&&(0,X.jsx)(Tn,{kb:F,initialFile:ee,onClose:N,onUploadMany:e=>{N(),R.add(F.id,e)},onCreated:(e,t)=>{N(),z({document:e.id,editorMode:t?null:`edit`})}})]})})}function Or({bases:e,projectName:t,kbId:n,documentId:r,documents:i,onSelectKb:a,onOpenDocument:s}){let[c,l]=(0,J.useState)(null);(0,J.useEffect)(()=>{r&&l(null)},[r]);let u=new Map;for(let n of e){let e=t(n.project_id);u.set(e,[...u.get(e)??[],n])}let d=[...u.entries()].sort(([e],[t])=>e===`Global`?-1:t===`Global`?1:e.localeCompare(t));return(0,X.jsx)(`div`,{"data-testid":`kb-list`,className:`space-y-3`,children:d.map(([e,t])=>(0,X.jsxs)(`section`,{"aria-label":e,children:[d.length>1&&(0,X.jsx)(`h3`,{className:`truncate px-2 pb-0.5 pt-1 text-xs text-outline`,children:e}),(0,X.jsx)(`ul`,{className:`space-y-0.5`,children:t.map(e=>{let t=e.id===n,u=t&&c!==e.id&&i.length>0;return(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-row`,"data-kb-name":e.name,"aria-current":t&&!r?`page`:void 0,"aria-expanded":u,className:o(`flex min-h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-surface-high`,t&&`font-medium`,t&&!r&&`bg-surface-high`),onClick:()=>{t&&l(t=>t===e.id?null:e.id),a(e.id)},children:[(0,X.jsx)(Te,{size:14,"aria-hidden":!0,className:o(`-mr-1 shrink-0 text-outline transition-transform motion-reduce:transition-none`,u&&`rotate-90`,e.document_count===0&&`invisible`)}),(0,X.jsx)(pe,{size:15,className:`shrink-0 text-outline`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,X.jsx)(`span`,{className:`text-xs font-normal tabular-nums text-outline`,children:e.document_count})]}),u&&(0,X.jsx)(`ul`,{className:`ml-4 mt-0.5 space-y-0.5 border-l border-outline-variant pl-2`,children:i.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"data-testid":`kb-nav-document`,"data-document-title":e.title,"aria-current":e.id===r?`page`:void 0,className:o(`flex min-h-8 w-full items-center gap-2 rounded-md px-2 text-left text-sm hover:bg-surface-high`,e.id===r?`bg-surface-high text-on-surface`:`text-outline`),onClick:()=>s(e.id),children:[(0,X.jsx)(Oe,{size:14,className:`shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]})},e.id))})]},e.id)})})]},e))})}function kr(){let e=dt(),t=e.data,n=t?t.embedding.provider===`none`?{text:`Keyword search only`,title:`Configure embeddings in Settings to also search by meaning`}:t.embedding.ready?{text:`Hybrid search`,title:t.embedding.model??void 0}:{text:`Embeddings not ready`,title:t.embedding.detail??``}:null,r=t?t.jobs.queued+t.jobs.running:0;return(0,X.jsx)(`p`,{role:`status`,"data-testid":`kb-status`,className:`shrink-0 border-t border-outline-variant px-4 py-2 text-xs text-outline`,children:t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{title:n?.title,children:n?.text}),r?` · ${r} processing`:``]}):e.error?`Knowledge status unavailable`:`Loading…`})}function Ar({children:e}){return(0,X.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:e})}function jr({children:e,testId:t}){return(0,X.jsx)(`div`,{"data-testid":t,className:`mx-auto flex max-w-lg flex-1 flex-col items-start justify-center gap-4 p-6`,children:e})}function Mr({query:e,search:t,onOpen:n,onClear:r}){let i=t.data;return(0,X.jsxs)(`section`,{"data-testid":`kb-search-results`,"aria-label":`Search results`,className:`w-full min-w-0 space-y-4 p-4 sm:p-8`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h2`,{className:`mr-auto text-lg font-medium`,children:[`Results for “`,e,`”`]}),i&&i.hits.length>0&&(0,X.jsxs)(`span`,{className:`text-xs text-outline`,"data-testid":`kb-search-count`,children:[i.hits.length,` `,i.hits.length===1?`result`:`results`]}),(0,X.jsxs)(s,{variant:`ghost`,size:`sm`,onClick:r,"data-testid":`kb-search-clear`,children:[(0,X.jsx)(h,{size:14}),`Clear`]})]}),i?.degraded&&(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:i.degraded}),t.isLoading&&(0,X.jsx)(`p`,{className:`text-sm text-outline`,children:`Searching…`}),t.error&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:t.error.message}),i?.hits.length===0&&(0,X.jsx)(`p`,{className:`text-sm text-outline`,"data-testid":`kb-search-empty`,children:`Nothing matched. Try other words or search all knowledge bases.`}),i?.hits.map(e=>(0,X.jsxs)(`article`,{"data-testid":`kb-search-result`,className:`space-y-2 border-b border-outline-variant pb-4`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`block text-left`,onClick:()=>n(e.document_id,Ir(e.passages[0]?.heading_path)),children:[(0,X.jsx)(`span`,{className:`block font-medium text-primary hover:underline`,children:e.title}),(0,X.jsxs)(`span`,{className:`block break-all text-xs text-outline`,children:[e.kb_name,` · `,e.path]})]}),e.labels.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.labels.map(e=>(0,X.jsx)(In,{variant:`secondary`,children:e},e))}),e.passages.map(t=>(0,X.jsxs)(`div`,{"data-testid":`kb-search-passage`,className:`cursor-pointer space-y-1 rounded-md p-2 hover:bg-surface-high`,onClick:()=>n(e.document_id,Ir(t.heading_path)),children:[(t.heading_path.length>0||t.locator?.page||t.locator?.sheet)&&(0,X.jsx)(`div`,{className:`text-xs text-outline`,children:[...t.heading_path.map(Tr),...t.locator?.page?[`page ${t.locator.page}`]:[],...t.locator?.sheet?[`sheet ${t.locator.sheet}`]:[]].join(` › `)}),(0,X.jsx)(`p`,{className:`text-sm leading-relaxed`,children:(0,X.jsx)(Er,{text:t.snippet})})]},t.chunk_id))]},e.document_id))]})}function Nr({uploads:e,onOpen:t}){if(!e.uploads.length)return null;let n=e.uploads.some(e=>e.status!==`uploading`);return(0,X.jsxs)(`section`,{"data-testid":`kb-upload-queue`,"aria-label":`Uploads`,className:`absolute bottom-4 right-4 z-10 flex max-h-72 w-80 max-w-[calc(100%-2rem)] flex-col rounded-lg border border-outline-variant bg-surface text-sm shadow-lg`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 py-1.5`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Uploads`}),n&&(0,X.jsx)(s,{size:`sm`,variant:`ghost`,onClick:e.clearFinished,"data-testid":`kb-upload-clear`,children:`Dismiss`})]}),(0,X.jsx)(`div`,{className:`min-h-0 space-y-1 overflow-y-auto px-3 pb-2`,children:e.uploads.map(n=>(0,X.jsx)(Fr,{upload:n,onOpen:t,onRetry:()=>e.retry(n.id)},n.id))})]})}var Pr={pending:`Parsing…`,ok:`Open`,partial:`Open · partly parsed`,failed:`Parse failed`};function Fr({upload:e,onOpen:t,onRetry:n}){let r=mt(e.status===`done`?e.kbId:null).data?.documents.find(t=>t.id===e.document?.id)??e.document;return(0,X.jsxs)(`div`,{"data-testid":`kb-upload-item`,"data-status":e.status,"data-parse-state":r?.parse_state,className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.file.name}),e.status===`uploading`&&(0,X.jsx)(`span`,{className:`h-1.5 w-24 overflow-hidden rounded-full bg-surface-high`,role:`progressbar`,"aria-label":`Upload progress`,"aria-valuenow":Math.round(e.progress*100),children:(0,X.jsx)(`span`,{className:`block h-full bg-primary`,style:{width:`${Math.round(e.progress*100)}%`}})}),e.status===`done`&&r&&(0,X.jsx)(`button`,{type:`button`,className:o(`hover:underline`,r.parse_state===`failed`?`text-error`:`text-primary`),onClick:()=>t(r.id),children:Pr[r.parse_state]}),e.status===`failed`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{role:`alert`,className:`text-error`,children:e.error}),(0,X.jsx)(s,{size:`sm`,variant:`ghost`,onClick:n,"data-testid":`kb-upload-retry`,children:`Retry`})]})]})}function Ir(e){return e?.[e.length-1]}export{wr as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-B5esWp7J.js","assets/rolldown-runtime-DSDNlrLa.js","assets/jsx-runtime-CVMpzJz9.js","assets/react-dom-DTbwZiiP.js","assets/button-BHKbOsmj.js","assets/bundle-mjs-CdK3cBzO.js","assets/createLucideIcon-jLuHkL03.js","assets/preload-helper-BLdHbfdN.js","assets/index-CMRGRbC9.js","assets/QueryClientProvider-DlPztvhd.js","assets/useMutation-HX90wI4L.js","assets/dist-ClOxCp9t.js","assets/dist-HH469UWY.js","assets/es2015-w69PgVrA.js","assets/x-BKorzD7S.js","assets/check-hFtKhUSV.js","assets/dist-B9K53eWS.js","assets/select-CBHDS40x.js","assets/dist-D3PXSw6Q.js","assets/dist-Ct6061MC.js","assets/dist-D8Wfxh48.js","assets/chevron-down-D2sszSv3.js","assets/label-BQ1Lr4sA.js","assets/MarkdownEditor-BMQq1cAY.js","assets/document-display-BQ5dM8QT.js","assets/file-kind-BYU1kv95.js","assets/client-BwhkVepQ.js","assets/bulk-actions-C8S1Gt4W.js","assets/index-BCGI8JzG.css","assets/mermaid.core-CE0shN4j.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-DpAUOMD9.js","assets/chunk-DU6HZSFF-BaVVqpDB.js","assets/chunk-75Z2AOVW-DGmxZV98.js","assets/dist-BwUkq7ma.js","assets/chunk-P2QGCYS3-DpMkYw3X.js","assets/chunk-PWAF6VOD-CP1kSMru.js","assets/chunk-GMAD6QVW-D7d5cxQ3.js","assets/chunk-4HAMMTFA-DY6eE90t.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-GfOuiNH1.js","assets/chunk-L3NEJ4N5-BD8q2mez.js","assets/chunk-OSK3NFVY-DN8XtEwT.js","assets/line-BmNPsHiE.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/graphlib-DS17s2tU.js","assets/wiki-links-A52THGx_.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./preload-helper-BLdHbfdN.js";var i=e(t(),1),a=n(),o=(0,i.lazy)(()=>r(()=>import(`./MarkdownRenderer-B5esWp7J.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47]))),s=(0,i.memo)(function(e){let{fallback:t,...n}=e;return(0,a.jsx)(i.Suspense,{fallback:t??(0,a.jsx)(`div`,{role:`status`,className:`text-sm text-outline`,children:`Loading document…`}),children:(0,a.jsx)(o,{...n})})});export{s as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SourceEditor-
|
|
2
|
-
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./button-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SourceEditor-B5CtJBt0.js","assets/rolldown-runtime-DSDNlrLa.js","assets/jsx-runtime-CVMpzJz9.js","assets/createLucideIcon-jLuHkL03.js","assets/Markdown-BYChkZ3Z.js","assets/preload-helper-BLdHbfdN.js","assets/file-kind-BYU1kv95.js","assets/index-CMRGRbC9.js","assets/QueryClientProvider-DlPztvhd.js","assets/useMutation-HX90wI4L.js","assets/react-dom-DTbwZiiP.js","assets/dist-ClOxCp9t.js","assets/button-BHKbOsmj.js","assets/bundle-mjs-CdK3cBzO.js","assets/dist-HH469UWY.js","assets/es2015-w69PgVrA.js","assets/x-BKorzD7S.js","assets/check-hFtKhUSV.js","assets/dist-B9K53eWS.js","assets/select-CBHDS40x.js","assets/dist-D3PXSw6Q.js","assets/dist-Ct6061MC.js","assets/dist-D8Wfxh48.js","assets/chevron-down-D2sszSv3.js","assets/label-BQ1Lr4sA.js","assets/client-BwhkVepQ.js","assets/document-display-BQ5dM8QT.js","assets/bulk-actions-C8S1Gt4W.js","assets/index-BCGI8JzG.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./button-BHKbOsmj.js";import{t as i}from"./createLucideIcon-jLuHkL03.js";import{t as a}from"./preload-helper-BLdHbfdN.js";import{t as o}from"./Markdown-BYChkZ3Z.js";import{r as s}from"./document-display-BQ5dM8QT.js";import{t as c}from"./file-kind-BYU1kv95.js";var l={name:`maximize-2`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]};l.node;var u=i(l),d={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};d.node;var f=i(d),p=e(t(),1),m=n(),h=(0,p.lazy)(()=>a(()=>import(`./SourceEditor-B5CtJBt0.js`).then(e=>({default:e.SourceEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])));function g(e){return(0,m.jsx)(p.Suspense,{fallback:(0,m.jsx)(`div`,{style:{height:e.height??320},className:`p-3 text-xs text-outline`,children:`Loading editor...`}),children:(0,m.jsx)(h,{...e})})}function _(e,t){if(!t)return e;let n=e.match(/^\s*#[ \t]+(.+?)[ \t#]*(?:\r?\n|$)/),r=e=>e.trim().replace(/\s+/g,` `).toLowerCase();return n?.[1]&&r(n[1])===r(t)?e.slice(n[0].length):e}function v({path:e,value:t,onChange:n,onSave:i,readOnly:a=!1,testId:l,wikiLinks:d,initialMode:h,mode:v,onModeChange:y,header:b,height:x,id:S,label:C,placeholder:w,expanded:T,onExpandedChange:E,layout:D=`frame`,actions:O,notice:k,pageTitle:A,hideFrontmatter:j=!1}){let M=c(e),[N,P]=(0,p.useState)(h??(a&&M?`read`:`edit`)),F=v??N;function I(e){P(e),y?.(e)}let[L,R]=(0,p.useState)(!1),z=T??L,B=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(!z||!B.current)return;let e=[],t=B.current;for(;t.parentElement;){let n=t.parentElement;for(let r of Array.from(n.children))r!==t&&r instanceof HTMLElement&&(e.push({element:r,inert:r.inert}),r.inert=!0);if(n.hasAttribute(`data-document-container`)||n===document.body)break;t=n}return()=>{for(let t of e)t.element.inert=t.inert}},[z]);function V(e){R(e),E?.(e)}(0,p.useEffect)(()=>{if(!z)return;function e(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=document.querySelector(`[role="dialog"], [role="alertdialog"]`);(!t||B.current?.contains(t))&&(R(!1),E?.(!1))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z,E]);let H=s(t),U=_(H.body,A),W=D===`page`&&M&&!z;return(0,m.jsxs)(`section`,{ref:B,"data-testid":`markdown-editor`,"data-expanded":z,"data-document-expanded":z,className:`flex min-w-0 flex-col ${W?``:`min-h-0 rounded-md border border-surface-highest bg-surface`} ${z?`fixed inset-2 z-60 sm:inset-6`:``}`,style:z||W?void 0:{height:x??`min(65dvh, 760px)`,minHeight:x?void 0:280},"aria-label":`Document ${e}`,onKeyDown:e=>{e.defaultPrevented||(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),i?.())},children:[b&&(0,m.jsx)(`div`,{className:`shrink-0 border-b border-surface-highest p-3`,children:b}),(0,m.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-surface-highest ${W?`sticky top-0 z-10 bg-background py-2`:`p-2`}`,children:[M&&(0,m.jsx)(`fieldset`,{className:`flex gap-1`,"aria-label":`Document mode`,children:[`read`,`edit`,`split`].map(e=>(0,m.jsx)(r,{type:`button`,size:`sm`,variant:F===e?`default`:`ghost`,className:e===`split`&&D===`page`?`hidden md:inline-flex`:void 0,"data-testid":`markdown-mode-${e}`,"aria-pressed":F===e,onClick:()=>I(e),children:e===`read`?`Read`:e===`edit`?a?`Source`:`Edit`:`Split`},e))}),(0,m.jsx)(`span`,{className:`min-w-0 flex-1 truncate px-1 text-xs text-outline`,title:e,children:D===`page`?``:e}),O,z&&i&&!b&&!O&&(0,m.jsx)(r,{type:`button`,"data-testid":`markdown-save`,disabled:a,onClick:i,children:`Save`}),(0,m.jsx)(r,{type:`button`,size:`icon`,variant:`ghost`,"data-testid":`markdown-expand`,"aria-label":z?`Exit fullscreen`:`Expand editor`,"aria-pressed":z,onClick:()=>V(!z),children:z?(0,m.jsx)(f,{size:16}):(0,m.jsx)(u,{size:16})})]}),k&&(0,m.jsx)(`div`,{className:`shrink-0 space-y-1 border-b border-surface-highest ${W?`py-2`:`p-3`}`,children:k}),(0,m.jsxs)(`div`,{className:`grid min-h-0 min-w-0 flex-1 ${W?`items-start gap-6 pt-4`:`overflow-hidden`} ${F===`split`&&M?`grid-rows-2 md:grid-cols-2 md:grid-rows-1`:`grid-cols-1`}`,children:[(0,m.jsx)(`div`,{className:`min-h-0 min-w-0 ${W?`[&_.cm-editor]:min-h-[50dvh]`:`overflow-hidden`} ${F===`read`&&M?`hidden`:``}`,children:(0,m.jsx)(g,{path:e,value:t,onChange:n,onSave:i,readOnly:a,height:W?`auto`:`100%`,testId:l,hidePreview:!0,defaultWrap:!0,id:S,label:C,placeholder:w})}),M&&F!==`edit`&&(0,m.jsx)(`article`,{"data-testid":`markdown-preview`,"aria-label":`Rendered Markdown`,className:`min-h-0 min-w-0 ${W?`pb-6`:`overflow-auto p-4 sm:p-8`} ${F===`split`&&!W?`border-t border-surface-highest md:border-l md:border-t-0`:``}`,children:(0,m.jsxs)(`div`,{className:`wrap-break-word ${W?`[&_:is(p,ul,ol,blockquote,h1,h2,h3,h4,h5,h6)]:max-w-[72ch]`:`mx-auto max-w-[76ch]`}`,children:[H.metadata!==null&&!j&&(0,m.jsxs)(`details`,{className:`mb-5 rounded border border-surface-highest p-3 text-sm text-outline`,children:[(0,m.jsx)(`summary`,{className:`cursor-pointer`,children:`Document metadata`}),(0,m.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap wrap-break-word font-mono text-xs`,children:H.metadata})]}),t.trim()?(0,m.jsx)(o,{readable:!0,wikiLinks:d,children:U}):(0,m.jsx)(`p`,{className:`text-sm text-outline`,children:`This document is empty.`})]})})]})]})}export{u as i,g as n,f as r,v as t};
|