@promptowl/contextnest-community 1.25.0 → 1.26.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.
Files changed (120) hide show
  1. package/API.md +68 -8
  2. package/CONFIGURATION.md +572 -116
  3. package/README.md +3 -2
  4. package/dist/{chunk-32SZCH36.js → chunk-2QOJE7A5.js} +4 -4
  5. package/dist/{chunk-2KHM5C7V.js → chunk-DGPTJXIV.js} +13 -15
  6. package/dist/chunk-I5EDEZBQ.js +523 -0
  7. package/dist/{chunk-TI7HMP64.js → chunk-IEAWRHMV.js} +2 -2
  8. package/dist/{chunk-DTLMBF4W.js → chunk-M6PGYMBD.js} +15 -8
  9. package/dist/{chunk-F66VCBLA.js → chunk-PICUHQEM.js} +51 -2
  10. package/dist/{chunk-KPGNZLZL.js → chunk-RPGFHESR.js} +1 -1
  11. package/dist/{chunk-7FROMOZM.js → chunk-SWA5M5XX.js} +68 -544
  12. package/dist/{chunk-JDAOA5KP.js → chunk-TRSGPS27.js} +39 -14
  13. package/dist/{engine-TER6FDBP.js → engine-QNMFDIBV.js} +3 -2
  14. package/dist/{external-edit-service-CAGENHDJ.js → external-edit-service-4MEGPT4D.js} +4 -3
  15. package/dist/{grants-service-2OTFS7EH.js → grants-service-24GLUBY4.js} +2 -2
  16. package/dist/index.js +911 -263
  17. package/dist/invited-user-AM6A3WGO.js +12 -0
  18. package/dist/{migrations.postgres-23VJJJJX.js → migrations.postgres-HGSQ7IA5.js} +4 -0
  19. package/dist/{review-service-4G2XUFS6.js → review-service-2EWN7WWO.js} +7 -6
  20. package/dist/{stewardship-service-S22V2JKG.js → stewardship-service-TDZUC2Q6.js} +4 -3
  21. package/dist/{version-service-X4FAG2OZ.js → version-service-C3JTZLJH.js} +4 -3
  22. package/dist/web3/assets/ActivityTracePage-DzwWIjjx.js +1 -0
  23. package/dist/web3/assets/{AgentDocsPage-Dkhgb1hk.js → AgentDocsPage-ixP2UdAE.js} +1 -1
  24. package/dist/web3/assets/CollaboratorManager-C9VAXZ0h.js +1 -0
  25. package/dist/web3/assets/CollaboratorsTab-tq4ZTexH.js +1 -0
  26. package/dist/web3/assets/DocumentEditor-C2CP2fiE.js +36 -0
  27. package/dist/web3/assets/DocumentsTab-Mh7KxUoB.js +6 -0
  28. package/dist/web3/assets/ExternalEditsTab-B_CWKXZ_.js +1 -0
  29. package/dist/web3/assets/{MarkdownEditor-Dfk5uIE5.js → MarkdownEditor-CKh4WSn-.js} +136 -131
  30. package/dist/web3/assets/MarkdownEditor-ndtIx5x0.css +1 -0
  31. package/dist/web3/assets/NestPageHeader-Cizo8nUi.js +1 -0
  32. package/dist/web3/assets/NestView-EW-sraEb.js +73 -0
  33. package/dist/web3/assets/OverviewTab-CjidsMX_.js +6 -0
  34. package/dist/web3/assets/PersonCombobox-BKI7dff4.js +1 -0
  35. package/dist/web3/assets/{ReviewActions-BXDTDPp1.js → ReviewActions-CS8JXgXF.js} +2 -2
  36. package/dist/web3/assets/ReviewTab-CwVrXzw5.js +1 -0
  37. package/dist/web3/assets/StewardsTab-C-iP6gnh.js +1 -0
  38. package/dist/web3/assets/SubmitForReviewModal-Biq3m79i.js +1 -0
  39. package/dist/web3/assets/{alert-dialog-4SiLKlz8.js → alert-dialog-BvF3NFr7.js} +2 -2
  40. package/dist/web3/assets/{arrow-left-BAgIocLn.js → arrow-left-CWIsv-sG.js} +1 -1
  41. package/dist/web3/assets/backlinks-Cqcn7n1J.js +19 -0
  42. package/dist/web3/assets/boxes-ClbgQqG2.js +6 -0
  43. package/dist/web3/assets/{chevron-left-XR4ReJ9Z.js → chevron-left-CK_ZPFm9.js} +1 -1
  44. package/dist/web3/assets/{circle-check-CSkZUEFK.js → circle-check-Bw_aTXiH.js} +1 -1
  45. package/dist/web3/assets/{circle-x-in2o3aHU.js → circle-x-DkIG68H7.js} +1 -1
  46. package/dist/web3/assets/{code-xml-pPQgdctI.js → code-xml-BlR7EN6l.js} +1 -1
  47. package/dist/web3/assets/{corner-down-right-CuxZWscX.js → corner-down-right-DSVxK3tf.js} +1 -1
  48. package/dist/web3/assets/count-skeleton-DToLM74B.js +1 -0
  49. package/dist/web3/assets/{earth-CXOcThqn.js → earth-BXhVPvCR.js} +1 -1
  50. package/dist/web3/assets/{file-exclamation-point-CSphs1VD.js → file-exclamation-point-BevGZgtj.js} +1 -1
  51. package/dist/web3/assets/{folder-input-BAwK9tFL.js → folder-input-m8UBV4fA.js} +1 -1
  52. package/dist/web3/assets/{index-A0_ymcqL.js → index-BOVYgMvj.js} +1 -1
  53. package/dist/web3/assets/index-DVnaYqj9.css +1 -0
  54. package/dist/web3/assets/index-WYDmEOfO.js +404 -0
  55. package/dist/web3/assets/page-B6pkc9cd.js +2 -0
  56. package/dist/web3/assets/page-BJrFCKXB.js +1 -0
  57. package/dist/web3/assets/page-Bgy9Ng9p.js +1 -0
  58. package/dist/web3/assets/page-C2zoxumw.js +1 -0
  59. package/dist/web3/assets/page-CJWO06dN.js +1 -0
  60. package/dist/web3/assets/page-CptuAPJc.js +6 -0
  61. package/dist/web3/assets/page-DPY01SOj.js +1 -0
  62. package/dist/web3/assets/page-Dea2SblF.js +9 -0
  63. package/dist/web3/assets/page-Deq6IKiN.js +6 -0
  64. package/dist/web3/assets/page-Dfjg8p7Z.js +1 -0
  65. package/dist/web3/assets/{page-xzYqkBUP.js → page-Dh57L0RG.js} +5 -5
  66. package/dist/web3/assets/page-Dwbp4Seu.js +6 -0
  67. package/dist/web3/assets/{page-CUjuSs5Q.js → page-DzKwP5Ds.js} +3 -3
  68. package/dist/web3/assets/page-YxjrE5b5.js +45 -0
  69. package/dist/web3/assets/{page-title-BkqlUA0j.js → page-title-DVq4qvMR.js} +1 -1
  70. package/dist/web3/assets/{play-B8xE9j5f.js → play-CXhS6Pgq.js} +1 -1
  71. package/dist/web3/assets/{send-CvAgOUPG.js → send-DdfwnIrj.js} +1 -1
  72. package/dist/web3/assets/{settings-EY4A_DYv.js → settings-DKX0Q4gO.js} +1 -1
  73. package/dist/web3/assets/{share-2-vGmZUl90.js → share-2-CxmXRt58.js} +1 -1
  74. package/dist/web3/assets/{tag-Br_y1f00.js → tag-DeYC_mRv.js} +1 -1
  75. package/dist/web3/assets/{trash-2-B4hRXo-p.js → trash-2-B0HyPTnI.js} +1 -1
  76. package/dist/web3/assets/{user-plus-4CTYEkd3.js → user-plus-Ckm_Isyc.js} +1 -1
  77. package/dist/web3/assets/{x-qxt1WrUi.js → x-mNtADYHc.js} +1 -1
  78. package/dist/web3/assets/{zap-BcsKR0ef.js → zap-D2ifcnYb.js} +1 -1
  79. package/dist/web3/index.html +2 -2
  80. package/package.json +3 -2
  81. package/dist/client-D44ZHDTJ.js +0 -11
  82. package/dist/keys-CTOGAG3W.js +0 -20
  83. package/dist/web3/assets/ActivityTracePage-D2iIbEph.js +0 -1
  84. package/dist/web3/assets/CollaboratorManager-Bo81D--Q.js +0 -1
  85. package/dist/web3/assets/CollaboratorsTab-DRCitQuX.js +0 -1
  86. package/dist/web3/assets/DocumentEditor-DV2WHYbj.js +0 -36
  87. package/dist/web3/assets/DocumentsTab-BUxBCN8o.js +0 -6
  88. package/dist/web3/assets/ExternalEditsTab-kIBimZyE.js +0 -1
  89. package/dist/web3/assets/MarkdownEditor-CsVusP2d.css +0 -1
  90. package/dist/web3/assets/NestPageHeader-yOK-OIYZ.js +0 -1
  91. package/dist/web3/assets/NestView-DwIagxwJ.js +0 -68
  92. package/dist/web3/assets/OverviewTab-DFOFMVyE.js +0 -1
  93. package/dist/web3/assets/PersonCombobox-D350WlrJ.js +0 -1
  94. package/dist/web3/assets/ReasonDialog-CN3ECAnQ.js +0 -1
  95. package/dist/web3/assets/ReviewTab-CZewAYiz.js +0 -1
  96. package/dist/web3/assets/StewardsTab-AagNWcWS.js +0 -1
  97. package/dist/web3/assets/SubmitForReviewModal-BOZJxwRN.js +0 -1
  98. package/dist/web3/assets/backlinks-Cb8Uf8mw.js +0 -24
  99. package/dist/web3/assets/card-UDyMRcps.js +0 -1
  100. package/dist/web3/assets/count-skeleton-DBWCDhRy.js +0 -1
  101. package/dist/web3/assets/dates-BCxbm4_q.js +0 -1
  102. package/dist/web3/assets/index-B5hLclEq.js +0 -389
  103. package/dist/web3/assets/index-DrUAtoQM.css +0 -1
  104. package/dist/web3/assets/page-BHD4beun.js +0 -1
  105. package/dist/web3/assets/page-BSYUXYmO.js +0 -11
  106. package/dist/web3/assets/page-BYc2DIux.js +0 -45
  107. package/dist/web3/assets/page-BfibLg8e.js +0 -1
  108. package/dist/web3/assets/page-CGe8MtUu.js +0 -9
  109. package/dist/web3/assets/page-CIgPJmG6.js +0 -2
  110. package/dist/web3/assets/page-Ck31nx9b.js +0 -1
  111. package/dist/web3/assets/page-Cpdj_11Y.js +0 -1
  112. package/dist/web3/assets/page-D0sN3GO6.js +0 -1
  113. package/dist/web3/assets/page-DEpH91X2.js +0 -1
  114. package/dist/web3/assets/page-l8-B7CGt.js +0 -1
  115. package/dist/web3/assets/page-mnSHmk6A.js +0 -6
  116. package/dist/web3/assets/refresh-cw-CsCtmWwX.js +0 -6
  117. package/dist/web3/assets/scroll-area-CbcH6yrZ.js +0 -1
  118. package/dist/web3/assets/scroll-area-dRWncRqa.css +0 -1
  119. package/dist/web3/assets/select-DrL0mpRN.js +0 -6
  120. package/dist/web3/assets/triangle-alert-CsYGyfGZ.js +0 -6
@@ -1,6 +0,0 @@
1
- import{c as Ws,j as e,e as Ke,s as At,u as Qs,S as Lt,i as He,r as n,bT as Us,bw as Gs,I as Be,cm as Ks,bx as Et,az as Rt,a1 as Ie,B as j,aP as Vt,L as We,ac as B,bz as Ys,D as zt,x as Ot,y as qt,z as Ht,H as Bt,a5 as Js,f as b,k as Xs,w as Zs,dP as er,ag as It,ad as Wt,aA as tr,dQ as sr,bG as rr,aq as ar,ar as lr,ah as or,ai as nr,ak as ir,am as I,an as cr}from"./index-B5hLclEq.js";import{e as dr,S as ur,P as mr,V as hr,A as pr,H as Qt}from"./backlinks-Cb8Uf8mw.js";import{j as xr,z as fr,n as Qe,U as gr,F as vr,E as yr}from"./MarkdownEditor-Dfk5uIE5.js";import{S as Z,a as ee,b as te,c as se,d as f,f as jr}from"./select-DrL0mpRN.js";import"./scroll-area-CbcH6yrZ.js";import{C as br,a as Nr,c as wr,d as Cr}from"./card-UDyMRcps.js";import{S as Sr}from"./SubmitForReviewModal-BOZJxwRN.js";import{R as Ue}from"./ReasonDialog-CN3ECAnQ.js";import{F as kr}from"./file-exclamation-point-CSphs1VD.js";import{C as Dr}from"./circle-x-in2o3aHU.js";import{C as Ye}from"./circle-check-CSkZUEFK.js";import{C as Tr,c as Fr,d as Ut,f as S,S as Gt,T as Kt,D as Yt,F as $r,N as Jt,t as Pr}from"./NestView-DwIagxwJ.js";import{f as Mr}from"./folder-target-CUSWqImF.js";import{X as ce}from"./x-qxt1WrUi.js";import{F as Se}from"./folder-input-BAwK9tFL.js";import{S as Xt}from"./share-2-vGmZUl90.js";import{T as de}from"./trash-2-B4hRXo-p.js";import{S as Zt}from"./send-CvAgOUPG.js";import"./dates-BCxbm4_q.js";import"./client-attribution-BraarYaP.js";import"./arrow-left-BAgIocLn.js";import"./zap-BcsKR0ef.js";import"./triangle-alert-CsYGyfGZ.js";import"./index-A0_ymcqL.js";import"./chevron-left-XR4ReJ9Z.js";import"./alert-dialog-4SiLKlz8.js";import"./NestPageHeader-yOK-OIYZ.js";import"./count-skeleton-DBWCDhRy.js";import"./PersonCombobox-D350WlrJ.js";import"./tag-Br_y1f00.js";import"./refresh-cw-CsCtmWwX.js";import"./user-plus-4CTYEkd3.js";import"./ReviewActions-BXDTDPp1.js";import"./settings-EY4A_DYv.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 _r=[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]],Ar=Ws("file-pen",_r),es={draft:{label:"Draft",icon:Ar,className:"bg-gray-100 text-gray-700 border-gray-200"},pending_review:{label:"Pending Review",icon:Tr,className:"bg-amber-100 text-amber-700 border-amber-200"},approved:{label:"Approved",icon:Ye,className:"bg-green-100 text-green-700 border-green-200"},published:{label:"Published",icon:Ye,className:"bg-green-100 text-green-700 border-green-200"},rejected:{label:"Rejected",icon:Dr,className:"bg-red-100 text-red-700 border-red-200"},external_edit_pending:{label:"External Edit",icon:kr,className:"bg-orange-100 text-orange-700 border-orange-200"}};function Lr({status:r,approvedVersion:m,currentVersion:l,showIcon:h=!0,size:g="default",className:i}){const u=es[r]||es.draft,w=u.icon,D=(r==="approved"||r==="published")&&m&&l&&m<l;return e.jsxs(Ke,{variant:"outline",className:At("!rounded-sm",u.className,g==="sm"&&"text-[10px] px-1.5 py-0",i),children:[h&&e.jsx(w,{className:At("mr-1",g==="sm"?"h-3 w-3":"h-3.5 w-3.5")}),u.label,D&&e.jsxs("span",{className:"ml-1 text-[10px] opacity-75",children:["(v",m,")"]})]})}function ts(r){return r.replace(/^#/,"").toLowerCase()}function ss(r,m){var D;const{search:l,status:h,tags:g,author:i,updatedAfter:u,type:w}=m;if(h&&h!=="all"&&r.status!==h||w&&w!=="all"&&(r.type||"document")!==w||i&&i!=="all"&&(r.author??"").toLowerCase()!==i.toLowerCase())return!1;if(u!=null){const T=r.updated_at?Date.parse(r.updated_at):NaN;if(Number.isNaN(T)||T<u)return!1}if(l){const T=l.toLowerCase(),re=((D=r.title)==null?void 0:D.toLowerCase().includes(T))??!1,ue=Array.isArray(r.tags)?r.tags.some(ke=>ke.toLowerCase().includes(T)):!1;if(!re&&!ue)return!1}if(g&&g.length>0){const T=new Set((r.tags??[]).map(ts));if(!g.every(re=>T.has(ts(re))))return!1}return!0}function Er(r){const m=r.startsWith("nodes/")?r.slice(6):r,l=m.lastIndexOf("/");return l>0?m.slice(0,l):""}function as(r){return!!r.search||r.status!=="all"||r.type!=="all"||r.tags.length>0||r.author!=="all"||r.datePreset!=="any"}function Rr(r){return(as({search:r.search,status:r.status,type:r.type,author:r.author,tags:r.tags,datePreset:r.updatedAfter?"on":"any"})?r.fullNodes??r.levelNodes:r.levelNodes).filter(h=>{if(r.folderFilter!==null){const g=Er(h.id||"");if(g!==r.folderFilter&&!g.startsWith(`${r.folderFilter}/`))return!1}return ss(h,{status:r.status,tags:r.tags,author:r.author,updatedAfter:r.updatedAfter,type:r.type})?r.search?ss(h,{search:r.search})||r.contentHits.has(h.id):!0:!1})}function Vr(r){return r.visibleCount>0?!1:r.filtering||r.folderCount===0}const zr=3;function Or(r,m=zr){const l=new Map;for(const i of r)for(const u of new Set(i.tags??[]))l.set(u,(l.get(u)??0)+1);const h=[...l.entries()].sort((i,u)=>u[1]-i[1]||i[0].localeCompare(u[0])).map(([i,u])=>({tag:i,count:u})),g=r.filter(i=>i.updated_at).sort((i,u)=>String(u.updated_at).localeCompare(String(i.updated_at))).slice(0,m).map(i=>({id:i.id,title:i.title??i.id,type:i.type||"document",updated_at:i.updated_at}));return{tags:h,recent:g}}function rs(r,m){const l=r||"",h=m||"";return l>h?l:h}function qr(r){const m=new Set,l=[];let h=!1;for(const i of r)for(const u of dr(i.content??"")){h=!0;const w=xr(r,u);w?w.id!==i.id&&m.add(w.id):l.push({sourceId:i.id,sourceTitle:i.title,target:u})}return{orphans:h?r.filter(i=>!m.has(i.id)).map(i=>({id:i.id,title:i.title})):[],broken:l}}const Hr={"7d":7,"30d":30,"90d":90,"1y":365};function Br(r,m){if(!(!r||r==="any"))return m-Hr[r]*24*60*60*1e3}function Ir(r,m){const l=m.name.toLowerCase();return[...r.filter(h=>h.name.toLowerCase()!==l),m]}function Wr(r,m){const l=m.toLowerCase();return r.filter(h=>h.name.toLowerCase()!==l)}function Qr(r){if(!r)return[];try{const m=JSON.parse(r);return Array.isArray(m)?m.filter(l=>l&&typeof l.name=="string"&&l.name.trim()).map(l=>({name:String(l.name),search:typeof l.search=="string"?l.search:void 0,status:typeof l.status=="string"?l.status:void 0,tags:Array.isArray(l.tags)?l.tags.filter(h=>typeof h=="string"):void 0,author:typeof l.author=="string"?l.author:void 0,datePreset:typeof l.datePreset=="string"?l.datePreset:void 0})):[]}catch{return[]}}function Ur(r){return JSON.stringify(r)}const Ge={search:"",tags:[],status:"all",type:"all",author:"all",datePreset:"any"};function $a({nestId:r,initialSearch:m,initialTags:l,initialLoad:h,loading:g,nodes:i,census:u,knownFolders:w,folderFilter:D,setFolderFilter:T,expandedFolders:re,loadingFolders:ue,toggleFolderExpanded:ke,expandFolder:ls,caps:os,isAdmin:ns,isOwner:Je,roles:is,permission:Gr,currentEmail:ae,myStewards:cs,stewardshipEnabled:De,allowSelfApprove:ds,primeTags:us,visibility:Kr,hasRoleOnNode:ms,canReviewNode:hs,reviewQueue:ps,reviewableQueue:xs,deletionRequests:W,stats:fs,onOpenDocument:A,onReview:Xe,onRefresh:gs,onWithdrawDeletion:Ze,importInputRef:vs}){var St,kt,Dt;const{canManage:v,collabCanWrite:ys,canEditDocs:me,isReadOnly:et}=os,js=Qs(),Q=((St=Lt(He.commentCounts(r)).data)==null?void 0:St.counts)??{},L=gs,[le,tt]=n.useState(null),[Te,st]=n.useState(null),[E,rt]=n.useState(null),[Fe,at]=n.useState(null),$e=n.useMemo(()=>{const s=new Map;for(const t of W)(t.targetType??"document")==="document"&&!s.has(t.nodeId)&&s.set(t.nodeId,t);return s},[W]),bs=n.useMemo(()=>new Set(W.filter(s=>s.targetType==="folder"&&s.status==="pending").map(s=>s.nodeId)),[W]),lt=s=>bs.has(s),Ns=n.useMemo(()=>{const s=new Map;for(const t of W)t.targetType==="folder"&&t.status==="pending"&&!s.has(t.nodeId)&&s.set(t.nodeId,t);return s},[W]),[he,ot]=n.useState(null),[P,pe]=n.useState(null),[M,nt]=n.useState(null),[ws,Cs]=n.useState({versions:[],approvedVersion:null,currentVersion:0}),Ss=s=>{const t=i.find(a=>{const d=S(a.id||"");return d===s||d.startsWith(`${s}/`)});return Mr(s,(t==null?void 0:t.id)??null)},it=async(s,t)=>{if(S(s)===t)return!0;const a=t?B(t):"nest root",d=b.loading(`Moving to ${a}…`);try{const{node:x,previousId:y}=await Wt(r,s,t),_=S(y);return b.success(t?`Moved to ${a}`:"Moved to nest root",{id:d,action:{label:"Undo",onClick:async()=>{try{await Wt(r,x.id,_),b.success("Move undone"),L()}catch(c){console.error("[NestView] undo move failed",r,x.id,c),b.error((c==null?void 0:c.message)||"Undo failed")}}},duration:6e3}),L(),!0}catch(x){return console.error("[NestView] moveNode failed",r,s,t,x),b.error((x==null?void 0:x.message)||"Move failed",{id:d}),!1}},[R,xe]=n.useState(null),[Pe,ct]=n.useState(""),[fe,dt]=n.useState(!1),[U,ge]=n.useState(null),V=Fr(U??""),ut=U===null?Pe:V.path,ks=n.useMemo(()=>((u==null?void 0:u.folders)??[]).map(s=>s.path).sort(Ut),[u]),mt=new Map;for(const s of ps)mt.set(s.nodeId,s.requestedBy.toLowerCase());const ve=s=>s?s.myGrant==="write"?!0:et?!1:v||ys?!0:cs.some(t=>{if(t.role!=="editor")return!1;if(t.scope==="nest")return!0;if(t.scope==="document")return t.nodePattern===s.id;if(t.scope==="tag"){const a=(t.tagName||"").toLowerCase().replace(/^#+/,"");return(s.tags||[]).map(d=>d.toLowerCase().replace(/^#+/,"")).includes(a)}return!1}):!1,Ds=new Set(xs.map(s=>s.nodeId)),ye=async s=>{nt(s);try{const t=await js.fetchQuery(He.nodeVersions(r,s.id));Cs(t)}catch(t){console.error("[NestView] getNodeVersions failed",r,s==null?void 0:s.id,t)}},Ts=async(s,t)=>{if(P)try{await tr(r,P.id,s,t),b.success("Submitted for review"),pe(null),L()}catch(a){console.error("[NestView] submitForReview failed",r,P==null?void 0:P.id,a),b.error((a==null?void 0:a.message)||"Submit failed")}},Fs=async()=>{const s=Te;try{await ar(r,s.id),L()}catch(t){throw console.error("[NestView] deleteNode failed",r,s==null?void 0:s.id,t),t}},$s=async s=>{await lr(r,le.id,s),b.success("Deletion requested — a nest admin will review it"),L()},Ps=async s=>{const t=E;if(v){const{deleted:a}=await sr(r,t.path);b.success(`Deleted ${t.label} — ${a} document${a===1?"":"s"}`)}else await rr(r,"folder",t.path,s),b.success("Deletion requested — a nest admin will review it");L()},k=D??"",Ms=k?k.split("/").length:0,[Me,_s]=n.useState(!1),ht=Lt({...He.nodes(r),enabled:Me}),G=Me?((kt=ht.data)==null?void 0:kt.nodes)??null:null,As=Me&&ht.isLoading,_e=n.useCallback(()=>_s(!0),[]),[o,je]=n.useState({...Ge,search:m??"",tags:l??[]}),C=(s,t)=>je(a=>({...a,[s]:t})),pt=s=>je(t=>({...t,tags:t.tags.includes(s)?t.tags.filter(a=>a!==s):[...t.tags,s]})),[be,Ls]=n.useState("activity"),[z,xt]=n.useState(()=>{try{return localStorage.getItem("nest:viewMode")==="cards"?"cards":"list"}catch{return"list"}});n.useEffect(()=>{try{localStorage.setItem("nest:viewMode",z)}catch{}},[z]);const Ae=`nest:${r}:savedFilters`,[Ne,Le]=n.useState([]);n.useEffect(()=>{try{Le(Qr(localStorage.getItem(Ae)))}catch{Le([])}},[Ae]);const ft=s=>{Le(s);try{localStorage.setItem(Ae,Ur(s))}catch{}},[Es,we]=n.useState(!1),[Ee,gt]=n.useState(""),vt=()=>{const s=Ee.trim();s&&(ft(Ir(Ne,{name:s,search:o.search||void 0,status:o.status!=="all"?o.status:void 0,tags:o.tags.length?o.tags:void 0,author:o.author!=="all"?o.author:void 0,datePreset:o.datePreset!=="any"?o.datePreset:void 0,type:o.type!=="all"?o.type:void 0})),gt(""),we(!1))},Rs=({name:s,...t})=>je({...Ge,...Object.fromEntries(Object.entries(t).filter(([,a])=>a!==void 0))}),[Vs,yt]=n.useState(new Set);n.useEffect(()=>{const s=o.search.trim();if(s.length<2){yt(new Set);return}let t=!1;const a=setTimeout(async()=>{try{const{nodes:d}=await Us(r,s);t||yt(new Set(d.map(x=>x.id)))}catch{}},300);return()=>{t=!0,clearTimeout(a)}},[r,o.search]);const O=as(o);n.useEffect(()=>{O&&_e()},[O,_e]);const zs=Br(o.datePreset,Date.now()),oe=Rr({...o,levelNodes:i,fullNodes:G,folderFilter:D,updatedAfter:zs,contentHits:Vs}),K=[...oe];be==="activity"?K.sort((s,t)=>{var a,d;return rs(t.updated_at,(a=Q[t.id])==null?void 0:a.lastAt).localeCompare(rs(s.updated_at,(d=Q[s.id])==null?void 0:d.lastAt))}):be==="edited"?K.sort((s,t)=>String(t.updated_at||"").localeCompare(String(s.updated_at||""))):be==="comments"?K.sort((s,t)=>{var _,c,N,J;const a=((_=Q[t.id])==null?void 0:_.count)||0,d=((c=Q[s.id])==null?void 0:c.count)||0;if(a!==d)return a-d;const x=((N=Q[t.id])==null?void 0:N.lastAt)||"",y=((J=Q[s.id])==null?void 0:J.lastAt)||"";return x!==y?String(x).localeCompare(String(y)):String(s.title||"").localeCompare(String(t.title||""))}):K.sort((s,t)=>String(s.title||"").localeCompare(String(t.title||"")));const Os=(()=>{const s=new Map;for(const t of K){const a=S(t.id||"");s.has(a)||s.set(a,[]),s.get(a).push(t)}return[...s.entries()].map(([t,a])=>({folder:t,depth:t?t.split("/").length-Ms:0,items:a})).sort((t,a)=>t.folder===""?-1:a.folder===""?1:Ut(t.folder,a.folder))})(),qs=Vr({visibleCount:oe.length,folderCount:w.length,filtering:O}),F=n.useMemo(()=>G?qr(G):{orphans:[],broken:[]},[G]),jt=(u==null?void 0:u.authors)??[],bt=n.useMemo(()=>Object.keys((u==null?void 0:u.types)??{}).sort((s,t)=>s.localeCompare(t)),[u]),Hs=()=>{je({...Ge})},Y=[];o.search&&Y.push({label:`Search: ${o.search}`,clear:()=>C("search","")}),o.status!=="all"&&Y.push({label:`Status: ${Gt[o.status]??o.status}`,clear:()=>C("status","all")}),o.type!=="all"&&Y.push({label:`Type: ${Kt[o.type]??o.type}`,clear:()=>C("type","all")}),o.author!=="all"&&Y.push({label:`Author: ${o.author}`,clear:()=>C("author","all")}),o.datePreset!=="any"&&Y.push({label:`Edited: ${Yt[o.datePreset]??o.datePreset}`,clear:()=>C("datePreset","any")});const Nt=n.useMemo(()=>Or(oe),[oe]),Ce=Nt.tags,wt=Nt.recent,[$,Re]=n.useState(null),[Ct,q]=n.useState(null),ne=n.useRef(null),ie=()=>{ne.current&&(clearTimeout(ne.current),ne.current=null)};n.useEffect(()=>ie,[]);const Bs=s=>{ie(),ne.current=setTimeout(()=>{ne.current=null,ls(s)},600)},Ve=s=>{const t=$;Re(null),q(null),ie(),t&&setTimeout(()=>void it(t,s),0)};return e.jsxs(e.Fragment,{children:[e.jsxs(br,{children:[e.jsx(Nr,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(wr,{className:"text-lg",children:"Documents"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full",children:[e.jsxs("div",{className:"relative flex-1 min-w-[12rem] sm:flex-none sm:w-80",children:[e.jsx(Gs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),e.jsx(Be,{placeholder:"Search title, tags, content…",value:o.search,onChange:s=>C("search",s.target.value),className:"pl-9 pr-12 w-full h-8"}),e.jsx("kbd",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground border rounded px-1 pointer-events-none",title:"Quick open",children:"⌘K"})]}),De&&e.jsxs(Z,{value:o.status,onValueChange:s=>C("status",s),children:[e.jsx(ee,{className:"w-[140px] h-8",children:e.jsx(te,{})}),e.jsxs(se,{children:[e.jsx(f,{value:"all",children:"All Status"}),Object.entries(Gt).map(([s,t])=>e.jsx(f,{value:s,children:t},s))]})]}),bt.length>1&&e.jsxs(Z,{value:o.type,onValueChange:s=>C("type",s),children:[e.jsx(ee,{className:"w-[130px] h-8",title:"Filter by type",children:e.jsx(te,{})}),e.jsxs(se,{children:[e.jsx(f,{value:"all",children:"All types"}),bt.map(s=>e.jsx(f,{value:s,children:Kt[s]??s},s))]})]}),jt.length>1&&e.jsxs(Z,{value:o.author,onValueChange:s=>C("author",s),children:[e.jsx(ee,{className:"w-[150px] h-8",title:"Filter by author",children:e.jsx(te,{})}),e.jsxs(se,{children:[e.jsx(f,{value:"all",children:"All authors"}),jt.map(s=>e.jsx(f,{value:s,children:s},s))]})]}),e.jsxs(Z,{value:o.datePreset,onValueChange:s=>C("datePreset",s),children:[e.jsx(ee,{className:"w-[140px] h-8",title:"Filter by last edited",children:e.jsx(te,{})}),e.jsxs(se,{children:[e.jsx(f,{value:"any",children:"Any time"}),Object.entries(Yt).map(([s,t])=>e.jsx(f,{value:s,children:t},s))]})]}),e.jsxs(Z,{value:be,onValueChange:s=>Ls(s),children:[e.jsx(ee,{className:"w-[150px] h-8",title:"Sort documents",children:e.jsx(te,{})}),e.jsxs(se,{children:[e.jsx(f,{value:"activity",children:"Recent activity"}),e.jsx(f,{value:"name",children:"Name (A–Z)"}),e.jsx(f,{value:"edited",children:"Recently edited"}),e.jsx(f,{value:"comments",children:"Most comments"})]})]}),e.jsxs("div",{className:"flex items-center rounded-md border h-8",children:[e.jsx("button",{type:"button",title:"List view","aria-pressed":z==="list",className:`px-2 h-full rounded-l-md ${z==="list"?"bg-muted":"hover:bg-muted/50"}`,onClick:()=>xt("list"),children:e.jsx(fr,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",title:"Card view","aria-pressed":z==="cards",className:`px-2 h-full rounded-r-md ${z==="cards"?"bg-muted":"hover:bg-muted/50"}`,onClick:()=>xt("cards"),children:e.jsx(Ks,{className:"h-4 w-4"})})]})]})]})}),e.jsxs(Cr,{children:[D!==null&&e.jsxs("div",{className:"flex items-center flex-wrap gap-1 mb-3 text-sm",children:[e.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:()=>T(null),children:"All documents"}),D.split("/").map((s,t,a)=>{const d=a.slice(0,t+1).join("/"),x=t===a.length-1;return e.jsxs(n.Fragment,{children:[e.jsx(Et,{className:"h-3.5 w-3.5 text-muted-foreground/50"}),x?e.jsxs("span",{className:"font-medium flex items-center gap-1",children:[e.jsx(Rt,{className:"h-4 w-4 text-blue-500"}),Ie(s)]}):e.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:()=>T(d),children:Ie(s)})]},d)}),e.jsx(Ke,{variant:"secondary",className:"ml-1 text-[10px] px-1.5 py-0 h-5",children:oe.length}),me&&e.jsxs(j,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground ml-1",onClick:()=>A("new",{folder:D}),title:"New document in this folder",children:[e.jsx(Vt,{className:"h-3.5 w-3.5 mr-1"})," New here"]})]}),Ne.length>0&&e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mb-2 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Saved:"}),Ne.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 hover:bg-muted",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1",onClick:()=>Rs(s),title:`Apply saved filter "${s.name}"`,children:[e.jsx(Qe,{className:"h-3 w-3 text-amber-500"}),s.name]}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>ft(Wr(Ne,s.name)),title:`Delete saved filter "${s.name}"`,children:e.jsx(ce,{className:"h-3 w-3"})})]},s.name))]}),O&&e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mb-3 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Active filters:"}),Y.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5",children:[s.label,e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:s.clear,title:"Remove this filter",children:e.jsx(ce,{className:"h-3 w-3"})})]},s.label)),o.tags.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5",children:["Tags: ",o.tags.join(", "),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>C("tags",[]),title:"Remove tag filters",children:e.jsx(ce,{className:"h-3 w-3"})})]}),e.jsxs(j,{variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>we(!0),children:[e.jsx(Qe,{className:"h-3 w-3 mr-1"}),"Save filter"]}),e.jsx(j,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground",onClick:Hs,children:"Clear all"})]}),Ce.length>0&&e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mb-3 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tags:"}),Ce.slice(0,14).map(({tag:s,count:t})=>{const a=o.tags.includes(s);return e.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 transition-colors ${a?"bg-primary text-primary-foreground border-primary":"text-foreground/80 hover:bg-muted"}`,onClick:()=>pt(s),title:a?`Remove filter ${s}`:`Filter by ${s}`,children:[s,e.jsx("span",{className:a?"text-primary-foreground/80":"text-muted-foreground",children:a?"×":t})]},s)}),Ce.length>14&&e.jsxs("span",{className:"text-muted-foreground",children:["+",Ce.length-14," more"]}),o.tags.length>0&&e.jsx("button",{type:"button",className:"text-muted-foreground hover:underline ml-1",onClick:()=>C("tags",[]),children:"clear"})]}),wt.length>0&&e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mb-3 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Recently edited:"}),wt.map(s=>e.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 hover:bg-muted truncate max-w-[180px] ${s.type==="artifact"?"border-amber-300 text-amber-700 dark:text-amber-300":"text-primary"}`,onClick:()=>A(s.id),children:[s.type==="artifact"&&e.jsx($r,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:s.title})]},s.id))]}),h||ue.has(k)?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(We,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):qs?O||!me?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:O?"No matching documents":"No documents yet"}):e.jsxs("button",{type:"button",onClick:()=>{var s;return(s=vs.current)==null?void 0:s.click()},className:"w-full flex flex-col items-center gap-2 rounded-lg border-2 border-dashed border-border py-10 text-muted-foreground hover:border-primary hover:text-primary transition-colors",children:[e.jsx(gr,{className:"h-7 w-7"}),e.jsx("div",{className:"text-sm font-medium",children:"Drag files here, or click to import"}),e.jsx("div",{className:"text-xs",children:".md → document · .html → hosted artifact"})]}):(()=>{const s=(t,a=0)=>{var Mt,_t;const d=z==="cards",x=t.type||"document",y=Pr(x),_=De&&t.status==="draft"&&ve(t),c=Ds.has(t.id)?!0:t.status==="pending_review"&&hs(t)&&(mt.get(t.id)!==ae||Je&&ds),N=t.status!=="pending_review"&&ve(t),J=!!t.author&&!!ae&&t.author.toLowerCase()===ae,X=v||J,H=$e.get(t.id),Tt=(H==null?void 0:H.status)==="pending",Ft=!et&&(X||ve(t))&&(X||!Tt),$t=()=>X?st(t):tt(t),ze=ve(t)&&(t.status!=="pending_review"||Je||ns||is.includes("admin")||ms(t,"reviewer")),Pt=()=>{ct(S(t.id)),ge(null),xe(t)},Oe=()=>!d&&!!$&&$!==t.id&&S($)!==S(t.id),Is=e.jsx("div",{onClick:p=>p.stopPropagation(),children:e.jsxs(or,{modal:!1,children:[e.jsx(nr,{asChild:!0,children:e.jsx(j,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 flex-shrink-0",title:"Actions",children:e.jsx(yr,{className:"h-4 w-4"})})}),e.jsxs(ir,{align:"end",className:"min-w-40",children:[N&&e.jsxs(I,{onSelect:()=>A(t.id),children:[e.jsx(It,{className:"h-3.5 w-3.5 mr-2"}),"Edit"]}),ze&&e.jsxs(I,{onSelect:Pt,children:[e.jsx(Se,{className:"h-3.5 w-3.5 mr-2"}),"Move to folder"]}),_&&e.jsxs(I,{onSelect:()=>pe(t),children:[e.jsx(Zt,{className:"h-3.5 w-3.5 mr-2"}),"Submit for review"]}),c&&e.jsxs(I,{onSelect:()=>Xe(t),children:[e.jsx(Ye,{className:"h-3.5 w-3.5 mr-2"}),"Review"]}),e.jsxs(I,{onSelect:()=>ye(t),children:[e.jsx(Qt,{className:"h-3.5 w-3.5 mr-2"}),"History"]}),v&&e.jsxs(I,{onSelect:()=>ot(t),children:[e.jsx(Xt,{className:"h-3.5 w-3.5 mr-2"}),"Publish"]}),e.jsx(cr,{}),Ft&&e.jsxs(I,{onSelect:$t,className:X?"text-destructive focus:text-destructive":void 0,children:[e.jsx(de,{className:"h-3.5 w-3.5 mr-2"}),"Delete"]})]})]})});return e.jsxs("div",{onClick:()=>A(t.id),className:`${d?"flex flex-col gap-2":"flex items-center gap-3"} p-3 rounded-lg border hover:bg-muted/50 transition-colors group cursor-pointer ${$===t.id?"opacity-40":""}`,style:!d&&a?{marginLeft:`${a*1.25}rem`}:void 0,draggable:!d&&ze,onDragStart:p=>{p.dataTransfer.setData("text/plain",t.id),p.dataTransfer.effectAllowed="move",Re(t.id)},onDragEnd:()=>{Re(null),q(null),ie()},onDragOver:p=>{Oe()&&(p.preventDefault(),p.dataTransfer.dropEffect="move")},onDragEnter:()=>{Oe()&&q(S(t.id))},onDrop:p=>{Oe()&&(p.preventDefault(),p.stopPropagation(),Ve(S(t.id)))},"data-testid":`document-row-${t.id}`,children:[!d&&e.jsx(Jt,{type:t.type,className:"h-5 w-5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx(Jt,{type:t.type,className:"h-4 w-4"}),e.jsx("span",{className:"font-medium truncate min-w-0",title:t.title,children:t.title}),y&&e.jsx("span",{className:`shrink-0 rounded px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide ${y.cls}`,title:y.title,children:y.label}),e.jsx(Lr,{status:t.status||"draft",size:"sm",className:"shrink-0 whitespace-nowrap"}),De&&er(t,us)&&e.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide border bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/30",title:typeof t.prime=="boolean"?"Prime: flagged on this document. Always requires steward approval.":"Prime: inherited from a prime tag. Always requires steward approval.","data-testid":`prime-badge-${t.id}`,children:[e.jsx(Qe,{className:"h-3 w-3"}),"Prime"]}),Tt&&(()=>{const p=H.requestedBy.toLowerCase()===ae;return e.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1 rounded px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide border bg-red-50 text-red-700 border-red-200 ${p?"cursor-pointer hover:bg-red-100":""}`,title:p?"Click to withdraw your deletion request":`${H.requestedBy} asked for this to be deleted: "${H.reason}". A nest admin decides.`,"data-testid":`deletion-flag-${t.id}`,onClick:p?qe=>{qe.stopPropagation(),Ze(H)}:void 0,children:[e.jsx(de,{className:"h-3 w-3"}),"Deletion requested",p&&e.jsx(ce,{className:"h-3 w-3 ml-0.5"})]})})(),d&&e.jsx("div",{className:"ml-auto",children:Is})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsxs("span",{children:["v",t.version||1]}),((Mt=t.tags)==null?void 0:Mt.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{className:"flex items-center gap-1 truncate",children:t.tags.slice(0,3).map(p=>e.jsx("button",{type:"button",title:o.tags.includes(p)?`Remove filter ${p}`:`Filter by ${p}`,className:`rounded-full border px-1.5 py-px transition-colors ${o.tags.includes(p)?"bg-primary text-primary-foreground border-primary":"hover:bg-muted"}`,onClick:qe=>{qe.stopPropagation(),pt(p)},children:p},p))})]}),(t.author||((_t=t.collaborators)==null?void 0:_t.length)>0)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx(pr,{author:t.author,collaborators:t.collaborators})]})]})]}),!d&&e.jsxs("div",{className:"flex items-center gap-1 transition-opacity opacity-0 group-hover:opacity-100",onClick:p=>p.stopPropagation(),children:[_&&e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>pe(t),children:[e.jsx(Zt,{className:"h-3.5 w-3.5 mr-1"}),"Submit"]}),c&&e.jsx(j,{variant:"outline",size:"sm",onClick:()=>Xe(t),className:"border-green-200 text-green-700 hover:bg-green-50",children:"Review"}),N&&e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>A(t.id),title:"Edit",children:e.jsx(It,{className:"h-3.5 w-3.5"})}),ze&&e.jsx(j,{variant:"ghost",size:"sm",onClick:Pt,title:"Move to folder","data-testid":`move-node-${t.id}`,children:e.jsx(Se,{className:"h-3.5 w-3.5"})}),e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>ye(t),title:"History",children:e.jsx(Qt,{className:"h-3.5 w-3.5"})}),Ft&&e.jsx(j,{variant:"ghost",size:"sm",onClick:$t,title:X?"Delete":"Delete (needs admin approval)","data-testid":`delete-node-${t.id}`,className:X?"text-destructive hover:text-destructive hover:bg-destructive/10":void 0,children:e.jsx(de,{className:"h-3.5 w-3.5"})})]})]},t.id)};return z==="cards"?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:K.map(t=>s(t))}):e.jsxs("div",{className:"space-y-1",children:[$&&S($)!==k&&e.jsxs("div",{className:`flex items-center gap-2 rounded-md border-2 border-dashed px-3 py-2 text-sm ${Ct===k?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground"}`,onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect="move"},onDragEnter:()=>q(k),onDragLeave:()=>q(t=>t===k?null:t),onDrop:t=>{t.preventDefault(),Ve(k)},children:[e.jsx(Se,{className:"h-4 w-4"}),"Move to ",k?B(k):"nest root"]}),e.jsx(Ys,{className:"space-y-1",groups:Os,baseFolder:k,known:O?void 0:w,isCollapsed:t=>O?!1:!re.has(t),renderFolder:(t,{collapsed:a})=>{const d=!!$&&S($)!==t.path,x=d&&Ct===t.path,y=t.total>0,_=ue.has(t.path);return e.jsxs("div",{className:`group/fh flex items-center gap-1.5 py-1.5 px-2 rounded-md select-none transition-colors ${y?"cursor-pointer":""} ${x?"bg-primary/10 ring-1 ring-primary":"hover:bg-muted/50"}`,onClick:y?()=>ke(t.path):void 0,onDragOver:c=>{d&&(c.preventDefault(),c.dataTransfer.dropEffect="move")},onDragEnter:c=>{c.currentTarget.contains(c.relatedTarget)||($&&y&&a&&Bs(t.path),d&&q(t.path))},onDragLeave:c=>{c.currentTarget.contains(c.relatedTarget)||(q(N=>N===t.path?null:N),ie())},onDrop:c=>{d&&(c.preventDefault(),Ve(t.path))},"data-testid":`folder-header-${t.path}`,children:[_?e.jsx(We,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}):y?e.jsx(Et,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform ${a?"":"rotate-90"}`}):e.jsx("span",{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(Rt,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:t.label}),t.total>0&&e.jsx(Ke,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5",title:t.count!==t.total?`${t.count} here · ${t.total} in this folder`:void 0,children:t.total}),me&&e.jsx("button",{type:"button",className:"ml-1 rounded p-0.5 text-muted-foreground opacity-0 group-hover/fh:opacity-100 hover:text-primary hover:bg-primary/10",title:`New document in ${B(t.path)}`,onClick:c=>{c.stopPropagation(),A("new",{folder:t.path})},children:e.jsx(Vt,{className:"h-3.5 w-3.5"})}),v&&e.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground opacity-0 group-hover/fh:opacity-100 hover:text-primary hover:bg-primary/10",title:`Share ${B(t.path)} with someone`,"data-testid":`share-folder-${t.path}`,onClick:c=>{c.stopPropagation(),at({path:Ss(t.path),label:t.label||Ie(t.name)})},children:e.jsx(Xt,{className:"h-3.5 w-3.5"})}),(v||me)&&(v||!lt(t.path))&&e.jsx("button",{type:"button",className:`rounded p-0.5 opacity-0 group-hover/fh:opacity-100 ${v?"text-muted-foreground hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-primary hover:bg-primary/10"}`,title:v?`Delete ${B(t.path)} and everything in it`:"Delete (needs admin approval)","data-testid":`delete-folder-${t.path}`,onClick:c=>{c.stopPropagation(),rt({path:t.path,label:B(t.path),total:t.total})},children:e.jsx(de,{className:"h-3.5 w-3.5"})}),lt(t.path)&&(()=>{const c=Ns.get(t.path),N=(c==null?void 0:c.requestedBy.toLowerCase())===ae;return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide bg-red-50 text-red-700 border border-red-200 ${N?"cursor-pointer hover:bg-red-100":""}`,title:N?"Click to withdraw your deletion request":"Someone asked for this folder to be deleted. A nest admin decides.",onClick:N&&c?J=>{J.stopPropagation(),Ze(c)}:void 0,children:[e.jsx(de,{className:"h-3 w-3"}),"Deletion requested",N&&e.jsx(ce,{className:"h-3 w-3 ml-0.5"})]})})()]})},renderDoc:t=>s(t,0)})]})})(),!g&&fs.total>0&&e.jsxs("details",{className:"mt-4 text-xs text-muted-foreground",onToggle:s=>{s.currentTarget.open&&_e()},children:[e.jsx("summary",{className:"cursor-pointer select-none",children:As?"Link health: checking the whole nest…":G?`Link health: ${F.broken.length} broken link${F.broken.length!==1?"s":""} · ${F.orphans.length} orphan doc${F.orphans.length!==1?"s":""}`:"Link health — check the whole nest"}),e.jsxs("div",{className:"mt-2 space-y-2 pl-1",children:[G&&F.broken.length===0&&F.orphans.length===0&&e.jsx("div",{children:"No broken links or orphan documents."}),F.broken.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"font-medium mb-1",children:"Broken links (target doesn't exist):"}),F.broken.slice(0,10).map((s,t)=>e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:()=>A(s.sourceId),children:s.sourceTitle})," ","→ [[",s.target,"]]"]},t))]}),F.orphans.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"font-medium mb-1",children:"Orphans (nothing links to them):"}),e.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:F.orphans.slice(0,15).map(s=>e.jsx("button",{type:"button",className:"text-primary hover:underline",onClick:()=>A(s.id),children:s.title},s.id))})]})]})]})]})]}),e.jsx(zt,{open:Es,onOpenChange:we,children:e.jsxs(Ot,{className:"max-w-md",children:[e.jsx(qt,{children:e.jsx(Ht,{children:"Save this filter"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Saved filters remember your current search, tags, status, author and date range. Pick one from the ",e.jsx("strong",{children:"Saved"})," row to re-apply the whole set in one click — handy for views you return to, like “My drafts” or “Edited this week”."]}),e.jsx(Be,{autoFocus:!0,placeholder:"Filter name (e.g. My drafts)",value:Ee,onChange:s=>gt(s.target.value),onKeyDown:s=>{s.key==="Enter"&&vt()}}),e.jsxs(Bt,{children:[e.jsx(j,{variant:"ghost",onClick:()=>we(!1),children:"Cancel"}),e.jsx(j,{onClick:vt,disabled:!Ee.trim(),children:"Save filter"})]})]})}),Fe&&e.jsx(ur,{nestId:r,targetType:"folder",target:Fe.path,label:Fe.label,onClose:()=>at(null)}),e.jsx(zt,{open:!!R,onOpenChange:s=>{!s&&!fe&&xe(null)},children:e.jsxs(Ot,{className:"max-w-md",children:[e.jsx(qt,{children:e.jsx(Ht,{children:"Move to folder"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Move ",e.jsx("strong",{children:R==null?void 0:R.title})," to another folder. Version history, review state, and [[wiki links]] follow the document."]}),e.jsxs(Z,{value:U!==null?"__new__":Pe===""?"__root__":Pe,onValueChange:s=>{if(s==="__new__"){ge("");return}ge(null),ct(s==="__root__"?"":s)},children:[e.jsx(ee,{"data-testid":"move-folder-select",children:e.jsx(te,{placeholder:"Choose a folder"})}),e.jsxs(se,{children:[e.jsx(f,{value:"__root__",children:"Nest root"}),ks.map(s=>e.jsx(f,{value:s,children:B(s)},s)),e.jsx(jr,{}),e.jsx(f,{value:"__new__",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(vr,{className:"h-3.5 w-3.5"}),"New folder…"]})})]})]}),U!==null&&e.jsxs(e.Fragment,{children:[e.jsx(Be,{autoFocus:!0,value:U,onChange:s=>ge(s.target.value),placeholder:"e.g. gtm/deals",className:"font-mono","data-testid":"move-folder-new-path"}),V.error?e.jsx("p",{className:"text-xs text-destructive",children:V.error}):V.rewritten&&V.path?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Will be created as"," ",e.jsx("code",{className:"font-mono",children:V.path})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"The folder is created by the move — nest it with a slash."})]}),e.jsxs(Bt,{children:[e.jsx(j,{variant:"ghost",disabled:fe,onClick:()=>xe(null),children:"Cancel"}),e.jsxs(j,{disabled:fe||!R||S(R.id)===ut||U!==null&&(!V.path||!!V.error),onClick:async()=>{if(!R)return;dt(!0);const s=await it(R.id,ut);dt(!1),s&&xe(null)},"data-testid":"move-folder-confirm",children:[fe?e.jsx(We,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Move"]})]})]})}),P&&e.jsx(Sr,{isOpen:!!P,onClose:()=>pe(null),documentTitle:P.title,currentVersion:P.version||1,onSubmit:Ts}),he&&e.jsx(mr,{nestId:r,nodeId:he.id,nodeTitle:he.title||he.id,onClose:()=>ot(null)}),E&&e.jsx(Ue,{open:!0,onOpenChange:s=>!s&&rt(null),title:v?`Delete "${E.label}"?`:`Request deletion of "${E.label}"`,description:v?`This deletes all ${E.total} document${E.total===1?"":"s"} in this folder and its subfolders, with their history, comments and annotations. It cannot be undone.`:`A nest admin reviews this. Honouring it deletes all ${E.total} document${E.total===1?"":"s"} in this folder. Nothing is removed yet.`,label:v?void 0:"Why should it be deleted?",placeholder:"e.g. superseded by the new API docs",confirmLabel:v?"Delete folder":"Request deletion",destructive:v,onConfirm:Ps}),Te&&e.jsx(Ue,{open:!0,onOpenChange:s=>!s&&st(null),title:`Delete "${Te.title}"?`,description:"This removes the document, its version history, comments and annotations. It cannot be undone.",confirmLabel:"Delete document",destructive:!0,onConfirm:Fs}),le&&e.jsx(Ue,{open:!0,onOpenChange:s=>!s&&tt(null),title:`Request deletion of "${le.title}"`,description:"A nest admin reviews this and either deletes the document or rejects with a note. Nothing is removed yet.",label:"Why should it be deleted?",placeholder:"e.g. superseded by the new runbook",confirmLabel:"Request deletion",priorDecline:((Dt=$e.get(le.id))==null?void 0:Dt.status)==="declined"?$e.get(le.id):null,onConfirm:$s}),M&&e.jsx(hr,{open:!0,onClose:()=>nt(null),title:M.title,versionData:ws,onLoadContent:async s=>(await Zs(r,M.id,s)).content,onRestore:async s=>{if(M)try{await Xs(r,M.id,s),b.success(`Reverted to version ${s}`),await ye(M),L()}catch(t){b.error((t==null?void 0:t.message)||"Revert failed")}},onDiscard:async()=>{if(M)try{const{version:s}=await Js(r,M.id);b.success(`Draft discarded — back to version ${s}`),await ye(M),L()}catch(s){b.error((s==null?void 0:s.message)||"Discard failed")}}})]})}export{$a as DocumentsTab};
@@ -1 +0,0 @@
1
- import{u as j,r as g,j as e,B as N,L as l,e as C,S as E,i as v,dL as w,a8 as y}from"./index-B5hLclEq.js";import{f as b}from"./dates-BCxbm4_q.js";import{C as k,a as _,c as F,b as L,d as S}from"./card-UDyMRcps.js";import{F as d}from"./file-exclamation-point-CSphs1VD.js";import{R as T}from"./refresh-cw-CsCtmWwX.js";import{C as B}from"./circle-check-CSkZUEFK.js";import{C as Q}from"./NestView-DwIagxwJ.js";import"./MarkdownEditor-Dfk5uIE5.js";import"./zap-BcsKR0ef.js";import"./triangle-alert-CsYGyfGZ.js";import"./scroll-area-CbcH6yrZ.js";import"./select-DrL0mpRN.js";import"./index-A0_ymcqL.js";import"./arrow-left-BAgIocLn.js";import"./trash-2-B4hRXo-p.js";import"./x-qxt1WrUi.js";import"./chevron-left-XR4ReJ9Z.js";import"./alert-dialog-4SiLKlz8.js";import"./NestPageHeader-yOK-OIYZ.js";import"./count-skeleton-DBWCDhRy.js";import"./folder-input-BAwK9tFL.js";import"./PersonCombobox-D350WlrJ.js";import"./tag-Br_y1f00.js";import"./user-plus-4CTYEkd3.js";import"./ReviewActions-BXDTDPp1.js";import"./circle-x-in2o3aHU.js";import"./ReasonDialog-CN3ECAnQ.js";import"./settings-EY4A_DYv.js";function R(t,a=!0){return E({...v.externalEdits(t),enabled:a})}function le({nestId:t,enabled:a,onOpenDocument:m,titleOf:x}){var c;const p=j(),i=R(t,a),r=((c=i.data)==null?void 0:c.entries)??[],[u,n]=g.useState(!1),h=async()=>{n(!0);try{await w(t).catch(s=>(console.error("[ExternalEditsTab] scanExternalEdits failed",t,s),null)),await p.invalidateQueries({queryKey:y.externalEdits(t)})}finally{n(!1)}},o=u||i.isFetching;return e.jsxs(k,{children:[e.jsx(_,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(F,{className:"text-lg flex items-center gap-2",children:[e.jsx(d,{className:"h-4 w-4 text-orange-600"}),"External Edits"]}),e.jsx(L,{children:"Files edited directly on disk, awaiting your approval."})]}),e.jsx(N,{variant:"ghost",size:"icon",onClick:h,disabled:o,className:"h-8 w-8","data-testid":"external-edits-refresh",children:o?e.jsx(l,{className:"h-4 w-4 animate-spin"}):e.jsx(T,{className:"h-4 w-4"})})]})}),e.jsx(S,{children:i.isLoading?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(B,{className:"h-10 w-10 text-green-500 mb-3"}),e.jsx("p",{className:"text-sm font-medium",children:"No pending external edits"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All files on disk match their last approved state."})]}):e.jsx("div",{className:"space-y-2",children:r.map(s=>{const f=x(s.document_id)||s.document_id.split("/").pop();return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>m(s.document_id),"data-testid":`external-edit-row-${s.suggestion_id}`,children:[e.jsx(d,{className:"h-5 w-5 text-orange-600 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:f}),e.jsx(C,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-orange-100 text-orange-700",children:s.source})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(Q,{className:"h-3 w-3"}),e.jsx("span",{children:b(s.detected_at)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:["by ",s.actor]})]})]})]},s.suggestion_id)})})})]})}export{le as ExternalEditsTab,R as useExternalEdits};
@@ -1 +0,0 @@
1
- .wiki-bracket-hidden,.video-url-hidden,.mention-domain-hidden{font-size:0;color:transparent;-webkit-user-select:none;-moz-user-select:none;user-select:none}.cn-video-embed{display:block;max-width:100%;border-radius:.375rem;margin:.5rem 0}.cn-video-embed--iframe{width:100%;max-width:48rem;aspect-ratio:16 / 9}.cn-video-embed--iframe iframe{display:block;width:100%;height:100%;border:0;border-radius:.375rem}.ProseMirror a{cursor:pointer}.wiki-link{cursor:pointer;text-decoration:none;font-weight:500}.wiki-link:hover{text-decoration:underline}.wiki-link-exists{color:#2563eb;text-decoration:underline;text-decoration-style:solid;text-underline-offset:2px}.wiki-link-broken{color:#9333ea;text-decoration:underline;text-decoration-style:dotted;text-underline-offset:2px;font-style:italic}.dark .wiki-link-exists{color:#60a5fa}.dark .wiki-link-broken{color:#c084fc}.mention{cursor:pointer;padding:0 4px;border-radius:4px;font-weight:500}.mention:hover{text-decoration:underline}.mention-user{color:#9333ea;background-color:#9333ea1a}.mention-user:hover{background-color:#9333ea33}.dark .mention-user{color:#c084fc}.mention-unresolved{color:#71717a;background-color:#71717a1a;-webkit-text-decoration:underline dashed;text-decoration:underline dashed;text-underline-offset:2px}.dark .mention-unresolved{color:#a1a1aa}.task-checkbox{font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,monospace;cursor:pointer;padding:0 2px;border-radius:2px;-webkit-user-select:none;-moz-user-select:none;user-select:none}.task-unchecked{color:#6b7280;background-color:#6b72801a}.task-unchecked:hover{background-color:#6b728033}.task-checked{color:#22c55e;background-color:#22c55e1a}.task-checked:hover{background-color:#22c55e33}.ProseMirror p.is-editor-empty:first-child:before{color:hsl(var(--muted-foreground));content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror ul{list-style:disc outside;padding-left:1.5rem}.ProseMirror ol{list-style:decimal outside;padding-left:1.5rem}.ProseMirror ul ul{list-style:circle outside}.ProseMirror ul ul ul{list-style:square outside}.ProseMirror ul[data-type=taskList]{list-style:none;padding-left:0}.ProseMirror ul[data-type=taskList] li{display:flex;align-items:flex-start;gap:.5rem}.ProseMirror:focus{outline:none}.prose pre,.prose-sm pre{background-color:hsl(var(--muted));color:hsl(var(--foreground))}.prose pre code,.prose-sm pre code{background-color:transparent;color:inherit}.prose :not(pre)>code,.prose-sm :not(pre)>code{background-color:hsl(var(--muted));color:hsl(var(--foreground))}.prose code:before,.prose code:after,.prose-sm code:before,.prose-sm code:after{content:none}.cn-code-block{position:relative;margin:.75rem 0}.cn-code-block-header{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.25rem .5rem;border:1px solid hsl(var(--border));border-bottom:none;border-radius:.375rem .375rem 0 0;background-color:hsl(var(--muted))}.cn-code-lang{height:1.5rem;border-radius:.25rem;border:1px solid hsl(var(--border));background-color:hsl(var(--background));color:hsl(var(--foreground));font-size:.75rem;padding:0 .25rem}.cn-code-copy{height:1.5rem;padding:0 .5rem;border-radius:.25rem;border:1px solid hsl(var(--border));background-color:hsl(var(--background));color:hsl(var(--muted-foreground));font-size:.75rem;cursor:pointer}.cn-code-copy:hover{color:hsl(var(--foreground))}.cn-code-actions{display:flex;align-items:center;gap:.5rem}.ProseMirror[contenteditable=false] .cn-code-to-table{display:none!important}.ProseMirror[contenteditable=false] .cn-code-lang{-moz-appearance:none;appearance:none;-webkit-appearance:none;border:none;background:transparent;padding:0;pointer-events:none}.cn-code-block pre{margin:0;border:1px solid hsl(var(--border));border-radius:0 0 .375rem .375rem}.cn-callout{margin:.75rem 0;padding:.75rem 1rem;border-left:4px solid;border-radius:.375rem;background-color:hsl(var(--muted))}.cn-callout>:first-child{margin-top:0}.cn-callout>:last-child{margin-bottom:0}.cn-callout[data-callout=info]{border-color:#3b82f6;background-color:#3b82f614}.cn-callout[data-callout=tip]{border-color:#22c55e;background-color:#22c55e14}.cn-callout[data-callout=warn]{border-color:#eab308;background-color:#eab3081a}.cn-columns{display:flex;gap:1rem;margin:.75rem 0}.cn-column{flex:1 1 0;min-width:0;border:1px dashed hsl(var(--border));border-radius:.375rem;padding:.5rem .75rem}.ProseMirror [data-type=details]{display:flex;gap:.25rem;margin:.75rem 0;border:1px solid hsl(var(--border));border-radius:.375rem;padding:.25rem .75rem}.ProseMirror [data-type=details]>button{flex:none;align-self:flex-start;cursor:pointer;background:transparent;border:none;padding:0;width:1.25rem;height:1.75rem;color:hsl(var(--muted-foreground))}.ProseMirror [data-type=details]>button:before{content:"▶";font-size:.7em;display:inline-block;transition:transform .15s ease}.ProseMirror [data-type=details].is-open>button:before{transform:rotate(90deg)}.ProseMirror [data-type=details]>div{flex:1 1 auto;min-width:0}.ProseMirror [data-type=details] summary{display:block;cursor:pointer;font-weight:500;padding:.25rem 0}.ProseMirror table{border-collapse:collapse;width:100%;margin:.75rem 0;table-layout:fixed}.ProseMirror th,.ProseMirror td{border:1px solid hsl(var(--border));padding:.375rem .5rem;vertical-align:top}.ProseMirror th{background-color:hsl(var(--muted));font-weight:600;text-align:left}.ProseMirror .selectedCell:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:#3b82f626;pointer-events:none}.hljs-comment,.hljs-quote{color:#8899a6;font-style:italic}.hljs-keyword,.hljs-selector-tag,.hljs-literal,.hljs-type{color:#c084fc}.hljs-string,.hljs-meta-string,.hljs-regexp{color:#34d399}.hljs-number,.hljs-built_in,.hljs-builtin-name{color:#fb923c}.hljs-title,.hljs-section,.hljs-function .hljs-title{color:#60a5fa}.hljs-attr,.hljs-attribute,.hljs-variable,.hljs-template-variable{color:#f87171}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}
@@ -1 +0,0 @@
1
- import{j as s,B as r}from"./index-B5hLclEq.js";import{A as l}from"./arrow-left-BAgIocLn.js";function c({nestName:e,onBack:a,title:i,badges:m,children:t}){return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(r,{variant:"ghost",size:"sm",onClick:a,className:"shrink-0 px-2",title:"Back to nests",children:s.jsx(l,{className:"h-4 w-4"})}),i??s.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",title:e,children:e}),m]}),t&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 w-full sm:ml-auto sm:w-auto sm:shrink-0 sm:justify-end",children:t})]})}export{c as N};
@@ -1,68 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ExternalEditsTab-kIBimZyE.js","assets/index-B5hLclEq.js","assets/index-DrUAtoQM.css","assets/dates-BCxbm4_q.js","assets/card-UDyMRcps.js","assets/file-exclamation-point-CSphs1VD.js","assets/refresh-cw-CsCtmWwX.js","assets/circle-check-CSkZUEFK.js","assets/MarkdownEditor-Dfk5uIE5.js","assets/zap-BcsKR0ef.js","assets/triangle-alert-CsYGyfGZ.js","assets/scroll-area-CbcH6yrZ.js","assets/select-DrL0mpRN.js","assets/scroll-area-dRWncRqa.css","assets/index-A0_ymcqL.js","assets/arrow-left-BAgIocLn.js","assets/trash-2-B4hRXo-p.js","assets/x-qxt1WrUi.js","assets/MarkdownEditor-CsVusP2d.css","assets/chevron-left-XR4ReJ9Z.js","assets/alert-dialog-4SiLKlz8.js","assets/NestPageHeader-yOK-OIYZ.js","assets/count-skeleton-DBWCDhRy.js","assets/folder-input-BAwK9tFL.js","assets/PersonCombobox-D350WlrJ.js","assets/tag-Br_y1f00.js","assets/user-plus-4CTYEkd3.js","assets/ReviewActions-BXDTDPp1.js","assets/circle-x-in2o3aHU.js","assets/ReasonDialog-CN3ECAnQ.js","assets/settings-EY4A_DYv.js","assets/StewardsTab-AagNWcWS.js","assets/CollaboratorsTab-DRCitQuX.js","assets/CollaboratorManager-Bo81D--Q.js","assets/share-2-vGmZUl90.js","assets/ReviewTab-CZewAYiz.js","assets/corner-down-right-CuxZWscX.js","assets/send-CvAgOUPG.js","assets/OverviewTab-DFOFMVyE.js","assets/DocumentsTab-BUxBCN8o.js","assets/backlinks-Cb8Uf8mw.js","assets/client-attribution-BraarYaP.js","assets/SubmitForReviewModal-BOZJxwRN.js","assets/folder-target-CUSWqImF.js"])))=>i.map(i=>d[i]);
2
- import{c as rt,ay as Gt,j as e,a2 as xr,F as st,D as Fe,x as Oe,y as qe,z as $e,bq as ya,G as kt,br as ta,r,B as k,C as gr,ao as vr,at as br,A as Jt,K as Na,a as Zt,J as se,bs as St,V as tt,aX as Ke,I as Sa,H as at,L as be,bt as wr,bu as jr,bv as yr,aE as ka,bw as Nr,bx as sa,by as Sr,bz as kr,aj as Cr,bA as Rr,az as _r,S as ss,i as H,u as as,aa as es,bB as Ar,O as Tr,bC as aa,f as N,_ as Dr,aI as Er,bD as Lr,aD as Pr,U as Fr,a9 as ra,ab as Or,e as Ye,ag as qr,T as $r,P as Mr,Q as Le,ah as zr,ai as Vr,ak as Wr,am as Kt,aP as Br,R as Pe,bE as Hr,E as Qr,bF as Ur,bG as na,as as Gr,bH as Me,bI as ze,ax as Kr,bJ as Yr,ac as Ir,bK as ia,bL as Xr,bM as Jr,au as Zr,av as en,bN as tn,bO as sn,bP as an,bQ as rn}from"./index-B5hLclEq.js";import{W as nn,T as on,v as ln,n as cn,h as dn,P as un,D as mn,S as oa,U as la,O as hn,w as pn,F as ca,q as fn,x as xn,M as gn,s as vn}from"./MarkdownEditor-Dfk5uIE5.js";import{Z as bn,F as wn}from"./zap-BcsKR0ef.js";import{p as jn,r as yn}from"./dates-BCxbm4_q.js";import{T as Nn}from"./triangle-alert-CsYGyfGZ.js";import{X as Ca}from"./x-qxt1WrUi.js";import{C as Sn}from"./chevron-left-XR4ReJ9Z.js";import{A as kn,a as Cn,b as Rn,c as _n,d as An,e as Tn,f as Dn,g as En}from"./alert-dialog-4SiLKlz8.js";import{N as Ln}from"./NestPageHeader-yOK-OIYZ.js";import{C as jt,D as Pn,R as Fn}from"./count-skeleton-DBWCDhRy.js";import{C as Ie,a as Xe,b as Je,c as Ze,d as et}from"./card-UDyMRcps.js";import{T as On}from"./scroll-area-CbcH6yrZ.js";import{S as da,a as ua,b as ma,c as ha,d as yt}from"./select-DrL0mpRN.js";import{P as qn}from"./PersonCombobox-D350WlrJ.js";import{T as $n,L as Mn}from"./tag-Br_y1f00.js";import{R as zn}from"./refresh-cw-CsCtmWwX.js";import{U as Vn}from"./user-plus-4CTYEkd3.js";import{R as Wn}from"./ReviewActions-BXDTDPp1.js";import{R as Yt}from"./ReasonDialog-CN3ECAnQ.js";import{F as Bn,A as Hn}from"./folder-input-BAwK9tFL.js";import{T as pa}from"./trash-2-B4hRXo-p.js";import{C as Qn}from"./circle-check-CSkZUEFK.js";import{S as fa}from"./settings-EY4A_DYv.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 Un=[["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"}]],Gn=rt("activity",Un);/**
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 Kn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Yn=rt("clock",Kn);/**
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 In=[["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"}]],Xn=rt("file-code-corner",In);/**
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 Jn=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Zn=rt("menu",Jn);/**
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 ei=[["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"}]],ti=rt("user-pen",ei);function si(s){return s.normalize("NFKD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}const xa=100;function ai(s){const n=s.split("/").map(p=>p.trim()).filter(Boolean),i=n.map(si).filter(Boolean).join("/"),o=i!==s.trim(),u=p=>({path:i,error:p,rewritten:o});if(n.length===0)return{path:"",error:null,rewritten:!1};if(n.some(p=>p==="."||p===".."))return u(`"." and ".." don't name a folder — use a name.`);if(!i)return u("Folder paths are built from a-z and 0-9, so the name needs at least one of those.");const b=i.split("/").length;if(b>Gt){const p=b-Gt;return u(`Folders may nest at most ${Gt} levels deep — this path is ${b}. Remove ${p} level${p===1?"":"s"}.`)}return i.split("/").some(p=>p.length>xa)?u(`Each folder level must be at most ${xa} characters.`):{path:i,error:null,rewritten:o}}function ri(){let s=!1;return{arm:()=>{s=!0},consume:()=>s?(s=!1,!0):!1}}function ni({type:s,className:n="h-4 w-4"}){const i=s==="agent"?{Icon:xr,cls:"text-violet-600 dark:text-violet-400 bg-violet-500/10",label:"Agent"}:s==="skill"?{Icon:bn,cls:"text-blue-600 dark:text-blue-400 bg-blue-500/10",label:"Skill"}:s==="artifact"?{Icon:Xn,cls:"text-amber-600 dark:text-amber-400 bg-amber-500/10",label:"Artifact"}:s==="tool"?{Icon:nn,cls:"text-teal-600 dark:text-teal-400 bg-teal-500/10",label:"Tool"}:s==="table"?{Icon:on,cls:"text-cyan-600 dark:text-cyan-400 bg-cyan-500/10",label:"Table"}:s==="pdf"?{Icon:wn,cls:"text-rose-600 dark:text-rose-400 bg-rose-500/10",label:"PDF"}:{Icon:st,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 ${i.cls}`,title:i.label,children:e.jsx(i.Icon,{className:n})})}function so(s){const n=jn(s);if(!n)return"";const i=Date.now()-n.getTime();return i<6e4?"just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:i<6048e5?`${Math.floor(i/864e5)}d ago`:n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ao(s){switch(s){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 ii(s,n){const i=s.split("/"),o=n.split("/");for(let u=0;u<Math.min(i.length,o.length);u++){const b=i[u].localeCompare(o[u]);if(b!==0)return b}return i.length-o.length}function oi(s){const n=s.startsWith("nodes/")?s.slice(6):s,i=n.lastIndexOf("/");return i>0?n.slice(0,i):""}const ro={draft:"Draft",pending_review:"Pending",published:"Published",rejected:"Rejected"},no={"7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days","1y":"Last year"},io={document:"Document",artifact:"Artifact",agent:"Agent",skill:"Skill",tool:"Tool",table:"Table"};function ga({label:s,text:n}){const[i,o]=r.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:s}),e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:async()=>{await br(n)&&(o(!0),setTimeout(()=>o(!1),1500))},children:i?e.jsxs(e.Fragment,{children:[e.jsx(gr,{className:"h-3 w-3 mr-1"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(vr,{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:n})]})}function li({isOpen:s,onClose:n,nestId:i,nestName:o,openMode:u}){const b=typeof window<"u"?window.location.origin:"https://your-server",p=u?"":` -H "Authorization: Bearer $CNST_KEY" \\
28
- `,S=`You are helping me build a ContextNest knowledge base — a "nest":
29
- a graph of small, linked context documents that AI agents read later. You can
30
- write to it over HTTP. Nest: "${o}".
31
-
32
- STEP 1 — Interview me first. Do NOT create anything yet. Ask me:
33
- • What body of knowledge should go in here? (sources, docs, transcripts, URLs, topics)
34
- • Who/what will use this nest, and for what? (purpose drives how granular to go)
35
- • What's authoritative vs. rough, and is there anything to leave out?
36
- • How do I want it organized — by topic, project, client/entity, or timeline?
37
- Ask follow-ups until you actually understand the material and my intent.
38
-
39
- STEP 2 — Propose an organization and wait for my OK. Give me a short plan:
40
- the main topic areas, a consistent tagging scheme, a node-naming convention, and
41
- roughly how many nodes. Adjust based on my feedback before writing anything.
42
-
43
- STEP 3 — Create the nodes, organized for retrieval (not prose):
44
- • One idea per node; keep each tight (~100–300 words). Prefer many small linked
45
- nodes over one big dump.
46
- • Clear, specific titles; 3–6 consistent lower-case tags per node.
47
- • Connect related nodes with [[Wiki Links]] (use the other node's title) so the
48
- graph is traversable.
49
- • type "document" for markdown; type "artifact" with raw HTML for self-contained
50
- pages (decks, dashboards, infographics).
51
-
52
- API — create one node per POST:
53
- POST ${b}/nests/${i}/nodes
54
- Content-Type: application/json${u?"":`
55
- Authorization: Bearer <MY_API_KEY> # mint one via Connect; omit if the server is in open mode`}
56
- Body: {
57
- "title": "<short, specific title>",
58
- "content": "<markdown body, with [[Wiki Links]] to related nodes>",
59
- "type": "document",
60
- "tags": ["<tag>", "<tag>"]
61
- }
62
-
63
- After each create, report the node id. At the end, give me a short map of what
64
- you created and how it's organized.
65
-
66
- Begin at STEP 1 by interviewing me about what to put in this nest.`,w=`curl -X POST ${b}/nests/${i}/nodes \\
67
- ${p} -H "Content-Type: application/json" \\
68
- -d '{"title":"My note","content":"# Hello\\n\\nSome context…","type":"document","tags":["demo"]}'`;return e.jsx(Fe,{open:s,onOpenChange:n,children:e.jsxs(Oe,{className:"sm:max-w-[640px] max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs(qe,{children:[e.jsxs($e,{className:"flex items-center gap-2",children:[e.jsx(ya,{className:"h-4 w-4 text-primary"}),"Generate & add context to ",o]}),e.jsx(kt,{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(ga,{label:"Prompt for your agent",text:S})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"2. Or call the API directly"}),e.jsx(ga,{label:"curl",text:w})]}),!u&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border bg-card p-3 text-xs text-muted-foreground",children:[e.jsx(ta,{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."]})]}),u&&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(ta,{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 ci({nestId:s,nestName:n,stewardshipEnabled:i,allowSelfApprove:o,primeOnlyReview:u,primeTags:b,creatorIsReviewer:p,canManageStewardship:S,onClose:w,onChanged:g}){const[j,$]=r.useState(i),[v,m]=r.useState(o),[P,C]=r.useState(u),[R,Q]=r.useState(b.join(", ")),[U,le]=r.useState(p),[A,O]=r.useState(!1),[G,T]=r.useState(null),[J,D]=r.useState(!1),K=i&&!j,ae=j&&P,re=[...new Set(R.split(",").map(M=>M.trim().replace(/^#+/,"").toLowerCase()).filter(Boolean))],V=async()=>{const M=j!==i,W=v!==o,F=P!==u,f=re.join(",")!==b.join(","),x=U!==p;if(!M&&!W&&!F&&!f&&!x){w();return}O(!0),T(null);try{const y=await wr(s,{...M?{stewardship_enabled:j}:{},...W?{allow_self_approve:v}:{},...F?{prime_only_review:P}:{},...f?{prime_tags:re}:{},...x?{creator_is_reviewer:U}:{}});if(y.stewardship_enabled!==j||y.allow_self_approve!==v||y.prime_only_review!==P||y.creator_is_reviewer!==U){T("Server did not accept the change. You may not have permission to change these settings."),O(!1);return}g({stewardshipEnabled:y.stewardship_enabled,allowSelfApprove:y.allow_self_approve,primeOnlyReview:y.prime_only_review,primeTags:y.prime_tags,creatorIsReviewer:y.creator_is_reviewer})}catch(y){T(y.message),O(!1)}};return e.jsx(Fe,{open:!0,onOpenChange:w,children:e.jsxs(Oe,{className:"sm:max-w-[500px] flex flex-col max-h-[85vh]",children:[e.jsxs(qe,{children:[e.jsxs($e,{children:["Settings: ",n]}),e.jsx(kt,{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:[G&&e.jsxs(Jt,{variant:"destructive",children:[e.jsx(Na,{className:"h-4 w-4"}),e.jsx(Zt,{children:G})]}),S&&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(se,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(St,{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(tt,{checked:j,onCheckedChange:$})]}),!j&&!K&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{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."]})]}),K&&e.jsxs(Jt,{variant:"destructive",className:"pt-2",children:[e.jsx(Nn,{className:"h-4 w-4"}),e.jsxs(Zt,{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:J,onChange:M=>D(M.target.checked),className:"h-3.5 w-3.5"}),"I understand this will remove all stewards."]})]})]}),j&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{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."]})]})]}),S&&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(se,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ln,{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(tt,{checked:v,onCheckedChange:m,disabled:ae})]}),ae&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{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."]})]}),j&&!ae&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{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."]})]})]}),S&&j&&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(se,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(cn,{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(tt,{checked:P,onCheckedChange:C})]}),e.jsxs("div",{className:"space-y-1 pt-2 border-t",children:[e.jsx(se,{className:"text-xs font-medium",children:"Prime tags"}),e.jsx(Sa,{value:R,onChange:M=>Q(M.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."})]})]}),S&&j&&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(se,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ti,{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(tt,{checked:U,onCheckedChange:le})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{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(at,{children:[e.jsx(k,{variant:"outline",onClick:w,disabled:A,children:"Cancel"}),e.jsx(k,{onClick:V,disabled:A||K&&!J,children:A?e.jsx(be,{className:"h-4 w-4 animate-spin"}):"Save Settings"})]})]})})}function Nt(s){let n=s.trim().replace(/^\/+/,"").replace(/\.md$/i,"");return n.startsWith("nodes/")||(n=`nodes/${n}`),n.toLowerCase()}function di(s,n){const i=s.trim();if(!i)return null;if(i.includes("/")){const u=Nt(i),b=n.find(w=>Nt(w.id)===u);if(b)return b;const p=u.split("/").pop()??"",S=n.filter(w=>Nt(w.id).endsWith(`/${p}`));return S.length===1?S[0]:null}const o=i.toLowerCase();return n.find(u=>String(u.title??"").toLowerCase()===o)??n.find(u=>Nt(u.id).endsWith(`/${o}`))??null}function Ra(s){const n=s.replace(/[-_]+/g," ").trim();return n&&n[0].toUpperCase()+n.slice(1)}function ui(s){return!s||s==="Root"?"General":Ra(s.split("/").filter(Boolean).pop()??s)}function va(s){return s.replace(/^nodes\//,"").split("/").filter(Boolean).slice(0,-1).map(Ra)}const ts=/^(overview|index|readme|welcome|home)$/i;function rs(s){return s.split("/").pop()??s}function mi(s,n){const i=rs(s.id).toLowerCase(),o=(n.split("/").filter(Boolean).pop()??"").toLowerCase();return ts.test(i)||ts.test(String(s.title??""))||!!o&&i===o}function _a(s,n){const i=n.filter(o=>mi(o,s));return[...i,...n.filter(o=>!i.includes(o))]}function hi(s){return s.flatMap(n=>_a(n.folder,n.items))}function pi(s,n){const i=s.findIndex(o=>o.id===n);return i<0?{prev:null,next:null}:{prev:s[i-1]??null,next:s[i+1]??null}}function fi(s,n){if(!n)return s;const i=s.match(/^\s*#[ \t]+(.+?)[ \t]*#*[ \t]*(?:\r?\n|$)/);if(!i)return s;const o=u=>u.replace(/[*_`]/g,"").trim().toLowerCase();return o(i[1])===o(n)?s.slice(i[0].length):s}function xi(s,n=[]){const i=new Set;for(const u of s)u.folder&&u.folder!=="Root"&&i.add(u.folder.split("/")[0]);for(const u of n)u.path&&i.add(u.path.split("/")[0]);const o=s.some(u=>!u.folder||u.folder==="Root");return i.size===1&&!o?[...i][0]:""}function gi(s,n){if(!s)return"";const i=String(s.title??"").trim()||rs(s.id);if(!n||!ts.test(i))return i;const o=n.match(/^\s*#[ \t]+(.+?)[ \t]*#*[ \t]*(?:\r?\n|$)/);return o?o[1].replace(/[*_`]/g,"").trim():i}function Aa(s){const n=s.replace(/^nodes\//,"").split("/").filter(Boolean).slice(0,-1);return n.map((i,o)=>n.slice(0,o+1).join("/"))}function vi(s){return new Set(["",...s.flatMap(n=>Aa(n.id||""))])}const ba="lg:min-h-0 lg:overflow-y-auto",It="rounded-lg border border-border bg-card p-4";function bi(s,n){const i=n.trim().toLowerCase().replace(/^#/,"");return i?s.filter(o=>String(o.title||rs(o.id)).toLowerCase().includes(i)||(o.tags??[]).some(u=>String(u).toLowerCase().replace(/^#/,"").includes(i))):null}const wi=["welcome","index","readme","home","overview"];function ji({nestId:s,nestName:n,nodes:i,tocGroups:o,knownFolders:u,readerHomeNode:b,initialDoc:p,onDocChange:S,onExpandFolder:w,loadingFolders:g,loadedFolders:j,approvedOnly:$=!1}){const v=r.useMemo(()=>{if(b){const l=i.find(c=>jr(c,b));if(l)return l}for(const l of wi){const c=i.find(E=>yr(E).includes(l));if(c)return c}return null},[i,b]),[m,P]=r.useState(()=>p??(v==null?void 0:v.id)??null),C=l=>{P(l),S==null||S(l),W(!1),V(null)};r.useEffect(()=>{!m&&v&&P(v.id)},[v,m]);const[R,Q]=r.useState({}),[U,le]=r.useState({}),[A,O]=r.useState(null),G=r.useRef(new Set),T=async l=>{if(!(R[l]!==void 0||G.current.has(l))){G.current.add(l),O(l);try{const{node:c}=await Sr(s,l,$);Q(E=>({...E,[l]:(c==null?void 0:c.content)??""})),(c==null?void 0:c.type)==="pdf"&&(c!=null&&c.pdf)&&le(E=>({...E,[l]:c.pdf}))}catch{V("This page could not be loaded.")}finally{G.current.delete(l),O(c=>c===l?null:c)}}};r.useEffect(()=>{m&&T(m)},[m,s]);const[J,D]=r.useState(()=>new Map),K=l=>J.get(l)??!(j!=null&&j.has(l)),ae=l=>{const c=K(l);D(E=>new Map(E).set(l,!c)),c&&w(l)};r.useEffect(()=>{if(!m)return;const l=Aa(m);if(l.length!==0){D(c=>{const E=new Map(c);for(const me of l)E.set(me,!1);return E});for(const c of l)j!=null&&j.has(c)||w(c)}},[m]);const[re,V]=r.useState(null),[M,W]=r.useState(!1),[F,f]=r.useState(""),x=r.useMemo(()=>bi(i,F),[i,F]),y=l=>{const c=di(l,i);c?C(c.id):V(`No page called “${l}” in this nest.`)},we=m?i.find(l=>l.id===m):null,Ce=m?R[m]:void 0,je=gi(we,Ce),ce=Ce===void 0?void 0:fi(Ce,je),fe=!!m&&ce===void 0&&A===m,nt=r.useMemo(()=>ce?dn(ce):[],[ce]),Re=r.useMemo(()=>hi(o),[o]),{prev:de,next:ie}=m?pi(Re,m):{prev:null,next:null},_e=m?va(m):[],Ct=l=>{var me;const c=document.getElementById(l);if(!c)return;const E=(me=window.matchMedia)==null?void 0:me.call(window,"(prefers-reduced-motion: reduce)").matches;c.scrollIntoView({behavior:E?"auto":"smooth",block:"start"})},it=r.useMemo(()=>xi(o,u),[o,u]),ue=r.useMemo(()=>o.map(l=>({...l,items:_a(l.folder,l.items)})),[o]),Rt=e.jsx(kr,{className:"space-y-px",groups:ue,baseFolder:it||void 0,known:u,isCollapsed:K,renderFolder:(l,{collapsed:c})=>e.jsxs("button",{type:"button",onClick:()=>ae(l.path),"aria-expanded":!c,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:[c?e.jsx(sa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(Cr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c?e.jsx(Rr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(_r,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:ui(l.path)}),(g==null?void 0:g.has(l.path))&&e.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:"loading"})]}),renderDoc:l=>{const c=m===l.id;return e.jsxs("button",{type:"button",onClick:()=>C(l.id),"aria-current":c?"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 "+(c?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),title:l.title||l.id,children:[e.jsx(st,{className:"h-3.5 w-3.5 shrink-0 opacity-70"}),e.jsx("span",{className:"truncate",children:l.title||l.id})]})}});return e.jsxs("div",{className:"mx-auto w-full max-w-[88rem] lg:grid lg:h-[calc(100vh-9.25rem-var(--reader-offset,0px))] lg:grid-cols-[16rem_minmax(0,1fr)_14rem] lg:gap-5",children:[e.jsxs("aside",{className:ba+" "+It+" mb-4 lg:mb-0",children:[e.jsxs("button",{type:"button",onClick:()=>W(l=>!l),"aria-expanded":M,className:"lg:hidden inline-flex items-center gap-2 text-sm font-medium py-2",children:[e.jsx(Zn,{className:"h-4 w-4"}),"Contents"]}),e.jsxs("div",{className:(M?"block":"hidden")+" lg:block",children:[e.jsx("h2",{className:"mb-3 border-b pb-3",children:e.jsxs("button",{type:"button",onClick:()=>v&&C(v.id),disabled:!v,"aria-current":v&&m===v.id?"page":void 0,title:n,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 "+(v&&m!==v.id?"text-foreground/80 hover:text-foreground":"text-foreground"),children:[e.jsx(ka,{className:"h-5 w-5 shrink-0 text-primary"}),e.jsx("span",{className:"truncate",children:n})]})}),e.jsxs("label",{className:"relative mb-3 block",children:[e.jsx(Nr,{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:F,onChange:l=>f(l.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"}),F&&e.jsx("button",{type:"button",onClick:()=>f(""),"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(Ca,{className:"h-3.5 w-3.5"})})]}),x?x.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:x.map(l=>{const c=m===l.id,E=va(l.id).join(" / ");return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>C(l.id),"aria-current":c?"page":void 0,title:l.title||l.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 "+(c?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[e.jsx(st,{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:l.title||l.id}),E&&e.jsx("span",{className:"block truncate text-[11px] font-normal text-muted-foreground/70",children:E})]})]})},l.id)})}):Rt]})]}),e.jsxs("article",{className:"min-w-0 "+It+" px-6 py-6 lg:min-h-0 lg:overflow-y-auto lg:px-8",children:[re&&e.jsxs("p",{role:"status",className:"mb-4 text-sm text-amber-800 dark:text-amber-300",children:[re,m&&R[m]===void 0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:()=>{V(null),T(m)},children:"Try again"})]})]}),we&&e.jsxs("header",{className:"mb-6",children:[_e.length>0&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-2 truncate text-[13px] text-muted-foreground",title:_e.join(" / "),children:_e.map((l,c)=>e.jsxs("span",{children:[c>0&&e.jsx("span",{"aria-hidden":!0,className:"mx-1.5 text-muted-foreground/60",children:"/"}),l]},c))}),e.jsx("h1",{className:"break-words text-[2rem] leading-[1.15] font-semibold tracking-tight text-foreground",children:je}),e.jsx(yi,{node:we})]}),!m&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a page from the contents."}),fe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}),m&&ce!==void 0&&U[m]&&e.jsx(un,{nestId:s,nodeId:m,title:je,pdf:U[m],approvedOnly:$}),m&&ce!==void 0&&e.jsx(mn,{content:ce,onWikiLinkClick:y,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"}),(de||ie)&&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:de&&e.jsxs("button",{type:"button",onClick:()=>C(de.id),title:de.title||de.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(Sn,{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:de.title||de.id})]})]})}),e.jsx("div",{className:"min-w-0",children:ie&&e.jsxs("button",{type:"button",onClick:()=>C(ie.id),title:ie.title||ie.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:ie.title||ie.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 "+ba+" "+It,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"}),nt.length===0?e.jsx("p",{className:"text-[13px] text-muted-foreground/70",children:m?"No headings yet.":"Open a page to see its headings."}):e.jsx("ul",{className:"space-y-1",children:nt.map(l=>e.jsx("li",{style:{paddingLeft:(l.level-1)*12},children:e.jsx("button",{type:"button",onClick:()=>Ct(l.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:l.text,children:l.text})},l.id))})]})})]})}function yi({node:s}){const n=String(s.status||"draft"),i=s.updated_at?yn(s.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 "+(n==="published"?"bg-emerald-500":"bg-amber-500")}),n==="published"?"Published":n.replace(/_/g," ")]}),s.version!=null&&e.jsxs("span",{children:["Version ",s.version]}),i&&e.jsxs("span",{children:["Updated ",i]})]})}const Ni=50;function Si(s,n=!0){return ss({...H.feed(s,"comments",Ni,0),enabled:n})}const Xt={nest:{label:"Entire Nest",icon:es,placeholder:""},tag:{label:"Tag",icon:$n,placeholder:"e.g., #architecture"},document:{label:"Document",icon:st,placeholder:"e.g., nodes/getting-started"}};function wa(s){return s.scope==="tag"?s.tagName||"":s.scope==="document"&&s.nodePattern||""}function ja({isOpen:s,onClose:n,nestId:i,steward:o,onSubmit:u,onSync:b}){const p=!!o,[S,w]=r.useState(""),[g,j]=r.useState("tag"),[$,v]=r.useState(""),[m,P]=r.useState("reviewer"),[C,R]=r.useState(!1),[Q,U]=r.useState(!1),[le,A]=r.useState(null),[O,G]=r.useState([]),[T,J]=r.useState(null),[D,K]=r.useState(!1),ae=as();r.useEffect(()=>{s&&(w((o==null?void 0:o.userEmail)??""),j((o==null?void 0:o.scope)??"tag"),v(o?wa(o):""),P((o==null?void 0:o.role)??"reviewer"),A(null))},[s,o]),r.useEffect(()=>{if(!s||g!=="document"&&g!=="tag")return;let f=!1;return K(!0),(g==="document"?ae.fetchQuery(H.nodes(i)).then(y=>{if(f)return;const we=Array.isArray(y==null?void 0:y.nodes)?y.nodes:[];G(we)}):ae.fetchQuery(H.tags(i)).then(y=>{f||(J(y),y.length===0&&!o&&j("nest"))})).catch(y=>console.error(`[StewardModal] ${g} fetch failed`,y)).finally(()=>{f||K(!1)}),()=>{f=!0}},[s,g,i]);const re=!p||m!==o.role||g!==o.scope||$!==wa(o),V=async()=>{if(b){U(!0),A(null);try{await b()}catch(f){A(f instanceof Error?f.message:"Failed to sync stewards.yaml")}finally{U(!1)}}},M=async()=>{if(p&&!re){n();return}if(!p&&!S.trim()){A("Please enter an email");return}if(!p&&!Ar(S.trim())){A("Enter a valid email address.");return}if(g!=="nest"&&!$.trim()){A(`Please specify the ${g} target`);return}R(!0),A(null);try{await u({email:((o==null?void 0:o.userEmail)??S).trim(),scope:g,target:g==="nest"?void 0:$.trim(),role:m}),n()}catch(f){A(f instanceof Error?f.message:p?"Failed to update steward":"Failed to assign steward"),R(!1)}},W=C||Q,F=Xt[g].icon;return e.jsx(Fe,{open:s,onOpenChange:f=>!f&&!W&&n(),children:e.jsxs(Oe,{className:"sm:max-w-[500px]",children:[e.jsxs(qe,{children:[e.jsx($e,{children:p?"Edit steward":"Assign Context Steward"}),e.jsx(kt,{children:p?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:[le&&e.jsxs(Jt,{variant:"destructive",children:[e.jsx(Na,{className:"h-4 w-4"}),e.jsx(Zt,{children:le})]}),!p&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"email",children:"Steward Email"}),e.jsx(qn,{id:"email",value:S,onChange:w,placeholder:"reviewer@acme.com",disabled:C,testId:"steward-email-input"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Scope"}),e.jsxs(da,{value:g,onValueChange:f=>{j(f),v("")},disabled:C,children:[e.jsx(ua,{children:e.jsx(ma,{})}),e.jsx(ha,{children:Object.entries(Xt).map(([f,x])=>{const y=x.icon;return e.jsx(yt,{value:f,disabled:f==="tag"&&(T==null?void 0:T.length)===0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{className:"h-4 w-4"}),x.label]})},f)})})]})]}),g!=="nest"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(se,{htmlFor:"target",children:[e.jsx(F,{className:"h-4 w-4 inline mr-2"}),g==="tag"?"Tag":Xt[g].label]}),g==="tag"?e.jsx(oa,{id:"target",testId:"steward-tag-select",value:$,onChange:v,disabled:C||D,options:(T??[]).map(f=>({value:f,label:`#${f}`})),placeholder:D?"Loading tags...":(T==null?void 0:T.length)===0?"No tags in this nest":"Select a tag",searchPlaceholder:"Search tags…",emptyText:"No tag matches that."}):e.jsx(oa,{id:"target",testId:"steward-document-select",value:$,onChange:v,disabled:C||D,options:O.map(f=>({value:f.id,label:f.title||f.id})),placeholder:D?"Loading documents...":O.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:g==="tag"?"Steward approves any document with this tag.":"Steward governs this specific document."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Role"}),e.jsxs(da,{value:m,onValueChange:f=>P(f),disabled:C,children:[e.jsx(ua,{children:e.jsx(ma,{})}),e.jsxs(ha,{children:[e.jsx(yt,{value:"editor",children:"Editor — can edit but not approve"}),e.jsx(yt,{value:"reviewer",children:"Reviewer — can approve/reject"}),e.jsx(yt,{value:"viewer",children:"Viewer — read-only access"})]})]})]})]}),e.jsxs(at,{className:"sm:justify-between",children:[b&&!p?e.jsxs(k,{variant:"ghost",size:"sm",onClick:V,disabled:W,title:"Re-import steward rows from the nest's stewards.yaml",children:[Q?e.jsx(be,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(zn,{className:"h-4 w-4 mr-2"}),"Sync stewards.yaml"]}):e.jsx("span",{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"outline",onClick:n,disabled:W,children:"Cancel"}),e.jsxs(k,{onClick:M,disabled:W||!p&&!S.trim(),children:[C?e.jsx(be,{className:"h-4 w-4 mr-2 animate-spin"}):p?null:e.jsx(Vn,{className:"h-4 w-4 mr-2"}),p?"Save":"Assign Steward"]})]})]})]})})}const ki=Me(()=>ze(()=>import("./ExternalEditsTab-kIBimZyE.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,23,24,25,26,27,28,29,30])).then(s=>({default:s.ExternalEditsTab}))),Ci=Me(()=>ze(()=>import("./StewardsTab-AagNWcWS.js"),__vite__mapDeps([31,1,2,26,8,9,10,11,12,13,14,15,16,17,18,25,4])).then(s=>({default:s.StewardsTab}))),Ri=Me(()=>ze(()=>import("./CollaboratorsTab-DRCitQuX.js"),__vite__mapDeps([32,1,2,33,12,20,11,13,8,9,10,14,15,16,17,18,24,26,34,4])).then(s=>({default:s.CollaboratorsTab}))),_i=Me(()=>ze(()=>import("./ReviewTab-CZewAYiz.js"),__vite__mapDeps([35,1,2,12,11,13,4,3,6,7,36,27,28,10,29,37,16,8,9,14,15,17,18,19,20,21,22,23,24,25,26,30])).then(s=>({default:s.ReviewTab}))),Ai=Me(()=>ze(()=>import("./OverviewTab-DFOFMVyE.js"),__vite__mapDeps([38,1,2,4,8,9,10,11,12,13,14,15,16,17,18,3,19,20,21,22,23,24,25,6,26,27,7,28,29,30])).then(s=>({default:s.OverviewTab}))),Ti=Me(()=>ze(()=>import("./DocumentsTab-BUxBCN8o.js"),__vite__mapDeps([39,1,2,40,4,11,12,13,8,9,10,14,15,16,17,18,3,41,7,28,23,34,42,37,29,5,43,19,20,21,22,24,25,6,26,27,30])).then(s=>({default:s.DocumentsTab})));function Di({nestId:s,nestName:n,isOwner:i,isAnonOwned:o,isArchived:u,onBack:b,initialDoc:p,onReaderDocChange:S,onOpenDocument:w,onOpenTrace:g,onManageKeys:j,initialSearch:$,initialTags:v,initialFolder:m,initialTab:P,onTabChange:C}){var Ks,Ys,Is,Xs,Js,Zs,ea;const{isAdmin:R,adminStatus:Q,authMode:U,sharedDeployment:le}=Tr(),A=i||o&&U!=="open"&&R,O=((Ys=(Ks=Q==null?void 0:Q.me)==null?void 0:Ks.email)==null?void 0:Ys.toLowerCase())??"",[G,T]=r.useState(n),J=r.useRef(n);r.useEffect(()=>{T(n),J.current=n},[n,s]);const D=r.useRef(null),K=r.useRef(()=>{}),ae=r.useRef(ri()).current,[re,V]=r.useState(null);K.current=async()=>{const t=G.trim();if(t&&t!==J.current.trim())try{await aa(s,{name:t}),J.current=t,V(null)}catch(a){const d=a instanceof Error?a.message:"Failed to rename nest";V(d)}};const M=r.useCallback(()=>{D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{D.current=null,K.current()},1200)},[]),W=r.useCallback(()=>{D.current&&(window.clearTimeout(D.current),D.current=null),!ae.consume()&&K.current()},[]);r.useEffect(()=>()=>{D.current&&window.clearTimeout(D.current)},[]);const[F,f]=r.useState([]),[x,y]=r.useState(null),[we,Ce]=r.useState(!1),[je,ce]=r.useState([]),[fe,nt]=r.useState([]),[Re,de]=r.useState([]),[ie,_e]=r.useState(null),[Ct,it]=r.useState(!1),ue=Re.find(t=>(t.targetType==="nest"||t.targetType==="nest_archive")&&t.status==="pending"),Rt=!!ue,l=r.useMemo(()=>Re.filter(t=>t.status==="pending"),[Re]),[c,E]=r.useState(null),[me,Ta]=r.useState(!1),[Z,ns]=r.useState(!1),[ot,is]=r.useState(!1),[Da,os]=r.useState(!1),[Ea,ls]=r.useState(!1),[cs,ds]=r.useState([]),[q,lt]=r.useState("private"),[us,ms]=r.useState(!1),[La,_t]=r.useState(!1),[hs,ps]=r.useState(""),[xe,ct]=r.useState(!1),[he,At]=r.useState(null),[Ve,dt]=r.useState(!1),[Tt,ut]=r.useState(!1),[ye,fs]=r.useState(!1),[xs,gs]=r.useState(!1),[Pa,mt]=r.useState(null),[vs,Fa]=r.useState(!1),[Oa,qa]=r.useState(null),[Ne,$a]=r.useState(null),oe=R&&(i||o)||!R&&(i||Ne==="owner"||Ne==="admin"),Ma=R||i||Ne==="owner"||Ne==="admin",[Dt,za]=r.useState([]),[Va,We]=r.useState(!1),[Be,bs]=r.useState(null),[Et,ws]=r.useState(!0),[ne,Wa]=r.useState(!0),[ee,Ae]=r.useState(null),[js,Lt]=r.useState(!1),[ys,Pt]=r.useState(!1),[Ns,Ss]=r.useState(!1),[Ba,ht]=r.useState(!1),ks=r.useRef(null),[Cs,Rs]=r.useState(""),[_s,As]=r.useState(!1),pe=ai(Cs),Ts=async()=>{const t=pe.path;if(t&&!pe.error){As(!0);try{await Yr(s,t),Rs(""),ht(!1),N.success(`Folder "${Ir(t)}" created`),_()}catch(a){console.error("[NestView] createFolder failed",a),N.error((a==null?void 0:a.message)||"Failed to create folder")}finally{As(!1)}}},[Ha,pt]=r.useState(!1),[Qa,Ft]=r.useState(!1),[ft,Ot]=r.useState(null),[Te,Ds]=r.useState(m??null),[De,Ua]=r.useState(P??(m||v!=null&&v.length?"documents":"overview")),He=t=>{Ua(t),C==null||C(t)},[Es,xt]=r.useState(new Set),[Ls,Ps]=r.useState(new Set),Y=as(),Se=r.useRef(new Set),[Ga,qt]=r.useState(new Set),ge=r.useCallback(async(t,a={})=>{if(!(!a.refresh&&Se.current.has(t))){Ps(d=>new Set(d).add(t));try{const d=await Y.fetchQuery(H.folderNodes(s,t));Se.current.add(t),qt(h=>new Set(h).add(t)),f(h=>[...h.filter(B=>oi(B.id||"")!==t),...d.nodes])}catch(d){console.error("[NestView] listFolderNodes failed",s,t,d),N.error((d==null?void 0:d.message)||"Failed to load folder")}finally{Ps(d=>{const h=new Set(d);return h.delete(t),h})}}},[s,Y]),gt=r.useCallback(async()=>{try{const{census:t}=await Y.fetchQuery(H.census(s));y(t)}catch(t){console.error("[NestView] getNestCensus failed",s,t)}finally{Ce(!0)}},[s,Y]),Fs=r.useCallback(async()=>{Se.current.size&&await Promise.all([gt(),...[...Se.current].map(t=>ge(t,{refresh:!0}))])},[ge,gt]),Ka=t=>{Ds(t),He("documents")},Ya=t=>{xt(a=>a.has(t)?a:new Set(a).add(t)),ge(t)},Ia=t=>{const a=!Es.has(t);xt(d=>{const h=new Set(d);return a?h.add(t):h.delete(t),h}),a&&ge(t)},_=r.useCallback(async()=>{var Ge;ws(!0);const t=await Y.fetchQuery(H.nest(s)).catch(z=>(console.error("[NestView] getNest failed",s,z),null)),a=!!(t!=null&&t.grant_only);Ta(a);const d=z=>Promise.resolve(z),[,h,B,L]=await Promise.all([Fs(),a?d({requests:[],total:0}):Y.fetchQuery(H.reviewQueue(s)).catch(z=>(console.error("[NestView] getReviewQueue failed",s,z),N.error((z==null?void 0:z.message)||"Failed to load review queue"),{requests:[],total:0})),a?d({requests:[],total:0}):Y.fetchQuery(H.deletionRequests(s,"all")).catch(z=>(console.error("[NestView] getDeletionRequests failed",s,z),{requests:[],total:0})),a?d({stewardship_enabled:!1,allow_self_approve:!1,prime_only_review:!1,prime_tags:[],creator_is_reviewer:!1}):Y.fetchQuery(H.settings(s)).catch(z=>(console.error("[NestView] getNestSettings failed",s,z),{stewardship_enabled:!1,allow_self_approve:!1,prime_only_review:!1,prime_tags:[],creator_is_reviewer:!1}))]);nt(h.requests),de(B.requests),ns(L.stewardship_enabled),is(L.allow_self_approve),os(!!L.prime_only_review),ls(!!L.creator_is_reviewer),ds(L.prime_tags??[]),(Ge=t==null?void 0:t.nest)!=null&&Ge.visibility&&lt(t.nest.visibility),t!=null&&t.nest&&(Fa(!!t.nest.is_imported),Ot(t.nest.description??null),ct(!!t.nest.reader_mode),At(t.nest.reader_home_node??null),qa(t.nest.archived_at??null)),t!=null&&t.permission&&$a(t.permission),za((t==null?void 0:t.roles)??[]),ce((t==null?void 0:t.myStewards)??[]),ws(!1),Wa(!1)},[s,Y,Fs]);r.useEffect(()=>{_()},[_]),r.useEffect(()=>{Se.current=new Set,xt(new Set),f([]),Ce(!1),ge(Te??""),gt()},[s,Te,ge,gt]);const $t=r.useMemo(()=>((x==null?void 0:x.folders)??[]).map(t=>({path:t.path,total:t.total})),[x]),Xa=(x==null?void 0:x.recent)??[],Ja=(x==null?void 0:x.editedLast7d)??0,vt=u||Dr({archived_at:Oa}),Qe=Er({roles:Dt,permission:Ne,myStewards:je,isOwner:i,isAdmin:R,readerMode:xe,previewReader:ye,isArchived:vt}),{canManage:ve,collabCanWrite:Mt,canEditDocs:ke,isReadOnly:I,isReaderView:zt}=Qe;r.useEffect(()=>{if(!zt)return;let t=!1;return Y.fetchQuery(H.nodesMeta(s,ye)).then(({nodes:a})=>{if(t)return;const d=vi(a);Se.current=d,qt(d),f(a)}).catch(a=>N.error((a==null?void 0:a.message)||"Failed to load documents")),()=>{t=!0}},[zt,ye,s,Y]);const Za=()=>{fs(!1),Se.current=new Set,qt(new Set),xt(new Set),f([]),ge(Te??"")},Os=(t,a)=>je.some(d=>{if(d.role!==a)return!1;if(d.scope==="nest")return!0;if(d.scope==="document")return d.nodePattern===t.id;if(d.scope==="tag"){const h=(d.tagName||"").toLowerCase().replace(/^#+/,"");return(t.tags||[]).map(B=>B.toLowerCase().replace(/^#+/,"")).includes(h)}return!1}),qs=t=>!t||I?!1:R||Dt.includes("admin")?!0:i?ot:!!Os(t,"reviewer"),Ue=fe.filter(t=>{if(t.canReview!==void 0)return t.canReview;const a=F.find(h=>h.id===t.nodeId);return!(!a||!qs(a)||t.requestedBy.toLowerCase()===O&&!(i&&ot))}),er=fe.filter(t=>t.requestedBy.toLowerCase()===O),$s=((Is=ss({...H.externalEditCount(s),enabled:!me}).data)==null?void 0:Is.total)??0,Ms=Z||Qe.canReviewDocs||fe.length>0||Qe.canManage&&l.length>0,Ee=Si(s,!me&&!ne&&!Ms).data,tr=((Xs=Ee==null?void 0:Ee.counts)==null?void 0:Xs.comments)??((Ee==null?void 0:Ee.items)??[]).filter(t=>t.type==="comment").length,Vt=Ms||tr>0,zs={overview:!0,documents:!0,review:Vt&&!I,"external-edits":!I,stewards:Z&&oe,collaborators:ve||Mt};r.useEffect(()=>{!ne&&!zs[De]&&He("overview")},[ne,De,zs[De]]);const X={total:(x==null?void 0:x.total)??F.length,pending:((Js=x==null?void 0:x.statuses)==null?void 0:Js.pending_review)??0,approved:(((Zs=x==null?void 0:x.statuses)==null?void 0:Zs.approved)??0)+(((ea=x==null?void 0:x.statuses)==null?void 0:ea.published)??0),reviewQueue:fe.length,reviewable:Ue.length},Vs=(()=>{const t=new Map;for(const a of F){const d=a.id||"",h=d.startsWith("nodes/")?d.slice(6):d,B=h.lastIndexOf("/"),L=B>0?h.slice(0,B):"Root";t.has(L)||t.set(L,[]),t.get(L).push(a)}return[...t.entries()].map(([a,d])=>({folder:a,depth:a==="Root"?0:a.split("/").length,items:[...d].sort((h,B)=>String(h.title||h.id).localeCompare(String(B.title||B.id)))})).sort((a,d)=>a.folder==="Root"?-1:d.folder==="Root"?1:ii(a.folder,d.folder))})(),sr=(x==null?void 0:x.folders.length)??0,Ws=async t=>{try{await Gr(s,t.id),N.success("Deletion request withdrawn"),_()}catch(a){N.error((a==null?void 0:a.message)||"Failed to withdraw deletion request")}},ar=async t=>{if(ee)try{await en(s,ee.id,t),N.success("Approved"),Ae(null),_()}catch(a){console.error("[NestView] approveNode failed",s,ee==null?void 0:ee.id,a),N.error((a==null?void 0:a.message)||"Approve failed")}},rr=async t=>{if(ee)try{await Zr(s,ee.id,t),N.success("Rejected"),Ae(null),_()}catch(a){console.error("[NestView] rejectNode failed",s,ee==null?void 0:ee.id,a),N.error((a==null?void 0:a.message)||"Reject failed")}},nr=async t=>{try{await Kr(s,t),N.success("Submission withdrawn — back to Draft"),_()}catch(a){console.error("[NestView] cancelReview failed",s,t,a),N.error((a==null?void 0:a.message)||"Failed to withdraw submission")}},ir=async()=>{const t=ie;try{await tn(s,t),_()}catch(a){throw console.error("[NestView] removeSteward failed",s,t,a),a}},or=async t=>{const{target:a,...d}=t,h={...d};t.scope==="document"?h.nodePattern=a:t.scope==="tag"&&(h.tagName=a),await Xr(s,h),_()},lr=async t=>{if(!Be)return;const a={role:t.role,scope:t.scope};t.scope==="document"?a.nodePattern=t.target:t.scope==="tag"&&(a.tagName=t.target),await Jr(s,Be.id,a),N.success("Steward updated"),_()},cr=async()=>{await sn(s,c.request.id),N.success("Document deleted"),_()},dr=async t=>{await an(s,c.request.id,t),N.success("Request rejected"),_()},Bs=async(t,a)=>{const d=q;lt(t),ms(!0);try{const h=await rn(s,t,a);h!=null&&h.visibility&&lt(h.visibility)}catch(h){lt(d),N.error((h==null?void 0:h.message)||"Failed to change visibility")}finally{ms(!1)}},ur=async()=>{if(q==="org"){He("collaborators");return}if(q!=="public"){ps(ft??""),_t(!0);return}await Bs("private")},mr=async()=>{_t(!1);const t=hs.trim();if(t&&t!==(ft??"").trim())try{await aa(s,{description:t}),Ot(t)}catch(a){N.error((a==null?void 0:a.message)||"Failed to save the description — publishing anyway")}await Bs("public",!0)},Wt=xn("public",{sharedDeployment:le}),hr=async()=>{const t=!xe;ct(t),dt(!0);try{const a=await ia(s,{enabled:t});ct(!!a.reader_mode),At(a.reader_home_node??null)}catch(a){ct(!t),N.error((a==null?void 0:a.message)||"Failed to change reader mode")}finally{dt(!1)}};r.useEffect(()=>{if(!Tt||!he){mt(null);return}let t=!1;return Y.fetchQuery(H.node(s,he)).then(({node:a})=>{t||mt((a==null?void 0:a.title)||he)}).catch(()=>{t||mt(he)}),()=>{t=!0}},[Tt,he,s,Y]);const Hs=async t=>{dt(!0);try{const a=await ia(s,{home_node:t});At(a.reader_home_node??null),N.success("Saved reader home node")}catch(a){N.error((a==null?void 0:a.message)||"Failed to set reader home node")}finally{dt(!1)}},[pr,Bt]=r.useState(!1),[fr,Qs]=r.useState(!1),Ht=r.useRef(null),Us=r.useRef(null),Gs=t=>{const a=t.toLowerCase().split(".").pop()||"";return a==="html"||a==="htm"?"artifact":a==="pdf"?"pdf":a==="md"||a==="markdown"||a==="txt"?"document":null},bt=r.useCallback(async t=>{var B;const a=Array.from(t).filter(L=>Gs(L.name)),d=t.length-a.length;if(!a.length){N.error("Drop .md, .html or .pdf files to add them to this vault.");return}Qs(!0);const h=[];try{for(const L of a){const Ge=Gs(L.name),z=L.name.replace(/\.(md|markdown|txt|html|htm|pdf)$/i,""),Qt=L.webkitRelativePath;let Ut;if(Qt&&Qt.includes("/")){const te=Qt.split("/").slice(1,-1);if(te.some(wt=>wt.startsWith(".")))continue;Ut=(te[0]==="nodes"?te.slice(1):te).join("/")||void 0}try{const te=Ge==="pdf"?await Lr(s,L,{title:z,folder:Ut}):await Pr(s,{title:z,content:await L.text(),type:Ge,folder:Ut}),wt=(B=te==null?void 0:te.node)==null?void 0:B.id;wt&&h.push(wt)}catch(te){N.error(`${L.name}: ${(te==null?void 0:te.message)||"failed to import"}`)}}h.length&&(N.success(`Added ${h.length} ${h.length===1?"item":"items"}`+(d?` (skipped ${d} unsupported)`:"")),await _(),h.length===1&&w(h[0]))}finally{Qs(!1)}},[s,_,w]);return zt?e.jsxs("div",{style:ye?{"--reader-offset":"3.5rem"}:void 0,children:[ye&&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(k,{variant:"outline",size:"sm",className:"h-7",onClick:Za,children:"Exit preview"})]}),e.jsx(ji,{nestId:s,nestName:G,nodes:F,tocGroups:Vs,knownFolders:$t,readerHomeNode:he,initialDoc:p,onDocChange:S,onExpandFolder:ge,loadingFolders:Ls,loadedFolders:Ga,approvedOnly:ye},ye?"preview":"reader")]}):e.jsxs("div",{className:"relative",onDragOver:t=>{ke&&Array.from(t.dataTransfer.types).includes("Files")&&(t.preventDefault(),Bt(!0))},onDragLeave:t=>{t.currentTarget===t.target&&Bt(!1)},onDrop:t=>{var a;ke&&(t.preventDefault(),Bt(!1),(a=t.dataTransfer.files)!=null&&a.length&&bt(t.dataTransfer.files))},children:[pr&&ke&&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(la,{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"})]})}),fr&&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(be,{className:"h-4 w-4 animate-spin"})," Importing…"]})}),e.jsxs(Ln,{nestName:n,onBack:b,title:ve?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:G,onChange:t=>{T(t.target.value),V(null),M()},onBlur:W,onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),W(),t.target.blur()),t.key==="Escape"&&(ae.arm(),T(J.current),V(null),t.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"}),!Et&&e.jsx("button",{type:"button",onClick:()=>{W(),Ft(!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(qr,{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:[ve?e.jsxs(k,{variant:"outline",size:"sm",onClick:ur,disabled:us,className:`shrink-0 h-7 gap-1.5 ${q==="public"?"border-blue-200 bg-blue-50 text-blue-700 hover:bg-blue-100":""}`,title:q==="public"?"Public — anyone with the URL can read. Click to make private.":q==="org"?`Organization — ${pn("org",{sharedDeployment:le}).toLowerCase()}. Click to manage sharing (Collaborators tab).`:"Private. Click to make public (anyone with the URL can read).",children:[us?e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}):q==="public"?e.jsx(ra,{className:"h-3.5 w-3.5"}):q==="org"?e.jsx(es,{className:"h-3.5 w-3.5"}):e.jsx(Or,{className:"h-3.5 w-3.5"}),q==="public"?"Public":q==="org"?"Organization":"Private"]}):q!=="private"&&e.jsxs(Ye,{variant:"outline",className:`shrink-0 gap-1 ${q==="public"?"border-green-200 bg-green-50 text-green-700":"border-blue-200 bg-blue-50 text-blue-700"}`,title:q==="public"?"Anyone with the URL can read this nest":"Everyone signed in to this deployment can read this nest",children:[q==="public"?e.jsx(ra,{className:"h-3 w-3"}):e.jsx(es,{className:"h-3 w-3"}),q==="public"?"Public":"Organization"]}),Ma&&!vt&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>ut(!0),className:`shrink-0 h-7 gap-1.5 ${xe?"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:[Ve?e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ka,{className:"h-3.5 w-3.5"}),xe?"Reader: On":"Reader: Off"]}),vs&&e.jsxs(Ye,{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(Bn,{className:"h-3 w-3"}),"Imported"]}),ue&&(()=>{const t=ue.requestedBy.toLowerCase()===O,a=ue.targetType==="nest_archive",d=a?"archived":"deleted";return e.jsxs(Ye,{variant:"outline",className:`shrink-0 gap-1 ${a?"border-amber-200 bg-amber-50 text-amber-700":"border-red-200 bg-red-50 text-red-700"} ${t?"cursor-pointer hover:opacity-80":""}`,title:t?`Click to withdraw your ${a?"archive":"deletion"} request`:`${ue.requestedBy} asked for this nest to be ${d}: "${ue.reason}". A nest owner or admin decides.`,"data-testid":"nest-deletion-flag",onClick:t?()=>Ws(ue):void 0,children:[a?e.jsx(Hn,{className:"h-3 w-3"}):e.jsx(pa,{className:"h-3 w-3"}),a?"Archive requested":"Deletion requested",t&&e.jsx(Ca,{className:"h-3 w-3 ml-0.5"})]})})()]}),children:[!vt&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>Pt(!0),children:[e.jsx(Mn,{className:"h-3.5 w-3.5 mr-1.5"}),"Connect"]}),!I&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>Ss(!0),children:[e.jsx(ya,{className:"h-3.5 w-3.5 mr-1.5"}),"Add with AI"]}),ve&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>He("collaborators"),children:[e.jsx(Fr,{className:"h-3.5 w-3.5 mr-1.5"}),"Share"]}),!I&&ke&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:Ht,type:"file",multiple:!0,accept:".md,.markdown,.txt,.html,.htm,.pdf",className:"hidden",onChange:t=>{var a;(a=t.target.files)!=null&&a.length&&bt(t.target.files),t.target.value=""}}),e.jsx("input",{ref:Us,type:"file",multiple:!0,accept:"application/pdf,.pdf",className:"hidden",onChange:t=>{var a;(a=t.target.files)!=null&&a.length&&bt(t.target.files),t.target.value=""}}),e.jsx("input",{ref:ks,type:"file",className:"hidden",webkitdirectory:"",onChange:t=>{var a;(a=t.target.files)!=null&&a.length&&bt(t.target.files),t.target.value=""}})]}),(()=>{const t=[];return!I&&oe&&t.push({label:"Nest settings",icon:fa,onSelect:()=>We(!0)}),!I&&Z&&oe&&t.push({label:"Assign Steward",icon:St,onSelect:()=>Lt(!0)}),oe&&g&&!vt&&t.push({label:"Activity trace",icon:Gn,onSelect:g}),!I&&(A||ke)&&(A||!Rt)&&t.push({label:"Delete",icon:pa,destructive:A,separatorBefore:!0,onSelect:()=>A?pt(!0):it(!0)}),e.jsx(hn,{actions:t,variant:"outline",className:"h-8 w-8"})})()]}),e.jsxs("div",{className:`grid grid-cols-1 gap-4 mb-4 ${Z?"md:grid-cols-4":"md:grid-cols-1 max-w-sm"}`,children:[e.jsxs(Ie,{children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(Je,{children:"Total Documents"}),e.jsx(Ze,{className:"text-3xl",children:ne?e.jsx(jt,{className:"h-8 w-12"}):X.total})]}),e.jsx(et,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(st,{className:"h-4 w-4"}),e.jsx("span",{children:ne?"Loading…":X.total===0?"No documents yet":Z?"In your context":"Auto-approved, AI-ready"})]})})]}),Z&&e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(Je,{children:"Pending Approvals"}),e.jsx(Ze,{className:"text-3xl text-amber-600",children:ne?e.jsx(jt,{className:"h-8 w-12"}):X.pending})]}),e.jsx(et,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Yn,{className:"h-4 w-4"}),e.jsx("span",{children:"Awaiting approval"})]})})]}),e.jsxs(Ie,{children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(Je,{children:"AI Ready"}),e.jsx(Ze,{className:"text-3xl text-green-600",children:ne?e.jsx(jt,{className:"h-8 w-12"}):X.approved})]}),e.jsx(et,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Qn,{className:"h-4 w-4"}),e.jsx("span",{children:ne?"Loading…":X.total===0?"Nothing to evaluate yet":"Approved for AI"})]})})]}),e.jsxs(Ie,{children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(Je,{children:"Your Review Queue"}),e.jsx(Ze,{className:"text-3xl text-blue-600",children:ne?e.jsx(jt,{className:"h-8 w-12"}):X.reviewable})]}),e.jsx(et,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(St,{className:"h-4 w-4"}),e.jsxs("span",{children:["Need your review",X.reviewQueue>X.reviewable&&e.jsxs("span",{className:"ml-1 text-xs",children:["(",X.reviewQueue," pending total,"," ",X.reviewQueue-X.reviewable," outside your scope)"]})]})]})})]})]})]}),e.jsxs($r,{value:De,onValueChange:He,className:"w-full min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 min-w-0",children:[e.jsxs(Mr,{className:"max-w-full justify-start overflow-x-auto",children:[e.jsx(Le,{value:"overview",children:"Overview"}),e.jsx(Le,{value:"documents",children:"Documents"}),Vt&&!I&&e.jsxs(Le,{value:"review",className:"gap-2",children:["Review Queue",Ue.length>0&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:Ue.length})]}),!I&&e.jsxs(Le,{value:"external-edits",className:"gap-2",children:["External Edits",$s>0&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-orange-100 text-orange-700",children:$s})]}),Z&&oe&&e.jsx(Le,{value:"stewards",children:"Stewards"}),(ve||Mt)&&e.jsx(Le,{value:"collaborators",children:"Collaborators"})]}),!I&&ke&&e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(k,{variant:"outline",size:"sm",className:"text-muted-foreground",onClick:()=>ht(!0),title:"Create a folder (nest with parent/child)",children:[e.jsx(ca,{className:"h-4 w-4 mr-1.5"}),"New Folder"]}),e.jsxs(zr,{modal:!1,children:[e.jsx(Vr,{asChild:!0,children:e.jsxs(k,{variant:"outline",size:"sm","data-testid":"nest-import-files",children:[e.jsx(la,{className:"h-3.5 w-3.5 mr-1.5"}),"Import"]})}),e.jsxs(Wr,{align:"end",children:[e.jsx(Kt,{onSelect:()=>{var t;return(t=Ht.current)==null?void 0:t.click()},children:"Files (.md / .html / .pdf)"}),e.jsx(Kt,{onSelect:()=>{var t;return(t=Us.current)==null?void 0:t.click()},"data-testid":"nest-upload-pdf",children:"Upload PDF (as a document)"}),e.jsx(Kt,{onSelect:()=>{var t;return(t=ks.current)==null?void 0:t.click()},children:"Whole vault (folder, keeps structure)"})]})]}),e.jsxs(k,{size:"sm",onClick:()=>w("new",{folder:De==="documents"&&Te?Te:void 0}),children:[e.jsx(Br,{className:"h-3.5 w-3.5 mr-1.5"}),"New Document"]})]})]}),e.jsx(Pe,{value:"overview",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(Ai,{initialLoad:ne||!we,stats:X,recentlyEdited:Xa,recentlyEditedCount:Ja,folderCount:sr,tocGroups:Vs,knownFolders:$t,isReadOnly:I,canEditDocs:ke,onOpenDocument:w,onOpenFolder:Ka})})}),e.jsx(Pe,{value:"documents",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(Ti,{nestId:s,initialSearch:$,initialTags:v,initialLoad:ne,loading:Et,nodes:F,census:x,knownFolders:$t,folderFilter:Te,setFolderFilter:Ds,expandedFolders:Es,loadingFolders:Ls,toggleFolderExpanded:Ia,expandFolder:Ya,caps:Qe,isAdmin:R,isOwner:i,roles:Dt,permission:Ne,currentEmail:O,myStewards:je,stewardshipEnabled:Z,allowSelfApprove:ot,primeTags:cs,visibility:q,hasRoleOnNode:Os,canReviewNode:qs,reviewQueue:fe,reviewableQueue:Ue,deletionRequests:Re,stats:X,onOpenDocument:w,onReview:Ae,onRefresh:_,onWithdrawDeletion:t=>void Ws(t),importInputRef:Ht})})}),Vt&&e.jsx(Pe,{value:"review",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(_i,{nestId:s,enabled:!me,reviewQueue:fe,reviewableQueue:Ue,myPendingSubmissions:er,pendingDeletions:l,canManage:ve,loading:Et,onRefresh:_,onOpenDocument:w,onSelectRequest:t=>{const a=F.find(d=>d.id===t.nodeId);if(a){Ae(a);return}w(t.nodeId)},onResolveDeletion:(t,a)=>E({request:t,action:a}),onWithdrawSubmission:t=>void nr(t)},s)})}),e.jsx(Pe,{value:"external-edits",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(ki,{nestId:s,enabled:!me,onOpenDocument:w,titleOf:t=>{var a;return(a=F.find(d=>d.id===t))==null?void 0:a.title}})})}),Z&&oe&&e.jsx(Pe,{value:"stewards",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(Ci,{nestId:s,canManage:oe&&!Qe.isReadOnly,currentUserEmail:O,onAssign:()=>Lt(!0),onRemove:_e,onEditRole:bs})})}),(ve||Mt)&&e.jsx(Pe,{value:"collaborators",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(Ri,{nestId:s,nestName:n,canManage:ve,canManageGovernance:oe,stewardshipEnabled:Z,currentUserEmail:O,callerPermission:Ne??void 0,onOpenSettings:()=>We(!0),onChanged:_})})})]}),De==="review"&&!Z&&!I&&oe&&e.jsxs(Ie,{className:"mt-4",children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsxs(Ze,{className:"text-base flex items-center gap-2",children:[e.jsx(St,{className:"h-4 w-4"}),"Stewardship is off"]}),e.jsx(Je,{children:"New documents are auto-approved and immediately AI-ready."})]}),e.jsxs(et,{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(k,{variant:"outline",size:"sm",className:"w-full",onClick:()=>We(!0),children:[e.jsx(fa,{className:"h-3.5 w-3.5 mr-2"}),"Open Settings"]})]})]}),ys&&e.jsx(Hr,{isOpen:ys,onClose:()=>Pt(!1),nestId:s,nestName:n,onManageKeys:j&&(()=>{Pt(!1),j()})}),Ns&&e.jsx(li,{isOpen:Ns,onClose:()=>Ss(!1),nestId:s,nestName:n,openMode:U==="open"}),Va&&e.jsx(ci,{nestId:s,nestName:n,stewardshipEnabled:Z,allowSelfApprove:ot,primeOnlyReview:Da,primeTags:cs,creatorIsReviewer:Ea,canManageStewardship:oe,onClose:()=>We(!1),onChanged:t=>{We(!1),ns(t.stewardshipEnabled),is(t.allowSelfApprove),os(t.primeOnlyReview),ds(t.primeTags),ls(t.creatorIsReviewer),_()}}),Ha&&e.jsx(Pn,{nestId:s,nestName:n,isImported:vs,open:!0,onOpenChange:pt,onDeleted:()=>{pt(!1),b()},onArchived:()=>{pt(!1),N.success(`"${n}" archived — find it under Archived`),b()}}),Qa&&e.jsx(Fn,{nestId:s,nestName:G,nestDescription:ft,open:!0,onOpenChange:Ft,onRenamed:(t,a)=>{a.nameChanged&&(T(t.name),J.current=t.name,V(null)),Ot(t.description),Ft(!1)}}),e.jsx(Fe,{open:Ba,onOpenChange:ht,children:e.jsxs(Oe,{className:"max-w-md",children:[e.jsx(qe,{children:e.jsx($e,{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(Sa,{autoFocus:!0,value:Cs,onChange:t=>Rs(t.target.value),onKeyDown:t=>{t.key==="Enter"&&Ts()},placeholder:"e.g. gtm/deals",className:"font-mono"}),pe.error?e.jsx("p",{className:"text-xs text-destructive","data-testid":"new-folder-error",children:pe.error}):pe.rewritten&&pe.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:pe.path})]}):null,e.jsxs(at,{children:[e.jsx(k,{variant:"ghost",onClick:()=>ht(!1),children:"Cancel"}),e.jsxs(k,{onClick:()=>void Ts(),disabled:_s||!pe.path||!!pe.error,children:[_s?e.jsx(be,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ca,{className:"h-4 w-4 mr-2"}),"Create folder"]})]})]})}),e.jsx(Fe,{open:Tt,onOpenChange:ut,children:e.jsxs(Oe,{className:"sm:max-w-[520px]",children:[e.jsxs(qe,{children:[e.jsx($e,{children:"Public Docs Reader Mode"}),e.jsx(kt,{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(se,{className:"text-sm font-medium",children:"Reader mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xe?"Read-only visitors get the docs reader.":"Everyone gets the standard nest view."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Ve&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),e.jsx(tt,{checked:xe,onCheckedChange:()=>void hr(),disabled:Ve,"aria-label":"Toggle Public Docs Reader Mode"})]})]}),xe&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsx(se,{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:he?Pa??"Loading…":e.jsx("span",{className:"text-muted-foreground",children:"Resolved by convention"})}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>gs(!0),disabled:Ve,children:he?"Change":"Choose"}),he&&e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>void Hs(null),disabled:Ve,children:"Clear"})]})]}),e.jsxs(at,{children:[xe&&e.jsxs(k,{variant:"outline",className:"mr-auto gap-1.5",onClick:()=>{ut(!1),fs(!0)},children:[e.jsx(Qr,{className:"h-3.5 w-3.5"}),"Preview as reader"]}),e.jsx(k,{variant:"outline",onClick:()=>ut(!1),children:"Done"})]})]})}),xs&&e.jsx(fn,{isOpen:xs,onClose:()=>gs(!1),nestId:s,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:t=>{mt(t.title),Hs(t.id)}}),e.jsx(kn,{open:La,onOpenChange:_t,children:e.jsxs(Cn,{children:[e.jsxs(Rn,{children:[e.jsx(_n,{children:Wt.title}),e.jsx(An,{children:Wt.body})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(se,{htmlFor:"nest-public-description",className:"text-xs",children:(ft??"").trim()?"Description readers will see":"This nest has no description — readers will only see its name. Add one? (optional)"}),e.jsx(On,{id:"nest-public-description",value:hs,onChange:t=>ps(t.target.value),placeholder:"What this nest is for, and who it's meant for",rows:2,"data-testid":"nest-public-description"})]}),e.jsxs(Tn,{children:[e.jsx(Dn,{children:"Cancel"}),e.jsx(En,{onClick:()=>void mr(),children:Wt.confirm})]})]})}),js&&e.jsx(ja,{isOpen:js,onClose:()=>Lt(!1),nestId:s,onSubmit:or,onSync:async()=>{await Ur(s),await _()}}),Be&&e.jsx(ja,{isOpen:!!Be,steward:Be,nestId:s,onClose:()=>bs(null),onSubmit:lr}),ee&&e.jsx(Ei,{node:ee,nestId:s,onApprove:ar,onReject:rr,onClose:()=>Ae(null),onOpenDocument:t=>{Ae(null),w(t)}}),ie&&e.jsx(Yt,{open:!0,onOpenChange:t=>!t&&_e(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:ir}),Ct&&e.jsx(Yt,{open:!0,onOpenChange:it,title:`Request removal of "${n}"`,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 t=>{await na(s,"nest_archive",s,t),N.success("Archive requested — a nest admin will review it"),_()},onConfirm:async t=>{await na(s,"nest",s,t),N.success("Deletion requested — a nest admin will review it"),_()}}),c&&e.jsx(Yt,{open:!0,onOpenChange:t=>!t&&E(null),title:c.action!=="delete"?"Reject this request":c.request.targetType==="nest_archive"?`Archive "${c.request.title||c.request.nodeId}"?`:`Delete "${c.request.title||c.request.nodeId}"?`,description:c.action!=="delete"?`${c.request.requestedBy} asked for this: "${c.request.reason}". The document stays; your note is the record.`:c.request.targetType==="nest_archive"?`${c.request.requestedBy} asked for this: "${c.request.reason}". The nest goes read-only and leaves the dashboard; nothing is deleted and you can restore it.`:`${c.request.requestedBy} asked for this: "${c.request.reason}". Deleting cannot be undone.`,label:c.action==="decline"?"Why are you rejecting?":void 0,placeholder:"e.g. still referenced by onboarding",confirmLabel:c.action!=="delete"?"Reject":c.request.targetType==="nest_archive"?"Archive nest":"Delete document",destructive:c.action==="delete"&&c.request.targetType!=="nest_archive",onConfirm:c.action==="delete"?cr:dr})]})}function Ei({node:s,nestId:n,onApprove:i,onReject:o,onClose:u,onOpenDocument:b}){var m;const[p,S]=r.useState(null),w=as(),{data:g,isLoading:j}=ss({...H.node(n,s.id),enabled:!s.content}),$=s.content||((m=g==null?void 0:g.node)==null?void 0:m.content)||"",v=async(P,C)=>{S(null);try{const{nodes:R}=await w.fetchQuery(H.nodes(n)),Q=vn(R,P,!1);if(Q.kind==="navigate"){b(Q.node.id);return}S(`"${P}" doesn't exist in this nest. Reviewers can't create new documents — ask an editor to add it.`)}catch(R){console.error("[NestView] wiki-link lookup failed",n,P,R),S("Couldn't look up that document — try again later.")}};return e.jsx(Fe,{open:!0,onOpenChange:u,children:e.jsxs(Oe,{className:"sm:max-w-[600px] max-h-[80vh] flex flex-col",children:[e.jsx(qe,{children:e.jsx($e,{children:s.title})}),p&&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:p}),e.jsx("div",{className:"flex-1 overflow-y-auto rounded-md",children:$?e.jsx(gn,{content:$,onChange:()=>{},editable:!1,nestId:n,onWikiLinkClick:v},s.id):j?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(at,{children:e.jsx(Wn,{documentTitle:s.title,version:s.version||1,onApprove:i,onReject:o})})]})})}const oo=Object.freeze(Object.defineProperty({__proto__:null,NestView:Di,NodeTypeIcon:ni},Symbol.toStringTag,{value:"Module"}));export{Yn as C,no as D,Xn as F,ni as N,ro as S,io as T,Ni as a,so as b,ai as c,ii as d,oo as e,oi as f,ao as t,Si as u};
@@ -1 +0,0 @@
1
- import{j as e,L as C,az as d,bx as i,F,B as P,aP as c,bz as B,e as T,ac as p}from"./index-B5hLclEq.js";import{C as u,N as h,t as j,b as $}from"./NestView-DwIagxwJ.js";import{C as a,d as l,a as g,c as N,b as z}from"./card-UDyMRcps.js";import"./MarkdownEditor-Dfk5uIE5.js";import"./zap-BcsKR0ef.js";import"./triangle-alert-CsYGyfGZ.js";import"./scroll-area-CbcH6yrZ.js";import"./select-DrL0mpRN.js";import"./index-A0_ymcqL.js";import"./arrow-left-BAgIocLn.js";import"./trash-2-B4hRXo-p.js";import"./x-qxt1WrUi.js";import"./dates-BCxbm4_q.js";import"./chevron-left-XR4ReJ9Z.js";import"./alert-dialog-4SiLKlz8.js";import"./NestPageHeader-yOK-OIYZ.js";import"./count-skeleton-DBWCDhRy.js";import"./folder-input-BAwK9tFL.js";import"./PersonCombobox-D350WlrJ.js";import"./tag-Br_y1f00.js";import"./refresh-cw-CsCtmWwX.js";import"./user-plus-4CTYEkd3.js";import"./ReviewActions-BXDTDPp1.js";import"./circle-check-CSkZUEFK.js";import"./circle-x-in2o3aHU.js";import"./ReasonDialog-CN3ECAnQ.js";import"./settings-EY4A_DYv.js";function le({initialLoad:f,stats:b,recentlyEdited:o,recentlyEditedCount:y,folderCount:m,tocGroups:w,knownFolders:n,isReadOnly:v,canEditDocs:x,onOpenDocument:r,onOpenFolder:k}){return e.jsx(e.Fragment,{children:f?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(C,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2",children:[e.jsx(a,{className:"border-muted/60",children:e.jsxs(l,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"rounded-md bg-blue-500/10 text-blue-600 p-2",children:e.jsx(d,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-semibold leading-none",children:m}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Folder",m===1?"":"s"]})]})]})}),e.jsx(a,{className:"border-muted/60",children:e.jsxs(l,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"rounded-md bg-amber-500/10 text-amber-600 p-2",children:e.jsx(u,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-semibold leading-none",children:y}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Edited this week"})]})]})})]}),o.length>0&&e.jsxs(a,{children:[e.jsx(g,{className:"pb-3",children:e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(u,{className:"h-4 w-4 text-muted-foreground"}),"Recently edited"]})}),e.jsx(l,{className:"pt-0",children:e.jsx("ul",{className:"divide-y",children:o.map(t=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>r(t.id),className:"w-full flex items-center gap-3 py-2 px-1 -mx-1 rounded hover:bg-muted/50 text-left group",children:[e.jsx(h,{type:t.type}),e.jsx("span",{className:"text-sm truncate flex-1",children:t.title||t.id}),(()=>{const s=j(t.type||"document");return s?e.jsx("span",{className:`shrink-0 rounded px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide ${s.cls}`,title:s.title,children:s.label}):null})(),t.updated_at&&e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:$(t.updated_at)}),e.jsx(i,{className:"h-4 w-4 text-muted-foreground/40 group-hover:text-muted-foreground shrink-0"})]})},t.id))})})]}),e.jsxs(a,{children:[e.jsxs(g,{className:"pb-3",children:[e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(d,{className:"h-4 w-4 text-muted-foreground"}),"Contents"]}),e.jsx(z,{children:"Browse documents grouped by folder."})]}),e.jsx(l,{className:"pt-0",children:b.total===0&&n.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(F,{className:"h-8 w-8 text-muted-foreground/40 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No documents yet."}),!v&&x&&e.jsxs(P,{className:"mt-3",size:"sm",onClick:()=>r("new"),children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),"New Document"]})]}):e.jsx(B,{className:"space-y-1",groups:w,known:n,renderFolder:t=>e.jsxs("button",{type:"button",onClick:()=>k(t.path),className:"flex items-center gap-2 py-1 group/folder rounded px-1 -mx-1 hover:bg-muted/60 w-full text-left",title:`Browse ${p(t.path)} in Documents`,children:[e.jsx(d,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm font-medium group-hover/folder:underline",children:t.label}),e.jsx(T,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5",children:t.total}),e.jsx(i,{className:"h-3.5 w-3.5 text-muted-foreground/40 group-hover/folder:text-muted-foreground"}),x&&e.jsx("span",{role:"button",tabIndex:0,className:"rounded p-0.5 text-muted-foreground opacity-0 group-hover/folder:opacity-100 hover:text-primary hover:bg-primary/10",title:`New document in ${p(t.path)}`,onClick:s=>{s.stopPropagation(),r("new",{folder:t.path})},onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),r("new",{folder:t.path}))},children:e.jsx(c,{className:"h-3.5 w-3.5"})})]}),renderDoc:t=>e.jsxs("button",{onClick:()=>r(t.id),className:"flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-muted/50 text-left group min-w-0 w-full",title:t.title||t.id,children:[e.jsx(h,{type:t.type,className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm truncate flex-1",children:t.title||t.id}),(()=>{const s=j(t.type||"document");return s?e.jsx("span",{className:`shrink-0 rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ${s.cls}`,title:s.title,children:s.label}):null})(),e.jsx(i,{className:"h-3.5 w-3.5 text-muted-foreground/40 group-hover:text-muted-foreground shrink-0"})]})})})]})]})})}export{le as OverviewTab};
@@ -1 +0,0 @@
1
- import{r as o,S as C,i as L,j as r,I as M,s as v}from"./index-B5hLclEq.js";const N=200;function S({value:u,onChange:d,onSubmit:c,placeholder:y="name@company.com",disabled:x,exclude:h,id:D,className:E,testId:b}){const[s,l]=o.useState(!1),[a,i]=o.useState(-1),g=o.useRef(null),[j,k]=o.useState(u.trim().toLowerCase());o.useEffect(()=>{const e=setTimeout(()=>k(u.trim().toLowerCase()),N);return()=>clearTimeout(e)},[u]);const{data:f}=C({...L.peopleSuggest(j),enabled:s&&!x}),w=o.useMemo(()=>new Set((h??[]).map(e=>e.trim().toLowerCase())),[h]),n=o.useMemo(()=>((f==null?void 0:f.people)??[]).filter(e=>!w.has(e.email.trim().toLowerCase())),[f,w]);o.useEffect(()=>i(-1),[n.length]),o.useEffect(()=>{if(!s)return;const e=t=>{var m;(m=g.current)!=null&&m.contains(t.target)||l(!1)};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[s]);const p=e=>{d(e),l(!1),i(-1)};return r.jsxs("div",{ref:g,className:v("relative",E),children:[r.jsx(M,{id:D,type:"text",inputMode:"email",autoComplete:"off",placeholder:y,value:u,disabled:x,"data-testid":b,role:"combobox","aria-expanded":s,"aria-autocomplete":"list",onChange:e=>{d(e.target.value),l(!0)},onFocus:()=>l(!0),onKeyDown:e=>{if(e.key==="Escape"&&s){e.stopPropagation(),l(!1);return}if(!s||n.length===0){e.key==="Enter"&&c&&(e.preventDefault(),c());return}if(e.key==="ArrowDown")e.preventDefault(),i(t=>(t+1)%n.length);else if(e.key==="ArrowUp")e.preventDefault(),i(t=>t<=0?n.length-1:t-1);else if(e.key==="Enter"){const t=a>=0?n[a]:void 0;t?(e.preventDefault(),p(t.email)):c&&(e.preventDefault(),c())}else if(e.key==="Tab"&&a>=0){const t=n[a];t&&(e.preventDefault(),p(t.email))}}}),s&&n.length>0&&r.jsx("ul",{role:"listbox",className:"absolute z-50 mt-1 max-h-56 w-full overflow-auto rounded-md border bg-popover py-1 text-popover-foreground shadow-md",children:n.map((e,t)=>r.jsx("li",{children:r.jsxs("button",{type:"button",role:"option","aria-selected":t===a,onMouseDown:m=>{m.preventDefault(),p(e.email)},onMouseEnter:()=>i(t),className:v("flex w-full flex-col items-start px-3 py-1.5 text-left text-sm",t===a?"bg-accent text-accent-foreground":""),children:[r.jsx("span",{className:"truncate font-medium",children:e.name||e.email.split("@")[0]}),r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:e.email})]})},e.email))})]})}export{S as P};
@@ -1 +0,0 @@
1
- import{r as c,j as s,D as F,x as T,y as H,z as L,G as $,J as z,A as G,K as J,a as K,H as q,B as m,L as y}from"./index-B5hLclEq.js";import{T as I}from"./scroll-area-CbcH6yrZ.js";import{f as N}from"./dates-BCxbm4_q.js";function Q({open:w,onOpenChange:u,title:C,description:x,label:t,optionalReason:A,placeholder:R,confirmLabel:k,destructive:B,priorDecline:a,secondaryLabel:h,onSecondary:j,onConfirm:S}){const[r,n]=c.useState(""),[o,g]=c.useState(null),i=o!==null,[f,l]=c.useState(null),v=e=>{i||(e||(n(""),l(null)),u(e))},p=async(e,E)=>{g(e),l(null);try{await E(r.trim()),n(""),u(!1)}catch(d){l((d==null?void 0:d.message)||"Something went wrong")}finally{g(null)}},D=()=>p("confirm",S),b=i||!!t&&!A&&!r.trim();return s.jsx(F,{open:w,onOpenChange:v,children:s.jsxs(T,{className:"sm:max-w-[440px]",children:[s.jsxs(H,{children:[s.jsx(L,{children:C}),x&&s.jsx($,{children:x})]}),a&&s.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900 space-y-1","data-testid":"reason-dialog-prior-decline",children:[s.jsxs("p",{className:"font-medium",children:["Rejected",a.resolvedBy?` by ${a.resolvedBy}`:"",N(a.resolvedAt)?` · ${N(a.resolvedAt)}`:""]}),a.resolutionNote&&s.jsxs("p",{children:["“",a.resolutionNote,"”"]}),a.reason&&s.jsxs("p",{className:"text-amber-800/80",children:["Asked before: “",a.reason,"”"]})]}),t&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(z,{htmlFor:"reason-dialog-input",children:t}),s.jsx(I,{id:"reason-dialog-input",autoFocus:!0,rows:3,value:r,placeholder:R,onChange:e=>n(e.target.value),"data-testid":"reason-dialog-input"})]}),f&&s.jsxs(G,{variant:"destructive",children:[s.jsx(J,{className:"h-4 w-4"}),s.jsx(K,{children:f})]}),s.jsxs(q,{children:[s.jsx(m,{variant:"outline",onClick:()=>v(!1),disabled:i,children:"Cancel"}),h&&j&&s.jsxs(m,{variant:"outline",onClick:()=>p("secondary",j),disabled:b,"data-testid":"reason-dialog-secondary",children:[o==="secondary"&&s.jsx(y,{className:"h-4 w-4 mr-2 animate-spin"}),h]}),s.jsxs(m,{onClick:D,disabled:b,variant:B?"destructive":"default","data-testid":"reason-dialog-confirm",children:[o==="confirm"&&s.jsx(y,{className:"h-4 w-4 mr-2 animate-spin"}),k]})]})]})})}export{Q as R};
@@ -1 +0,0 @@
1
- import{j as e,L as ae,B as d,e as E,cc as X,cd as Z,bx as O,F as le,s as ce,u as de,r as z,co as q,i as me,f as P,ct as xe,a8 as he}from"./index-B5hLclEq.js";import{C as Q,u as pe,a as ue}from"./NestView-DwIagxwJ.js";import"./select-DrL0mpRN.js";import{f as re}from"./scroll-area-CbcH6yrZ.js";import{C as $,a as A,c as R,d as S,b as W}from"./card-UDyMRcps.js";import{p as ge}from"./dates-BCxbm4_q.js";import{R as ee}from"./refresh-cw-CsCtmWwX.js";import{C as fe}from"./circle-check-CSkZUEFK.js";import{C as je}from"./corner-down-right-CuxZWscX.js";import{M as ve}from"./ReviewActions-BXDTDPp1.js";import{T as te}from"./triangle-alert-CsYGyfGZ.js";import{R as ye}from"./ReasonDialog-CN3ECAnQ.js";import{S as Ne}from"./send-CvAgOUPG.js";import{T as be}from"./trash-2-B4hRXo-p.js";import"./MarkdownEditor-Dfk5uIE5.js";import"./zap-BcsKR0ef.js";import"./index-A0_ymcqL.js";import"./arrow-left-BAgIocLn.js";import"./x-qxt1WrUi.js";import"./chevron-left-XR4ReJ9Z.js";import"./alert-dialog-4SiLKlz8.js";import"./NestPageHeader-yOK-OIYZ.js";import"./count-skeleton-DBWCDhRy.js";import"./folder-input-BAwK9tFL.js";import"./PersonCombobox-D350WlrJ.js";import"./tag-Br_y1f00.js";import"./user-plus-4CTYEkd3.js";import"./settings-EY4A_DYv.js";import"./circle-x-in2o3aHU.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:te},urgent:{label:"Urgent",className:"bg-red-100 text-red-600",icon:te}};function se(c){const x=ge(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:j=!0,onRefresh:p,onSelect:N,comments:T,onSelectComment:v,selectedNodeIds:u,onToggleSelect:F}){const g=T!==void 0,M=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:[j&&e.jsx(A,{className:"pb-3",children:e.jsx(R,{className:"text-lg",children:"Review Queue"})}),e.jsx(S,{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:[j&&e.jsx(A,{className:"pb-3",children:e.jsx(R,{className:"text-lg",children:"Review Queue"})}),e.jsx(S,{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(ee,{className:"h-4 w-4"})})]})})]}):e.jsxs($,{className:r,children:[j&&e.jsx(A,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-lg",children:g?"Activity":"Review Queue"}),e.jsx(W,{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(ee,{className:"h-4 w-4"})})]})}),e.jsx(S,{children:M.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:M.map(a=>{var B,D;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(je,{className:"h-5 w-5 text-amber-500 flex-shrink-0 mt-0.5"}):e.jsx(ve,{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(X,{className:"h-4 w-4",children:e.jsx(Z,{className:"text-[8px]",children:((B=n.author[0])==null?void 0:B.toUpperCase())||"?"})}),e.jsx("span",{children:n.author})]}),e.jsx("span",{children:"•"}),e.jsx(Q,{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(O,{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,b=we[s.priority],w=b.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:()=>N==null?void 0:N(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",b.className),children:[w&&e.jsx(w,{className:"h-3 w-3 mr-1"}),b.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(X,{className:"h-4 w-4",children:e.jsx(Z,{className:"text-[8px]",children:((D=s.requestedBy[0])==null?void 0:D.toUpperCase())||"?"})}),e.jsx("span",{children:s.requestedBy})]}),e.jsx("span",{children:"•"}),e.jsx(Q,{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(O,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},s.id)})})})]})}function et({nestId:c,enabled:x,reviewQueue:h,reviewableQueue:r,myPendingSubmissions:j,pendingDeletions:p,canManage:N,loading:T,onRefresh:v,onOpenDocument:u,onSelectRequest:F,onResolveDeletion:g,onWithdrawSubmission:M}){var Y,G,J;const a=de(),[s,b]=z.useState("all"),w=pe(c,x),[B,D]=z.useState([]),[n,K]=z.useState(!1),U=(((Y=w.data)==null?void 0:Y.items)??[]).filter(t=>t.type==="comment"),I=(()=>{const t=new Set(U.map(o=>o.id));return[...U,...B.filter(o=>!t.has(o.id))]})(),_=((J=(G=w.data)==null?void 0:G.counts)==null?void 0:J.comments)??U.length,ne=async()=>{K(!0);try{const o=(await a.fetchQuery(me.feed(c,"comments",ue,I.length))).items.filter(l=>l.type==="comment");D(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{K(!1)}},[i,k]=z.useState(new Set),[m,L]=z.useState(null),ie=async(t,o)=>{const l=[...i],{succeeded:C,failed:y,results:V}=await xe(c,t,l,o||void 0),H=t==="approve"?"approved":"rejected";if(y===0)P.success(`${C} document${C===1?"":"s"} ${H}`),k(new Set);else{const oe=[...new Set(V.filter(f=>!f.ok).map(f=>f.error||"Unknown reason"))];P.warning(`${C} ${H}, ${y} could not be`,{description:oe.join(" "),duration:1e4}),k(new Set(V.filter(f=>!f.ok).map(f=>f.nodeId)))}L(null),a.invalidateQueries({queryKey:he.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:()=>b(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"&&j.length>0&&e.jsxs($,{children:[e.jsxs(A,{className:"pb-3",children:[e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4 text-blue-600"}),"Submitted by you — awaiting review"]}),e.jsx(W,{children:"Your edits are awaiting review by another user. You can't approve your own work due to separation of duties."})]}),e.jsx(S,{className:"space-y-2",children:j.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:()=>M(t.nodeId),children:"Withdraw"})]},t.id))})]}),N&&p.length>0&&e.jsxs($,{children:[e.jsxs(A,{className:"pb-3",children:[e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4 text-destructive"}),"Deletion requests"]}),e.jsx(W,{children:"Documents flagged as stale. Delete them, or reject with a note."})]}),e.jsx(S,{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:()=>L("approve"),"data-testid":"bulk-approve",children:["Approve ",i.size]}),e.jsxs(d,{size:"sm",variant:"outline",disabled:i.size>q,onClick:()=>L("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:I,onSelectComment:t=>u(t.nodeId,{thread:t.threadId}),loading:T,onRefresh:v,onSelect:F}),s!=="changes"&&I.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 (",_-I.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(ye,{open:!0,onOpenChange:t=>!t&&L(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{et as ReviewTab};
@@ -1 +0,0 @@
1
- import{r as w,j as e,L as S,s as j,bs as f,B as m,cc as k,cd as T,e as B,ah as F,ai as I,ak as U,am as L,ag as V,aa as P,F as H,S as W,i as q}from"./index-B5hLclEq.js";import{U as b}from"./user-plus-4CTYEkd3.js";import{E as M}from"./MarkdownEditor-Dfk5uIE5.js";import{T as Q}from"./trash-2-B4hRXo-p.js";import{T as $}from"./tag-Br_y1f00.js";import{S as G,a as J,b as K,c as O,d as g}from"./select-DrL0mpRN.js";import"./scroll-area-CbcH6yrZ.js";import{C as E,a as D,c as A,d as R,b as X}from"./card-UDyMRcps.js";import"./zap-BcsKR0ef.js";import"./triangle-alert-CsYGyfGZ.js";import"./index-A0_ymcqL.js";import"./arrow-left-BAgIocLn.js";import"./x-qxt1WrUi.js";const Y={document:{label:"Document",icon:H},tag:{label:"Tag",icon:$},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]=w.useState(null),v=(x||"").toLowerCase(),p=async s=>{if(c){d(s);try{await c(s)}finally{d(null)}}},a=s=>{const C=Y[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(b,{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(b,{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(M,{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(Q,{className:"h-4 w-4 mr-2"}),"Remove"]})]})]})]},s.id)),r&&e.jsxs(m,{variant:"outline",className:"w-full",onClick:r,children:[e.jsx(b,{className:"h-4 w-4 mr-2"}),"Add Steward"]})]})}function xe({nestId:t,canManage:n,currentUserEmail:N,onAssign:l,onRemove:r,onEditRole:c}){var p;const i=W(q.stewards(t)),o=((p=i.data)==null?void 0:p.stewards)??[],[x,h]=w.useState("all"),[d,v]=w.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(X,{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(G,{value:d,onValueChange:a=>v(a),children:[e.jsx(J,{className:"w-[120px] h-7 text-xs",children:e.jsx(K,{})}),e.jsxs(O,{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{xe as StewardsTab};
@@ -1 +0,0 @@
1
- import{r,j as e,D as S,x as y,y as f,z as C,G as N,A as D,K as A,a as F,J as u,H as P,B as j,L as E}from"./index-B5hLclEq.js";import{T as L}from"./scroll-area-CbcH6yrZ.js";import{S as H,a as I,b as R,c as T,d as i}from"./select-DrL0mpRN.js";import{S as k}from"./send-CvAgOUPG.js";function G({isOpen:g,onClose:v,documentTitle:o,currentVersion:l,onSubmit:b}){const[c,d]=r.useState(""),[h,m]=r.useState("normal"),[s,p]=r.useState(!1),[x,t]=r.useState(null),w=async()=>{p(!0),t(null);try{await b(c,h),n()}catch(a){t(a instanceof Error?a.message:"Failed to submit for review")}finally{p(!1)}},n=()=>{s||(d(""),m("normal"),t(null),v())};return e.jsx(S,{open:g,onOpenChange:n,children:e.jsxs(y,{className:"sm:max-w-[425px]",children:[e.jsxs(f,{children:[e.jsx(C,{children:l==null?`Publish ${o} (requires approval)`:`Publish “${o}” (requires approval)`}),e.jsx(N,{children:l==null?e.jsxs(e.Fragment,{children:["Publishing in this nest goes through stewardship. Each selected draft moves to ",e.jsx("strong",{children:"pending review"}),"; once a steward approves one, that version becomes the AI-readable copy."]}):e.jsxs(e.Fragment,{children:["Publishing in this nest goes through stewardship. Version"," ",l," will move to ",e.jsx("strong",{children:"pending review"}),"; once a steward approves it, this version becomes the AI-readable copy."]})})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[x&&e.jsxs(D,{variant:"destructive",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx(F,{children:x})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"priority",children:"Priority"}),e.jsxs(H,{value:h,onValueChange:a=>m(a),disabled:s,children:[e.jsx(I,{id:"priority",children:e.jsx(R,{placeholder:"Select priority"})}),e.jsxs(T,{children:[e.jsx(i,{value:"low",children:"Low"}),e.jsx(i,{value:"normal",children:"Normal"}),e.jsx(i,{value:"high",children:"High"}),e.jsx(i,{value:"urgent",children:"Urgent"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"note",children:"Note for Reviewer (optional)"}),e.jsx(L,{id:"note",placeholder:"Add context or specific areas to review...",value:c,onChange:a=>d(a.target.value),disabled:s,className:"min-h-[100px]"})]})]}),e.jsxs(P,{children:[e.jsx(j,{variant:"outline",onClick:n,disabled:s,children:"Cancel"}),e.jsxs(j,{onClick:w,disabled:s,children:[s?e.jsx(E,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(k,{className:"h-4 w-4 mr-2"}),"Submit for approval"]})]})]})})}export{G as S};