convex-cms 0.0.9-alpha.6 → 0.0.9-alpha.8

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 (74) hide show
  1. package/admin/src/contexts/SettingsConfigContext.tsx +67 -11
  2. package/admin/src/embed/components/EmbedLayout.tsx +6 -2
  3. package/admin/src/embed/components/EmbedSidebar.tsx +4 -7
  4. package/admin/src/embed/index.tsx +8 -5
  5. package/admin/src/embed/types.ts +6 -0
  6. package/admin/src/pages/SettingsPage.tsx +124 -80
  7. package/admin/src/routes/__root.tsx +4 -1
  8. package/admin/src/styles/globals.css +9 -0
  9. package/admin/src/styles/theme.css +141 -3
  10. package/admin-dist/nitro.json +1 -1
  11. package/admin-dist/public/assets/{CmsEmptyState-la_kLGHv.js → CmsEmptyState-DTlpzjOI.js} +1 -1
  12. package/admin-dist/public/assets/{CmsPageHeader-Cf0SafVG.js → CmsPageHeader-0REGRH4X.js} +1 -1
  13. package/admin-dist/public/assets/{CmsStatusBadge-BovugIHH.js → CmsStatusBadge-D_n8u8xa.js} +1 -1
  14. package/admin-dist/public/assets/{CmsSurface-Dp1TegU4.js → CmsSurface-BHmvNai4.js} +1 -1
  15. package/admin-dist/public/assets/{CmsToolbar-B1zdfMu0.js → CmsToolbar-CY6GV2L8.js} +1 -1
  16. package/admin-dist/public/assets/{ContentEntryEditor-CB--8SC3.js → ContentEntryEditor-CRgcRkk5.js} +1 -1
  17. package/admin-dist/public/assets/{TaxonomyFilter-fmZxxbdA.js → TaxonomyFilter-Ohv5Jg9c.js} +1 -1
  18. package/admin-dist/public/assets/{_contentTypeId-vT09P77i.js → _contentTypeId-C_vJq22X.js} +1 -1
  19. package/admin-dist/public/assets/{_entryId-Dhq6ybYt.js → _entryId-jPXz4z9T.js} +1 -1
  20. package/admin-dist/public/assets/{alert-DfdkD-ZZ.js → alert-CG97cMfC.js} +1 -1
  21. package/admin-dist/public/assets/{badge-Cmc3T9vs.js → badge-C6qt24oj.js} +1 -1
  22. package/admin-dist/public/assets/{circle-check-big-B8AJAcBi.js → circle-check-big-PltpxuB1.js} +1 -1
  23. package/admin-dist/public/assets/{command-BsmkQ6_j.js → command-CJ8i86fd.js} +1 -1
  24. package/admin-dist/public/assets/{content-DdQ1u7T4.js → content-pKaIL2ru.js} +1 -1
  25. package/admin-dist/public/assets/{content-types-QYcwm0Sy.js → content-types-Bl_8I1Re.js} +1 -1
  26. package/admin-dist/public/assets/{index-kxLB3e43.js → index-CtHq_P5q.js} +1 -1
  27. package/admin-dist/public/assets/{main-BrFRroF1.js → main-CA-4LyFT.js} +19 -19
  28. package/admin-dist/public/assets/{media-Cx9IyZvU.js → media-Bl1tBbJQ.js} +1 -1
  29. package/admin-dist/public/assets/{new._contentTypeId-2HsDwzy_.js → new._contentTypeId-qsvo01mH.js} +1 -1
  30. package/admin-dist/public/assets/{pencil-PaJhpDeC.js → pencil-gAL0R34f.js} +1 -1
  31. package/admin-dist/public/assets/{refresh-cw-D_KNzBUN.js → refresh-cw-sdVUGJNs.js} +1 -1
  32. package/admin-dist/public/assets/{rotate-ccw-I3wzW1RQ.js → rotate-ccw-6OcXCcxb.js} +1 -1
  33. package/admin-dist/public/assets/{scroll-area-t72-FBB4.js → scroll-area-CJBhf9pf.js} +1 -1
  34. package/admin-dist/public/assets/{search-BsuImjd-.js → search-WXp6KxDJ.js} +1 -1
  35. package/admin-dist/public/assets/settings-D8crrFCn.js +1 -0
  36. package/admin-dist/public/assets/{switch-DWN_fx2n.js → switch-Ck9ecqEX.js} +1 -1
  37. package/admin-dist/public/assets/{tabs-BG0vukFH.js → tabs-vQYu8rjC.js} +1 -1
  38. package/admin-dist/public/assets/{tanstack-adapter-DHsy8Fjs.js → tanstack-adapter-BRt2CUCw.js} +1 -1
  39. package/admin-dist/public/assets/{taxonomies-WG8YV2pR.js → taxonomies-DvILUNvr.js} +1 -1
  40. package/admin-dist/public/assets/{trash-C3Lt5m9d.js → trash-YyYaC3L9.js} +1 -1
  41. package/admin-dist/public/assets/{useBreadcrumbLabel-BC8wl3jQ.js → useBreadcrumbLabel-tlSh7dtO.js} +1 -1
  42. package/admin-dist/public/assets/{usePermissions-BM1Vv1YJ.js → usePermissions-BTGdTOJS.js} +1 -1
  43. package/admin-dist/server/_ssr/{CmsEmptyState-NKmyUWD9.mjs → CmsEmptyState-CB6e53i5.mjs} +1 -1
  44. package/admin-dist/server/_ssr/{CmsPageHeader-CngxPIOg.mjs → CmsPageHeader-COUHuECp.mjs} +1 -1
  45. package/admin-dist/server/_ssr/{CmsStatusBadge-D4fiHjJD.mjs → CmsStatusBadge-kMTL6koE.mjs} +2 -2
  46. package/admin-dist/server/_ssr/{CmsSurface-DN9I2iuX.mjs → CmsSurface-D1HDYjRg.mjs} +1 -1
  47. package/admin-dist/server/_ssr/{CmsToolbar-ux-veU96.mjs → CmsToolbar-NB014hsd.mjs} +1 -1
  48. package/admin-dist/server/_ssr/{ContentEntryEditor-BiY9bJr9.mjs → ContentEntryEditor-Bq8FR_uK.mjs} +8 -8
  49. package/admin-dist/server/_ssr/{TaxonomyFilter-BdtKJie2.mjs → TaxonomyFilter-bm_p4ADg.mjs} +3 -3
  50. package/admin-dist/server/_ssr/{_contentTypeId-CRo5WQVu.mjs → _contentTypeId-B7obLmi_.mjs} +10 -10
  51. package/admin-dist/server/_ssr/{_entryId-FnG3uc_Y.mjs → _entryId-B4zhQqFg.mjs} +11 -11
  52. package/admin-dist/server/_ssr/_tanstack-start-manifest_v-DndoqCo7.mjs +4 -0
  53. package/admin-dist/server/_ssr/{badge-D3SGS0Jp.mjs → badge-NOEC9bkk.mjs} +1 -1
  54. package/admin-dist/server/_ssr/{command-2t7uTBKt.mjs → command-h4-OYNBo.mjs} +1 -1
  55. package/admin-dist/server/_ssr/{content-CCsSzXeb.mjs → content-CShtLuhK.mjs} +8 -8
  56. package/admin-dist/server/_ssr/{content-types-CuVG3uSt.mjs → content-types-PeyRyfbc.mjs} +6 -6
  57. package/admin-dist/server/_ssr/{index-CLwCLoco.mjs → index-CplFXpGg.mjs} +3 -3
  58. package/admin-dist/server/_ssr/index.mjs +2 -2
  59. package/admin-dist/server/_ssr/{media-D3duVWkk.mjs → media-QAkNdX54.mjs} +9 -9
  60. package/admin-dist/server/_ssr/{new._contentTypeId-6uKYdgGO.mjs → new._contentTypeId-DEJyMphJ.mjs} +10 -10
  61. package/admin-dist/server/_ssr/{router-D9Zk56-q.mjs → router-CQXMuGMF.mjs} +59 -16
  62. package/admin-dist/server/_ssr/{scroll-area-vbjKsfFu.mjs → scroll-area-B7zoNyWB.mjs} +1 -1
  63. package/admin-dist/server/_ssr/{settings-D7-vwjqD.mjs → settings-CNaqVa4D.mjs} +97 -82
  64. package/admin-dist/server/_ssr/{switch-CbKuV4Qh.mjs → switch-BKZhvryc.mjs} +1 -1
  65. package/admin-dist/server/_ssr/{tabs-C_IfqLiu.mjs → tabs-DtIIQxiD.mjs} +1 -1
  66. package/admin-dist/server/_ssr/{tanstack-adapter-yhyAcBi-.mjs → tanstack-adapter-CLavdbUY.mjs} +1 -1
  67. package/admin-dist/server/_ssr/{taxonomies-C15s_nvM.mjs → taxonomies-vIZYICzr.mjs} +7 -7
  68. package/admin-dist/server/_ssr/{trash-BPIjmAUh.mjs → trash-7yGR4-dF.mjs} +7 -7
  69. package/admin-dist/server/_ssr/{useBreadcrumbLabel-BC7plG0L.mjs → useBreadcrumbLabel-DR5FaAMf.mjs} +1 -1
  70. package/admin-dist/server/_ssr/{usePermissions-DJ8a7bZU.mjs → usePermissions-DKkpETj_.mjs} +1 -1
  71. package/admin-dist/server/index.mjs +159 -159
  72. package/package.json +1 -1
  73. package/admin-dist/public/assets/settings-DB6TvceQ.js +0 -1
  74. package/admin-dist/server/_ssr/_tanstack-start-manifest_v-BbSNqRIw.mjs +0 -4
@@ -1 +1 @@
1
- import{m as F,r as o,u as N,j as s,ak as P,al as B,C,p as E,q as M,h as O,am as $,X as A,g as D,x as q}from"./main-BrFRroF1.js";import{C as G,a as Q,b as V,c as X,d as H,e as J,f as K}from"./command-BsmkQ6_j.js";import{B as v}from"./badge-Cmc3T9vs.js";function ss({selectedTermIds:e,onChange:n,taxonomyId:r,placeholder:b="Filter by tags...",disabled:y=!1,className:k}){const d=F(),[p,h]=o.useState(!1),[c,w]=o.useState(""),m=N(d.listTaxonomies,{isActive:!0}),i=m?.page??[],_=o.useMemo(()=>r?i.find(a=>a._id===r):null,[r,i]),u=r??i[0]?._id,g=N(d.listTerms,u?{taxonomyId:u,paginationOpts:{numItems:200,cursor:null}}:"skip"),t=g?.page??[],f=o.useMemo(()=>t.filter(a=>e.includes(a._id)),[t,e]),j=o.useMemo(()=>{if(!c.trim())return t;const a=c.toLowerCase();return t.filter(l=>l.name.toLowerCase().includes(a))},[t,c]),z=o.useCallback(a=>{e.includes(a)?n(e.filter(l=>l!==a)):n([...e,a])},[e,n]),S=o.useCallback(()=>{n([]),h(!1)},[n]),L=o.useCallback((a,l)=>{l.stopPropagation(),n(e.filter(T=>T!==a))},[e,n]),x=_?.displayName??i[0]?.displayName??"Tags",R=m===void 0||!!u&&g===void 0;return i.length===0&&m!==void 0?null:s.jsxs(P,{open:p,onOpenChange:h,children:[s.jsx(B,{asChild:!0,children:s.jsxs(C,{variant:"outline",role:"combobox","aria-expanded":p,disabled:y||R,className:O("h-9 min-w-[140px] justify-between gap-2",e.length>0&&"border-primary/50",k),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{className:"size-4 text-muted-foreground"}),e.length===0?s.jsx("span",{className:"text-muted-foreground",children:b}):e.length===1?s.jsx("span",{className:"max-w-[100px] truncate",children:f[0]?.name??"Tag"}):s.jsxs("span",{children:[e.length," tags"]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[e.length>0&&s.jsx(v,{variant:"secondary",className:"size-5 rounded-full p-0 text-xs",children:e.length}),s.jsx(M,{className:"size-4 text-muted-foreground"})]})]})}),s.jsx($,{className:"w-[280px] p-0",align:"start",children:s.jsxs(G,{shouldFilter:!1,children:[s.jsx(Q,{placeholder:`Search ${x.toLowerCase()}...`,value:c,onValueChange:w}),s.jsx(V,{children:j.length===0?s.jsx(X,{children:t.length===0?`No ${x.toLowerCase()} found`:"No matches"}):s.jsx(H,{heading:x,children:j.map(a=>s.jsx(U,{term:a,isSelected:e.includes(a._id),onToggle:()=>z(a._id)},a._id))})}),e.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(J,{}),s.jsxs("div",{className:"p-2",children:[s.jsx("div",{className:"mb-2 flex flex-wrap gap-1",children:f.map(a=>s.jsxs(v,{variant:"secondary",className:"gap-1 pr-1",style:a.color?{backgroundColor:a.color,color:"#fff"}:void 0,children:[a.name,s.jsx("button",{type:"button",className:"ml-0.5 rounded-full p-0.5 hover:bg-black/10",onClick:l=>L(a._id,l),"aria-label":`Remove ${a.name}`,children:s.jsx(A,{className:"size-3"})})]},a._id))}),s.jsx(C,{variant:"ghost",size:"sm",className:"w-full",onClick:S,children:"Clear all filters"})]})]})]})})]})}function U({term:e,isSelected:n,onToggle:r}){return s.jsxs(K,{onSelect:r,className:"cursor-pointer",children:[s.jsx(D,{checked:n,className:"mr-2","aria-hidden":"true",tabIndex:-1}),e.color&&s.jsx("span",{className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),s.jsx("span",{className:"flex-1 truncate",children:e.name}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.usageCount}),n&&s.jsx(q,{className:"ml-1 size-4 text-primary"})]})}export{ss as T};
1
+ import{m as F,r as o,u as N,j as s,ak as P,al as B,C,p as E,q as M,h as O,am as $,X as A,g as D,w as q}from"./main-CA-4LyFT.js";import{C as G,a as Q,b as V,c as X,d as H,e as J,f as K}from"./command-CJ8i86fd.js";import{B as v}from"./badge-C6qt24oj.js";function ss({selectedTermIds:e,onChange:n,taxonomyId:r,placeholder:b="Filter by tags...",disabled:y=!1,className:k}){const d=F(),[p,h]=o.useState(!1),[c,w]=o.useState(""),m=N(d.listTaxonomies,{isActive:!0}),i=m?.page??[],_=o.useMemo(()=>r?i.find(a=>a._id===r):null,[r,i]),u=r??i[0]?._id,g=N(d.listTerms,u?{taxonomyId:u,paginationOpts:{numItems:200,cursor:null}}:"skip"),t=g?.page??[],f=o.useMemo(()=>t.filter(a=>e.includes(a._id)),[t,e]),j=o.useMemo(()=>{if(!c.trim())return t;const a=c.toLowerCase();return t.filter(l=>l.name.toLowerCase().includes(a))},[t,c]),z=o.useCallback(a=>{e.includes(a)?n(e.filter(l=>l!==a)):n([...e,a])},[e,n]),S=o.useCallback(()=>{n([]),h(!1)},[n]),L=o.useCallback((a,l)=>{l.stopPropagation(),n(e.filter(T=>T!==a))},[e,n]),x=_?.displayName??i[0]?.displayName??"Tags",R=m===void 0||!!u&&g===void 0;return i.length===0&&m!==void 0?null:s.jsxs(P,{open:p,onOpenChange:h,children:[s.jsx(B,{asChild:!0,children:s.jsxs(C,{variant:"outline",role:"combobox","aria-expanded":p,disabled:y||R,className:O("h-9 min-w-[140px] justify-between gap-2",e.length>0&&"border-primary/50",k),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{className:"size-4 text-muted-foreground"}),e.length===0?s.jsx("span",{className:"text-muted-foreground",children:b}):e.length===1?s.jsx("span",{className:"max-w-[100px] truncate",children:f[0]?.name??"Tag"}):s.jsxs("span",{children:[e.length," tags"]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[e.length>0&&s.jsx(v,{variant:"secondary",className:"size-5 rounded-full p-0 text-xs",children:e.length}),s.jsx(M,{className:"size-4 text-muted-foreground"})]})]})}),s.jsx($,{className:"w-[280px] p-0",align:"start",children:s.jsxs(G,{shouldFilter:!1,children:[s.jsx(Q,{placeholder:`Search ${x.toLowerCase()}...`,value:c,onValueChange:w}),s.jsx(V,{children:j.length===0?s.jsx(X,{children:t.length===0?`No ${x.toLowerCase()} found`:"No matches"}):s.jsx(H,{heading:x,children:j.map(a=>s.jsx(U,{term:a,isSelected:e.includes(a._id),onToggle:()=>z(a._id)},a._id))})}),e.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(J,{}),s.jsxs("div",{className:"p-2",children:[s.jsx("div",{className:"mb-2 flex flex-wrap gap-1",children:f.map(a=>s.jsxs(v,{variant:"secondary",className:"gap-1 pr-1",style:a.color?{backgroundColor:a.color,color:"#fff"}:void 0,children:[a.name,s.jsx("button",{type:"button",className:"ml-0.5 rounded-full p-0.5 hover:bg-black/10",onClick:l=>L(a._id,l),"aria-label":`Remove ${a.name}`,children:s.jsx(A,{className:"size-3"})})]},a._id))}),s.jsx(C,{variant:"ghost",size:"sm",className:"w-full",onClick:S,children:"Clear all filters"})]})]})]})})]})}function U({term:e,isSelected:n,onToggle:r}){return s.jsxs(K,{onSelect:r,className:"cursor-pointer",children:[s.jsx(D,{checked:n,className:"mr-2","aria-hidden":"true",tabIndex:-1}),e.color&&s.jsx("span",{className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),s.jsx("span",{className:"flex-1 truncate",children:e.name}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.usageCount}),n&&s.jsx(q,{className:"ml-1 size-4 text-primary"})]})}export{ss as T};
@@ -1 +1 @@
1
- import{l as ce,ah as de,ae as ue,r as s,a as me,k as x,u as g,j as e,F as J,C as u,ai as P,P as he,I as xe,S as pe,b as fe,c as ge,d as je,e as j,i as ye,aj as Ce,q as Ne}from"./main-BrFRroF1.js";import{u as ve}from"./usePermissions-BM1Vv1YJ.js";import{u as be}from"./useBreadcrumbLabel-BC8wl3jQ.js";import{C as Se}from"./CmsPageHeader-Cf0SafVG.js";import{C as Te}from"./CmsToolbar-B1zdfMu0.js";import{C as ke}from"./CmsStatusBadge-BovugIHH.js";import{C as K}from"./CmsEmptyState-la_kLGHv.js";import{T as Ee}from"./TaxonomyFilter-fmZxxbdA.js";import{S as De}from"./search-BsuImjd-.js";import"./badge-Cmc3T9vs.js";import"./command-BsmkQ6_j.js";const we=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ie=ce("arrow-up-down",we);function Oe(){const{contentTypeId:T}=de.useParams(),W=ue(),[y,_]=s.useState("all"),[C,B]=s.useState(""),[X,M]=s.useState(""),[N,Y]=s.useState("updatedAt"),[v,L]=s.useState("desc"),[d,c]=s.useState(0),[n,$]=s.useState([]),b=25,{canCreate:Z,canUpdate:ee,canDelete:te}=ve(),R=me(x.admin.deleteEntry),[se,k]=s.useState(!1),[p,E]=s.useState(null),[D,U]=s.useState(!1),[ae,S]=s.useState(null);s.useEffect(()=>{const t=setTimeout(()=>{M(C),c(0)},300);return()=>clearTimeout(t)},[C]);const l=g(x.admin.getContentType,{id:T});be(`/entries/type/${T}`,l?.displayName);const O=g(x.admin.listEntries,{contentTypeName:l?.name,status:y==="all"?void 0:y,search:X||void 0,paginationOpts:{numItems:250,cursor:null}}),V=O?.page??[],Q=g(x.admin.getEntriesByTerm,n[0]?{termId:n[0]}:"skip"),q=g(x.admin.getEntriesByTerm,n[1]?{termId:n[1]}:"skip"),H=g(x.admin.getEntriesByTerm,n[2]?{termId:n[2]}:"skip"),w=s.useMemo(()=>{if(n.length===0)return null;const t=new Set,a=[Q,q,H];for(let r=0;r<n.length&&r<3;r++){const i=a[r];if(i?.page)for(const f of i.page)t.add(f)}return t},[n,Q,q,H]),m=s.useCallback(t=>{const a=l?.titleField??"title",r=t.data[a];return typeof r=="string"&&r?r:"Untitled"},[l?.titleField]),o=s.useMemo(()=>{let t=[...V];return w!==null&&(t=t.filter(a=>w.has(a._id))),t.sort((a,r)=>{let i=0;switch(N){case"title":{const f=m(a).toLowerCase(),z=m(r).toLowerCase();i=f.localeCompare(z);break}case"status":i=a.status.localeCompare(r.status);break;case"updatedAt":{const f=a.lastPublishedAt??a._creationTime??0,z=r.lastPublishedAt??r._creationTime??0;i=f-z;break}case"createdAt":i=(a._creationTime??0)-(r._creationTime??0);break;default:i=0}return v==="desc"?-i:i}),t},[V,N,v,m,w]),G=s.useMemo(()=>{const t=d*b;return o.slice(t,t+b)},[o,d,b]),h=Math.ceil(o.length/b),re=t=>new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),I=t=>{N===t?L(v==="asc"?"desc":"asc"):(Y(t),L("desc"))},A=t=>N!==t?e.jsx(Ie,{className:"size-3.5 text-muted-foreground/50"}):v==="asc"?e.jsx(Ce,{className:"size-3.5"}):e.jsx(Ne,{className:"size-3.5"}),ne=s.useCallback(t=>{const a=m(t);E({_id:t._id,title:a}),S(null),k(!0)},[m]),le=s.useCallback(async()=>{if(p){U(!0),S(null);try{await R({id:p._id,hardDelete:!1}),k(!1),E(null)}catch(t){const a=t instanceof Error?t.message:"Failed to delete entry";S(a)}finally{U(!1)}}},[p,R]),ie=s.useCallback(t=>{!t&&!D&&(k(!1),E(null),S(null))},[D]),oe=s.useCallback(()=>{B(""),M(""),_("all"),$([]),c(0)},[]);if(l===void 0||O===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 entries..."})]})});if(l===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(K,{icon:e.jsx(J,{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:()=>W({to:"/content-types"})}})});const F=C||y!=="all"||n.length>0;return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(Se,{title:l.displayName,description:l.description,actions:Z("contentEntries")&&e.jsx(u,{asChild:!0,children:e.jsxs(P,{to:"/entries/new/$contentTypeId",params:{contentTypeId:T},children:[e.jsx(he,{className:"size-4"}),"Create ",l.displayName]})})}),e.jsx(Te,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(xe,{type:"search",placeholder:"Search entries...",value:C,onChange:t=>B(t.target.value),className:"w-64 pl-9"})]}),e.jsxs(pe,{value:y,onValueChange:t=>{_(t),c(0)},children:[e.jsx(fe,{className:"w-36",children:e.jsx(ge,{placeholder:"All Statuses"})}),e.jsxs(je,{children:[e.jsx(j,{value:"all",children:"All Statuses"}),e.jsx(j,{value:"draft",children:"Draft"}),e.jsx(j,{value:"published",children:"Published"}),e.jsx(j,{value:"scheduled",children:"Scheduled"}),e.jsx(j,{value:"archived",children:"Archived"})]})]}),e.jsx(Ee,{selectedTermIds:n,onChange:t=>{$(t),c(0)},placeholder:"Tags"})]}),right:e.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.length," ",o.length===1?"entry":"entries"]})}),o.length===0?e.jsx(K,{icon:e.jsx(J,{className:"size-6"}),title:F?"No matching entries":`No ${l.displayName} entries yet`,description:F?"Try adjusting your search or filter criteria.":`Click "Create ${l.displayName}" to add your first entry.`,action:F?{label:"Clear Filters",onClick:oe,variant:"secondary"}:void 0}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"p-3 text-left",children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground",onClick:()=>I("title"),children:["Title",A("title")]})}),e.jsx("th",{className:"p-3 text-left",children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground",onClick:()=>I("status"),children:["Status",A("status")]})}),e.jsx("th",{className:"p-3 text-left",children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground",onClick:()=>I("updatedAt"),children:["Updated",A("updatedAt")]})}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:G.map(t=>e.jsxs("tr",{className:"border-b last:border-0 transition-colors hover:bg-muted/50",children:[e.jsxs("td",{className:"p-3",children:[e.jsx(P,{to:"/entries/$entryId",params:{entryId:t._id},className:"font-medium text-foreground hover:text-primary hover:underline",children:m(t)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.slug})]}),e.jsx("td",{className:"p-3",children:e.jsx(ke,{status:t.status})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:re(t.lastPublishedAt??t._creationTime)}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{variant:"outline",size:"sm",asChild:!0,children:e.jsx(P,{to:"/entries/$entryId",params:{entryId:t._id},children:ee("contentEntries")?"Edit":"View"})}),te("contentEntries")&&e.jsx(u,{variant:"danger",size:"sm",onClick:()=>ne(t),"data-testid":`delete-entry-${t._id}`,children:"Delete"})]})})]},t._id))})]})}),h>1&&e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(0),disabled:d===0,children:"First"}),e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(t=>Math.max(0,t-1)),disabled:d===0,children:"Previous"}),e.jsxs("span",{className:"px-3 text-sm text-muted-foreground",children:["Page ",d+1," of ",h]}),e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(t=>Math.min(h-1,t+1)),disabled:d>=h-1,children:"Next"}),e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(h-1),disabled:d>=h-1,children:"Last"})]})]}),o.length>0&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Showing ",G.length," of ",o.length," ",o.length===1?"entry":"entries"]}),e.jsx(ye,{open:se,onOpenChange:ie,title:"Delete Entry",description:p?`Are you sure you want to delete "${p.title}"? It will be moved to the trash and can be restored within the retention period.`:"Are you sure you want to delete this entry?",confirmLabel:"Delete",variant:"danger",onConfirm:le,isLoading:D,error:ae})]})}export{Oe as component};
1
+ import{l as ce,ah as de,ae as ue,r as s,a as me,k as x,u as g,j as e,F as J,C as u,ai as P,P as he,I as xe,S as pe,b as fe,c as ge,d as je,e as j,i as ye,aj as Ce,q as Ne}from"./main-CA-4LyFT.js";import{u as ve}from"./usePermissions-BTGdTOJS.js";import{u as be}from"./useBreadcrumbLabel-tlSh7dtO.js";import{C as Se}from"./CmsPageHeader-0REGRH4X.js";import{C as Te}from"./CmsToolbar-CY6GV2L8.js";import{C as ke}from"./CmsStatusBadge-D_n8u8xa.js";import{C as K}from"./CmsEmptyState-DTlpzjOI.js";import{T as Ee}from"./TaxonomyFilter-Ohv5Jg9c.js";import{S as De}from"./search-WXp6KxDJ.js";import"./badge-C6qt24oj.js";import"./command-CJ8i86fd.js";const we=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ie=ce("arrow-up-down",we);function Oe(){const{contentTypeId:T}=de.useParams(),W=ue(),[y,_]=s.useState("all"),[C,B]=s.useState(""),[X,M]=s.useState(""),[N,Y]=s.useState("updatedAt"),[v,L]=s.useState("desc"),[d,c]=s.useState(0),[n,$]=s.useState([]),b=25,{canCreate:Z,canUpdate:ee,canDelete:te}=ve(),R=me(x.admin.deleteEntry),[se,k]=s.useState(!1),[p,E]=s.useState(null),[D,U]=s.useState(!1),[ae,S]=s.useState(null);s.useEffect(()=>{const t=setTimeout(()=>{M(C),c(0)},300);return()=>clearTimeout(t)},[C]);const l=g(x.admin.getContentType,{id:T});be(`/entries/type/${T}`,l?.displayName);const O=g(x.admin.listEntries,{contentTypeName:l?.name,status:y==="all"?void 0:y,search:X||void 0,paginationOpts:{numItems:250,cursor:null}}),V=O?.page??[],Q=g(x.admin.getEntriesByTerm,n[0]?{termId:n[0]}:"skip"),q=g(x.admin.getEntriesByTerm,n[1]?{termId:n[1]}:"skip"),H=g(x.admin.getEntriesByTerm,n[2]?{termId:n[2]}:"skip"),w=s.useMemo(()=>{if(n.length===0)return null;const t=new Set,a=[Q,q,H];for(let r=0;r<n.length&&r<3;r++){const i=a[r];if(i?.page)for(const f of i.page)t.add(f)}return t},[n,Q,q,H]),m=s.useCallback(t=>{const a=l?.titleField??"title",r=t.data[a];return typeof r=="string"&&r?r:"Untitled"},[l?.titleField]),o=s.useMemo(()=>{let t=[...V];return w!==null&&(t=t.filter(a=>w.has(a._id))),t.sort((a,r)=>{let i=0;switch(N){case"title":{const f=m(a).toLowerCase(),z=m(r).toLowerCase();i=f.localeCompare(z);break}case"status":i=a.status.localeCompare(r.status);break;case"updatedAt":{const f=a.lastPublishedAt??a._creationTime??0,z=r.lastPublishedAt??r._creationTime??0;i=f-z;break}case"createdAt":i=(a._creationTime??0)-(r._creationTime??0);break;default:i=0}return v==="desc"?-i:i}),t},[V,N,v,m,w]),G=s.useMemo(()=>{const t=d*b;return o.slice(t,t+b)},[o,d,b]),h=Math.ceil(o.length/b),re=t=>new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),I=t=>{N===t?L(v==="asc"?"desc":"asc"):(Y(t),L("desc"))},A=t=>N!==t?e.jsx(Ie,{className:"size-3.5 text-muted-foreground/50"}):v==="asc"?e.jsx(Ce,{className:"size-3.5"}):e.jsx(Ne,{className:"size-3.5"}),ne=s.useCallback(t=>{const a=m(t);E({_id:t._id,title:a}),S(null),k(!0)},[m]),le=s.useCallback(async()=>{if(p){U(!0),S(null);try{await R({id:p._id,hardDelete:!1}),k(!1),E(null)}catch(t){const a=t instanceof Error?t.message:"Failed to delete entry";S(a)}finally{U(!1)}}},[p,R]),ie=s.useCallback(t=>{!t&&!D&&(k(!1),E(null),S(null))},[D]),oe=s.useCallback(()=>{B(""),M(""),_("all"),$([]),c(0)},[]);if(l===void 0||O===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 entries..."})]})});if(l===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(K,{icon:e.jsx(J,{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:()=>W({to:"/content-types"})}})});const F=C||y!=="all"||n.length>0;return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(Se,{title:l.displayName,description:l.description,actions:Z("contentEntries")&&e.jsx(u,{asChild:!0,children:e.jsxs(P,{to:"/entries/new/$contentTypeId",params:{contentTypeId:T},children:[e.jsx(he,{className:"size-4"}),"Create ",l.displayName]})})}),e.jsx(Te,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(xe,{type:"search",placeholder:"Search entries...",value:C,onChange:t=>B(t.target.value),className:"w-64 pl-9"})]}),e.jsxs(pe,{value:y,onValueChange:t=>{_(t),c(0)},children:[e.jsx(fe,{className:"w-36",children:e.jsx(ge,{placeholder:"All Statuses"})}),e.jsxs(je,{children:[e.jsx(j,{value:"all",children:"All Statuses"}),e.jsx(j,{value:"draft",children:"Draft"}),e.jsx(j,{value:"published",children:"Published"}),e.jsx(j,{value:"scheduled",children:"Scheduled"}),e.jsx(j,{value:"archived",children:"Archived"})]})]}),e.jsx(Ee,{selectedTermIds:n,onChange:t=>{$(t),c(0)},placeholder:"Tags"})]}),right:e.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.length," ",o.length===1?"entry":"entries"]})}),o.length===0?e.jsx(K,{icon:e.jsx(J,{className:"size-6"}),title:F?"No matching entries":`No ${l.displayName} entries yet`,description:F?"Try adjusting your search or filter criteria.":`Click "Create ${l.displayName}" to add your first entry.`,action:F?{label:"Clear Filters",onClick:oe,variant:"secondary"}:void 0}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"p-3 text-left",children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground",onClick:()=>I("title"),children:["Title",A("title")]})}),e.jsx("th",{className:"p-3 text-left",children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground",onClick:()=>I("status"),children:["Status",A("status")]})}),e.jsx("th",{className:"p-3 text-left",children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground",onClick:()=>I("updatedAt"),children:["Updated",A("updatedAt")]})}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:G.map(t=>e.jsxs("tr",{className:"border-b last:border-0 transition-colors hover:bg-muted/50",children:[e.jsxs("td",{className:"p-3",children:[e.jsx(P,{to:"/entries/$entryId",params:{entryId:t._id},className:"font-medium text-foreground hover:text-primary hover:underline",children:m(t)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.slug})]}),e.jsx("td",{className:"p-3",children:e.jsx(ke,{status:t.status})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:re(t.lastPublishedAt??t._creationTime)}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{variant:"outline",size:"sm",asChild:!0,children:e.jsx(P,{to:"/entries/$entryId",params:{entryId:t._id},children:ee("contentEntries")?"Edit":"View"})}),te("contentEntries")&&e.jsx(u,{variant:"danger",size:"sm",onClick:()=>ne(t),"data-testid":`delete-entry-${t._id}`,children:"Delete"})]})})]},t._id))})]})}),h>1&&e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(0),disabled:d===0,children:"First"}),e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(t=>Math.max(0,t-1)),disabled:d===0,children:"Previous"}),e.jsxs("span",{className:"px-3 text-sm text-muted-foreground",children:["Page ",d+1," of ",h]}),e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(t=>Math.min(h-1,t+1)),disabled:d>=h-1,children:"Next"}),e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(h-1),disabled:d>=h-1,children:"Last"})]})]}),o.length>0&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Showing ",G.length," of ",o.length," ",o.length===1?"entry":"entries"]}),e.jsx(ye,{open:se,onOpenChange:ie,title:"Delete Entry",description:p?`Are you sure you want to delete "${p.title}"? It will be moved to the trash and can be restored within the retention period.`:"Are you sure you want to delete this entry?",confirmLabel:"Delete",variant:"danger",onConfirm:le,isLoading:D,error:ae})]})}export{Oe as component};
@@ -1 +1 @@
1
- import{ag as f,ae as j,u as a,k as c,j as e,F as l}from"./main-BrFRroF1.js";import{C as h}from"./ContentEntryEditor-CB--8SC3.js";import{u as v}from"./usePermissions-BM1Vv1YJ.js";import{u as N}from"./useBreadcrumbLabel-BC8wl3jQ.js";import{C as d}from"./CmsEmptyState-la_kLGHv.js";import"./switch-DWN_fx2n.js";import"./tabs-BG0vukFH.js";import"./refresh-cw-D_KNzBUN.js";import"./pencil-PaJhpDeC.js";import"./search-BsuImjd-.js";import"./command-BsmkQ6_j.js";import"./badge-Cmc3T9vs.js";import"./CmsStatusBadge-BovugIHH.js";import"./scroll-area-t72-FBB4.js";import"./circle-check-big-B8AJAcBi.js";function Q(){const{entryId:i}=f.useParams(),o=j(),{canDelete:m}=v(),t=a(c.admin.getEntry,{id:i}),n=a(c.admin.getContentType,t?{name:t.contentTypeName}:"skip"),p=()=>{if(!t||!n)return;const r=n.titleField??"title",s=t.data[r];return typeof s=="string"&&s?s:"Untitled"};if(N(`/entries/${i}`,p()),t===void 0||t&&n===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 entry..."})]})});if(t===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(d,{icon:e.jsx(l,{className:"size-6"}),title:"Entry Not Found",description:"The content entry you're looking for doesn't exist or has been deleted.",action:{label:"Back to Content",onClick:()=>o({to:"/content-types"})}})});if(n===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(d,{icon:e.jsx(l,{className:"size-6"}),title:"Content Type Not Found",description:"The content type for this entry doesn't exist or has been deleted.",action:{label:"Back to Content",onClick:()=>o({to:"/content-types"})}})});const u=r=>{},y=()=>{o({to:"/content"})},x=()=>{o({to:"/content"})};return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(h,{contentType:n,entry:t,onSave:u,onCancel:y,onDelete:x,canDelete:m("contentEntries")})})}export{Q as component};
1
+ import{ag as f,ae as j,u as a,k as c,j as e,F as l}from"./main-CA-4LyFT.js";import{C as h}from"./ContentEntryEditor-CRgcRkk5.js";import{u as v}from"./usePermissions-BTGdTOJS.js";import{u as N}from"./useBreadcrumbLabel-tlSh7dtO.js";import{C as d}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 Q(){const{entryId:i}=f.useParams(),o=j(),{canDelete:m}=v(),t=a(c.admin.getEntry,{id:i}),n=a(c.admin.getContentType,t?{name:t.contentTypeName}:"skip"),p=()=>{if(!t||!n)return;const r=n.titleField??"title",s=t.data[r];return typeof s=="string"&&s?s:"Untitled"};if(N(`/entries/${i}`,p()),t===void 0||t&&n===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 entry..."})]})});if(t===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(d,{icon:e.jsx(l,{className:"size-6"}),title:"Entry Not Found",description:"The content entry you're looking for doesn't exist or has been deleted.",action:{label:"Back to Content",onClick:()=>o({to:"/content-types"})}})});if(n===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(d,{icon:e.jsx(l,{className:"size-6"}),title:"Content Type Not Found",description:"The content type for this entry doesn't exist or has been deleted.",action:{label:"Back to Content",onClick:()=>o({to:"/content-types"})}})});const u=r=>{},y=()=>{o({to:"/content"})},x=()=>{o({to:"/content"})};return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(h,{contentType:n,entry:t,onSave:u,onCancel:y,onDelete:x,canDelete:m("contentEntries")})})}export{Q as component};
@@ -1 +1 @@
1
- import{j as r,h as e,ac as i}from"./main-BrFRroF1.js";const l=i("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function d({className:t,variant:a,...s}){return r.jsx("div",{"data-slot":"alert",role:"alert",className:e(l({variant:a}),t),...s})}function c({className:t,...a}){return r.jsx("div",{"data-slot":"alert-title",className:e("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...a})}function o({className:t,...a}){return r.jsx("div",{"data-slot":"alert-description",className:e("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...a})}export{d as A,o as a,c as b};
1
+ import{j as r,h as e,ac as i}from"./main-CA-4LyFT.js";const l=i("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function d({className:t,variant:a,...s}){return r.jsx("div",{"data-slot":"alert",role:"alert",className:e(l({variant:a}),t),...s})}function c({className:t,...a}){return r.jsx("div",{"data-slot":"alert-title",className:e("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...a})}function o({className:t,...a}){return r.jsx("div",{"data-slot":"alert-description",className:e("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...a})}export{d as A,o as a,c as b};
@@ -1 +1 @@
1
- import{j as n,aT as s,h as o,ac as d}from"./main-BrFRroF1.js";const c=d("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function u({className:e,variant:r,asChild:t=!1,...a}){const i=t?s:"span";return n.jsx(i,{"data-slot":"badge",className:o(c({variant:r}),e),...a})}export{u as B};
1
+ import{j as n,aT as s,h as o,ac as d}from"./main-CA-4LyFT.js";const c=d("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function u({className:e,variant:r,asChild:t=!1,...a}){const i=t?s:"span";return n.jsx(i,{"data-slot":"badge",className:o(c({variant:r}),e),...a})}export{u as B};
@@ -1 +1 @@
1
- import{l as c}from"./main-BrFRroF1.js";const e=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],t=c("circle-check-big",e);export{t as C};
1
+ import{l as c}from"./main-CA-4LyFT.js";const e=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],t=c("circle-check-big",e);export{t as C};
@@ -1 +1 @@
1
- import{r as l,aJ as L,z as A,aO as Se,aP as Ce,aQ as Ie,aR as Re,aS as V,j as C,h as P}from"./main-BrFRroF1.js";import{S as Ae}from"./search-BsuImjd-.js";var me=1,je=.9,Me=.8,$e=.17,ee=.1,te=.999,De=.9999,Ne=.99,Fe=/[\\\/_+.#"@\[\(\{&]/,Ke=/[\\\/_+.#"@\[\(\{&]/g,Le=/[\s-]/,he=/[\s-]/g;function ne(e,n,r,f,u,c,d){if(c===n.length)return u===e.length?me:Ne;var m=`${u},${c}`;if(d[m]!==void 0)return d[m];for(var b=f.charAt(c),o=r.indexOf(b,u),v=0,h,S,w,I;o>=0;)h=ne(e,n,r,f,o+1,c+1,d),h>v&&(o===u?h*=me:Fe.test(e.charAt(o-1))?(h*=Me,w=e.slice(u,o-1).match(Ke),w&&u>0&&(h*=Math.pow(te,w.length))):Le.test(e.charAt(o-1))?(h*=je,I=e.slice(u,o-1).match(he),I&&u>0&&(h*=Math.pow(te,I.length))):(h*=$e,u>0&&(h*=Math.pow(te,o-u))),e.charAt(o)!==n.charAt(c)&&(h*=De)),(h<ee&&r.charAt(o-1)===f.charAt(c+1)||f.charAt(c+1)===f.charAt(c)&&r.charAt(o-1)!==f.charAt(c))&&(S=ne(e,n,r,f,o+1,c+2,d),S*ee>h&&(h=S*ee)),h>v&&(v=h),o=r.indexOf(b,o+1);return d[m]=v,v}function pe(e){return e.toLowerCase().replace(he," ")}function Pe(e,n,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,ne(e,n,pe(e),pe(n),0,0,{})}var z='[cmdk-group=""]',re='[cmdk-group-items=""]',qe='[cmdk-group-heading=""]',ge='[cmdk-item=""]',ve=`${ge}:not([aria-disabled="true"])`,le="cmdk-item-select",F="data-value",ze=(e,n,r)=>Pe(e,n,r),be=l.createContext(void 0),O=()=>l.useContext(be),xe=l.createContext(void 0),ae=()=>l.useContext(xe),ye=l.createContext(void 0),we=l.forwardRef((e,n)=>{let r=K(()=>{var t,i;return{search:"",value:(i=(t=e.value)!=null?t:e.defaultValue)!=null?i:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),f=K(()=>new Set),u=K(()=>new Map),c=K(()=>new Map),d=K(()=>new Set),m=ke(e),{label:b,children:o,value:v,onValueChange:h,filter:S,shouldFilter:w,loop:I,disablePointerSelection:H=!1,vimBindings:j=!0,...B}=e,J=L(),ue=L(),T=L(),M=l.useRef(null),x=Qe();$(()=>{if(v!==void 0){let t=v.trim();r.current.value=t,k.emit()}},[v]),$(()=>{x(6,ie)},[]);let k=l.useMemo(()=>({subscribe:t=>(d.current.add(t),()=>d.current.delete(t)),snapshot:()=>r.current,setState:(t,i,s)=>{var a,p,g,E;if(!Object.is(r.current[t],i)){if(r.current[t]=i,t==="search")X(),_(),x(1,Q);else if(t==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let y=document.getElementById(T);y?y.focus():(a=document.getElementById(J))==null||a.focus()}if(x(7,()=>{var y;r.current.selectedItemId=(y=N())==null?void 0:y.id,k.emit()}),s||x(5,ie),((p=m.current)==null?void 0:p.value)!==void 0){let y=i??"";(E=(g=m.current).onValueChange)==null||E.call(g,y);return}}k.emit()}},emit:()=>{d.current.forEach(t=>t())}}),[]),W=l.useMemo(()=>({value:(t,i,s)=>{var a;i!==((a=c.current.get(t))==null?void 0:a.value)&&(c.current.set(t,{value:i,keywords:s}),r.current.filtered.items.set(t,oe(i,s)),x(2,()=>{_(),k.emit()}))},item:(t,i)=>(f.current.add(t),i&&(u.current.has(i)?u.current.get(i).add(t):u.current.set(i,new Set([t]))),x(3,()=>{X(),_(),r.current.value||Q(),k.emit()}),()=>{c.current.delete(t),f.current.delete(t),r.current.filtered.items.delete(t);let s=N();x(4,()=>{X(),s?.getAttribute("id")===t&&Q(),k.emit()})}),group:t=>(u.current.has(t)||u.current.set(t,new Set),()=>{c.current.delete(t),u.current.delete(t)}),filter:()=>m.current.shouldFilter,label:b||e["aria-label"],getDisablePointerSelection:()=>m.current.disablePointerSelection,listId:J,inputId:T,labelId:ue,listInnerRef:M}),[]);function oe(t,i){var s,a;let p=(a=(s=m.current)==null?void 0:s.filter)!=null?a:ze;return t?p(t,r.current.search,i):0}function _(){if(!r.current.search||m.current.shouldFilter===!1)return;let t=r.current.filtered.items,i=[];r.current.filtered.groups.forEach(a=>{let p=u.current.get(a),g=0;p.forEach(E=>{let y=t.get(E);g=Math.max(y,g)}),i.push([a,g])});let s=M.current;q().sort((a,p)=>{var g,E;let y=a.getAttribute("id"),G=p.getAttribute("id");return((g=t.get(G))!=null?g:0)-((E=t.get(y))!=null?E:0)}).forEach(a=>{let p=a.closest(re);p?p.appendChild(a.parentElement===p?a:a.closest(`${re} > *`)):s.appendChild(a.parentElement===s?a:a.closest(`${re} > *`))}),i.sort((a,p)=>p[1]-a[1]).forEach(a=>{var p;let g=(p=M.current)==null?void 0:p.querySelector(`${z}[${F}="${encodeURIComponent(a[0])}"]`);g?.parentElement.appendChild(g)})}function Q(){let t=q().find(s=>s.getAttribute("aria-disabled")!=="true"),i=t?.getAttribute(F);k.setState("value",i||void 0)}function X(){var t,i,s,a;if(!r.current.search||m.current.shouldFilter===!1){r.current.filtered.count=f.current.size;return}r.current.filtered.groups=new Set;let p=0;for(let g of f.current){let E=(i=(t=c.current.get(g))==null?void 0:t.value)!=null?i:"",y=(a=(s=c.current.get(g))==null?void 0:s.keywords)!=null?a:[],G=oe(E,y);r.current.filtered.items.set(g,G),G>0&&p++}for(let[g,E]of u.current)for(let y of E)if(r.current.filtered.items.get(y)>0){r.current.filtered.groups.add(g);break}r.current.filtered.count=p}function ie(){var t,i,s;let a=N();a&&(((t=a.parentElement)==null?void 0:t.firstChild)===a&&((s=(i=a.closest(z))==null?void 0:i.querySelector(qe))==null||s.scrollIntoView({block:"nearest"})),a.scrollIntoView({block:"nearest"}))}function N(){var t;return(t=M.current)==null?void 0:t.querySelector(`${ge}[aria-selected="true"]`)}function q(){var t;return Array.from(((t=M.current)==null?void 0:t.querySelectorAll(ve))||[])}function Y(t){let i=q()[t];i&&k.setState("value",i.getAttribute(F))}function Z(t){var i;let s=N(),a=q(),p=a.findIndex(E=>E===s),g=a[p+t];(i=m.current)!=null&&i.loop&&(g=p+t<0?a[a.length-1]:p+t===a.length?a[0]:a[p+t]),g&&k.setState("value",g.getAttribute(F))}function ce(t){let i=N(),s=i?.closest(z),a;for(;s&&!a;)s=t>0?We(s,z):_e(s,z),a=s?.querySelector(ve);a?k.setState("value",a.getAttribute(F)):Z(t)}let de=()=>Y(q().length-1),se=t=>{t.preventDefault(),t.metaKey?de():t.altKey?ce(1):Z(1)},fe=t=>{t.preventDefault(),t.metaKey?Y(0):t.altKey?ce(-1):Z(-1)};return l.createElement(A.div,{ref:n,tabIndex:-1,...B,"cmdk-root":"",onKeyDown:t=>{var i;(i=B.onKeyDown)==null||i.call(B,t);let s=t.nativeEvent.isComposing||t.keyCode===229;if(!(t.defaultPrevented||s))switch(t.key){case"n":case"j":{j&&t.ctrlKey&&se(t);break}case"ArrowDown":{se(t);break}case"p":case"k":{j&&t.ctrlKey&&fe(t);break}case"ArrowUp":{fe(t);break}case"Home":{t.preventDefault(),Y(0);break}case"End":{t.preventDefault(),de();break}case"Enter":{t.preventDefault();let a=N();if(a){let p=new Event(le);a.dispatchEvent(p)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:W.inputId,id:W.labelId,style:Ye},b),U(e,t=>l.createElement(xe.Provider,{value:k},l.createElement(be.Provider,{value:W},t))))}),Ve=l.forwardRef((e,n)=>{var r,f;let u=L(),c=l.useRef(null),d=l.useContext(ye),m=O(),b=ke(e),o=(f=(r=b.current)==null?void 0:r.forceMount)!=null?f:d?.forceMount;$(()=>{if(!o)return m.item(u,d?.id)},[o]);let v=Ee(u,c,[e.value,e.children,c],e.keywords),h=ae(),S=R(x=>x.value&&x.value===v.current),w=R(x=>o||m.filter()===!1?!0:x.search?x.filtered.items.get(u)>0:!0);l.useEffect(()=>{let x=c.current;if(!(!x||e.disabled))return x.addEventListener(le,I),()=>x.removeEventListener(le,I)},[w,e.onSelect,e.disabled]);function I(){var x,k;H(),(k=(x=b.current).onSelect)==null||k.call(x,v.current)}function H(){h.setState("value",v.current,!0)}if(!w)return null;let{disabled:j,value:B,onSelect:J,forceMount:ue,keywords:T,...M}=e;return l.createElement(A.div,{ref:V(c,n),...M,id:u,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!S,"data-disabled":!!j,"data-selected":!!S,onPointerMove:j||m.getDisablePointerSelection()?void 0:H,onClick:j?void 0:I},e.children)}),Oe=l.forwardRef((e,n)=>{let{heading:r,children:f,forceMount:u,...c}=e,d=L(),m=l.useRef(null),b=l.useRef(null),o=L(),v=O(),h=R(w=>u||v.filter()===!1?!0:w.search?w.filtered.groups.has(d):!0);$(()=>v.group(d),[]),Ee(d,m,[e.value,e.heading,b]);let S=l.useMemo(()=>({id:d,forceMount:u}),[u]);return l.createElement(A.div,{ref:V(m,n),...c,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},r&&l.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":!0,id:o},r),U(e,w=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?o:void 0},l.createElement(ye.Provider,{value:S},w))))}),Be=l.forwardRef((e,n)=>{let{alwaysRender:r,...f}=e,u=l.useRef(null),c=R(d=>!d.search);return!r&&!c?null:l.createElement(A.div,{ref:V(u,n),...f,"cmdk-separator":"",role:"separator"})}),Ge=l.forwardRef((e,n)=>{let{onValueChange:r,...f}=e,u=e.value!=null,c=ae(),d=R(o=>o.search),m=R(o=>o.selectedItemId),b=O();return l.useEffect(()=>{e.value!=null&&c.setState("search",e.value)},[e.value]),l.createElement(A.input,{ref:n,...f,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":m,id:b.inputId,type:"text",value:u?e.value:d,onChange:o=>{u||c.setState("search",o.target.value),r?.(o.target.value)}})}),Ue=l.forwardRef((e,n)=>{let{children:r,label:f="Suggestions",...u}=e,c=l.useRef(null),d=l.useRef(null),m=R(o=>o.selectedItemId),b=O();return l.useEffect(()=>{if(d.current&&c.current){let o=d.current,v=c.current,h,S=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let w=o.offsetHeight;v.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return S.observe(o),()=>{cancelAnimationFrame(h),S.unobserve(o)}}},[]),l.createElement(A.div,{ref:V(c,n),...u,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":m,"aria-label":f,id:b.listId},U(e,o=>l.createElement("div",{ref:V(d,b.listInnerRef),"cmdk-list-sizer":""},o)))}),He=l.forwardRef((e,n)=>{let{open:r,onOpenChange:f,overlayClassName:u,contentClassName:c,container:d,...m}=e;return l.createElement(Se,{open:r,onOpenChange:f},l.createElement(Ce,{container:d},l.createElement(Ie,{"cmdk-overlay":"",className:u}),l.createElement(Re,{"aria-label":e.label,"cmdk-dialog":"",className:c},l.createElement(we,{ref:n,...m}))))}),Je=l.forwardRef((e,n)=>R(r=>r.filtered.count===0)?l.createElement(A.div,{ref:n,...e,"cmdk-empty":"",role:"presentation"}):null),Te=l.forwardRef((e,n)=>{let{progress:r,children:f,label:u="Loading...",...c}=e;return l.createElement(A.div,{ref:n,...c,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":u},U(e,d=>l.createElement("div",{"aria-hidden":!0},d)))}),D=Object.assign(we,{List:Ue,Item:Ve,Input:Ge,Group:Oe,Separator:Be,Dialog:He,Empty:Je,Loading:Te});function We(e,n){let r=e.nextElementSibling;for(;r;){if(r.matches(n))return r;r=r.nextElementSibling}}function _e(e,n){let r=e.previousElementSibling;for(;r;){if(r.matches(n))return r;r=r.previousElementSibling}}function ke(e){let n=l.useRef(e);return $(()=>{n.current=e}),n}var $=typeof window>"u"?l.useEffect:l.useLayoutEffect;function K(e){let n=l.useRef();return n.current===void 0&&(n.current=e()),n}function R(e){let n=ae(),r=()=>e(n.snapshot());return l.useSyncExternalStore(n.subscribe,r,r)}function Ee(e,n,r,f=[]){let u=l.useRef(),c=O();return $(()=>{var d;let m=(()=>{var o;for(let v of r){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(o=v.current.textContent)==null?void 0:o.trim():u.current}})(),b=f.map(o=>o.trim());c.value(e,m,b),(d=n.current)==null||d.setAttribute(F,m),u.current=m}),u}var Qe=()=>{let[e,n]=l.useState(),r=K(()=>new Map);return $(()=>{r.current.forEach(f=>f()),r.current=new Map},[e]),(f,u)=>{r.current.set(f,u),n({})}};function Xe(e){let n=e.type;return typeof n=="function"?n(e.props):"render"in n?n.render(e.props):e}function U({asChild:e,children:n},r){return e&&l.isValidElement(n)?l.cloneElement(Xe(n),{ref:n.ref},r(n.props.children)):r(n)}var Ye={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function tt({className:e,...n}){return C.jsx(D,{"data-slot":"command",className:P("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...n})}function rt({className:e,...n}){return C.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[C.jsx(Ae,{className:"size-4 shrink-0 opacity-50"}),C.jsx(D.Input,{"data-slot":"command-input",className:P("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...n})]})}function nt({className:e,...n}){return C.jsx(D.List,{"data-slot":"command-list",className:P("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...n})}function lt({...e}){return C.jsx(D.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function at({className:e,...n}){return C.jsx(D.Group,{"data-slot":"command-group",className:P("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...n})}function ut({className:e,...n}){return C.jsx(D.Separator,{"data-slot":"command-separator",className:P("bg-border -mx-1 h-px",e),...n})}function ot({className:e,...n}){return C.jsx(D.Item,{"data-slot":"command-item",className:P("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n})}export{tt as C,rt as a,nt as b,lt as c,at as d,ut as e,ot as f};
1
+ import{r as l,aJ as L,z as A,aO as Se,aP as Ce,aQ as Ie,aR as Re,aS as V,j as C,h as P}from"./main-CA-4LyFT.js";import{S as Ae}from"./search-WXp6KxDJ.js";var me=1,je=.9,Me=.8,$e=.17,ee=.1,te=.999,De=.9999,Ne=.99,Fe=/[\\\/_+.#"@\[\(\{&]/,Ke=/[\\\/_+.#"@\[\(\{&]/g,Le=/[\s-]/,he=/[\s-]/g;function ne(e,n,r,f,u,c,d){if(c===n.length)return u===e.length?me:Ne;var m=`${u},${c}`;if(d[m]!==void 0)return d[m];for(var b=f.charAt(c),o=r.indexOf(b,u),v=0,h,S,w,I;o>=0;)h=ne(e,n,r,f,o+1,c+1,d),h>v&&(o===u?h*=me:Fe.test(e.charAt(o-1))?(h*=Me,w=e.slice(u,o-1).match(Ke),w&&u>0&&(h*=Math.pow(te,w.length))):Le.test(e.charAt(o-1))?(h*=je,I=e.slice(u,o-1).match(he),I&&u>0&&(h*=Math.pow(te,I.length))):(h*=$e,u>0&&(h*=Math.pow(te,o-u))),e.charAt(o)!==n.charAt(c)&&(h*=De)),(h<ee&&r.charAt(o-1)===f.charAt(c+1)||f.charAt(c+1)===f.charAt(c)&&r.charAt(o-1)!==f.charAt(c))&&(S=ne(e,n,r,f,o+1,c+2,d),S*ee>h&&(h=S*ee)),h>v&&(v=h),o=r.indexOf(b,o+1);return d[m]=v,v}function pe(e){return e.toLowerCase().replace(he," ")}function Pe(e,n,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,ne(e,n,pe(e),pe(n),0,0,{})}var z='[cmdk-group=""]',re='[cmdk-group-items=""]',qe='[cmdk-group-heading=""]',ge='[cmdk-item=""]',ve=`${ge}:not([aria-disabled="true"])`,le="cmdk-item-select",F="data-value",ze=(e,n,r)=>Pe(e,n,r),be=l.createContext(void 0),O=()=>l.useContext(be),xe=l.createContext(void 0),ae=()=>l.useContext(xe),ye=l.createContext(void 0),we=l.forwardRef((e,n)=>{let r=K(()=>{var t,i;return{search:"",value:(i=(t=e.value)!=null?t:e.defaultValue)!=null?i:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),f=K(()=>new Set),u=K(()=>new Map),c=K(()=>new Map),d=K(()=>new Set),m=ke(e),{label:b,children:o,value:v,onValueChange:h,filter:S,shouldFilter:w,loop:I,disablePointerSelection:H=!1,vimBindings:j=!0,...B}=e,J=L(),ue=L(),T=L(),M=l.useRef(null),x=Qe();$(()=>{if(v!==void 0){let t=v.trim();r.current.value=t,k.emit()}},[v]),$(()=>{x(6,ie)},[]);let k=l.useMemo(()=>({subscribe:t=>(d.current.add(t),()=>d.current.delete(t)),snapshot:()=>r.current,setState:(t,i,s)=>{var a,p,g,E;if(!Object.is(r.current[t],i)){if(r.current[t]=i,t==="search")X(),_(),x(1,Q);else if(t==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let y=document.getElementById(T);y?y.focus():(a=document.getElementById(J))==null||a.focus()}if(x(7,()=>{var y;r.current.selectedItemId=(y=N())==null?void 0:y.id,k.emit()}),s||x(5,ie),((p=m.current)==null?void 0:p.value)!==void 0){let y=i??"";(E=(g=m.current).onValueChange)==null||E.call(g,y);return}}k.emit()}},emit:()=>{d.current.forEach(t=>t())}}),[]),W=l.useMemo(()=>({value:(t,i,s)=>{var a;i!==((a=c.current.get(t))==null?void 0:a.value)&&(c.current.set(t,{value:i,keywords:s}),r.current.filtered.items.set(t,oe(i,s)),x(2,()=>{_(),k.emit()}))},item:(t,i)=>(f.current.add(t),i&&(u.current.has(i)?u.current.get(i).add(t):u.current.set(i,new Set([t]))),x(3,()=>{X(),_(),r.current.value||Q(),k.emit()}),()=>{c.current.delete(t),f.current.delete(t),r.current.filtered.items.delete(t);let s=N();x(4,()=>{X(),s?.getAttribute("id")===t&&Q(),k.emit()})}),group:t=>(u.current.has(t)||u.current.set(t,new Set),()=>{c.current.delete(t),u.current.delete(t)}),filter:()=>m.current.shouldFilter,label:b||e["aria-label"],getDisablePointerSelection:()=>m.current.disablePointerSelection,listId:J,inputId:T,labelId:ue,listInnerRef:M}),[]);function oe(t,i){var s,a;let p=(a=(s=m.current)==null?void 0:s.filter)!=null?a:ze;return t?p(t,r.current.search,i):0}function _(){if(!r.current.search||m.current.shouldFilter===!1)return;let t=r.current.filtered.items,i=[];r.current.filtered.groups.forEach(a=>{let p=u.current.get(a),g=0;p.forEach(E=>{let y=t.get(E);g=Math.max(y,g)}),i.push([a,g])});let s=M.current;q().sort((a,p)=>{var g,E;let y=a.getAttribute("id"),G=p.getAttribute("id");return((g=t.get(G))!=null?g:0)-((E=t.get(y))!=null?E:0)}).forEach(a=>{let p=a.closest(re);p?p.appendChild(a.parentElement===p?a:a.closest(`${re} > *`)):s.appendChild(a.parentElement===s?a:a.closest(`${re} > *`))}),i.sort((a,p)=>p[1]-a[1]).forEach(a=>{var p;let g=(p=M.current)==null?void 0:p.querySelector(`${z}[${F}="${encodeURIComponent(a[0])}"]`);g?.parentElement.appendChild(g)})}function Q(){let t=q().find(s=>s.getAttribute("aria-disabled")!=="true"),i=t?.getAttribute(F);k.setState("value",i||void 0)}function X(){var t,i,s,a;if(!r.current.search||m.current.shouldFilter===!1){r.current.filtered.count=f.current.size;return}r.current.filtered.groups=new Set;let p=0;for(let g of f.current){let E=(i=(t=c.current.get(g))==null?void 0:t.value)!=null?i:"",y=(a=(s=c.current.get(g))==null?void 0:s.keywords)!=null?a:[],G=oe(E,y);r.current.filtered.items.set(g,G),G>0&&p++}for(let[g,E]of u.current)for(let y of E)if(r.current.filtered.items.get(y)>0){r.current.filtered.groups.add(g);break}r.current.filtered.count=p}function ie(){var t,i,s;let a=N();a&&(((t=a.parentElement)==null?void 0:t.firstChild)===a&&((s=(i=a.closest(z))==null?void 0:i.querySelector(qe))==null||s.scrollIntoView({block:"nearest"})),a.scrollIntoView({block:"nearest"}))}function N(){var t;return(t=M.current)==null?void 0:t.querySelector(`${ge}[aria-selected="true"]`)}function q(){var t;return Array.from(((t=M.current)==null?void 0:t.querySelectorAll(ve))||[])}function Y(t){let i=q()[t];i&&k.setState("value",i.getAttribute(F))}function Z(t){var i;let s=N(),a=q(),p=a.findIndex(E=>E===s),g=a[p+t];(i=m.current)!=null&&i.loop&&(g=p+t<0?a[a.length-1]:p+t===a.length?a[0]:a[p+t]),g&&k.setState("value",g.getAttribute(F))}function ce(t){let i=N(),s=i?.closest(z),a;for(;s&&!a;)s=t>0?We(s,z):_e(s,z),a=s?.querySelector(ve);a?k.setState("value",a.getAttribute(F)):Z(t)}let de=()=>Y(q().length-1),se=t=>{t.preventDefault(),t.metaKey?de():t.altKey?ce(1):Z(1)},fe=t=>{t.preventDefault(),t.metaKey?Y(0):t.altKey?ce(-1):Z(-1)};return l.createElement(A.div,{ref:n,tabIndex:-1,...B,"cmdk-root":"",onKeyDown:t=>{var i;(i=B.onKeyDown)==null||i.call(B,t);let s=t.nativeEvent.isComposing||t.keyCode===229;if(!(t.defaultPrevented||s))switch(t.key){case"n":case"j":{j&&t.ctrlKey&&se(t);break}case"ArrowDown":{se(t);break}case"p":case"k":{j&&t.ctrlKey&&fe(t);break}case"ArrowUp":{fe(t);break}case"Home":{t.preventDefault(),Y(0);break}case"End":{t.preventDefault(),de();break}case"Enter":{t.preventDefault();let a=N();if(a){let p=new Event(le);a.dispatchEvent(p)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:W.inputId,id:W.labelId,style:Ye},b),U(e,t=>l.createElement(xe.Provider,{value:k},l.createElement(be.Provider,{value:W},t))))}),Ve=l.forwardRef((e,n)=>{var r,f;let u=L(),c=l.useRef(null),d=l.useContext(ye),m=O(),b=ke(e),o=(f=(r=b.current)==null?void 0:r.forceMount)!=null?f:d?.forceMount;$(()=>{if(!o)return m.item(u,d?.id)},[o]);let v=Ee(u,c,[e.value,e.children,c],e.keywords),h=ae(),S=R(x=>x.value&&x.value===v.current),w=R(x=>o||m.filter()===!1?!0:x.search?x.filtered.items.get(u)>0:!0);l.useEffect(()=>{let x=c.current;if(!(!x||e.disabled))return x.addEventListener(le,I),()=>x.removeEventListener(le,I)},[w,e.onSelect,e.disabled]);function I(){var x,k;H(),(k=(x=b.current).onSelect)==null||k.call(x,v.current)}function H(){h.setState("value",v.current,!0)}if(!w)return null;let{disabled:j,value:B,onSelect:J,forceMount:ue,keywords:T,...M}=e;return l.createElement(A.div,{ref:V(c,n),...M,id:u,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!S,"data-disabled":!!j,"data-selected":!!S,onPointerMove:j||m.getDisablePointerSelection()?void 0:H,onClick:j?void 0:I},e.children)}),Oe=l.forwardRef((e,n)=>{let{heading:r,children:f,forceMount:u,...c}=e,d=L(),m=l.useRef(null),b=l.useRef(null),o=L(),v=O(),h=R(w=>u||v.filter()===!1?!0:w.search?w.filtered.groups.has(d):!0);$(()=>v.group(d),[]),Ee(d,m,[e.value,e.heading,b]);let S=l.useMemo(()=>({id:d,forceMount:u}),[u]);return l.createElement(A.div,{ref:V(m,n),...c,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},r&&l.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":!0,id:o},r),U(e,w=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?o:void 0},l.createElement(ye.Provider,{value:S},w))))}),Be=l.forwardRef((e,n)=>{let{alwaysRender:r,...f}=e,u=l.useRef(null),c=R(d=>!d.search);return!r&&!c?null:l.createElement(A.div,{ref:V(u,n),...f,"cmdk-separator":"",role:"separator"})}),Ge=l.forwardRef((e,n)=>{let{onValueChange:r,...f}=e,u=e.value!=null,c=ae(),d=R(o=>o.search),m=R(o=>o.selectedItemId),b=O();return l.useEffect(()=>{e.value!=null&&c.setState("search",e.value)},[e.value]),l.createElement(A.input,{ref:n,...f,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":m,id:b.inputId,type:"text",value:u?e.value:d,onChange:o=>{u||c.setState("search",o.target.value),r?.(o.target.value)}})}),Ue=l.forwardRef((e,n)=>{let{children:r,label:f="Suggestions",...u}=e,c=l.useRef(null),d=l.useRef(null),m=R(o=>o.selectedItemId),b=O();return l.useEffect(()=>{if(d.current&&c.current){let o=d.current,v=c.current,h,S=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let w=o.offsetHeight;v.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return S.observe(o),()=>{cancelAnimationFrame(h),S.unobserve(o)}}},[]),l.createElement(A.div,{ref:V(c,n),...u,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":m,"aria-label":f,id:b.listId},U(e,o=>l.createElement("div",{ref:V(d,b.listInnerRef),"cmdk-list-sizer":""},o)))}),He=l.forwardRef((e,n)=>{let{open:r,onOpenChange:f,overlayClassName:u,contentClassName:c,container:d,...m}=e;return l.createElement(Se,{open:r,onOpenChange:f},l.createElement(Ce,{container:d},l.createElement(Ie,{"cmdk-overlay":"",className:u}),l.createElement(Re,{"aria-label":e.label,"cmdk-dialog":"",className:c},l.createElement(we,{ref:n,...m}))))}),Je=l.forwardRef((e,n)=>R(r=>r.filtered.count===0)?l.createElement(A.div,{ref:n,...e,"cmdk-empty":"",role:"presentation"}):null),Te=l.forwardRef((e,n)=>{let{progress:r,children:f,label:u="Loading...",...c}=e;return l.createElement(A.div,{ref:n,...c,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":u},U(e,d=>l.createElement("div",{"aria-hidden":!0},d)))}),D=Object.assign(we,{List:Ue,Item:Ve,Input:Ge,Group:Oe,Separator:Be,Dialog:He,Empty:Je,Loading:Te});function We(e,n){let r=e.nextElementSibling;for(;r;){if(r.matches(n))return r;r=r.nextElementSibling}}function _e(e,n){let r=e.previousElementSibling;for(;r;){if(r.matches(n))return r;r=r.previousElementSibling}}function ke(e){let n=l.useRef(e);return $(()=>{n.current=e}),n}var $=typeof window>"u"?l.useEffect:l.useLayoutEffect;function K(e){let n=l.useRef();return n.current===void 0&&(n.current=e()),n}function R(e){let n=ae(),r=()=>e(n.snapshot());return l.useSyncExternalStore(n.subscribe,r,r)}function Ee(e,n,r,f=[]){let u=l.useRef(),c=O();return $(()=>{var d;let m=(()=>{var o;for(let v of r){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(o=v.current.textContent)==null?void 0:o.trim():u.current}})(),b=f.map(o=>o.trim());c.value(e,m,b),(d=n.current)==null||d.setAttribute(F,m),u.current=m}),u}var Qe=()=>{let[e,n]=l.useState(),r=K(()=>new Map);return $(()=>{r.current.forEach(f=>f()),r.current=new Map},[e]),(f,u)=>{r.current.set(f,u),n({})}};function Xe(e){let n=e.type;return typeof n=="function"?n(e.props):"render"in n?n.render(e.props):e}function U({asChild:e,children:n},r){return e&&l.isValidElement(n)?l.cloneElement(Xe(n),{ref:n.ref},r(n.props.children)):r(n)}var Ye={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function tt({className:e,...n}){return C.jsx(D,{"data-slot":"command",className:P("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...n})}function rt({className:e,...n}){return C.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[C.jsx(Ae,{className:"size-4 shrink-0 opacity-50"}),C.jsx(D.Input,{"data-slot":"command-input",className:P("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...n})]})}function nt({className:e,...n}){return C.jsx(D.List,{"data-slot":"command-list",className:P("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...n})}function lt({...e}){return C.jsx(D.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function at({className:e,...n}){return C.jsx(D.Group,{"data-slot":"command-group",className:P("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...n})}function ut({className:e,...n}){return C.jsx(D.Separator,{"data-slot":"command-separator",className:P("bg-border -mx-1 h-px",e),...n})}function ot({className:e,...n}){return C.jsx(D.Item,{"data-slot":"command-item",className:P("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n})}export{tt as C,rt as a,nt as b,lt as c,at as d,ut as e,ot as f};
@@ -1 +1 @@
1
- import{j as e,n as Q,f as q,C as p,m as G,r as i,a as T,X as H,u as D,J,K,P as W,q as X,M as Y,N as Z,I as ee,S as _,b as I,c as U,d as B,e as j,F as se,g as L,h as te,k as ae}from"./main-BrFRroF1.js";import{u as ne}from"./usePermissions-BM1Vv1YJ.js";import{C as ie}from"./circle-check-big-B8AJAcBi.js";import{B as le}from"./badge-Cmc3T9vs.js";import{C as P}from"./CmsPageHeader-Cf0SafVG.js";import{C as re}from"./CmsToolbar-B1zdfMu0.js";import{C as ce}from"./CmsEmptyState-la_kLGHv.js";import{C as de}from"./CmsStatusBadge-BovugIHH.js";import{S as oe}from"./search-BsuImjd-.js";import{u as me}from"./tanstack-adapter-DHsy8Fjs.js";const ue={publish:{title:"Publish Items",description:"This will publish all selected items, making them publicly visible.",confirmLabel:"Publish All",confirmVariant:"success"},unpublish:{title:"Unpublish Items",description:"This will unpublish all selected items, changing them back to draft status.",confirmLabel:"Unpublish All",confirmVariant:"warning"},delete:{title:"Delete Items",description:"This will move all selected items to trash.",warning:"Items in trash can be restored within the retention period.",confirmLabel:"Delete All",confirmVariant:"danger"},archive:{title:"Archive Items",description:"This will archive all selected items.",confirmLabel:"Archive All",confirmVariant:"secondary"}};function he({action:a,count:l,isProcessing:u,result:t,onConfirm:r,onCancel:h}){const c=ue[a];return e.jsx(Q,{open:!0,onOpenChange:f=>!f&&!u&&h(),title:c.title,size:"sm",footer:t?e.jsx(p,{variant:"primary",onClick:h,children:t.failed===0?"Done":"Close"}):e.jsxs(e.Fragment,{children:[e.jsx(p,{variant:"outline",onClick:h,disabled:u,children:"Cancel"}),e.jsx(p,{variant:c.confirmVariant,onClick:r,loading:u,children:c.confirmLabel})]}),children:t?e.jsx("div",{className:"space-y-4",children:t.failed===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-4 text-center",children:[e.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-diff-added-bg text-diff-added",children:e.jsx(ie,{className:"size-6"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Successfully processed"," ",e.jsx("span",{className:"font-semibold text-foreground",children:t.succeeded})," ",t.succeeded===1?"item":"items"]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"diff-added rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-semibold text-diff-added",children:t.succeeded}),e.jsx("p",{className:"text-xs text-diff-added-foreground",children:"Succeeded"})]}),e.jsxs("div",{className:"diff-removed rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-semibold text-diff-removed",children:t.failed}),e.jsx("p",{className:"text-xs text-diff-removed-foreground",children:"Failed"})]})]}),t.errors&&t.errors.length>0&&e.jsxs("div",{className:"diff-modified rounded-lg border p-3",children:[e.jsx("p",{className:"mb-2 text-sm font-medium text-diff-modified",children:"Errors:"}),e.jsxs("ul",{className:"space-y-1 text-xs text-diff-modified-foreground",children:[t.errors.slice(0,5).map((f,d)=>e.jsxs("li",{className:"truncate",children:["• ",f]},d)),t.errors.length>5&&e.jsxs("li",{className:"text-diff-modified-foreground/80",children:["...and ",t.errors.length-5," more errors"]})]})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You are about to ",a," ",e.jsxs("span",{className:"font-semibold text-foreground",children:[l," ",l===1?"item":"items"]}),"."]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description}),c.warning&&e.jsxs("div",{className:"diff-modified flex items-start gap-2 rounded-lg border p-3",children:[e.jsx(q,{className:"mt-0.5 size-4 shrink-0 text-diff-modified"}),e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Note:"})," ",c.warning]})]})]})})}function xe({selectedIds:a,onClearSelection:l,onOperationComplete:u}){const t=G(),[r,h]=i.useState(null),[c,f]=i.useState(!1),[d,o]=i.useState(null),y=T(t.bulkPublish),k=T(t.bulkUnpublish),v=T(t.bulkDelete),x=T(t.bulkUpdate),b=i.useCallback(n=>{h(n),o(null)},[]),S=i.useCallback(async()=>{if(!(!r||a.length===0)){f(!0),o(null);try{let n;switch(r){case"publish":n=await y({ids:a,changeDescription:"Bulk published from admin"});break;case"unpublish":n=await k({ids:a});break;case"delete":n=await v({ids:a,hardDelete:!1});break;case"archive":n=await x({ids:a,status:"archived"});break;default:throw new Error(`Unknown action: ${r}`)}o({succeeded:n.succeeded,failed:n.failed,errors:n.errors?.map(N=>`${N.id}: ${N.error}`)}),n.failed===0&&setTimeout(()=>{h(null),l(),u?.()},1500)}catch(n){const N=n instanceof Error?n.message:"Operation failed";o({succeeded:0,failed:a.length,errors:[N]})}finally{f(!1)}}},[r,a,y,k,v,x,l,u]),m=i.useCallback(()=>{h(null),o(null)},[]);return a.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 px-6 py-3 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(le,{variant:"secondary",className:"text-sm font-semibold",children:a.length}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.length===1?"item":"items"," selected"]}),e.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(H,{className:"size-3"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"success",size:"sm",onClick:()=>b("publish"),children:"Publish"}),e.jsx(p,{variant:"warning",size:"sm",onClick:()=>b("unpublish"),children:"Unpublish"}),e.jsx(p,{variant:"secondary",size:"sm",onClick:()=>b("archive"),children:"Archive"}),e.jsx(p,{variant:"danger",size:"sm",onClick:()=>b("delete"),children:"Delete"})]})]})}),r&&e.jsx(he,{action:r,count:a.length,isProcessing:c,result:d,onConfirm:S,onCancel:m})]})}function pe({api:a,navigation:l}){const[u,t]=i.useState(""),[r,h]=i.useState(""),[c,f]=i.useState(""),[d,o]=i.useState(new Set),{canCreate:y,canUpdate:k}=ne();i.useEffect(()=>{const s=l.params?.contentTypeId;if(s){const g=s.startsWith("code:")?s.slice(5):s;t(g)}else t("")},[l.params?.contentTypeId]);const v=D(a.listContentTypes,{isActive:!0}),x=v?.page??[],b=v===void 0,S=D(a.listEntries,{contentTypeName:u||void 0,status:r||void 0,search:c.trim()||void 0,paginationOpts:{numItems:50,cursor:null}}),m=S?.page??[],N=b||S===void 0,V=s=>{l.navigateToNewEntry(s)},F=s=>x.find(w=>w.name===s)?.displayName??s,E=(s,g)=>{const C=x.find($=>$.name===g)?.titleField??"title",A=s.data[C];return typeof A=="string"&&A?A:"Untitled"},M=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=i.useCallback((s,g)=>{o(w=>{const C=new Set(w);return g?C.add(s):C.delete(s),C})},[]),R=i.useCallback(()=>{d.size===m.length&&m.length>0?o(new Set):o(new Set(m.map(s=>s._id)))},[d.size,m]),z=i.useCallback(()=>{o(new Set)},[]);return N?e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(P,{title:"Content",description:"Browse and manage content entries across all content types."}),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..."})]})]}):e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(P,{title:"Content",description:"Browse and manage content entries across all content types."}),e.jsx(re,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(oe,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ee,{type:"text",placeholder:"Search content...",value:c,onChange:s=>f(s.target.value),className:"w-64 pl-9","data-testid":"content-search-input"})]}),e.jsxs(_,{value:u||"all",onValueChange:s=>t(s==="all"?"":s),children:[e.jsx(I,{className:"w-48",children:e.jsx(U,{placeholder:"All Content Types"})}),e.jsxs(B,{children:[e.jsx(j,{value:"all",children:"All Content Types"}),x.map(s=>e.jsx(j,{value:s._id,children:s.displayName},s._id))]})]}),e.jsxs(_,{value:r||"all",onValueChange:s=>h(s==="all"?"":s),children:[e.jsx(I,{className:"w-36",children:e.jsx(U,{placeholder:"All Statuses"})}),e.jsxs(B,{children:[e.jsx(j,{value:"all",children:"All Statuses"}),e.jsx(j,{value:"draft",children:"Draft"}),e.jsx(j,{value:"published",children:"Published"}),e.jsx(j,{value:"scheduled",children:"Scheduled"}),e.jsx(j,{value:"archived",children:"Archived"})]})]})]}),right:y("contentEntries")&&e.jsxs(J,{children:[e.jsx(K,{asChild:!0,children:e.jsxs(p,{disabled:x.length===0,children:[e.jsx(W,{className:"size-4"}),"Create Entry",e.jsx(X,{className:"size-4"})]})}),e.jsx(Y,{align:"end",children:x.map(s=>e.jsx(Z,{onClick:()=>V(s._id),children:s.displayName},s._id))})]})}),e.jsx(xe,{selectedIds:Array.from(d),onClearSelection:z,onOperationComplete:z}),m.length===0?e.jsx(ce,{icon:e.jsx(se,{className:"size-6"}),title:"No content entries yet",description:x.length===0?"Create a content type first, then start adding content entries.":'Click "Create Entry" to add your first content entry.'}):e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"w-10 p-3 text-left",children:e.jsx(L,{checked:d.size===m.length&&m.length>0,onCheckedChange:R,"aria-label":"Select all entries"})}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Title"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Type"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Updated"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:m.map(s=>e.jsxs("tr",{className:te("border-b last:border-0 transition-colors hover:bg-muted/50",d.has(s._id)&&"bg-primary/5"),children:[e.jsx("td",{className:"p-3",children:e.jsx(L,{checked:d.has(s._id),onCheckedChange:g=>O(s._id,g),"aria-label":`Select ${E(s,s.contentTypeName)}`})}),e.jsx("td",{className:"p-3",children:e.jsxs("button",{type:"button",onClick:()=>l.navigateToEntry(s._id),className:"block text-left",children:[e.jsx("span",{className:"font-medium text-foreground hover:text-primary",children:E(s,s.contentTypeName)}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:s.slug})]})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:F(s.contentTypeName)}),e.jsx("td",{className:"p-3",children:e.jsx(de,{status:s.status})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:M(s._creationTime)}),e.jsx("td",{className:"p-3",children:e.jsx(p,{variant:"outline",size:"sm",onClick:()=>l.navigateToEntry(s._id),children:k("contentEntries")?"Edit":"View"})})]},s._id))})]})})]})}function we(){const a=me();return e.jsx(pe,{api:ae.admin,navigation:a})}export{we as component};
1
+ import{j as e,n as Q,f as q,C as p,m as G,r as i,a as T,X as H,u as D,J,K,P as W,q as X,M as Y,N as Z,I as ee,S as _,b as I,c as U,d as B,e as j,F as se,g as L,h as te,k as ae}from"./main-CA-4LyFT.js";import{u as ne}from"./usePermissions-BTGdTOJS.js";import{C as ie}from"./circle-check-big-PltpxuB1.js";import{B as le}from"./badge-C6qt24oj.js";import{C as P}from"./CmsPageHeader-0REGRH4X.js";import{C as re}from"./CmsToolbar-CY6GV2L8.js";import{C as ce}from"./CmsEmptyState-DTlpzjOI.js";import{C as de}from"./CmsStatusBadge-D_n8u8xa.js";import{S as oe}from"./search-WXp6KxDJ.js";import{u as me}from"./tanstack-adapter-BRt2CUCw.js";const ue={publish:{title:"Publish Items",description:"This will publish all selected items, making them publicly visible.",confirmLabel:"Publish All",confirmVariant:"success"},unpublish:{title:"Unpublish Items",description:"This will unpublish all selected items, changing them back to draft status.",confirmLabel:"Unpublish All",confirmVariant:"warning"},delete:{title:"Delete Items",description:"This will move all selected items to trash.",warning:"Items in trash can be restored within the retention period.",confirmLabel:"Delete All",confirmVariant:"danger"},archive:{title:"Archive Items",description:"This will archive all selected items.",confirmLabel:"Archive All",confirmVariant:"secondary"}};function he({action:a,count:l,isProcessing:u,result:t,onConfirm:r,onCancel:h}){const c=ue[a];return e.jsx(Q,{open:!0,onOpenChange:f=>!f&&!u&&h(),title:c.title,size:"sm",footer:t?e.jsx(p,{variant:"primary",onClick:h,children:t.failed===0?"Done":"Close"}):e.jsxs(e.Fragment,{children:[e.jsx(p,{variant:"outline",onClick:h,disabled:u,children:"Cancel"}),e.jsx(p,{variant:c.confirmVariant,onClick:r,loading:u,children:c.confirmLabel})]}),children:t?e.jsx("div",{className:"space-y-4",children:t.failed===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-4 text-center",children:[e.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-diff-added-bg text-diff-added",children:e.jsx(ie,{className:"size-6"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Successfully processed"," ",e.jsx("span",{className:"font-semibold text-foreground",children:t.succeeded})," ",t.succeeded===1?"item":"items"]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"diff-added rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-semibold text-diff-added",children:t.succeeded}),e.jsx("p",{className:"text-xs text-diff-added-foreground",children:"Succeeded"})]}),e.jsxs("div",{className:"diff-removed rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-semibold text-diff-removed",children:t.failed}),e.jsx("p",{className:"text-xs text-diff-removed-foreground",children:"Failed"})]})]}),t.errors&&t.errors.length>0&&e.jsxs("div",{className:"diff-modified rounded-lg border p-3",children:[e.jsx("p",{className:"mb-2 text-sm font-medium text-diff-modified",children:"Errors:"}),e.jsxs("ul",{className:"space-y-1 text-xs text-diff-modified-foreground",children:[t.errors.slice(0,5).map((f,d)=>e.jsxs("li",{className:"truncate",children:["• ",f]},d)),t.errors.length>5&&e.jsxs("li",{className:"text-diff-modified-foreground/80",children:["...and ",t.errors.length-5," more errors"]})]})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You are about to ",a," ",e.jsxs("span",{className:"font-semibold text-foreground",children:[l," ",l===1?"item":"items"]}),"."]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description}),c.warning&&e.jsxs("div",{className:"diff-modified flex items-start gap-2 rounded-lg border p-3",children:[e.jsx(q,{className:"mt-0.5 size-4 shrink-0 text-diff-modified"}),e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Note:"})," ",c.warning]})]})]})})}function xe({selectedIds:a,onClearSelection:l,onOperationComplete:u}){const t=G(),[r,h]=i.useState(null),[c,f]=i.useState(!1),[d,o]=i.useState(null),y=T(t.bulkPublish),k=T(t.bulkUnpublish),v=T(t.bulkDelete),x=T(t.bulkUpdate),b=i.useCallback(n=>{h(n),o(null)},[]),S=i.useCallback(async()=>{if(!(!r||a.length===0)){f(!0),o(null);try{let n;switch(r){case"publish":n=await y({ids:a,changeDescription:"Bulk published from admin"});break;case"unpublish":n=await k({ids:a});break;case"delete":n=await v({ids:a,hardDelete:!1});break;case"archive":n=await x({ids:a,status:"archived"});break;default:throw new Error(`Unknown action: ${r}`)}o({succeeded:n.succeeded,failed:n.failed,errors:n.errors?.map(N=>`${N.id}: ${N.error}`)}),n.failed===0&&setTimeout(()=>{h(null),l(),u?.()},1500)}catch(n){const N=n instanceof Error?n.message:"Operation failed";o({succeeded:0,failed:a.length,errors:[N]})}finally{f(!1)}}},[r,a,y,k,v,x,l,u]),m=i.useCallback(()=>{h(null),o(null)},[]);return a.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 px-6 py-3 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(le,{variant:"secondary",className:"text-sm font-semibold",children:a.length}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.length===1?"item":"items"," selected"]}),e.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(H,{className:"size-3"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"success",size:"sm",onClick:()=>b("publish"),children:"Publish"}),e.jsx(p,{variant:"warning",size:"sm",onClick:()=>b("unpublish"),children:"Unpublish"}),e.jsx(p,{variant:"secondary",size:"sm",onClick:()=>b("archive"),children:"Archive"}),e.jsx(p,{variant:"danger",size:"sm",onClick:()=>b("delete"),children:"Delete"})]})]})}),r&&e.jsx(he,{action:r,count:a.length,isProcessing:c,result:d,onConfirm:S,onCancel:m})]})}function pe({api:a,navigation:l}){const[u,t]=i.useState(""),[r,h]=i.useState(""),[c,f]=i.useState(""),[d,o]=i.useState(new Set),{canCreate:y,canUpdate:k}=ne();i.useEffect(()=>{const s=l.params?.contentTypeId;if(s){const g=s.startsWith("code:")?s.slice(5):s;t(g)}else t("")},[l.params?.contentTypeId]);const v=D(a.listContentTypes,{isActive:!0}),x=v?.page??[],b=v===void 0,S=D(a.listEntries,{contentTypeName:u||void 0,status:r||void 0,search:c.trim()||void 0,paginationOpts:{numItems:50,cursor:null}}),m=S?.page??[],N=b||S===void 0,V=s=>{l.navigateToNewEntry(s)},F=s=>x.find(w=>w.name===s)?.displayName??s,E=(s,g)=>{const C=x.find($=>$.name===g)?.titleField??"title",A=s.data[C];return typeof A=="string"&&A?A:"Untitled"},M=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=i.useCallback((s,g)=>{o(w=>{const C=new Set(w);return g?C.add(s):C.delete(s),C})},[]),R=i.useCallback(()=>{d.size===m.length&&m.length>0?o(new Set):o(new Set(m.map(s=>s._id)))},[d.size,m]),z=i.useCallback(()=>{o(new Set)},[]);return N?e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(P,{title:"Content",description:"Browse and manage content entries across all content types."}),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..."})]})]}):e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(P,{title:"Content",description:"Browse and manage content entries across all content types."}),e.jsx(re,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(oe,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ee,{type:"text",placeholder:"Search content...",value:c,onChange:s=>f(s.target.value),className:"w-64 pl-9","data-testid":"content-search-input"})]}),e.jsxs(_,{value:u||"all",onValueChange:s=>t(s==="all"?"":s),children:[e.jsx(I,{className:"w-48",children:e.jsx(U,{placeholder:"All Content Types"})}),e.jsxs(B,{children:[e.jsx(j,{value:"all",children:"All Content Types"}),x.map(s=>e.jsx(j,{value:s._id,children:s.displayName},s._id))]})]}),e.jsxs(_,{value:r||"all",onValueChange:s=>h(s==="all"?"":s),children:[e.jsx(I,{className:"w-36",children:e.jsx(U,{placeholder:"All Statuses"})}),e.jsxs(B,{children:[e.jsx(j,{value:"all",children:"All Statuses"}),e.jsx(j,{value:"draft",children:"Draft"}),e.jsx(j,{value:"published",children:"Published"}),e.jsx(j,{value:"scheduled",children:"Scheduled"}),e.jsx(j,{value:"archived",children:"Archived"})]})]})]}),right:y("contentEntries")&&e.jsxs(J,{children:[e.jsx(K,{asChild:!0,children:e.jsxs(p,{disabled:x.length===0,children:[e.jsx(W,{className:"size-4"}),"Create Entry",e.jsx(X,{className:"size-4"})]})}),e.jsx(Y,{align:"end",children:x.map(s=>e.jsx(Z,{onClick:()=>V(s._id),children:s.displayName},s._id))})]})}),e.jsx(xe,{selectedIds:Array.from(d),onClearSelection:z,onOperationComplete:z}),m.length===0?e.jsx(ce,{icon:e.jsx(se,{className:"size-6"}),title:"No content entries yet",description:x.length===0?"Create a content type first, then start adding content entries.":'Click "Create Entry" to add your first content entry.'}):e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"w-10 p-3 text-left",children:e.jsx(L,{checked:d.size===m.length&&m.length>0,onCheckedChange:R,"aria-label":"Select all entries"})}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Title"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Type"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Updated"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:m.map(s=>e.jsxs("tr",{className:te("border-b last:border-0 transition-colors hover:bg-muted/50",d.has(s._id)&&"bg-primary/5"),children:[e.jsx("td",{className:"p-3",children:e.jsx(L,{checked:d.has(s._id),onCheckedChange:g=>O(s._id,g),"aria-label":`Select ${E(s,s.contentTypeName)}`})}),e.jsx("td",{className:"p-3",children:e.jsxs("button",{type:"button",onClick:()=>l.navigateToEntry(s._id),className:"block text-left",children:[e.jsx("span",{className:"font-medium text-foreground hover:text-primary",children:E(s,s.contentTypeName)}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:s.slug})]})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:F(s.contentTypeName)}),e.jsx("td",{className:"p-3",children:e.jsx(de,{status:s.status})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:M(s._creationTime)}),e.jsx("td",{className:"p-3",children:e.jsx(p,{variant:"outline",size:"sm",onClick:()=>l.navigateToEntry(s._id),children:k("contentEntries")?"Edit":"View"})})]},s._id))})]})})]})}function we(){const a=me();return e.jsx(pe,{api:ae.admin,navigation:a})}export{we as component};
@@ -1 +1 @@
1
- import{l as V,r as a,u as q,j as e,h as g,$ as E,C as l,P as B,I as R,g as $,a0 as j,a1 as z,O as k,a2 as L,a3 as G,a4 as Q,t as H,q as J,a5 as X,E as K,U as W,a6 as S,a7 as Y,a8 as Z,k as T}from"./main-BrFRroF1.js";import{C as ee}from"./CmsPageHeader-Cf0SafVG.js";import{C as se}from"./CmsToolbar-B1zdfMu0.js";import{C as te}from"./CmsEmptyState-la_kLGHv.js";import{B as d}from"./badge-Cmc3T9vs.js";import{S as ae}from"./search-BsuImjd-.js";import{P as M}from"./pencil-PaJhpDeC.js";import{u as re}from"./tanstack-adapter-DHsy8Fjs.js";const ie=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],de=V("grid-3x3",ie),oe={text:e.jsx(L,{className:"size-3"}),richText:e.jsx(j,{className:"size-3"}),number:e.jsx(Z,{className:"size-3"}),boolean:e.jsx(Y,{className:"size-3"}),date:e.jsx(S,{className:"size-3"}),datetime:e.jsx(S,{className:"size-3"}),reference:e.jsx(W,{className:"size-3"}),media:e.jsx(K,{className:"size-3"}),json:e.jsx(X,{className:"size-3"}),select:e.jsx(J,{className:"size-3"}),multiSelect:e.jsx(E,{className:"size-3"}),tags:e.jsx(H,{className:"size-3"}),category:e.jsx(Q,{className:"size-3"})};function ne({api:c,navigation:p}){const[r,A]=a.useState(""),[m,N]=a.useState("grid"),[b,_]=a.useState(!0),[I,x]=a.useState(!1),[v,i]=a.useState(null),D=a.useCallback(()=>{x(!1)},[]),F=a.useCallback(()=>{i(null)},[]),y=q(c.listContentTypes,{isActive:b?!0:void 0,includeEntryCounts:!0}),o=y?.page??[],C=y===void 0,n=a.useMemo(()=>{if(!r.trim())return o;const s=r.toLowerCase();return o.filter(t=>t.name.toLowerCase().includes(s)||t.displayName.toLowerCase().includes(s))},[o,r]),w=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=s=>{const P=Date.now()-s,U=Math.floor(P/1e3),u=Math.floor(U/60),f=Math.floor(u/60),h=Math.floor(f/24);return h>30?w(s):h>0?`${h}d ago`:f>0?`${f}h ago`:u>0?`${u}m ago`:"Just now"};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(ee,{title:"Content Types",description:"Define the structure of your content with custom fields and validation rules."}),e.jsx(se,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ae,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(R,{type:"search",placeholder:"Search content types...",value:r,onChange:s=>A(s.target.value),className:"w-64 pl-9"})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx($,{checked:b,onCheckedChange:s=>_(s)}),"Active only"]})]}),right:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex rounded-md border bg-muted/30",children:[e.jsx("button",{className:g("rounded-l-md p-2 transition-colors",m==="grid"?"bg-background shadow-sm":"hover:bg-muted/50"),onClick:()=>N("grid"),title:"Grid view","aria-label":"Grid view",children:e.jsx(de,{className:"size-4"})}),e.jsx("button",{className:g("rounded-r-md p-2 transition-colors",m==="list"?"bg-background shadow-sm":"hover:bg-muted/50"),onClick:()=>N("list"),title:"List view","aria-label":"List view",children:e.jsx(E,{className:"size-4"})})]}),e.jsxs(l,{onClick:()=>x(!0),"data-testid":"create-content-type-button",children:[e.jsx(B,{className:"size-4"}),"Create Content Type"]})]})}),C?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 types..."})]}):n.length===0?e.jsx(te,{icon:e.jsx(j,{className:"size-6"}),title:r?"No content types match your search":"No content types defined",description:r?"Try adjusting your search query or filters.":"Content types define the schema for your content. Create one to get started."}):m==="grid"?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(s=>e.jsxs("div",{className:"group flex flex-col rounded-lg border bg-card p-4 transition-all hover:border-primary/50 hover:shadow-md",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground",children:e.jsx(j,{className:"size-5"})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[s.source==="code"&&e.jsxs(d,{variant:"secondary",className:"border-violet-200 bg-violet-50 text-xs font-normal text-violet-700",title:"Managed by code - edit in your codebase",children:[e.jsx(z,{className:"mr-1 size-3"}),"Code"]}),!s.isActive&&e.jsx(d,{variant:"secondary",className:"text-xs font-normal",children:"Inactive"}),s.singleton&&e.jsx(d,{variant:"secondary",className:"border-diff-modified-border bg-diff-modified-bg text-xs font-normal text-diff-modified-foreground",children:"Singleton"}),s.source==="code"?e.jsx("button",{className:"rounded p-1.5 text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground group-hover:opacity-100",title:"View content type (managed by code)","aria-label":"View content type",onClick:()=>i(s),children:e.jsx(k,{className:"size-4"})}):e.jsx("button",{onClick:()=>i(s),className:"rounded p-1.5 text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground group-hover:opacity-100",title:"Edit content type","aria-label":"Edit content type",children:e.jsx(M,{className:"size-4"})})]})]}),e.jsxs("button",{type:"button",onClick:()=>p.navigateToContentType(s._id),className:"flex flex-1 flex-col text-left",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:s.displayName}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:s.name}),e.jsxs("div",{className:"mt-3 flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:s.fields.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.fields.length===1?"Field":"Fields"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:s.entryCount??0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.entryCount===1?"Entry":"Entries"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[s.fields.slice(0,4).map(t=>e.jsxs("span",{className:"flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",title:t.label,children:[oe[t.type]||e.jsx(L,{className:"size-3"}),e.jsx("span",{className:"truncate",children:t.label})]},t.name)),s.fields.length>4&&e.jsxs("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:["+",s.fields.length-4," more"]})]}),e.jsxs("p",{className:"mt-auto pt-3 text-xs text-muted-foreground",children:["Updated ",O(s._creationTime)]})]})]},s._id))}):e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Fields"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Entries"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Last Updated"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:n.map(s=>e.jsxs("tr",{className:"border-b last:border-0 transition-colors hover:bg-muted/50",children:[e.jsxs("td",{className:"p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:s.displayName}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.name})]}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:s.fields.length}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:s.entryCount??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[s.source==="code"&&e.jsxs(d,{variant:"secondary",className:"border-violet-200 bg-violet-50 text-xs font-normal text-violet-700",title:"Managed by code",children:[e.jsx(z,{className:"mr-1 size-3"}),"Code"]}),e.jsx(d,{variant:s.isActive?"default":"secondary",className:g("text-xs font-normal",s.isActive&&"border-diff-added-border bg-diff-added-bg text-diff-added-foreground"),children:s.isActive?"Active":"Inactive"}),s.singleton&&e.jsx(d,{variant:"secondary",className:"border-diff-modified-border bg-diff-modified-bg text-xs font-normal text-diff-modified-foreground",children:"Singleton"})]})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:w(s._creationTime)}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.source==="code"?e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>i(s),title:"View content type (managed by code)",children:[e.jsx(k,{className:"size-3.5"}),"View"]}):e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>i(s),children:[e.jsx(M,{className:"size-3.5"}),"Edit"]}),e.jsx(l,{variant:"outline",size:"sm",onClick:()=>p.navigateToContentType(s._id),children:"View Entries"})]})})]},s._id))})]})}),!C&&n.length>0&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Showing ",n.length," of ",o.length," content type",o.length!==1?"s":""]}),e.jsx(G,{isOpen:I||!!v,onClose:()=>{x(!1),i(null)},contentType:v,onCreated:D,onUpdated:F})]})}function je(){const c=re();return e.jsx(ne,{api:T.admin,navigation:c})}export{je as component};
1
+ import{l as V,r as a,u as q,j as e,h as g,$ as E,C as l,P as B,I as R,g as $,a0 as j,a1 as z,O as k,a2 as L,a3 as G,a4 as Q,t as H,q as J,a5 as X,E as K,U as W,a6 as S,a7 as Y,a8 as Z,k as T}from"./main-CA-4LyFT.js";import{C as ee}from"./CmsPageHeader-0REGRH4X.js";import{C as se}from"./CmsToolbar-CY6GV2L8.js";import{C as te}from"./CmsEmptyState-DTlpzjOI.js";import{B as d}from"./badge-C6qt24oj.js";import{S as ae}from"./search-WXp6KxDJ.js";import{P as M}from"./pencil-gAL0R34f.js";import{u as re}from"./tanstack-adapter-BRt2CUCw.js";const ie=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],de=V("grid-3x3",ie),oe={text:e.jsx(L,{className:"size-3"}),richText:e.jsx(j,{className:"size-3"}),number:e.jsx(Z,{className:"size-3"}),boolean:e.jsx(Y,{className:"size-3"}),date:e.jsx(S,{className:"size-3"}),datetime:e.jsx(S,{className:"size-3"}),reference:e.jsx(W,{className:"size-3"}),media:e.jsx(K,{className:"size-3"}),json:e.jsx(X,{className:"size-3"}),select:e.jsx(J,{className:"size-3"}),multiSelect:e.jsx(E,{className:"size-3"}),tags:e.jsx(H,{className:"size-3"}),category:e.jsx(Q,{className:"size-3"})};function ne({api:c,navigation:p}){const[r,A]=a.useState(""),[m,N]=a.useState("grid"),[b,_]=a.useState(!0),[I,x]=a.useState(!1),[v,i]=a.useState(null),D=a.useCallback(()=>{x(!1)},[]),F=a.useCallback(()=>{i(null)},[]),y=q(c.listContentTypes,{isActive:b?!0:void 0,includeEntryCounts:!0}),o=y?.page??[],C=y===void 0,n=a.useMemo(()=>{if(!r.trim())return o;const s=r.toLowerCase();return o.filter(t=>t.name.toLowerCase().includes(s)||t.displayName.toLowerCase().includes(s))},[o,r]),w=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=s=>{const P=Date.now()-s,U=Math.floor(P/1e3),u=Math.floor(U/60),f=Math.floor(u/60),h=Math.floor(f/24);return h>30?w(s):h>0?`${h}d ago`:f>0?`${f}h ago`:u>0?`${u}m ago`:"Just now"};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(ee,{title:"Content Types",description:"Define the structure of your content with custom fields and validation rules."}),e.jsx(se,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ae,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(R,{type:"search",placeholder:"Search content types...",value:r,onChange:s=>A(s.target.value),className:"w-64 pl-9"})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx($,{checked:b,onCheckedChange:s=>_(s)}),"Active only"]})]}),right:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex rounded-md border bg-muted/30",children:[e.jsx("button",{className:g("rounded-l-md p-2 transition-colors",m==="grid"?"bg-background shadow-sm":"hover:bg-muted/50"),onClick:()=>N("grid"),title:"Grid view","aria-label":"Grid view",children:e.jsx(de,{className:"size-4"})}),e.jsx("button",{className:g("rounded-r-md p-2 transition-colors",m==="list"?"bg-background shadow-sm":"hover:bg-muted/50"),onClick:()=>N("list"),title:"List view","aria-label":"List view",children:e.jsx(E,{className:"size-4"})})]}),e.jsxs(l,{onClick:()=>x(!0),"data-testid":"create-content-type-button",children:[e.jsx(B,{className:"size-4"}),"Create Content Type"]})]})}),C?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 types..."})]}):n.length===0?e.jsx(te,{icon:e.jsx(j,{className:"size-6"}),title:r?"No content types match your search":"No content types defined",description:r?"Try adjusting your search query or filters.":"Content types define the schema for your content. Create one to get started."}):m==="grid"?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(s=>e.jsxs("div",{className:"group flex flex-col rounded-lg border bg-card p-4 transition-all hover:border-primary/50 hover:shadow-md",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground",children:e.jsx(j,{className:"size-5"})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[s.source==="code"&&e.jsxs(d,{variant:"secondary",className:"border-violet-200 bg-violet-50 text-xs font-normal text-violet-700",title:"Managed by code - edit in your codebase",children:[e.jsx(z,{className:"mr-1 size-3"}),"Code"]}),!s.isActive&&e.jsx(d,{variant:"secondary",className:"text-xs font-normal",children:"Inactive"}),s.singleton&&e.jsx(d,{variant:"secondary",className:"border-diff-modified-border bg-diff-modified-bg text-xs font-normal text-diff-modified-foreground",children:"Singleton"}),s.source==="code"?e.jsx("button",{className:"rounded p-1.5 text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground group-hover:opacity-100",title:"View content type (managed by code)","aria-label":"View content type",onClick:()=>i(s),children:e.jsx(k,{className:"size-4"})}):e.jsx("button",{onClick:()=>i(s),className:"rounded p-1.5 text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground group-hover:opacity-100",title:"Edit content type","aria-label":"Edit content type",children:e.jsx(M,{className:"size-4"})})]})]}),e.jsxs("button",{type:"button",onClick:()=>p.navigateToContentType(s._id),className:"flex flex-1 flex-col text-left",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:s.displayName}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:s.name}),e.jsxs("div",{className:"mt-3 flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:s.fields.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.fields.length===1?"Field":"Fields"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:s.entryCount??0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.entryCount===1?"Entry":"Entries"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[s.fields.slice(0,4).map(t=>e.jsxs("span",{className:"flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",title:t.label,children:[oe[t.type]||e.jsx(L,{className:"size-3"}),e.jsx("span",{className:"truncate",children:t.label})]},t.name)),s.fields.length>4&&e.jsxs("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:["+",s.fields.length-4," more"]})]}),e.jsxs("p",{className:"mt-auto pt-3 text-xs text-muted-foreground",children:["Updated ",O(s._creationTime)]})]})]},s._id))}):e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Fields"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Entries"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Last Updated"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:n.map(s=>e.jsxs("tr",{className:"border-b last:border-0 transition-colors hover:bg-muted/50",children:[e.jsxs("td",{className:"p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:s.displayName}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.name})]}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:s.fields.length}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:s.entryCount??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[s.source==="code"&&e.jsxs(d,{variant:"secondary",className:"border-violet-200 bg-violet-50 text-xs font-normal text-violet-700",title:"Managed by code",children:[e.jsx(z,{className:"mr-1 size-3"}),"Code"]}),e.jsx(d,{variant:s.isActive?"default":"secondary",className:g("text-xs font-normal",s.isActive&&"border-diff-added-border bg-diff-added-bg text-diff-added-foreground"),children:s.isActive?"Active":"Inactive"}),s.singleton&&e.jsx(d,{variant:"secondary",className:"border-diff-modified-border bg-diff-modified-bg text-xs font-normal text-diff-modified-foreground",children:"Singleton"})]})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:w(s._creationTime)}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.source==="code"?e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>i(s),title:"View content type (managed by code)",children:[e.jsx(k,{className:"size-3.5"}),"View"]}):e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>i(s),children:[e.jsx(M,{className:"size-3.5"}),"Edit"]}),e.jsx(l,{variant:"outline",size:"sm",onClick:()=>p.navigateToContentType(s._id),children:"View Entries"})]})})]},s._id))})]})}),!C&&n.length>0&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Showing ",n.length," of ",o.length," content type",o.length!==1?"s":""]}),e.jsx(G,{isOpen:I||!!v,onClose:()=>{x(!1),i(null)},contentType:v,onCreated:D,onUpdated:F})]})}function je(){const c=re();return e.jsx(ne,{api:T.admin,navigation:c})}export{je as component};
@@ -1 +1 @@
1
- import{l as j,j as e,h as o,u as y,a as w,r as g,a9 as z,f as D,G as T,F as A,E as M,aa as E,ab as R,k as _}from"./main-BrFRroF1.js";import{C as L}from"./CmsPageHeader-Cf0SafVG.js";import{A as h,b as f,a as p}from"./alert-DfdkD-ZZ.js";import{R as I}from"./refresh-cw-D_KNzBUN.js";import{u as $}from"./tanstack-adapter-DHsy8Fjs.js";const P=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],F=j("circle-x",P);const H=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Q=j("trending-up",H);function N({className:t,...s}){return e.jsx("div",{"data-slot":"card",className:o("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...s})}function U({className:t,...s}){return e.jsx("div",{"data-slot":"card-header",className:o("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...s})}function W({className:t,...s}){return e.jsx("div",{"data-slot":"card-title",className:o("leading-none font-semibold",t),...s})}function q({className:t,...s}){return e.jsx("div",{"data-slot":"card-description",className:o("text-muted-foreground text-sm",t),...s})}function b({className:t,...s}){return e.jsx("div",{"data-slot":"card-content",className:o("px-6",t),...s})}function B({className:t,...s}){return e.jsx("div",{"data-slot":"skeleton",className:o("bg-accent animate-pulse rounded-md",t),...s})}function G({api:t}){const s=y(t.checkSchemaDrift,{}),r=w(t.syncCodeDefinedTypes),[n,c]=g.useState(!1),[d,u]=g.useState(null);if(s===void 0)return null;if(!s||s.length===0)return d&&(d.created>0||d.updated>0)?e.jsxs(h,{className:"border-success/50 bg-success/10",children:[e.jsx(z,{className:"size-4 text-success"}),e.jsx(f,{className:"text-diff-added-foreground",children:"Sync Complete"}),e.jsxs(p,{className:"text-diff-added-foreground/80",children:[d.created>0&&e.jsxs("span",{children:[d.created," content type(s) created. "]}),d.updated>0&&e.jsxs("span",{children:[d.updated," content type(s) updated."]})]})]}):null;const a=s.filter(i=>i.severity==="error"),x=s.filter(i=>i.severity==="warning"),v=async()=>{c(!0),u(null);try{const i=await r({});u(i)}catch(i){console.error("Sync failed:",i)}finally{c(!1)}},C=a.length>0?"destructive":"default",S=a.length>0?F:D,k=a.length>0?"text-destructive":"text-warning";return e.jsxs(h,{variant:C,className:a.length===0?"border-warning/50 bg-warning/10":"",children:[e.jsx(S,{className:`size-4 ${k}`}),e.jsx(f,{className:a.length===0?"text-diff-modified-foreground":"",children:"Schema Drift Detected"}),e.jsx(p,{className:a.length===0?"text-diff-modified-foreground/80":"",children:e.jsxs("div",{className:"space-y-2",children:[a.length>0&&e.jsxs("p",{children:[e.jsxs("strong",{children:[a.length," error(s)"]}),":"," ",a.slice(0,3).map(i=>i.message).join(" "),a.length>3&&` ...and ${a.length-3} more`]}),x.length>0&&e.jsxs("p",{children:[e.jsxs("strong",{children:[x.length," warning(s)"]}),": Code-defined types may need syncing."]}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsxs(T,{size:"sm",variant:a.length>0?"destructive":"outline",onClick:v,disabled:n,className:a.length===0?"border-warning/50 text-diff-modified-foreground hover:bg-warning/20":"",children:[e.jsx(I,{className:`mr-1.5 size-3.5 ${n?"animate-spin":""}`}),n?"Syncing...":"Sync Now"]}),e.jsx("span",{className:"text-xs opacity-75",children:"Syncs code-defined types to the database"})]})]})})]})}function X({api:t,navigation:s}){const r=y(t.getDashboardStats,{}),n=r===void 0,c=r===null;return e.jsxs("div",{className:"space-y-8",children:[e.jsx(L,{title:"Dashboard",description:"Welcome to Convex CMS Admin. Manage your content, media, and publishing workflows."}),e.jsx(G,{api:t}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(l,{title:"Content Entries",description:"Create and manage your content",onClick:()=>s.navigate("/content"),icon:e.jsx(A,{className:"size-5"})}),e.jsx(l,{title:"Media Library",description:"Upload and organize media assets",onClick:()=>s.navigate("/media"),icon:e.jsx(M,{className:"size-5"})}),e.jsx(l,{title:"Content Types",description:"Define content schemas and fields",onClick:()=>s.navigate("/content-types"),icon:e.jsx(E,{className:"size-5"})}),e.jsx(l,{title:"Settings",description:"Configure CMS settings",onClick:()=>s.navigate("/settings"),icon:e.jsx(R,{className:"size-5"})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"size-5 text-muted-foreground"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Quick Stats"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(m,{label:"Content Types",value:n?void 0:c?"—":String(r.contentTypes),isLoading:n}),e.jsx(m,{label:"Content Entries",value:n?void 0:c?"—":String(r.contentEntries),isLoading:n}),e.jsx(m,{label:"Media Assets",value:n?void 0:c?"—":String(r.mediaAssets),isLoading:n}),e.jsx(m,{label:"Published",value:n?void 0:c?"—":String(r.published),isLoading:n})]})]})]})}function l({title:t,description:s,onClick:r,icon:n}){return e.jsx("button",{type:"button",onClick:r,className:"text-left",children:e.jsxs(N,{className:"h-full transition-colors hover:bg-accent/50",children:[e.jsxs(U,{className:"pb-2",children:[e.jsx("div",{className:"mb-2 flex size-10 items-center justify-center rounded-lg bg-primary/10 text-primary",children:n}),e.jsx(W,{className:"text-base",children:t})]}),e.jsx(b,{children:e.jsx(q,{children:s})})]})})}function m({label:t,value:s,isLoading:r=!1}){return e.jsx(N,{children:e.jsxs(b,{className:"p-4",children:[r?e.jsx(B,{className:"mb-1 h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:s}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t})]})})}function Z(){const t=$();return e.jsx(X,{api:_.admin,navigation:t})}export{Z as component};
1
+ import{l as j,j as e,h as o,u as y,a as w,r as g,a9 as z,f as D,G as T,F as A,E as M,aa as E,ab as R,k as _}from"./main-CA-4LyFT.js";import{C as L}from"./CmsPageHeader-0REGRH4X.js";import{A as h,b as f,a as p}from"./alert-CG97cMfC.js";import{R as I}from"./refresh-cw-sdVUGJNs.js";import{u as $}from"./tanstack-adapter-BRt2CUCw.js";const P=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],F=j("circle-x",P);const H=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Q=j("trending-up",H);function N({className:t,...s}){return e.jsx("div",{"data-slot":"card",className:o("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...s})}function U({className:t,...s}){return e.jsx("div",{"data-slot":"card-header",className:o("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...s})}function W({className:t,...s}){return e.jsx("div",{"data-slot":"card-title",className:o("leading-none font-semibold",t),...s})}function q({className:t,...s}){return e.jsx("div",{"data-slot":"card-description",className:o("text-muted-foreground text-sm",t),...s})}function b({className:t,...s}){return e.jsx("div",{"data-slot":"card-content",className:o("px-6",t),...s})}function B({className:t,...s}){return e.jsx("div",{"data-slot":"skeleton",className:o("bg-accent animate-pulse rounded-md",t),...s})}function G({api:t}){const s=y(t.checkSchemaDrift,{}),r=w(t.syncCodeDefinedTypes),[n,c]=g.useState(!1),[d,u]=g.useState(null);if(s===void 0)return null;if(!s||s.length===0)return d&&(d.created>0||d.updated>0)?e.jsxs(h,{className:"border-success/50 bg-success/10",children:[e.jsx(z,{className:"size-4 text-success"}),e.jsx(f,{className:"text-diff-added-foreground",children:"Sync Complete"}),e.jsxs(p,{className:"text-diff-added-foreground/80",children:[d.created>0&&e.jsxs("span",{children:[d.created," content type(s) created. "]}),d.updated>0&&e.jsxs("span",{children:[d.updated," content type(s) updated."]})]})]}):null;const a=s.filter(i=>i.severity==="error"),x=s.filter(i=>i.severity==="warning"),v=async()=>{c(!0),u(null);try{const i=await r({});u(i)}catch(i){console.error("Sync failed:",i)}finally{c(!1)}},C=a.length>0?"destructive":"default",S=a.length>0?F:D,k=a.length>0?"text-destructive":"text-warning";return e.jsxs(h,{variant:C,className:a.length===0?"border-warning/50 bg-warning/10":"",children:[e.jsx(S,{className:`size-4 ${k}`}),e.jsx(f,{className:a.length===0?"text-diff-modified-foreground":"",children:"Schema Drift Detected"}),e.jsx(p,{className:a.length===0?"text-diff-modified-foreground/80":"",children:e.jsxs("div",{className:"space-y-2",children:[a.length>0&&e.jsxs("p",{children:[e.jsxs("strong",{children:[a.length," error(s)"]}),":"," ",a.slice(0,3).map(i=>i.message).join(" "),a.length>3&&` ...and ${a.length-3} more`]}),x.length>0&&e.jsxs("p",{children:[e.jsxs("strong",{children:[x.length," warning(s)"]}),": Code-defined types may need syncing."]}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsxs(T,{size:"sm",variant:a.length>0?"destructive":"outline",onClick:v,disabled:n,className:a.length===0?"border-warning/50 text-diff-modified-foreground hover:bg-warning/20":"",children:[e.jsx(I,{className:`mr-1.5 size-3.5 ${n?"animate-spin":""}`}),n?"Syncing...":"Sync Now"]}),e.jsx("span",{className:"text-xs opacity-75",children:"Syncs code-defined types to the database"})]})]})})]})}function X({api:t,navigation:s}){const r=y(t.getDashboardStats,{}),n=r===void 0,c=r===null;return e.jsxs("div",{className:"space-y-8",children:[e.jsx(L,{title:"Dashboard",description:"Welcome to Convex CMS Admin. Manage your content, media, and publishing workflows."}),e.jsx(G,{api:t}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(l,{title:"Content Entries",description:"Create and manage your content",onClick:()=>s.navigate("/content"),icon:e.jsx(A,{className:"size-5"})}),e.jsx(l,{title:"Media Library",description:"Upload and organize media assets",onClick:()=>s.navigate("/media"),icon:e.jsx(M,{className:"size-5"})}),e.jsx(l,{title:"Content Types",description:"Define content schemas and fields",onClick:()=>s.navigate("/content-types"),icon:e.jsx(E,{className:"size-5"})}),e.jsx(l,{title:"Settings",description:"Configure CMS settings",onClick:()=>s.navigate("/settings"),icon:e.jsx(R,{className:"size-5"})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"size-5 text-muted-foreground"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Quick Stats"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(m,{label:"Content Types",value:n?void 0:c?"—":String(r.contentTypes),isLoading:n}),e.jsx(m,{label:"Content Entries",value:n?void 0:c?"—":String(r.contentEntries),isLoading:n}),e.jsx(m,{label:"Media Assets",value:n?void 0:c?"—":String(r.mediaAssets),isLoading:n}),e.jsx(m,{label:"Published",value:n?void 0:c?"—":String(r.published),isLoading:n})]})]})]})}function l({title:t,description:s,onClick:r,icon:n}){return e.jsx("button",{type:"button",onClick:r,className:"text-left",children:e.jsxs(N,{className:"h-full transition-colors hover:bg-accent/50",children:[e.jsxs(U,{className:"pb-2",children:[e.jsx("div",{className:"mb-2 flex size-10 items-center justify-center rounded-lg bg-primary/10 text-primary",children:n}),e.jsx(W,{className:"text-base",children:t})]}),e.jsx(b,{children:e.jsx(q,{children:s})})]})})}function m({label:t,value:s,isLoading:r=!1}){return e.jsx(N,{children:e.jsxs(b,{className:"p-4",children:[r?e.jsx(B,{className:"mb-1 h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:s}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t})]})})}function Z(){const t=$();return e.jsx(X,{api:_.admin,navigation:t})}export{Z as component};