@promptowl/contextnest-community 1.26.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +34 -1
- package/CONFIGURATION.md +32 -1
- package/dist/{chunk-TRSGPS27.js → chunk-H3W72HN3.js} +28 -0
- package/dist/{chunk-DGPTJXIV.js → chunk-MB52DWWP.js} +4 -4
- package/dist/{chunk-IEAWRHMV.js → chunk-NFFUZF2B.js} +23 -2
- package/dist/{chunk-PICUHQEM.js → chunk-O3JEI33N.js} +2 -2
- package/dist/{chunk-SWA5M5XX.js → chunk-QMQDWRHN.js} +128 -22
- package/dist/{chunk-I5EDEZBQ.js → chunk-RXCVXG34.js} +1 -1
- package/dist/{chunk-2QOJE7A5.js → chunk-SE5U4J4T.js} +4 -4
- package/dist/{chunk-RPGFHESR.js → chunk-VHEMGQ3I.js} +1 -1
- package/dist/{chunk-M6PGYMBD.js → chunk-VRLAP4HB.js} +33 -15
- package/dist/{engine-QNMFDIBV.js → engine-HLYQLP5T.js} +3 -3
- package/dist/{external-edit-service-4MEGPT4D.js → external-edit-service-3DFQ4EZZ.js} +4 -4
- package/dist/{grants-service-24GLUBY4.js → grants-service-WICV4Y2J.js} +2 -2
- package/dist/index.js +804 -304
- package/dist/{invited-user-AM6A3WGO.js → invited-user-XEBX6BM4.js} +3 -3
- package/dist/{review-service-2EWN7WWO.js → review-service-GB43UQVH.js} +7 -7
- package/dist/{stewardship-service-TDZUC2Q6.js → stewardship-service-KDBPWRZI.js} +4 -4
- package/dist/{version-service-C3JTZLJH.js → version-service-JYHFPSYP.js} +8 -4
- package/dist/web3/assets/{ActivityTracePage-DzwWIjjx.js → ActivityTracePage-CkRoyIc-.js} +1 -1
- package/dist/web3/assets/AgentDocsPage-BTRXmliv.js +1 -0
- package/dist/web3/assets/CollaboratorManager-CqJIkvs-.js +1 -0
- package/dist/web3/assets/CollaboratorsTab-JcO1P-qm.js +1 -0
- package/dist/web3/assets/DocumentEditor-D1GLeeEP.js +36 -0
- package/dist/web3/assets/DocumentsTab-BAgSxTX1.js +6 -0
- package/dist/web3/assets/ExternalEditsTab-DuuTXZap.js +1 -0
- package/dist/web3/assets/{MarkdownEditor-CKh4WSn-.js → MarkdownEditor-BELFww9q.js} +116 -126
- package/dist/web3/assets/{NestPageHeader-Cizo8nUi.js → NestPageHeader-Bbje2ncY.js} +1 -1
- package/dist/web3/assets/NestView-D4OMXPQ7.js +73 -0
- package/dist/web3/assets/OverviewTab-FIDGjR3Q.js +6 -0
- package/dist/web3/assets/{PersonCombobox-BKI7dff4.js → PersonCombobox-D52m_jhc.js} +1 -1
- package/dist/web3/assets/{ReviewActions-CS8JXgXF.js → ReviewActions-DYqBcWlv.js} +2 -2
- package/dist/web3/assets/ReviewTab-DoxfygOb.js +1 -0
- package/dist/web3/assets/StewardsTab-CFsYjbEn.js +1 -0
- package/dist/web3/assets/{SubmitForReviewModal-Biq3m79i.js → SubmitForReviewModal-AW2OLNAE.js} +1 -1
- package/dist/web3/assets/{alert-dialog-BvF3NFr7.js → alert-dialog-p-fBLSWx.js} +2 -2
- package/dist/web3/assets/{arrow-left-CWIsv-sG.js → arrow-left-CiErCCTG.js} +1 -1
- package/dist/web3/assets/{backlinks-Cqcn7n1J.js → backlinks-DaVSYvhV.js} +2 -2
- package/dist/web3/assets/{boxes-ClbgQqG2.js → boxes-VWrCCMzW.js} +1 -1
- package/dist/web3/assets/{chevron-left-CK_ZPFm9.js → chevron-left-CsD8gZwL.js} +1 -1
- package/dist/web3/assets/{circle-check-Bw_aTXiH.js → circle-check-BBCXd9LI.js} +1 -1
- package/dist/web3/assets/{circle-x-DkIG68H7.js → circle-x-C9LsnORQ.js} +1 -1
- package/dist/web3/assets/{code-xml-BlR7EN6l.js → code-xml-BaoV7HiQ.js} +1 -1
- package/dist/web3/assets/{corner-down-right-DSVxK3tf.js → corner-down-right-DgiTXrtw.js} +1 -1
- package/dist/web3/assets/{count-skeleton-DToLM74B.js → count-skeleton-CnEE4uF-.js} +1 -1
- package/dist/web3/assets/{earth-BXhVPvCR.js → earth-BmMbVt9k.js} +1 -1
- package/dist/web3/assets/{file-exclamation-point-BevGZgtj.js → file-exclamation-point-qJeca9-A.js} +1 -1
- package/dist/web3/assets/{folder-input-m8UBV4fA.js → folder-input-D7R93LJ6.js} +1 -1
- package/dist/web3/assets/index-DNmWTxN7.css +1 -0
- package/dist/web3/assets/index-DvuUIUP6.js +451 -0
- package/dist/web3/assets/{page-DzKwP5Ds.js → page-BJQuaTRW.js} +2 -2
- package/dist/web3/assets/{page-B6pkc9cd.js → page-Bb8xGOPQ.js} +2 -2
- package/dist/web3/assets/{page-Deq6IKiN.js → page-BtM-qDzr.js} +2 -2
- package/dist/web3/assets/{page-DPY01SOj.js → page-Bxd0EG25.js} +1 -1
- package/dist/web3/assets/page-C3QCO6IR.js +1 -0
- package/dist/web3/assets/{page-CptuAPJc.js → page-CfoR0khy.js} +2 -2
- package/dist/web3/assets/page-D7Zr5tAI.js +1 -0
- package/dist/web3/assets/{page-Dwbp4Seu.js → page-DATSlHCW.js} +2 -2
- package/dist/web3/assets/page-DTjPQizZ.js +45 -0
- package/dist/web3/assets/{page-Bgy9Ng9p.js → page-DspptlWr.js} +1 -1
- package/dist/web3/assets/{page-Dh57L0RG.js → page-I6vAFJOj.js} +4 -4
- package/dist/web3/assets/page-QxI4Ud2s.js +9 -0
- package/dist/web3/assets/{page-BJrFCKXB.js → page-YcNNg-dX.js} +1 -1
- package/dist/web3/assets/page-kM7eO5Kj.js +1 -0
- package/dist/web3/assets/{page-title-DVq4qvMR.js → page-title-Dn5jANiU.js} +1 -1
- package/dist/web3/assets/{play-CXhS6Pgq.js → play-B2k_Ix-L.js} +1 -1
- package/dist/web3/assets/{send-DdfwnIrj.js → send-DPNxv3As.js} +1 -1
- package/dist/web3/assets/{settings-DKX0Q4gO.js → settings-DZjq-OQA.js} +1 -1
- package/dist/web3/assets/{share-2-CxmXRt58.js → share-2-C-OnE2ru.js} +1 -1
- package/dist/web3/assets/{tag-DeYC_mRv.js → tag-CwJl7FdI.js} +1 -1
- package/dist/web3/assets/{trash-2-B0HyPTnI.js → trash-2-aljmIff4.js} +1 -1
- package/dist/web3/assets/{user-plus-Ckm_Isyc.js → user-plus-DPerZexX.js} +1 -1
- package/dist/web3/assets/{zap-D2ifcnYb.js → zap-CHZtiN7P.js} +1 -1
- package/dist/web3/index.html +2 -2
- package/package.json +6 -2
- package/dist/web3/assets/AgentDocsPage-ixP2UdAE.js +0 -1
- package/dist/web3/assets/CollaboratorManager-C9VAXZ0h.js +0 -1
- package/dist/web3/assets/CollaboratorsTab-tq4ZTexH.js +0 -1
- package/dist/web3/assets/DocumentEditor-C2CP2fiE.js +0 -36
- package/dist/web3/assets/DocumentsTab-Mh7KxUoB.js +0 -6
- package/dist/web3/assets/ExternalEditsTab-B_CWKXZ_.js +0 -1
- package/dist/web3/assets/NestView-EW-sraEb.js +0 -73
- package/dist/web3/assets/OverviewTab-CjidsMX_.js +0 -6
- package/dist/web3/assets/ReviewTab-CwVrXzw5.js +0 -1
- package/dist/web3/assets/StewardsTab-C-iP6gnh.js +0 -1
- package/dist/web3/assets/index-BOVYgMvj.js +0 -29
- package/dist/web3/assets/index-DVnaYqj9.css +0 -1
- package/dist/web3/assets/index-WYDmEOfO.js +0 -404
- package/dist/web3/assets/page-C2zoxumw.js +0 -1
- package/dist/web3/assets/page-CJWO06dN.js +0 -1
- package/dist/web3/assets/page-Dea2SblF.js +0 -9
- package/dist/web3/assets/page-Dfjg8p7Z.js +0 -1
- package/dist/web3/assets/page-YxjrE5b5.js +0 -45
- package/dist/web3/assets/x-mNtADYHc.js +0 -6
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ExternalEditsTab-B_CWKXZ_.js","assets/index-WYDmEOfO.js","assets/index-DVnaYqj9.css","assets/file-exclamation-point-BevGZgtj.js","assets/circle-check-Bw_aTXiH.js","assets/MarkdownEditor-CKh4WSn-.js","assets/zap-D2ifcnYb.js","assets/index-BOVYgMvj.js","assets/arrow-left-CWIsv-sG.js","assets/trash-2-B0HyPTnI.js","assets/x-mNtADYHc.js","assets/MarkdownEditor-ndtIx5x0.css","assets/chevron-left-CK_ZPFm9.js","assets/alert-dialog-BvF3NFr7.js","assets/NestPageHeader-Cizo8nUi.js","assets/count-skeleton-DToLM74B.js","assets/folder-input-m8UBV4fA.js","assets/PersonCombobox-BKI7dff4.js","assets/tag-DeYC_mRv.js","assets/user-plus-Ckm_Isyc.js","assets/ReviewActions-CS8JXgXF.js","assets/circle-x-DkIG68H7.js","assets/settings-DKX0Q4gO.js","assets/StewardsTab-C-iP6gnh.js","assets/CollaboratorsTab-tq4ZTexH.js","assets/CollaboratorManager-C9VAXZ0h.js","assets/share-2-CxmXRt58.js","assets/ReviewTab-CwVrXzw5.js","assets/corner-down-right-DSVxK3tf.js","assets/send-DdfwnIrj.js","assets/OverviewTab-CjidsMX_.js","assets/DocumentsTab-Mh7KxUoB.js","assets/backlinks-Cqcn7n1J.js","assets/client-attribution-BraarYaP.js","assets/SubmitForReviewModal-Biq3m79i.js","assets/folder-target-CUSWqImF.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as He,r as n,u as gs,l as K,F as ut,ae as ms,j as e,D as Ae,z as Te,G as De,H as Ee,J as pt,A as hs,N as Ua,a as ps,M as Q,ah as ja,ai as ya,aj as Na,ak as ka,al as Pt,K as Ve,B as C,L as ce,R as zr,bB as Vr,aJ as ns,a6 as Hr,bC as Ia,bD as _a,C as Qr,az as Ur,aE as Ir,bE as $t,Z as ze,b6 as at,h as Gr,I as xt,bF as Kr,bG as mt,bH as Yr,bI as Xr,aP as Ga,bJ as Jr,bK as Sa,bL as vs,bM as Zr,bN as en,au as tn,bO as sn,aK as an,ar as rn,bP as nn,bQ as Ka,bR as on,bS as rt,bT as ht,bU as ln,bV as Ca,bW as Ra,bX as cn,i as S,aA as dn,Y as bs,Q as un,bY as Aa,a2 as mn,aT as hn,bZ as pn,aO as xn,U as Ta,ad as Da,af as fn,e as nt,aq as gn,S as vn,V as bn,W as Me,as as wn,at as jn,av as yn,ax as os,a_ as Nn,b_ as ot,b$ as it,c0 as lt,c1 as ct,c2 as dt,X as qe,c3 as kn,E as _n,T as Sn,c4 as Cn,ag as is,c5 as Ea,aD as Rn,c6 as Qe,c7 as Ue,aI as An,c8 as Tn,am as Dn,c9 as Pa,ca as En,cb as Pn,aF as Ln,aG as Fn,cc as On,cd as $n,ce as Mn,cf as qn}from"./index-WYDmEOfO.js";import{S as La,W as Bn,T as Wn,v as zn,n as Vn,h as Hn,P as Qn,D as Un,R as In,I as Gn,U as Fa,O as Kn,w as Yn,F as Oa,q as Xn,x as Jn,M as Zn,s as eo}from"./MarkdownEditor-CKh4WSn-.js";import{Z as to,F as so}from"./zap-D2ifcnYb.js";import{X as Ya}from"./x-mNtADYHc.js";import{C as ao}from"./chevron-left-CK_ZPFm9.js";import{T as xs}from"./trash-2-B0HyPTnI.js";import{A as ro,a as no,b as oo,c as io,d as lo,e as co,f as uo,g as mo}from"./alert-dialog-BvF3NFr7.js";import{N as ho}from"./NestPageHeader-Cizo8nUi.js";import{C as Lt,D as po,R as xo}from"./count-skeleton-DToLM74B.js";import{P as fo}from"./PersonCombobox-BKI7dff4.js";import{T as go,L as vo}from"./tag-DeYC_mRv.js";import{U as bo}from"./user-plus-Ckm_Isyc.js";import{R as wo}from"./ReviewActions-CS8JXgXF.js";import{F as jo,A as yo}from"./folder-input-m8UBV4fA.js";import{C as No}from"./circle-check-Bw_aTXiH.js";import{S as $a}from"./settings-DKX0Q4gO.js";/**
|
|
3
|
-
* @license lucide-react v0.577.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const ko=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],_o=He("activity",ko);/**
|
|
8
|
-
* @license lucide-react v0.577.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const So=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Co=He("clock",So);/**
|
|
13
|
-
* @license lucide-react v0.577.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const Ro=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Ao=He("file-code-corner",Ro);/**
|
|
18
|
-
* @license lucide-react v0.577.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const To=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Do=He("menu",To);/**
|
|
23
|
-
* @license lucide-react v0.577.0 - ISC
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the ISC license.
|
|
26
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const Eo=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Po=He("palette",Eo);/**
|
|
28
|
-
* @license lucide-react v0.577.0 - ISC
|
|
29
|
-
*
|
|
30
|
-
* This source code is licensed under the ISC license.
|
|
31
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const Lo=[["path",{d:"M11.5 15H7a4 4 0 0 0-4 4v2",key:"15lzij"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}]],Fo=He("user-pen",Lo),ls={nest:{label:"Entire Nest",icon:ms,placeholder:""},tag:{label:"Tag",icon:go,placeholder:"e.g., #architecture"},document:{label:"Document",icon:ut,placeholder:"e.g., nodes/getting-started"}};function Ma(t){return t.scope==="tag"?t.tagName||"":t.scope==="document"&&t.nodePattern||""}function qa({isOpen:t,onClose:a,nestId:r,steward:o,onSubmit:l,onSync:h}){const m=!!o,[d,k]=n.useState(""),[v,_]=n.useState("tag"),[P,b]=n.useState(""),[y,f]=n.useState("reviewer"),[p,D]=n.useState(!1),[x,A]=n.useState(!1),[ae,L]=n.useState(null),[z,Y]=n.useState([]),[F,U]=n.useState(null),[O,Z]=n.useState(!1),ee=gs();n.useEffect(()=>{t&&(k((o==null?void 0:o.userEmail)??""),_((o==null?void 0:o.scope)??"tag"),b(o?Ma(o):""),f((o==null?void 0:o.role)??"reviewer"),L(null))},[t,o]),n.useEffect(()=>{if(!t||v!=="document"&&v!=="tag")return;let w=!1;return Z(!0),(v==="document"?ee.fetchQuery(K.nodes(r)).then(R=>{if(w)return;const ye=Array.isArray(R==null?void 0:R.nodes)?R.nodes:[];Y(ye)}):ee.fetchQuery(K.tags(r)).then(R=>{w||(U(R),R.length===0&&!o&&_("nest"))})).catch(R=>console.error(`[StewardModal] ${v} fetch failed`,R)).finally(()=>{w||Z(!1)}),()=>{w=!0}},[t,v,r]);const re=!m||y!==o.role||v!==o.scope||P!==Ma(o),ne=async()=>{if(h){A(!0),L(null);try{await h()}catch(w){L(w instanceof Error?w.message:"Failed to sync stewards.yaml")}finally{A(!1)}}},V=async()=>{if(m&&!re){a();return}if(!m&&!d.trim()){L("Please enter an email");return}if(!m&&!Vr(d.trim())){L("Enter a valid email address.");return}if(v!=="nest"&&!P.trim()){L(`Please specify the ${v} target`);return}D(!0),L(null);try{await l({email:((o==null?void 0:o.userEmail)??d).trim(),scope:v,target:v==="nest"?void 0:P.trim(),role:y}),a()}catch(w){L(w instanceof Error?w.message:m?"Failed to update steward":"Failed to assign steward"),D(!1)}},M=p||x,q=ls[v].icon;return e.jsx(Ae,{open:t,onOpenChange:w=>!w&&!M&&a(),children:e.jsxs(Te,{className:"sm:max-w-[500px]",children:[e.jsxs(De,{children:[e.jsx(Ee,{children:m?"Edit steward":"Assign Context Steward"}),e.jsx(pt,{children:m?e.jsxs(e.Fragment,{children:["Change the role and scope for"," ",e.jsx("strong",{className:"text-foreground",children:o.userEmail}),"."]}):"Stewards can approve or reject documents within their assigned scope, ensuring quality context is available for AI."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[ae&&e.jsxs(hs,{variant:"destructive",children:[e.jsx(Ua,{className:"h-4 w-4"}),e.jsx(ps,{children:ae})]}),!m&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"email",children:"Steward Email"}),e.jsx(fo,{id:"email",value:d,onChange:k,placeholder:"reviewer@acme.com",disabled:p,testId:"steward-email-input"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{children:"Scope"}),e.jsxs(ja,{value:v,onValueChange:w=>{_(w),b("")},disabled:p,children:[e.jsx(ya,{children:e.jsx(Na,{})}),e.jsx(ka,{children:Object.entries(ls).map(([w,j])=>{const R=j.icon;return e.jsx(Pt,{value:w,disabled:w==="tag"&&(F==null?void 0:F.length)===0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),j.label]})},w)})})]})]}),v!=="nest"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Q,{htmlFor:"target",children:[e.jsx(q,{className:"h-4 w-4 inline mr-2"}),v==="tag"?"Tag":ls[v].label]}),v==="tag"?e.jsx(La,{id:"target",testId:"steward-tag-select",value:P,onChange:b,disabled:p||O,options:(F??[]).map(w=>({value:w,label:`#${w}`})),placeholder:O?"Loading tags...":(F==null?void 0:F.length)===0?"No tags in this nest":"Select a tag",searchPlaceholder:"Search tags…",emptyText:"No tag matches that."}):e.jsx(La,{id:"target",testId:"steward-document-select",value:P,onChange:b,disabled:p||O,options:z.map(w=>({value:w.id,label:w.title||w.id})),placeholder:O?"Loading documents...":z.length===0?"No documents in this nest":"Select a document",searchPlaceholder:"Search documents…",emptyText:"No document matches that."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v==="tag"?"Steward approves any document with this tag.":"Steward governs this specific document."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{children:"Role"}),e.jsxs(ja,{value:y,onValueChange:w=>f(w),disabled:p,children:[e.jsx(ya,{children:e.jsx(Na,{})}),e.jsxs(ka,{children:[e.jsx(Pt,{value:"editor",children:"Editor — can edit but not approve"}),e.jsx(Pt,{value:"reviewer",children:"Reviewer — can approve/reject"}),e.jsx(Pt,{value:"viewer",children:"Viewer — read-only access"})]})]})]})]}),e.jsxs(Ve,{className:"sm:justify-between",children:[h&&!m?e.jsxs(C,{variant:"ghost",size:"sm",onClick:ne,disabled:M,title:"Re-import steward rows from the nest's stewards.yaml",children:[x?e.jsx(ce,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Sync stewards.yaml"]}):e.jsx("span",{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{variant:"outline",onClick:a,disabled:M,children:"Cancel"}),e.jsxs(C,{onClick:V,disabled:M||!m&&!d.trim(),children:[p?e.jsx(ce,{className:"h-4 w-4 mr-2 animate-spin"}):m?null:e.jsx(bo,{className:"h-4 w-4 mr-2"}),m?"Save":"Assign Steward"]})]})]})]})})}function Oo(t){return t.normalize("NFKD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}const Ba=100;function $o(t){const a=t.split("/").map(m=>m.trim()).filter(Boolean),r=a.map(Oo).filter(Boolean).join("/"),o=r!==t.trim(),l=m=>({path:r,error:m,rewritten:o});if(a.length===0)return{path:"",error:null,rewritten:!1};if(a.some(m=>m==="."||m===".."))return l(`"." and ".." don't name a folder — use a name.`);if(!r)return l("Folder paths are built from a-z and 0-9, so the name needs at least one of those.");const h=r.split("/").length;if(h>ns){const m=h-ns;return l(`Folders may nest at most ${ns} levels deep — this path is ${h}. Remove ${m} level${m===1?"":"s"}.`)}return r.split("/").some(m=>m.length>Ba)?l(`Each folder level must be at most ${Ba} characters.`):{path:r,error:null,rewritten:o}}function Mo(){let t=!1;return{arm:()=>{t=!0},consume:()=>t?(t=!1,!0):!1}}function qo({type:t,className:a="h-4 w-4"}){const r=t==="agent"?{Icon:Hr,cls:"text-violet-600 dark:text-violet-400 bg-violet-500/10",label:"Agent"}:t==="skill"?{Icon:to,cls:"text-blue-600 dark:text-blue-400 bg-blue-500/10",label:"Skill"}:t==="artifact"?{Icon:Ao,cls:"text-amber-600 dark:text-amber-400 bg-amber-500/10",label:"Artifact"}:t==="tool"?{Icon:Bn,cls:"text-teal-600 dark:text-teal-400 bg-teal-500/10",label:"Tool"}:t==="table"?{Icon:Wn,cls:"text-cyan-600 dark:text-cyan-400 bg-cyan-500/10",label:"Table"}:t==="pdf"?{Icon:so,cls:"text-rose-600 dark:text-rose-400 bg-rose-500/10",label:"PDF"}:{Icon:ut,cls:"text-slate-500 dark:text-slate-400 bg-slate-500/10",label:"Document"};return e.jsx("span",{className:`inline-flex items-center justify-center rounded-md p-1 shrink-0 ${r.cls}`,title:r.label,children:e.jsx(r.Icon,{className:a})})}function Mi(t){switch(t){case"artifact":return{label:"HTML",title:"Hosted HTML artifact",cls:"bg-amber-100 text-amber-800 dark:bg-amber-950/40 dark:text-amber-300"};case"agent":return{label:"Agent",title:"Runnable agent node",cls:"bg-violet-100 text-violet-800 dark:bg-violet-950/40 dark:text-violet-300"};case"skill":return{label:"Skill",title:"Runnable skill node",cls:"bg-sky-100 text-sky-800 dark:bg-sky-950/40 dark:text-sky-300"};default:return null}}function Xa(t,a){const r=t.split("/"),o=a.split("/");for(let l=0;l<Math.min(r.length,o.length);l++){const h=r[l].localeCompare(o[l]);if(h!==0)return h}return r.length-o.length}function Bo(t){const a=t.startsWith("nodes/")?t.slice(6):t,r=a.lastIndexOf("/");return r>0?a.slice(0,r):""}const qi={draft:"Draft",pending_review:"Pending",published:"Published",rejected:"Rejected"},Bi={"7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days","1y":"Last year"},Wi={document:"Document",artifact:"Artifact",agent:"Agent",skill:"Skill",tool:"Tool",table:"Table"};function Wa({label:t,text:a}){const[r,o]=n.useState(!1);return e.jsxs("div",{className:"rounded-md border bg-muted/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5 border-b",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:async()=>{await Ir(a)&&(o(!0),setTimeout(()=>o(!1),1500))},children:r?e.jsxs(e.Fragment,{children:[e.jsx(Qr,{className:"h-3 w-3 mr-1"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ur,{className:"h-3 w-3 mr-1"})," Copy"]})})]}),e.jsx("pre",{className:"overflow-x-auto px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap break-words",children:a})]})}function Wo({isOpen:t,onClose:a,nestId:r,nestName:o,openMode:l}){const h=typeof window<"u"?window.location.origin:"https://your-server",m=l?"":` -H "Authorization: Bearer $CNST_KEY" \\
|
|
33
|
-
`,d=`You are helping me build a ContextNest knowledge base — a "nest":
|
|
34
|
-
a graph of small, linked context documents that AI agents read later. You can
|
|
35
|
-
write to it over HTTP. Nest: "${o}".
|
|
36
|
-
|
|
37
|
-
STEP 1 — Interview me first. Do NOT create anything yet. Ask me:
|
|
38
|
-
• What body of knowledge should go in here? (sources, docs, transcripts, URLs, topics)
|
|
39
|
-
• Who/what will use this nest, and for what? (purpose drives how granular to go)
|
|
40
|
-
• What's authoritative vs. rough, and is there anything to leave out?
|
|
41
|
-
• How do I want it organized — by topic, project, client/entity, or timeline?
|
|
42
|
-
Ask follow-ups until you actually understand the material and my intent.
|
|
43
|
-
|
|
44
|
-
STEP 2 — Propose an organization and wait for my OK. Give me a short plan:
|
|
45
|
-
the main topic areas, a consistent tagging scheme, a node-naming convention, and
|
|
46
|
-
roughly how many nodes. Adjust based on my feedback before writing anything.
|
|
47
|
-
|
|
48
|
-
STEP 3 — Create the nodes, organized for retrieval (not prose):
|
|
49
|
-
• One idea per node; keep each tight (~100–300 words). Prefer many small linked
|
|
50
|
-
nodes over one big dump.
|
|
51
|
-
• Clear, specific titles; 3–6 consistent lower-case tags per node.
|
|
52
|
-
• Connect related nodes with [[Wiki Links]] (use the other node's title) so the
|
|
53
|
-
graph is traversable.
|
|
54
|
-
• type "document" for markdown; type "artifact" with raw HTML for self-contained
|
|
55
|
-
pages (decks, dashboards, infographics).
|
|
56
|
-
|
|
57
|
-
API — create one node per POST:
|
|
58
|
-
POST ${h}/nests/${r}/nodes
|
|
59
|
-
Content-Type: application/json${l?"":`
|
|
60
|
-
Authorization: Bearer <MY_API_KEY> # mint one via Connect; omit if the server is in open mode`}
|
|
61
|
-
Body: {
|
|
62
|
-
"title": "<short, specific title>",
|
|
63
|
-
"content": "<markdown body, with [[Wiki Links]] to related nodes>",
|
|
64
|
-
"type": "document",
|
|
65
|
-
"tags": ["<tag>", "<tag>"]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
After each create, report the node id. At the end, give me a short map of what
|
|
69
|
-
you created and how it's organized.
|
|
70
|
-
|
|
71
|
-
Begin at STEP 1 by interviewing me about what to put in this nest.`,k=`curl -X POST ${h}/nests/${r}/nodes \\
|
|
72
|
-
${m} -H "Content-Type: application/json" \\
|
|
73
|
-
-d '{"title":"My note","content":"# Hello\\n\\nSome context…","type":"document","tags":["demo"]}'`;return e.jsx(Ae,{open:t,onOpenChange:a,children:e.jsxs(Te,{className:"sm:max-w-[640px] max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs(De,{children:[e.jsxs(Ee,{className:"flex items-center gap-2",children:[e.jsx(Ia,{className:"h-4 w-4 text-primary"}),"Generate & add context to ",o]}),e.jsx(pt,{children:"Have Claude, Codex, or any agent generate context and push it straight into this nest via the API — no copy-pasting documents by hand."})]}),e.jsxs("div",{className:"space-y-4 overflow-y-auto pr-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"1. Paste this into Claude / Codex"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"It interviews you about what to ingest, proposes an organization (topics, tags, links), then creates well-structured nodes — it won't just dump one big doc."}),e.jsx(Wa,{label:"Prompt for your agent",text:d})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"2. Or call the API directly"}),e.jsx(Wa,{label:"curl",text:k})]}),!l&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border bg-card p-3 text-xs text-muted-foreground",children:[e.jsx(_a,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsxs("span",{children:["Writes need an API key (",e.jsx("code",{children:"Bearer cnst_*"}),"). Mint one in"," ",e.jsx("strong",{children:"Connect"})," — it's shown once; set it as"," ",e.jsx("code",{children:"$CNST_KEY"})," for the snippets above."]})]}),l&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 dark:bg-amber-950/20 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx(_a,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsxs("span",{children:["Server is in ",e.jsx("strong",{children:"open"})," mode — no API key needed; anyone on the network can write. Lock it down before exposing it."]})]})]})]})})}function zo(t){const a=new Map;for(const r of t){const o=r.id||"",l=o.startsWith("nodes/")?o.slice(6):o,h=l.lastIndexOf("/"),m=h>0?l.slice(0,h):"Root";a.has(m)||a.set(m,[]),a.get(m).push(r)}return[...a.entries()].map(([r,o])=>({folder:r,depth:r==="Root"?0:r.split("/").length,items:[...o].sort((l,h)=>String(l.title||l.id).localeCompare(String(h.title||h.id)))})).sort((r,o)=>r.folder==="Root"?-1:o.folder==="Root"?1:Xa(r.folder,o.folder))}const za=(t,a,r=`${a}s`)=>`${t} ${t===1?a:r}`;function zi(t){const a=[{key:"documents",text:za(t.total,"document")}];t.folderCount>0&&a.push({key:"folders",text:za(t.folderCount,"folder")}),t.editedThisWeek>0&&a.push({key:"edited",text:`${t.editedThisWeek} edited this week`});const r=t.governance;return r&&(a.push({key:"ai-ready",text:`${r.approved} AI ready`,...r.approved>0?{tone:"ok"}:{}}),r.pending>0&&a.push({key:"pending",text:`${r.pending} pending review`,tone:"warn"}),r.reviewable>0&&a.push({key:"review",text:`${r.reviewable} waiting on your review`,action:"review"})),a}function Vi(t){const a=[];return t.canWrite&&a.push("new"),t.canWrite&&t.canImport&&a.push("import"),t.canAddWithAI&&a.push("ai"),a}function Hi(t,a,r){return a.get(t)??!r.has(t)}function Qi(t,a,r){return t.filter(o=>o.path&&!o.path.includes("/")&&o.total>0).sort((o,l)=>Xa(o.path,l.path)).slice(0,r).map(o=>o.path).filter(o=>!a.has(o))}function Ui(t,a){return t.map(r=>{if(r.folder==="Root"||r.items.length<=a)return r;const o={id:`more:${r.folder}`,more:{folder:r.folder,hidden:r.items.length-a,total:r.items.length}};return{...r,items:[...r.items.slice(0,a),o]}})}function Vo(t){const a=n.useMemo(()=>typeof window<"u"&&window.matchMedia?window.matchMedia(t):null,[t]),r=n.useCallback(o=>a?(a.addEventListener("change",o),()=>a.removeEventListener("change",o)):()=>{},[a]);return n.useSyncExternalStore(r,()=>(a==null?void 0:a.matches)??!1,()=>!1)}function Ho({nestId:t,nestName:a,stewardshipEnabled:r,allowSelfApprove:o,primeOnlyReview:l,primeTags:h,creatorIsReviewer:m,canManageStewardship:d,onClose:k,onChanged:v}){const[_,P]=n.useState(r),[b,y]=n.useState(o),[f,p]=n.useState(l),[D,x]=n.useState(h.join(", ")),[A,ae]=n.useState(m),[L,z]=n.useState(!1),[Y,F]=n.useState(null),[U,O]=n.useState(!1),Z=r&&!_,ee=_&&f,re=[...new Set(D.split(",").map(V=>V.trim().replace(/^#+/,"").toLowerCase()).filter(Boolean))],ne=async()=>{const V=_!==r,M=b!==o,q=f!==l,w=re.join(",")!==h.join(","),j=A!==m;if(!V&&!M&&!q&&!w&&!j){k();return}z(!0),F(null);try{const R=await Kr(t,{...V?{stewardship_enabled:_}:{},...M?{allow_self_approve:b}:{},...q?{prime_only_review:f}:{},...w?{prime_tags:re}:{},...j?{creator_is_reviewer:A}:{}});if(R.stewardship_enabled!==_||R.allow_self_approve!==b||R.prime_only_review!==f||R.creator_is_reviewer!==A){F("Server did not accept the change. You may not have permission to change these settings."),z(!1);return}v({stewardshipEnabled:R.stewardship_enabled,allowSelfApprove:R.allow_self_approve,primeOnlyReview:R.prime_only_review,primeTags:R.prime_tags,creatorIsReviewer:R.creator_is_reviewer})}catch(R){F(R.message),z(!1)}};return e.jsx(Ae,{open:!0,onOpenChange:k,children:e.jsxs(Te,{className:"sm:max-w-[500px] flex flex-col max-h-[85vh]",children:[e.jsxs(De,{children:[e.jsxs(Ee,{children:["Settings: ",a]}),e.jsx(pt,{children:"Admin controls for this nest. Changes apply to all future documents."})]}),e.jsxs("div",{className:"space-y-4 py-2 flex-1 min-h-0 overflow-y-auto pr-1",children:[Y&&e.jsxs(hs,{variant:"destructive",children:[e.jsx(Ua,{className:"h-4 w-4"}),e.jsx(ps,{children:Y})]}),d&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Q,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx($t,{className:"h-4 w-4"}),"Stewardship & Approval Workflow"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Require steward approval before documents become AI-ready. New documents will start as ",e.jsx("strong",{children:"drafts"}),". This also changes what “publishing” means in this nest: with stewardship on, the document editor shows",e.jsx("em",{children:" Publish (requires approval)"}),"; with it off, saving auto-publishes and an ",e.jsx("em",{children:"Auto-published"})," badge appears next to the title."]})]}),e.jsx(ze,{checked:_,onCheckedChange:P})]}),!_&&!Z&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(at,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"Currently off."})," New documents are auto-approved and immediately available to AI. Versioning is still on — every edit creates a new version."]})]}),Z&&e.jsxs(hs,{variant:"destructive",className:"pt-2",children:[e.jsx(Gr,{className:"h-4 w-4"}),e.jsxs(ps,{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Disabling stewardship removes governance."})," ","All steward assignments and pending review requests for this nest will be deleted, and new documents become auto-approved. Collaborator access is kept — manage it from Share. Approved/rejected review history is kept."]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:V=>O(V.target.checked),className:"h-3.5 w-3.5"}),"I understand this will remove all stewards."]})]})]}),_&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(at,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"When enabled:"})," New documents start as drafts. Assigned stewards must approve before they're available to AI queries. Existing approved documents stay approved."]})]})]}),d&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Q,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(zn,{className:"h-4 w-4"}),"Auto-publish owner & admin edits"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Default off. When enabled, edits by an owner or admin publish immediately — their changes skip the review queue instead of waiting for approval. Editors and reviewers are unaffected: they still submit drafts for review as usual. Turning this back off only changes future behavior; it doesn't unpublish anything. Audit logs still record every actor."})]}),e.jsx(ze,{checked:b,onCheckedChange:y,disabled:ee})]}),ee&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(at,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"No effect right now."})," ","“Review prime documents only” is on, so every non-prime document already self-publishes for everyone — and prime documents always need approval, including from owners and admins. Turn prime-only review off to use this bypass."]})]}),_&&!ee&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(at,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"Prime wins."})," A document flagged prime (or carrying a prime tag) always goes through review, even for an owner or admin with this on."]})]})]}),d&&_&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Q,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Vn,{className:"h-4 w-4"}),"Review prime documents only"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Default off. When enabled, day-to-day content self-publishes and only ",e.jsx("strong",{children:"prime"})," documents go through draft → pending → approved. Prime always wins: a prime document needs approval even from an owner or admin with auto-publish on, and turning this on makes the auto-publish bypass above redundant."]})]}),e.jsx(ze,{checked:f,onCheckedChange:p})]}),e.jsxs("div",{className:"space-y-1 pt-2 border-t",children:[e.jsx(Q,{className:"text-xs font-medium",children:"Prime tags"}),e.jsx(xt,{value:D,onChange:V=>x(V.target.value),placeholder:"prime-document, messaging-architecture"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Comma-separated. Any document carrying one of these tags is prime. A single document can also be flagged directly from its editor, which overrides its tags."})]})]}),d&&_&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Q,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Fo,{className:"h-4 w-4"}),"Creators review their own documents"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Default off. When enabled, whoever creates a document becomes its ",e.jsx("strong",{children:"reviewer"})," and the first version publishes right away. Changes by anyone else go to the creator for approval; the creator’s own later edits go to the nest’s other reviewers. Applies to documents created from now on — existing documents keep their stewards."]})]}),e.jsx(ze,{checked:A,onCheckedChange:ae})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(at,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"Prime wins."})," A prime document still starts as a draft — its creator is made its reviewer, but someone else has to approve the first version."]})]})]})]}),e.jsxs(Ve,{children:[e.jsx(C,{variant:"outline",onClick:k,disabled:L,children:"Cancel"}),e.jsx(C,{onClick:ne,disabled:L||Z&&!U,children:L?e.jsx(ce,{className:"h-4 w-4 animate-spin"}):"Save Settings"})]})]})})}function Ft(t){let a=t.trim().replace(/^\/+/,"").replace(/\.md$/i,"");return a.startsWith("nodes/")||(a=`nodes/${a}`),a.toLowerCase()}function Qo(t,a){const r=t.trim();if(!r)return null;if(r.includes("/")){const l=Ft(r),h=a.find(k=>Ft(k.id)===l);if(h)return h;const m=l.split("/").pop()??"",d=a.filter(k=>Ft(k.id).endsWith(`/${m}`));return d.length===1?d[0]:null}const o=r.toLowerCase();return a.find(l=>String(l.title??"").toLowerCase()===o)??a.find(l=>Ft(l.id).endsWith(`/${o}`))??null}function Ja(t){return t.split(/[-_]/).map(a=>a&&a[0].toUpperCase()+a.slice(1)).join(" ")}function Uo(t){return!t||t==="Root"?"General":Ja(t.split("/").filter(Boolean).pop()??t)}function Va(t){return t.replace(/^nodes\//,"").split("/").filter(Boolean).slice(0,-1).map(Ja)}const fs=/^(overview|index|readme|welcome|home)$/i;function ws(t){return t.split("/").pop()??t}function Io(t,a){const r=ws(t.id).toLowerCase(),o=(a.split("/").filter(Boolean).pop()??"").toLowerCase();return fs.test(r)||fs.test(String(t.title??""))||!!o&&r===o}function Za(t,a){const r=a.filter(o=>Io(o,t));return[...r,...a.filter(o=>!r.includes(o))]}function Go(t){return t.flatMap(a=>Za(a.folder,a.items))}function Ko(t,a){const r=t.findIndex(o=>o.id===a);return r<0?{prev:null,next:null}:{prev:t[r-1]??null,next:t[r+1]??null}}function Yo(t,a){if(!a)return t;const r=t.match(/^\s*#[ \t]+(.+?)[ \t]*#*[ \t]*(?:\r?\n|$)/);if(!r)return t;const o=l=>l.replace(/[*_`]/g,"").trim().toLowerCase();return o(r[1])===o(a)?t.slice(r[0].length):t}function Xo(t,a=[]){const r=new Set;for(const l of t)l.folder&&l.folder!=="Root"&&r.add(l.folder.split("/")[0]);for(const l of a)l.path&&r.add(l.path.split("/")[0]);const o=t.some(l=>!l.folder||l.folder==="Root");return r.size===1&&!o?[...r][0]:""}function Jo(t,a){if(!t)return"";const r=String(t.title??"").trim()||ws(t.id);if(!a||!fs.test(r))return r;const o=a.match(/^\s*#[ \t]+(.+?)[ \t]*#*[ \t]*(?:\r?\n|$)/);return o?o[1].replace(/[*_`]/g,"").trim():r}function er(t){const a=t.replace(/^nodes\//,"").split("/").filter(Boolean).slice(0,-1);return a.map((r,o)=>a.slice(0,o+1).join("/"))}function Zo(t){return new Set(["",...t.flatMap(a=>er(a.id||""))])}const Ha="lg:min-h-0 lg:overflow-y-auto",cs="rounded-lg border border-border bg-card p-4";function ei(t,a){const r=a.trim().toLowerCase().replace(/^#/,"");return r?t.filter(o=>String(o.title||ws(o.id)).toLowerCase().includes(r)||(o.tags??[]).some(l=>String(l).toLowerCase().replace(/^#/,"").includes(r))):null}const ti=["welcome","index","readme","home","overview"];function si({nestId:t,nestName:a,nodes:r,tocGroups:o,knownFolders:l,readerHomeNode:h,initialDoc:m,onDocChange:d,onExpandFolder:k,loadingFolders:v,loadedFolders:_,approvedOnly:P=!1,branding:b=null}){const y=mt(b),f=n.useMemo(()=>{if(h){const c=r.find(u=>Yr(u,h));if(c)return c}for(const c of ti){const u=r.find($=>Xr($).includes(c));if(u)return u}return null},[r,h]),[p,D]=n.useState(()=>m??(f==null?void 0:f.id)??null),x=c=>{D(c),d==null||d(c),w(!1),M(null)};n.useEffect(()=>{!p&&f&&D(f.id)},[f,p]),n.useEffect(()=>{D(m??(f==null?void 0:f.id)??null)},[m]);const[A,ae]=n.useState({}),[L,z]=n.useState({}),[Y,F]=n.useState(null),U=n.useRef(new Set),O=async c=>{if(!(A[c]!==void 0||U.current.has(c))){U.current.add(c),F(c);try{const{node:u}=await Zr(t,c,P);ae($=>({...$,[c]:(u==null?void 0:u.content)??""})),(u==null?void 0:u.type)==="pdf"&&(u!=null&&u.pdf)&&z($=>({...$,[c]:u.pdf}))}catch{M("This page could not be loaded.")}finally{U.current.delete(c),F(u=>u===c?null:u)}}};n.useEffect(()=>{p&&O(p)},[p,t]);const[Z,ee]=n.useState(()=>new Map),re=c=>Z.get(c)??!(_!=null&&_.has(c)),ne=c=>{const u=re(c);ee($=>new Map($).set(c,!u)),u&&k(c)};n.useEffect(()=>{if(!p)return;const c=er(p);if(c.length!==0){ee(u=>{const $=new Map(u);for(const he of c)$.set(he,!1);return $});for(const u of c)_!=null&&_.has(u)||k(u)}},[p]);const[V,M]=n.useState(null),[q,w]=n.useState(!1),[j,R]=n.useState(""),ye=n.useMemo(()=>ei(r,j),[r,j]),ft=c=>{const u=Qo(c,r);u?x(u.id):M(`No page called “${c}” in this nest.`)},ve=p?r.find(c=>c.id===p):null,Ie=p?A[p]:void 0,oe=Jo(ve,Ie),de=Ie===void 0?void 0:Yo(Ie,oe),Pe=!!p&&de===void 0&&Y===p,gt=n.useMemo(()=>de?Hn(de):[],[de]),vt=n.useMemo(()=>Go(o),[o]),{prev:ie,next:ue}=p?Ko(vt,p):{prev:null,next:null},Le=p?Va(p):[],me=c=>{var he;const u=document.getElementById(c);if(!u)return;const $=(he=window.matchMedia)==null?void 0:he.call(window,"(prefers-reduced-motion: reduce)").matches;u.scrollIntoView({behavior:$?"auto":"smooth",block:"start"})},Mt=n.useMemo(()=>Xo(o,l),[o,l]),bt=n.useMemo(()=>o.map(c=>({...c,items:Za(c.folder,c.items)})),[o]),T=e.jsx(en,{className:"space-y-px",groups:bt,baseFolder:Mt||void 0,known:l,isCollapsed:re,renderFolder:(c,{collapsed:u})=>e.jsxs("button",{type:"button",onClick:()=>ne(c.path),"aria-expanded":!u,className:"flex w-full items-center gap-1.5 py-1.5 pr-2 text-left text-[13px] font-medium text-foreground/80 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 rounded-sm",children:[u?e.jsx(Sa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(tn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),u?e.jsx(sn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(an,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:Uo(c.path)}),(v==null?void 0:v.has(c.path))&&e.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:"loading"})]}),renderDoc:c=>{const u=p===c.id;return e.jsxs("button",{type:"button",onClick:()=>x(c.id),"aria-current":u?"page":void 0,className:"flex w-full items-center gap-1.5 rounded-md py-1 pl-2 pr-2 text-left text-[13px] leading-5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 "+(u?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),title:c.title||c.id,children:[e.jsx(ut,{className:"h-3.5 w-3.5 shrink-0 opacity-70"}),e.jsx("span",{className:"truncate",children:c.title||c.id})]})}}),Ge=e.jsxs("div",{className:"mx-auto w-full max-w-[88rem] lg:grid lg:h-[calc(100vh-9.25rem-var(--reader-offset,0px)-var(--reader-banner,0px))] lg:grid-cols-[16rem_minmax(0,1fr)_14rem] lg:gap-5",children:[e.jsxs("aside",{className:Ha+" "+cs+" mb-4 lg:mb-0",children:[e.jsxs("button",{type:"button",onClick:()=>w(c=>!c),"aria-expanded":q,className:"lg:hidden inline-flex items-center gap-2 text-sm font-medium py-2",children:[e.jsx(Do,{className:"h-4 w-4"}),"Contents"]}),e.jsxs("div",{className:(q?"block":"hidden")+" lg:block",children:[e.jsx("h2",{className:"mb-3 border-b pb-3",children:e.jsxs("button",{type:"button",onClick:()=>f&&x(f.id),disabled:!f,"aria-current":f&&p===f.id?"page":void 0,title:a,className:"flex w-full items-center gap-2 text-left text-base font-bold tracking-tight focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 rounded-sm disabled:cursor-default "+(f&&p!==f.id?"text-foreground/80 hover:text-foreground":"text-foreground"),children:[e.jsx(Ga,{className:"h-5 w-5 shrink-0 text-primary"}),e.jsx("span",{className:"truncate",children:a})]})}),e.jsxs("label",{className:"relative mb-3 block",children:[e.jsx(Jr,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"text",value:j,onChange:c=>R(c.target.value),placeholder:"Search by title or tag","aria-label":"Search pages by title or tag",className:"h-8 w-full rounded-md border border-input bg-background pl-8 pr-7 text-[13px] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"}),j&&e.jsx("button",{type:"button",onClick:()=>R(""),"aria-label":"Clear search",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground",children:e.jsx(Ya,{className:"h-3.5 w-3.5"})})]}),ye?ye.length===0?e.jsx("p",{className:"px-2 text-[13px] text-muted-foreground/70",children:"No pages match."}):e.jsx("ul",{className:"space-y-px",children:ye.map(c=>{const u=p===c.id,$=Va(c.id).join(" / ");return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>x(c.id),"aria-current":u?"page":void 0,title:c.title||c.id,className:"flex w-full items-start gap-1.5 rounded-md py-1 pl-2 pr-2 text-left text-[13px] leading-5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 "+(u?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[e.jsx(ut,{className:"mt-[3px] h-3.5 w-3.5 shrink-0 opacity-70"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:c.title||c.id}),$&&e.jsx("span",{className:"block truncate text-[11px] font-normal text-muted-foreground/70",children:$})]})]})},c.id)})}):T]})]}),e.jsxs("article",{className:"min-w-0 "+cs+" px-6 py-6 lg:min-h-0 lg:overflow-y-auto lg:px-8",children:[V&&e.jsxs("p",{role:"status",className:"mb-4 text-sm text-amber-800 dark:text-amber-300",children:[V,p&&A[p]===void 0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:()=>{M(null),O(p)},children:"Try again"})]})]}),ve&&e.jsxs("header",{className:"mb-6",children:[Le.length>0&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-2 truncate text-[13px] text-muted-foreground",title:Le.join(" / "),children:Le.map((c,u)=>e.jsxs("span",{children:[u>0&&e.jsx("span",{"aria-hidden":!0,className:"mx-1.5 text-muted-foreground/60",children:"/"}),c]},u))}),e.jsx("h1",{className:"break-words text-[2rem] leading-[1.15] font-semibold tracking-tight text-foreground",children:oe}),e.jsx(oi,{node:ve})]}),!p&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a page from the contents."}),Pe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}),p&&de!==void 0&&L[p]&&e.jsx(Qn,{nestId:t,nodeId:p,title:oe,pdf:L[p],approvedOnly:P}),p&&de!==void 0&&e.jsx(Un,{content:de,onWikiLinkClick:ft,plainLinks:!0,className:"max-w-none px-0 py-0 min-h-0 max-h-none overflow-visible prose-base prose-headings:scroll-mt-24 prose-h2:mt-10 prose-h2:text-xl prose-h3:text-base prose-p:leading-7 prose-pre:rounded-sm prose-code:before:content-none prose-code:after:content-none"}),(ie||ue)&&e.jsxs("nav",{"aria-label":"Previous and next pages",className:"mt-14 grid grid-cols-2 gap-4 border-t pt-6 text-sm",children:[e.jsx("div",{className:"min-w-0",children:ie&&e.jsxs("button",{type:"button",onClick:()=>x(ie.id),title:ie.title||ie.id,className:"group flex w-full items-center gap-3 rounded-lg border px-4 py-3 text-left hover:border-primary/60 hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",children:[e.jsx(ao,{className:"h-4 w-4 shrink-0 text-muted-foreground group-hover:text-primary"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Previous"}),e.jsx("span",{className:"block truncate font-medium text-foreground group-hover:text-primary",children:ie.title||ie.id})]})]})}),e.jsx("div",{className:"min-w-0",children:ue&&e.jsxs("button",{type:"button",onClick:()=>x(ue.id),title:ue.title||ue.id,className:"group flex w-full items-center justify-end gap-3 rounded-lg border px-4 py-3 text-right hover:border-primary/60 hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Next"}),e.jsx("span",{className:"block truncate font-medium text-foreground group-hover:text-primary",children:ue.title||ue.id})]}),e.jsx(Sa,{className:"h-4 w-4 shrink-0 text-muted-foreground group-hover:text-primary"})]})})]})]}),e.jsx("aside",{className:"hidden lg:block "+Ha+" "+cs,children:e.jsxs("nav",{"aria-label":"On this page",children:[e.jsx("p",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wide text-muted-foreground",children:"On this page"}),gt.length===0?e.jsx("p",{className:"text-[13px] text-muted-foreground/70",children:p?"No headings yet.":"Open a page to see its headings."}):e.jsx("ul",{className:"space-y-1",children:gt.map(c=>e.jsx("li",{style:{paddingLeft:(c.level-1)*12},children:e.jsx("button",{type:"button",onClick:()=>me(c.id),className:"block w-full truncate text-left text-[13px] leading-5 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 rounded-sm",title:c.text,children:c.text})},c.id))})]})})]});if(!y)return Ge;const Ne=!!(b.banner_url||b.banner_headline)&&(!f||p===f.id);return e.jsxs("div",{"data-reader-branded":"",style:{...vs(b,ai()),...Ne?{"--reader-banner":"11rem"}:{}},children:[e.jsx(ri,{branding:b,nestName:a,pageTitle:ve?oe:null}),Ne&&e.jsx(ni,{branding:b}),Ge]})}function ai(){return typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function ri({branding:t,nestName:a,pageTitle:r}){const o=nn(r,t,a);n.useEffect(()=>{const h=document.title;return document.title=o,()=>{document.title=h}},[o]);const l=t.favicon_url||null;return n.useEffect(()=>{if(!l)return;const h=document.querySelector('link[rel="icon"]');if(!h)return;const m=h.href;return h.href=l,()=>{h.href=m}},[l]),null}function ni({branding:t}){const a=t.banner_url||null,r=!!t.accent_color;return e.jsxs("section",{"aria-label":t.banner_headline||t.site_title||"Banner",className:"relative mx-auto mb-4 flex h-28 w-full max-w-[88rem] flex-col justify-end overflow-hidden rounded-lg border px-5 py-4 sm:h-36 sm:px-8 lg:h-40",style:a?{backgroundImage:Ka(a),backgroundSize:"cover",backgroundPosition:"center",color:"#ffffff"}:{background:r?"var(--reader-accent)":"hsl(var(--primary))",color:r?"var(--reader-accent-fg)":"hsl(var(--primary-foreground))"},children:[a&&e.jsx("div",{"aria-hidden":!0,className:"absolute inset-0 bg-gradient-to-t from-black/65 via-black/25 to-black/0"}),a&&r&&e.jsx("div",{"aria-hidden":!0,className:"absolute inset-x-0 bottom-0 h-1",style:{background:"var(--reader-accent)"}}),t.banner_headline&&e.jsx("h2",{className:"relative max-w-3xl truncate text-xl font-semibold tracking-tight sm:text-2xl lg:text-3xl",children:t.banner_headline}),t.banner_subtext&&e.jsx("p",{className:"relative mt-1 line-clamp-2 max-w-3xl text-sm opacity-90 sm:text-base",children:t.banner_subtext})]})}function oi({node:t}){const a=String(t.status||"draft"),r=t.updated_at?rn(t.updated_at):null;return e.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-[13px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block h-1.5 w-1.5 rounded-full "+(a==="published"?"bg-emerald-500":"bg-amber-500")}),a==="published"?"Published":a.replace(/_/g," ")]}),t.version!=null&&e.jsxs("span",{children:["Version ",t.version]}),r&&e.jsxs("span",{children:["Updated ",r]})]})}const ii="image/png,image/jpeg,image/webp,image/gif";function Qa(t){return{logo_url:(t==null?void 0:t.logo_url)??"",banner_url:(t==null?void 0:t.banner_url)??"",banner_headline:(t==null?void 0:t.banner_headline)??"",banner_subtext:(t==null?void 0:t.banner_subtext)??"",accent_color:(t==null?void 0:t.accent_color)??"",header_bg_color:(t==null?void 0:t.header_bg_color)??"",page_tint_color:(t==null?void 0:t.page_tint_color)??"",site_title:(t==null?void 0:t.site_title)??"",footer_text:(t==null?void 0:t.footer_text)??"",footer_link_url:(t==null?void 0:t.footer_link_url)??"",footer_link_label:(t==null?void 0:t.footer_link_label)??"",favicon_url:(t==null?void 0:t.favicon_url)??"",hide_powered_by:!!(t!=null&&t.hide_powered_by)}}function tr(t){const a={};for(const[r,o]of Object.entries(t))typeof o=="string"&&o.trim()!==""&&(a[r]=o.trim());return t.hide_powered_by&&(a.hide_powered_by=!0),mt(a)?a:null}function li({open:t,onOpenChange:a,nestId:r,nestName:o,branding:l,isServerAdmin:h,onSaved:m}){const[d,k]=n.useState(()=>Qa(l)),[v,_]=n.useState(!1),[P,b]=n.useState(null);n.useEffect(()=>{t&&(k(Qa(l)),b(null))},[t,l]);const y=(x,A)=>k(ae=>({...ae,[x]:A})),f=n.useMemo(()=>on(d,r),[d,r]),p=Object.keys(f).length>0,D=async x=>{_(!0),b(null);try{const A=await cn(r,x);m(A.branding),S.success(A.branding?"Branding saved":"Branding reset to default"),a(!1)}catch(A){b((A==null?void 0:A.message)||"Could not save branding")}finally{_(!1)}};return e.jsx(Ae,{open:t,onOpenChange:a,children:e.jsxs(Te,{className:"flex max-h-[92vh] flex-col sm:max-w-[1040px]",children:[e.jsxs(De,{children:[e.jsx(Ee,{children:"Reader branding"}),e.jsx(pt,{children:"How this nest looks to people reading it in reader mode and on its published /p links. Colors adjust their text automatically so everything stays readable."})]}),e.jsxs("div",{className:"-mx-4 grid min-h-0 flex-1 gap-6 overflow-y-auto border-y px-4 py-4 sm:-mx-6 sm:px-6 md:grid-cols-[minmax(0,1fr)_minmax(0,26rem)]",children:[e.jsxs("div",{className:"min-w-0 space-y-5",children:[e.jsxs(Ot,{title:"Identity",children:[e.jsx(Be,{label:"Site title",hint:`Shown in the header and the browser tab. Defaults to “${o}”.`,value:d.site_title,max:rt.site_title,error:f.site_title,onChange:x=>y("site_title",x),placeholder:o}),e.jsx(us,{label:"Logo",hint:"Header logo. Falls back to the server logo.",nestId:r,value:d.logo_url,error:f.logo_url,onChange:x=>y("logo_url",x)}),e.jsx(us,{label:"Favicon",hint:"Browser tab icon while reading. Optional.",nestId:r,value:d.favicon_url,error:f.favicon_url,onChange:x=>y("favicon_url",x)})]}),e.jsxs(Ot,{title:"Banner",children:[e.jsx(us,{label:"Banner image",hint:"Wide image at the top of the home page. Around 1600×400 works well.",nestId:r,value:d.banner_url,error:f.banner_url,onChange:x=>y("banner_url",x)}),e.jsx(Be,{label:"Headline",value:d.banner_headline,max:rt.banner_headline,error:f.banner_headline,onChange:x=>y("banner_headline",x),placeholder:"Welcome to the Acme handbook"}),e.jsx(Be,{label:"Subtext",value:d.banner_subtext,max:rt.banner_subtext,error:f.banner_subtext,onChange:x=>y("banner_subtext",x),placeholder:"Policies, playbooks and how we work."})]}),e.jsxs(Ot,{title:"Colors",children:[e.jsx(ds,{label:"Accent",hint:"Links, the current page, buttons, and the banner when it has no image.",value:d.accent_color,error:f.accent_color,onChange:x=>y("accent_color",x)}),e.jsx(ds,{label:"Header background",value:d.header_bg_color,error:f.header_bg_color,onChange:x=>y("header_bg_color",x)}),e.jsx(ds,{label:"Page tint",hint:"A light wash of this color behind the reader. Optional.",value:d.page_tint_color,error:f.page_tint_color,onChange:x=>y("page_tint_color",x)})]}),e.jsxs(Ot,{title:"Footer",children:[e.jsx(Be,{label:"Footer text",value:d.footer_text,max:rt.footer_text,error:f.footer_text,onChange:x=>y("footer_text",x),placeholder:"© Acme Corp"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(Be,{label:"Footer link",value:d.footer_link_url,error:f.footer_link_url,onChange:x=>y("footer_link_url",x),placeholder:"https://acme.example.com"}),e.jsx(Be,{label:"Link label",value:d.footer_link_label,max:rt.footer_link_label,error:f.footer_link_label,onChange:x=>y("footer_link_label",x),placeholder:"acme.example.com"})]}),h?e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Q,{htmlFor:"brand-hide-powered",className:"text-sm font-medium",children:"Hide “Powered by ContextNest”"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Server admin only. Also hides “Secured by PromptOwl” on /p pages."})]}),e.jsx(ze,{id:"brand-hide-powered",checked:d.hide_powered_by,onCheckedChange:x=>y("hide_powered_by",x)})]}):d.hide_powered_by&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"“Powered by ContextNest” is hidden by the server admin."})]})]}),e.jsxs("div",{className:"min-w-0 md:sticky md:top-0 md:self-start",children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Live preview"}),e.jsx(di,{draft:d,nestName:o}),e.jsx(ui,{draft:d})]})]}),P&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:P}),e.jsxs(Ve,{className:"gap-2 sm:gap-2",children:[e.jsxs(C,{variant:"ghost",className:"mr-auto gap-1.5",onClick:()=>void D(null),disabled:v||!mt(l),title:"Remove all branding — the reader goes back to the default look",children:[e.jsx(In,{className:"h-3.5 w-3.5"}),"Reset to default"]}),e.jsx(C,{variant:"outline",onClick:()=>a(!1),disabled:v,children:"Cancel"}),e.jsxs(C,{onClick:()=>void D(tr(d)),disabled:v||p,children:[v&&e.jsx(ce,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Save branding"]})]})]})})}function Ot({title:t,children:a}){return e.jsxs("fieldset",{className:"space-y-3 rounded-lg border p-4",children:[e.jsx("legend",{className:"px-1 text-sm font-semibold",children:t}),a]})}function js({label:t,hint:a,error:r,htmlFor:o,children:l}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Q,{htmlFor:o,className:"text-[13px] font-medium",children:t}),l,r?e.jsx("p",{className:"text-xs text-destructive",children:r}):a?e.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null]})}let ci=0;function ys(t){const a=n.useRef();return a.current||(a.current=`${t}-${++ci}`),a.current}function Be({label:t,hint:a,value:r,onChange:o,error:l,max:h,placeholder:m}){const d=ys("brand-text");return e.jsx(js,{label:t,hint:a,error:l,htmlFor:d,children:e.jsx(xt,{id:d,value:r,onChange:k=>o(k.target.value),maxLength:h,placeholder:m,"aria-invalid":!!l,className:"h-9"})})}function ds({label:t,hint:a,value:r,onChange:o,error:l}){const h=ys("brand-color"),m=ht(r);return e.jsx(js,{label:t,hint:a,error:l,htmlFor:h,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color","aria-label":`${t} color picker`,value:m??"#000000",onChange:d=>o(d.target.value),className:"h-9 w-11 shrink-0 cursor-pointer rounded-md border border-input bg-background p-1"}),e.jsx(xt,{id:h,value:r,onChange:d=>o(d.target.value.trim()),placeholder:"#1e40af",maxLength:7,"aria-invalid":!!l,className:"h-9 w-32 font-mono"}),r&&e.jsx(C,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-muted-foreground",onClick:()=>o(""),children:"Clear"})]})})}function us({label:t,hint:a,value:r,onChange:o,error:l,nestId:h}){const m=ys("brand-img"),d=n.useRef(null),[k,v]=n.useState(!1),_=async b=>{if(b){if(!/\.(png|jpe?g|gif|webp)$/i.test(b.name)){S.error("Use a PNG, JPG, GIF or WebP image");return}v(!0);try{const y=await dn(h,b);o(y.url)}catch(y){S.error((y==null?void 0:y.message)||"Upload failed")}finally{v(!1),d.current&&(d.current.value="")}}},P=r&&!l;return e.jsx(js,{label:t,hint:a,error:l,htmlFor:m,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded-md border bg-muted/40",children:P?e.jsx("img",{src:r,alt:"",className:"h-full w-full object-contain"}):e.jsx(Gn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(xt,{id:m,value:r,onChange:b=>o(b.target.value),placeholder:"Upload, or paste an https:// image link","aria-invalid":!!l,className:"h-9 min-w-0 flex-1"}),e.jsx("input",{ref:d,type:"file",accept:ii,className:"hidden",onChange:b=>{var y;return void _((y=b.target.files)==null?void 0:y[0])}}),e.jsx(C,{type:"button",variant:"outline",size:"sm",className:"h-9 shrink-0",onClick:()=>{var b;return(b=d.current)==null?void 0:b.click()},disabled:k,children:k?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):"Upload"}),r&&e.jsx(C,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0","aria-label":`Remove ${t.toLowerCase()}`,onClick:()=>o(""),children:e.jsx(xs,{className:"h-3.5 w-3.5"})})]})})}function di({draft:t,nestName:a}){const r=tr(t)??{},o=vs(r,"light"),l=ht(t.header_bg_color),h=ht(t.accent_color),m=t.site_title.trim()||a,d=!!(t.banner_url.trim()||t.banner_headline.trim());return e.jsxs("div",{"data-reader-branded":"",style:o,className:"overflow-hidden rounded-lg border bg-background text-foreground shadow-sm","aria-hidden":!0,children:[e.jsxs("div",{className:"flex h-11 items-center gap-2 border-b bg-card px-3",style:l?{backgroundColor:"var(--reader-header-bg)",color:"var(--reader-header-fg)",borderColor:"transparent"}:void 0,children:[e.jsx("img",{src:t.logo_url.trim()||ln,alt:"",className:"h-6 w-auto max-w-[5rem] object-contain"}),e.jsx("span",{className:"truncate text-[13px] font-semibold",children:m}),e.jsx("span",{className:"ml-auto rounded border border-input bg-background px-2 py-0.5 text-[10px] text-foreground",children:"Login"})]}),e.jsxs("div",{className:"space-y-2 p-3",children:[d&&e.jsxs("div",{className:"relative flex h-20 flex-col justify-end overflow-hidden rounded-md px-3 py-2",style:t.banner_url.trim()?{backgroundImage:Ka(t.banner_url.trim()),backgroundSize:"cover",backgroundPosition:"center",color:"#fff"}:{background:h?"var(--reader-accent)":"hsl(var(--primary))",color:h?"var(--reader-accent-fg)":"hsl(var(--primary-foreground))"},children:[t.banner_url.trim()&&e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/65 via-black/25 to-black/0"}),t.banner_url.trim()&&h&&e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-1",style:{background:"var(--reader-accent)"}}),t.banner_headline&&e.jsx("p",{className:"relative truncate text-sm font-semibold",children:t.banner_headline}),t.banner_subtext&&e.jsx("p",{className:"relative truncate text-[11px] opacity-90",children:t.banner_subtext})]}),e.jsxs("div",{className:"grid grid-cols-[6.5rem_minmax(0,1fr)] gap-2",children:[e.jsxs("aside",{className:"space-y-0.5 rounded-md border bg-card p-2 text-[11px]",children:[e.jsx("button",{type:"button",tabIndex:-1,"aria-current":"page",className:"block w-full truncate rounded bg-accent px-1.5 py-0.5 text-left font-medium text-foreground",children:"Welcome"}),e.jsx("span",{className:"block truncate px-1.5 py-0.5 text-muted-foreground",children:"Getting started"}),e.jsx("span",{className:"block truncate px-1.5 py-0.5 text-muted-foreground",children:"Policies"})]}),e.jsxs("div",{className:"rounded-md border bg-card p-3 text-[11px] leading-relaxed",children:[e.jsx("p",{className:"text-sm font-semibold",children:"Welcome"}),e.jsx("div",{className:"prose prose-sm max-w-none text-[11px]",children:e.jsxs("p",{className:"my-1",children:["Read the ",e.jsx("a",{href:"#preview",children:"onboarding guide"})," first."]})}),e.jsx("span",{className:"mt-2 inline-block rounded bg-primary px-2 py-0.5 text-[10px] font-medium text-primary-foreground",children:"Next page"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-x-3 border-t px-3 py-2 text-[10px] text-muted-foreground",children:[t.footer_text&&e.jsx("span",{children:t.footer_text}),t.footer_link_url&&e.jsx("span",{style:{color:"var(--reader-accent-text, inherit)"},className:"underline",children:t.footer_link_label||t.footer_link_url}),!t.hide_powered_by&&e.jsx("span",{children:"Powered by ContextNest"})]})]})}function ui({draft:t}){const a=[],r=ht(t.accent_color);if(r){const l=Ca(r);a.push(`Text on the accent: ${l==="#000000"?"black":"white"} (${Ra(l,r).toFixed(1)}:1, meets WCAG AA)`),vs({accent_color:r,page_tint_color:t.page_tint_color},"light")["--reader-accent-text"]!==r&&a.push("Links use a deeper shade of the accent so they stay readable.")}const o=ht(t.header_bg_color);if(o){const l=Ca(o);a.push(`Header text: ${l==="#000000"?"black":"white"} (${Ra(l,o).toFixed(1)}:1, meets WCAG AA)`)}return a.length?e.jsx("ul",{className:"mt-2 space-y-0.5 text-xs text-muted-foreground",children:a.map(l=>e.jsx("li",{children:l},l))}):null}const mi=50;function hi(t,a=!0){return bs({...K.feed(t,"comments",mi,0),enabled:a})}const pi=Qe(()=>Ue(()=>import("./ExternalEditsTab-B_CWKXZ_.js"),__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])).then(t=>({default:t.ExternalEditsTab}))),xi=Qe(()=>Ue(()=>import("./StewardsTab-C-iP6gnh.js"),__vite__mapDeps([23,1,2,19,5,6,7,8,9,10,11,18])).then(t=>({default:t.StewardsTab}))),fi=Qe(()=>Ue(()=>import("./CollaboratorsTab-tq4ZTexH.js"),__vite__mapDeps([24,1,2,25,13,5,6,7,8,9,10,11,17,19,26])).then(t=>({default:t.CollaboratorsTab}))),gi=Qe(()=>Ue(()=>import("./ReviewTab-CwVrXzw5.js"),__vite__mapDeps([27,1,2,4,28,20,21,29,9,5,6,7,8,10,11,12,13,14,15,16,17,18,19,22])).then(t=>({default:t.ReviewTab}))),vi=Qe(()=>Ue(()=>import("./OverviewTab-CjidsMX_.js"),__vite__mapDeps([30,1,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,4,21,22])).then(t=>({default:t.OverviewTab}))),bi=Qe(()=>Ue(()=>import("./DocumentsTab-Mh7KxUoB.js"),__vite__mapDeps([31,1,2,32,5,6,7,8,9,10,11,33,4,21,16,26,34,29,3,35,12,13,14,15,17,18,19,20,22])).then(t=>({default:t.DocumentsTab}))),We="relative rounded-none px-0 pb-2.5 pt-1 text-muted-foreground hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:rounded-full after:bg-transparent data-[state=active]:after:bg-primary";function wi({nestId:t,nestName:a,isOwner:r,isAnonOwned:o,isArchived:l,onBack:h,initialDoc:m,onReaderDocChange:d,onOpenDocument:k,onOpenTrace:v,onManageKeys:_,initialSearch:P,initialTags:b,initialFolder:y,initialTab:f,onTabChange:p}){var pa,xa,fa,ga,va,ba,wa;const{isAdmin:D,adminStatus:x,authMode:A,sharedDeployment:ae}=un(),L=r||o&&A!=="open"&&D,z=((xa=(pa=x==null?void 0:x.me)==null?void 0:pa.email)==null?void 0:xa.toLowerCase())??"",[Y,F]=n.useState(a),U=n.useRef(a);n.useEffect(()=>{F(a),U.current=a},[a,t]);const O=n.useRef(null),Z=n.useRef(()=>{}),ee=n.useRef(Mo()).current,[re,ne]=n.useState(null);Z.current=async()=>{const s=Y.trim();if(s&&s!==U.current.trim())try{await Aa(t,{name:s}),U.current=s,ne(null)}catch(i){const g=i instanceof Error?i.message:"Failed to rename nest";ne(g)}};const V=n.useCallback(()=>{O.current&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{O.current=null,Z.current()},1200)},[]),M=n.useCallback(()=>{O.current&&(window.clearTimeout(O.current),O.current=null),!ee.consume()&&Z.current()},[]);n.useEffect(()=>()=>{O.current&&window.clearTimeout(O.current)},[]);const[q,w]=n.useState([]),[j,R]=n.useState(null),[ye,ft]=n.useState(!1),[ve,Ie]=n.useState([]),[oe,de]=n.useState([]),[Pe,gt]=n.useState([]),[vt,ie]=n.useState(null),[ue,Le]=n.useState(!1),me=Pe.find(s=>(s.targetType==="nest"||s.targetType==="nest_archive")&&s.status==="pending"),Mt=!!me,bt=n.useMemo(()=>Pe.filter(s=>s.status==="pending"),[Pe]),[T,Ge]=n.useState(null),[Ne,c]=n.useState(!1),[u,$]=n.useState(!1),[he,Ns]=n.useState(!1),[sr,ks]=n.useState(!1),[ar,_s]=n.useState(!1),[Ss,Cs]=n.useState([]),[B,wt]=n.useState("private"),[Rs,As]=n.useState(!1),[rr,qt]=n.useState(!1),[Ts,Ds]=n.useState(""),[be,jt]=n.useState(!1),[pe,Bt]=n.useState(null),[Ke,yt]=n.useState(!1),[Wt,Ye]=n.useState(!1),[Nt,Es]=n.useState(null),[nr,Ps]=n.useState(!1),[ke,Ls]=n.useState(!1),[Fs,Os]=n.useState(!1),[or,kt]=n.useState(null),[$s,ir]=n.useState(!1),[lr,cr]=n.useState(null),[_e,dr]=n.useState(null),le=D&&(r||o)||!D&&(r||_e==="owner"||_e==="admin"),ur=D||r||_e==="owner"||_e==="admin",[zt,mr]=n.useState([]),[hr,Xe]=n.useState(!1),[Je,Ms]=n.useState(null),[Vt,qs]=n.useState(!0),[X,pr]=n.useState(!0),[te,Fe]=n.useState(null),[Bs,Ht]=n.useState(!1),[Ws,Qt]=n.useState(!1),[zs,Ut]=n.useState(!1),[xr,_t]=n.useState(!1),Vs=n.useRef(null),[Hs,Qs]=n.useState(""),[Us,Is]=n.useState(!1),xe=$o(Hs),Gs=async()=>{const s=xe.path;if(s&&!xe.error){Is(!0);try{await Tn(t,s),Qs(""),_t(!1),S.success(`Folder "${Dn(s)}" created`),E()}catch(i){console.error("[NestView] createFolder failed",i),S.error((i==null?void 0:i.message)||"Failed to create folder")}finally{Is(!1)}}},[fr,St]=n.useState(!1),[gr,It]=n.useState(!1),[Ze,Gt]=n.useState(null),[Oe,Ks]=n.useState(y??null),[Se,vr]=n.useState(f??(y||b!=null&&b.length?"documents":"overview")),Ce=s=>{vr(s),p==null||p(s)},[Ys,Ct]=n.useState(new Set),[Kt,Xs]=n.useState(new Set),J=gs(),Re=n.useRef(new Set),[Js,Yt]=n.useState(new Set),fe=n.useCallback(async(s,i={})=>{if(!(!i.refresh&&Re.current.has(s))){Xs(g=>new Set(g).add(s));try{const g=await J.fetchQuery(K.folderNodes(t,s));Re.current.add(s),Yt(N=>new Set(N).add(s)),w(N=>[...N.filter(je=>Bo(je.id||"")!==s),...g.nodes])}catch(g){console.error("[NestView] listFolderNodes failed",t,s,g),S.error((g==null?void 0:g.message)||"Failed to load folder")}finally{Xs(g=>{const N=new Set(g);return N.delete(s),N})}}},[t,J]),Rt=n.useCallback(async()=>{try{const{census:s}=await J.fetchQuery(K.census(t));R(s)}catch(s){console.error("[NestView] getNestCensus failed",t,s)}finally{ft(!0)}},[t,J]),Zs=n.useCallback(async()=>{Re.current.size&&await Promise.all([Rt(),...[...Re.current].map(s=>fe(s,{refresh:!0}))])},[fe,Rt]),br=s=>{Ks(s),Ce("documents")},wr=s=>{Ct(i=>i.has(s)?i:new Set(i).add(s)),fe(s)},jr=s=>{const i=!Ys.has(s);Ct(g=>{const N=new Set(g);return i?N.add(s):N.delete(s),N}),i&&fe(s)},E=n.useCallback(async()=>{var st;qs(!0);const s=await J.fetchQuery(K.nest(t)).catch(H=>(console.error("[NestView] getNest failed",t,H),null)),i=!!(s!=null&&s.grant_only);c(i);const g=H=>Promise.resolve(H),[,N,je,G]=await Promise.all([Zs(),i?g({requests:[],total:0}):J.fetchQuery(K.reviewQueue(t)).catch(H=>(console.error("[NestView] getReviewQueue failed",t,H),S.error((H==null?void 0:H.message)||"Failed to load review queue"),{requests:[],total:0})),i?g({requests:[],total:0}):J.fetchQuery(K.deletionRequests(t,"all")).catch(H=>(console.error("[NestView] getDeletionRequests failed",t,H),{requests:[],total:0})),i?g({stewardship_enabled:!1,allow_self_approve:!1,prime_only_review:!1,prime_tags:[],creator_is_reviewer:!1}):J.fetchQuery(K.settings(t)).catch(H=>(console.error("[NestView] getNestSettings failed",t,H),{stewardship_enabled:!1,allow_self_approve:!1,prime_only_review:!1,prime_tags:[],creator_is_reviewer:!1}))]);de(N.requests),gt(je.requests),$(G.stewardship_enabled),Ns(G.allow_self_approve),ks(!!G.prime_only_review),_s(!!G.creator_is_reviewer),Cs(G.prime_tags??[]),(st=s==null?void 0:s.nest)!=null&&st.visibility&&wt(s.nest.visibility),s!=null&&s.nest&&(ir(!!s.nest.is_imported),Gt(s.nest.description??null),jt(!!s.nest.reader_mode),Bt(s.nest.reader_home_node??null),Es(s.nest.branding??null),cr(s.nest.archived_at??null)),s!=null&&s.permission&&dr(s.permission),mr((s==null?void 0:s.roles)??[]),Ie((s==null?void 0:s.myStewards)??[]),qs(!1),pr(!1)},[t,J,Zs]);n.useEffect(()=>{E()},[E]),n.useEffect(()=>{Re.current=new Set,Ct(new Set),w([]),ft(!1),fe(Oe??""),Rt()},[t,Oe,fe,Rt]);const Xt=n.useMemo(()=>((j==null?void 0:j.folders)??[]).map(s=>({path:s.path,total:s.total})),[j]),yr=(j==null?void 0:j.recent)??[],Nr=(j==null?void 0:j.editedLast7d)??0,At=l||mn({archived_at:lr}),et=hn({roles:zt,permission:_e,myStewards:ve,isOwner:r,isAdmin:D,readerMode:be,previewReader:ke,isArchived:At}),{canManage:ge,collabCanWrite:Jt,canEditDocs:we,isReadOnly:W,isReaderView:Zt}=et;n.useEffect(()=>{if(!Zt)return;let s=!1;return J.fetchQuery(K.nodesMeta(t,ke)).then(({nodes:i})=>{if(s)return;const g=Zo(i);Re.current=g,Yt(g),w(i)}).catch(i=>S.error((i==null?void 0:i.message)||"Failed to load documents")),()=>{s=!0}},[Zt,ke,t,J]);const kr=()=>{Ls(!1),Re.current=new Set,Yt(new Set),Ct(new Set),w([]),fe(Oe??"")},ea=(s,i)=>ve.some(g=>{if(g.role!==i)return!1;if(g.scope==="nest")return!0;if(g.scope==="document")return g.nodePattern===s.id;if(g.scope==="tag"){const N=(g.tagName||"").toLowerCase().replace(/^#+/,"");return(s.tags||[]).map(je=>je.toLowerCase().replace(/^#+/,"")).includes(N)}return!1}),ta=s=>!s||W?!1:D||zt.includes("admin")?!0:r?he:!!ea(s,"reviewer"),tt=oe.filter(s=>{if(s.canReview!==void 0)return s.canReview;const i=q.find(N=>N.id===s.nodeId);return!(!i||!ta(i)||s.requestedBy.toLowerCase()===z&&!(r&&he))}),_r=oe.filter(s=>s.requestedBy.toLowerCase()===z),sa=((fa=bs({...K.externalEditCount(t),enabled:!Ne}).data)==null?void 0:fa.total)??0,aa=u||et.canReviewDocs||oe.length>0||et.canManage&&bt.length>0,$e=hi(t,!Ne&&!X&&!aa).data,Sr=((ga=$e==null?void 0:$e.counts)==null?void 0:ga.comments)??(($e==null?void 0:$e.items)??[]).filter(s=>s.type==="comment").length,Tt=aa||Sr>0,ra={overview:!0,documents:!0,review:Tt&&!W,"external-edits":!W,stewards:u&&le,collaborators:ge||Jt};n.useEffect(()=>{!X&&!ra[Se]&&Ce("overview")},[X,Se,ra[Se]]);const I={total:(j==null?void 0:j.total)??q.length,pending:((va=j==null?void 0:j.statuses)==null?void 0:va.pending_review)??0,approved:(((ba=j==null?void 0:j.statuses)==null?void 0:ba.approved)??0)+(((wa=j==null?void 0:j.statuses)==null?void 0:wa.published)??0),reviewQueue:oe.length,reviewable:tt.length},na=n.useMemo(()=>zo(q),[q]),Cr=(j==null?void 0:j.folders.length)??0,oa=async s=>{try{await Rn(t,s.id),S.success("Deletion request withdrawn"),E()}catch(i){S.error((i==null?void 0:i.message)||"Failed to withdraw deletion request")}},Rr=async s=>{if(te)try{await Fn(t,te.id,s),S.success("Approved"),Fe(null),E()}catch(i){console.error("[NestView] approveNode failed",t,te==null?void 0:te.id,i),S.error((i==null?void 0:i.message)||"Approve failed")}},Ar=async s=>{if(te)try{await Ln(t,te.id,s),S.success("Rejected"),Fe(null),E()}catch(i){console.error("[NestView] rejectNode failed",t,te==null?void 0:te.id,i),S.error((i==null?void 0:i.message)||"Reject failed")}},Tr=async s=>{try{await An(t,s),S.success("Submission withdrawn — back to Draft"),E()}catch(i){console.error("[NestView] cancelReview failed",t,s,i),S.error((i==null?void 0:i.message)||"Failed to withdraw submission")}},Dr=async()=>{const s=vt;try{await On(t,s),E()}catch(i){throw console.error("[NestView] removeSteward failed",t,s,i),i}},Er=async s=>{const{target:i,...g}=s,N={...g};s.scope==="document"?N.nodePattern=i:s.scope==="tag"&&(N.tagName=i),await En(t,N),E()},Pr=async s=>{if(!Je)return;const i={role:s.role,scope:s.scope};s.scope==="document"?i.nodePattern=s.target:s.scope==="tag"&&(i.tagName=s.target),await Pn(t,Je.id,i),S.success("Steward updated"),E()},Lr=async()=>{await $n(t,T.request.id),S.success("Document deleted"),E()},Fr=async s=>{await Mn(t,T.request.id,s),S.success("Request rejected"),E()},ia=async(s,i)=>{const g=B;wt(s),As(!0);try{const N=await qn(t,s,i);N!=null&&N.visibility&&wt(N.visibility)}catch(N){wt(g),S.error((N==null?void 0:N.message)||"Failed to change visibility")}finally{As(!1)}},Or=async()=>{if(B==="org"){Ce("collaborators");return}if(B!=="public"){Ds(Ze??""),qt(!0);return}await ia("private")},$r=async()=>{qt(!1);const s=Ts.trim();if(s&&s!==(Ze??"").trim())try{await Aa(t,{description:s}),Gt(s)}catch(i){S.error((i==null?void 0:i.message)||"Failed to save the description — publishing anyway")}await ia("public",!0)},es=Jn("public",{sharedDeployment:ae}),Mr=async()=>{const s=!be;jt(s),yt(!0);try{const i=await Pa(t,{enabled:s});jt(!!i.reader_mode),Bt(i.reader_home_node??null)}catch(i){jt(!s),S.error((i==null?void 0:i.message)||"Failed to change reader mode")}finally{yt(!1)}};n.useEffect(()=>{if(!Wt||!pe){kt(null);return}let s=!1;return J.fetchQuery(K.node(t,pe)).then(({node:i})=>{s||kt((i==null?void 0:i.title)||pe)}).catch(()=>{s||kt(pe)}),()=>{s=!0}},[Wt,pe,t,J]);const la=async s=>{yt(!0);try{const i=await Pa(t,{home_node:s});Bt(i.reader_home_node??null),S.success("Saved reader home node")}catch(i){S.error((i==null?void 0:i.message)||"Failed to set reader home node")}finally{yt(!1)}},[qr,ts]=n.useState(!1),[Br,ca]=n.useState(!1),ss=n.useRef(null),[Wr,da]=n.useState(!1),ua=Vo("(max-width: 639px)"),ma=n.useRef(null),ha=s=>{const i=s.toLowerCase().split(".").pop()||"";return i==="html"||i==="htm"?"artifact":i==="pdf"?"pdf":i==="md"||i==="markdown"||i==="txt"?"document":null},Dt=n.useCallback(async s=>{var je;const i=Array.from(s).filter(G=>ha(G.name)),g=s.length-i.length;if(!i.length){S.error("Drop .md, .html or .pdf files to add them to this vault.");return}ca(!0);const N=[];try{for(const G of i){const st=ha(G.name),H=G.name.replace(/\.(md|markdown|txt|html|htm|pdf)$/i,""),as=G.webkitRelativePath;let rs;if(as&&as.includes("/")){const se=as.split("/").slice(1,-1);if(se.some(Et=>Et.startsWith(".")))continue;rs=(se[0]==="nodes"?se.slice(1):se).join("/")||void 0}try{const se=st==="pdf"?await pn(t,G,{title:H,folder:rs}):await xn(t,{title:H,content:await G.text(),type:st,folder:rs}),Et=(je=se==null?void 0:se.node)==null?void 0:je.id;Et&&N.push(Et)}catch(se){S.error(`${G.name}: ${(se==null?void 0:se.message)||"failed to import"}`)}}N.length&&(S.success(`Added ${N.length} ${N.length===1?"item":"items"}`+(g?` (skipped ${g} unsupported)`:"")),await E(),N.length===1&&k(N[0]))}finally{ca(!1)}},[t,E,k]);return Zt?e.jsxs("div",{style:ke?{"--reader-offset":"3.5rem"}:void 0,children:[ke&&e.jsxs("div",{role:"status",className:"mb-4 flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/40 dark:text-amber-200",children:[e.jsx("span",{children:"Previewing as a reader — this is what visitors see."}),e.jsx(C,{variant:"outline",size:"sm",className:"h-7",onClick:kr,children:"Exit preview"})]}),e.jsx(si,{nestId:t,nestName:Y,nodes:q,tocGroups:na,knownFolders:Xt,readerHomeNode:pe,initialDoc:m,onDocChange:d,onExpandFolder:fe,loadingFolders:Kt,loadedFolders:Js,approvedOnly:ke,branding:Nt},ke?"preview":"reader")]}):e.jsxs("div",{className:"relative",onDragOver:s=>{we&&Array.from(s.dataTransfer.types).includes("Files")&&(s.preventDefault(),ts(!0))},onDragLeave:s=>{s.currentTarget===s.target&&ts(!1)},onDrop:s=>{var i;we&&(s.preventDefault(),ts(!1),(i=s.dataTransfer.files)!=null&&i.length&&Dt(s.dataTransfer.files))},children:[qr&&we&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-40 flex items-center justify-center rounded-lg border-2 border-dashed border-primary bg-primary/5 backdrop-blur-[1px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[e.jsx(Fa,{className:"h-8 w-8"}),e.jsx("div",{className:"text-sm font-medium",children:"Drop to add to this vault"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:".md → document · .html → hosted artifact · .pdf → PDF document"})]})}),Br&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-40 flex items-center justify-center bg-background/60",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"})," Importing…"]})}),e.jsxs(ho,{nestName:a,onBack:h,title:ge?e.jsxs("div",{className:"min-w-[11rem] flex-1 sm:min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:Y,onChange:s=>{F(s.target.value),ne(null),V()},onBlur:M,onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),M(),s.target.blur()),s.key==="Escape"&&(ee.arm(),F(U.current),ne(null),s.target.blur())},"aria-label":"Nest name",title:"Click to rename — saved automatically",className:"w-full min-w-0 truncate text-xl font-semibold bg-transparent outline-none border-b border-transparent hover:border-border focus:border-primary px-1 -ml-1 rounded-sm"}),!Vt&&e.jsx("button",{type:"button",onClick:()=>{M(),It(!0)},className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Rename nest","aria-label":"Rename nest","data-testid":"nest-rename",children:e.jsx(gn,{className:"h-4 w-4"})})]}),re&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-red-700",title:re,children:re})]}):void 0,badges:e.jsxs(e.Fragment,{children:[!X&&(ge?e.jsxs(C,{variant:"outline",size:"sm",onClick:Or,disabled:Rs,className:`shrink-0 h-7 gap-1.5 ${B==="public"?"border-blue-200 bg-blue-50 text-blue-700 hover:bg-blue-100":""}`,title:B==="public"?"Public — anyone with the URL can read. Click to make private.":B==="org"?`Organization — ${Yn("org",{sharedDeployment:ae}).toLowerCase()}. Click to manage sharing (Collaborators tab).`:"Private. Click to make public (anyone with the URL can read).",children:[Rs?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):B==="public"?e.jsx(Da,{className:"h-3.5 w-3.5"}):B==="org"?e.jsx(ms,{className:"h-3.5 w-3.5"}):e.jsx(fn,{className:"h-3.5 w-3.5"}),B==="public"?"Public":B==="org"?"Organization":"Private"]}):B!=="private"&&e.jsxs(nt,{variant:"outline",className:`shrink-0 gap-1 ${B==="public"?"border-green-200 bg-green-50 text-green-700":"border-blue-200 bg-blue-50 text-blue-700"}`,title:B==="public"?"Anyone with the URL can read this nest":"Everyone signed in to this deployment can read this nest",children:[B==="public"?e.jsx(Da,{className:"h-3 w-3"}):e.jsx(ms,{className:"h-3 w-3"}),B==="public"?"Public":"Organization"]})),ur&&!At&&!X&&e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>Ye(!0),className:`shrink-0 h-7 gap-1.5 ${be?"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100":""}`,title:"Public Docs Reader Mode — the clean, read-only docs view public readers get.",children:[Ke?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ga,{className:"h-3.5 w-3.5"}),be?"Reader: On":"Reader: Off"]}),$s&&e.jsxs(nt,{variant:"outline",className:"shrink-0 gap-1 border-blue-200 bg-blue-50 text-blue-700",title:"Imported from a folder — its files were copied into the workspace",children:[e.jsx(jo,{className:"h-3 w-3"}),"Imported"]}),me&&(()=>{const s=me.requestedBy.toLowerCase()===z,i=me.targetType==="nest_archive",g=i?"archived":"deleted";return e.jsxs(nt,{variant:"outline",className:`shrink-0 gap-1 ${i?"border-amber-200 bg-amber-50 text-amber-700":"border-red-200 bg-red-50 text-red-700"} ${s?"cursor-pointer hover:opacity-80":""}`,title:s?`Click to withdraw your ${i?"archive":"deletion"} request`:`${me.requestedBy} asked for this nest to be ${g}: "${me.reason}". A nest owner or admin decides.`,"data-testid":"nest-deletion-flag",onClick:s?()=>oa(me):void 0,children:[i?e.jsx(yo,{className:"h-3 w-3"}):e.jsx(xs,{className:"h-3 w-3"}),i?"Archive requested":"Deletion requested",s&&e.jsx(Ya,{className:"h-3 w-3 ml-0.5"})]})})()]}),children:[!At&&e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>Qt(!0),children:[e.jsx(vo,{className:"h-3.5 w-3.5 mr-1.5"}),"Connect"]}),!W&&e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>Ut(!0),children:[e.jsx(Ia,{className:"h-3.5 w-3.5 mr-1.5"}),"Add with AI"]}),ge&&!ua&&e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>Ce("collaborators"),children:[e.jsx(Ta,{className:"h-3.5 w-3.5 mr-1.5"}),"Share"]}),!W&&we&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:ss,type:"file",multiple:!0,accept:".md,.markdown,.txt,.html,.htm,.pdf",className:"hidden",onChange:s=>{var i;(i=s.target.files)!=null&&i.length&&Dt(s.target.files),s.target.value=""}}),e.jsx("input",{ref:ma,type:"file",multiple:!0,accept:"application/pdf,.pdf",className:"hidden",onChange:s=>{var i;(i=s.target.files)!=null&&i.length&&Dt(s.target.files),s.target.value=""}}),e.jsx("input",{ref:Vs,type:"file",className:"hidden",webkitdirectory:"",onChange:s=>{var i;(i=s.target.files)!=null&&i.length&&Dt(s.target.files),s.target.value=""}})]}),(()=>{const s=[];return ge&&ua&&s.push({label:"Share",icon:Ta,onSelect:()=>Ce("collaborators")}),!W&&le&&s.push({label:"Nest settings",icon:$a,onSelect:()=>Xe(!0)}),!W&&u&&le&&s.push({label:"Assign Steward",icon:$t,onSelect:()=>Ht(!0)}),le&&v&&!At&&s.push({label:"Activity trace",icon:_o,onSelect:v}),!W&&(L||we)&&(L||!Mt)&&s.push({label:"Delete",icon:xs,destructive:L,separatorBefore:!0,onSelect:()=>L?St(!0):Le(!0)}),e.jsx(Kn,{actions:s,variant:"outline",className:"h-8 w-8"})})()]}),e.jsxs(vn,{value:Se,onValueChange:Ce,className:"w-full min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-x-2 gap-y-3 mb-5 min-w-0 border-b",children:[e.jsxs(bn,{className:"h-auto min-h-0 max-w-full justify-start gap-5 overflow-x-auto rounded-none bg-transparent p-0",children:[e.jsx(Me,{value:"overview",className:We,children:"Overview"}),e.jsx(Me,{value:"documents",className:We,children:"Documents"}),Tt&&!W&&e.jsxs(Me,{value:"review",className:We+" gap-2",children:["Review Queue",tt.length>0&&e.jsx(nt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:tt.length})]}),!W&&e.jsxs(Me,{value:"external-edits",className:We+" gap-2",children:["External Edits",sa>0&&e.jsx(nt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-orange-100 text-orange-700",children:sa})]}),u&&le&&e.jsx(Me,{value:"stewards",className:We,children:"Stewards"}),(ge||Jt)&&e.jsx(Me,{value:"collaborators",className:We,children:"Collaborators"})]}),!W&&we&&e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2 pb-2 max-sm:order-first max-sm:w-full max-sm:justify-end",children:[e.jsxs(C,{variant:"outline",size:"sm",className:"text-muted-foreground",onClick:()=>_t(!0),title:"Create a folder (nest with parent/child)","aria-label":"New Folder",children:[e.jsx(Oa,{className:"h-4 w-4 sm:mr-1.5"}),e.jsx("span",{className:"max-sm:hidden",children:"New Folder"})]}),e.jsxs(wn,{modal:!1,open:Wr,onOpenChange:da,children:[e.jsx(jn,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm","data-testid":"nest-import-files",children:[e.jsx(Fa,{className:"h-3.5 w-3.5 mr-1.5"}),"Import"]})}),e.jsxs(yn,{align:"end",children:[e.jsx(os,{onSelect:()=>{var s;return(s=ss.current)==null?void 0:s.click()},children:"Files (.md / .html / .pdf)"}),e.jsx(os,{onSelect:()=>{var s;return(s=ma.current)==null?void 0:s.click()},"data-testid":"nest-upload-pdf",children:"Upload PDF (as a document)"}),e.jsx(os,{onSelect:()=>{var s;return(s=Vs.current)==null?void 0:s.click()},children:"Whole vault (folder, keeps structure)"})]})]}),e.jsxs(C,{size:"sm",onClick:()=>k("new",{folder:Se==="documents"&&Oe?Oe:void 0}),children:[e.jsx(Nn,{className:"h-3.5 w-3.5 mr-1.5"}),"New Document"]})]})]}),Se!=="overview"&&e.jsxs("div",{className:`grid grid-cols-1 gap-4 mb-4 ${u?"md:grid-cols-4":"md:grid-cols-1 max-w-sm"}`,children:[e.jsxs(ot,{children:[e.jsxs(it,{className:"pb-2",children:[e.jsx(lt,{children:"Total Documents"}),e.jsx(ct,{className:"text-3xl",children:X?e.jsx(Lt,{className:"h-8 w-12"}):I.total})]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ut,{className:"h-4 w-4"}),e.jsx("span",{children:X?"Loading…":I.total===0?"No documents yet":u?"In your context":"Auto-approved, AI-ready"})]})})]}),u&&e.jsxs(e.Fragment,{children:[e.jsxs(ot,{children:[e.jsxs(it,{className:"pb-2",children:[e.jsx(lt,{children:"Pending Approvals"}),e.jsx(ct,{className:"text-3xl text-amber-600",children:X?e.jsx(Lt,{className:"h-8 w-12"}):I.pending})]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Co,{className:"h-4 w-4"}),e.jsx("span",{children:"Awaiting approval"})]})})]}),e.jsxs(ot,{children:[e.jsxs(it,{className:"pb-2",children:[e.jsx(lt,{children:"AI Ready"}),e.jsx(ct,{className:"text-3xl text-green-600",children:X?e.jsx(Lt,{className:"h-8 w-12"}):I.approved})]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(No,{className:"h-4 w-4"}),e.jsx("span",{children:X?"Loading…":I.total===0?"Nothing to evaluate yet":"Approved for AI"})]})})]}),e.jsxs(ot,{children:[e.jsxs(it,{className:"pb-2",children:[e.jsx(lt,{children:"Your Review Queue"}),e.jsx(ct,{className:"text-3xl text-blue-600",children:X?e.jsx(Lt,{className:"h-8 w-12"}):I.reviewable})]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx($t,{className:"h-4 w-4"}),e.jsxs("span",{children:["Need your review",I.reviewQueue>I.reviewable&&e.jsxs("span",{className:"ml-1 text-xs",children:["(",I.reviewQueue," pending total,"," ",I.reviewQueue-I.reviewable," outside your scope)"]})]})]})})]})]})]}),e.jsx(qe,{value:"overview",className:"space-y-4",children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(vi,{initialLoad:X||!ye,stats:I,recentlyEdited:yr,recentlyEditedCount:Nr,folderCount:Cr,tocGroups:na,knownFolders:Xt,isReadOnly:W,canEditDocs:we,onOpenDocument:k,onOpenFolder:br,nestName:Y,loadedFolders:Js,loadingFolders:Kt,onExpandFolder:fe,description:Ze,governance:u?I:void 0,onOpenReview:Tt&&!W?()=>Ce("review"):void 0,onImport:we&&!W?()=>da(!0):void 0,onAddWithAI:W?void 0:()=>Ut(!0)})})}),e.jsx(qe,{value:"documents",className:"space-y-4",children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(bi,{nestId:t,initialSearch:P,initialTags:b,initialLoad:X,loading:Vt,nodes:q,census:j,knownFolders:Xt,folderFilter:Oe,setFolderFilter:Ks,expandedFolders:Ys,loadingFolders:Kt,toggleFolderExpanded:jr,expandFolder:wr,caps:et,isAdmin:D,isOwner:r,roles:zt,permission:_e,currentEmail:z,myStewards:ve,stewardshipEnabled:u,allowSelfApprove:he,primeTags:Ss,visibility:B,hasRoleOnNode:ea,canReviewNode:ta,reviewQueue:oe,reviewableQueue:tt,deletionRequests:Pe,stats:I,onOpenDocument:k,onReview:Fe,onRefresh:E,onWithdrawDeletion:s=>void oa(s),importInputRef:ss})})}),Tt&&e.jsx(qe,{value:"review",className:"space-y-4",children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(gi,{nestId:t,enabled:!Ne,reviewQueue:oe,reviewableQueue:tt,myPendingSubmissions:_r,pendingDeletions:bt,canManage:ge,loading:Vt,onRefresh:E,onOpenDocument:k,onSelectRequest:s=>{const i=q.find(g=>g.id===s.nodeId);if(i){Fe(i);return}k(s.nodeId)},onResolveDeletion:(s,i)=>Ge({request:s,action:i}),onWithdrawSubmission:s=>void Tr(s)},t)})}),e.jsx(qe,{value:"external-edits",className:"space-y-4",children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(pi,{nestId:t,enabled:!Ne,onOpenDocument:k,titleOf:s=>{var i;return(i=q.find(g=>g.id===s))==null?void 0:i.title}})})}),u&&le&&e.jsx(qe,{value:"stewards",className:"space-y-4",children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(xi,{nestId:t,canManage:le&&!et.isReadOnly,currentUserEmail:z,onAssign:()=>Ht(!0),onRemove:ie,onEditRole:Ms})})}),(ge||Jt)&&e.jsx(qe,{value:"collaborators",className:"space-y-4",children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(fi,{nestId:t,nestName:a,canManage:ge,canManageGovernance:le,stewardshipEnabled:u,currentUserEmail:z,callerPermission:_e??void 0,onOpenSettings:()=>Xe(!0),onChanged:E})})})]}),Se==="review"&&!u&&!W&&le&&e.jsxs(ot,{className:"mt-4",children:[e.jsxs(it,{className:"pb-3",children:[e.jsxs(ct,{className:"text-base flex items-center gap-2",children:[e.jsx($t,{className:"h-4 w-4"}),"Stewardship is off"]}),e.jsx(lt,{children:"New documents are auto-approved and immediately AI-ready."})]}),e.jsxs(dt,{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Enable stewardship to require steward approval before documents become AI-ready. Versioning stays on either way."}),e.jsxs(C,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Xe(!0),children:[e.jsx($a,{className:"h-3.5 w-3.5 mr-2"}),"Open Settings"]})]})]}),Ws&&e.jsx(kn,{isOpen:Ws,onClose:()=>Qt(!1),nestId:t,nestName:a,onManageKeys:_&&(()=>{Qt(!1),_()})}),zs&&e.jsx(Wo,{isOpen:zs,onClose:()=>Ut(!1),nestId:t,nestName:a,openMode:A==="open"}),hr&&e.jsx(Ho,{nestId:t,nestName:a,stewardshipEnabled:u,allowSelfApprove:he,primeOnlyReview:sr,primeTags:Ss,creatorIsReviewer:ar,canManageStewardship:le,onClose:()=>Xe(!1),onChanged:s=>{Xe(!1),$(s.stewardshipEnabled),Ns(s.allowSelfApprove),ks(s.primeOnlyReview),Cs(s.primeTags),_s(s.creatorIsReviewer),E()}}),fr&&e.jsx(po,{nestId:t,nestName:a,isImported:$s,open:!0,onOpenChange:St,onDeleted:()=>{St(!1),h()},onArchived:()=>{St(!1),S.success(`"${a}" archived — find it under Archived`),h()}}),gr&&e.jsx(xo,{nestId:t,nestName:Y,nestDescription:Ze,open:!0,onOpenChange:It,onRenamed:(s,i)=>{i.nameChanged&&(F(s.name),U.current=s.name,ne(null)),Gt(s.description),It(!1)}}),e.jsx(Ae,{open:xr,onOpenChange:_t,children:e.jsxs(Te,{className:"max-w-md",children:[e.jsx(De,{children:e.jsx(Ee,{children:"New folder"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Name the folder. Nest it with a slash — e.g."," ",e.jsx("code",{className:"text-xs",children:"gtm/deals"}),". It starts empty; add documents to it whenever you like."]}),e.jsx(xt,{autoFocus:!0,value:Hs,onChange:s=>Qs(s.target.value),onKeyDown:s=>{s.key==="Enter"&&Gs()},placeholder:"e.g. gtm/deals",className:"font-mono"}),xe.error?e.jsx("p",{className:"text-xs text-destructive","data-testid":"new-folder-error",children:xe.error}):xe.rewritten&&xe.path?e.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"new-folder-preview",children:["Will be created as"," ",e.jsx("code",{className:"font-mono",children:xe.path})]}):null,e.jsxs(Ve,{children:[e.jsx(C,{variant:"ghost",onClick:()=>_t(!1),children:"Cancel"}),e.jsxs(C,{onClick:()=>void Gs(),disabled:Us||!xe.path||!!xe.error,children:[Us?e.jsx(ce,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Create folder"]})]})]})}),e.jsx(Ae,{open:Wt,onOpenChange:Ye,children:e.jsxs(Te,{className:"sm:max-w-[520px]",children:[e.jsxs(De,{children:[e.jsx(Ee,{children:"Public Docs Reader Mode"}),e.jsx(pt,{children:"A clean, read-only docs view for people who can only read this nest. Owners, editors and reviewers keep the full authoring UI, and reader mode grants no access on its own."})]}),e.jsxs("div",{className:"rounded-lg border p-4 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(Q,{className:"text-sm font-medium",children:"Reader mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:be?"Read-only visitors get the docs reader.":"Everyone gets the standard nest view."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Ke&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),e.jsx(ze,{checked:be,onCheckedChange:()=>void Mr(),disabled:Ke,"aria-label":"Toggle Public Docs Reader Mode"})]})]}),be&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsx(Q,{className:"text-sm font-medium",children:"Home document"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Reader mode opens on this document and keeps it in the side pane. Left unset, it resolves one by convention (welcome / index / readme / home / overview)."}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm",children:pe?or??"Loading…":e.jsx("span",{className:"text-muted-foreground",children:"Resolved by convention"})}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>Os(!0),disabled:Ke,children:pe?"Change":"Choose"}),pe&&e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>void la(null),disabled:Ke,children:"Clear"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(Q,{className:"text-sm font-medium",children:"Branding"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:mt(Nt)?"Custom logo, colors and footer are applied for readers.":"Readers see the default ContextNest look."})]}),e.jsxs(C,{variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>{Ye(!1),Ps(!0)},children:[e.jsx(Po,{className:"h-3.5 w-3.5"}),mt(Nt)?"Edit branding":"Customize"]})]}),e.jsxs(Ve,{children:[be&&e.jsxs(C,{variant:"outline",className:"mr-auto gap-1.5",onClick:()=>{Ye(!1),Ls(!0)},children:[e.jsx(_n,{className:"h-3.5 w-3.5"}),"Preview as reader"]}),e.jsx(C,{variant:"outline",onClick:()=>Ye(!1),children:"Done"})]})]})}),e.jsx(li,{open:nr,onOpenChange:Ps,nestId:t,nestName:Y,branding:Nt,isServerAdmin:D,onSaved:Es}),Fs&&e.jsx(Xn,{isOpen:Fs,onClose:()=>Os(!1),nestId:t,title:"Choose the reader home document",description:"Reader mode opens on this document and keeps it in the side pane. Close without picking to resolve one by convention (welcome / index / readme / home / overview).",onSelect:s=>{kt(s.title),la(s.id)}}),e.jsx(ro,{open:rr,onOpenChange:qt,children:e.jsxs(no,{children:[e.jsxs(oo,{children:[e.jsx(io,{children:es.title}),e.jsx(lo,{children:es.body})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Q,{htmlFor:"nest-public-description",className:"text-xs",children:(Ze??"").trim()?"Description readers will see":"This nest has no description — readers will only see its name. Add one? (optional)"}),e.jsx(Sn,{id:"nest-public-description",value:Ts,onChange:s=>Ds(s.target.value),placeholder:"What this nest is for, and who it's meant for",rows:2,"data-testid":"nest-public-description"})]}),e.jsxs(co,{children:[e.jsx(uo,{children:"Cancel"}),e.jsx(mo,{onClick:()=>void $r(),children:es.confirm})]})]})}),Bs&&e.jsx(qa,{isOpen:Bs,onClose:()=>Ht(!1),nestId:t,onSubmit:Er,onSync:async()=>{await Cn(t),await E()}}),Je&&e.jsx(qa,{isOpen:!!Je,steward:Je,nestId:t,onClose:()=>Ms(null),onSubmit:Pr}),te&&e.jsx(ji,{node:te,nestId:t,onApprove:Rr,onReject:Ar,onClose:()=>Fe(null),onOpenDocument:s=>{Fe(null),k(s)}}),vt&&e.jsx(is,{open:!0,onOpenChange:s=>!s&&ie(null),title:"Remove this steward?",description:"They lose approval rights immediately. The user account and any documents stay intact.",confirmLabel:"Remove steward",destructive:!0,onConfirm:Dr}),ue&&e.jsx(is,{open:!0,onOpenChange:Le,title:`Request removal of "${a}"`,description:"A nest owner or admin reviews this. Nothing is removed yet — ask for the nest to be archived (reversible, nothing deleted) or deleted outright.",label:"Why should it be removed?",placeholder:"e.g. project wound down, superseded by another nest",confirmLabel:"Request deletion",secondaryLabel:"Request archive",onSecondary:async s=>{await Ea(t,"nest_archive",t,s),S.success("Archive requested — a nest admin will review it"),E()},onConfirm:async s=>{await Ea(t,"nest",t,s),S.success("Deletion requested — a nest admin will review it"),E()}}),T&&e.jsx(is,{open:!0,onOpenChange:s=>!s&&Ge(null),title:T.action!=="delete"?"Reject this request":T.request.targetType==="nest_archive"?`Archive "${T.request.title||T.request.nodeId}"?`:`Delete "${T.request.title||T.request.nodeId}"?`,description:T.action!=="delete"?`${T.request.requestedBy} asked for this: "${T.request.reason}". The document stays; your note is the record.`:T.request.targetType==="nest_archive"?`${T.request.requestedBy} asked for this: "${T.request.reason}". The nest goes read-only and leaves the dashboard; nothing is deleted and you can restore it.`:`${T.request.requestedBy} asked for this: "${T.request.reason}". Deleting cannot be undone.`,label:T.action==="decline"?"Why are you rejecting?":void 0,placeholder:"e.g. still referenced by onboarding",confirmLabel:T.action!=="delete"?"Reject":T.request.targetType==="nest_archive"?"Archive nest":"Delete document",destructive:T.action==="delete"&&T.request.targetType!=="nest_archive",onConfirm:T.action==="delete"?Lr:Fr})]})}function ji({node:t,nestId:a,onApprove:r,onReject:o,onClose:l,onOpenDocument:h}){var y;const[m,d]=n.useState(null),k=gs(),{data:v,isLoading:_}=bs({...K.node(a,t.id),enabled:!t.content}),P=t.content||((y=v==null?void 0:v.node)==null?void 0:y.content)||"",b=async(f,p,D)=>{d(null);try{const{nodes:x}=await k.fetchQuery(K.nodes(a)),A=eo(x,f,!1,D);if(A.kind==="navigate"){h(A.node.id);return}d(`"${A.title}" doesn't exist in this nest. Reviewers can't create new documents — ask an editor to add it.`)}catch(x){console.error("[NestView] wiki-link lookup failed",a,f,x),d("Couldn't look up that document — try again later.")}};return e.jsx(Ae,{open:!0,onOpenChange:l,children:e.jsxs(Te,{className:"sm:max-w-[600px] max-h-[80vh] flex flex-col",children:[e.jsx(De,{children:e.jsx(Ee,{children:t.title})}),m&&e.jsx("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:bg-amber-950 dark:text-amber-200",children:m}),e.jsx("div",{className:"flex-1 overflow-y-auto rounded-md",children:P?e.jsx(Zn,{content:P,onChange:()=>{},editable:!1,nestId:a,onWikiLinkClick:b},t.id):_?e.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading content…"}):e.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"(no content)"})}),e.jsx(Ve,{children:e.jsx(wo,{documentTitle:t.title,version:t.version||1,onApprove:r,onReject:o})})]})})}const Ii=Object.freeze(Object.defineProperty({__proto__:null,NestView:wi,NodeTypeIcon:qo},Symbol.toStringTag,{value:"Module"}));export{Co as C,Bi as D,Ao as F,qo as N,cs as R,qi as S,Wi as T,mi as a,Va as b,Ui as c,Hi as d,Vi as e,Qi as f,$o as g,Xa as h,Bo as i,Ii as j,zi as o,Mi as t,hi as u};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{c as q,r as g,j as e,L as $,bN as G,ar as D,F as O,a_ as M,bC as J,am as S,bK as F,au as Q,bO as X,aK as Z}from"./index-WYDmEOfO.js";import{f as ee,c as te,o as se,R as A,b as re,d as ae,N as ne,e as ie,t as oe}from"./NestView-EW-sraEb.js";import{U as le}from"./MarkdownEditor-CKh4WSn-.js";import"./zap-D2ifcnYb.js";import"./x-mNtADYHc.js";import"./chevron-left-CK_ZPFm9.js";import"./trash-2-B0HyPTnI.js";import"./alert-dialog-BvF3NFr7.js";import"./NestPageHeader-Cizo8nUi.js";import"./arrow-left-CWIsv-sG.js";import"./count-skeleton-DToLM74B.js";import"./folder-input-m8UBV4fA.js";import"./PersonCombobox-BKI7dff4.js";import"./tag-DeYC_mRv.js";import"./user-plus-Ckm_Isyc.js";import"./ReviewActions-CS8JXgXF.js";import"./circle-check-Bw_aTXiH.js";import"./circle-x-DkIG68H7.js";import"./settings-DKX0Q4gO.js";import"./index-BOVYgMvj.js";/**
|
|
2
|
-
* @license lucide-react v0.577.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ce=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],de=q("arrow-up-right",ce),me=5,xe=5,E="text-[12px] font-semibold uppercase tracking-wide text-muted-foreground",u="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",w="group flex w-full min-w-0 items-center gap-2 rounded-md py-1.5 pl-1 pr-2 text-left text-sm "+u,I="w-16 shrink-0 text-right text-[12px] tabular-nums text-muted-foreground/80",T="shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-background hover:text-foreground focus-visible:opacity-100 group-hover/row:opacity-100 max-sm:opacity-60 "+u;function Ie({initialLoad:s,nestName:n,stats:a,recentlyEdited:r,recentlyEditedCount:o,folderCount:l,tocGroups:x,knownFolders:m,loadedFolders:i,loadingFolders:c,onExpandFolder:N,isReadOnly:L,canEditDocs:P,onOpenDocument:h,onOpenFolder:b,description:f,governance:H,onOpenReview:v,onImport:U,onAddWithAI:W}){const[y,B]=g.useState(()=>new Map),k=t=>ae(t,y,i),K=t=>{const d=k(t);B(p=>new Map(p).set(t,!d)),d&&N(t)},C=g.useMemo(()=>ee(m,i,me),[m,i]);g.useEffect(()=>{if(!s)for(const t of C)!c.has(t)&&!y.has(t)&&N(t)},[s,C.join("|")]);const z=g.useMemo(()=>te(x,xe),[x]);if(s)return e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx($,{className:"h-6 w-6 animate-spin text-muted-foreground"})});const R=!L&&P,V=a.total===0&&m.length===0,Y=se({total:a.total,folderCount:l,editedThisWeek:o,governance:H}),_=r.length>0;return e.jsxs("div",{className:"grid min-w-0 gap-5 "+(_?"lg:grid-cols-[minmax(0,1fr)_16rem]":""),children:[e.jsx("section",{"aria-labelledby":"nest-overview-heading",className:"min-w-0 "+A+" px-5 py-6 sm:px-8 sm:py-8",children:V?e.jsx(ge,{canWrite:R,onOpenDocument:h,onImport:U,onAddWithAI:W}):e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"mb-8 max-sm:mb-6",children:[e.jsx("h2",{id:"nest-overview-heading",className:"break-words text-[2rem] font-semibold leading-[1.15] tracking-tight text-foreground max-sm:sr-only",children:n}),f&&e.jsx("p",{className:"mt-3 max-sm:mt-0 max-w-[65ch] text-[17px] leading-7 text-muted-foreground",children:f}),e.jsx("p",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-[13px] text-muted-foreground"+(f?"":" max-sm:mt-0"),"data-testid":"nest-overview-facts",children:Y.map(t=>t.action==="review"&&v?e.jsx("button",{type:"button",onClick:v,className:"rounded-sm text-primary underline-offset-2 hover:underline "+u,children:t.text},t.key):e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.tone&&e.jsx("span",{"aria-hidden":!0,className:"inline-block h-1.5 w-1.5 rounded-full "+(t.tone==="ok"?"bg-emerald-500":"bg-amber-500")}),t.text]},t.key))})]}),e.jsxs("nav",{"aria-label":"Contents",className:"border-t pt-5",children:[e.jsx("h3",{className:E+" mb-2 px-1",children:"Contents"}),e.jsx(G,{className:"space-y-px",groups:z,known:m,isCollapsed:k,renderFolder:(t,{collapsed:d})=>e.jsx(pe,{label:t.label,path:t.path,total:t.total,collapsed:d,loading:c.has(t.path),onToggle:()=>K(t.path),onOpenFolder:()=>b(t.path),onNewDoc:R?()=>h("new",{folder:t.path}):void 0}),renderDoc:t=>t.more?e.jsx(he,{more:t.more,onOpen:()=>b(t.more.folder)}):e.jsx(ue,{node:t,onOpen:()=>h(t.id)})})]})]})}),_&&e.jsxs("aside",{"aria-labelledby":"nest-overview-recent",className:"min-w-0 self-start "+A,children:[e.jsx("h2",{id:"nest-overview-recent",className:E+" mb-2",children:"Recently edited"}),e.jsx("ul",{className:"space-y-px",children:r.map(t=>{const d=re(t.id).join(" / "),p=t.updated_at?D(t.updated_at):"";return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>h(t.id),title:t.title||t.id,className:"flex w-full items-start gap-1.5 rounded-md py-1.5 pl-2 pr-2 text-left text-[13px] leading-5 text-muted-foreground hover:bg-accent/60 hover:text-foreground "+u,children:[e.jsx(O,{className:"mt-[3px] h-3.5 w-3.5 shrink-0 opacity-70"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-foreground/90",children:t.title||t.id}),(d||p)&&e.jsxs("span",{className:"flex gap-2 text-[11px] text-muted-foreground/80",children:[d&&e.jsx("span",{className:"min-w-0 truncate",children:d}),p&&e.jsx("span",{className:"shrink-0",children:p})]})]})]})},t.id)})})]})]})}function pe({label:s,path:n,total:a,collapsed:r,loading:o,onToggle:l,onOpenFolder:x,onNewDoc:m}){const i=S(n),c=a>0;return e.jsxs("div",{className:"group/row flex min-w-0 items-center rounded-md hover:bg-accent/60",children:[e.jsxs("button",{type:"button",onClick:c?l:x,"aria-expanded":c?!r:void 0,title:c?r?`Show ${i}`:`Hide ${i}`:`Browse ${i} in Documents`,className:w+" flex-1 font-medium text-foreground/85 hover:text-foreground",children:[e.jsx("span",{className:"flex w-4 shrink-0 justify-center text-muted-foreground",children:c&&(r?e.jsx(F,{className:"h-3.5 w-3.5"}):e.jsx(Q,{className:"h-3.5 w-3.5"}))}),r||!c?e.jsx(X,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(Z,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:s}),o&&e.jsx($,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground","aria-label":"Loading"})]}),m&&e.jsx("button",{type:"button",onClick:m,className:T,title:`New document in ${i}`,"aria-label":`New document in ${i}`,children:e.jsx(M,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:x,className:T,title:`Open ${i} in Documents`,"aria-label":`Open ${i} in Documents`,children:e.jsx(de,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:I+" pr-2","aria-label":`${a} document${a===1?"":"s"}`,children:a})]})}function ue({node:s,onOpen:n}){const a=s.type||"document",r=oe(a),o=s.updated_at?D(s.updated_at):"";return e.jsxs("button",{type:"button",onClick:n,title:s.title||s.id,className:w+" text-muted-foreground hover:bg-accent/60 hover:text-foreground",children:[e.jsx("span",{className:"w-4 shrink-0","aria-hidden":!0}),a==="document"?e.jsx(O,{className:"h-4 w-4 shrink-0 opacity-70"}):e.jsx(ne,{type:a,className:"h-3 w-3"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground/90 group-hover:text-foreground",children:s.title||s.id}),r&&e.jsx("span",{className:`shrink-0 rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ${r.cls}`,title:r.title,children:r.label}),e.jsx("span",{className:I+" max-sm:hidden",children:o})]})}function he({more:s,onOpen:n}){return e.jsxs("button",{type:"button",onClick:n,title:`${s.hidden} more — open ${S(s.folder)} in Documents`,className:w+" text-[13px] text-muted-foreground hover:bg-accent/60 hover:text-primary",children:[e.jsx("span",{className:"w-4 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"w-4 shrink-0","aria-hidden":!0}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["View all ",s.total]})]})}function ge({canWrite:s,onOpenDocument:n,onImport:a,onAddWithAI:r}){const o=ie({canWrite:s,canImport:!!a,canAddWithAI:!!r});return o.length===0?e.jsxs("div",{className:"py-6",children:[e.jsx("h2",{id:"nest-overview-heading",className:"text-xl font-semibold tracking-tight text-foreground",children:"Contents"}),e.jsx("p",{className:"mt-2 text-[15px] leading-7 text-muted-foreground",children:"No documents yet."})]}):e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h2",{id:"nest-overview-heading",className:"text-xl font-semibold tracking-tight text-foreground",children:"Add the first page"}),e.jsx("p",{className:"mt-1.5 text-[15px] leading-7 text-muted-foreground",children:s?"Write one from scratch, bring in files you already have, or have AI draft a starting set.":"Have AI draft a starting set of pages."}),e.jsx("ul",{className:"mt-6 grid gap-3",children:o.map(l=>l==="new"?e.jsx(j,{icon:M,title:"New document",detail:"Write a page in the editor.",onClick:()=>n("new"),primary:!0},l):l==="import"?e.jsx(j,{icon:le,title:"Import files",detail:"Markdown or HTML files, or a whole vault folder with its structure.",onClick:a},l):e.jsx(j,{icon:J,title:"Add with AI",detail:"Describe the nest and get draft pages to edit.",onClick:r},l))}),s&&e.jsx("p",{className:"mt-5 text-[13px] text-muted-foreground max-sm:hidden",children:"You can also drop files anywhere on this page."})]})}function j({icon:s,title:n,detail:a,onClick:r,primary:o=!1}){return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:r,className:"group flex w-full items-center gap-3 rounded-lg border px-4 py-3 text-left hover:border-primary/60 hover:bg-accent/50 "+u,children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md "+(o?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground group-hover:text-primary"),children:e.jsx(s,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-medium text-foreground group-hover:text-primary",children:n}),e.jsx("span",{className:"block text-[13px] text-muted-foreground",children:a})]}),e.jsx(F,{className:"h-4 w-4 shrink-0 text-muted-foreground group-hover:text-primary"})]})})}export{Ie as OverviewTab};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,b_ as $,b$ as A,c1 as S,c2 as R,L as ae,B as d,R as H,c0 as K,e as E,cK as Z,cL as O,bK as Q,h as ee,d0 as re,F as le,w as ce,cX as de,u as me,r as z,d1 as q,ag as xe,l as he,i as P,d6 as pe,ac as ue}from"./index-WYDmEOfO.js";import{C as te,u as ge,a as je}from"./NestView-EW-sraEb.js";import{C as fe}from"./circle-check-Bw_aTXiH.js";import{C as ve}from"./corner-down-right-DSVxK3tf.js";import{M as ye}from"./ReviewActions-CS8JXgXF.js";import{S as be}from"./send-DdfwnIrj.js";import{T as Ne}from"./trash-2-B0HyPTnI.js";import"./MarkdownEditor-CKh4WSn-.js";import"./zap-D2ifcnYb.js";import"./index-BOVYgMvj.js";import"./arrow-left-CWIsv-sG.js";import"./x-mNtADYHc.js";import"./chevron-left-CK_ZPFm9.js";import"./alert-dialog-BvF3NFr7.js";import"./NestPageHeader-Cizo8nUi.js";import"./count-skeleton-DToLM74B.js";import"./folder-input-m8UBV4fA.js";import"./PersonCombobox-BKI7dff4.js";import"./tag-DeYC_mRv.js";import"./user-plus-Ckm_Isyc.js";import"./settings-DKX0Q4gO.js";import"./circle-x-DkIG68H7.js";const we={low:{label:"Low",className:"bg-gray-100 text-gray-600"},normal:{label:"Normal",className:"bg-blue-100 text-blue-600"},high:{label:"High",className:"bg-amber-100 text-amber-600",icon:ee},urgent:{label:"Urgent",className:"bg-red-100 text-red-600",icon:ee}};function se(c){const x=de(c);if(!x)return"";const r=new Date().getTime()-x.getTime();return r<6e4?"Just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:r<6048e5?`${Math.floor(r/864e5)}d ago`:x.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ke({requests:c,loading:x=!1,error:h=null,className:r,showHeader:f=!0,onRefresh:p,onSelect:b,comments:T,onSelectComment:v,selectedNodeIds:u,onToggleSelect:F}){const g=T!==void 0,L=g?[...c.map(a=>({kind:"change",at:a.requestedAt,id:a.id,request:a})),...(T??[]).map(a=>({kind:"comment",at:a.createdAt,id:a.id,comment:a}))].sort((a,s)=>s.at.localeCompare(a.at)||s.id.localeCompare(a.id)):c.map(a=>({kind:"change",at:a.requestedAt,id:a.id,request:a}));return x?e.jsxs($,{className:r,children:[f&&e.jsx(A,{className:"pb-3",children:e.jsx(S,{className:"text-lg",children:"Review Queue"})}),e.jsx(R,{children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ae,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):h?e.jsxs($,{className:r,children:[f&&e.jsx(A,{className:"pb-3",children:e.jsx(S,{className:"text-lg",children:"Review Queue"})}),e.jsx(R,{children:e.jsxs("div",{className:"text-center py-4 text-sm text-destructive",children:[h,p&&e.jsx(d,{variant:"ghost",size:"sm",onClick:p,className:"ml-2",children:e.jsx(H,{className:"h-4 w-4"})})]})})]}):e.jsxs($,{className:r,children:[f&&e.jsx(A,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(S,{className:"text-lg",children:g?"Activity":"Review Queue"}),e.jsx(K,{children:g?"Changes awaiting approval and new comments":"Documents awaiting your approval"})]}),p&&e.jsx(d,{variant:"ghost",size:"icon",onClick:p,className:"h-8 w-8",children:e.jsx(H,{className:"h-4 w-4"})})]})}),e.jsx(R,{children:L.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(fe,{className:"h-10 w-10 text-green-500 mb-3"}),e.jsx("p",{className:"text-sm font-medium",children:"Nothing needs your review"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g?"No changes or comments waiting on you":"No documents awaiting your approval"})]}):e.jsx("div",{className:"space-y-2",children:L.map(a=>{var M,B;if(a.kind==="comment"){const n=a.comment;return e.jsxs("div",{"data-testid":"feed-comment-item",className:"flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors group",onClick:()=>v==null?void 0:v(n),children:[n.isReply?e.jsx(ve,{className:"h-5 w-5 text-amber-500 flex-shrink-0 mt-0.5"}):e.jsx(ye,{className:"h-5 w-5 text-amber-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:n.title||n.nodeId}),e.jsx(E,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-100 text-amber-700",children:n.isReply?"Reply":"Comment"}),!n.resolved&&e.jsx(E,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-amber-400 text-amber-700",children:"Unresolved"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{className:"h-4 w-4",children:e.jsx(O,{className:"text-[8px]",children:((M=n.author[0])==null?void 0:M.toUpperCase())||"?"})}),e.jsx("span",{children:n.author})]}),e.jsx("span",{children:"•"}),e.jsx(te,{className:"h-3 w-3"}),e.jsx("span",{children:se(n.createdAt)})]}),n.snippet&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:["“",n.snippet,"”"]})]}),e.jsx(Q,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity mt-1"})]},`comment-${n.id}`)}const s=a.request,N=we[s.priority],w=N.icon;return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors group",onClick:()=>b==null?void 0:b(s),"data-testid":"review-queue-row",children:[F&&s.canReview!==!1&&e.jsx(re,{checked:(u==null?void 0:u.has(s.nodeId))??!1,onCheckedChange:()=>F(s.nodeId),onClick:n=>n.stopPropagation(),"aria-label":`Select ${s.title||s.nodeId}`,"data-testid":"review-queue-select"}),e.jsx(le,{className:"h-5 w-5 text-blue-500 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:s.title||s.nodeId}),e.jsxs(E,{variant:"secondary",className:ce("text-[10px] px-1.5 py-0",N.className),children:[w&&e.jsx(w,{className:"h-3 w-3 mr-1"}),N.label]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsxs("span",{children:["v",s.version]}),e.jsx("span",{children:"•"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{className:"h-4 w-4",children:e.jsx(O,{className:"text-[8px]",children:((B=s.requestedBy[0])==null?void 0:B.toUpperCase())||"?"})}),e.jsx("span",{children:s.requestedBy})]}),e.jsx("span",{children:"•"}),e.jsx(te,{className:"h-3 w-3"}),e.jsx("span",{children:se(s.requestedAt)})]}),s.requestNote&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:["“",s.requestNote,"”"]})]}),e.jsx(Q,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},s.id)})})})]})}function Je({nestId:c,enabled:x,reviewQueue:h,reviewableQueue:r,myPendingSubmissions:f,pendingDeletions:p,canManage:b,loading:T,onRefresh:v,onOpenDocument:u,onSelectRequest:F,onResolveDeletion:g,onWithdrawSubmission:L}){var Y,G,J;const a=me(),[s,N]=z.useState("all"),w=ge(c,x),[M,B]=z.useState([]),[n,W]=z.useState(!1),U=(((Y=w.data)==null?void 0:Y.items)??[]).filter(t=>t.type==="comment"),D=(()=>{const t=new Set(U.map(o=>o.id));return[...U,...M.filter(o=>!t.has(o.id))]})(),_=((J=(G=w.data)==null?void 0:G.counts)==null?void 0:J.comments)??U.length,ne=async()=>{W(!0);try{const o=(await a.fetchQuery(he.feed(c,"comments",je,D.length))).items.filter(l=>l.type==="comment");B(l=>{const C=new Set(l.map(y=>y.id));return[...l,...o.filter(y=>!C.has(y.id))]})}catch(t){console.error("[ReviewTab] getNestFeed load-more failed",c,t),P.error((t==null?void 0:t.message)||"Failed to load more comments")}finally{W(!1)}},[i,k]=z.useState(new Set),[m,I]=z.useState(null),ie=async(t,o)=>{const l=[...i],{succeeded:C,failed:y,results:V}=await pe(c,t,l,o||void 0),X=t==="approve"?"approved":"rejected";if(y===0)P.success(`${C} document${C===1?"":"s"} ${X}`),k(new Set);else{const oe=[...new Set(V.filter(j=>!j.ok).map(j=>j.error||"Unknown reason"))];P.warning(`${C} ${X}, ${y} could not be`,{description:oe.join(" "),duration:1e4}),k(new Set(V.filter(j=>!j.ok).map(j=>j.nodeId)))}I(null),a.invalidateQueries({queryKey:ue.nest(c)}),v()};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-1.5","data-testid":"feed-filter-chips",children:[{key:"all",label:"All"},{key:"changes",label:`Changes (${r.length})`},{key:"comments",label:`Comments (${_})`}].map(t=>e.jsx("button",{type:"button",onClick:()=>N(t.key),className:`rounded-full border px-3 py-1 text-xs font-medium transition-colors ${s===t.key?"border-primary bg-primary text-primary-foreground":"border-border text-muted-foreground hover:bg-muted hover:text-foreground"}`,"data-testid":`feed-filter-${t.key}`,children:t.label},t.key))}),s!=="comments"&&f.length>0&&e.jsxs($,{children:[e.jsxs(A,{className:"pb-3",children:[e.jsxs(S,{className:"text-lg flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4 text-blue-600"}),"Submitted by you — awaiting review"]}),e.jsx(K,{children:"Your edits are awaiting review by another user. You can't approve your own work due to separation of duties."})]}),e.jsx(R,{className:"space-y-2",children:f.map(t=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm hover:bg-muted/50",children:[e.jsx("button",{onClick:()=>u(t.nodeId),className:"flex-1 min-w-0 text-left truncate",children:t.title||t.nodeId}),e.jsx(E,{variant:"secondary",className:"text-[10px] shrink-0",children:"Awaiting review"}),e.jsx(d,{size:"sm",variant:"ghost",className:"shrink-0 h-7 px-2 text-muted-foreground",title:"Withdraw this submission and return the document to Draft",onClick:()=>L(t.nodeId),children:"Withdraw"})]},t.id))})]}),b&&p.length>0&&e.jsxs($,{children:[e.jsxs(A,{className:"pb-3",children:[e.jsxs(S,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4 text-destructive"}),"Deletion requests"]}),e.jsx(K,{children:"Documents flagged as stale. Delete them, or reject with a note."})]}),e.jsx(R,{className:"space-y-2",children:p.map(t=>e.jsxs("div",{"data-testid":"deletion-request-item",className:"flex items-center gap-3 rounded-md border px-3 py-2 text-sm",children:[e.jsxs("button",{className:"flex-1 min-w-0 text-left",onClick:()=>u(t.nodeId),children:[e.jsxs("span",{className:"font-medium truncate block",children:[t.title||t.nodeId,t.targetType&&t.targetType!=="document"&&e.jsx("span",{className:"ml-2 rounded bg-muted px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:t.targetType==="folder"?"Folder":t.targetType==="nest_archive"?"Archive nest":"Nest"})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.requestedBy," — “",t.reason,"”"]})]}),e.jsx(d,{variant:"ghost",size:"sm",onClick:()=>g(t,"decline"),children:"Reject"}),e.jsx(d,{variant:"ghost",size:"sm",className:t.targetType==="nest_archive"?"":"text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>g(t,"delete"),children:t.targetType==="nest_archive"?"Approve":"Delete"})]},t.id))})]}),s!=="comments"&&r.length>1&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border bg-muted/40 px-3 py-2 text-sm",children:[e.jsx(re,{checked:i.size===0?!1:i.size===r.length?!0:"indeterminate",onCheckedChange:t=>k(t===!0?new Set(r.map(o=>o.nodeId)):new Set),"aria-label":"Select every document you can review","data-testid":"review-queue-select-all"}),e.jsx("span",{className:"text-muted-foreground",children:i.size>0?`${i.size} selected`:`Select all ${r.length}`}),i.size>q&&e.jsxs("span",{className:"text-destructive",children:["Up to ",q," at a time — deselect"," ",i.size-q,"."]}),i.size>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(d,{size:"sm",disabled:i.size>q,onClick:()=>I("approve"),"data-testid":"bulk-approve",children:["Approve ",i.size]}),e.jsxs(d,{size:"sm",variant:"outline",disabled:i.size>q,onClick:()=>I("reject"),"data-testid":"bulk-reject",children:["Reject ",i.size]}),e.jsx(d,{size:"sm",variant:"ghost",onClick:()=>k(new Set),children:"Clear"})]})]}),e.jsx(ke,{requests:s==="comments"?[]:r,selectedNodeIds:i,onToggleSelect:r.length>1?t=>k(o=>{const l=new Set(o);return l.has(t)?l.delete(t):l.add(t),l}):void 0,comments:s==="changes"?void 0:D,onSelectComment:t=>u(t.nodeId,{thread:t.threadId}),loading:T,onRefresh:v,onSelect:F}),s!=="changes"&&D.length<_&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(d,{variant:"outline",size:"sm",onClick:ne,disabled:n,"data-testid":"feed-load-more",children:[n?e.jsx(ae,{className:"h-4 w-4 mr-1.5 animate-spin"}):null,"Load more comments (",_-D.length," remaining)"]})}),s!=="comments"&&h.length>0&&r.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:h.length===1?"1 pending review in this nest, but it doesn't require your action — it's either outside your steward scope or was submitted by you.":`${h.length} pending reviews in this nest, but none require your action — they're either outside your steward scope or were submitted by you.`}),m&&e.jsx(xe,{open:!0,onOpenChange:t=>!t&&I(null),title:m==="approve"?`Approve ${i.size} document${i.size===1?"":"s"}?`:`Reject ${i.size} document${i.size===1?"":"s"}?`,description:m==="approve"?"Approving publishes each one. Anything you can't review, or that changed since this queue loaded, is reported back and left alone.":"Each author gets the same reason and the work goes back to them.",label:m==="reject"?"Why?":"Comment (optional)",optionalReason:m==="approve",placeholder:"Shared with every author in this batch",confirmLabel:m==="approve"?"Approve all":"Reject all",destructive:m==="reject",onConfirm:t=>ie(m,t)})]})}export{Je as ReviewTab};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as b,j as e,L as S,w as j,bE as f,B as m,cK as k,cL as T,e as B,as as F,at as I,av as U,ax as L,aq as V,ae as P,F as q,Y as H,l as W,b_ as E,b$ as D,c1 as A,c2 as R,c0 as $,ah as K,ai as M,aj as Q,ak as Y,al as g}from"./index-WYDmEOfO.js";import{U as w}from"./user-plus-Ckm_Isyc.js";import{E as _}from"./MarkdownEditor-CKh4WSn-.js";import{T as G}from"./trash-2-B0HyPTnI.js";import{T as J}from"./tag-DeYC_mRv.js";import"./zap-D2ifcnYb.js";import"./index-BOVYgMvj.js";import"./arrow-left-CWIsv-sG.js";import"./x-mNtADYHc.js";const O={document:{label:"Document",icon:q},tag:{label:"Tag",icon:J},nest:{label:"Nest",icon:P}};function z({stewards:t,loading:n=!1,showScope:N=!1,className:l,onAddSteward:r,onRemove:c,onEditRole:i,compact:o=!1,currentUserEmail:x}){const[h,d]=b.useState(null),v=(x||"").toLowerCase(),p=async s=>{if(c){d(s);try{await c(s)}finally{d(null)}}},a=s=>{const C=O[s.scope];let u="";return s.scope==="tag"?u=s.tagName||"":s.scope==="document"&&(u=s.nodeTitle||s.nodePattern||""),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(C.icon,{className:"h-3 w-3"}),e.jsx("span",{children:C.label}),u&&e.jsxs("span",{className:"opacity-75",children:[": ",u]})]})},y=s=>(s.userEmail[0]||"?").toUpperCase();return n?e.jsx("div",{className:j("flex items-center justify-center py-4",l),children:e.jsx(S,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):t.length===0?e.jsxs("div",{className:j("text-center py-4",l),children:[e.jsx(f,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No stewards assigned"}),r&&e.jsxs(m,{variant:"outline",size:"sm",onClick:r,children:[e.jsx(w,{className:"h-4 w-4 mr-2"}),"Assign Steward"]})]}):o?e.jsxs("div",{className:j("flex items-center gap-1",l),children:[e.jsx(f,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex -space-x-2",children:t.slice(0,3).map(s=>e.jsx(k,{className:"h-6 w-6 border-2 border-background",children:e.jsx(T,{className:"text-[10px]",children:y(s)})},s.id))}),t.length>3&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",t.length-3]}),r&&e.jsx(m,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:r,children:e.jsx(w,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:j("space-y-2",l),children:[t.map(s=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg border bg-card",children:[e.jsx(k,{className:"h-8 w-8",children:e.jsx(T,{children:y(s)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s.userEmail}),N&&a(s),e.jsx("div",{className:"flex items-center gap-1 mt-1",children:e.jsx(B,{variant:"secondary",className:"text-[10px] px-1.5 py-0 capitalize",children:s.role})})]}),(i||c)&&s.userEmail.toLowerCase()!==v&&e.jsxs(F,{modal:!1,children:[e.jsx(I,{asChild:!0,children:e.jsx(m,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:h===s.id,children:h===s.id?e.jsx(S,{className:"h-4 w-4 animate-spin"}):e.jsx(_,{className:"h-4 w-4"})})}),e.jsxs(U,{align:"end",children:[i&&e.jsxs(L,{onClick:()=>i(s),children:[e.jsx(V,{className:"h-4 w-4 mr-2"}),"Edit Role"]}),c&&e.jsxs(L,{className:"text-destructive",onClick:()=>p(s.id),children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),"Remove"]})]})]})]},s.id)),r&&e.jsxs(m,{variant:"outline",className:"w-full",onClick:r,children:[e.jsx(w,{className:"h-4 w-4 mr-2"}),"Add Steward"]})]})}function ne({nestId:t,canManage:n,currentUserEmail:N,onAssign:l,onRemove:r,onEditRole:c}){var p;const i=H(W.stewards(t)),o=((p=i.data)==null?void 0:p.stewards)??[],[x,h]=b.useState("all"),[d,v]=b.useState("all");return e.jsxs(e.Fragment,{children:[e.jsxs(E,{className:"border-blue-200 bg-blue-50/40",children:[e.jsx(D,{className:"pb-2",children:e.jsxs(A,{className:"text-sm flex items-center gap-2",children:[e.jsx(f,{className:"h-4 w-4 text-blue-700"}),"How stewardship works"]})}),e.jsxs(R,{className:"text-xs text-muted-foreground space-y-2 leading-relaxed",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-foreground",children:"New documents start as drafts."})," ","They're not available to AI queries until a steward approves them."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-foreground",children:"Stewards"})," are people you name to govern content by scope. Resolution priority (first match wins):"]}),e.jsxs("ol",{className:"list-decimal list-inside ml-2 space-y-0.5",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Document"})," — this exact doc"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Tag"})," — everything with #tag"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Nest"})," — anything not matched above"]})]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-foreground",children:"Reviewers"})," can approve/reject;"," ",e.jsx("strong",{className:"text-foreground",children:"editors"})," can edit;"," ",e.jsx("strong",{className:"text-foreground",children:"viewers"})," have read access. Authors can't approve their own work."]})]})]}),e.jsxs(E,{children:[e.jsx(D,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(A,{className:"text-lg",children:"Stewards"}),e.jsx($,{children:i.isLoading?"Loading…":o.length===0?"Nobody's governing content yet":"Who governs what"})]}),o.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[["all","document","tag","nest"].map(a=>e.jsx("button",{onClick:()=>h(a),className:`text-xs px-2 py-1 rounded border ${x===a?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-border hover:bg-secondary"}`,children:a==="all"?"All":a.charAt(0).toUpperCase()+a.slice(1)},a)),e.jsx("span",{className:"w-px h-4 bg-border"}),e.jsxs(K,{value:d,onValueChange:a=>v(a),children:[e.jsx(M,{className:"w-[120px] h-7 text-xs",children:e.jsx(Q,{})}),e.jsxs(Y,{children:[e.jsx(g,{value:"all",children:"All"}),e.jsx(g,{value:"editor",children:"Editor"}),e.jsx(g,{value:"reviewer",children:"Reviewer"}),e.jsx(g,{value:"viewer",children:"Viewer"})]})]})]})]})}),e.jsx(R,{children:i.isLoading?e.jsx(z,{stewards:[],loading:!0,showScope:!0}):o.length===0?e.jsxs("div",{className:"text-sm space-y-3 py-2",children:[e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Without stewards, every draft needs the nest owner to approve. Add an editor/reviewer to delegate approvals for a tag or specific doc."}),n&&e.jsxs(m,{variant:"outline",size:"sm",className:"w-full",onClick:l,children:[e.jsx(f,{className:"h-3.5 w-3.5 mr-2"}),"Assign your first steward"]})]}):e.jsx(z,{stewards:o.filter(a=>(x==="all"||a.scope===x)&&(d==="all"||a.role===d)),showScope:!0,onAddSteward:n?l:void 0,onRemove:n?async a=>r(a):void 0,onEditRole:n?c:void 0,currentUserEmail:N})})]})]})}export{ne as StewardsTab};
|