convex-cms 0.0.9-alpha.8 → 0.0.10

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 (136) hide show
  1. package/README.md +27 -0
  2. package/admin/src/components/Header.tsx +1 -1
  3. package/admin/src/components/RouteGuard.tsx +1 -1
  4. package/admin/src/components/UploadDropzone.tsx +1 -1
  5. package/admin/src/components/cmsds/CmsFilterBar.tsx +74 -0
  6. package/admin/src/components/cmsds/CmsInput.tsx +24 -0
  7. package/admin/src/components/cmsds/CmsPagination.tsx +79 -0
  8. package/admin/src/components/cmsds/CmsSelect.tsx +59 -0
  9. package/admin/src/components/cmsds/CmsStatCard.tsx +79 -0
  10. package/admin/src/components/cmsds/CmsStatusBadge.tsx +1 -1
  11. package/admin/src/components/cmsds/index.ts +5 -0
  12. package/admin/src/components/ui/sidebar.tsx +1 -1
  13. package/admin/src/contexts/AuthContext.tsx +1 -1
  14. package/admin/src/contexts/ThemeContext.tsx +85 -17
  15. package/admin/src/embed/components/EmbedHeader.tsx +11 -9
  16. package/admin/src/embed/components/EmbedLayout.tsx +2 -6
  17. package/admin/src/embed/components/EmbedSidebar.tsx +16 -13
  18. package/admin/src/embed/contexts/ApiContext.tsx +1 -1
  19. package/admin/src/embed/index.tsx +3 -2
  20. package/admin/src/embed/types.ts +6 -0
  21. package/admin/src/hooks/usePermissions.ts +1 -1
  22. package/admin/src/index.css +432 -0
  23. package/admin/src/lib/cmsExports.ts +6 -0
  24. package/admin/src/pages/ContentPage.tsx +116 -172
  25. package/admin/src/pages/ContentTypeEntriesPage.tsx +120 -194
  26. package/admin/src/pages/ContentTypesPage.tsx +136 -139
  27. package/admin/src/pages/DashboardPage.tsx +15 -55
  28. package/admin/src/pages/MediaPage.tsx +31 -57
  29. package/admin/src/pages/SettingsPage.tsx +5 -1
  30. package/admin/src/pages/TrashPage.tsx +115 -170
  31. package/admin/src/routes/__root.tsx +1 -1
  32. package/admin-dist/nitro.json +1 -1
  33. package/admin-dist/public/assets/{CmsEmptyState-DTlpzjOI.js → CmsEmptyState-BKeL4DBB.js} +1 -1
  34. package/admin-dist/public/assets/CmsFilterBar-CEpMHd_c.js +1 -0
  35. package/admin-dist/public/assets/{CmsPageHeader-0REGRH4X.js → CmsPageHeader-CIEkTbyH.js} +1 -1
  36. package/admin-dist/public/assets/{CmsStatusBadge-D_n8u8xa.js → CmsStatusBadge-BFMOsfMW.js} +1 -1
  37. package/admin-dist/public/assets/{CmsSurface-BHmvNai4.js → CmsSurface-kqqaFKUI.js} +1 -1
  38. package/admin-dist/public/assets/CmsTable-Db53Exq0.js +1 -0
  39. package/admin-dist/public/assets/ContentEntryEditor-Ct7cHayy.js +4 -0
  40. package/admin-dist/public/assets/TaxonomyFilter-Bm1DI1A7.js +1 -0
  41. package/admin-dist/public/assets/_contentTypeId-BekeCblX.js +1 -0
  42. package/admin-dist/public/assets/{_entryId-jPXz4z9T.js → _entryId-CoZDE0l0.js} +1 -1
  43. package/admin-dist/public/assets/{alert-CG97cMfC.js → alert-CpLdsTGU.js} +1 -1
  44. package/admin-dist/public/assets/{badge-C6qt24oj.js → badge-BQAotc5B.js} +1 -1
  45. package/admin-dist/public/assets/{circle-check-big-PltpxuB1.js → circle-check-big-BF3Y5nES.js} +1 -1
  46. package/admin-dist/public/assets/{command-CJ8i86fd.js → command-lEq6f_Ee.js} +1 -1
  47. package/admin-dist/public/assets/content-DH6k0dN6.js +1 -0
  48. package/admin-dist/public/assets/content-types-DHr9tc2V.js +1 -0
  49. package/admin-dist/public/assets/index-Cf0lbl0G.js +1 -0
  50. package/admin-dist/public/assets/index-D-4wFfgU.css +1 -0
  51. package/admin-dist/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  52. package/admin-dist/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  53. package/admin-dist/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  54. package/admin-dist/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  55. package/admin-dist/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  56. package/admin-dist/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  57. package/admin-dist/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  58. package/admin-dist/public/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  59. package/admin-dist/public/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  60. package/admin-dist/public/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  61. package/admin-dist/public/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  62. package/admin-dist/public/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  63. package/admin-dist/public/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  64. package/admin-dist/public/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  65. package/admin-dist/public/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  66. package/admin-dist/public/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  67. package/admin-dist/public/assets/main-B-6700eG.js +137 -0
  68. package/admin-dist/public/assets/media-DY5zD52L.js +1 -0
  69. package/admin-dist/public/assets/{new._contentTypeId-qsvo01mH.js → new._contentTypeId-Dq_NqTQV.js} +1 -1
  70. package/admin-dist/public/assets/{pencil-gAL0R34f.js → pencil-CI_KfxSx.js} +1 -1
  71. package/admin-dist/public/assets/refresh-cw-BrXg9a2r.js +1 -0
  72. package/admin-dist/public/assets/rotate-ccw-PwzxdPxd.js +1 -0
  73. package/admin-dist/public/assets/{scroll-area-CJBhf9pf.js → scroll-area-DX_nZYp8.js} +1 -1
  74. package/admin-dist/public/assets/{search-WXp6KxDJ.js → search-DlwBH4C5.js} +1 -1
  75. package/admin-dist/public/assets/settings-2mx3_ORG.js +1 -0
  76. package/admin-dist/public/assets/{switch-Ck9ecqEX.js → switch-CjPi4DKH.js} +1 -1
  77. package/admin-dist/public/assets/{tabs-vQYu8rjC.js → tabs-B5X37GEM.js} +1 -1
  78. package/admin-dist/public/assets/tanstack-adapter-KSm-nO5L.js +1 -0
  79. package/admin-dist/public/assets/{taxonomies-DvILUNvr.js → taxonomies-CHjJKNlR.js} +1 -1
  80. package/admin-dist/public/assets/trash-Cle-tcqq.js +1 -0
  81. package/admin-dist/public/assets/{useBreadcrumbLabel-tlSh7dtO.js → useBreadcrumbLabel-yZQG_N_3.js} +1 -1
  82. package/admin-dist/public/assets/{usePermissions-BTGdTOJS.js → usePermissions-D6vsoaJf.js} +1 -1
  83. package/admin-dist/server/_libs/convex-helpers.mjs +1077 -2
  84. package/admin-dist/server/_libs/convex.mjs +222 -13
  85. package/admin-dist/server/_libs/lucide-react.mjs +57 -51
  86. package/admin-dist/server/_ssr/{CmsEmptyState-CB6e53i5.mjs → CmsEmptyState-DzzuQG0S.mjs} +1 -1
  87. package/admin-dist/server/_ssr/CmsFilterBar-C5XADS12.mjs +81 -0
  88. package/admin-dist/server/_ssr/{CmsPageHeader-COUHuECp.mjs → CmsPageHeader-DZ6h7smh.mjs} +1 -1
  89. package/admin-dist/server/_ssr/{CmsStatusBadge-kMTL6koE.mjs → CmsStatusBadge-D-YFSAa1.mjs} +3 -3
  90. package/admin-dist/server/_ssr/{CmsSurface-D1HDYjRg.mjs → CmsSurface-Cv51NBLZ.mjs} +1 -1
  91. package/admin-dist/server/_ssr/CmsTable-DG88C5nO.mjs +189 -0
  92. package/admin-dist/server/_ssr/{ContentEntryEditor-Bq8FR_uK.mjs → ContentEntryEditor-CRjwXB17.mjs} +10 -10
  93. package/admin-dist/server/_ssr/{TaxonomyFilter-bm_p4ADg.mjs → TaxonomyFilter-xGwcgtjr.mjs} +3 -3
  94. package/admin-dist/server/_ssr/{_contentTypeId-B7obLmi_.mjs → _contentTypeId-DRCfeKkm.mjs} +53 -12
  95. package/admin-dist/server/_ssr/{_entryId-B4zhQqFg.mjs → _entryId-DULm2TDy.mjs} +11 -11
  96. package/admin-dist/server/_ssr/_tanstack-start-manifest_v-iX3K33p1.mjs +4 -0
  97. package/admin-dist/server/_ssr/{badge-NOEC9bkk.mjs → badge-CbjIvhb6.mjs} +1 -1
  98. package/admin-dist/server/_ssr/{command-h4-OYNBo.mjs → command-xB2uiYps.mjs} +2 -2
  99. package/admin-dist/server/_ssr/{content-CShtLuhK.mjs → content-BfLBaJCZ.mjs} +108 -138
  100. package/admin-dist/server/_ssr/{content-types-PeyRyfbc.mjs → content-types-DZbF6O2q.mjs} +130 -119
  101. package/admin-dist/server/_ssr/{index-CplFXpGg.mjs → index-Cfe8sZv5.mjs} +65 -39
  102. package/admin-dist/server/_ssr/index.mjs +2 -2
  103. package/admin-dist/server/_ssr/{media-QAkNdX54.mjs → media-Bds2AnPC.mjs} +36 -56
  104. package/admin-dist/server/_ssr/{new._contentTypeId-DEJyMphJ.mjs → new._contentTypeId-DGvz_tlW.mjs} +10 -10
  105. package/admin-dist/server/_ssr/{router-CQXMuGMF.mjs → router-DxF7GBcO.mjs} +8804 -4995
  106. package/admin-dist/server/_ssr/{scroll-area-B7zoNyWB.mjs → scroll-area-DLDlXI07.mjs} +1 -1
  107. package/admin-dist/server/_ssr/{settings-CNaqVa4D.mjs → settings-BbaiS6z9.mjs} +13 -10
  108. package/admin-dist/server/_ssr/{switch-BKZhvryc.mjs → switch-Bl89Pfxu.mjs} +1 -1
  109. package/admin-dist/server/_ssr/{tabs-DtIIQxiD.mjs → tabs-QkbR0iir.mjs} +3 -3
  110. package/admin-dist/server/_ssr/{tanstack-adapter-CLavdbUY.mjs → tanstack-adapter-CKknPtcU.mjs} +19 -1
  111. package/admin-dist/server/_ssr/{taxonomies-vIZYICzr.mjs → taxonomies-S_Ontd0z.mjs} +9 -9
  112. package/admin-dist/server/_ssr/{trash-7yGR4-dF.mjs → trash-BzAIsbbN.mjs} +109 -132
  113. package/admin-dist/server/_ssr/{useBreadcrumbLabel-DR5FaAMf.mjs → useBreadcrumbLabel-BjiR1fM_.mjs} +1 -1
  114. package/admin-dist/server/_ssr/{usePermissions-DKkpETj_.mjs → usePermissions-CDHN95Nz.mjs} +1 -1
  115. package/admin-dist/server/index.mjs +284 -165
  116. package/package.json +3 -2
  117. package/admin/src/styles/globals.css +0 -104
  118. package/admin/src/styles/tailwind-config.css +0 -99
  119. package/admin/src/styles/theme.css +0 -261
  120. package/admin-dist/public/assets/CmsToolbar-CY6GV2L8.js +0 -1
  121. package/admin-dist/public/assets/ContentEntryEditor-CRgcRkk5.js +0 -4
  122. package/admin-dist/public/assets/TaxonomyFilter-Ohv5Jg9c.js +0 -1
  123. package/admin-dist/public/assets/_contentTypeId-C_vJq22X.js +0 -1
  124. package/admin-dist/public/assets/content-pKaIL2ru.js +0 -1
  125. package/admin-dist/public/assets/content-types-Bl_8I1Re.js +0 -1
  126. package/admin-dist/public/assets/globals-CoCRjt0K.css +0 -1
  127. package/admin-dist/public/assets/index-CtHq_P5q.js +0 -1
  128. package/admin-dist/public/assets/main-CA-4LyFT.js +0 -107
  129. package/admin-dist/public/assets/media-Bl1tBbJQ.js +0 -1
  130. package/admin-dist/public/assets/refresh-cw-sdVUGJNs.js +0 -1
  131. package/admin-dist/public/assets/rotate-ccw-6OcXCcxb.js +0 -1
  132. package/admin-dist/public/assets/settings-D8crrFCn.js +0 -1
  133. package/admin-dist/public/assets/tanstack-adapter-BRt2CUCw.js +0 -1
  134. package/admin-dist/public/assets/trash-YyYaC3L9.js +0 -1
  135. package/admin-dist/server/_ssr/CmsToolbar-NB014hsd.mjs +0 -48
  136. package/admin-dist/server/_ssr/_tanstack-start-manifest_v-DndoqCo7.mjs +0 -4
@@ -0,0 +1 @@
1
+ import{e as ee,j as e,L as Xe,n as P,r as a,z as As,D as ve,A as be,B as ye,C as h,T as K,X as ce,m as es,F as ss,E as oe,f as de,u as A,a as E,o as Es,G as Ps,I as G,H as Qe,P as Bs,g as ze,h as ts,J as as,K as is,M as ls,N as H,O as Is,Q as Ne,U as Rs,V as rs,W as Ce,i as Ye,Y as Ge,Z as Ze,c as ge,_ as Ls,d as Us}from"./main-B-6700eG.js";import{u as $s}from"./tanstack-adapter-KSm-nO5L.js";import{C as ns,F as os,M as cs,V as ds,T as Vs,a as Hs,b as Je,U as qs,c as Ws}from"./tabs-B5X37GEM.js";import{B as us}from"./badge-BQAotc5B.js";import{C as je}from"./CmsEmptyState-BKeL4DBB.js";import{C as Os}from"./CmsPageHeader-CIEkTbyH.js";import{C as Ks}from"./CmsFilterBar-CEpMHd_c.js";import{T as Qs}from"./TaxonomyFilter-Bm1DI1A7.js";import{P as Fe}from"./pencil-CI_KfxSx.js";import{R as ke}from"./rotate-ccw-PwzxdPxd.js";import{S as Ys}from"./search-DlwBH4C5.js";import"./refresh-cw-BrXg9a2r.js";import"./command-lEq6f_Ee.js";const Gs=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Zs=ee("copy",Gs);const Js=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],we=ee("download",Js);const Xs=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],et=ee("ellipsis-vertical",Xs);const st=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],tt=ee("ellipsis",st);const at=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],Se=ee("folder-input",at);const it=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],lt=ee("folder-plus",it);function Y({label:s,description:l,error:i,required:r,htmlFor:u,className:m,children:g}){return e.jsxs("div",{className:P("space-y-2",m),children:[s&&e.jsxs(Xe,{htmlFor:u,className:P("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",i&&"text-destructive"),children:[s,r&&e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),g,l&&!i&&e.jsx("p",{className:"text-[13px] text-muted-foreground",children:l}),i&&e.jsx("p",{className:"text-[13px] font-medium text-destructive",children:i})]})}var rt=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),nt="VisuallyHidden",ms=a.forwardRef((s,l)=>e.jsx(As.span,{...s,ref:l,style:{...rt,...s.style}}));ms.displayName=nt;function ot(s){return s?s.startsWith("image/")?"image":s.startsWith("video/")?"video":s.startsWith("audio/")?"audio":s==="application/pdf"||s.includes("document")||s.includes("sheet")||s.includes("presentation")||s.startsWith("text/")?"document":"other":"other"}function ct(s){if(!s||s===0)return"0 B";const l=1024,i=["B","KB","MB","GB"],r=Math.floor(Math.log(s)/Math.log(l));return`${parseFloat((s/Math.pow(l,r)).toFixed(1))} ${i[r]}`}function dt(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function ut(s,l="size-16"){const i={className:l};switch(s){case"image":return e.jsx(oe,{...i});case"video":return e.jsx(ds,{...i});case"audio":return e.jsx(cs,{...i});case"document":return e.jsx(ss,{...i});default:return e.jsx(os,{...i})}}function mt({asset:s,assets:l,currentIndex:i,open:r,onOpenChange:u,onNavigate:m,onEdit:g,onDelete:d}){const F=i>0,p=i<l.length-1,y=a.useCallback(()=>{F&&m(i-1)},[F,i,m]),o=a.useCallback(()=>{p&&m(i+1)},[p,i,m]),x=a.useCallback(c=>{if(r)switch(c.key){case"ArrowLeft":c.preventDefault(),y();break;case"ArrowRight":c.preventDefault(),o();break;case"Escape":c.preventDefault(),u(!1);break}},[r,y,o,u]);a.useEffect(()=>(window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)),[x]);const v=a.useCallback(()=>{if(!s?.url)return;const c=document.createElement("a");c.href=s.url,c.download=s.name,c.target="_blank",document.body.appendChild(c),c.click(),document.body.removeChild(c)},[s]),k=a.useCallback(async()=>{s?.url&&await navigator.clipboard.writeText(s.url)},[s]);if(!s)return null;const b=ot(s.mimeType),S=b==="image",D=!!s.url;return e.jsx(ve,{open:r,onOpenChange:u,children:e.jsxs(be,{className:"flex h-[90vh] w-[95vw] max-w-[1400px] flex-col gap-0 overflow-hidden p-0 sm:max-w-[1400px]",showCloseButton:!1,children:[e.jsx(ms,{children:e.jsxs(ye,{children:["Preview: ",s.name]})}),e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"truncate text-lg font-semibold",title:s.name,children:s.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[i+1," of ",l.length]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:k,disabled:!s.url,title:"Copy URL",children:e.jsx(Zs,{className:"size-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:v,disabled:!s.url,title:"Download",children:e.jsx(we,{className:"size-4"})}),g&&e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>g(s),title:"Edit",children:e.jsx(Fe,{className:"size-4"})}),d&&e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>d(s),title:"Delete",className:"text-destructive hover:text-destructive",children:e.jsx(K,{className:"size-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>u(!1),title:"Close (Esc)",children:e.jsx(ce,{className:"size-4"})})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsxs("div",{className:"relative flex flex-1 items-center justify-center bg-zinc-950",children:[F&&e.jsx("button",{onClick:y,className:"absolute left-4 z-10 flex size-10 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70",title:"Previous (←)",children:e.jsx(ns,{className:"size-6"})}),p&&e.jsx("button",{onClick:o,className:"absolute right-4 z-10 flex size-10 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70",title:"Next (→)",children:e.jsx(es,{className:"size-6"})}),S&&D?e.jsx("img",{src:s.url,alt:s.altText||s.title||s.name,className:"max-h-full max-w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-4 text-zinc-400",children:[ut(b),e.jsx("p",{className:"text-sm",children:S&&!D?"Image URL not available":"Preview not available for this file type"}),D&&e.jsxs(h,{variant:"secondary",onClick:v,children:[e.jsx(we,{className:"mr-2 size-4"}),"Download to view"]})]})]}),e.jsx("div",{className:"w-72 shrink-0 overflow-y-auto border-l bg-background",children:e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx("h3",{className:"font-semibold",children:"File Information"}),e.jsx(V,{label:"Filename",value:s.name}),s.title&&e.jsx(V,{label:"Title",value:s.title}),s.description&&e.jsx(V,{label:"Description",value:s.description}),s.altText&&e.jsx(V,{label:"Alt Text",value:s.altText}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx(V,{label:"Type",value:b,capitalize:!0}),s.mimeType&&e.jsx(V,{label:"MIME Type",value:s.mimeType}),e.jsx(V,{label:"Size",value:ct(s.size)}),s.width&&s.height&&e.jsx(V,{label:"Dimensions",value:`${s.width} × ${s.height} px`})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(V,{label:"Uploaded",value:dt(s._creationTime)})}),s.tags&&s.tags.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.tags.map(c=>e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs",children:c},c))})]})]})})]})]})})}function V({label:s,value:l,capitalize:i}){return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:s}),e.jsx("p",{className:P("break-words text-sm",i&&"capitalize"),children:l})]})}function xt({mediaId:s,taxonomyId:l,taxonomyName:i="Tags",allowCreate:r=!0,disabled:u=!1,className:m=""}){const g=de(),[d,F]=a.useState(""),[p,y]=a.useState(!1),[o,x]=a.useState(0),[v,k]=a.useState(!1),[b,S]=a.useState(!1),D=a.useRef(null),c=a.useRef(null),M=a.useRef(null),B=A(g.getTermsByMedia,{mediaId:s,taxonomyId:l}),N=B?.map(n=>n._id)??[],f=A(g.suggestTerms,{taxonomyId:l,query:d,limit:10,excludeIds:N})??[],I=E(g.setMediaTerms),q=E(g.createTermAndAddToMedia);a.useEffect(()=>{function n(C){M.current&&!M.current.contains(C.target)&&y(!1)}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]);const Q=a.useCallback(async n=>{if(!N.includes(n)){S(!0);try{await I({mediaId:s,taxonomyId:l,termIds:[...N,n]})}catch(C){console.error("Failed to add tag:",C)}finally{S(!1),F(""),y(!1),x(0),D.current?.focus()}}},[s,l,N,I]),se=a.useCallback(async n=>{S(!0);try{await I({mediaId:s,taxonomyId:l,termIds:N.filter(C=>C!==n)})}catch(C){console.error("Failed to remove tag:",C)}finally{S(!1)}},[s,l,N,I]),Z=a.useCallback(async()=>{if(!(!d.trim()||!r)){k(!0);try{await q({taxonomyId:l,name:d.trim(),mediaId:s}),F(""),y(!1),x(0)}catch(n){console.error("Failed to create tag:",n)}finally{k(!1)}}},[d,r,l,s,q]),te=n=>{if(!u)switch(n.key){case"ArrowDown":n.preventDefault(),x(C=>C<f.length-1?C+1:C);break;case"ArrowUp":n.preventDefault(),x(C=>C>0?C-1:0);break;case"Enter":n.preventDefault(),f.length>0&&o<f.length?Q(f[o]._id):d.trim()&&r&&Z();break;case"Escape":y(!1);break;case"Backspace":d===""&&N.length>0&&se(N[N.length-1]);break}};a.useEffect(()=>{if(c.current&&p){const n=c.current.querySelector(`[data-index="${o}"]`);n&&n.scrollIntoView({block:"nearest"})}},[o,p]);const $=f.filter(n=>!N.includes(n._id)),T=r&&d.trim()&&!$.some(n=>n.name.toLowerCase()===d.trim().toLowerCase());return e.jsxs("div",{className:P("space-y-2",m),children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(Es,{className:"size-4"}),i]}),e.jsxs("div",{ref:M,className:P("relative rounded-md border border-input bg-background",u&&"opacity-50"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 p-2",children:[(B??[]).map(n=>e.jsxs(us,{variant:"secondary",className:"gap-1 pr-1",style:n.color?{backgroundColor:n.color,color:"#fff"}:void 0,children:[n.name,!u&&e.jsx(Ps,{type:"button",variant:"ghost",size:"icon",className:"size-4 hover:bg-transparent",onClick:()=>se(n._id),disabled:b,"aria-label":`Remove ${n.name}`,children:e.jsx(ce,{className:"size-3"})})]},n._id)),!u&&e.jsx(G,{ref:D,type:"text",className:"h-7 min-w-[120px] flex-1 border-0 bg-transparent px-1 shadow-none focus-visible:ring-0",value:d,onChange:n=>{F(n.target.value),y(!0),x(0)},onFocus:()=>y(!0),onKeyDown:te,placeholder:N.length===0?"Add tags...":"",disabled:u||v||b})]}),p&&($.length>0||T)&&e.jsxs("div",{ref:c,className:"absolute left-0 right-0 top-full z-50 mt-1 max-h-48 overflow-auto rounded-md border bg-popover shadow-lg",role:"listbox",children:[$.map((n,C)=>e.jsxs("div",{"data-index":C,className:P("flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",C===o&&"bg-accent"),onClick:()=>Q(n._id),role:"option","aria-selected":C===o,children:[n.color&&e.jsx("span",{className:"size-2.5 rounded-full",style:{backgroundColor:n.color}}),e.jsx("span",{className:"flex-1",children:n.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.usageCount," uses"]})]},n._id)),T&&e.jsxs("div",{"data-index":$.length,className:P("flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",$.length===o&&"bg-accent"),onClick:Z,role:"option","aria-selected":$.length===o,children:[v?e.jsx(Qe,{className:"size-4 animate-spin"}):e.jsx(Bs,{className:"size-4"}),e.jsxs("span",{children:['Create "',d.trim(),'"']})]})]}),(b||v)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50",children:e.jsx(Qe,{className:"size-4 animate-spin"})})]})]})}function ht({asset:s,open:l,onOpenChange:i,onSaved:r}){const u=de(),[m,g]=a.useState(""),[d,F]=a.useState(""),[p,y]=a.useState(""),[o,x]=a.useState(""),[v,k]=a.useState(""),[b,S]=a.useState(!1),[D,c]=a.useState(""),M=E(u.updateMediaAsset),N=A(u.listTaxonomies,{isActive:!0,paginationOpts:{numItems:50,cursor:null}})?.page??[];a.useEffect(()=>{s&&(g(s.name),F(s.title||""),y(s.description||""),x(s.altText||""),k(s.tags?.join(", ")||""),c(""))},[s]);const L=a.useCallback(async()=>{if(s){if(!m.trim()){c("Filename is required");return}S(!0),c("");try{const f=v.split(",").map(I=>I.trim()).filter(Boolean);await M({id:s._id,name:m.trim(),title:d.trim()||void 0,description:p.trim()||void 0,altText:o.trim()||void 0,tags:f.length>0?f:void 0}),r?.(),i(!1)}catch(f){c(f instanceof Error?f.message:"Failed to update asset")}finally{S(!1)}}},[s,m,d,p,o,v,M,r,i]);return s?e.jsx(ze,{open:l,onOpenChange:i,title:"Edit File",size:"md",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",onClick:()=>i(!1),disabled:b,children:"Cancel"}),e.jsx(h,{onClick:L,loading:b,children:"Save Changes"})]}),children:e.jsxs("div",{className:"space-y-4",children:[D&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:D}),e.jsx(Y,{label:"Filename",required:!0,htmlFor:"asset-name",children:e.jsx(G,{id:"asset-name",value:m,onChange:f=>g(f.target.value),placeholder:"Enter filename"})}),e.jsx(Y,{label:"Title",description:"A human-readable title for the file",htmlFor:"asset-title",children:e.jsx(G,{id:"asset-title",value:d,onChange:f=>F(f.target.value),placeholder:"Enter title (optional)"})}),e.jsx(Y,{label:"Description",description:"A brief description of the file",htmlFor:"asset-description",children:e.jsx(ts,{id:"asset-description",value:p,onChange:f=>y(f.target.value),placeholder:"Enter description (optional)",rows:3})}),e.jsx(Y,{label:"Alt Text",description:"Alternative text for accessibility (important for images)",htmlFor:"asset-alt",children:e.jsx(G,{id:"asset-alt",value:o,onChange:f=>x(f.target.value),placeholder:"Describe the image content"})}),e.jsx(Y,{label:"Quick Tags",description:"Comma-separated tags for simple organization",htmlFor:"asset-tags",children:e.jsx(G,{id:"asset-tags",value:v,onChange:f=>k(f.target.value),placeholder:"e.g., hero, blog, product"})}),N.length>0&&s&&e.jsxs("div",{className:"space-y-4 pt-2 border-t",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Organize with taxonomy terms"}),N.map(f=>e.jsx(xt,{mediaId:s._id,taxonomyId:f._id,taxonomyName:f.displayName,allowCreate:f.allowInlineCreation,disabled:b},f._id))]})]})}):null}function ft({folder:s,open:l,onOpenChange:i,onSaved:r}){const u=de(),[m,g]=a.useState(""),[d,F]=a.useState(""),[p,y]=a.useState(!1),[o,x]=a.useState(""),v=E(u.updateMediaFolder);a.useEffect(()=>{s&&(g(s.name),F(s.description||""),x(""))},[s]);const k=a.useCallback(async()=>{if(s){if(!m.trim()){x("Folder name is required");return}y(!0),x("");try{await v({id:s._id,name:m.trim(),description:d.trim()||void 0}),r?.(),i(!1)}catch(b){x(b instanceof Error?b.message:"Failed to update folder")}finally{y(!1)}}},[s,m,d,v,r,i]);return s?e.jsx(ze,{open:l,onOpenChange:i,title:"Edit Folder",size:"sm",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",onClick:()=>i(!1),disabled:p,children:"Cancel"}),e.jsx(h,{onClick:k,loading:p,children:"Save Changes"})]}),children:e.jsxs("div",{className:"space-y-4",children:[o&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:o}),e.jsx(Y,{label:"Folder Name",required:!0,htmlFor:"folder-name",children:e.jsx(G,{id:"folder-name",value:m,onChange:b=>g(b.target.value),placeholder:"Enter folder name"})}),e.jsx(Y,{label:"Description",description:"A brief description of the folder contents",htmlFor:"folder-description",children:e.jsx(ts,{id:"folder-description",value:d,onChange:b=>F(b.target.value),placeholder:"Enter description (optional)",rows:3})})]})}):null}function pt({asset:s,onView:l,onEdit:i,onMove:r,onDelete:u}){const m=()=>{if(!s.url)return;const d=document.createElement("a");d.href=s.url,d.download=s.name,d.target="_blank",document.body.appendChild(d),d.click(),document.body.removeChild(d)},g=async()=>{s.url&&await navigator.clipboard.writeText(s.url)};return e.jsxs(as,{children:[e.jsx(is,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon-sm",className:"opacity-0 group-hover:opacity-100",onClick:d=>d.stopPropagation(),children:e.jsx(et,{className:"size-4"})})}),e.jsxs(ls,{side:"bottom",onClick:d=>d.stopPropagation(),children:[l&&e.jsxs(H,{onClick:l,children:[e.jsx(Is,{className:"mr-2 size-4"}),"View Details"]}),i&&e.jsxs(H,{onClick:i,children:[e.jsx(Fe,{className:"mr-2 size-4"}),"Edit"]}),r&&e.jsxs(H,{onClick:r,children:[e.jsx(Se,{className:"mr-2 size-4"}),"Move to..."]}),e.jsx(Ne,{}),e.jsxs(H,{onClick:m,disabled:!s.url,children:[e.jsx(we,{className:"mr-2 size-4"}),"Download"]}),e.jsxs(H,{onClick:g,disabled:!s.url,children:[e.jsx(Rs,{className:"mr-2 size-4"}),"Copy URL"]}),u&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{}),e.jsxs(H,{onClick:u,className:"text-destructive focus:text-destructive",children:[e.jsx(K,{className:"mr-2 size-4"}),"Delete"]})]})]})]})}function gt({folder:s,onEdit:l,onMove:i,onDelete:r}){return e.jsxs(as,{children:[e.jsx(is,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon-sm",className:"opacity-0 group-hover:opacity-100",onClick:u=>u.stopPropagation(),children:e.jsx(tt,{className:"size-4"})})}),e.jsxs(ls,{align:"end",onClick:u=>u.stopPropagation(),children:[l&&e.jsxs(H,{onClick:l,children:[e.jsx(Fe,{className:"mr-2 size-4"}),"Rename"]}),i&&e.jsxs(H,{onClick:i,children:[e.jsx(Se,{className:"mr-2 size-4"}),"Move to..."]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{}),e.jsxs(H,{onClick:r,className:"text-destructive focus:text-destructive",children:[e.jsx(K,{className:"mr-2 size-4"}),"Delete"]})]})]})]})}function jt({selectedCount:s,onClear:l,onMove:i,onDelete:r,isDeleting:u}){return s===0?null:e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between px-6 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s," ",s===1?"file":"files"," selected"]}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:l,children:[e.jsx(ce,{className:"mr-1 size-4"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"secondary",onClick:i,disabled:u,children:[e.jsx(Se,{className:"mr-2 size-4"}),"Move to..."]}),e.jsxs(h,{variant:"danger",onClick:r,loading:u,children:[e.jsx(K,{className:"mr-2 size-4"}),"Delete"]})]})]})})}function vt({selectedCount:s,onClear:l,onRestore:i,onPermanentDelete:r,isRestoring:u,isDeleting:m}){return s===0?null:e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between px-6 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s," ",s===1?"file":"files"," selected"]}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:l,children:[e.jsx(ce,{className:"mr-1 size-4"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"secondary",onClick:i,loading:u,disabled:m,children:[e.jsx(ke,{className:"mr-2 size-4"}),"Restore"]}),e.jsxs(h,{variant:"danger",onClick:r,loading:m,disabled:u,children:[e.jsx(K,{className:"mr-2 size-4"}),"Delete Forever"]})]})]})})}function bt({open:s,onOpenChange:l,assetIds:i,currentFolderId:r,onMoved:u}){const m=de(),[g,d]=a.useState(void 0),[F,p]=a.useState(!1),[y,o]=a.useState(""),x=A(m.getMediaFolderTree,{}),v=E(m.moveMediaAssets),k=a.useMemo(()=>{if(!x)return[];const c=(M,B)=>x.filter(L=>L.parentId===M).flatMap(L=>[{...L,depth:B},...c(L._id,B+1)]);return c(void 0,0)},[x]),b=async()=>{if(i.length!==0){p(!0),o("");try{await v({assetIds:i,targetFolderId:g}),u?.(),l(!1)}catch(c){o(c instanceof Error?c.message:"Failed to move files")}finally{p(!1)}}},S=g===r,D=g===void 0;return e.jsx(ze,{open:s,onOpenChange:l,title:"Move Files",description:`Select a destination folder for ${i.length} ${i.length===1?"file":"files"}`,size:"sm",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",onClick:()=>l(!1),disabled:F,children:"Cancel"}),e.jsx(h,{onClick:b,loading:F,disabled:S,children:"Move Here"})]}),children:e.jsxs("div",{className:"space-y-2",children:[y&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:y}),e.jsxs("div",{className:"max-h-[300px] overflow-y-auto rounded-md border",children:[e.jsxs("button",{type:"button",className:P("flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-muted",D&&"bg-primary/10 text-primary",r===void 0&&"opacity-50"),onClick:()=>d(void 0),children:[e.jsx(rs,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:"Root (All Files)"}),r===void 0&&e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Current"})]}),k.map(c=>{const M=c._id===r,B=c._id===g;return e.jsxs("button",{type:"button",className:P("flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-muted",B&&"bg-primary/10 text-primary",M&&"opacity-50"),style:{paddingLeft:`${12+c.depth*20}px`},onClick:()=>d(c._id),children:[c.depth>0&&e.jsx(es,{className:"size-3 text-muted-foreground"}),e.jsx(Ce,{className:"size-4 text-amber-500"}),e.jsx("span",{className:"truncate",children:c.name}),M&&e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Current"})]},c._id)}),k.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"No folders yet. Create folders to organize your files."})]}),S&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Files are already in this folder"})]})})}function yt(s){if(s===0)return"0 B";const l=1024,i=["B","KB","MB","GB"],r=Math.floor(Math.log(s)/Math.log(l));return`${parseFloat((s/Math.pow(l,r)).toFixed(1))} ${i[r]}`}function Nt(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Ct(s,l="size-6"){const i={className:l};switch(s){case"image":return e.jsx(oe,{...i});case"video":return e.jsx(ds,{...i});case"audio":return e.jsx(cs,{...i});case"document":return e.jsx(ss,{...i});default:return e.jsx(os,{...i})}}function kt(s){return s?s.startsWith("image/")?"image":s.startsWith("video/")?"video":s.startsWith("audio/")?"audio":s==="application/pdf"||s.includes("document")||s.includes("sheet")||s.includes("presentation")||s.startsWith("text/")?"document":"other":"other"}function wt({api:s,navigation:l,settings:i}){a.useEffect(()=>{i&&!i.features.mediaManagement&&l.navigate("/")},[i,l]);const[r,u]=a.useState(void 0),[m,g]=a.useState(""),[d,F]=a.useState(""),[p,y]=a.useState([]),[o,x]=a.useState(new Set),[v,k]=a.useState(!1),[b,S]=a.useState(!1),[D,c]=a.useState(!1),[M,B]=a.useState(""),[N,L]=a.useState(!1),[f,I]=a.useState(""),[q,Q]=a.useState(null),[se,Z]=a.useState(null),[te,$]=a.useState(null),[T,n]=a.useState(null),[C,Me]=a.useState(!1),[xs,De]=a.useState(!1),[hs,ue]=a.useState(!1),[Te,_e]=a.useState(!1),[Ae,fs]=a.useState("library"),[Ee,J]=a.useState(!1),[Pe,Be]=a.useState(!1),[ps,ae]=a.useState(!1),[X,ie]=a.useState(null),w=Ae==="trash",_=A(s.listMediaAssets,{folderId:w?void 0:r,type:d||void 0,search:m||void 0,deletedOnly:w?!0:void 0,paginationOpts:{numItems:100,cursor:null}}),me=A(s.getMediaTrashCount,{}),Ie=A(s.getMediaByTerm,p[0]?{termId:p[0]}:"skip"),Re=A(s.getMediaByTerm,p[1]?{termId:p[1]}:"skip"),Le=A(s.getMediaByTerm,p[2]?{termId:p[2]}:"skip"),xe=a.useMemo(()=>{if(p.length===0)return null;const t=new Set,j=[Ie,Re,Le];for(let z=0;z<p.length&&z<3;z++){const O=j[z];if(O?.page)for(const U of O.page)t.add(U)}return t},[p,Ie,Re,Le]),R=A(s.listMediaFolders,{parentId:w?void 0:r,deletedOnly:w||void 0}),he=A(s.getMediaFolder,r?{id:r}:"skip"),le=A(s.getMediaFolderTree,{}),Ue=E(s.createMediaFolder),re=E(s.deleteMediaAsset),$e=E(s.deleteMediaFolder),ne=E(s.restoreMediaAsset),Ve=E(s.restoreMediaFolder),He=E(s.permanentDeleteMediaAsset),qe=E(s.bulkPermanentDeleteMediaAssets),We=a.useMemo(()=>{if(!r||!le)return[];const t=[];let j=le.find(z=>z._id===r);for(;j;){t.unshift(j);const z=j.parentId;j=z?le.find(O=>O._id===z):void 0}return t},[r,le]),Oe=a.useCallback(t=>{u(t),g("")},[]),gs=a.useCallback(()=>{he?.parentId?u(he.parentId):u(void 0)},[he]),js=a.useCallback(()=>{u(void 0),g("")},[]),fe=a.useCallback(t=>{x(j=>{const z=new Set(j);return z.has(t)?z.delete(t):z.add(t),z})},[]),vs=a.useCallback(()=>{_?.page&&x(new Set(_.page.map(t=>t._id)))},[_?.page]),pe=a.useCallback(()=>{x(new Set)},[]),bs=a.useCallback(t=>{fs(t),x(new Set),k(!1)},[]),ys=a.useCallback(t=>{if(v)fe(t);else{const j=_?.page?.findIndex(z=>z._id===t)??-1;j!==-1&&Q(j)}},[v,fe,_?.page]),Ns=a.useCallback(t=>{Q(t)},[]),Cs=a.useCallback(async()=>{if(T){Me(!0);try{T.type==="asset"?await re({id:T.id}):await $e({id:T.id}),n(null)}catch(t){console.error("Delete failed:",t)}finally{Me(!1)}}},[T,re,$e]),ks=a.useCallback(async()=>{if(o.size!==0){_e(!0);try{const t=Array.from(o).map(j=>re({id:j}));await Promise.all(t),x(new Set),k(!1),ue(!1)}catch(t){console.error("Bulk delete failed:",t)}finally{_e(!1)}}},[o,re]),ws=a.useCallback(()=>{x(new Set),k(!1)},[]),zs=a.useCallback(async t=>{J(!0);try{await ne({id:t})}catch(j){console.error("Restore failed:",j)}finally{J(!1)}},[ne]),Fs=a.useCallback(async()=>{if(o.size!==0){J(!0);try{const t=Array.from(o).map(j=>ne({id:j}));await Promise.all(t),x(new Set),k(!1)}catch(t){console.error("Bulk restore failed:",t)}finally{J(!1)}}},[o,ne]),Ss=a.useCallback(async t=>{J(!0);try{await Ve({id:t})}catch(j){console.error("Restore folder failed:",j)}finally{J(!1)}},[Ve]),Ms=a.useCallback(async()=>{if(X){Be(!0);try{X==="bulk"?(await qe({ids:Array.from(o)}),x(new Set),k(!1)):await He({id:X}),ae(!1),ie(null)}catch(t){console.error("Permanent delete failed:",t)}finally{Be(!1)}}},[X,He,qe,o]),Ke=a.useCallback(async()=>{if(!M.trim()){I("Folder name is required");return}L(!0),I("");try{await Ue({name:M.trim(),parentId:r}),S(!1),B("")}catch(t){I(t instanceof Error?t.message:"Failed to create folder")}finally{L(!1)}},[M,r,Ue]),Ds=a.useCallback(t=>{c(!1)},[]),Ts=_===void 0||R===void 0,W=a.useMemo(()=>{const t=_?.page??[];return xe===null?t:t.filter(j=>xe.has(j._id))},[_?.page,xe]);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(Os,{title:"Media Library",description:"Upload, organize, and manage media assets for your content."}),e.jsx(Vs,{value:Ae,onValueChange:t=>bs(t),children:e.jsxs(Hs,{children:[e.jsxs(Je,{value:"library",children:[e.jsx(oe,{className:"mr-1.5 size-4"}),"Library"]}),e.jsxs(Je,{value:"trash",children:[e.jsx(K,{className:"mr-1.5 size-4"}),"Trash",me&&me.total>0&&e.jsx(us,{variant:"secondary",className:"ml-1.5",children:me.total})]})]})}),!w&&e.jsxs("nav",{className:"flex items-center gap-1","aria-label":"Folder navigation",children:[e.jsxs("button",{className:P("flex items-center gap-1.5 rounded-md px-2 py-1 text-sm transition-colors",r?"text-muted-foreground hover:bg-muted hover:text-foreground":"bg-primary/10 font-medium text-primary"),onClick:js,children:[e.jsx(rs,{className:"size-4"}),e.jsx("span",{children:"All Files"})]}),We.map((t,j)=>e.jsxs("span",{className:"flex items-center",children:[e.jsx("span",{className:"mx-1 text-muted-foreground",children:"/"}),e.jsx("button",{className:P("rounded-md px-2 py-1 text-sm transition-colors",j===We.length-1?"bg-primary/10 font-medium text-primary":"text-muted-foreground hover:bg-muted hover:text-foreground"),onClick:()=>Oe(t._id),children:t.name})]},t._id))]}),e.jsx(Ks,{search:{value:m,onChange:g,placeholder:"Search files...",className:"w-64"},filters:[{key:"type",value:d||"all",onChange:t=>F(t==="all"?"":t),options:[{value:"all",label:"All Types"},{value:"image",label:"Images"},{value:"video",label:"Videos"},{value:"audio",label:"Audio"},{value:"document",label:"Documents"},{value:"other",label:"Other"}],className:"w-36"}],actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Qs,{selectedTermIds:p,onChange:y,placeholder:"Tags"}),_?.page&&_.page.length>0&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx(Ye,{checked:v,onCheckedChange:t=>{k(t),t||x(new Set)}}),"Selection Mode"]}),v&&o.size>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.size," selected"]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"secondary",size:"sm",onClick:vs,children:"Select All"}),e.jsx(h,{variant:"secondary",size:"sm",onClick:pe,children:"Clear"})]}),r&&!w&&e.jsxs(h,{variant:"secondary",onClick:gs,children:[e.jsx(ns,{className:"size-4"}),"Up"]}),!w&&e.jsxs(e.Fragment,{children:[e.jsxs(h,{variant:"secondary",onClick:()=>S(!0),children:[e.jsx(lt,{className:"size-4"}),"New Folder"]}),e.jsxs(h,{onClick:()=>c(!0),children:[e.jsx(qs,{className:"size-4"}),"Upload Files"]})]})]})}),Ts?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading media library..."})]}):e.jsxs(e.Fragment,{children:[!w&&R&&R.length>0&&!m&&e.jsxs("section",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:"Folders"}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 md:grid-cols-6",children:R.map(t=>e.jsxs("div",{className:"group relative flex cursor-pointer flex-col items-center gap-2 rounded-lg border bg-card p-4 text-center transition-colors hover:border-primary/50 hover:bg-muted/50",onClick:()=>Oe(t._id),children:[e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(gt,{folder:{_id:t._id,name:t.name},onEdit:()=>$({_id:t._id,name:t.name,description:t.description}),onDelete:()=>n({type:"folder",id:t._id,name:t.name})})}),e.jsx(Ce,{className:"size-10 text-amber-500"}),e.jsx("span",{className:"truncate text-sm font-medium",children:t.name})]},t._id))})]}),w&&R&&R.length>0&&e.jsxs("section",{children:[e.jsxs("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:["Deleted Folders (",R.length,")"]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 md:grid-cols-6",children:R.map(t=>e.jsxs("div",{className:"group relative flex flex-col items-center gap-2 rounded-lg border border-destructive/20 bg-card p-4 text-center opacity-60",children:[e.jsx(Ce,{className:"size-10 text-amber-500/50"}),e.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e.jsxs(h,{variant:"secondary",size:"sm",onClick:()=>Ss(t._id),disabled:Ee,children:[e.jsx(ke,{className:"mr-1 size-3"}),"Restore"]})]},t._id))})]}),W.length>0?e.jsxs("section",{children:[!w&&R&&R.length>0&&!m&&e.jsx("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:"Files"}),w&&e.jsxs("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:["Deleted Files (",W.length,")"]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 md:grid-cols-6",children:W.map(t=>{const j=t._id,z=o.has(j),O=kt(t.mimeType);return e.jsxs("div",{className:P("group relative flex cursor-pointer flex-col overflow-hidden rounded-lg border bg-card transition-all hover:border-primary/50",z&&"border-primary ring-2 ring-primary/20"),onClick:()=>ys(j),children:[v&&e.jsx("div",{className:"absolute left-2 top-2 z-10",children:e.jsx(Ye,{checked:z,onCheckedChange:()=>fe(j),onClick:U=>U.stopPropagation(),className:"bg-white/80"})}),!v&&!w&&e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(pt,{asset:{_id:t._id,name:t.name,url:t.url},onView:()=>{const U=W.findIndex(_s=>_s._id===t._id);U!==-1&&Q(U)},onEdit:()=>Z({_id:t._id,name:t.name,title:t.title,description:t.description,altText:t.altText,tags:t.tags}),onDelete:()=>n({type:"asset",id:t._id,name:t.name})})}),!v&&w&&e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex gap-1 opacity-0 group-hover:opacity-100",children:[e.jsx(h,{variant:"secondary",size:"icon-sm",onClick:U=>{U.stopPropagation(),zs(t._id)},title:"Restore",children:e.jsx(ke,{className:"size-4"})}),e.jsx(h,{variant:"danger",size:"icon-sm",onClick:U=>{U.stopPropagation(),ie(t._id),ae(!0)},title:"Delete Forever",children:e.jsx(K,{className:"size-4"})})]}),e.jsx("div",{className:"aspect-square overflow-hidden bg-muted",children:O==="image"&&t.url?e.jsx("img",{src:t.url,alt:t.title||t.name,className:"h-full w-full object-cover"}):e.jsx("div",{className:"flex size-full items-center justify-center text-muted-foreground",children:Ct(O,"size-10")})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",title:t.name,children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"capitalize",children:O}),e.jsx("span",{children:"•"}),e.jsx("span",{children:yt(t.size??0)})]}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:Nt(t._creationTime)})]})]},t._id)})}),!_.isDone&&e.jsxs("p",{className:"mt-4 text-center text-sm text-muted-foreground",children:["Showing ",_.page.length," files. More files available."]})]}):w?e.jsx(je,{icon:e.jsx(K,{className:"size-8"}),title:"Trash is empty",description:"Deleted files will appear here. You can restore them or permanently delete them."}):!R?.length&&e.jsx(je,{icon:e.jsx(oe,{className:"size-8"}),title:"No media assets yet",description:"Upload images, videos, documents, and other files to use in your content.",action:{label:"Upload Files",onClick:()=>c(!0)}}),m&&W.length===0&&!w&&e.jsx(je,{icon:e.jsx(Ys,{className:"size-8"}),title:"No results found",description:`No files match "${m}". Try a different search term.`,action:{label:"Clear Search",onClick:()=>g(""),variant:"secondary"}})]}),e.jsx(ve,{open:b,onOpenChange:S,children:e.jsxs(be,{children:[e.jsx(Ge,{children:e.jsx(ye,{children:"Create New Folder"})}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(Xe,{htmlFor:"folder-name",children:"Folder Name"}),e.jsx(G,{id:"folder-name",value:M,onChange:t=>{B(t.target.value),I("")},placeholder:"Enter folder name",autoFocus:!0,onKeyDown:t=>{t.key==="Enter"&&!N&&Ke()}}),f&&e.jsx("p",{className:"text-sm text-destructive",children:f})]})}),e.jsxs(Ze,{children:[e.jsx(h,{variant:"secondary",onClick:()=>S(!1),disabled:N,children:"Cancel"}),e.jsx(h,{onClick:Ke,disabled:N||!M.trim(),loading:N,children:"Create Folder"})]})]})}),e.jsx(ve,{open:D,onOpenChange:c,children:e.jsxs(be,{className:"max-w-lg",children:[e.jsx(Ge,{children:e.jsx(ye,{children:"Upload Files"})}),e.jsx("div",{className:"py-4",children:e.jsx(Ws,{currentFolderId:r,generateUploadUrl:s.generateUploadUrl,createAsset:s.createMediaAsset,onUploadComplete:Ds,maxFileSize:50*1024*1024,maxConcurrentUploads:3})}),e.jsx(Ze,{children:e.jsx(h,{variant:"secondary",onClick:()=>c(!1),children:"Close"})})]})}),e.jsx(mt,{asset:q!==null&&W[q]?W[q]:null,assets:W,currentIndex:q??0,open:q!==null,onOpenChange:t=>{t||Q(null)},onNavigate:Ns,onEdit:w?void 0:t=>Z({_id:t._id,name:t.name,title:t.title,description:t.description,altText:t.altText,tags:t.tags}),onDelete:w?void 0:t=>n({type:"asset",id:t._id,name:t.name})}),e.jsx(ht,{asset:se,open:se!==null,onOpenChange:t=>{t||Z(null)}}),e.jsx(ft,{folder:te,open:te!==null,onOpenChange:t=>{t||$(null)}}),e.jsx(ge,{open:T!==null,onOpenChange:t=>{t||n(null)},title:`Delete ${T?.type==="folder"?"Folder":"File"}?`,description:`Are you sure you want to delete "${T?.name}"? ${T?.type==="folder"?"This will also delete all files inside the folder.":"This action can be undone from the trash."}`,confirmLabel:"Delete",onConfirm:Cs,variant:"danger",loading:C}),e.jsx(ge,{open:hs,onOpenChange:ue,title:"Delete Selected Files?",description:`Are you sure you want to delete ${o.size} ${o.size===1?"file":"files"}? This action can be undone from the trash.`,confirmLabel:"Delete All",onConfirm:ks,variant:"danger",loading:Te}),e.jsx(ge,{open:ps,onOpenChange:t=>{ae(t),t||ie(null)},title:X==="bulk"?`Delete ${o.size} ${o.size===1?"File":"Files"} Forever?`:"Delete Forever?",description:X==="bulk"?`This will permanently delete ${o.size} ${o.size===1?"file":"files"}. This action cannot be undone.`:"This will permanently delete this file. This action cannot be undone.",confirmLabel:"Delete Forever",onConfirm:Ms,variant:"danger",loading:Pe}),e.jsx(bt,{open:xs,onOpenChange:De,assetIds:Array.from(o),currentFolderId:r,onMoved:ws}),v&&!w&&e.jsx(jt,{selectedCount:o.size,onClear:pe,onMove:()=>De(!0),onDelete:()=>ue(!0),isDeleting:Te}),v&&w&&e.jsx(vt,{selectedCount:o.size,onClear:pe,onRestore:Fs,onPermanentDelete:()=>{ie("bulk"),ae(!0)},isRestoring:Ee,isDeleting:Pe})]})}function Lt(){const s=$s(),{settings:l}=Ls();return e.jsx(wt,{api:Us.admin,navigation:s,settings:l})}export{Lt as component};
@@ -1 +1 @@
1
- import{ar as i,ae as p,u as m,k as c,j as e,F as d}from"./main-CA-4LyFT.js";import{C as l}from"./ContentEntryEditor-CRgcRkk5.js";import{u as y}from"./useBreadcrumbLabel-tlSh7dtO.js";import{C as u}from"./CmsEmptyState-DTlpzjOI.js";import"./switch-Ck9ecqEX.js";import"./tabs-vQYu8rjC.js";import"./refresh-cw-sdVUGJNs.js";import"./pencil-gAL0R34f.js";import"./search-WXp6KxDJ.js";import"./command-CJ8i86fd.js";import"./badge-C6qt24oj.js";import"./CmsStatusBadge-D_n8u8xa.js";import"./scroll-area-CJBhf9pf.js";import"./circle-check-big-PltpxuB1.js";function w(){const{contentTypeId:n}=i.useParams(),o=p(),t=m(c.admin.getContentType,{id:n});if(y(`/entries/new/${n}`,t?`New ${t.displayName}`:void 0),t===void 0)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading content type..."})]})});if(t===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(u,{icon:e.jsx(d,{className:"size-6"}),title:"Content Type Not Found",description:"The content type you're looking for doesn't exist or has been deleted.",action:{label:"Back to Content Types",onClick:()=>o({to:"/content-types"})}})});const s=a=>{o({to:"/entries/$entryId",params:{entryId:a._id}})},r=()=>{o({to:"/entries/type/$contentTypeId",params:{contentTypeId:n}})};return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(l,{contentType:t,onSave:s,onCancel:r})})}export{w as component};
1
+ import{ar as i,af as p,u as m,d as c,j as e,F as d}from"./main-B-6700eG.js";import{C as l}from"./ContentEntryEditor-Ct7cHayy.js";import{u as y}from"./useBreadcrumbLabel-yZQG_N_3.js";import{C as u}from"./CmsEmptyState-BKeL4DBB.js";import"./switch-CjPi4DKH.js";import"./tabs-B5X37GEM.js";import"./refresh-cw-BrXg9a2r.js";import"./pencil-CI_KfxSx.js";import"./search-DlwBH4C5.js";import"./command-lEq6f_Ee.js";import"./badge-BQAotc5B.js";import"./CmsStatusBadge-BFMOsfMW.js";import"./scroll-area-DX_nZYp8.js";import"./circle-check-big-BF3Y5nES.js";function w(){const{contentTypeId:n}=i.useParams(),o=p(),t=m(c.admin.getContentType,{id:n});if(y(`/entries/new/${n}`,t?`New ${t.displayName}`:void 0),t===void 0)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading content type..."})]})});if(t===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(u,{icon:e.jsx(d,{className:"size-6"}),title:"Content Type Not Found",description:"The content type you're looking for doesn't exist or has been deleted.",action:{label:"Back to Content Types",onClick:()=>o({to:"/content-types"})}})});const s=a=>{o({to:"/entries/$entryId",params:{entryId:a._id}})},r=()=>{o({to:"/entries/type/$contentTypeId",params:{contentTypeId:n}})};return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(l,{contentType:t,onSave:s,onCancel:r})})}export{w as component};
@@ -1 +1 @@
1
- import{l as a}from"./main-CA-4LyFT.js";const e=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],c=a("pencil",e);export{c as P};
1
+ import{e as a}from"./main-B-6700eG.js";const e=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],c=a("pencil",e);export{c as P};
@@ -0,0 +1 @@
1
+ import{e}from"./main-B-6700eG.js";const t=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],c=e("refresh-cw",t);export{c as R};
@@ -0,0 +1 @@
1
+ import{e}from"./main-B-6700eG.js";const t=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],a=e("rotate-ccw",t);export{a as R};
@@ -1 +1 @@
1
- import{r as s,ax as A,ay as se,j as f,az as L,aA as O,aB as ce,aC as C,aD as P,aE as ae,aF as ie,h as F}from"./main-CA-4LyFT.js";function de(e,o){return s.useReducer((r,l)=>o[r][l]??r,e)}var U="ScrollArea",[$]=ce(U),[ue,p]=$(U),q=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,type:l="hover",dir:t,scrollHideDelay:n=600,...c}=e,[a,i]=s.useState(null),[h,d]=s.useState(null),[b,u]=s.useState(null),[S,w]=s.useState(null),[T,Y]=s.useState(null),[x,_]=s.useState(0),[M,D]=s.useState(0),[j,y]=s.useState(!1),[N,W]=s.useState(!1),v=A(o,E=>i(E)),m=se(t);return f.jsx(ue,{scope:r,type:l,dir:m,scrollHideDelay:n,scrollArea:a,viewport:h,onViewportChange:d,content:b,onContentChange:u,scrollbarX:S,onScrollbarXChange:w,scrollbarXEnabled:j,onScrollbarXEnabledChange:y,scrollbarY:T,onScrollbarYChange:Y,scrollbarYEnabled:N,onScrollbarYEnabledChange:W,onCornerWidthChange:_,onCornerHeightChange:D,children:f.jsx(L.div,{dir:m,...c,ref:v,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":M+"px",...e.style}})})});q.displayName=U;var G="ScrollAreaViewport",J=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,children:l,nonce:t,...n}=e,c=p(G,r),a=s.useRef(null),i=A(o,a,c.onViewportChange);return f.jsxs(f.Fragment,{children:[f.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:t}),f.jsx(L.div,{"data-radix-scroll-area-viewport":"",...n,ref:i,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:f.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:l})})]})});J.displayName=G;var g="ScrollAreaScrollbar",K=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=p(g,e.__scopeScrollArea),{onScrollbarXEnabledChange:n,onScrollbarYEnabledChange:c}=t,a=e.orientation==="horizontal";return s.useEffect(()=>(a?n(!0):c(!0),()=>{a?n(!1):c(!1)}),[a,n,c]),t.type==="hover"?f.jsx(he,{...l,ref:o,forceMount:r}):t.type==="scroll"?f.jsx(fe,{...l,ref:o,forceMount:r}):t.type==="auto"?f.jsx(Q,{...l,ref:o,forceMount:r}):t.type==="always"?f.jsx(B,{...l,ref:o}):null});K.displayName=g;var he=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=p(g,e.__scopeScrollArea),[n,c]=s.useState(!1);return s.useEffect(()=>{const a=t.scrollArea;let i=0;if(a){const h=()=>{window.clearTimeout(i),c(!0)},d=()=>{i=window.setTimeout(()=>c(!1),t.scrollHideDelay)};return a.addEventListener("pointerenter",h),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(i),a.removeEventListener("pointerenter",h),a.removeEventListener("pointerleave",d)}}},[t.scrollArea,t.scrollHideDelay]),f.jsx(O,{present:r||n,children:f.jsx(Q,{"data-state":n?"visible":"hidden",...l,ref:o})})}),fe=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=p(g,e.__scopeScrollArea),n=e.orientation==="horizontal",c=X(()=>i("SCROLL_END"),100),[a,i]=de("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return s.useEffect(()=>{if(a==="idle"){const h=window.setTimeout(()=>i("HIDE"),t.scrollHideDelay);return()=>window.clearTimeout(h)}},[a,t.scrollHideDelay,i]),s.useEffect(()=>{const h=t.viewport,d=n?"scrollLeft":"scrollTop";if(h){let b=h[d];const u=()=>{const S=h[d];b!==S&&(i("SCROLL"),c()),b=S};return h.addEventListener("scroll",u),()=>h.removeEventListener("scroll",u)}},[t.viewport,n,i,c]),f.jsx(O,{present:r||a!=="hidden",children:f.jsx(B,{"data-state":a==="hidden"?"hidden":"visible",...l,ref:o,onPointerEnter:C(e.onPointerEnter,()=>i("POINTER_ENTER")),onPointerLeave:C(e.onPointerLeave,()=>i("POINTER_LEAVE"))})})}),Q=s.forwardRef((e,o)=>{const r=p(g,e.__scopeScrollArea),{forceMount:l,...t}=e,[n,c]=s.useState(!1),a=e.orientation==="horizontal",i=X(()=>{if(r.viewport){const h=r.viewport.offsetWidth<r.viewport.scrollWidth,d=r.viewport.offsetHeight<r.viewport.scrollHeight;c(a?h:d)}},10);return R(r.viewport,i),R(r.content,i),f.jsx(O,{present:l||n,children:f.jsx(B,{"data-state":n?"visible":"hidden",...t,ref:o})})}),B=s.forwardRef((e,o)=>{const{orientation:r="vertical",...l}=e,t=p(g,e.__scopeScrollArea),n=s.useRef(null),c=s.useRef(0),[a,i]=s.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),h=te(a.viewport,a.content),d={...l,sizes:a,onSizesChange:i,hasThumb:h>0&&h<1,onThumbChange:u=>n.current=u,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:u=>c.current=u};function b(u,S){return we(u,c.current,a,S)}return r==="horizontal"?f.jsx(be,{...d,ref:o,onThumbPositionChange:()=>{if(t.viewport&&n.current){const u=t.viewport.scrollLeft,S=k(u,a,t.dir);n.current.style.transform=`translate3d(${S}px, 0, 0)`}},onWheelScroll:u=>{t.viewport&&(t.viewport.scrollLeft=u)},onDragScroll:u=>{t.viewport&&(t.viewport.scrollLeft=b(u,t.dir))}}):r==="vertical"?f.jsx(Se,{...d,ref:o,onThumbPositionChange:()=>{if(t.viewport&&n.current){const u=t.viewport.scrollTop,S=k(u,a);n.current.style.transform=`translate3d(0, ${S}px, 0)`}},onWheelScroll:u=>{t.viewport&&(t.viewport.scrollTop=u)},onDragScroll:u=>{t.viewport&&(t.viewport.scrollTop=b(u))}}):null}),be=s.forwardRef((e,o)=>{const{sizes:r,onSizesChange:l,...t}=e,n=p(g,e.__scopeScrollArea),[c,a]=s.useState(),i=s.useRef(null),h=A(o,i,n.onScrollbarXChange);return s.useEffect(()=>{i.current&&a(getComputedStyle(i.current))},[i]),f.jsx(ee,{"data-orientation":"horizontal",...t,ref:h,sizes:r,style:{bottom:0,left:n.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:n.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":I(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,b)=>{if(n.viewport){const u=n.viewport.scrollLeft+d.deltaX;e.onWheelScroll(u),le(u,b)&&d.preventDefault()}},onResize:()=>{i.current&&n.viewport&&c&&l({content:n.viewport.scrollWidth,viewport:n.viewport.offsetWidth,scrollbar:{size:i.current.clientWidth,paddingStart:H(c.paddingLeft),paddingEnd:H(c.paddingRight)}})}})}),Se=s.forwardRef((e,o)=>{const{sizes:r,onSizesChange:l,...t}=e,n=p(g,e.__scopeScrollArea),[c,a]=s.useState(),i=s.useRef(null),h=A(o,i,n.onScrollbarYChange);return s.useEffect(()=>{i.current&&a(getComputedStyle(i.current))},[i]),f.jsx(ee,{"data-orientation":"vertical",...t,ref:h,sizes:r,style:{top:0,right:n.dir==="ltr"?0:void 0,left:n.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":I(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,b)=>{if(n.viewport){const u=n.viewport.scrollTop+d.deltaY;e.onWheelScroll(u),le(u,b)&&d.preventDefault()}},onResize:()=>{i.current&&n.viewport&&c&&l({content:n.viewport.scrollHeight,viewport:n.viewport.offsetHeight,scrollbar:{size:i.current.clientHeight,paddingStart:H(c.paddingTop),paddingEnd:H(c.paddingBottom)}})}})}),[ve,Z]=$(g),ee=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,sizes:l,hasThumb:t,onThumbChange:n,onThumbPointerUp:c,onThumbPointerDown:a,onThumbPositionChange:i,onDragScroll:h,onWheelScroll:d,onResize:b,...u}=e,S=p(g,r),[w,T]=s.useState(null),Y=A(o,v=>T(v)),x=s.useRef(null),_=s.useRef(""),M=S.viewport,D=l.content-l.viewport,j=P(d),y=P(i),N=X(b,10);function W(v){if(x.current){const m=v.clientX-x.current.left,E=v.clientY-x.current.top;h({x:m,y:E})}}return s.useEffect(()=>{const v=m=>{const E=m.target;w?.contains(E)&&j(m,D)};return document.addEventListener("wheel",v,{passive:!1}),()=>document.removeEventListener("wheel",v,{passive:!1})},[M,w,D,j]),s.useEffect(y,[l,y]),R(w,N),R(S.content,N),f.jsx(ve,{scope:r,scrollbar:w,hasThumb:t,onThumbChange:P(n),onThumbPointerUp:P(c),onThumbPositionChange:y,onThumbPointerDown:P(a),children:f.jsx(L.div,{...u,ref:Y,style:{position:"absolute",...u.style},onPointerDown:C(e.onPointerDown,v=>{v.button===0&&(v.target.setPointerCapture(v.pointerId),x.current=w.getBoundingClientRect(),_.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",S.viewport&&(S.viewport.style.scrollBehavior="auto"),W(v))}),onPointerMove:C(e.onPointerMove,W),onPointerUp:C(e.onPointerUp,v=>{const m=v.target;m.hasPointerCapture(v.pointerId)&&m.releasePointerCapture(v.pointerId),document.body.style.webkitUserSelect=_.current,S.viewport&&(S.viewport.style.scrollBehavior=""),x.current=null})})})}),z="ScrollAreaThumb",re=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=Z(z,e.__scopeScrollArea);return f.jsx(O,{present:r||t.hasThumb,children:f.jsx(pe,{ref:o,...l})})}),pe=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,style:l,...t}=e,n=p(z,r),c=Z(z,r),{onThumbPositionChange:a}=c,i=A(o,b=>c.onThumbChange(b)),h=s.useRef(void 0),d=X(()=>{h.current&&(h.current(),h.current=void 0)},100);return s.useEffect(()=>{const b=n.viewport;if(b){const u=()=>{if(d(),!h.current){const S=ge(b,a);h.current=S,a()}};return a(),b.addEventListener("scroll",u),()=>b.removeEventListener("scroll",u)}},[n.viewport,d,a]),f.jsx(L.div,{"data-state":c.hasThumb?"visible":"hidden",...t,ref:i,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...l},onPointerDownCapture:C(e.onPointerDownCapture,b=>{const S=b.target.getBoundingClientRect(),w=b.clientX-S.left,T=b.clientY-S.top;c.onThumbPointerDown({x:w,y:T})}),onPointerUp:C(e.onPointerUp,c.onThumbPointerUp)})});re.displayName=z;var V="ScrollAreaCorner",oe=s.forwardRef((e,o)=>{const r=p(V,e.__scopeScrollArea),l=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&l?f.jsx(me,{...e,ref:o}):null});oe.displayName=V;var me=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,...l}=e,t=p(V,r),[n,c]=s.useState(0),[a,i]=s.useState(0),h=!!(n&&a);return R(t.scrollbarX,()=>{const d=t.scrollbarX?.offsetHeight||0;t.onCornerHeightChange(d),i(d)}),R(t.scrollbarY,()=>{const d=t.scrollbarY?.offsetWidth||0;t.onCornerWidthChange(d),c(d)}),h?f.jsx(L.div,{...l,ref:o,style:{width:n,height:a,position:"absolute",right:t.dir==="ltr"?0:void 0,left:t.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function H(e){return e?parseInt(e,10):0}function te(e,o){const r=e/o;return isNaN(r)?0:r}function I(e){const o=te(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,l=(e.scrollbar.size-r)*o;return Math.max(l,18)}function we(e,o,r,l="ltr"){const t=I(r),n=t/2,c=o||n,a=t-c,i=r.scrollbar.paddingStart+c,h=r.scrollbar.size-r.scrollbar.paddingEnd-a,d=r.content-r.viewport,b=l==="ltr"?[0,d]:[d*-1,0];return ne([i,h],b)(e)}function k(e,o,r="ltr"){const l=I(o),t=o.scrollbar.paddingStart+o.scrollbar.paddingEnd,n=o.scrollbar.size-t,c=o.content-o.viewport,a=n-l,i=r==="ltr"?[0,c]:[c*-1,0],h=ie(e,i);return ne([0,c],[0,a])(h)}function ne(e,o){return r=>{if(e[0]===e[1]||o[0]===o[1])return o[0];const l=(o[1]-o[0])/(e[1]-e[0]);return o[0]+l*(r-e[0])}}function le(e,o){return e>0&&e<o}var ge=(e,o=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},l=0;return(function t(){const n={left:e.scrollLeft,top:e.scrollTop},c=r.left!==n.left,a=r.top!==n.top;(c||a)&&o(),r=n,l=window.requestAnimationFrame(t)})(),()=>window.cancelAnimationFrame(l)};function X(e,o){const r=P(e),l=s.useRef(0);return s.useEffect(()=>()=>window.clearTimeout(l.current),[]),s.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(r,o)},[r,o])}function R(e,o){const r=P(o);ae(()=>{let l=0;if(e){const t=new ResizeObserver(()=>{cancelAnimationFrame(l),l=window.requestAnimationFrame(r)});return t.observe(e),()=>{window.cancelAnimationFrame(l),t.unobserve(e)}}},[e,r])}var xe=q,Pe=J,Ce=oe;function Te({className:e,children:o,...r}){return f.jsxs(xe,{"data-slot":"scroll-area",className:F("relative",e),...r,children:[f.jsx(Pe,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:o}),f.jsx(Ee,{}),f.jsx(Ce,{})]})}function Ee({className:e,orientation:o="vertical",...r}){return f.jsx(K,{"data-slot":"scroll-area-scrollbar",orientation:o,className:F("flex touch-none p-px transition-colors select-none",o==="vertical"&&"h-full w-2.5 border-l border-l-transparent",o==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:f.jsx(re,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}export{Te as S};
1
+ import{r as s,ax as A,ay as se,j as f,az as L,aA as O,aB as ce,aC as C,aD as P,aE as ae,aF as ie,n as F}from"./main-B-6700eG.js";function de(e,o){return s.useReducer((r,l)=>o[r][l]??r,e)}var U="ScrollArea",[$]=ce(U),[ue,p]=$(U),q=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,type:l="hover",dir:t,scrollHideDelay:n=600,...c}=e,[a,i]=s.useState(null),[h,d]=s.useState(null),[b,u]=s.useState(null),[S,w]=s.useState(null),[T,Y]=s.useState(null),[x,_]=s.useState(0),[M,D]=s.useState(0),[j,y]=s.useState(!1),[N,W]=s.useState(!1),v=A(o,E=>i(E)),m=se(t);return f.jsx(ue,{scope:r,type:l,dir:m,scrollHideDelay:n,scrollArea:a,viewport:h,onViewportChange:d,content:b,onContentChange:u,scrollbarX:S,onScrollbarXChange:w,scrollbarXEnabled:j,onScrollbarXEnabledChange:y,scrollbarY:T,onScrollbarYChange:Y,scrollbarYEnabled:N,onScrollbarYEnabledChange:W,onCornerWidthChange:_,onCornerHeightChange:D,children:f.jsx(L.div,{dir:m,...c,ref:v,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":M+"px",...e.style}})})});q.displayName=U;var G="ScrollAreaViewport",J=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,children:l,nonce:t,...n}=e,c=p(G,r),a=s.useRef(null),i=A(o,a,c.onViewportChange);return f.jsxs(f.Fragment,{children:[f.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:t}),f.jsx(L.div,{"data-radix-scroll-area-viewport":"",...n,ref:i,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:f.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:l})})]})});J.displayName=G;var g="ScrollAreaScrollbar",K=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=p(g,e.__scopeScrollArea),{onScrollbarXEnabledChange:n,onScrollbarYEnabledChange:c}=t,a=e.orientation==="horizontal";return s.useEffect(()=>(a?n(!0):c(!0),()=>{a?n(!1):c(!1)}),[a,n,c]),t.type==="hover"?f.jsx(he,{...l,ref:o,forceMount:r}):t.type==="scroll"?f.jsx(fe,{...l,ref:o,forceMount:r}):t.type==="auto"?f.jsx(Q,{...l,ref:o,forceMount:r}):t.type==="always"?f.jsx(B,{...l,ref:o}):null});K.displayName=g;var he=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=p(g,e.__scopeScrollArea),[n,c]=s.useState(!1);return s.useEffect(()=>{const a=t.scrollArea;let i=0;if(a){const h=()=>{window.clearTimeout(i),c(!0)},d=()=>{i=window.setTimeout(()=>c(!1),t.scrollHideDelay)};return a.addEventListener("pointerenter",h),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(i),a.removeEventListener("pointerenter",h),a.removeEventListener("pointerleave",d)}}},[t.scrollArea,t.scrollHideDelay]),f.jsx(O,{present:r||n,children:f.jsx(Q,{"data-state":n?"visible":"hidden",...l,ref:o})})}),fe=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=p(g,e.__scopeScrollArea),n=e.orientation==="horizontal",c=X(()=>i("SCROLL_END"),100),[a,i]=de("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return s.useEffect(()=>{if(a==="idle"){const h=window.setTimeout(()=>i("HIDE"),t.scrollHideDelay);return()=>window.clearTimeout(h)}},[a,t.scrollHideDelay,i]),s.useEffect(()=>{const h=t.viewport,d=n?"scrollLeft":"scrollTop";if(h){let b=h[d];const u=()=>{const S=h[d];b!==S&&(i("SCROLL"),c()),b=S};return h.addEventListener("scroll",u),()=>h.removeEventListener("scroll",u)}},[t.viewport,n,i,c]),f.jsx(O,{present:r||a!=="hidden",children:f.jsx(B,{"data-state":a==="hidden"?"hidden":"visible",...l,ref:o,onPointerEnter:C(e.onPointerEnter,()=>i("POINTER_ENTER")),onPointerLeave:C(e.onPointerLeave,()=>i("POINTER_LEAVE"))})})}),Q=s.forwardRef((e,o)=>{const r=p(g,e.__scopeScrollArea),{forceMount:l,...t}=e,[n,c]=s.useState(!1),a=e.orientation==="horizontal",i=X(()=>{if(r.viewport){const h=r.viewport.offsetWidth<r.viewport.scrollWidth,d=r.viewport.offsetHeight<r.viewport.scrollHeight;c(a?h:d)}},10);return R(r.viewport,i),R(r.content,i),f.jsx(O,{present:l||n,children:f.jsx(B,{"data-state":n?"visible":"hidden",...t,ref:o})})}),B=s.forwardRef((e,o)=>{const{orientation:r="vertical",...l}=e,t=p(g,e.__scopeScrollArea),n=s.useRef(null),c=s.useRef(0),[a,i]=s.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),h=te(a.viewport,a.content),d={...l,sizes:a,onSizesChange:i,hasThumb:h>0&&h<1,onThumbChange:u=>n.current=u,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:u=>c.current=u};function b(u,S){return we(u,c.current,a,S)}return r==="horizontal"?f.jsx(be,{...d,ref:o,onThumbPositionChange:()=>{if(t.viewport&&n.current){const u=t.viewport.scrollLeft,S=k(u,a,t.dir);n.current.style.transform=`translate3d(${S}px, 0, 0)`}},onWheelScroll:u=>{t.viewport&&(t.viewport.scrollLeft=u)},onDragScroll:u=>{t.viewport&&(t.viewport.scrollLeft=b(u,t.dir))}}):r==="vertical"?f.jsx(Se,{...d,ref:o,onThumbPositionChange:()=>{if(t.viewport&&n.current){const u=t.viewport.scrollTop,S=k(u,a);n.current.style.transform=`translate3d(0, ${S}px, 0)`}},onWheelScroll:u=>{t.viewport&&(t.viewport.scrollTop=u)},onDragScroll:u=>{t.viewport&&(t.viewport.scrollTop=b(u))}}):null}),be=s.forwardRef((e,o)=>{const{sizes:r,onSizesChange:l,...t}=e,n=p(g,e.__scopeScrollArea),[c,a]=s.useState(),i=s.useRef(null),h=A(o,i,n.onScrollbarXChange);return s.useEffect(()=>{i.current&&a(getComputedStyle(i.current))},[i]),f.jsx(ee,{"data-orientation":"horizontal",...t,ref:h,sizes:r,style:{bottom:0,left:n.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:n.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":I(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,b)=>{if(n.viewport){const u=n.viewport.scrollLeft+d.deltaX;e.onWheelScroll(u),le(u,b)&&d.preventDefault()}},onResize:()=>{i.current&&n.viewport&&c&&l({content:n.viewport.scrollWidth,viewport:n.viewport.offsetWidth,scrollbar:{size:i.current.clientWidth,paddingStart:H(c.paddingLeft),paddingEnd:H(c.paddingRight)}})}})}),Se=s.forwardRef((e,o)=>{const{sizes:r,onSizesChange:l,...t}=e,n=p(g,e.__scopeScrollArea),[c,a]=s.useState(),i=s.useRef(null),h=A(o,i,n.onScrollbarYChange);return s.useEffect(()=>{i.current&&a(getComputedStyle(i.current))},[i]),f.jsx(ee,{"data-orientation":"vertical",...t,ref:h,sizes:r,style:{top:0,right:n.dir==="ltr"?0:void 0,left:n.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":I(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,b)=>{if(n.viewport){const u=n.viewport.scrollTop+d.deltaY;e.onWheelScroll(u),le(u,b)&&d.preventDefault()}},onResize:()=>{i.current&&n.viewport&&c&&l({content:n.viewport.scrollHeight,viewport:n.viewport.offsetHeight,scrollbar:{size:i.current.clientHeight,paddingStart:H(c.paddingTop),paddingEnd:H(c.paddingBottom)}})}})}),[ve,Z]=$(g),ee=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,sizes:l,hasThumb:t,onThumbChange:n,onThumbPointerUp:c,onThumbPointerDown:a,onThumbPositionChange:i,onDragScroll:h,onWheelScroll:d,onResize:b,...u}=e,S=p(g,r),[w,T]=s.useState(null),Y=A(o,v=>T(v)),x=s.useRef(null),_=s.useRef(""),M=S.viewport,D=l.content-l.viewport,j=P(d),y=P(i),N=X(b,10);function W(v){if(x.current){const m=v.clientX-x.current.left,E=v.clientY-x.current.top;h({x:m,y:E})}}return s.useEffect(()=>{const v=m=>{const E=m.target;w?.contains(E)&&j(m,D)};return document.addEventListener("wheel",v,{passive:!1}),()=>document.removeEventListener("wheel",v,{passive:!1})},[M,w,D,j]),s.useEffect(y,[l,y]),R(w,N),R(S.content,N),f.jsx(ve,{scope:r,scrollbar:w,hasThumb:t,onThumbChange:P(n),onThumbPointerUp:P(c),onThumbPositionChange:y,onThumbPointerDown:P(a),children:f.jsx(L.div,{...u,ref:Y,style:{position:"absolute",...u.style},onPointerDown:C(e.onPointerDown,v=>{v.button===0&&(v.target.setPointerCapture(v.pointerId),x.current=w.getBoundingClientRect(),_.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",S.viewport&&(S.viewport.style.scrollBehavior="auto"),W(v))}),onPointerMove:C(e.onPointerMove,W),onPointerUp:C(e.onPointerUp,v=>{const m=v.target;m.hasPointerCapture(v.pointerId)&&m.releasePointerCapture(v.pointerId),document.body.style.webkitUserSelect=_.current,S.viewport&&(S.viewport.style.scrollBehavior=""),x.current=null})})})}),z="ScrollAreaThumb",re=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=Z(z,e.__scopeScrollArea);return f.jsx(O,{present:r||t.hasThumb,children:f.jsx(pe,{ref:o,...l})})}),pe=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,style:l,...t}=e,n=p(z,r),c=Z(z,r),{onThumbPositionChange:a}=c,i=A(o,b=>c.onThumbChange(b)),h=s.useRef(void 0),d=X(()=>{h.current&&(h.current(),h.current=void 0)},100);return s.useEffect(()=>{const b=n.viewport;if(b){const u=()=>{if(d(),!h.current){const S=ge(b,a);h.current=S,a()}};return a(),b.addEventListener("scroll",u),()=>b.removeEventListener("scroll",u)}},[n.viewport,d,a]),f.jsx(L.div,{"data-state":c.hasThumb?"visible":"hidden",...t,ref:i,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...l},onPointerDownCapture:C(e.onPointerDownCapture,b=>{const S=b.target.getBoundingClientRect(),w=b.clientX-S.left,T=b.clientY-S.top;c.onThumbPointerDown({x:w,y:T})}),onPointerUp:C(e.onPointerUp,c.onThumbPointerUp)})});re.displayName=z;var V="ScrollAreaCorner",oe=s.forwardRef((e,o)=>{const r=p(V,e.__scopeScrollArea),l=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&l?f.jsx(me,{...e,ref:o}):null});oe.displayName=V;var me=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,...l}=e,t=p(V,r),[n,c]=s.useState(0),[a,i]=s.useState(0),h=!!(n&&a);return R(t.scrollbarX,()=>{const d=t.scrollbarX?.offsetHeight||0;t.onCornerHeightChange(d),i(d)}),R(t.scrollbarY,()=>{const d=t.scrollbarY?.offsetWidth||0;t.onCornerWidthChange(d),c(d)}),h?f.jsx(L.div,{...l,ref:o,style:{width:n,height:a,position:"absolute",right:t.dir==="ltr"?0:void 0,left:t.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function H(e){return e?parseInt(e,10):0}function te(e,o){const r=e/o;return isNaN(r)?0:r}function I(e){const o=te(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,l=(e.scrollbar.size-r)*o;return Math.max(l,18)}function we(e,o,r,l="ltr"){const t=I(r),n=t/2,c=o||n,a=t-c,i=r.scrollbar.paddingStart+c,h=r.scrollbar.size-r.scrollbar.paddingEnd-a,d=r.content-r.viewport,b=l==="ltr"?[0,d]:[d*-1,0];return ne([i,h],b)(e)}function k(e,o,r="ltr"){const l=I(o),t=o.scrollbar.paddingStart+o.scrollbar.paddingEnd,n=o.scrollbar.size-t,c=o.content-o.viewport,a=n-l,i=r==="ltr"?[0,c]:[c*-1,0],h=ie(e,i);return ne([0,c],[0,a])(h)}function ne(e,o){return r=>{if(e[0]===e[1]||o[0]===o[1])return o[0];const l=(o[1]-o[0])/(e[1]-e[0]);return o[0]+l*(r-e[0])}}function le(e,o){return e>0&&e<o}var ge=(e,o=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},l=0;return(function t(){const n={left:e.scrollLeft,top:e.scrollTop},c=r.left!==n.left,a=r.top!==n.top;(c||a)&&o(),r=n,l=window.requestAnimationFrame(t)})(),()=>window.cancelAnimationFrame(l)};function X(e,o){const r=P(e),l=s.useRef(0);return s.useEffect(()=>()=>window.clearTimeout(l.current),[]),s.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(r,o)},[r,o])}function R(e,o){const r=P(o);ae(()=>{let l=0;if(e){const t=new ResizeObserver(()=>{cancelAnimationFrame(l),l=window.requestAnimationFrame(r)});return t.observe(e),()=>{window.cancelAnimationFrame(l),t.unobserve(e)}}},[e,r])}var xe=q,Pe=J,Ce=oe;function Te({className:e,children:o,...r}){return f.jsxs(xe,{"data-slot":"scroll-area",className:F("relative",e),...r,children:[f.jsx(Pe,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:o}),f.jsx(Ee,{}),f.jsx(Ce,{})]})}function Ee({className:e,orientation:o="vertical",...r}){return f.jsx(K,{"data-slot":"scroll-area-scrollbar",orientation:o,className:F("flex touch-none p-px transition-colors select-none",o==="vertical"&&"h-full w-2.5 border-l border-l-transparent",o==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:f.jsx(re,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}export{Te as S};
@@ -1 +1 @@
1
- import{l as c}from"./main-CA-4LyFT.js";const e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],o=c("search",e);export{o as S};
1
+ import{e as c}from"./main-B-6700eG.js";const e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],o=c("search",e);export{o as S};
@@ -0,0 +1 @@
1
+ import{e as k,j as e,p as U,u as q,a as _,r as t,R as L,q as B,X as O,C,L as i,S as G,s as V,t as $,v as H,w as J,x as D,y as Q,n as X,d as Z}from"./main-B-6700eG.js";import{u as K}from"./tanstack-adapter-KSm-nO5L.js";import{u as W}from"./usePermissions-D6vsoaJf.js";import{C as M}from"./CmsPageHeader-CIEkTbyH.js";import{C as m}from"./CmsSurface-kqqaFKUI.js";import{S as v}from"./switch-CjPi4DKH.js";import{B as S}from"./badge-BQAotc5B.js";import{A as Y,a as ee}from"./alert-CpLdsTGU.js";const se=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],te=k("info",se);const ae=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],ne=k("monitor",ae);const ie=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],le=k("moon",ie);const re=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],ce=k("sun",re),b={versioning:!0,scheduling:!0,localization:!1,mediaManagement:!0},g={_id:null,defaultLocale:"en",availableLocales:["en","es","fr","de"],features:b},de=[{value:"en",label:"English (en)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"},{value:"it",label:"Italian (it)"},{value:"pt",label:"Portuguese (pt)"},{value:"zh",label:"Chinese (zh)"},{value:"ja",label:"Japanese (ja)"}],oe=[{value:"light",label:"Light",icon:e.jsx(ce,{className:"size-4"})},{value:"dark",label:"Dark",icon:e.jsx(le,{className:"size-4"})},{value:"system",label:"System",icon:e.jsx(ne,{className:"size-4"})}];function E(){const{theme:s,setTheme:y,canToggleDarkMode:h}=Q();return h?e.jsxs(m,{elevation:"base",className:"p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-foreground",children:"Appearance"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(i,{className:"text-sm font-medium",children:"Theme"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose your preferred color theme for the admin interface."})]}),e.jsx("div",{className:"flex gap-1 rounded-lg border bg-muted/50 p-1",children:oe.map(d=>e.jsxs("button",{type:"button",onClick:()=>y(d.value),className:X("flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",s===d.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[d.icon,d.label]},d.value))})]})})]}):null}function me(){return e.jsx(L,{requiredPermission:{resource:"settings",action:"manage"},children:e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(M,{title:"Settings",description:"Configure your CMS settings and preferences."}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{}),e.jsxs(Y,{children:[e.jsx(te,{className:"size-4"}),e.jsxs(ee,{children:[e.jsx("strong",{children:"Settings not configured."})," To enable CMS settings, export"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"getSettings"}),","," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"updateSettings"}),", and"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"resetSettings"})," ","from your"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"convex/admin.ts"})," ","file."]})]}),e.jsxs(m,{elevation:"base",className:"p-6",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Features"}),e.jsxs(S,{variant:"secondary",className:"gap-1",children:[e.jsx(D,{className:"size-3"}),"Default values"]})]}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Showing default feature flags. Configure settings in your admin API to customize."}),e.jsx("div",{className:"space-y-4",children:["versioning","scheduling","localization","mediaManagement"].map(s=>e.jsxs("div",{className:"flex items-center justify-between opacity-75",children:[e.jsx("div",{children:e.jsx(i,{className:"text-sm font-medium capitalize",children:s})}),e.jsx(v,{checked:b[s],disabled:!0})]},s))})]}),e.jsxs(m,{elevation:"base",className:"p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-foreground",children:"API"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(i,{className:"text-sm font-medium",children:"Convex Deployment URL"}),e.jsx("code",{className:"mt-1 block rounded-md bg-muted px-3 py-2 text-sm",children:"https://majestic-beagle-49.convex.cloud"})]})})]})]})]})})}function ue({api:s}){const{canManageSettings:y}=W(),h=y(),d=U(),l=q(s.getSettings,{}),w=_(s.updateSettings??(()=>{})),T=_(s.resetSettings??(()=>{})),[r,f]=t.useState(null),[u,N]=t.useState(!1),[x,a]=t.useState("idle"),[A,j]=t.useState(null),n=t.useMemo(()=>l?{_id:l._id??null,defaultLocale:l.defaultLocale??g.defaultLocale,availableLocales:l.availableLocales??g.availableLocales,features:{...b,...l.features??{}},updatedBy:l.updatedBy,_creationTime:l._creationTime}:null,[l]);t.useEffect(()=>{n&&!r&&f(n)},[n,r]),t.useEffect(()=>{n&&!u&&f(n)},[n,u]);const P=t.useCallback(c=>{r&&(f({...r,defaultLocale:c}),N(!0),a("idle"))},[r]),I=t.useCallback(async()=>{if(!(!r||!u||!s.updateSettings)){a("saving"),j(null);try{await w({defaultLocale:r.defaultLocale}),a("saved"),N(!1),setTimeout(()=>{a("idle")},3e3)}catch(c){a("error"),j(c instanceof Error?c.message:"Failed to save settings")}}},[r,u,s.updateSettings,w]),F=t.useCallback(async()=>{if(!(!s.resetSettings||!window.confirm("Are you sure you want to reset all settings to their defaults? This action cannot be undone."))){a("saving"),j(null);try{const o=await T({});f({...g,_id:o?._id??null,defaultLocale:o?.defaultLocale??g.defaultLocale,availableLocales:o?.availableLocales??g.availableLocales,features:{...b,...o?.features??{}}}),a("saved"),N(!1),setTimeout(()=>{a("idle")},3e3)}catch(o){a("error"),j(o instanceof Error?o.message:"Failed to reset settings")}}},[s.resetSettings,T]),R=t.useCallback(()=>{n&&(f(n),N(!1),a("idle"),j(null))},[n]);if(l===void 0)return e.jsx(L,{requiredPermission:{resource:"settings",action:"manage"},children:e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(M,{title:"Settings",description:"Configure your CMS settings and preferences."}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading settings..."})]})]})});const z=r??n??g,p=z.features??b;return e.jsx(L,{requiredPermission:{resource:"settings",action:"manage"},children:e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(M,{title:"Settings",description:"Configure your CMS settings and preferences."}),h&&s.updateSettings&&e.jsxs("div",{className:"flex items-center gap-3",children:[x==="saved"&&e.jsxs(S,{variant:"secondary",className:"gap-1 bg-diff-added-bg text-diff-added-foreground",children:[e.jsx(B,{className:"size-3"}),"Settings saved successfully"]}),x==="error"&&e.jsxs(S,{variant:"destructive",className:"gap-1",children:[e.jsx(O,{className:"size-3"}),A||"An error occurred"]}),u&&e.jsx(C,{variant:"secondary",onClick:R,disabled:x==="saving",children:"Discard Changes"}),e.jsx(C,{onClick:I,disabled:!u,loading:x==="saving",children:"Save Changes"})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{}),p.localization&&e.jsxs(m,{elevation:"base",className:"p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-foreground",children:"General"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(i,{className:"text-sm font-medium",children:"Default Locale"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The default language for new content entries."})]}),e.jsxs(G,{value:z.defaultLocale,onValueChange:P,disabled:!h||x==="saving"||!s.updateSettings,children:[e.jsx(V,{className:"w-48",children:e.jsx($,{})}),e.jsx(H,{children:de.map(c=>e.jsx(J,{value:c.value,children:c.label},c.value))})]})]})})]}),e.jsxs(m,{elevation:"base",className:"p-6",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Features"}),e.jsxs(S,{variant:"secondary",className:"gap-1",children:[e.jsx(D,{className:"size-3"}),"Configured in code"]})]}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Feature flags are defined in your Convex configuration and cannot be changed from the UI."}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between opacity-75",children:[e.jsxs("div",{children:[e.jsx(i,{className:"text-sm font-medium",children:"Versioning"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track content history and enable rollback to previous versions"})]}),e.jsx(v,{checked:p.versioning,disabled:!0})]}),e.jsxs("div",{className:"flex items-center justify-between opacity-75",children:[e.jsxs("div",{children:[e.jsx(i,{className:"text-sm font-medium",children:"Scheduling"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Schedule content to publish at a future date and time"})]}),e.jsx(v,{checked:p.scheduling,disabled:!0})]}),e.jsxs("div",{className:"flex items-center justify-between opacity-75",children:[e.jsxs("div",{children:[e.jsx(i,{className:"text-sm font-medium",children:"Localization"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Support multiple languages for content entries"})]}),e.jsx(v,{checked:p.localization,disabled:!0})]}),d.navigation.showMedia&&e.jsxs("div",{className:"flex items-center justify-between opacity-75",children:[e.jsxs("div",{children:[e.jsx(i,{className:"text-sm font-medium",children:"Media Management"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Use the built-in media library for image and file uploads"})]}),e.jsx(v,{checked:p.mediaManagement,disabled:!0})]})]})]}),e.jsxs(m,{elevation:"base",className:"p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-foreground",children:"API"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(i,{className:"text-sm font-medium",children:"Convex Deployment URL"}),e.jsx("code",{className:"mt-1 block rounded-md bg-muted px-3 py-2 text-sm",children:"https://majestic-beagle-49.convex.cloud"})]})})]}),h&&s.resetSettings&&e.jsxs(m,{elevation:"base",className:"border-destructive/50 p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-destructive",children:"Danger Zone"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(i,{className:"text-sm font-medium",children:"Reset to Defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Reset all settings to their default values. This cannot be undone."})]}),e.jsx(C,{variant:"danger",onClick:F,disabled:x==="saving",children:"Reset Settings"})]})]})]})]})})}function xe({api:s,navigation:y}){return s.getSettings?e.jsx(ue,{api:s}):e.jsx(me,{})}function Ne(){const s=K();return e.jsx(xe,{api:Z.admin,navigation:s})}export{Ne as component};
@@ -1 +1 @@
1
- import{r as s,ax as C,aG as I,j as o,az as y,aC as T,aH as H,aI as M,aB as z,h as g}from"./main-CA-4LyFT.js";var b="Switch",[A]=z(b),[U,q]=A(b),P=s.forwardRef((e,a)=>{const{__scopeSwitch:t,name:n,checked:r,defaultChecked:m,required:d,disabled:c,value:u="on",onCheckedChange:k,form:i,...w}=e,[l,p]=s.useState(null),v=C(a,f=>p(f)),x=s.useRef(!1),S=l?i||!!l.closest("form"):!0,[h,N]=I({prop:r,defaultProp:m??!1,onChange:k,caller:b});return o.jsxs(U,{scope:t,checked:h,disabled:c,children:[o.jsx(y.button,{type:"button",role:"switch","aria-checked":h,"aria-required":d,"data-state":_(h),"data-disabled":c?"":void 0,disabled:c,value:u,...w,ref:v,onClick:T(e.onClick,f=>{N(B=>!B),S&&(x.current=f.isPropagationStopped(),x.current||f.stopPropagation())})}),S&&o.jsx(j,{control:l,bubbles:!x.current,name:n,value:u,checked:h,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});P.displayName=b;var E="SwitchThumb",R=s.forwardRef((e,a)=>{const{__scopeSwitch:t,...n}=e,r=q(E,t);return o.jsx(y.span,{"data-state":_(r.checked),"data-disabled":r.disabled?"":void 0,...n,ref:a})});R.displayName=E;var L="SwitchBubbleInput",j=s.forwardRef(({__scopeSwitch:e,control:a,checked:t,bubbles:n=!0,...r},m)=>{const d=s.useRef(null),c=C(d,m),u=H(t),k=M(a);return s.useEffect(()=>{const i=d.current;if(!i)return;const w=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(w,"checked").set;if(u!==t&&p){const v=new Event("click",{bubbles:n});p.call(i,t),i.dispatchEvent(v)}},[u,t,n]),o.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...r,tabIndex:-1,ref:c,style:{...r.style,...k,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});j.displayName=L;function _(e){return e?"checked":"unchecked"}var O=P,D=R;function G({className:e,...a}){return o.jsx(O,{"data-slot":"switch",className:g("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:o.jsx(D,{"data-slot":"switch-thumb",className:g("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{G as S};
1
+ import{r as s,ax as C,aG as I,j as o,az as y,aC as T,aH as H,aI as M,aB as z,n as g}from"./main-B-6700eG.js";var b="Switch",[A]=z(b),[U,q]=A(b),P=s.forwardRef((e,a)=>{const{__scopeSwitch:t,name:n,checked:r,defaultChecked:m,required:d,disabled:c,value:u="on",onCheckedChange:k,form:i,...w}=e,[l,p]=s.useState(null),v=C(a,f=>p(f)),x=s.useRef(!1),S=l?i||!!l.closest("form"):!0,[h,N]=I({prop:r,defaultProp:m??!1,onChange:k,caller:b});return o.jsxs(U,{scope:t,checked:h,disabled:c,children:[o.jsx(y.button,{type:"button",role:"switch","aria-checked":h,"aria-required":d,"data-state":_(h),"data-disabled":c?"":void 0,disabled:c,value:u,...w,ref:v,onClick:T(e.onClick,f=>{N(B=>!B),S&&(x.current=f.isPropagationStopped(),x.current||f.stopPropagation())})}),S&&o.jsx(j,{control:l,bubbles:!x.current,name:n,value:u,checked:h,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});P.displayName=b;var E="SwitchThumb",R=s.forwardRef((e,a)=>{const{__scopeSwitch:t,...n}=e,r=q(E,t);return o.jsx(y.span,{"data-state":_(r.checked),"data-disabled":r.disabled?"":void 0,...n,ref:a})});R.displayName=E;var L="SwitchBubbleInput",j=s.forwardRef(({__scopeSwitch:e,control:a,checked:t,bubbles:n=!0,...r},m)=>{const d=s.useRef(null),c=C(d,m),u=H(t),k=M(a);return s.useEffect(()=>{const i=d.current;if(!i)return;const w=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(w,"checked").set;if(u!==t&&p){const v=new Event("click",{bubbles:n});p.call(i,t),i.dispatchEvent(v)}},[u,t,n]),o.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...r,tabIndex:-1,ref:c,style:{...r.style,...k,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});j.displayName=L;function _(e){return e?"checked":"unchecked"}var O=P,D=R;function G({className:e,...a}){return o.jsx(O,{"data-slot":"switch",className:g("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:o.jsx(D,{"data-slot":"switch-thumb",className:g("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{G as S};
@@ -1 +1 @@
1
- import{l as k,r as u,a as B,j as t,a9 as ee,C as y,h as N,X as z,w as te,ay as se,aG as re,az as T,aJ as ae,aK as ne,aL as oe,aC as $,aM as F,aB as ie,aA as ce}from"./main-CA-4LyFT.js";import{R as le}from"./refresh-cw-sdVUGJNs.js";const de=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],_e=k("chevron-left",de);const ue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Re=k("file",ue);const pe=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Ue=k("music",pe);const me=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ge=k("upload",me);const fe=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],De=k("video",fe);function he(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function ve(r,a=5e3){return r.type.startsWith("image/")?new Promise(s=>{const c=new Image;let l=null;const i=setTimeout(()=>{l&&URL.revokeObjectURL(l),s(void 0)},a);c.onload=()=>{clearTimeout(i),l&&URL.revokeObjectURL(l),s({width:c.naturalWidth,height:c.naturalHeight})},c.onerror=()=>{clearTimeout(i),l&&URL.revokeObjectURL(l),s(void 0)},l=URL.createObjectURL(r),c.src=l}):Promise.resolve(void 0)}function xe(r,a,s,c){return new Promise((l,i)=>{const n=new XMLHttpRequest,g=()=>{n.abort(),i(new DOMException("Upload aborted","AbortError"))};s.addEventListener("abort",g),n.upload.onprogress=h=>{if(h.lengthComputable){const v=Math.round(h.loaded/h.total*80);c(10+v)}},n.onload=()=>{if(s.removeEventListener("abort",g),n.status>=200&&n.status<300)try{const h=JSON.parse(n.responseText);l(h.storageId)}catch{i(new Error("Invalid response from upload server"))}else i(new Error(`Upload failed: ${n.statusText||`HTTP ${n.status}`}`))},n.onerror=()=>{s.removeEventListener("abort",g),i(new Error("Network error during upload"))},n.ontimeout=()=>{s.removeEventListener("abort",g),i(new Error("Upload timed out"))},n.open("POST",r),n.setRequestHeader("Content-Type",a.type),n.send(a)})}function be(r,a){switch(a.type){case"ADD_FILES":{const s=a.files.map(c=>({id:he(),file:c,status:"pending",progress:0}));return[...r,...s]}case"UPDATE_FILE":return r.map(s=>s.id===a.id?{...s,...a.updates}:s);case"RETRY_FILE":return r.map(s=>s.id===a.id?{...s,status:"pending",progress:0,error:void 0}:s);case"REMOVE_FILE":return r.filter(s=>s.id!==a.id);case"CLEAR_COMPLETED":return r.filter(s=>s.status==="pending"||s.status==="uploading");case"CLEAR_ALL":return[];case"CANCEL_FILE":return r.map(s=>s.id===a.id&&(s.status==="pending"||s.status==="uploading")?{...s,status:"cancelled",error:"Upload cancelled"}:s);case"CANCEL_ALL":return r.map(s=>s.status==="pending"||s.status==="uploading"?{...s,status:"cancelled",error:"Upload cancelled"}:s);default:return r}}function Ce(r){const{maxConcurrent:a=3,metadata:s,onComplete:c,onError:l}=r,[i,n]=u.useReducer(be,[]),g=B(r.getUploadUrl),h=B(r.createAsset),v=u.useRef(0),p=u.useRef(new Map),m=u.useRef(!1),x=u.useCallback(async o=>{const f=new AbortController;p.current.set(o.id,f),n({type:"UPDATE_FILE",id:o.id,updates:{status:"uploading",progress:0}});try{const j=await g({});n({type:"UPDATE_FILE",id:o.id,updates:{progress:5}});const e=await xe(j,o.file,f.signal,L=>{n({type:"UPDATE_FILE",id:o.id,updates:{progress:L}})});n({type:"UPDATE_FILE",id:o.id,updates:{progress:90}});const C=await ve(o.file),b=await h({storageId:e,name:o.file.name,mimeType:o.file.type,size:o.file.size,...C,...s});n({type:"UPDATE_FILE",id:o.id,updates:{status:"complete",progress:100,result:b}})}catch(j){const e=j instanceof Error?j:new Error(String(j));if(e.name==="AbortError")n({type:"UPDATE_FILE",id:o.id,updates:{status:"cancelled",error:"Upload cancelled"}});else{const C={...o,status:"error",error:e.message};n({type:"UPDATE_FILE",id:o.id,updates:{status:"error",error:e.message}}),l?.(C)}}finally{p.current.delete(o.id),v.current--}},[g,h,s,l]),d=u.useCallback(()=>{if(m.current)return;m.current=!0;const o=i.filter(f=>f.status==="pending");for(;v.current<a&&o.length>0;){const f=o.shift();v.current++,x(f)}m.current=!1,v.current===0&&i.length>0&&i.every(f=>f.status!=="pending"&&f.status!=="uploading")&&c?.(i)},[i,a,x,c]);u.useEffect(()=>{i.some(o=>o.status==="pending")&&v.current<a&&d()},[i,a,d]);const A=u.useCallback(o=>{n({type:"ADD_FILES",files:o})},[]),E=u.useCallback(o=>{const f=p.current.get(o);f&&f.abort(),n({type:"CANCEL_FILE",id:o})},[]),_=u.useCallback(()=>{p.current.forEach(o=>o.abort()),n({type:"CANCEL_ALL"})},[]),R=u.useCallback(o=>{n({type:"RETRY_FILE",id:o})},[]),U=u.useCallback(()=>{n({type:"CLEAR_COMPLETED"})},[]),D=u.useCallback(()=>{p.current.forEach(o=>o.abort()),n({type:"CLEAR_ALL"})},[]),I=i.some(o=>o.status==="uploading"),M=i.length>0?Math.round(i.reduce((o,f)=>o+f.progress,0)/i.length):0;return{files:i,addFiles:A,cancelFile:E,cancelAll:_,retryFile:R,clearCompleted:U,clearAll:D,isUploading:I,overallProgress:M}}function S(r){if(r===0)return"0 B";const a=1024,s=["B","KB","MB","GB"],c=Math.floor(Math.log(r)/Math.log(a));return`${parseFloat((r/Math.pow(a,c)).toFixed(1))} ${s[c]}`}function je(r,a){return a.length===0?!0:a.some(s=>{if(s.endsWith("/*")){const c=s.slice(0,-2);return r.startsWith(c+"/")}return r===s})}function Ie({onUploadComplete:r,currentFolderId:a,generateUploadUrl:s,createAsset:c,maxFileSize:l,allowedMimeTypes:i=[],maxConcurrentUploads:n=3,onError:g}){const[h,v]=u.useState(!1),[p,m]=u.useState(new Map),x=u.useRef(null),d=Ce({getUploadUrl:s,createAsset:c,maxConcurrent:n,metadata:a?{parentId:a}:void 0,onComplete:e=>{const C=e.map(b=>({filename:b.file.name,storageId:b.result?String(b.result._id||""):"",success:b.status==="complete",error:b.error}));r(C)},onError:e=>{g?.(e.error||"Upload failed",e.file.name)}}),A=u.useCallback(e=>l&&e.size>l?`File exceeds maximum size of ${S(l)}`:i.length>0&&!je(e.type,i)?`File type ${e.type||"unknown"} is not allowed`:null,[l,i]),E=u.useCallback(e=>{const C=Array.from(e),b=new Map,L=[];for(const P of C){const V=A(P);V?b.set(P.name,V):L.push(P)}m(b),L.length>0&&d.addFiles(L)},[A,d]),_=u.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!0)},[]),R=u.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!1)},[]),U=u.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),D=u.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!1),e.dataTransfer.files?.length&&E(e.dataTransfer.files)},[E]),I=u.useCallback(e=>{e.target.files?.length&&(E(e.target.files),e.target.value="")},[E]),M=e=>{switch(e){case"complete":return t.jsx(te,{className:"size-4 text-success"});case"error":case"cancelled":return t.jsx(z,{className:"size-4 text-destructive"});case"uploading":return t.jsx("div",{className:"size-4 animate-spin rounded-full border-2 border-muted border-t-primary"});default:return t.jsx("div",{className:"size-4 rounded-full border-2 border-muted"})}},o=d.files.filter(e=>e.status==="complete").length,f=d.files.filter(e=>e.status==="error"||e.status==="cancelled").length,j=o>0||f>0;return t.jsxs("div",{className:"space-y-4",children:[p.size>0&&t.jsxs("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(ee,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),t.jsx("div",{className:"flex-1 space-y-1",children:Array.from(p.entries()).map(([e,C])=>t.jsxs("p",{className:"text-sm text-destructive",children:[t.jsxs("span",{className:"font-medium",children:[e,":"]})," ",C]},e))})]}),t.jsx(y,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>m(new Map),children:"Dismiss"})]}),!d.isUploading&&d.files.length===0&&t.jsxs("div",{className:N("flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-8 text-center transition-colors",h?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50 hover:bg-muted/50"),onClick:()=>x.current?.click(),onDragEnter:_,onDragLeave:R,onDragOver:U,onDrop:D,children:[t.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-muted",children:t.jsx(ge,{className:"size-6 text-muted-foreground"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:h?"Drop files here":"Drag and drop files here"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"or click to browse"})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Supports images, videos, documents, and more",l&&` (max ${S(l)} per file)`]})]}),d.files.length>0&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsxs("span",{className:"font-medium",children:[d.files.length," file",d.files.length!==1?"s":""]}),d.isUploading&&t.jsxs("span",{className:"text-muted-foreground",children:[d.overallProgress,"% complete"]}),!d.isUploading&&j&&t.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&t.jsxs("span",{className:"text-success",children:[o," completed"]}),f>0&&t.jsxs("span",{className:"text-destructive",children:[f," failed"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[!d.isUploading&&t.jsx(y,{variant:"outline",size:"sm",onClick:()=>x.current?.click(),children:"Add More"}),d.isUploading&&t.jsx(y,{variant:"outline",size:"sm",onClick:d.cancelAll,children:"Cancel All"}),j&&!d.isUploading&&t.jsx(y,{variant:"ghost",size:"sm",onClick:d.clearCompleted,children:"Clear Done"})]})]}),d.isUploading&&t.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:t.jsx("div",{className:"h-full bg-primary transition-all duration-300",style:{width:`${d.overallProgress}%`}})}),t.jsx("div",{className:"space-y-2",children:d.files.map(e=>t.jsxs("div",{className:N("flex items-center gap-3 rounded-lg border bg-card p-3",e.status==="error"&&"border-diff-removed-border bg-diff-removed-bg",e.status==="complete"&&"border-diff-added-border bg-diff-added-bg"),children:[t.jsx("div",{className:"shrink-0",children:M(e.status)}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium",title:e.file.name,children:e.file.name}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:S(e.file.size)}),e.error&&t.jsx("span",{className:"text-xs text-destructive",children:e.error})]})]}),e.status==="uploading"&&t.jsxs("div",{className:"flex w-20 items-center gap-2",children:[t.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",children:t.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${e.progress}%`}})}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.progress,"%"]})]}),t.jsxs("div",{className:"shrink-0",children:[e.status==="pending"&&!d.isUploading&&t.jsx(y,{variant:"ghost",size:"icon-sm",onClick:()=>d.cancelFile(e.id),title:"Remove",children:t.jsx(z,{className:"size-4"})}),(e.status==="uploading"||e.status==="pending")&&d.isUploading&&t.jsx(y,{variant:"ghost",size:"icon-sm",onClick:()=>d.cancelFile(e.id),title:"Cancel",children:t.jsx(z,{className:"size-4"})}),(e.status==="error"||e.status==="cancelled")&&!d.isUploading&&t.jsx(y,{variant:"ghost",size:"icon-sm",onClick:()=>d.retryFile(e.id),title:"Retry",children:t.jsx(le,{className:"size-4"})})]})]},e.id))})]}),t.jsx("input",{ref:x,type:"file",multiple:!0,onChange:I,className:"hidden",accept:i.length>0?i.join(","):void 0})]})}var w="Tabs",[ye]=ie(w,[F]),G=F(),[Ee,O]=ye(w),H=u.forwardRef((r,a)=>{const{__scopeTabs:s,value:c,onValueChange:l,defaultValue:i,orientation:n="horizontal",dir:g,activationMode:h="automatic",...v}=r,p=se(g),[m,x]=re({prop:c,onChange:l,defaultProp:i??"",caller:w});return t.jsx(Ee,{scope:s,baseId:ae(),value:m,onValueChange:x,orientation:n,dir:p,activationMode:h,children:t.jsx(T.div,{dir:p,"data-orientation":n,...v,ref:a})})});H.displayName=w;var K="TabsList",W=u.forwardRef((r,a)=>{const{__scopeTabs:s,loop:c=!0,...l}=r,i=O(K,s),n=G(s);return t.jsx(ne,{asChild:!0,...n,orientation:i.orientation,dir:i.dir,loop:c,children:t.jsx(T.div,{role:"tablist","aria-orientation":i.orientation,...l,ref:a})})});W.displayName=K;var X="TabsTrigger",J=u.forwardRef((r,a)=>{const{__scopeTabs:s,value:c,disabled:l=!1,...i}=r,n=O(X,s),g=G(s),h=Z(n.baseId,c),v=q(n.baseId,c),p=c===n.value;return t.jsx(oe,{asChild:!0,...g,focusable:!l,active:p,children:t.jsx(T.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":v,"data-state":p?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:h,...i,ref:a,onMouseDown:$(r.onMouseDown,m=>{!l&&m.button===0&&m.ctrlKey===!1?n.onValueChange(c):m.preventDefault()}),onKeyDown:$(r.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&n.onValueChange(c)}),onFocus:$(r.onFocus,()=>{const m=n.activationMode!=="manual";!p&&!l&&m&&n.onValueChange(c)})})})});J.displayName=X;var Q="TabsContent",Y=u.forwardRef((r,a)=>{const{__scopeTabs:s,value:c,forceMount:l,children:i,...n}=r,g=O(Q,s),h=Z(g.baseId,c),v=q(g.baseId,c),p=c===g.value,m=u.useRef(p);return u.useEffect(()=>{const x=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(x)},[]),t.jsx(ce,{present:l||p,children:({present:x})=>t.jsx(T.div,{"data-state":p?"active":"inactive","data-orientation":g.orientation,role:"tabpanel","aria-labelledby":h,hidden:!x,id:v,tabIndex:0,...n,ref:a,style:{...r.style,animationDuration:m.current?"0s":void 0},children:x&&i})})});Y.displayName=Q;function Z(r,a){return`${r}-trigger-${a}`}function q(r,a){return`${r}-content-${a}`}var Ne=H,Le=W,ke=J,Ae=Y;function Me({className:r,...a}){return t.jsx(Ne,{"data-slot":"tabs",className:N("flex flex-col gap-2",r),...a})}function Pe({className:r,...a}){return t.jsx(Le,{"data-slot":"tabs-list",className:N("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",r),...a})}function ze({className:r,...a}){return t.jsx(ke,{"data-slot":"tabs-trigger",className:N("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",r),...a})}function $e({className:r,...a}){return t.jsx(Ae,{"data-slot":"tabs-content",className:N("flex-1 outline-none",r),...a})}export{_e as C,Re as F,Ue as M,Me as T,ge as U,De as V,Pe as a,ze as b,Ie as c,$e as d};
1
+ import{e as k,r as u,a as B,j as t,aa as ee,C as y,n as N,X as z,q as te,ay as se,aG as re,az as T,aJ as ae,aK as ne,aL as oe,aC as $,aM as F,aB as ie,aA as ce}from"./main-B-6700eG.js";import{R as le}from"./refresh-cw-BrXg9a2r.js";const de=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],_e=k("chevron-left",de);const ue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Re=k("file",ue);const pe=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Ue=k("music",pe);const me=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ge=k("upload",me);const fe=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],De=k("video",fe);function he(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function ve(r,a=5e3){return r.type.startsWith("image/")?new Promise(s=>{const c=new Image;let l=null;const i=setTimeout(()=>{l&&URL.revokeObjectURL(l),s(void 0)},a);c.onload=()=>{clearTimeout(i),l&&URL.revokeObjectURL(l),s({width:c.naturalWidth,height:c.naturalHeight})},c.onerror=()=>{clearTimeout(i),l&&URL.revokeObjectURL(l),s(void 0)},l=URL.createObjectURL(r),c.src=l}):Promise.resolve(void 0)}function xe(r,a,s,c){return new Promise((l,i)=>{const n=new XMLHttpRequest,g=()=>{n.abort(),i(new DOMException("Upload aborted","AbortError"))};s.addEventListener("abort",g),n.upload.onprogress=h=>{if(h.lengthComputable){const v=Math.round(h.loaded/h.total*80);c(10+v)}},n.onload=()=>{if(s.removeEventListener("abort",g),n.status>=200&&n.status<300)try{const h=JSON.parse(n.responseText);l(h.storageId)}catch{i(new Error("Invalid response from upload server"))}else i(new Error(`Upload failed: ${n.statusText||`HTTP ${n.status}`}`))},n.onerror=()=>{s.removeEventListener("abort",g),i(new Error("Network error during upload"))},n.ontimeout=()=>{s.removeEventListener("abort",g),i(new Error("Upload timed out"))},n.open("POST",r),n.setRequestHeader("Content-Type",a.type),n.send(a)})}function be(r,a){switch(a.type){case"ADD_FILES":{const s=a.files.map(c=>({id:he(),file:c,status:"pending",progress:0}));return[...r,...s]}case"UPDATE_FILE":return r.map(s=>s.id===a.id?{...s,...a.updates}:s);case"RETRY_FILE":return r.map(s=>s.id===a.id?{...s,status:"pending",progress:0,error:void 0}:s);case"REMOVE_FILE":return r.filter(s=>s.id!==a.id);case"CLEAR_COMPLETED":return r.filter(s=>s.status==="pending"||s.status==="uploading");case"CLEAR_ALL":return[];case"CANCEL_FILE":return r.map(s=>s.id===a.id&&(s.status==="pending"||s.status==="uploading")?{...s,status:"cancelled",error:"Upload cancelled"}:s);case"CANCEL_ALL":return r.map(s=>s.status==="pending"||s.status==="uploading"?{...s,status:"cancelled",error:"Upload cancelled"}:s);default:return r}}function Ce(r){const{maxConcurrent:a=3,metadata:s,onComplete:c,onError:l}=r,[i,n]=u.useReducer(be,[]),g=B(r.getUploadUrl),h=B(r.createAsset),v=u.useRef(0),p=u.useRef(new Map),m=u.useRef(!1),x=u.useCallback(async o=>{const f=new AbortController;p.current.set(o.id,f),n({type:"UPDATE_FILE",id:o.id,updates:{status:"uploading",progress:0}});try{const j=await g({});n({type:"UPDATE_FILE",id:o.id,updates:{progress:5}});const e=await xe(j,o.file,f.signal,L=>{n({type:"UPDATE_FILE",id:o.id,updates:{progress:L}})});n({type:"UPDATE_FILE",id:o.id,updates:{progress:90}});const C=await ve(o.file),b=await h({storageId:e,name:o.file.name,mimeType:o.file.type,size:o.file.size,...C,...s});n({type:"UPDATE_FILE",id:o.id,updates:{status:"complete",progress:100,result:b}})}catch(j){const e=j instanceof Error?j:new Error(String(j));if(e.name==="AbortError")n({type:"UPDATE_FILE",id:o.id,updates:{status:"cancelled",error:"Upload cancelled"}});else{const C={...o,status:"error",error:e.message};n({type:"UPDATE_FILE",id:o.id,updates:{status:"error",error:e.message}}),l?.(C)}}finally{p.current.delete(o.id),v.current--}},[g,h,s,l]),d=u.useCallback(()=>{if(m.current)return;m.current=!0;const o=i.filter(f=>f.status==="pending");for(;v.current<a&&o.length>0;){const f=o.shift();v.current++,x(f)}m.current=!1,v.current===0&&i.length>0&&i.every(f=>f.status!=="pending"&&f.status!=="uploading")&&c?.(i)},[i,a,x,c]);u.useEffect(()=>{i.some(o=>o.status==="pending")&&v.current<a&&d()},[i,a,d]);const A=u.useCallback(o=>{n({type:"ADD_FILES",files:o})},[]),E=u.useCallback(o=>{const f=p.current.get(o);f&&f.abort(),n({type:"CANCEL_FILE",id:o})},[]),_=u.useCallback(()=>{p.current.forEach(o=>o.abort()),n({type:"CANCEL_ALL"})},[]),R=u.useCallback(o=>{n({type:"RETRY_FILE",id:o})},[]),U=u.useCallback(()=>{n({type:"CLEAR_COMPLETED"})},[]),D=u.useCallback(()=>{p.current.forEach(o=>o.abort()),n({type:"CLEAR_ALL"})},[]),I=i.some(o=>o.status==="uploading"),M=i.length>0?Math.round(i.reduce((o,f)=>o+f.progress,0)/i.length):0;return{files:i,addFiles:A,cancelFile:E,cancelAll:_,retryFile:R,clearCompleted:U,clearAll:D,isUploading:I,overallProgress:M}}function S(r){if(r===0)return"0 B";const a=1024,s=["B","KB","MB","GB"],c=Math.floor(Math.log(r)/Math.log(a));return`${parseFloat((r/Math.pow(a,c)).toFixed(1))} ${s[c]}`}function je(r,a){return a.length===0?!0:a.some(s=>{if(s.endsWith("/*")){const c=s.slice(0,-2);return r.startsWith(c+"/")}return r===s})}function Ie({onUploadComplete:r,currentFolderId:a,generateUploadUrl:s,createAsset:c,maxFileSize:l,allowedMimeTypes:i=[],maxConcurrentUploads:n=3,onError:g}){const[h,v]=u.useState(!1),[p,m]=u.useState(new Map),x=u.useRef(null),d=Ce({getUploadUrl:s,createAsset:c,maxConcurrent:n,metadata:a?{parentId:a}:void 0,onComplete:e=>{const C=e.map(b=>({filename:b.file.name,storageId:b.result?String(b.result._id||""):"",success:b.status==="complete",error:b.error}));r(C)},onError:e=>{g?.(e.error||"Upload failed",e.file.name)}}),A=u.useCallback(e=>l&&e.size>l?`File exceeds maximum size of ${S(l)}`:i.length>0&&!je(e.type,i)?`File type ${e.type||"unknown"} is not allowed`:null,[l,i]),E=u.useCallback(e=>{const C=Array.from(e),b=new Map,L=[];for(const P of C){const V=A(P);V?b.set(P.name,V):L.push(P)}m(b),L.length>0&&d.addFiles(L)},[A,d]),_=u.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!0)},[]),R=u.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!1)},[]),U=u.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),D=u.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!1),e.dataTransfer.files?.length&&E(e.dataTransfer.files)},[E]),I=u.useCallback(e=>{e.target.files?.length&&(E(e.target.files),e.target.value="")},[E]),M=e=>{switch(e){case"complete":return t.jsx(te,{className:"size-4 text-success"});case"error":case"cancelled":return t.jsx(z,{className:"size-4 text-destructive"});case"uploading":return t.jsx("div",{className:"size-4 animate-spin rounded-full border-2 border-muted border-t-primary"});default:return t.jsx("div",{className:"size-4 rounded-full border-2 border-muted"})}},o=d.files.filter(e=>e.status==="complete").length,f=d.files.filter(e=>e.status==="error"||e.status==="cancelled").length,j=o>0||f>0;return t.jsxs("div",{className:"space-y-4",children:[p.size>0&&t.jsxs("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(ee,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),t.jsx("div",{className:"flex-1 space-y-1",children:Array.from(p.entries()).map(([e,C])=>t.jsxs("p",{className:"text-sm text-destructive",children:[t.jsxs("span",{className:"font-medium",children:[e,":"]})," ",C]},e))})]}),t.jsx(y,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>m(new Map),children:"Dismiss"})]}),!d.isUploading&&d.files.length===0&&t.jsxs("div",{className:N("flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-8 text-center transition-colors",h?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50 hover:bg-muted/50"),onClick:()=>x.current?.click(),onDragEnter:_,onDragLeave:R,onDragOver:U,onDrop:D,children:[t.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-muted",children:t.jsx(ge,{className:"size-6 text-muted-foreground"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:h?"Drop files here":"Drag and drop files here"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"or click to browse"})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Supports images, videos, documents, and more",l&&` (max ${S(l)} per file)`]})]}),d.files.length>0&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsxs("span",{className:"font-medium",children:[d.files.length," file",d.files.length!==1?"s":""]}),d.isUploading&&t.jsxs("span",{className:"text-muted-foreground",children:[d.overallProgress,"% complete"]}),!d.isUploading&&j&&t.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&t.jsxs("span",{className:"text-success",children:[o," completed"]}),f>0&&t.jsxs("span",{className:"text-destructive",children:[f," failed"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[!d.isUploading&&t.jsx(y,{variant:"outline",size:"sm",onClick:()=>x.current?.click(),children:"Add More"}),d.isUploading&&t.jsx(y,{variant:"outline",size:"sm",onClick:d.cancelAll,children:"Cancel All"}),j&&!d.isUploading&&t.jsx(y,{variant:"ghost",size:"sm",onClick:d.clearCompleted,children:"Clear Done"})]})]}),d.isUploading&&t.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:t.jsx("div",{className:"h-full bg-primary transition-all duration-300",style:{width:`${d.overallProgress}%`}})}),t.jsx("div",{className:"space-y-2",children:d.files.map(e=>t.jsxs("div",{className:N("flex items-center gap-3 rounded-lg border bg-card p-3",e.status==="error"&&"border-diff-removed-border bg-diff-removed-bg",e.status==="complete"&&"border-diff-added-border bg-diff-added-bg"),children:[t.jsx("div",{className:"shrink-0",children:M(e.status)}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium",title:e.file.name,children:e.file.name}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:S(e.file.size)}),e.error&&t.jsx("span",{className:"text-xs text-destructive",children:e.error})]})]}),e.status==="uploading"&&t.jsxs("div",{className:"flex w-20 items-center gap-2",children:[t.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",children:t.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${e.progress}%`}})}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.progress,"%"]})]}),t.jsxs("div",{className:"shrink-0",children:[e.status==="pending"&&!d.isUploading&&t.jsx(y,{variant:"ghost",size:"icon-sm",onClick:()=>d.cancelFile(e.id),title:"Remove",children:t.jsx(z,{className:"size-4"})}),(e.status==="uploading"||e.status==="pending")&&d.isUploading&&t.jsx(y,{variant:"ghost",size:"icon-sm",onClick:()=>d.cancelFile(e.id),title:"Cancel",children:t.jsx(z,{className:"size-4"})}),(e.status==="error"||e.status==="cancelled")&&!d.isUploading&&t.jsx(y,{variant:"ghost",size:"icon-sm",onClick:()=>d.retryFile(e.id),title:"Retry",children:t.jsx(le,{className:"size-4"})})]})]},e.id))})]}),t.jsx("input",{ref:x,type:"file",multiple:!0,onChange:I,className:"hidden",accept:i.length>0?i.join(","):void 0})]})}var w="Tabs",[ye]=ie(w,[F]),G=F(),[Ee,O]=ye(w),H=u.forwardRef((r,a)=>{const{__scopeTabs:s,value:c,onValueChange:l,defaultValue:i,orientation:n="horizontal",dir:g,activationMode:h="automatic",...v}=r,p=se(g),[m,x]=re({prop:c,onChange:l,defaultProp:i??"",caller:w});return t.jsx(Ee,{scope:s,baseId:ae(),value:m,onValueChange:x,orientation:n,dir:p,activationMode:h,children:t.jsx(T.div,{dir:p,"data-orientation":n,...v,ref:a})})});H.displayName=w;var K="TabsList",W=u.forwardRef((r,a)=>{const{__scopeTabs:s,loop:c=!0,...l}=r,i=O(K,s),n=G(s);return t.jsx(ne,{asChild:!0,...n,orientation:i.orientation,dir:i.dir,loop:c,children:t.jsx(T.div,{role:"tablist","aria-orientation":i.orientation,...l,ref:a})})});W.displayName=K;var X="TabsTrigger",J=u.forwardRef((r,a)=>{const{__scopeTabs:s,value:c,disabled:l=!1,...i}=r,n=O(X,s),g=G(s),h=Z(n.baseId,c),v=q(n.baseId,c),p=c===n.value;return t.jsx(oe,{asChild:!0,...g,focusable:!l,active:p,children:t.jsx(T.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":v,"data-state":p?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:h,...i,ref:a,onMouseDown:$(r.onMouseDown,m=>{!l&&m.button===0&&m.ctrlKey===!1?n.onValueChange(c):m.preventDefault()}),onKeyDown:$(r.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&n.onValueChange(c)}),onFocus:$(r.onFocus,()=>{const m=n.activationMode!=="manual";!p&&!l&&m&&n.onValueChange(c)})})})});J.displayName=X;var Q="TabsContent",Y=u.forwardRef((r,a)=>{const{__scopeTabs:s,value:c,forceMount:l,children:i,...n}=r,g=O(Q,s),h=Z(g.baseId,c),v=q(g.baseId,c),p=c===g.value,m=u.useRef(p);return u.useEffect(()=>{const x=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(x)},[]),t.jsx(ce,{present:l||p,children:({present:x})=>t.jsx(T.div,{"data-state":p?"active":"inactive","data-orientation":g.orientation,role:"tabpanel","aria-labelledby":h,hidden:!x,id:v,tabIndex:0,...n,ref:a,style:{...r.style,animationDuration:m.current?"0s":void 0},children:x&&i})})});Y.displayName=Q;function Z(r,a){return`${r}-trigger-${a}`}function q(r,a){return`${r}-content-${a}`}var Ne=H,Le=W,ke=J,Ae=Y;function Me({className:r,...a}){return t.jsx(Ne,{"data-slot":"tabs",className:N("flex flex-col gap-2",r),...a})}function Pe({className:r,...a}){return t.jsx(Le,{"data-slot":"tabs-list",className:N("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",r),...a})}function ze({className:r,...a}){return t.jsx(ke,{"data-slot":"tabs-trigger",className:N("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",r),...a})}function $e({className:r,...a}){return t.jsx(Ae,{"data-slot":"tabs-content",className:N("flex-1 outline-none",r),...a})}export{_e as C,Re as F,Ue as M,Me as T,ge as U,De as V,Pe as a,ze as b,Ie as c,$e as d};
@@ -0,0 +1 @@
1
+ import{ae as d,r as s,j as g,I as f,n as y,af as k,ag as b}from"./main-B-6700eG.js";function C(a){return d({select:t=>t.location})}const h=s.forwardRef(({className:a,error:t,...n},o)=>g.jsx(f,{ref:o,className:y(t&&"border-destructive focus-visible:ring-destructive",a),"aria-invalid":t,...n}));h.displayName="CmsInput";function I(){const a=k(),t=C(),n=b({strict:!1}),o=s.useCallback((e,p)=>{let c=e;if(p)for(const[m,v]of Object.entries(p))c=c.replace(`:${m}`,v).replace(`$${m}`,v);a({to:c})},[a]),r=s.useCallback(e=>{a({to:"/entries/$entryId",params:{entryId:e}})},[a]),i=s.useCallback(e=>{a({to:"/entries/type/$contentTypeId",params:{contentTypeId:e}})},[a]),u=s.useCallback(e=>{a({to:"/entries/new/$contentTypeId",params:{contentTypeId:e}})},[a]),l=s.useCallback(()=>{window.history.back()},[]);return s.useMemo(()=>({navigate:o,currentRoute:t.pathname,params:n??{},canGoBack:window.history.length>1,goBack:l,navigateToEntry:r,navigateToContentType:i,navigateToNewEntry:u}),[o,t.pathname,n,l,r,i,u])}export{h as C,I as u};
@@ -1 +1 @@
1
- import{l as W,r as t,m as q,a as I,j as e,n as R,L as f,I as A,o as Z,g as _,C as N,u as M,P as L,p as X,i as U,q as Y,s as ee,h as P,T as V,t as H,k as se}from"./main-CA-4LyFT.js";import{C as G}from"./CmsEmptyState-DTlpzjOI.js";import{P as J}from"./pencil-gAL0R34f.js";import{C as ae}from"./CmsPageHeader-0REGRH4X.js";import{C as B}from"./CmsSurface-BHmvNai4.js";import{B as Q}from"./badge-C6qt24oj.js";import{S as te}from"./scroll-area-CJBhf9pf.js";import{u as re}from"./tanstack-adapter-BRt2CUCw.js";const ie=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],ne=W("folder-tree",ie);function le({taxonomy:i,onSave:c,onCancel:d}){const x=!!i,[l,C]=t.useState({name:i?.name??"",displayName:i?.displayName??"",description:i?.description??"",isHierarchical:i?.isHierarchical??!1,allowInlineCreation:i?.allowInlineCreation??!0,isActive:i?.isActive??!0,icon:i?.icon??"",sortOrder:i?.sortOrder??0}),[g,r]=t.useState({}),[u,p]=t.useState(!1),[O,m]=t.useState(null),[y,S]=t.useState(!1),w=q(),k=I(w.createTaxonomy),z=I(w.updateTaxonomy);t.useEffect(()=>{i&&C({name:i.name,displayName:i.displayName,description:i.description??"",isHierarchical:i.isHierarchical,allowInlineCreation:i.allowInlineCreation,isActive:i.isActive,icon:i.icon??"",sortOrder:i.sortOrder??0})},[i]);const h=t.useCallback((s,T)=>{C(E=>({...E,[s]:T})),r(E=>{const{[s]:n,...a}=E;return a})},[]),b=t.useCallback(s=>s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),F=t.useCallback(s=>{h("displayName",s),!x&&!y&&h("name",b(s))},[h,x,y,b]),v=t.useCallback(()=>{const s={};return l.name.trim()?/^[a-z][a-z0-9-]*$/.test(l.name)||(s.name="Slug must start with a letter and contain only lowercase letters, numbers, and hyphens"):s.name="Slug is required",l.displayName.trim()||(s.displayName="Display name is required"),r(s),Object.keys(s).length===0},[l]),o=t.useCallback(async s=>{if(s.preventDefault(),!!v()){p(!0),m(null);try{x&&i?await z({id:i._id,displayName:l.displayName,description:l.description||void 0,allowInlineCreation:l.allowInlineCreation,icon:l.icon||void 0,sortOrder:l.sortOrder,isActive:l.isActive}):await k({name:l.name,displayName:l.displayName,description:l.description||void 0,isHierarchical:l.isHierarchical,allowInlineCreation:l.allowInlineCreation,icon:l.icon||void 0,sortOrder:l.sortOrder}),c()}catch(T){const E=T instanceof Error?T.message:"Failed to save taxonomy";m(E)}finally{p(!1)}}},[v,x,i,l,k,z,c]);return e.jsx(R,{open:!0,onOpenChange:s=>!s&&!u&&d(),title:x?"Edit Taxonomy":"Create Taxonomy",size:"lg",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:d,disabled:u,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:o,loading:u,children:x?"Save Changes":"Create Taxonomy"})]}),children:e.jsxs("form",{onSubmit:o,className:"space-y-4",children:[O&&e.jsx("div",{className:"diff-removed rounded-lg border px-3 py-2 text-sm",children:O}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"displayName",children:["Display Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"displayName",value:l.displayName,onChange:s=>F(s.target.value),placeholder:"e.g., Categories, Tags",disabled:u,className:g.displayName?"border-destructive":""}),g.displayName&&e.jsx("p",{className:"text-xs text-destructive",children:g.displayName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"name",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"name",value:l.name,onChange:s=>{h("name",s.target.value.toLowerCase()),S(!0)},placeholder:"e.g., categories, tags",disabled:u||x,className:g.name?"border-destructive":""}),g.name&&e.jsx("p",{className:"text-xs text-destructive",children:g.name}),x&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"description",children:"Description"}),e.jsx(Z,{id:"description",value:l.description,onChange:s=>h("description",s.target.value),placeholder:"Optional description",rows:2,disabled:u})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"icon",children:"Icon"}),e.jsx(A,{id:"icon",value:l.icon,onChange:s=>h("icon",s.target.value),placeholder:"e.g., 🏷️ or folder",disabled:u}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emoji or icon name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"sortOrder",children:"Sort Order"}),e.jsx(A,{id:"sortOrder",type:"number",value:l.sortOrder,onChange:s=>h("sortOrder",parseInt(s.target.value)||0),disabled:u})]})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"isHierarchical",checked:l.isHierarchical,onCheckedChange:s=>h("isHierarchical",s),disabled:u||x}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isHierarchical",className:"cursor-pointer font-medium",children:"Hierarchical"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terms can have parent-child relationships (like categories)"}),x&&e.jsx("p",{className:"text-xs text-warning",children:"Hierarchy type cannot be changed after creation"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"allowInlineCreation",checked:l.allowInlineCreation,onCheckedChange:s=>h("allowInlineCreation",s),disabled:u}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"allowInlineCreation",className:"cursor-pointer font-medium",children:"Allow inline creation"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Users can create new terms while editing content"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"isActive",checked:l.isActive,onCheckedChange:s=>h("isActive",s),disabled:u}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isActive",className:"cursor-pointer font-medium",children:"Active"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Inactive taxonomies are hidden from content editors"})]})]})]})]})})}function oe({taxonomyId:i,isHierarchical:c,allowInlineCreation:d}){const x=q(),[l,C]=t.useState(new Set),[g,r]=t.useState(null),[u,p]=t.useState(!1),[O,m]=t.useState(),[y,S]=t.useState(null),[w,k]=t.useState(null),z=c?M(x.getTermsHierarchy,{taxonomyId:i}):M(x.listTerms,{taxonomyId:i}),h=I(x.deleteTerm),b=c?z:z?.page,F=b===void 0,v=t.useCallback(n=>{C(a=>{const j=new Set(a);return j.has(n)?j.delete(n):j.add(n),j})},[]),o=t.useCallback(n=>{m(n),r(null),p(!0)},[]),s=t.useCallback(n=>{r(n),p(!0)},[]),T=t.useCallback(async n=>{k(null);try{await h({id:n,cascade:!0}),S(null)}catch(a){const j=a instanceof Error?a.message:"Failed to delete term";k(j)}},[h]),E=(n,a=0)=>{const j=n.children&&n.children.length>0,D=l.has(n._id);return e.jsxs("div",{className:"border-b border-border/50 last:border-0",children:[e.jsxs("div",{className:P("group flex items-center gap-2 py-2 pr-2 transition-colors hover:bg-muted/50",a>0&&"border-l-2 border-muted"),style:{paddingLeft:`${a*24+8}px`},children:[c&&e.jsx("button",{type:"button",onClick:()=>v(n._id),disabled:!j,className:P("flex size-5 items-center justify-center rounded transition-colors",j?"text-muted-foreground hover:bg-muted hover:text-foreground":"invisible"),"aria-expanded":D,children:j&&(D?e.jsx(Y,{className:"size-4"}):e.jsx(ee,{className:"size-4"}))}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.color&&e.jsx("span",{className:"size-3 shrink-0 rounded-full",style:{backgroundColor:n.color}}),n.icon&&e.jsx("span",{className:"shrink-0 text-sm",children:n.icon}),e.jsx("span",{className:"truncate font-medium text-foreground",children:n.name}),e.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:["(",n.slug,")"]}),e.jsxs("span",{className:"ml-auto shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[n.usageCount," ",n.usageCount===1?"use":"uses"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[c&&d&&e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>o(n._id),title:"Add child term",className:"size-7 p-0",children:e.jsx(L,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>s(n),title:"Edit term",className:"size-7 p-0",children:e.jsx(J,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>S(n._id),title:"Delete term",className:"size-7 p-0 text-destructive hover:text-destructive",children:e.jsx(V,{className:"size-3.5"})})]})]}),c&&j&&D&&e.jsx("div",{children:n.children.map($=>E($,a+1))})]},n._id)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Terms"}),e.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>o(),children:[e.jsx(L,{className:"size-3.5"}),"Add Term"]})]}),w&&e.jsxs("div",{className:"diff-removed flex items-center justify-between rounded-lg border px-3 py-2 text-sm",children:[w,e.jsx("button",{type:"button",onClick:()=>k(null),className:"text-diff-removed hover:text-diff-removed-foreground",children:"×"})]}),e.jsx("div",{className:"rounded-lg border bg-card",children:F?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"})}):!b||b.length===0?e.jsx(G,{icon:e.jsx(X,{className:"size-8"}),title:"No terms yet",description:"Add your first term to start organizing content.",action:d?{label:"Add your first term",onClick:()=>o(),variant:"secondary"}:void 0}):e.jsx("div",{className:"divide-y divide-border/50",children:b.map(n=>E(n))})}),u&&e.jsx(ce,{taxonomyId:i,term:g,parentId:O,isHierarchical:c,onSave:()=>{p(!1),r(null),m(void 0)},onCancel:()=>{p(!1),r(null),m(void 0)}}),e.jsx(U,{open:!!y,onOpenChange:n=>!n&&S(null),title:"Delete Term",description:c?"Are you sure you want to delete this term? All child terms will also be deleted.":"Are you sure you want to delete this term?",confirmLabel:"Delete",variant:"danger",onConfirm:()=>y&&T(y)})]})}function ce({taxonomyId:i,term:c,parentId:d,isHierarchical:x,onSave:l,onCancel:C}){const g=!!c,[r,u]=t.useState({name:c?.name??"",slug:c?.slug??"",description:c?.description??"",color:c?.color??"",icon:c?.icon??"",sortOrder:c?.sortOrder??0}),[p,O]=t.useState({}),[m,y]=t.useState(!1),[S,w]=t.useState(null),[k,z]=t.useState(!1),h=q(),b=I(h.createTerm),F=I(h.updateTerm),v=t.useCallback((a,j)=>{u(D=>({...D,[a]:j})),O(D=>{const{[a]:$,...K}=D;return K})},[]),o=t.useCallback(a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),s=t.useCallback(a=>{v("name",a),!g&&!k&&v("slug",o(a))},[v,g,k,o]),T=t.useCallback(()=>{const a={};return r.name.trim()||(a.name="Name is required"),r.slug.trim()?/^[a-z0-9-]+$/.test(r.slug)||(a.slug="Slug must contain only lowercase letters, numbers, and hyphens"):a.slug="Slug is required",O(a),Object.keys(a).length===0},[r]),E=t.useCallback(async a=>{if(a.preventDefault(),!!T()){y(!0),w(null);try{g&&c?await F({id:c._id,name:r.name,slug:r.slug,description:r.description||void 0,color:r.color||void 0,icon:r.icon||void 0,sortOrder:r.sortOrder}):await b({taxonomyId:i,name:r.name,slug:r.slug,description:r.description||void 0,parentId:d,color:r.color||void 0,icon:r.icon||void 0,sortOrder:r.sortOrder}),l()}catch(j){const D=j instanceof Error?j.message:"Failed to save term";w(D)}finally{y(!1)}}},[T,g,c,r,i,d,b,F,l]),n=g?"Edit Term":d?"Create Child Term":"Create Term";return e.jsx(R,{open:!0,onOpenChange:a=>!a&&!m&&C(),title:n,size:"md",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:C,disabled:m,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:E,loading:m,children:g?"Save Changes":"Create Term"})]}),children:e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[S&&e.jsx("div",{className:"diff-removed rounded-lg border px-3 py-2 text-sm",children:S}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termName",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"termName",value:r.name,onChange:a=>s(a.target.value),placeholder:"e.g., Technology",disabled:m,className:p.name?"border-destructive":""}),p.name&&e.jsx("p",{className:"text-xs text-destructive",children:p.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termSlug",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"termSlug",value:r.slug,onChange:a=>{v("slug",a.target.value.toLowerCase()),z(!0)},placeholder:"e.g., technology",disabled:m,className:p.slug?"border-destructive":""}),p.slug&&e.jsx("p",{className:"text-xs text-destructive",children:p.slug})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termDescription",children:"Description"}),e.jsx(Z,{id:"termDescription",value:r.description,onChange:a=>v("description",a.target.value),placeholder:"Optional description",rows:2,disabled:m})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termColor",children:"Color"}),e.jsx(A,{id:"termColor",type:"color",value:r.color||"#6b7280",onChange:a=>v("color",a.target.value),disabled:m,className:"h-9 p-1"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termIcon",children:"Icon"}),e.jsx(A,{id:"termIcon",value:r.icon,onChange:a=>v("icon",a.target.value),placeholder:"e.g., 💻",disabled:m})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termSortOrder",children:"Sort Order"}),e.jsx(A,{id:"termSortOrder",type:"number",value:r.sortOrder,onChange:a=>v("sortOrder",parseInt(a.target.value)||0),disabled:m})]})]})]})})}function de({api:i,navigation:c}){const[d,x]=t.useState(null),[l,C]=t.useState(!1),[g,r]=t.useState(null),[u,p]=t.useState(null),[O,m]=t.useState(null),y=M(i.listTaxonomies,{isActive:void 0,includeDeleted:!1}),S=I(i.deleteTaxonomy),w=y?.page??[],k=y===void 0,z=t.useCallback(()=>{r(null),C(!0)},[]),h=t.useCallback(o=>{r(o),C(!0)},[]),b=t.useCallback(async o=>{m(null);try{await S({id:o}),p(null),d?._id===o&&x(null)}catch(s){const T=s instanceof Error?s.message:"Failed to delete taxonomy";m(T)}},[S,d]),F=t.useCallback(()=>{C(!1),r(null)},[]),v=o=>o.isHierarchical?e.jsx(ne,{className:"size-5"}):e.jsx(H,{className:"size-5"});return e.jsxs("div",{className:"flex h-[calc(100vh-4rem)] flex-col p-6",children:[e.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[e.jsx(ae,{title:"Taxonomies",description:"Manage tags, categories, and other classification systems"}),e.jsxs(N,{onClick:z,children:[e.jsx(L,{className:"size-4"}),"Create Taxonomy"]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 gap-6",children:[e.jsx(B,{elevation:"base",className:"w-80 shrink-0 overflow-hidden",children:k?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Loading taxonomies..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center",children:[e.jsx(H,{className:"mb-3 size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No taxonomies created yet."}),e.jsx(N,{variant:"secondary",className:"mt-4",onClick:z,children:"Create your first taxonomy"})]}):e.jsx(te,{className:"h-full",children:e.jsx("div",{className:"divide-y",children:w.map(o=>e.jsxs("div",{className:P("group flex cursor-pointer items-center gap-3 p-3 transition-colors hover:bg-muted/50",d?._id===o._id&&"bg-primary/5",!o.isActive&&"opacity-60"),onClick:()=>x(o),children:[e.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:v(o)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.displayName}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.name})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Q,{variant:"secondary",className:"text-xs font-normal",children:o.isHierarchical?"Hierarchical":"Flat"}),!o.isActive&&e.jsx(Q,{variant:"outline",className:"text-xs font-normal",children:"Inactive"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:s=>{s.stopPropagation(),h(o)},title:"Edit taxonomy",children:e.jsx(J,{className:"size-4"})}),e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:s=>{s.stopPropagation(),p(o._id)},title:"Delete taxonomy",className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:e.jsx(V,{className:"size-4"})})]})]},o._id))})})}),e.jsx(B,{elevation:"base",className:"min-w-0 flex-1 overflow-hidden",children:d?e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between border-b p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground",children:v(d)}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:d.displayName}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]})]}),e.jsx(N,{variant:"secondary",onClick:()=>h(d),children:"Edit Taxonomy"})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(oe,{taxonomyId:d._id,isHierarchical:d.isHierarchical,allowInlineCreation:d.allowInlineCreation})})]}):e.jsx(G,{icon:e.jsx(H,{className:"size-6"}),title:"Select a taxonomy",description:"Select a taxonomy to view and manage its terms",className:"h-full"})})]}),l&&e.jsx(le,{taxonomy:g,onSave:F,onCancel:()=>{C(!1),r(null)}}),e.jsx(U,{open:u!==null,onOpenChange:o=>{o||(p(null),m(null))},title:"Delete Taxonomy",description:"Are you sure you want to delete this taxonomy? All associated terms will also be deleted.",confirmLabel:"Delete",onConfirm:()=>u&&b(u),variant:"danger",error:O})]})}function fe(){const i=re();return e.jsx(de,{api:se.admin,navigation:i})}export{fe as component};
1
+ import{e as W,r as t,f as $,a as I,j as e,g as R,L as f,I as A,h as Z,i as _,C as N,u as M,P as L,k as X,c as U,l as Y,m as ee,n as P,T as V,o as H,d as se}from"./main-B-6700eG.js";import{u as ae}from"./tanstack-adapter-KSm-nO5L.js";import{C as G}from"./CmsEmptyState-BKeL4DBB.js";import{P as J}from"./pencil-CI_KfxSx.js";import{C as te}from"./CmsPageHeader-CIEkTbyH.js";import{C as B}from"./CmsSurface-kqqaFKUI.js";import{B as Q}from"./badge-BQAotc5B.js";import{S as re}from"./scroll-area-DX_nZYp8.js";const ie=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],ne=W("folder-tree",ie);function le({taxonomy:i,onSave:c,onCancel:d}){const x=!!i,[l,C]=t.useState({name:i?.name??"",displayName:i?.displayName??"",description:i?.description??"",isHierarchical:i?.isHierarchical??!1,allowInlineCreation:i?.allowInlineCreation??!0,isActive:i?.isActive??!0,icon:i?.icon??"",sortOrder:i?.sortOrder??0}),[g,r]=t.useState({}),[u,p]=t.useState(!1),[O,m]=t.useState(null),[y,S]=t.useState(!1),w=$(),k=I(w.createTaxonomy),z=I(w.updateTaxonomy);t.useEffect(()=>{i&&C({name:i.name,displayName:i.displayName,description:i.description??"",isHierarchical:i.isHierarchical,allowInlineCreation:i.allowInlineCreation,isActive:i.isActive,icon:i.icon??"",sortOrder:i.sortOrder??0})},[i]);const h=t.useCallback((s,T)=>{C(E=>({...E,[s]:T})),r(E=>{const{[s]:n,...a}=E;return a})},[]),b=t.useCallback(s=>s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),F=t.useCallback(s=>{h("displayName",s),!x&&!y&&h("name",b(s))},[h,x,y,b]),v=t.useCallback(()=>{const s={};return l.name.trim()?/^[a-z][a-z0-9-]*$/.test(l.name)||(s.name="Slug must start with a letter and contain only lowercase letters, numbers, and hyphens"):s.name="Slug is required",l.displayName.trim()||(s.displayName="Display name is required"),r(s),Object.keys(s).length===0},[l]),o=t.useCallback(async s=>{if(s.preventDefault(),!!v()){p(!0),m(null);try{x&&i?await z({id:i._id,displayName:l.displayName,description:l.description||void 0,allowInlineCreation:l.allowInlineCreation,icon:l.icon||void 0,sortOrder:l.sortOrder,isActive:l.isActive}):await k({name:l.name,displayName:l.displayName,description:l.description||void 0,isHierarchical:l.isHierarchical,allowInlineCreation:l.allowInlineCreation,icon:l.icon||void 0,sortOrder:l.sortOrder}),c()}catch(T){const E=T instanceof Error?T.message:"Failed to save taxonomy";m(E)}finally{p(!1)}}},[v,x,i,l,k,z,c]);return e.jsx(R,{open:!0,onOpenChange:s=>!s&&!u&&d(),title:x?"Edit Taxonomy":"Create Taxonomy",size:"lg",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:d,disabled:u,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:o,loading:u,children:x?"Save Changes":"Create Taxonomy"})]}),children:e.jsxs("form",{onSubmit:o,className:"space-y-4",children:[O&&e.jsx("div",{className:"diff-removed rounded-lg border px-3 py-2 text-sm",children:O}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"displayName",children:["Display Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"displayName",value:l.displayName,onChange:s=>F(s.target.value),placeholder:"e.g., Categories, Tags",disabled:u,className:g.displayName?"border-destructive":""}),g.displayName&&e.jsx("p",{className:"text-xs text-destructive",children:g.displayName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"name",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"name",value:l.name,onChange:s=>{h("name",s.target.value.toLowerCase()),S(!0)},placeholder:"e.g., categories, tags",disabled:u||x,className:g.name?"border-destructive":""}),g.name&&e.jsx("p",{className:"text-xs text-destructive",children:g.name}),x&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"description",children:"Description"}),e.jsx(Z,{id:"description",value:l.description,onChange:s=>h("description",s.target.value),placeholder:"Optional description",rows:2,disabled:u})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"icon",children:"Icon"}),e.jsx(A,{id:"icon",value:l.icon,onChange:s=>h("icon",s.target.value),placeholder:"e.g., 🏷️ or folder",disabled:u}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emoji or icon name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"sortOrder",children:"Sort Order"}),e.jsx(A,{id:"sortOrder",type:"number",value:l.sortOrder,onChange:s=>h("sortOrder",parseInt(s.target.value)||0),disabled:u})]})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"isHierarchical",checked:l.isHierarchical,onCheckedChange:s=>h("isHierarchical",s),disabled:u||x}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isHierarchical",className:"cursor-pointer font-medium",children:"Hierarchical"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terms can have parent-child relationships (like categories)"}),x&&e.jsx("p",{className:"text-xs text-warning",children:"Hierarchy type cannot be changed after creation"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"allowInlineCreation",checked:l.allowInlineCreation,onCheckedChange:s=>h("allowInlineCreation",s),disabled:u}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"allowInlineCreation",className:"cursor-pointer font-medium",children:"Allow inline creation"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Users can create new terms while editing content"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"isActive",checked:l.isActive,onCheckedChange:s=>h("isActive",s),disabled:u}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isActive",className:"cursor-pointer font-medium",children:"Active"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Inactive taxonomies are hidden from content editors"})]})]})]})]})})}function oe({taxonomyId:i,isHierarchical:c,allowInlineCreation:d}){const x=$(),[l,C]=t.useState(new Set),[g,r]=t.useState(null),[u,p]=t.useState(!1),[O,m]=t.useState(),[y,S]=t.useState(null),[w,k]=t.useState(null),z=c?M(x.getTermsHierarchy,{taxonomyId:i}):M(x.listTerms,{taxonomyId:i}),h=I(x.deleteTerm),b=c?z:z?.page,F=b===void 0,v=t.useCallback(n=>{C(a=>{const j=new Set(a);return j.has(n)?j.delete(n):j.add(n),j})},[]),o=t.useCallback(n=>{m(n),r(null),p(!0)},[]),s=t.useCallback(n=>{r(n),p(!0)},[]),T=t.useCallback(async n=>{k(null);try{await h({id:n,cascade:!0}),S(null)}catch(a){const j=a instanceof Error?a.message:"Failed to delete term";k(j)}},[h]),E=(n,a=0)=>{const j=n.children&&n.children.length>0,D=l.has(n._id);return e.jsxs("div",{className:"border-b border-border/50 last:border-0",children:[e.jsxs("div",{className:P("group flex items-center gap-2 py-2 pr-2 transition-colors hover:bg-muted/50",a>0&&"border-l-2 border-muted"),style:{paddingLeft:`${a*24+8}px`},children:[c&&e.jsx("button",{type:"button",onClick:()=>v(n._id),disabled:!j,className:P("flex size-5 items-center justify-center rounded transition-colors",j?"text-muted-foreground hover:bg-muted hover:text-foreground":"invisible"),"aria-expanded":D,children:j&&(D?e.jsx(Y,{className:"size-4"}):e.jsx(ee,{className:"size-4"}))}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.color&&e.jsx("span",{className:"size-3 shrink-0 rounded-full",style:{backgroundColor:n.color}}),n.icon&&e.jsx("span",{className:"shrink-0 text-sm",children:n.icon}),e.jsx("span",{className:"truncate font-medium text-foreground",children:n.name}),e.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:["(",n.slug,")"]}),e.jsxs("span",{className:"ml-auto shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[n.usageCount," ",n.usageCount===1?"use":"uses"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[c&&d&&e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>o(n._id),title:"Add child term",className:"size-7 p-0",children:e.jsx(L,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>s(n),title:"Edit term",className:"size-7 p-0",children:e.jsx(J,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>S(n._id),title:"Delete term",className:"size-7 p-0 text-destructive hover:text-destructive",children:e.jsx(V,{className:"size-3.5"})})]})]}),c&&j&&D&&e.jsx("div",{children:n.children.map(q=>E(q,a+1))})]},n._id)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Terms"}),e.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>o(),children:[e.jsx(L,{className:"size-3.5"}),"Add Term"]})]}),w&&e.jsxs("div",{className:"diff-removed flex items-center justify-between rounded-lg border px-3 py-2 text-sm",children:[w,e.jsx("button",{type:"button",onClick:()=>k(null),className:"text-diff-removed hover:text-diff-removed-foreground",children:"×"})]}),e.jsx("div",{className:"rounded-lg border bg-card",children:F?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"})}):!b||b.length===0?e.jsx(G,{icon:e.jsx(X,{className:"size-8"}),title:"No terms yet",description:"Add your first term to start organizing content.",action:d?{label:"Add your first term",onClick:()=>o(),variant:"secondary"}:void 0}):e.jsx("div",{className:"divide-y divide-border/50",children:b.map(n=>E(n))})}),u&&e.jsx(ce,{taxonomyId:i,term:g,parentId:O,isHierarchical:c,onSave:()=>{p(!1),r(null),m(void 0)},onCancel:()=>{p(!1),r(null),m(void 0)}}),e.jsx(U,{open:!!y,onOpenChange:n=>!n&&S(null),title:"Delete Term",description:c?"Are you sure you want to delete this term? All child terms will also be deleted.":"Are you sure you want to delete this term?",confirmLabel:"Delete",variant:"danger",onConfirm:()=>y&&T(y)})]})}function ce({taxonomyId:i,term:c,parentId:d,isHierarchical:x,onSave:l,onCancel:C}){const g=!!c,[r,u]=t.useState({name:c?.name??"",slug:c?.slug??"",description:c?.description??"",color:c?.color??"",icon:c?.icon??"",sortOrder:c?.sortOrder??0}),[p,O]=t.useState({}),[m,y]=t.useState(!1),[S,w]=t.useState(null),[k,z]=t.useState(!1),h=$(),b=I(h.createTerm),F=I(h.updateTerm),v=t.useCallback((a,j)=>{u(D=>({...D,[a]:j})),O(D=>{const{[a]:q,...K}=D;return K})},[]),o=t.useCallback(a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),s=t.useCallback(a=>{v("name",a),!g&&!k&&v("slug",o(a))},[v,g,k,o]),T=t.useCallback(()=>{const a={};return r.name.trim()||(a.name="Name is required"),r.slug.trim()?/^[a-z0-9-]+$/.test(r.slug)||(a.slug="Slug must contain only lowercase letters, numbers, and hyphens"):a.slug="Slug is required",O(a),Object.keys(a).length===0},[r]),E=t.useCallback(async a=>{if(a.preventDefault(),!!T()){y(!0),w(null);try{g&&c?await F({id:c._id,name:r.name,slug:r.slug,description:r.description||void 0,color:r.color||void 0,icon:r.icon||void 0,sortOrder:r.sortOrder}):await b({taxonomyId:i,name:r.name,slug:r.slug,description:r.description||void 0,parentId:d,color:r.color||void 0,icon:r.icon||void 0,sortOrder:r.sortOrder}),l()}catch(j){const D=j instanceof Error?j.message:"Failed to save term";w(D)}finally{y(!1)}}},[T,g,c,r,i,d,b,F,l]),n=g?"Edit Term":d?"Create Child Term":"Create Term";return e.jsx(R,{open:!0,onOpenChange:a=>!a&&!m&&C(),title:n,size:"md",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:C,disabled:m,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:E,loading:m,children:g?"Save Changes":"Create Term"})]}),children:e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[S&&e.jsx("div",{className:"diff-removed rounded-lg border px-3 py-2 text-sm",children:S}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termName",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"termName",value:r.name,onChange:a=>s(a.target.value),placeholder:"e.g., Technology",disabled:m,className:p.name?"border-destructive":""}),p.name&&e.jsx("p",{className:"text-xs text-destructive",children:p.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termSlug",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"termSlug",value:r.slug,onChange:a=>{v("slug",a.target.value.toLowerCase()),z(!0)},placeholder:"e.g., technology",disabled:m,className:p.slug?"border-destructive":""}),p.slug&&e.jsx("p",{className:"text-xs text-destructive",children:p.slug})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termDescription",children:"Description"}),e.jsx(Z,{id:"termDescription",value:r.description,onChange:a=>v("description",a.target.value),placeholder:"Optional description",rows:2,disabled:m})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termColor",children:"Color"}),e.jsx(A,{id:"termColor",type:"color",value:r.color||"#6b7280",onChange:a=>v("color",a.target.value),disabled:m,className:"h-9 p-1"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termIcon",children:"Icon"}),e.jsx(A,{id:"termIcon",value:r.icon,onChange:a=>v("icon",a.target.value),placeholder:"e.g., 💻",disabled:m})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termSortOrder",children:"Sort Order"}),e.jsx(A,{id:"termSortOrder",type:"number",value:r.sortOrder,onChange:a=>v("sortOrder",parseInt(a.target.value)||0),disabled:m})]})]})]})})}function de({api:i,navigation:c}){const[d,x]=t.useState(null),[l,C]=t.useState(!1),[g,r]=t.useState(null),[u,p]=t.useState(null),[O,m]=t.useState(null),y=M(i.listTaxonomies,{isActive:void 0,includeDeleted:!1}),S=I(i.deleteTaxonomy),w=y?.page??[],k=y===void 0,z=t.useCallback(()=>{r(null),C(!0)},[]),h=t.useCallback(o=>{r(o),C(!0)},[]),b=t.useCallback(async o=>{m(null);try{await S({id:o}),p(null),d?._id===o&&x(null)}catch(s){const T=s instanceof Error?s.message:"Failed to delete taxonomy";m(T)}},[S,d]),F=t.useCallback(()=>{C(!1),r(null)},[]),v=o=>o.isHierarchical?e.jsx(ne,{className:"size-5"}):e.jsx(H,{className:"size-5"});return e.jsxs("div",{className:"flex h-[calc(100vh-4rem)] flex-col p-6",children:[e.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[e.jsx(te,{title:"Taxonomies",description:"Manage tags, categories, and other classification systems"}),e.jsxs(N,{onClick:z,children:[e.jsx(L,{className:"size-4"}),"Create Taxonomy"]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 gap-6",children:[e.jsx(B,{elevation:"base",className:"w-80 shrink-0 overflow-hidden",children:k?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Loading taxonomies..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center",children:[e.jsx(H,{className:"mb-3 size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No taxonomies created yet."}),e.jsx(N,{variant:"secondary",className:"mt-4",onClick:z,children:"Create your first taxonomy"})]}):e.jsx(re,{className:"h-full",children:e.jsx("div",{className:"divide-y",children:w.map(o=>e.jsxs("div",{className:P("group flex cursor-pointer items-center gap-3 p-3 transition-colors hover:bg-muted/50",d?._id===o._id&&"bg-primary/5",!o.isActive&&"opacity-60"),onClick:()=>x(o),children:[e.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:v(o)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.displayName}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.name})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Q,{variant:"secondary",className:"text-xs font-normal",children:o.isHierarchical?"Hierarchical":"Flat"}),!o.isActive&&e.jsx(Q,{variant:"outline",className:"text-xs font-normal",children:"Inactive"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:s=>{s.stopPropagation(),h(o)},title:"Edit taxonomy",children:e.jsx(J,{className:"size-4"})}),e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:s=>{s.stopPropagation(),p(o._id)},title:"Delete taxonomy",className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:e.jsx(V,{className:"size-4"})})]})]},o._id))})})}),e.jsx(B,{elevation:"base",className:"min-w-0 flex-1 overflow-hidden",children:d?e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between border-b p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground",children:v(d)}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:d.displayName}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]})]}),e.jsx(N,{variant:"secondary",onClick:()=>h(d),children:"Edit Taxonomy"})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(oe,{taxonomyId:d._id,isHierarchical:d.isHierarchical,allowInlineCreation:d.allowInlineCreation})})]}):e.jsx(G,{icon:e.jsx(H,{className:"size-6"}),title:"Select a taxonomy",description:"Select a taxonomy to view and manage its terms",className:"h-full"})})]}),l&&e.jsx(le,{taxonomy:g,onSave:F,onCancel:()=>{C(!1),r(null)}}),e.jsx(U,{open:u!==null,onOpenChange:o=>{o||(p(null),m(null))},title:"Delete Taxonomy",description:"Are you sure you want to delete this taxonomy? All associated terms will also be deleted.",confirmLabel:"Delete",onConfirm:()=>u&&b(u),variant:"danger",error:O})]})}function fe(){const i=ae();return e.jsx(de,{api:se.admin,navigation:i})}export{fe as component};
@@ -0,0 +1 @@
1
+ import{r as a,u as d,a as w,j as e,C as o,T as z,b as D,X as I,c as K,d as V}from"./main-B-6700eG.js";import{u as W}from"./tanstack-adapter-KSm-nO5L.js";import{C as R}from"./CmsSurface-kqqaFKUI.js";import{B as Y}from"./badge-BQAotc5B.js";import{C as Z}from"./CmsEmptyState-BKeL4DBB.js";import{C as ee}from"./CmsPageHeader-CIEkTbyH.js";import{C as se}from"./CmsTable-Db53Exq0.js";import{C as te}from"./CmsFilterBar-CEpMHd_c.js";import{A,a as Q}from"./alert-CpLdsTGU.js";import{R as M}from"./rotate-ccw-PwzxdPxd.js";import"./search-DlwBH4C5.js";function ae({api:n,navigation:ne}){const[g,B]=a.useState(""),[j,F]=a.useState(""),[l,i]=a.useState(new Set),[C,m]=a.useState(null),[u,N]=a.useState(!1),[L,p]=a.useState(!1),[v,T]=a.useState(!1),[b,h]=a.useState(null),S=d(n.listTrash,{contentTypeId:g||void 0,search:j||void 0,paginationOpts:{numItems:50,cursor:null}}),_=d(n.getTrashConfig,{}),O=d(n.getTrashStats,{}),P=d(n.listContentTypes,{})?.page??[],E=w(n.bulkRestore),k=w(n.emptyTrash),x=S?.page??[],U=S===void 0,c=_,y=O,f=a.useCallback(async s=>{N(!0),m(null);try{await E({ids:s}),i(t=>{const r=new Set(t);return s.forEach(J=>r.delete(J)),r})}catch(t){const r=t instanceof Error?t.message:"Failed to restore";m(r)}finally{N(!1)}},[E]),H=a.useCallback(async()=>{T(!0),h(null);try{await k({}),p(!1),i(new Set)}catch(s){const t=s instanceof Error?s.message:"Failed to empty trash";h(t)}finally{T(!1)}},[k]),X=s=>new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),$=s=>{if(!c?.retentionDays)return null;const t=s+c.retentionDays*24*60*60*1e3,r=Math.ceil((t-Date.now())/(1440*60*1e3));return Math.max(0,r)},q=s=>{if(s.title)return s.title;if(s.name)return s.name;if(s.data){const t=s.data.title||s.data.name;if(t&&typeof t=="string")return t}return s.slug||s._id},G=a.useMemo(()=>[{key:"name",header:"Name",cell:s=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-foreground",children:q(s)}),s.slug&&e.jsx("span",{className:"block text-xs text-muted-foreground",children:s.slug})]})},{key:"type",header:"Type",cell:s=>e.jsx("span",{className:"text-sm text-muted-foreground",children:s.contentTypeName||"Unknown"})},{key:"deleted",header:"Deleted",cell:s=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:X(s.deletedAt)}),s.deletedBy&&e.jsxs("span",{className:"block text-xs text-muted-foreground",children:["by ",s.deletedBy]})]})},{key:"expires",header:"Expires In",cell:s=>{const t=$(s.deletedAt);return t!==null?e.jsxs(Y,{variant:t<=3?"destructive":"secondary",className:"font-normal",children:[t," ",t===1?"day":"days"]}):null}},{key:"actions",header:"Actions",cell:s=>e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>f([s._id]),loading:u,children:[e.jsx(M,{className:"size-4"}),"Restore"]})}],[u,f,c?.retentionDays]);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(ee,{title:"Trash",description:`Deleted items are kept for ${c?.retentionDays??30} days before permanent deletion`}),x.length>0&&e.jsxs(o,{variant:"danger",onClick:()=>p(!0),children:[e.jsx(z,{className:"size-4"}),"Empty Trash"]})]}),y&&e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs(R,{elevation:"base",className:"p-4",children:[e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:y.totalCount??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Items in Trash"})]}),e.jsxs(R,{elevation:"base",className:"p-4",children:[e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:y.expiredCount??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Expired"})]})]}),e.jsx(te,{search:{value:j,onChange:F,placeholder:"Search deleted items...",className:"w-64"},filters:[{key:"contentType",value:g||"all",onChange:s=>B(s==="all"?"":s),options:[{value:"all",label:"All Content Types"},...P.map(s=>({value:s._id,label:s.displayName}))],className:"w-48"}]}),C&&e.jsxs(A,{variant:"destructive",children:[e.jsx(D,{className:"size-4"}),e.jsxs(Q,{className:"flex items-center justify-between",children:[C,e.jsx(o,{variant:"ghost",size:"icon-sm",onClick:()=>m(null),children:e.jsx(I,{className:"size-4"})})]})]}),b&&e.jsxs(A,{variant:"destructive",children:[e.jsx(D,{className:"size-4"}),e.jsxs(Q,{className:"flex items-center justify-between",children:[b,e.jsx(o,{variant:"ghost",size:"icon-sm",onClick:()=>h(null),children:e.jsx(I,{className:"size-4"})})]})]}),l.size>0&&e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-primary/20 bg-primary/5 p-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[l.size," ",l.size===1?"item":"items"," ","selected"]}),e.jsxs(o,{variant:"primary",size:"sm",onClick:()=>f(Array.from(l)),loading:u,children:[e.jsx(M,{className:"size-4"}),"Restore Selected"]}),e.jsx(o,{variant:"secondary",size:"sm",onClick:()=>i(new Set),children:"Clear Selection"})]}),U?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading trash..."})]}):x.length===0?e.jsx(Z,{icon:e.jsx(z,{className:"size-6"}),title:"Trash is empty",description:"Deleted items will appear here"}):e.jsx(se,{columns:G,data:x,getRowId:s=>s._id,selectable:!0,selectedIds:l,onSelectionChange:i,emptyMessage:"No items in trash"}),e.jsx(K,{open:L,onOpenChange:p,title:"Empty Trash",description:"This will permanently delete all items in the trash. This action cannot be undone.",confirmLabel:v?"Deleting...":"Empty Trash",onConfirm:H,variant:"danger",loading:v})]})}function fe(){const n=W();return e.jsx(ae,{api:V.admin,navigation:n})}export{fe as component};
@@ -1 +1 @@
1
- import{aN as u,r as c}from"./main-CA-4LyFT.js";function a(r,e){const{setOverride:s,clearOverride:t}=u();c.useEffect(()=>(e&&s(r,e),()=>{t(r)}),[r,e,s,t])}export{a as u};
1
+ import{aN as u,r as c}from"./main-B-6700eG.js";function a(r,e){const{setOverride:s,clearOverride:t}=u();c.useEffect(()=>(e&&s(r,e),()=>{t(r)}),[r,e,s,t])}export{a as u};
@@ -1 +1 @@
1
- import{an as c,r as o,ao as i,ap as u,aq as d}from"./main-CA-4LyFT.js";function C(){const{role:n}=c();return o.useMemo(()=>{const r=!!n,t=(e,s,a)=>n?d(n,{resource:e,action:s,scope:a}):!1;return{role:n,hasRole:r,check:t,canAccess:e=>n?u(n,e):!1,canCreate:e=>t(e,"create"),canRead:(e,s)=>t(e,"read",s),canUpdate:(e,s)=>t(e,"update",s),canDelete:(e,s)=>t(e,"delete",s),canPublish:e=>t("contentEntries","publish",e),canUnpublish:e=>t("contentEntries","unpublish",e),canManageSettings:()=>t("settings","manage"),canManageContentTypes:()=>t("contentTypes","create")||t("contentTypes","update")||t("contentTypes","delete"),getPermissions:e=>n?i(n,e):[],isAdmin:n==="admin",isEditor:n==="admin"||n==="editor",isAuthor:n==="admin"||n==="editor"||n==="author"}},[n])}export{C as u};
1
+ import{an as c,r as o,ao as i,ap as u,aq as d}from"./main-B-6700eG.js";function C(){const{role:n}=c();return o.useMemo(()=>{const r=!!n,t=(e,s,a)=>n?d(n,{resource:e,action:s,scope:a}):!1;return{role:n,hasRole:r,check:t,canAccess:e=>n?u(n,e):!1,canCreate:e=>t(e,"create"),canRead:(e,s)=>t(e,"read",s),canUpdate:(e,s)=>t(e,"update",s),canDelete:(e,s)=>t(e,"delete",s),canPublish:e=>t("contentEntries","publish",e),canUnpublish:e=>t("contentEntries","unpublish",e),canManageSettings:()=>t("settings","manage"),canManageContentTypes:()=>t("contentTypes","create")||t("contentTypes","update")||t("contentTypes","delete"),getPermissions:e=>n?i(n,e):[],isAdmin:n==="admin",isEditor:n==="admin"||n==="editor",isAuthor:n==="admin"||n==="editor"||n==="author"}},[n])}export{C as u};