headroom-cms 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/assets/AdminsPage-DYJhlQnA.js +1 -0
- package/admin/assets/AllContentPage-DShBvFru.js +1 -0
- package/admin/assets/{ApiKeysPage-FgNHZPBS.js → ApiKeysPage-DONrd-TJ.js} +1 -1
- package/admin/assets/{AuditPage-DAPpo-sj.js → AuditPage-BwhYu96L.js} +1 -1
- package/admin/assets/{BlockEditor-CZTwex-o.js → BlockEditor-C0KaZUHQ.js} +57 -57
- package/admin/assets/BlockTypeEditPage-BYJfEA6l.js +1 -0
- package/admin/assets/BlockTypesPage-Pf9u78-O.js +1 -0
- package/admin/assets/BulkActionBar-BX-t8fyM.js +1 -0
- package/admin/assets/CollectionEditPage-CQGo9Cbu.js +1 -0
- package/admin/assets/{CollectionsPage-BnCaxALz.js → CollectionsPage-D-QTkoW_.js} +1 -1
- package/admin/assets/{ContentCreatePage-CJI326o-.js → ContentCreatePage-DujNZXXj.js} +1 -1
- package/admin/assets/ContentEditPage-DyqgEoAe.js +3 -0
- package/admin/assets/ContentListPage-llAlhZTH.js +1 -0
- package/admin/assets/{CustomBlockPreview-CCssn6vF.js → CustomBlockPreview-CCiZrZhi.js} +1 -1
- package/admin/assets/FieldBuilder-B3-3MTqp.js +3 -0
- package/admin/assets/{LoginPage-Jrne8-Wr.js → LoginPage-BlJXP0GH.js} +1 -1
- package/admin/assets/MediaPage-Cad4n33B.js +1 -0
- package/admin/assets/SiteSettingsPage-xfAm3ZKQ.js +1 -0
- package/admin/assets/SitesPage-DnCiSu23.js +1 -0
- package/admin/assets/{TagsPage-BGpp0XZM.js → TagsPage-DNlaoFCE.js} +1 -1
- package/admin/assets/UsersPage-D_nOx6W9.js +1 -0
- package/admin/assets/{WebhookEditPage-BOcLe5OJ.js → WebhookEditPage-BUvLl4rY.js} +1 -1
- package/admin/assets/{WebhooksPage-Czco583Y.js → WebhooksPage-CG7WC9Bq.js} +1 -1
- package/admin/assets/{badge-0Z1nL6DI.js → badge-ChZ2DZue.js} +1 -1
- package/admin/assets/{card-D1-S-QZ6.js → card-DpNr7WTb.js} +1 -1
- package/admin/assets/check-BMpruHpO.js +1 -0
- package/admin/assets/{checkbox-BPqrj_XS.js → checkbox-VtCfoGic.js} +1 -1
- package/admin/assets/command-98iA8Va4.js +1 -0
- package/admin/assets/contentStatus-BmaiYVOm.js +1 -0
- package/admin/assets/{copy-BqH9rXYM.js → copy-fXL6Ngxi.js} +1 -1
- package/admin/assets/{core.esm-Csvubn5Q.js → core.esm-BtFZvlg0.js} +1 -1
- package/admin/assets/format-C88SDH8g.js +1 -0
- package/admin/assets/index-CwkwXbO-.js +18 -0
- package/admin/assets/index-FYfbavkE.css +1 -0
- package/admin/assets/plus-2Ds_MoqB.js +1 -0
- package/admin/assets/popover-DFInMOpa.js +1 -0
- package/admin/assets/radix-n1vDIPi6.js +51 -0
- package/admin/assets/search-DRNC6QB5.js +1 -0
- package/admin/assets/select-Cj54Wt-H.js +1 -0
- package/admin/assets/{sortable.esm-Zh-9QRSf.js → sortable.esm-BUhmZW2_.js} +1 -1
- package/admin/assets/{table-B3EHrN_H.js → table-D4rLgOKa.js} +1 -1
- package/admin/assets/{trash-2-Gny2Upn-.js → trash-2-CbbWF_O4.js} +1 -1
- package/admin/assets/use-mobile-Cvl5tIVY.js +1 -0
- package/admin/assets/useAdminResolver-B-_1f6SR.js +1 -0
- package/admin/assets/useContent-Cp41wBYR.js +1 -0
- package/admin/assets/useMedia-DjiNKMOU.js +1 -0
- package/admin/assets/{useTags-CYqbj5cK.js → useTags-BB47vbXO.js} +1 -1
- package/admin/assets/{useWebhooks-DXgtQ3aU.js → useWebhooks-DS4Ee8Wk.js} +1 -1
- package/admin/assets/workbox-window.prod.es5-BIl4cyR9.js +2 -0
- package/admin/icons/icon-180x180.png +0 -0
- package/admin/icons/icon-192x192.png +0 -0
- package/admin/icons/icon-512x512.png +0 -0
- package/admin/icons/maskable-icon-512x512.png +0 -0
- package/admin/index.html +11 -6
- package/admin/manifest.webmanifest +1 -0
- package/admin/sw.js +1 -0
- package/admin/workbox-7d58179f.js +1 -0
- package/dist/admin-site.d.ts.map +1 -1
- package/dist/admin-site.js +3 -0
- package/dist/admin-site.js.map +1 -1
- package/dist/image.d.ts.map +1 -1
- package/dist/image.js +3 -0
- package/dist/image.js.map +1 -1
- package/dist/storage.js +1 -1
- package/dist/storage.js.map +1 -1
- package/lambda/api/bootstrap +0 -0
- package/lambda/webhook-worker/bootstrap +0 -0
- package/package.json +2 -2
- package/src/admin-site.ts +3 -0
- package/src/image.ts +3 -0
- package/src/storage.ts +1 -1
- package/admin/assets/AdminsPage-CnrQqwKA.js +0 -1
- package/admin/assets/AllContentPage-ByN1h3PP.js +0 -1
- package/admin/assets/BlockTypeEditPage-Buuwbx1P.js +0 -1
- package/admin/assets/BlockTypesPage-Dj0qmsqX.js +0 -1
- package/admin/assets/BulkActionBar-BMcUBJSH.js +0 -1
- package/admin/assets/CollectionEditPage-CLgQu2HS.js +0 -1
- package/admin/assets/ContentEditPage-A4i8P2Jd.js +0 -3
- package/admin/assets/ContentListPage-Bc4mBIkB.js +0 -1
- package/admin/assets/FieldBuilder-YJGSk0nY.js +0 -3
- package/admin/assets/MediaPage-_qNXqsZg.js +0 -1
- package/admin/assets/SiteSettingsPage-CoZnavij.js +0 -1
- package/admin/assets/SitesPage-ETqFT3nO.js +0 -1
- package/admin/assets/UsersPage-CKRJpAb6.js +0 -1
- package/admin/assets/check-BGA0ADyt.js +0 -1
- package/admin/assets/command-ChD319uJ.js +0 -1
- package/admin/assets/contentStatus-DfWHjFVB.js +0 -1
- package/admin/assets/format-CZ9bpk32.js +0 -1
- package/admin/assets/index-DOqKbrpW.css +0 -1
- package/admin/assets/index-Ds50UTAc.js +0 -18
- package/admin/assets/media-url-DIg_vSyf.js +0 -1
- package/admin/assets/plus-BgHSYWJN.js +0 -1
- package/admin/assets/radix-DQ3amgxj.js +0 -51
- package/admin/assets/search-DIzcfCVh.js +0 -1
- package/admin/assets/select-CJXZv4wv.js +0 -1
- package/admin/assets/useAdminResolver-BsQc_N4z.js +0 -1
- package/admin/assets/useContent-CSobIico.js +0 -1
- package/admin/assets/useMedia-CQnmMz4N.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{u as A,e as H,r as o}from"./react-vendor-DNVhVxD7.js";import{L as d,I as b,W as C,a3 as R,S as k,a4 as U,a5 as V,a6 as W,B as h,a as _,D as z,i as G,j as J,k as K,l as M,m as Q,n as X,t as j}from"./index-CwkwXbO-.js";import{I as Y,F as Z}from"./FieldBuilder-B3-3MTqp.js";import{i as ee}from"./format-C88SDH8g.js";import{T as ae,C as se,b as te,c as le}from"./sortable.esm-BUhmZW2_.js";import{C as ie,a as ne,b as re,c as oe}from"./card-DpNr7WTb.js";import{C as ce}from"./CustomBlockPreview-CCiZrZhi.js";import{u as T}from"./useDebouncedValue-Bf8UizjU.js";import{b as de}from"./core.esm-BtFZvlg0.js";import{T as me}from"./trash-2-CbbWF_O4.js";import"./radix-n1vDIPi6.js";import"./select-Cj54Wt-H.js";import"./check-BMpruHpO.js";import"./checkbox-VtCfoGic.js";import"./plus-2Ds_MoqB.js";function pe({fields:s,previewTemplate:t,previewData:a,onPreviewDataChange:n,blockTypeName:c,blockTypeLabel:m,blockTypeIcon:f}){const r=T(t,300),y=T(a,300);return e.jsxs("div",{className:"space-y-4",children:[s.map(i=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:i.label}),e.jsx(b,{value:String(a[i.name]??""),onChange:v=>n({...a,[i.name]:v.target.value}),placeholder:`Sample ${i.label}...`})]},i.name)),e.jsx(C,{}),e.jsx("div",{className:"rounded-md border p-4",children:e.jsx(ce,{blockType:{name:c,label:m,icon:f,fields:s,previewTemplate:r},props:y})})]})}function Se(){const{host:s,name:t}=A(),a=t==="new",{data:n,isLoading:c}=R(s,a?"":t);return!a&&c?e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{className:"h-8 w-64"}),e.jsx(k,{className:"h-64 w-full"})]}):a?e.jsx(B,{host:s,isNew:!0}):n?e.jsx(B,{host:s,isNew:!1,blockType:n},n.name):e.jsx("p",{className:"text-muted-foreground",children:"Block type not found."})}function B({host:s,isNew:t,blockType:a}){const n=H(),c=U(s),m=V(s,a?.name??""),f=W(s,a?.name??""),[r,y]=o.useState(a?.name??""),[i,v]=o.useState(a?.label??""),[g,D]=o.useState(a?.icon??""),[S,F]=o.useState(!t),P=new Set((a?.fields??[]).map(l=>l.name).filter(Boolean)),[p,L]=o.useState(a?.fields??[]),[u,E]=o.useState(a?.previewTemplate??""),[x,I]=o.useState(a?.previewData??{}),[O,w]=o.useState(!1);async function $(l){l.preventDefault();try{t?(await c.mutateAsync({name:r,label:i,icon:g,fields:p,previewTemplate:u||void 0,previewData:Object.keys(x).length>0?x:void 0}),j.success("Block type created"),n(`/sites/${s}/settings/block-types/${r}`)):(await m.mutateAsync({label:i,icon:g,fields:p,previewTemplate:u||void 0,previewData:Object.keys(x).length>0?x:void 0}),j.success("Block type updated"))}catch(N){j.error(t?"Failed to create":"Failed to update",{description:N instanceof Error?N.message:void 0})}}async function q(){try{await f.mutateAsync(),j.success("Block type deleted"),n(`/sites/${s}/settings/block-types`)}catch(l){j.error("Failed to delete",{description:l instanceof Error?l.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:t?"New Block Type":`Edit: ${a?.label??r}`}),e.jsxs(ie,{children:[e.jsx(ne,{children:e.jsx(re,{children:"Block Type Settings"})}),e.jsx(oe,{children:e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"name",children:"Name"}),e.jsx(Y,{id:"name",value:r,onChange:y,onBlur:()=>{r&&!S&&v(ee(r))},readOnly:!t,placeholder:"e.g. hero_banner",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"label",children:"Label"}),e.jsx(b,{id:"label",value:i,onChange:l=>{v(l.target.value),F(!0)},required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"icon",children:"Icon"}),e.jsx(b,{id:"icon",value:g,onChange:l=>D(l.target.value)})]}),e.jsx(C,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Block Fields"}),e.jsx(Z,{fields:p,onChange:L,existingFieldNames:P})]}),e.jsx(C,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"preview-template",children:"Preview Template (Liquid + Tailwind)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Use Liquid syntax to render a preview. Block field values are available as template variables."}),e.jsx(ae,{id:"preview-template",value:u,onChange:l=>E(l.target.value),rows:6,placeholder:'<div class="p-4">{{ title }}</div>',className:"font-mono text-sm"})]}),(u||p.length>0)&&e.jsxs(se,{children:[e.jsxs(te,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(de,{className:"h-4 w-4 transition-transform [[data-state=open]>&]:rotate-90"}),"Preview"]}),e.jsx(le,{className:"mt-2",children:e.jsx(pe,{fields:p,previewTemplate:u,previewData:x,onPreviewDataChange:I,blockTypeName:r,blockTypeLabel:i,blockTypeIcon:g})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{type:"submit",disabled:c.isPending||m.isPending,children:[(c.isPending||m.isPending)&&e.jsx(_,{className:"mr-2 h-4 w-4 animate-spin"}),t?"Create":"Save"]}),e.jsx(h,{type:"button",variant:"outline",onClick:()=>n(`/sites/${s}/settings/block-types`),children:"Cancel"})]})]})})]}),!t&&e.jsx("div",{className:"mt-6",children:e.jsxs(z,{open:O,onOpenChange:w,children:[e.jsx(G,{asChild:!0,children:e.jsxs(h,{variant:"destructive",children:[e.jsx(me,{className:"mr-2 h-4 w-4"}),"Delete Block Type"]})}),e.jsxs(J,{children:[e.jsxs(K,{children:[e.jsx(M,{children:"Delete block type?"}),e.jsx(Q,{children:"This will permanently delete this block type."})]}),e.jsxs(X,{children:[e.jsx(h,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(h,{variant:"destructive",onClick:q,children:"Delete"})]})]})]})})]})}export{Se as BlockTypeEditPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{u as m,e as d}from"./react-vendor-DNVhVxD7.js";import{a2 as x,B as h,S as j}from"./index-CwkwXbO-.js";import{T as p,a as f,b as c,c as a,d as u,e as l}from"./table-D4rLgOKa.js";import{P as N}from"./plus-2Ds_MoqB.js";import"./radix-n1vDIPi6.js";function w(){const{host:n}=m(),i=d(),{data:r,isLoading:o}=x(n);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Block Types"}),e.jsxs(h,{onClick:()=>i(`/sites/${n}/settings/block-types/new`),children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),"New Block Type"]})]}),o?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,t)=>e.jsx(j,{className:"h-12 w-full"},t))}):r?.items.length?e.jsxs(p,{children:[e.jsx(f,{children:e.jsxs(c,{children:[e.jsx(a,{children:"Name"}),e.jsx(a,{children:"Label"}),e.jsx(a,{children:"Icon"}),e.jsx(a,{children:"Fields"})]})}),e.jsx(u,{children:r.items.map(s=>e.jsxs(c,{className:"cursor-pointer",onClick:()=>i(`/sites/${n}/settings/block-types/${s.name}`),children:[e.jsx(l,{className:"font-mono text-sm",children:s.name}),e.jsx(l,{children:s.label}),e.jsx(l,{children:s.icon}),e.jsx(l,{className:"text-muted-foreground",children:s.fields?.length??0})]},s.name))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No block types defined."})]})}export{w as BlockTypesPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{r as m}from"./react-vendor-DNVhVxD7.js";import{B as a,a as t,X as x,D as h,j,k as p,l as u,m as D,n as b}from"./index-CwkwXbO-.js";function k({selectedCount:i,onPublish:n,onUnpublish:r,onDelete:c,onClear:o,isPending:s}){const[d,l]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-md border bg-muted/50 px-4 py-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:[i," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{size:"sm",variant:"outline",onClick:n,disabled:s,children:[s&&e.jsx(t,{className:"mr-1 h-3 w-3 animate-spin"}),"Publish"]}),e.jsx(a,{size:"sm",variant:"outline",onClick:r,disabled:s,children:"Unpublish"}),e.jsx(a,{size:"sm",variant:"destructive",onClick:()=>l(!0),disabled:s,children:"Delete"})]}),e.jsx(a,{size:"sm",variant:"ghost",onClick:o,className:"ml-auto",disabled:s,children:e.jsx(x,{className:"h-4 w-4"})})]}),e.jsx(h,{open:d,onOpenChange:l,children:e.jsxs(j,{children:[e.jsxs(p,{children:[e.jsxs(u,{children:["Delete ",i," item",i!==1?"s":"","?"]}),e.jsx(D,{children:"This action cannot be undone. The selected content items will be permanently deleted."})]}),e.jsxs(b,{children:[e.jsx(a,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(a,{variant:"destructive",onClick:async()=>{l(!1),await c()},disabled:s,children:[s&&e.jsx(t,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})})]})}export{k as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{r as c,u as Q,e as X}from"./react-vendor-DNVhVxD7.js";import{o as Y,w as ee,B as C,I as E,Z as se,S as B,v as te,$ as ae,a0 as le,a1 as ne,L as f,W as T,a as ie,D as re,i as oe,j as ce,k as de,l as me,m as ue,n as xe,t as D}from"./index-CwkwXbO-.js";import{I as P,F as he}from"./FieldBuilder-B3-3MTqp.js";import{i as O,c as ge}from"./format-C88SDH8g.js";import{C as A}from"./checkbox-VtCfoGic.js";import{C as je,a as pe,b as fe,c as Ce}from"./card-DpNr7WTb.js";import{C as be,G as ve,b as Se,u as Ne,a as ye,P as De,D as Ee,c as ke}from"./core.esm-BtFZvlg0.js";import{u as we,C as Fe,b as Le,c as Re,S as Ie,v as Be,a as Te}from"./sortable.esm-BUhmZW2_.js";import{S as $e,a as Pe,b as Oe,c as Ae,d as _e}from"./select-Cj54Wt-H.js";import{T as _}from"./trash-2-CbbWF_O4.js";import{P as qe}from"./plus-2Ds_MoqB.js";import"./radix-n1vDIPi6.js";import"./check-BMpruHpO.js";const ze=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ve=Y("arrow-right",ze);function Ge({id:t,relationship:s,onChange:a,onRemove:d,collections:x,readOnlyName:u,defaultExpanded:g}){const[b,m]=c.useState(g??!1),[N,j]=c.useState(!!s.label),{attributes:v,listeners:r,setNodeRef:n,transform:o,transition:S}=we({id:t}),h={transform:be.Transform.toString(o),transition:S};function p(i){a({...s,...i})}const k=x.find(i=>i.name===s.targetCollection)?.label??s.targetCollection;return e.jsx("div",{ref:n,style:h,className:"rounded-md border bg-card",children:e.jsxs(Fe,{open:b,onOpenChange:m,children:[e.jsxs("div",{className:"flex items-center gap-2 p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...v,...r,children:e.jsx(ve,{className:"h-4 w-4"})}),e.jsx(Le,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex items-center",children:e.jsx(Se,{className:ee("h-4 w-4 transition-transform",b&&"rotate-90")})})}),e.jsx("span",{className:"min-w-[80px] text-sm font-mono",children:s.name||"unnamed"}),e.jsx(Ve,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:k}),e.jsx("span",{className:"flex-1 truncate text-sm text-muted-foreground",children:s.label}),e.jsx(C,{type:"button",variant:"ghost",size:"sm",onClick:d,className:"text-destructive",children:e.jsx(_,{className:"h-3 w-3"})})]}),e.jsx(Re,{children:e.jsxs("div",{className:"space-y-3 border-t p-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),e.jsx(P,{value:s.name,onChange:i=>p({name:i}),onBlur:()=>{s.name&&!N&&p({label:O(s.name)})},readOnly:u,className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Label"}),e.jsx(E,{value:s.label,onChange:i=>{p({label:i.target.value}),j(!0)},className:"h-8 text-sm"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Target Collection"}),e.jsxs($e,{value:s.targetCollection,onValueChange:i=>p({targetCollection:i}),children:[e.jsx(Pe,{className:"h-8 text-sm",children:e.jsx(Oe,{placeholder:"Select collection..."})}),e.jsx(Ae,{children:x.map(i=>e.jsx(_e,{value:i.name,children:i.label},i.name))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{id:`${t}-multiple`,checked:s.multiple,onCheckedChange:i=>p({multiple:!!i})}),e.jsx("label",{htmlFor:`${t}-multiple`,className:"text-sm",children:"Allow multiple"})]})]})})]})})}function He({relationships:t,onChange:s,collections:a,existingRelNames:d}){const x=Ne(ye(De)),u=t.map((r,n)=>`rel-${n}`),[g,b]=c.useState(null);function m(){b(t.length),s([...t,{name:"",label:"",targetCollection:"",multiple:!1}])}function N(r,n){const o=[...t];o[r]=n,s(o)}function j(r){s(t.filter((n,o)=>o!==r))}function v(r){const{active:n,over:o}=r;if(o&&n.id!==o.id){const S=u.indexOf(String(n.id)),h=u.indexOf(String(o.id));s(Te(t,S,h))}}return e.jsx(Ee,{sensors:x,collisionDetection:ke,onDragEnd:v,children:e.jsx(Ie,{items:u,strategy:Be,children:e.jsxs("div",{className:"space-y-2",children:[t.map((r,n)=>e.jsx(Ge,{id:`rel-${n}`,relationship:r,onChange:o=>N(n,o),onRemove:()=>j(n),collections:a,readOnlyName:!!(d?.has(r.name)&&r.name),defaultExpanded:n===g},`rel-${n}`)),e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:m,children:[e.jsx(qe,{className:"mr-2 h-3 w-3"})," Add Relationship"]})]})})})}function ns(){const{host:t,name:s}=Q(),a=s==="new",{data:d,isLoading:x}=se(t,a?"":s);return!a&&x?e.jsxs("div",{className:"space-y-4",children:[e.jsx(B,{className:"h-8 w-64"}),e.jsx(B,{className:"h-64 w-full"})]}):a?e.jsx($,{host:t,isNew:!0}):d?e.jsx($,{host:t,isNew:!1,collection:d},d.name):e.jsx("p",{className:"text-muted-foreground",children:"Collection not found."})}function $({host:t,isNew:s,collection:a}){const d=X(),{collections:x}=te(),u=ae(t),g=le(t,a?.name??""),b=ne(t,a?.name??""),[m,N]=c.useState(a?.name??""),[j,v]=c.useState(a?.label??""),[r,n]=c.useState(a?.labelSingular??""),[o,S]=c.useState(a?.slug??""),[h,p]=c.useState(a?.singleton??!1),[k,i]=c.useState(!s),[q,z]=c.useState(!s),[V,G]=c.useState(!s),H=new Set((a?.fields??[]).map(l=>l.name).filter(Boolean)),L=[{name:"blocks",label:"Blocks",type:"blocks",options:{}}],[w,R]=c.useState(a?.fields??(s&&!h?L:[])),[F,M]=c.useState(a?.relationships??[]),U=new Set((a?.relationships??[]).map(l=>l.name).filter(Boolean)),[W,I]=c.useState(!1);function Z(){if(!m)return;const l=O(m);k||v(l),q||n(ge(l)),V||S(m.replace(/_/g,"-"))}async function J(l){l.preventDefault();try{s?(await u.mutateAsync({name:m,label:j,labelSingular:r,slug:o,singleton:h,fields:w,relationships:F}),D.success("Collection created"),d(`/sites/${t}/settings/collections/${m}`)):(await g.mutateAsync({label:j,labelSingular:r,slug:o,singleton:h,fields:w,relationships:F}),D.success("Collection updated"))}catch(y){D.error(s?"Failed to create":"Failed to update",{description:y instanceof Error?y.message:void 0})}}async function K(){try{await b.mutateAsync(),D.success("Collection deleted"),d(`/sites/${t}/settings/collections`)}catch(l){D.error("Failed to delete",{description:l instanceof Error?l.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:s?"New Collection":`Edit: ${a?.label??m}`}),e.jsxs(je,{children:[e.jsx(pe,{children:e.jsx(fe,{children:"Collection Settings"})}),e.jsx(Ce,{children:e.jsxs("form",{onSubmit:J,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"name",children:"Name"}),e.jsx(P,{id:"name",value:m,onChange:N,onBlur:Z,readOnly:!s,placeholder:"e.g. blog_posts",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"label",children:"Label"}),e.jsx(E,{id:"label",value:j,onChange:l=>{v(l.target.value),i(!0)},required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"label-singular",children:"Label Singular"}),e.jsx(E,{id:"label-singular",value:r,onChange:l=>{n(l.target.value),z(!0)},required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"slug",children:"Slug"}),e.jsx(E,{id:"slug",value:o,onChange:l=>{S(l.target.value),G(!0)},required:!0})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{id:"singleton",checked:h,onCheckedChange:l=>{const y=!!l;p(y),s&&R(y?[]:L)},disabled:!s}),e.jsx(f,{htmlFor:"singleton",children:"Singleton (single entry, no list)"})]}),e.jsx(T,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Fields"}),e.jsx(he,{fields:w,onChange:R,existingFieldNames:H})]}),e.jsx(T,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Relationships"}),e.jsx(He,{relationships:F,onChange:M,collections:x,existingRelNames:U})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{type:"submit",disabled:u.isPending||g.isPending,children:[(u.isPending||g.isPending)&&e.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Create":"Save"]}),e.jsx(C,{type:"button",variant:"outline",onClick:()=>d(`/sites/${t}/settings/collections`),children:"Cancel"})]})]})})]}),!s&&e.jsx("div",{className:"mt-6",children:e.jsxs(re,{open:W,onOpenChange:I,children:[e.jsx(oe,{asChild:!0,children:e.jsxs(C,{variant:"destructive",children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Delete Collection"]})}),e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsx(me,{children:"Delete collection?"}),e.jsx(ue,{children:"This will permanently delete the collection and all its content."})]}),e.jsxs(xe,{children:[e.jsx(C,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(C,{variant:"destructive",onClick:K,children:"Delete"})]})]})]})})]})}export{ns as CollectionEditPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-BO6c-AOu.js";import{u as m,e as x}from"./react-vendor-DNVhVxD7.js";import{
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{u as m,e as x}from"./react-vendor-DNVhVxD7.js";import{Y as h,B as j,S as f}from"./index-CwkwXbO-.js";import{B as o}from"./badge-ChZ2DZue.js";import{T as u,a as p,b as r,c as l,d as g,e as n}from"./table-D4rLgOKa.js";import{P as N}from"./plus-2Ds_MoqB.js";import"./radix-n1vDIPi6.js";function P(){const{host:a}=m(),i=x(),{data:t,isLoading:c}=h(a);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Collections"}),e.jsxs(j,{onClick:()=>i(`/sites/${a}/settings/collections/new`),children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),"New Collection"]})]}),c?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,d)=>e.jsx(f,{className:"h-12 w-full"},d))}):t?.items.length?e.jsxs(u,{children:[e.jsx(p,{children:e.jsxs(r,{children:[e.jsx(l,{children:"Name"}),e.jsx(l,{children:"Label"}),e.jsx(l,{children:"Type"}),e.jsx(l,{children:"Fields"})]})}),e.jsx(g,{children:t.items.map(s=>e.jsxs(r,{className:"cursor-pointer",onClick:()=>i(`/sites/${a}/settings/collections/${s.name}`),children:[e.jsx(n,{className:"font-mono text-sm",children:s.name}),e.jsx(n,{children:s.label}),e.jsx(n,{children:s.singleton?e.jsx(o,{variant:"secondary",children:"Singleton"}):e.jsx(o,{variant:"outline",children:"Collection"})}),e.jsx(n,{className:"text-muted-foreground",children:s.fields?.length??0})]},s.name))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No collections defined."})]})}export{P as CollectionsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-BO6c-AOu.js";import{u as y,e as $,r as i,N as E}from"./react-vendor-DNVhVxD7.js";import{
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{u as y,e as $,r as i,N as E}from"./react-vendor-DNVhVxD7.js";import{v as w,L as g,I as h,B as f,a as I,t as p,x as F}from"./index-CwkwXbO-.js";import{e as P}from"./useContent-Cp41wBYR.js";import{C as T,a as A,b as L,c as B}from"./card-DpNr7WTb.js";import{s as D}from"./format-C88SDH8g.js";import"./radix-n1vDIPi6.js";function K(){const{host:n,collection:s}=y(),c=$(),{collections:C}=w(),o=P(n),[l,j]=i.useState(""),[u,d]=i.useState(""),[v,N]=i.useState(!1),[m,x]=i.useState(null),r=C.find(t=>t.name===s);if(r?.singleton){const t=r.singletonContentId?`/sites/${n}/content/${s}/${r.singletonContentId}`:`/sites/${n}/content/${s}`;return e.jsx(E,{to:t,replace:!0})}function S(t){j(t),v||d(D(t))}async function b(t){t.preventDefault(),x(null);try{const a=await o.mutateAsync({collection:s,title:l,slug:u||void 0});p.success("Content created"),c(`/sites/${n}/content/${s}/${a.contentId}`)}catch(a){a instanceof F&&a.status===409?x("A content item with this slug already exists. Choose a different slug."):p.error("Failed to create content",{description:a instanceof Error?a.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsxs("h1",{className:"mb-6 text-2xl font-semibold",children:["New ",r?.labelSingular??s]}),e.jsxs(T,{children:[e.jsx(A,{children:e.jsx(L,{children:"Details"})}),e.jsx(B,{children:e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"title",children:"Title"}),e.jsx(h,{id:"title",value:l,onChange:t=>S(t.target.value),required:!0,autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"slug",children:"Slug"}),e.jsx(h,{id:"slug",value:u,onChange:t=>{d(t.target.value),N(!0)}})]}),m&&e.jsx("p",{className:"text-sm text-destructive",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(f,{type:"submit",disabled:!l||o.isPending,children:[o.isPending&&e.jsx(I,{className:"mr-2 h-4 w-4 animate-spin"}),"Create"]}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>c(-1),children:"Cancel"})]})]})})]})]})}export{K as ContentCreatePage};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlockEditor-C0KaZUHQ.js","assets/tanstack-BO6c-AOu.js","assets/react-vendor-DNVhVxD7.js","assets/index-CwkwXbO-.js","assets/radix-n1vDIPi6.js","assets/index-FYfbavkE.css","assets/command-98iA8Va4.js","assets/search-DRNC6QB5.js","assets/badge-ChZ2DZue.js","assets/use-mobile-Cvl5tIVY.js","assets/CustomBlockPreview-CCiZrZhi.js","assets/useContent-Cp41wBYR.js","assets/useAdminResolver-B-_1f6SR.js","assets/select-Cj54Wt-H.js","assets/check-BMpruHpO.js","assets/format-C88SDH8g.js","assets/sortable.esm-BUhmZW2_.js","assets/core.esm-BtFZvlg0.js","assets/card-DpNr7WTb.js","assets/useMedia-DjiNKMOU.js","assets/useTags-BB47vbXO.js","assets/popover-DFInMOpa.js","assets/useDebouncedValue-Bf8UizjU.js","assets/plus-2Ds_MoqB.js","assets/checkbox-VtCfoGic.js","assets/trash-2-CbbWF_O4.js","assets/contentStatus-BmaiYVOm.js","assets/BlockEditor-Cp_wZ2xN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as e,u as At}from"./tanstack-BO6c-AOu.js";import{r as x,u as Ce,e as Tt,L as Lt}from"./react-vendor-DNVhVxD7.js";import{f as _t,g as Ls,h as Mt,i as _s,j as Ot,k as Ft,l as Rt,m as Et,n as $t,o as Ut,p as Vt,q as zt,r as Ms}from"./useContent-Cp41wBYR.js";import{o as we,x as Os,y as Bt,w as X,z as Ht,A as Wt,C as qt,E as Jt,S as O,T as Fs,F as Rs,G as xe,J as fe,D as ge,j as je,k as ve,l as ye,m as be,I as ie,B as v,a as z,K as Ue,t as L,e as Es,M as Z,X as ee,N as Kt,_ as Gt,L as ne,v as Qt,O as ws,P as Ss,Q as Yt,R as ks,V as Le,n as Oe,W as Xt,i as Zt}from"./index-CwkwXbO-.js";import{u as en}from"./useAdminResolver-B-_1f6SR.js";import{m as Ve,u as $s}from"./use-mobile-Cvl5tIVY.js";import{S as ze,a as Be,b as He,c as We,d as J,e as sn,f as tn,g as nn}from"./select-Cj54Wt-H.js";import{f as W,a as _e}from"./format-C88SDH8g.js";import{u as Us,S as qe,v as Je,a as Ke,T as Vs,C as zs,b as Bs,c as Hs}from"./sortable.esm-BUhmZW2_.js";import{B as le}from"./badge-ChZ2DZue.js";import{C as B,a as Fe,b as Re,c as q}from"./card-DpNr7WTb.js";import{u as an,a as ln,b as rn,c as on,U as cn,F as dn,d as Ws,T as un,E as hn,A as mn,e as pn,f as xn,g as fn,h as gn,i as jn,j as vn,k as yn}from"./useMedia-DjiNKMOU.js";import{u as bn}from"./useTags-BB47vbXO.js";import{C as qs,G as Js,u as Ge,a as Qe,P as Ye,D as Xe,c as Ze,b as Ks}from"./core.esm-BtFZvlg0.js";import{P as Nn,a as Cn,b as wn}from"./popover-DFInMOpa.js";import{C as Sn,a as kn,b as Pn,c as In,d as Dn,e as An}from"./command-98iA8Va4.js";import{u as Tn}from"./useDebouncedValue-Bf8UizjU.js";import{P as es}from"./plus-2Ds_MoqB.js";import{C as Ln}from"./checkbox-VtCfoGic.js";import{T as Gs}from"./trash-2-CbbWF_O4.js";import{g as _n,a as Mn,b as On}from"./contentStatus-BmaiYVOm.js";import{C as Ps}from"./check-BMpruHpO.js";const Fn=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Is=we("calendar-clock",Fn);const Rn=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],En=we("eye",Rn);const $n=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Un=we("pencil",$n);const Vn=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],zn=we("rotate-ccw",Vn),Bn=3e3,Hn="__HEADROOM_API_URL__".replace(/\/+$/,"");function Wn(i,s,n,t){const a=_t(i,s),l=x.useRef(null),r=x.useRef(n?JSON.stringify(n):""),o=x.useRef(void 0),[u,d]=x.useState(null),[p,b]=x.useState(null),h=x.useRef(!1),f=x.useCallback(m=>{JSON.stringify(m)!==r.current&&(l.current=m,clearTimeout(o.current),o.current=window.setTimeout(()=>{if(l.current){const P=l.current,C=JSON.stringify(P);l.current=null,a.mutate(P,{onSuccess:S=>{if(h.current){h.current=!1;return}r.current=C,d(Date.now()),S?.blockId&&b(S.blockId)},onError:S=>{S instanceof Os&&S.code==="SLUG_TAKEN"&&t?.()}})}},Bn))},[a,t]),g=x.useCallback(async m=>{if(clearTimeout(o.current),l.current){const y={...l.current};m?.createVersion&&(y.createVersion=!0);const P=JSON.stringify(l.current);l.current=null;const C=await a.mutateAsync(y);r.current=P,d(Date.now()),C?.blockId&&b(C.blockId)}else if(m?.createVersion&&r.current){const P={...JSON.parse(r.current),createVersion:!0},C=await a.mutateAsync(P);d(Date.now()),C?.blockId&&b(C.blockId)}},[a]),N=x.useCallback(()=>{clearTimeout(o.current),l.current=null},[]),w=x.useCallback(m=>{r.current=JSON.stringify(m)},[]),k=x.useCallback(()=>{clearTimeout(o.current),l.current=null,h.current=!0,b(null)},[]);return x.useEffect(()=>()=>{if(clearTimeout(o.current),l.current){const m=JSON.stringify(l.current),y=Bt(),P=`${Hn}/v1/admin/sites/${i}/content/${s}/draft`;fetch(P,{method:"PUT",body:m,headers:{"Content-Type":"application/json",...y?{Authorization:`Bearer ${y}`}:{}},keepalive:!0}).catch(()=>{}),l.current=null}},[i,s]),{schedule:f,flush:g,cancel:N,resetBaseline:w,discard:k,isSaving:a.isPending,lastSavedAt:u,lastSavedBlockId:p}}function qn({lines:i}){return e.jsx("div",{className:"font-mono text-sm leading-relaxed",children:i.map((s,n)=>e.jsx("div",{style:{paddingLeft:`${s.indent*1.5}rem`},className:X("min-h-[1.5em]",s.type==="label"&&"text-muted-foreground font-semibold mt-1",s.type==="heading"&&"font-bold",s.type==="empty"&&"h-2"),children:s.text},n))})}class Jn{diff(s,n,t={}){let a;typeof t=="function"?(a=t,t={}):"callback"in t&&(a=t.callback);const l=this.castInput(s,t),r=this.castInput(n,t),o=this.removeEmpty(this.tokenize(l,t)),u=this.removeEmpty(this.tokenize(r,t));return this.diffWithOptionsObj(o,u,t,a)}diffWithOptionsObj(s,n,t,a){var l;const r=m=>{if(m=this.postProcess(m,t),a){setTimeout(function(){a(m)},0);return}else return m},o=n.length,u=s.length;let d=1,p=o+u;t.maxEditLength!=null&&(p=Math.min(p,t.maxEditLength));const b=(l=t.timeout)!==null&&l!==void 0?l:1/0,h=Date.now()+b,f=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(f[0],n,s,0,t);if(f[0].oldPos+1>=u&&g+1>=o)return r(this.buildValues(f[0].lastComponent,n,s));let N=-1/0,w=1/0;const k=()=>{for(let m=Math.max(N,-d);m<=Math.min(w,d);m+=2){let y;const P=f[m-1],C=f[m+1];P&&(f[m-1]=void 0);let S=!1;if(C){const D=C.oldPos-m;S=C&&0<=D&&D<o}const A=P&&P.oldPos+1<u;if(!S&&!A){f[m]=void 0;continue}if(!A||S&&P.oldPos<C.oldPos?y=this.addToPath(C,!0,!1,0,t):y=this.addToPath(P,!1,!0,1,t),g=this.extractCommon(y,n,s,m,t),y.oldPos+1>=u&&g+1>=o)return r(this.buildValues(y.lastComponent,n,s))||!0;f[m]=y,y.oldPos+1>=u&&(w=Math.min(w,m-1)),g+1>=o&&(N=Math.max(N,m+1))}d++};if(a)(function m(){setTimeout(function(){if(d>p||Date.now()>h)return a(void 0);k()||m()},0)})();else for(;d<=p&&Date.now()<=h;){const m=k();if(m)return m}}addToPath(s,n,t,a,l){const r=s.lastComponent;return r&&!l.oneChangePerToken&&r.added===n&&r.removed===t?{oldPos:s.oldPos+a,lastComponent:{count:r.count+1,added:n,removed:t,previousComponent:r.previousComponent}}:{oldPos:s.oldPos+a,lastComponent:{count:1,added:n,removed:t,previousComponent:r}}}extractCommon(s,n,t,a,l){const r=n.length,o=t.length;let u=s.oldPos,d=u-a,p=0;for(;d+1<r&&u+1<o&&this.equals(t[u+1],n[d+1],l);)d++,u++,p++,l.oneChangePerToken&&(s.lastComponent={count:1,previousComponent:s.lastComponent,added:!1,removed:!1});return p&&!l.oneChangePerToken&&(s.lastComponent={count:p,previousComponent:s.lastComponent,added:!1,removed:!1}),s.oldPos=u,d}equals(s,n,t){return t.comparator?t.comparator(s,n):s===n||!!t.ignoreCase&&s.toLowerCase()===n.toLowerCase()}removeEmpty(s){const n=[];for(let t=0;t<s.length;t++)s[t]&&n.push(s[t]);return n}castInput(s,n){return s}tokenize(s,n){return Array.from(s)}join(s){return s.join("")}postProcess(s,n){return s}get useLongestToken(){return!1}buildValues(s,n,t){const a=[];let l;for(;s;)a.push(s),l=s.previousComponent,delete s.previousComponent,s=l;a.reverse();const r=a.length;let o=0,u=0,d=0;for(;o<r;o++){const p=a[o];if(p.removed)p.value=this.join(t.slice(d,d+p.count)),d+=p.count;else{if(!p.added&&this.useLongestToken){let b=n.slice(u,u+p.count);b=b.map(function(h,f){const g=t[d+f];return g.length>h.length?g:h}),p.value=this.join(b)}else p.value=this.join(n.slice(u,u+p.count));u+=p.count,p.added||(d+=p.count)}}return a}}class Kn extends Jn{tokenize(s){return s.slice()}join(s){return s}removeEmpty(s){return s}}const Gn=new Kn;function Qs(i,s,n){return Gn.diff(i,s,n)}const Qn=5;function Yn({published:i,draft:s,leftLabel:n="Published",rightLabel:t="Draft"}){const a=x.useMemo(()=>ea(i,s),[i,s]),l=x.useMemo(()=>sa(a),[a]);return a.every(r=>r.type==="unchanged")?e.jsxs("p",{className:"text-sm text-muted-foreground italic py-4",children:["No changes between ",n," and ",t," versions."]}):e.jsxs("div",{className:"font-mono text-xs leading-relaxed border rounded-md overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-2 border-b bg-muted/50 text-muted-foreground text-[10px] font-semibold",children:[e.jsx("div",{className:"px-3 py-1.5",children:n}),e.jsx("div",{className:"px-3 py-1.5 border-l",children:t})]}),e.jsx("div",{children:l.map((r,o)=>e.jsx(Xn,{segment:r},o))})]})}function Xn({segment:i}){const[s,n]=x.useState(!1);return i.type==="collapsed"&&!s?e.jsxs("button",{onClick:()=>n(!0),className:"w-full grid grid-cols-2 text-[10px] text-muted-foreground bg-muted/30 hover:bg-muted/50 transition-colors cursor-pointer",children:[e.jsxs("div",{className:"px-3 py-1 text-center border-b",children:["... ",i.count," unchanged lines ..."]}),e.jsxs("div",{className:"px-3 py-1 text-center border-l border-b",children:["... ",i.count," unchanged lines ..."]})]}):i.type==="collapsed"?null:e.jsx(e.Fragment,{children:i.rows.map((t,a)=>e.jsx(Zn,{row:t},a))})}function Zn({row:i}){return e.jsxs("div",{className:"grid grid-cols-2 border-b last:border-b-0",children:[e.jsx("div",{className:X("px-3 py-0.5 min-h-[1.5em]",i.type==="removed"&&"bg-red-50 dark:bg-red-950/30"),style:i.left?{paddingLeft:`calc(0.75rem + ${i.left.indent*1}rem)`}:void 0,children:e.jsx("span",{className:X(i.left?.type==="label"&&"text-muted-foreground font-semibold",i.left?.type==="heading"&&"font-bold"),children:i.left?.text??""})}),e.jsx("div",{className:X("px-3 py-0.5 min-h-[1.5em] border-l",i.type==="added"&&"bg-green-50 dark:bg-green-950/30"),style:i.right?{paddingLeft:`calc(0.75rem + ${i.right.indent*1}rem)`}:void 0,children:e.jsx("span",{className:X(i.right?.type==="label"&&"text-muted-foreground font-semibold",i.right?.type==="heading"&&"font-bold"),children:i.right?.text??""})})]})}function ea(i,s){const n=Qs(i,s,{comparator:(a,l)=>a.text===l.text&&a.indent===l.indent&&a.type===l.type}),t=[];for(const a of n)if(a.added)for(const l of a.value)t.push({type:"added",right:l});else if(a.removed)for(const l of a.value)t.push({type:"removed",left:l});else for(const l of a.value)t.push({type:"unchanged",left:l,right:l});return t}function sa(i){const s=[];let n=[];function t(){if(n.length!==0){if(n.length>Qn){const r=n.slice(0,2),o=n.slice(-2),u=n.length-4;s.push({type:"rows",rows:r}),u>0&&s.push({type:"collapsed",count:u}),s.push({type:"rows",rows:o})}else s.push({type:"rows",rows:n});n=[]}}let a=[];function l(){a.length!==0&&(s.push({type:"rows",rows:a}),a=[])}for(const r of i)r.type==="unchanged"?(l(),n.push(r)):(t(),a.push(r));return l(),t(),s}function Ee(i){switch(i.kind){case"draft":return"Draft";case"published":return"Published";case"history":return W(i.createdAt)}}function Ne(i){switch(i.kind){case"draft":return"draft";case"published":return"published";case"history":return`history:${i.blockId}`}}function Ds({value:i,onChange:s,isPublished:n,versions:t,exclude:a,size:l}){const r=a?Ne(a):null;function o(u){if(u==="draft")s({kind:"draft"});else if(u==="published")s({kind:"published"});else if(u.startsWith("history:")){const d=u.slice(8),p=t.find(b=>b.blockId===d);p&&s({kind:"history",blockId:p.blockId,createdAt:p.createdAt,title:p.title})}}return e.jsxs(ze,{value:Ne(i),onValueChange:o,children:[e.jsx(Be,{size:l,children:e.jsx(He,{children:Ee(i)})}),e.jsxs(We,{position:"popper",children:[r!=="draft"&&e.jsx(J,{value:"draft",children:"Draft"}),n&&r!=="published"&&e.jsx(J,{value:"published",children:"Published"}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(sn,{}),e.jsxs(tn,{children:[e.jsx(nn,{children:"Version History"}),t.map(u=>{const d=`history:${u.blockId}`;return d===r?null:e.jsx(J,{value:d,children:W(u.createdAt)},d)})]})]})]})]})}function Ys(i,s){if(s==null||s==="")return[{text:"(empty)",indent:0,type:"value"}];switch(i.type){case"text":case"url":case"email":case"date":case"number":case"select":return[{text:String(s),indent:0,type:"value"}];case"textarea":return String(s).split(`
|
|
3
|
+
`).map(n=>({text:n,indent:0,type:"value"}));case"boolean":return[{text:s?"Yes":"No",indent:0,type:"value"}];case"media":return[{text:`[Media: ${s}]`,indent:0,type:"value"}];case"blocks":return $e(s);case"array":return aa(i,s);default:return[{text:String(s),indent:0,type:"value"}]}}function ae(i,s,n,t){const a=[];n&&(n.title!==void 0&&(a.push({text:"Title",indent:0,type:"label"}),a.push({text:n.title||"(empty)",indent:0,type:"value"}),a.push({text:"",indent:0,type:"empty"})),n.slug!==void 0&&(a.push({text:"Slug",indent:0,type:"label"}),a.push({text:n.slug||"(empty)",indent:0,type:"value"}),a.push({text:"",indent:0,type:"empty"})),n.snippet!==void 0&&(a.push({text:"Snippet",indent:0,type:"label"}),a.push({text:n.snippet||"(empty)",indent:0,type:"value"}),a.push({text:"",indent:0,type:"empty"})),n.tags!==void 0&&(a.push({text:"Tags",indent:0,type:"label"}),a.push({text:n.tags.length>0?n.tags.join(", "):"(empty)",indent:0,type:"value"}),a.push({text:"",indent:0,type:"empty"})));for(const l of i){a.push({text:l.label,indent:0,type:"label"});const r=Ys(l,s[l.name]);a.push(...r),a.push({text:"",indent:0,type:"empty"})}if(t&&t.defs.length>0)for(const l of t.defs){a.push({text:l.label,indent:0,type:"label"});const r=t.values[l.name]??[];r.length===0?a.push({text:"(empty)",indent:0,type:"value"}):a.push({text:r.map(o=>o.title).join(", "),indent:0,type:"value"}),a.push({text:"",indent:0,type:"empty"})}return a.length>0&&a[a.length-1].type==="empty"&&a.pop(),a}const ta=[["bold","**","**"],["italic","_","_"],["underline","__","__"],["strike","~~","~~"],["code","`","`"]];function na(i,s){if(!s||!i)return i;let n=i;for(const[t,a,l]of ta)s[t]===!0&&(n=a+n+l);return n}function Y(i){return Array.isArray(i)?i.map(s=>typeof s.text=="string"?na(s.text,s.styles):s.type==="link"&&Array.isArray(s.content)?`[${Y(s.content)}](${s.href??""})`:"").join(""):""}function $e(i,s=0){if(!Array.isArray(i))return[{text:"(empty)",indent:0,type:"value"}];if(i.length===0)return[{text:"(empty)",indent:0,type:"value"}];const n=[];let t=0;for(const a of i){if(typeof a!="object"||a===null)continue;const l=a,r=l.type??"";switch(r!=="numberedListItem"&&(t=0),r){case"paragraph":{const o=Y(l.content);n.push({text:o||"",indent:s,type:"value"});break}case"heading":{const o=l.props?.level??1,u="#".repeat(Math.min(o,6))+" ",d=Y(l.content);n.push({text:u+d,indent:s,type:"heading"});break}case"bulletListItem":{const o=Y(l.content);n.push({text:`- ${o}`,indent:s,type:"list-item"});break}case"numberedListItem":{t++;const o=Y(l.content);n.push({text:`${t}. ${o}`,indent:s,type:"list-item"});break}case"image":case"HeadroomImage":{const o=l.props?.alt,u=l.props?.mediaId,d=o||u||"image";n.push({text:`[Image: ${d}]`,indent:s,type:"value"});break}default:{if(l.props&&typeof l.props=="object"){const o=l.props,u=Object.entries(o).filter(([d])=>!["textAlignment","level"].includes(d));if(u.length>0){n.push({text:`[${r}]`,indent:s,type:"label"});for(const[d,p]of u)p==null||p===""||(Array.isArray(p)?(n.push({text:`${d}:`,indent:s+1,type:"label"}),n.push(...$e(p,s+2))):n.push({text:`${d}: ${String(p)}`,indent:s+1,type:"value"}))}else n.push({text:`[${r}]`,indent:s,type:"value"})}else{const o=Y(l.content);o&&n.push({text:o,indent:s,type:"value"})}break}}Array.isArray(l.children)&&l.children.length>0&&n.push(...$e(l.children,s+1))}return n}function aa(i,s){if(!Array.isArray(s)||s.length===0)return[{text:"(empty)",indent:0,type:"value"}];const t=i.options?.itemFields??[],a=[];for(let l=0;l<s.length;l++){a.push({text:`${l+1}.`,indent:0,type:"list-item"});const r=s[l];if(t.length>0)for(const o of t){a.push({text:o.label+":",indent:1,type:"label"});const u=Ys(o,r[o.name]);a.push(...u.map(d=>({...d,indent:d.indent+1})))}else a.push({text:JSON.stringify(r,null,2),indent:1,type:"value"})}return a}function As({ref:i,host:s,contentId:n,collectionFields:t,isSingleton:a,draftBody:l,draftMetadata:r,collectionRelationships:o,draftRelationships:u}){const d=i?.kind==="published",p=i?.kind==="history",b=p?i.blockId:null,{data:h,isLoading:f}=Ls(s,n,d),{data:g,isLoading:N}=Mt(s,n,p?b:null),w=x.useMemo(()=>(o??[]).map(y=>({name:y.name,label:y.label})),[o]);function k(y){if(w.length!==0)return{defs:w,values:y??{}}}const m=x.useMemo(()=>{if(!i)return[];if(i.kind==="draft")return l?ae(t,l,a?void 0:r,k(u)):[];if(i.kind==="published"){if(!h)return[];const C=a?void 0:{title:h.title,slug:h.slug,snippet:h.snippet,tags:h.tags},S=h.relationships;return ae(t,h.body??{},C,k(S))}if(!g)return[];const y=a?void 0:{title:g.title,slug:g.slug,snippet:g.snippet,tags:g.tags},P=g.relationships;return ae(t,g.body??{},y,k(P))},[i,l,r,u,h,g,t,a,w]);return i?i.kind==="draft"?{lines:m,isLoading:!1,hasData:!!l}:i.kind==="published"?{lines:m,isLoading:f,hasData:!!h}:{lines:m,isLoading:N,hasData:!!g}:{lines:[],isLoading:!1,hasData:!1}}function ia({open:i,onOpenChange:s,host:n,contentId:t,collectionFields:a,isSingleton:l,isPublished:r,draftBody:o,draftMetadata:u,initialVersion:d,collectionRelationships:p,draftRelationships:b}){const[h,f]=x.useState(d??{kind:"published"}),[g,N]=x.useState({kind:"draft"}),[w,k]=x.useState(i),[m,y]=x.useState(d);if((i!==w||d!==m)&&(k(i),y(d),i)){const T=d??{kind:"published"};f(T),N(T.kind==="draft"?{kind:"published"}:{kind:"draft"})}Ne(h)===Ne(g)&&(h.kind!=="draft"?N({kind:"draft"}):r&&N({kind:"published"}));const{data:P}=_s(n,t),C=P?.items??[],S={host:n,contentId:t,collectionFields:a,isSingleton:l,draftBody:o,draftMetadata:u,collectionRelationships:p,draftRelationships:b},A=As({ref:h,...S}),D=As({ref:g,...S}),j=A.isLoading;return e.jsx(Ht,{open:i,onOpenChange:s,children:e.jsxs(Wt,{className:"w-[calc(100vw-2rem)] sm:max-w-2xl overflow-y-auto pt-[env(safe-area-inset-top,0px)] pr-[env(safe-area-inset-right,0px)]",children:[e.jsx(qt,{children:e.jsxs(Jt,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground text-sm font-normal",children:"Viewing"}),e.jsx(Ds,{value:h,onChange:f,isPublished:r,versions:C,size:"sm"})]})}),j&&e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(O,{className:"h-6 w-48"}),e.jsx(O,{className:"h-4 w-full"}),e.jsx(O,{className:"h-4 w-full"}),e.jsx(O,{className:"h-4 w-2/3"})]}),!j&&!A.hasData&&e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"No data available for this version."}),!j&&A.hasData&&e.jsx("div",{className:"p-4",children:e.jsxs(Fs,{defaultValue:"changes",children:[e.jsxs(Rs,{variant:"line",className:"mb-4",children:[e.jsx(xe,{value:"content",children:"Content"}),e.jsx(xe,{value:"changes",children:"Changes"})]}),e.jsx(fe,{value:"content",children:e.jsx(qn,{lines:A.lines})}),e.jsxs(fe,{value:"changes",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Compare with"}),e.jsx(Ds,{value:g,onChange:N,isPublished:r,versions:C,exclude:h,size:"sm"})]}),D.isLoading?e.jsxs("div",{className:"space-y-4",children:[e.jsx(O,{className:"h-4 w-full"}),e.jsx(O,{className:"h-4 w-full"}),e.jsx(O,{className:"h-4 w-2/3"})]}):D.hasData?e.jsx(Yn,{published:A.lines,draft:D.lines,leftLabel:Ee(h),rightLabel:Ee(g)}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No data available for comparison."})]})]})})]})})}function Xs({open:i,onSelect:s,onClose:n,allowedTypes:t}){const{host:a}=Ce(),[l,r]=x.useState(""),[o,u]=x.useState("__all__"),d=x.useRef(null),p=an(a),b=ln(a),{data:h}=rn(a),f=h?.items??[],g=o==="__all__"?void 0:o==="__unfiled__"?"":o,{data:N,fetchNextPage:w,hasNextPage:k,isFetchingNextPage:m}=on(a,{folderId:g}),[y,P]=x.useState(!1),S=(N?.pages.flatMap(j=>j.items)??[]).filter(j=>t&&!t.some(R=>R.endsWith("/*")?j.mimeType.startsWith(R.slice(0,-1)):j.mimeType===R)?!1:l?j.filename.toLowerCase().includes(l.toLowerCase())||j.alt?.toLowerCase().includes(l.toLowerCase()):!0);async function A(j){P(!0);try{const{uploadUrl:T,mediaId:R}=await p.mutateAsync({filename:j.name,contentType:j.type,size:j.size});await fetch(T,{method:"PUT",body:j,headers:{"Content-Type":j.type}});const M=await b.mutateAsync({mediaId:R,filename:j.name});s(M),n()}catch(T){L.error("Upload failed",{description:T instanceof Error?T.message:void 0})}finally{P(!1)}}function D(j){return j.startsWith("image/")}return e.jsx(ge,{open:i,onOpenChange:()=>n(),children:e.jsxs(je,{className:"max-w-3xl",children:[e.jsxs(ve,{children:[e.jsx(ye,{children:"Select Media"}),e.jsx(be,{className:"sr-only",children:"Browse and select media files"})]}),e.jsxs("div",{className:"mb-4 flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{placeholder:"Search by filename...",value:l,onChange:j=>r(j.target.value),className:"max-w-xs"}),f.length>0&&e.jsxs(ze,{value:o,onValueChange:u,children:[e.jsx(Be,{className:"w-[150px]",children:e.jsx(He,{})}),e.jsxs(We,{children:[e.jsx(J,{value:"__all__",children:"All folders"}),f.map(j=>e.jsx(J,{value:j.folderId,children:j.name},j.folderId)),e.jsx(J,{value:"__unfiled__",children:"Unfiled"})]})]})]}),e.jsxs("div",{children:[e.jsx("input",{ref:d,type:"file",className:"hidden",accept:t?.join(",")??void 0,onChange:j=>j.target.files?.[0]&&A(j.target.files[0])}),e.jsxs(v,{variant:"outline",onClick:()=>d.current?.click(),disabled:y,children:[y?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(cn,{className:"mr-2 h-4 w-4"}),"Upload New"]})]})]}),e.jsx("div",{className:"grid max-h-96 grid-cols-4 gap-3 overflow-y-auto",children:S.map(j=>e.jsxs(B,{className:"cursor-pointer overflow-hidden hover:ring-2 hover:ring-primary",onClick:()=>{s(j),n()},children:[e.jsx("div",{className:"flex aspect-square items-center justify-center bg-muted",children:D(j.mimeType)?e.jsx("img",{src:Ve(j.urls?.thumb_md??j.url),alt:j.alt??j.filename,className:"h-full w-full object-cover"}):e.jsxs("div",{className:"flex flex-col items-center gap-1 p-2",children:[j.mimeType.startsWith("image/")?e.jsx(Ue,{className:"h-8 w-8 text-muted-foreground"}):e.jsx(dn,{className:"h-8 w-8 text-muted-foreground"}),e.jsx("span",{className:"max-w-full truncate text-xs text-muted-foreground",children:j.filename})]})}),e.jsx("div",{className:"p-1.5",children:e.jsx("p",{className:"truncate text-xs",children:j.filename})})]},j.mediaId))}),S.length===0&&e.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No media found."}),k&&e.jsxs(v,{variant:"ghost",className:"mt-2 w-full",onClick:()=>w(),disabled:m,children:[m?e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Load More"]})]})})}function la(i,s,n){const t=Es(),a=n?.length===1?n[0]:void 0,l=new URLSearchParams;return s?(l.set("q",s),l.set("search","full")):l.set("limit","5"),a&&l.set("collection",a),At({queryKey:["sites",i,"content-search",s,n??[]],queryFn:async()=>{const r=await t.apiFetch(`/v1/admin/sites/${i}/content?${l.toString()}`);return n&&n.length>1?{...r,items:r.items.filter(o=>n.includes(o.collection))}:r},enabled:!!i,staleTime:3e4})}function ra({field:i,value:s,onChange:n}){const{host:t}=Ce(),a=i.options,l=!!a?.multiple,r=a?.collections;return l?e.jsx(ca,{host:t,collections:r,value:s??[],onChange:n}):e.jsx(oa,{host:t,collections:r,value:s,onChange:n})}function oa({host:i,collections:s,value:n,onChange:t}){const[a,l]=x.useState(!1),r=n?[n.contentId]:[];function o(u){t(u),l(!1)}return e.jsx("div",{children:n?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[e.jsx(Z,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:n.title}),e.jsx(le,{variant:"secondary",children:n.collection}),e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>t(null),children:e.jsx(ee,{className:"h-3 w-3"})})]}):e.jsx(Se,{host:i,collections:s,selectedIds:r,open:a,onOpenChange:l,onSelect:o,trigger:e.jsxs(v,{type:"button",variant:"outline",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Select Content"]})})})}function ca({host:i,collections:s,value:n,onChange:t}){const a=Ge(Qe(Ye)),[l,r]=x.useState(!1),o=n??[],u=o.map(f=>f.contentId),d=o.map(f=>f.contentId);function p(f){t([...o,f]),r(!1)}function b(f){t(o.filter((g,N)=>N!==f))}function h(f){const{active:g,over:N}=f;if(N&&g.id!==N.id){const w=o.findIndex(m=>m.contentId===String(g.id)),k=o.findIndex(m=>m.contentId===String(N.id));w!==-1&&k!==-1&&t(Ke(o,w,k))}}return e.jsx(Xe,{sensors:a,collisionDetection:Ze,onDragEnd:h,children:e.jsx(qe,{items:u,strategy:Je,children:e.jsxs("div",{className:"space-y-2",children:[o.map(f=>e.jsx(Zs,{id:f.contentId,contentRef:f,onRemove:()=>b(o.indexOf(f))},f.contentId)),e.jsx(Se,{host:i,collections:s,selectedIds:d,open:l,onOpenChange:r,onSelect:p,trigger:e.jsxs(v,{type:"button",variant:"outline",size:"sm",children:[e.jsx(es,{className:"mr-2 h-3 w-3"}),"Add Content"]})})]})})})}function Zs({id:i,contentRef:s,onRemove:n}){const{attributes:t,listeners:a,setNodeRef:l,transform:r,transition:o}=Us({id:i}),u={transform:qs.Transform.toString(r),transition:o};return e.jsxs("div",{ref:l,style:u,className:"flex items-center gap-2 rounded-md border p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...t,...a,children:e.jsx(Js,{className:"h-4 w-4"})}),e.jsx(Z,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:s.title}),e.jsx(le,{variant:"secondary",children:s.collection}),e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:n,className:"text-destructive",children:e.jsx(ee,{className:"h-3 w-3"})})]})}function Se({host:i,collections:s,selectedIds:n,open:t,onOpenChange:a,onSelect:l,trigger:r}){const[o,u]=x.useState(""),d=Tn(o,300),{data:p,isLoading:b}=la(i,d,s);return e.jsxs(Nn,{open:t,onOpenChange:a,children:[e.jsx(Cn,{asChild:!0,children:r}),e.jsx(wn,{className:"w-80 p-0",align:"start",children:e.jsxs(Sn,{shouldFilter:!1,children:[e.jsx(kn,{placeholder:"Search content...",value:o,onValueChange:u}),e.jsx(Pn,{children:b?e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}):e.jsxs(e.Fragment,{children:[e.jsx(In,{children:"No content found."}),e.jsx(Dn,{heading:d.length===0?"Recent":void 0,children:p?.items.map(h=>{const f=n.includes(h.contentId);return e.jsxs(An,{value:h.contentId,disabled:f,onSelect:()=>l({contentId:h.contentId,collection:h.collection,slug:h.slug??"",title:h.title}),children:[e.jsx(Z,{className:"h-4 w-4"}),e.jsx("span",{className:"flex-1 truncate",children:h.title}),e.jsx(le,{variant:"outline",className:"text-xs",children:h.collection})]},h.contentId)})})]})})]})})]})}function da({relationships:i,values:s,onChange:n,host:t}){return e.jsxs(B,{children:[e.jsx(Fe,{children:e.jsx(Re,{children:"Relationships"})}),e.jsx(q,{className:"space-y-4",children:i.map(a=>a.multiple?e.jsx(ha,{rel:a,items:s[a.name]??[],host:t,onChange:l=>n({...s,[a.name]:l})},a.name):e.jsx(ua,{rel:a,value:s[a.name]?.[0]??null,host:t,onChange:l=>n({...s,[a.name]:l?[l]:[]})},a.name))})]})}function ua({rel:i,value:s,host:n,onChange:t}){const[a,l]=x.useState(!1),r=s?[s.contentId]:[];return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:i.label}),s?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[e.jsx(Z,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:s.title}),e.jsx(le,{variant:"secondary",children:s.collection}),e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>t(null),children:e.jsx(ee,{className:"h-3 w-3"})})]}):e.jsx(Se,{host:n,collections:[i.targetCollection],selectedIds:r,open:a,onOpenChange:l,onSelect:o=>{t(o),l(!1)},trigger:e.jsxs(v,{type:"button",variant:"outline",size:"sm",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Select ",i.label]})})]})}function ha({rel:i,items:s,host:n,onChange:t}){const a=Ge(Qe(Ye)),[l,r]=x.useState(!1),o=s.map(h=>h.contentId),u=s.map(h=>h.contentId);function d(h){t([...s,h]),r(!1)}function p(h){t(s.filter((f,g)=>g!==h))}function b(h){const{active:f,over:g}=h;if(g&&f.id!==g.id){const N=s.findIndex(k=>k.contentId===String(f.id)),w=s.findIndex(k=>k.contentId===String(g.id));N!==-1&&w!==-1&&t(Ke(s,N,w))}}return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:i.label}),e.jsx(Xe,{sensors:a,collisionDetection:Ze,onDragEnd:b,children:e.jsx(qe,{items:o,strategy:Je,children:e.jsxs("div",{className:"space-y-2",children:[s.map(h=>e.jsx(Zs,{id:h.contentId,contentRef:h,onRemove:()=>p(s.indexOf(h))},h.contentId)),e.jsx(Se,{host:n,collections:[i.targetCollection],selectedIds:u,open:l,onOpenChange:r,onSelect:d,trigger:e.jsxs(v,{type:"button",variant:"outline",size:"sm",children:[e.jsx(es,{className:"mr-2 h-3 w-3"}),"Add ",i.label]})})]})})})]})}function Me({field:i,value:s,onChange:n}){const t=i.options;return e.jsx(ie,{value:s??"",onChange:a=>n(a.target.value),placeholder:t?.placeholder,maxLength:t?.maxLength,required:!!t?.required,type:i.type==="url"?"url":i.type==="email"?"email":"text"})}function ma({field:i,value:s,onChange:n}){const t=i.options;return e.jsx(Vs,{value:s??"",onChange:a=>n(a.target.value),placeholder:t?.placeholder,maxLength:t?.maxLength,required:!!t?.required,rows:4})}function pa({field:i,value:s,onChange:n}){const t=i.options;return e.jsx(ie,{type:"number",value:s??"",onChange:a=>n(a.target.value===""?void 0:Number(a.target.value)),min:t?.min,max:t?.max,step:t?.step,required:!!t?.required})}function xa({field:i,value:s,onChange:n}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ln,{id:`field-${i.name}`,checked:!!s,onCheckedChange:t=>n(!!t)}),e.jsx("label",{htmlFor:`field-${i.name}`,className:"text-sm text-muted-foreground",children:i.label})]})}function fa({field:i,value:s,onChange:n}){const a=i.options?.choices??[];return e.jsxs(ze,{value:s??"",onValueChange:l=>n(l),children:[e.jsx(Be,{children:e.jsx(He,{placeholder:"Select..."})}),e.jsx(We,{children:a.map(l=>e.jsx(J,{value:l,children:l},l))})]})}function ga({field:i,value:s,onChange:n}){const{host:t}=Ce(),[a,l]=x.useState(!1),o=i.options?.allowedTypes,u=typeof s=="string"?s:s?.mediaId??"",{data:d}=Ws(t,u);return e.jsxs("div",{children:[u?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>l(!0),children:[d?.url&&e.jsx("img",{src:Ve(d.urls?.thumb_sm??d.url),alt:d?.filename??"",className:"h-10 w-10 rounded object-cover bg-muted"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:d?.filename??"Loading..."}),e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:p=>{p.stopPropagation(),n("")},children:e.jsx(ee,{className:"h-3 w-3"})})]}):e.jsxs(v,{type:"button",variant:"outline",onClick:()=>l(!0),children:[e.jsx(Ue,{className:"mr-2 h-4 w-4"}),"Select Media"]}),e.jsx(Xs,{open:a,onClose:()=>l(!1),onSelect:p=>{n({mediaId:p.mediaId,url:p.url,width:p.width??0,height:p.height??0,filename:p.filename}),l(!1)},allowedTypes:o})]})}function ja({field:i,value:s,onChange:n}){const t=Ge(Qe(Ye)),a=s??[],r=i.options?.itemFields??[],o=a.map((h,f)=>`item-${f}`);function u(){n([...a,{}])}function d(h){n(a.filter((f,g)=>g!==h))}function p(h,f){const g=[...a];g[h]=f,n(g)}function b(h){const{active:f,over:g}=h;if(g&&f.id!==g.id){const N=o.indexOf(String(f.id)),w=o.indexOf(String(g.id));n(Ke(a,N,w))}}return e.jsx(Xe,{sensors:t,collisionDetection:Ze,onDragEnd:b,children:e.jsx(qe,{items:o,strategy:Je,children:e.jsxs("div",{className:"space-y-3",children:[a.map((h,f)=>e.jsx(va,{id:`item-${f}`,itemFields:r,item:h,onUpdate:g=>p(f,g),onRemove:()=>d(f)},`item-${f}`)),e.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:u,children:[e.jsx(es,{className:"mr-2 h-3 w-3"})," Add Item"]})]})})})}function va({id:i,itemFields:s,item:n,onUpdate:t,onRemove:a}){const{attributes:l,listeners:r,setNodeRef:o,transform:u,transition:d}=Us({id:i}),p={transform:qs.Transform.toString(u),transition:d};return e.jsx(B,{ref:o,style:p,children:e.jsxs(q,{className:"flex gap-2 p-3",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...l,...r,children:e.jsx(Js,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1",children:e.jsx(et,{fields:s,values:n,onChange:t})}),e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:a,className:"text-destructive",children:e.jsx(Gs,{className:"h-3 w-3"})})]})})}const ya=x.lazy(()=>Gt(()=>import("./BlockEditor-C0KaZUHQ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]))),ba=2,Ts=x.createContext(0);function Na({value:i,onChange:s,compact:n=!0}){const t=x.useContext(Ts),l=Kt()?.blockTypes??[],r=$s();return t>=ba?e.jsx("div",{className:"rounded-md border border-muted p-4 text-sm text-muted-foreground",children:"Maximum nesting depth reached. Cannot embed another block editor here."}):e.jsx(Ts.Provider,{value:t+1,children:e.jsx("div",{className:r?"":"rounded-md border",children:e.jsx(x.Suspense,{fallback:e.jsx(O,{className:"h-48"}),children:e.jsx(ya,{initialBlocks:i??[],onChange:s,blockTypes:l,compact:n})})})})}function et({fields:i,values:s,onChange:n}){function t(a,l){n({...s,[a]:l})}return e.jsx("div",{className:"space-y-4",children:i.map(a=>e.jsxs("div",{className:"space-y-2",children:[a.type!=="boolean"&&e.jsx(ne,{children:a.label}),Ca(a,s[a.name],l=>t(a.name,l))]},a.name))})}function Ca(i,s,n){switch(i.type){case"text":case"url":case"email":return e.jsx(Me,{field:i,value:s,onChange:n});case"textarea":return e.jsx(ma,{field:i,value:s,onChange:n});case"number":return e.jsx(pa,{field:i,value:s,onChange:n});case"boolean":return e.jsx(xa,{field:i,value:s,onChange:n});case"select":return e.jsx(fa,{field:i,value:s,onChange:n});case"media":return e.jsx(ga,{field:i,value:s,onChange:n});case"content":return e.jsx(ra,{field:i,value:s,onChange:n});case"blocks":return e.jsx(Na,{field:i,value:s,onChange:n});case"array":return e.jsx(ja,{field:i,value:s,onChange:n});case"date":return e.jsx(Me,{field:{...i,type:"text"},value:s,onChange:n});default:return e.jsx(Me,{field:i,value:s,onChange:n})}}function wa(){const{host:i,collection:s,id:n}=Ce(),{data:t,isLoading:a}=Ot(i,n);return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(O,{className:"h-8 w-64"}),e.jsx(O,{className:"h-64 w-full"})]}):t?.content?e.jsx(Sa,{host:i,collection:s,contentId:n,content:t.content,draft:t.draft,publishedBlockId:t.publishedBlockId}):e.jsx("p",{className:"text-muted-foreground",children:"Content not found."})}function Sa({host:i,collection:s,contentId:n,content:t,draft:a,publishedBlockId:l}){const r=Tt(),o=Es(),{collections:u}=Qt(),d=Ft(i,n),p=Rt(i,n),b=Et(i,n),h=$t(i,n),f=Ut(i,n),g=Vt(i,n),N=a?{title:a.title??t.title,slug:a.slug??t.slug??"",snippet:a.snippet??t.snippet??"",tags:a.tags??t.tags??[],coverUrl:a.coverUrl??t.coverUrl??"",coverMediaId:a.coverMediaId??t.coverMediaId??"",coverWidth:a.coverWidth??t.coverWidth??0,coverHeight:a.coverHeight??t.coverHeight??0,body:a.body??{},relationships:a.relationships??{}}:void 0,[w,k]=x.useState(null),m=Wn(i,n,N,()=>{k("This slug is already in use by another item in this collection")}),{data:y}=bn(i),P=y?.map(c=>c.tag),C=u.find(c=>c.name===s),S=x.useMemo(()=>C?.fields??[],[C?.fields]),A=x.useMemo(()=>C?.relationships??[],[C?.relationships]),D=C?.singleton??!1,j=$s(),[T,R]=x.useState(a?.title??t.title),[M,ss]=x.useState(a?.slug??t.slug??""),[E,ts]=x.useState(a?.snippet??t.snippet??""),ns=a?.autoSnippet??"",[K,as]=x.useState(a?.tags??t.tags??[]),[ke,is]=x.useState(a?.coverUrl??t.coverUrl??""),[re,ls]=x.useState(a?.coverMediaId??t.coverMediaId??""),[rs,os]=x.useState(a?.coverWidth??t.coverWidth??0),[cs,ds]=x.useState(a?.coverHeight??t.coverHeight??0),[G,us]=x.useState(a?.body??{}),[Q,hs]=x.useState(a?.relationships??{}),[st,tt]=x.useState(0),[nt,at]=x.useState(!1),[it,oe]=x.useState(!1),[lt,se]=x.useState(!1),[rt,ce]=x.useState(null),[Pe,de]=x.useState(!1),[ot,ue]=x.useState(!1),[ct,he]=x.useState(!1),[me,ms]=x.useState(""),[dt,Ie]=x.useState(!1),[De,ps]=x.useState(""),xs=zt(i,n),{data:fs}=Ws(i,re),H=x.useCallback(()=>({title:T,slug:M,snippet:E,tags:K,coverUrl:ke,coverMediaId:re,coverWidth:rs,coverHeight:cs,body:G,relationships:Q}),[T,M,E,K,ke,re,rs,cs,G,Q]);function ut(c){R(c),setTimeout(()=>m.schedule({...H(),title:c}),0)}function ht(c){ss(c),k(null),setTimeout(()=>m.schedule({...H(),slug:c}),0)}function mt(c){ts(c),setTimeout(()=>m.schedule({...H(),snippet:c}),0)}function pt(c){as(c),setTimeout(()=>m.schedule({...H(),tags:c}),0)}function gs(c,I,V,te){is(c),ls(I),os(V),ds(te),setTimeout(()=>m.schedule({...H(),coverUrl:c,coverMediaId:I,coverWidth:V,coverHeight:te}),0)}function xt(c){us(c),setTimeout(()=>m.schedule({...H(),body:c}),0)}function ft(c){hs(c),setTimeout(()=>m.schedule({...H(),relationships:c}),0)}const gt=m.lastSavedBlockId??a?.blockId,$=_n(t.publishedAt,t.lastPublishedAt,l,gt,t.scheduledAt,t.scheduledFailed),js=Mn($),vs=On($),{data:U}=Ls(i,n,!!t.publishedAt),F=x.useMemo(()=>{if(!Pe||!U)return null;const c=D?void 0:{title:U.title,slug:U.slug,snippet:U.snippet,tags:U.tags},I=A.map(_=>({name:_.name,label:_.label})),V=U.relationships,te=I.length>0?{defs:I,values:V??{}}:void 0,St=ae(S,U.body??{},c,te),kt=D?void 0:{title:T,slug:M,snippet:E,tags:K},Pt=I.length>0?{defs:I,values:Q}:void 0,It=ae(S,G,kt,Pt),Dt=Qs(St,It,{comparator:(_,Te)=>_.text===Te.text&&_.indent===Te.indent&&_.type===Te.type});let Ns=0,Cs=0;for(const _ of Dt)_.added?Ns+=_.count??0:_.removed&&(Cs+=_.count??0);return{added:Ns,removed:Cs}},[Pe,U,S,A,D,T,M,E,K,G,Q]);function jt(){if(t.publishedAt&&t.slug&&M!==t.slug){ue(!0);return}$==="published-changes"?de(!0):pe()}async function pe(){try{m.cancel(),await m.flush({createVersion:!0}),await d.mutateAsync(void 0),L.success("Content published")}catch(c){if(c instanceof Os&&c.code==="SLUG_TAKEN"){k("This slug is already in use by another item in this collection"),L.error("Slug already in use",{description:"Please choose a different slug before publishing."});return}L.error("Failed to publish",{description:c instanceof Error?c.message:void 0})}}async function vt(){try{await p.mutateAsync(),se(!1),L.success("Content unpublished")}catch(c){L.error("Failed to unpublish",{description:c instanceof Error?c.message:void 0})}}async function yt(){try{m.discard();const c=await o.apiFetch(`/v1/admin/sites/${i}/content/${n}/published`);await xs.mutateAsync();const I={title:c.title??"",slug:c.slug??"",snippet:c.snippet??"",tags:c.tags??[],coverUrl:c.coverUrl??"",coverMediaId:c.coverMediaId??"",coverWidth:c.coverWidth??0,coverHeight:c.coverHeight??0,body:c.body??{},relationships:c.relationships??{}};R(I.title),ss(I.slug),ts(I.snippet),as(I.tags),is(I.coverUrl),ls(I.coverMediaId),os(I.coverWidth),ds(I.coverHeight),us(I.body),hs(I.relationships),tt(V=>V+1),m.resetBaseline(I),L.success("Changes discarded")}catch(c){L.error("Failed to discard changes",{description:c instanceof Error?c.message:void 0})}}async function bt(){try{await b.mutateAsync(),L.success("Content deleted"),r(`/sites/${i}/content/${s}`)}catch(c){L.error("Failed to delete",{description:c instanceof Error?c.message:void 0})}}async function Nt(){if(me)try{m.cancel(),await m.flush({createVersion:!0});const c=new Date(me).getTime();await f.mutateAsync(c),he(!1),ms(""),L.success("Content scheduled for publishing")}catch(c){L.error("Failed to schedule",{description:c instanceof Error?c.message:void 0})}}async function Ct(){try{await g.mutateAsync(),L.success("Schedule cancelled")}catch(c){L.error("Failed to cancel schedule",{description:c instanceof Error?c.message:void 0})}}async function wt(){if(De)try{const c=new Date(De).getTime();await h.mutateAsync(c),Ie(!1),L.success("Publish date updated")}catch(c){L.error("Failed to update publish date",{description:c instanceof Error?c.message:void 0})}}function Ae(c){const I=new Date(c),V=I.getTimezoneOffset();return new Date(I.getTime()-V*6e4).toISOString().slice(0,16)}const ys=e.jsx("div",{className:"space-y-6",children:S.length>0?e.jsx(et,{fields:S,values:G,onChange:xt},st):e.jsx(B,{children:e.jsx(q,{className:"py-8 text-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No fields defined for this collection."," ",e.jsx(Lt,{to:`/sites/${i}/settings/collections/${s}`,className:"underline",children:"Configure fields"})]})})})}),bs=e.jsxs("div",{className:"space-y-6",children:[!D&&e.jsx(B,{children:e.jsxs(q,{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"title",children:"Title"}),e.jsx(ie,{id:"title",value:T,onChange:c=>ut(c.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"slug",children:"Slug"}),e.jsx(ie,{id:"slug",value:M,onChange:c=>ht(c.target.value),className:w?"border-destructive":""}),w&&e.jsx("p",{className:"text-sm text-destructive",children:w})]}),e.jsxs(zs,{defaultOpen:!!E,children:[e.jsxs(Bs,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(Ks,{className:"h-4 w-4 transition-transform [[data-state=open]>&]:rotate-90"}),"Snippet",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(auto-generated if empty)"})]}),e.jsxs(Hs,{className:"mt-2 space-y-2",children:[e.jsx(Vs,{id:"snippet",value:E,onChange:c=>mt(c.target.value),rows:3,placeholder:"Brief summary of this content..."}),!E&&ns&&e.jsxs("p",{className:"text-xs italic text-muted-foreground",children:["Auto-generated: ",ns]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{children:"Cover Image"}),re?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>oe(!0),children:[e.jsx("img",{src:Ve(ke),alt:fs?.filename??"",className:"h-10 w-10 rounded object-cover bg-muted"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:fs?.filename??"Loading..."}),e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),gs("","",0,0)},children:e.jsx(ee,{className:"h-3 w-3"})})]}):e.jsxs(v,{type:"button",variant:"outline",className:"w-full",onClick:()=>oe(!0),children:[e.jsx(Ue,{className:"mr-2 h-4 w-4"}),"Select Image"]}),e.jsx(Xs,{open:it,onClose:()=>oe(!1),onSelect:c=>{gs(c.url,c.mediaId,c.width??0,c.height??0),oe(!1)},allowedTypes:["image/*"]})]})]})}),!D&&e.jsxs(B,{children:[e.jsx(Fe,{children:e.jsx(Re,{children:"Tags"})}),e.jsx(q,{children:e.jsx(un,{tags:K,onChange:pt,suggestions:P})})]}),A.length>0&&e.jsx(da,{relationships:A,values:Q,onChange:ft,host:i}),e.jsxs(B,{children:[e.jsx(Fe,{children:e.jsx(Re,{children:"Info"})}),e.jsxs(q,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Collection"}),e.jsx("span",{children:t.collection})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"ID"}),e.jsx("span",{className:"font-mono text-xs",children:t.contentId})]}),t.publishedAt?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"Published"}),dt?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"datetime-local",value:De,onChange:c=>ps(c.target.value),className:"text-xs border rounded px-1 py-0.5",max:Ae(Date.now())}),e.jsx(v,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:wt,disabled:h.isPending,children:e.jsx(Ps,{className:"h-3 w-3"})}),e.jsx(v,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>Ie(!1),children:e.jsx(ee,{className:"h-3 w-3"})})]}):e.jsxs("span",{className:"cursor-pointer hover:underline",title:W(t.publishedAt),onClick:()=>{ps(Ae(t.publishedAt)),Ie(!0)},children:[_e(t.publishedAt),e.jsx(Un,{className:"inline ml-1 h-3 w-3 text-muted-foreground"})]})]}),t.lastPublishedAt&&t.lastPublishedAt!==t.publishedAt&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last published"}),e.jsx("span",{title:W(t.lastPublishedAt),children:_e(t.lastPublishedAt)})]})]}):t.lastPublishedAt?e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last published"}),e.jsx("span",{title:W(t.lastPublishedAt),children:_e(t.lastPublishedAt)})]}):null,$==="scheduled"&&t.scheduledAt&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"Scheduled for"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Is,{className:"h-3 w-3"}),W(t.scheduledAt)]})]}),$==="schedule-failed"&&e.jsx("div",{className:"text-destructive text-xs",children:"Scheduled publishing failed after multiple attempts."}),t.publishedAt&&e.jsxs(v,{variant:"outline",size:"sm",className:"w-full mt-2",onClick:()=>{ce({kind:"published"}),se(!0)},children:[e.jsx(En,{className:"mr-2 h-4 w-4"}),"View published"]})]})]}),e.jsx(Ia,{host:i,contentId:n,onViewVersion:c=>{ce({kind:"history",blockId:c.blockId,createdAt:c.createdAt,title:c.title}),se(!0)}}),!D&&e.jsx(Pa,{deleteOpen:nt,setDeleteOpen:at,onDelete:bt,host:i,contentId:n})]});return e.jsxs("div",{className:"mx-auto max-w-6xl",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 md:mb-6 md:flex-nowrap md:gap-3 md:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 md:gap-3",children:[e.jsx("h1",{className:"truncate text-xl font-semibold md:text-2xl",children:D?C?.label??s:T||"Untitled"}),e.jsx(le,{variant:js.variant,children:js.label}),m.isSaving&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(z,{className:"h-3 w-3 animate-spin"}),"Saving..."]}),!m.isSaving&&m.lastSavedAt&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ps,{className:"h-3 w-3"}),"Saved"]})]}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(v,{variant:"outline",onClick:()=>m.flush({createVersion:!0}),disabled:m.isSaving,children:[m.isSaving&&e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Draft"]}),$==="scheduled"&&e.jsxs(e.Fragment,{children:[e.jsxs(v,{variant:"outline",onClick:Ct,disabled:g.isPending,children:[g.isPending&&e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Cancel Schedule"]}),e.jsxs(v,{onClick:()=>void pe(),disabled:d.isPending,children:[d.isPending&&e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Publish Now"]})]}),$!=="scheduled"&&vs&&e.jsxs("div",{className:"flex",children:[e.jsxs(v,{onClick:jt,disabled:d.isPending,className:"rounded-r-none",children:[d.isPending&&e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),vs]}),!t.publishedAt&&e.jsxs(ws,{children:[e.jsx(Ss,{asChild:!0,children:e.jsx(v,{className:"rounded-l-none border-l px-2",disabled:d.isPending,children:e.jsx(Yt,{className:"h-4 w-4"})})}),e.jsx(ks,{align:"end",children:e.jsxs(Le,{onClick:()=>he(!0),children:[e.jsx(Is,{className:"mr-2 h-4 w-4"}),"Schedule for later"]})})]})]}),t.publishedAt&&e.jsxs(ws,{children:[e.jsx(Ss,{asChild:!0,children:e.jsx(v,{variant:"outline",size:"icon",children:e.jsx(hn,{className:"h-4 w-4"})})}),e.jsxs(ks,{align:"end",children:[$==="published-changes"&&e.jsxs(Le,{onClick:yt,disabled:xs.isPending,children:[e.jsx(zn,{className:"mr-2 h-4 w-4"}),"Discard Changes"]}),e.jsx(Le,{onClick:vt,className:"text-destructive focus:text-destructive",children:"Unpublish"})]})]})]})]}),j?e.jsxs(Fs,{defaultValue:"content",children:[e.jsxs(Rs,{variant:"line",className:"mb-2",children:[e.jsx(xe,{value:"content",children:"Content"}),e.jsx(xe,{value:"info",children:"Info"})]}),e.jsx(fe,{value:"content",className:"mt-0",children:ys}),e.jsx(fe,{value:"info",className:"mt-0",children:bs})]}):e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx("div",{className:"lg:col-span-2",children:ys}),e.jsx("div",{children:bs})]}),e.jsx(ia,{open:lt,onOpenChange:c=>{se(c),c||ce(null)},host:i,contentId:n,collectionFields:S,isSingleton:D,isPublished:!!t.publishedAt,draftBody:G,draftMetadata:D?void 0:{title:T,slug:M,snippet:E,tags:K},initialVersion:rt,collectionRelationships:A,draftRelationships:Q}),e.jsx(mn,{open:Pe,onOpenChange:de,children:e.jsxs(pn,{children:[e.jsxs(xn,{children:[e.jsx(fn,{children:"Publish changes?"}),e.jsx(gn,{children:F?e.jsxs(e.Fragment,{children:[F.added>0&&e.jsxs("span",{className:"text-green-600",children:["+",F.added," added"]}),F.added>0&&F.removed>0&&", ",F.removed>0&&e.jsxs("span",{className:"text-red-600",children:["-",F.removed," removed"]}),F.added===0&&F.removed===0&&e.jsx("span",{children:"No visible changes detected."})]}):"This will update the published version with your current changes."})]}),e.jsx("div",{className:"mb-2",children:e.jsx(v,{variant:"link",className:"p-0 h-auto text-sm",onClick:()=>{de(!1),ce({kind:"published"}),se(!0)},children:"View full diff"})}),e.jsxs(jn,{children:[e.jsx(vn,{children:"Cancel"}),e.jsx(yn,{onClick:()=>{de(!1),pe()},children:"Publish Update"})]})]})}),e.jsx(ge,{open:ot,onOpenChange:ue,children:e.jsxs(je,{children:[e.jsxs(ve,{children:[e.jsx(ye,{children:"Slug change detected"}),e.jsxs(be,{children:["You are changing the slug from “",t.slug,"” to “",M,"”. This may break external bookmarks and SEO links."]})]}),e.jsx(ka,{host:i,contentId:n}),e.jsxs(Oe,{children:[e.jsx(v,{variant:"outline",onClick:()=>ue(!1),children:"Cancel"}),e.jsx(v,{onClick:()=>{ue(!1),pe()},children:"Publish Anyway"})]})]})}),e.jsx(ge,{open:ct,onOpenChange:he,children:e.jsxs(je,{children:[e.jsxs(ve,{children:[e.jsx(ye,{children:"Schedule publishing"}),e.jsx(be,{children:"Choose a date and time to automatically publish this content. Times are rounded to the nearest 15-minute interval."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"schedule-date",children:"Publish at"}),e.jsx("input",{id:"schedule-date",type:"datetime-local",value:me,onChange:c=>ms(c.target.value),min:Ae(Date.now()+1200*1e3),className:"w-full rounded-md border px-3 py-2 text-sm",step:"900"})]}),e.jsxs(Oe,{children:[e.jsx(v,{variant:"outline",onClick:()=>he(!1),children:"Cancel"}),e.jsxs(v,{onClick:Nt,disabled:!me||f.isPending,children:[f.isPending&&e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Schedule"]})]})]})})]})}function ka({host:i,contentId:s}){const{data:n}=Ms(i,s,!0);return!n||n.count===0?null:e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-50 p-3 text-sm dark:bg-yellow-950/30",children:[e.jsxs("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:["This content is referenced by ",n.count," other"," ",n.count===1?"item":"items",":"]}),e.jsxs("ul",{className:"mt-1 list-disc pl-5 text-yellow-700 dark:text-yellow-300",children:[n.items.slice(0,5).map(t=>e.jsxs("li",{children:[t.title," (",t.collection,")"]},`${t.contentId}-${t.fieldName}`)),n.items.length>5&&e.jsxs("li",{children:["and ",n.items.length-5," more..."]})]})]})}function Pa({deleteOpen:i,setDeleteOpen:s,onDelete:n,host:t,contentId:a}){const{data:l}=Ms(t,a,i);return e.jsxs(e.Fragment,{children:[e.jsx(Xt,{}),e.jsxs(ge,{open:i,onOpenChange:s,children:[e.jsx(Zt,{asChild:!0,children:e.jsxs(v,{variant:"destructive",className:"w-full",children:[e.jsx(Gs,{className:"mr-2 h-4 w-4"}),"Delete"]})}),e.jsxs(je,{children:[e.jsxs(ve,{children:[e.jsx(ye,{children:"Delete content?"}),e.jsx(be,{children:"This action cannot be undone. The content will be permanently deleted."})]}),l&&l.count>0&&e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-50 p-3 text-sm dark:bg-yellow-950/30",children:[e.jsxs("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:["This content is referenced by ",l.count," other"," ",l.count===1?"item":"items",":"]}),e.jsxs("ul",{className:"mt-1 list-disc pl-5 text-yellow-700 dark:text-yellow-300",children:[l.items.slice(0,5).map(r=>e.jsxs("li",{children:[r.title," (",r.collection,")"]},`${r.contentId}-${r.fieldName}`)),l.items.length>5&&e.jsxs("li",{children:["and ",l.items.length-5," more..."]})]})]}),e.jsxs(Oe,{children:[e.jsx(v,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(v,{variant:"destructive",onClick:n,children:"Delete"})]})]})]})]})}function Ia({host:i,contentId:s,onViewVersion:n}){const{data:t}=_s(i,s),[a,l]=x.useState(!1),r=t?.items??[],o=r.map(d=>d.createdBy).filter(Boolean),{resolve:u}=en(o);return r.length===0?null:e.jsx(B,{children:e.jsx(q,{className:"pt-4",children:e.jsxs(zs,{open:a,onOpenChange:l,children:[e.jsxs(Bs,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(Ks,{className:X("h-4 w-4 transition",a&&"rotate-90")}),"Version History (",r.length,")"]}),e.jsx(Hs,{className:"mt-2",children:e.jsx("div",{className:"space-y-1",children:r.map((d,p)=>e.jsxs("button",{className:"py-1 text-sm hover:bg-muted rounded px-1 -mx-1 transition-colors w-full text-left",onClick:()=>n(d),children:[e.jsx("span",{children:W(d.createdAt)}),d.createdBy&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:u(d.createdBy)}),d.title&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:d.title})]},`${d.createdAt}-${p}`))})})]})})})}const Ya=Object.freeze(Object.defineProperty({__proto__:null,ContentEditPage:wa},Symbol.toStringTag,{value:"Module"}));export{Se as C,et as F,Xs as M,Un as P,Ya as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{u as fe,e as ve,r as o}from"./react-vendor-DNVhVxD7.js";import{o as be,v as Ne,B,t as m,I as le,X as I,L as U,S as Se,a as Ce,w as we}from"./index-CwkwXbO-.js";import{d as ke,e as ye,a as _e,b as Ae,c as Ie}from"./useContent-Cp41wBYR.js";import{u as Pe}from"./useTags-BB47vbXO.js";import{u as Te}from"./useDebouncedValue-Bf8UizjU.js";import{u as $e,m as te}from"./use-mobile-Cvl5tIVY.js";import{B as N}from"./badge-ChZ2DZue.js";import{C as Me,c as Be}from"./card-DpNr7WTb.js";import{C as F}from"./checkbox-VtCfoGic.js";import{P as Ue,a as De,b as Ve}from"./popover-DFInMOpa.js";import{S as j,a as p,b as g,c as f,d as r}from"./select-Cj54Wt-H.js";import{T as Le,a as qe,b as ne,c as P,d as ze,e as T}from"./table-D4rLgOKa.js";import{a as D,f as ce}from"./format-C88SDH8g.js";import{g as re,a as ie}from"./contentStatus-BmaiYVOm.js";import{B as Oe}from"./BulkActionBar-BX-t8fyM.js";import{P as Fe}from"./plus-2Ds_MoqB.js";import{S as de}from"./search-DRNC6QB5.js";import"./radix-n1vDIPi6.js";import"./check-BMpruHpO.js";const He=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Re=be("sliders-horizontal",He),V=3,oe=[{value:"updated_desc",label:"Last updated"},{value:"updated_asc",label:"Oldest updated"},{value:"title_asc",label:"Title A–Z",requiresCollection:!0},{value:"title_desc",label:"Title Z–A",requiresCollection:!0},{value:"created_desc",label:"Newest created"},{value:"created_asc",label:"Oldest created"}],H=[{value:"all",label:"All statuses"},{value:"draft",label:"Draft"},{value:"published",label:"Published"},{value:"changed",label:"Changed"},{value:"unpublished",label:"Unpublished"},{value:"scheduled",label:"Scheduled"}];function us(){const{host:i,collection:n}=fe(),w=ve(),{collections:ue}=Ne(),[k,y]=o.useState(""),[_,R]=o.useState("prefix"),[u,L]=o.useState(),[h,q]=o.useState(),[S,E]=o.useState("updated_desc"),[he,X]=o.useState(),[d,v]=o.useState(new Set),Z=$e(),b=Te(k,300),l=o.useCallback(()=>X(void 0),[]),xe=o.useMemo(()=>{const s={};return b&&(s.q=b,s.search=_),u&&(s.tag=u),h&&(s.status=h),S!=="updated_desc"&&(s.sort=S),s},[b,_,u,h,S]),C=ue.find(s=>s.name===n),{data:A,isLoading:me}=ke(i,n,xe,he),z=ye(i),G=_e(i),Q=Ae(i),J=Ie(i),{data:K}=Pe(i),$=o.useMemo(()=>K?.map(s=>s.tag)??[],[K]);if(C?.singleton&&A?.items.length===1)return w(`/sites/${i}/content/${n}/${A.items[0].contentId}`,{replace:!0}),null;const M=A?.items,O=M?.map(s=>s.contentId)??[],W=O.length>0&&O.every(s=>d.has(s));function Y(s){v(c=>{const a=new Set(c);return a.has(s)?a.delete(s):a.add(s),a})}function je(){v(W?new Set:new Set(O))}const ee=!!(b||u||h),se=!!b,ae=[_!=="prefix"?1:0,u?1:0,h?1:0,S!=="updated_desc"?1:0].reduce((s,c)=>s+c,0),pe=G.isPending||Q.isPending||J.isPending;async function ge(){try{const s=await z.mutateAsync({collection:n,title:C?.label??n});m.success("Singleton content recreated"),w(`/sites/${i}/content/${n}/${s.contentId}`)}catch(s){m.error("Failed to recreate singleton",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:C?.label??n}),!C?.singleton&&e.jsxs(B,{onClick:()=>w(`/sites/${i}/content/${n}/new`),children:[e.jsx(Fe,{className:"mr-2 h-4 w-4"}),"New"]})]}),d.size>0?e.jsx(Oe,{selectedCount:d.size,onPublish:async()=>{const s=[...d],a=(await G.mutateAsync(s)).filter(t=>t.status==="rejected").length;a?m.error(`${a} of ${s.length} failed to publish`):m.success(`${s.length} item(s) published`),v(new Set)},onUnpublish:async()=>{const s=[...d],a=(await Q.mutateAsync(s)).filter(t=>t.status==="rejected").length;a?m.error(`${a} of ${s.length} failed to unpublish`):m.success(`${s.length} item(s) unpublished`),v(new Set)},onDelete:async()=>{const s=[...d],a=(await J.mutateAsync(s)).filter(t=>t.status==="rejected").length;a?m.error(`${a} of ${s.length} failed to delete`):m.success(`${s.length} item(s) deleted`),v(new Set)},onClear:()=>v(new Set),isPending:pe}):Z?e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(de,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(le,{placeholder:"Search...",value:k,onChange:s=>{y(s.target.value),l()},className:"pl-8 pr-8"}),k&&e.jsx("button",{onClick:()=>{y(""),l()},className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",children:e.jsx(I,{className:"h-4 w-4"})})]}),e.jsxs(Ue,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(B,{variant:"outline",size:"icon",className:"relative shrink-0","aria-label":"Filters",children:[e.jsx(Re,{className:"h-4 w-4"}),ae>0&&e.jsx("span",{className:"absolute -right-1 -top-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-[10px] text-primary-foreground",children:ae})]})}),e.jsxs(Ve,{className:"w-64 space-y-3",align:"end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"Search Mode"}),e.jsxs(j,{value:_,onValueChange:s=>{R(s),l()},children:[e.jsx(p,{children:e.jsx(g,{})}),e.jsxs(f,{children:[e.jsx(r,{value:"prefix",children:"Starts with"}),e.jsx(r,{value:"full",children:"Contains"})]})]})]}),$.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"Tag"}),e.jsxs(j,{value:u??"__all__",onValueChange:s=>{L(s==="__all__"?void 0:s),l()},children:[e.jsx(p,{children:e.jsx(g,{})}),e.jsxs(f,{children:[e.jsx(r,{value:"__all__",children:"All tags"}),$.map(s=>e.jsx(r,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"Status"}),e.jsxs(j,{value:h??"all",onValueChange:s=>{q(s==="all"?void 0:s),l()},children:[e.jsx(p,{children:e.jsx(g,{})}),e.jsx(f,{children:H.map(s=>e.jsx(r,{value:s.value??"all",children:s.label},s.value??"all"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"Sort"}),e.jsxs(j,{value:S,onValueChange:s=>{E(s),l()},disabled:se,children:[e.jsx(p,{children:e.jsx(g,{})}),e.jsx(f,{children:oe.map(s=>e.jsx(r,{value:s.value,disabled:s.requiresCollection&&!n,children:s.label},s.value))})]})]})]})]})]}):e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(de,{className:"absolute left-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(le,{placeholder:"Search titles...",value:k,onChange:s=>{y(s.target.value),l()},className:"w-56 pl-8 pr-8"}),k&&e.jsx("button",{onClick:()=>{y(""),l()},className:"absolute right-2 text-muted-foreground hover:text-foreground",children:e.jsx(I,{className:"h-4 w-4"})})]}),e.jsxs(j,{value:_,onValueChange:s=>{R(s),l()},children:[e.jsx(p,{className:"w-[130px]",children:e.jsx(g,{})}),e.jsxs(f,{children:[e.jsx(r,{value:"prefix",children:"Starts with"}),e.jsx(r,{value:"full",children:"Contains"})]})]}),$.length>0&&e.jsxs(j,{value:u??"__all__",onValueChange:s=>{L(s==="__all__"?void 0:s),l()},children:[e.jsx(p,{className:"w-[140px]",children:e.jsx(g,{placeholder:"Tag"})}),e.jsxs(f,{children:[e.jsx(r,{value:"__all__",children:"All tags"}),$.map(s=>e.jsx(r,{value:s,children:s},s))]})]}),e.jsxs(j,{value:h??"all",onValueChange:s=>{q(s==="all"?void 0:s),l()},children:[e.jsx(p,{className:"w-[150px]",children:e.jsx(g,{})}),e.jsx(f,{children:H.map(s=>e.jsx(r,{value:s.value??"all",children:s.label},s.value??"all"))})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(j,{value:S,onValueChange:s=>{E(s),l()},disabled:se,children:[e.jsx(p,{className:"w-[170px]",children:e.jsx(g,{})}),e.jsx(f,{children:oe.map(s=>e.jsx(r,{value:s.value,disabled:s.requiresCollection&&!n,children:s.label},s.value))})]})})]}),ee&&d.size===0&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[b&&e.jsxs(N,{variant:"secondary",className:"gap-1",children:["Search: ",b,e.jsx("button",{onClick:()=>{y(""),l()},children:e.jsx(I,{className:"h-3 w-3"})})]}),u&&e.jsxs(N,{variant:"secondary",className:"gap-1",children:["Tag: ",u,e.jsx("button",{onClick:()=>{L(void 0),l()},children:e.jsx(I,{className:"h-3 w-3"})})]}),h&&e.jsxs(N,{variant:"secondary",className:"gap-1",children:["Status: ",H.find(s=>s.value===h)?.label,e.jsx("button",{onClick:()=>{q(void 0),l()},children:e.jsx(I,{className:"h-3 w-3"})})]})]}),me?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,c)=>e.jsx(Se,{className:"h-12 w-full"},c))}):M?.length?e.jsxs(e.Fragment,{children:[Z?e.jsx("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"content-card-view",children:M.map(s=>{const c=re(s.publishedAt,s.lastPublishedAt,s.publishedBlockId,s.lastDraftBlockId,s.scheduledAt,s.scheduledFailed),a=ie(c),t=s.tags??[];return e.jsx(Me,{className:we("cursor-pointer gap-0 overflow-hidden py-0 transition-shadow hover:shadow-md",d.has(s.contentId)&&"ring-2 ring-primary"),onClick:()=>w(`/sites/${i}/content/${n}/${s.contentId}`),children:e.jsxs(Be,{className:"p-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[s.coverUrl&&e.jsx("img",{src:te(s.coverUrl),alt:"",className:"h-12 w-12 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-medium truncate",children:s.title||"Untitled"}),e.jsx(N,{variant:a.variant,className:"shrink-0",children:a.label})]}),s.slug&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:["/",s.slug]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s.lastDraftAt?D(s.lastDraftAt):"—"})]}),e.jsx(F,{checked:d.has(s.contentId),onCheckedChange:()=>Y(s.contentId),onClick:x=>x.stopPropagation(),className:"mt-1"})]}),t.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:t.slice(0,V).map(x=>e.jsx(N,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:x},x))})]})},s.contentId)})}):e.jsxs(Le,{children:[e.jsx(qe,{children:e.jsxs(ne,{children:[e.jsx(P,{className:"w-10",children:e.jsx(F,{checked:W,onCheckedChange:je,"aria-label":"Select all"})}),e.jsx(P,{children:"Title"}),e.jsx(P,{children:"Slug"}),e.jsx(P,{children:"Status"}),e.jsx(P,{children:"Updated"})]})}),e.jsx(ze,{children:M.map(s=>{const c=re(s.publishedAt,s.lastPublishedAt,s.publishedBlockId,s.lastDraftBlockId),a=ie(c),t=s.tags??[];return e.jsxs(ne,{className:"cursor-pointer",onClick:()=>w(`/sites/${i}/content/${n}/${s.contentId}`),children:[e.jsx(T,{onClick:x=>x.stopPropagation(),children:e.jsx(F,{checked:d.has(s.contentId),onCheckedChange:()=>Y(s.contentId),"aria-label":`Select ${s.title||"Untitled"}`})}),e.jsx(T,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-3",children:[s.coverUrl&&e.jsx("img",{src:te(s.coverUrl),alt:"",className:"h-8 w-8 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{children:s.title||"Untitled"}),t.length>0&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-1",children:[t.slice(0,V).map(x=>e.jsx(N,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal text-muted-foreground",children:x},x)),t.length>V&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",t.length-V," more"]})]})]})]})}),e.jsx(T,{className:"text-muted-foreground text-sm",children:s.slug||"—"}),e.jsx(T,{children:e.jsx(N,{variant:a.variant,children:a.label})}),e.jsx(T,{className:"text-muted-foreground",children:s.scheduledAt&&!s.publishedAt?e.jsxs("span",{title:ce(s.scheduledAt),children:["Scheduled ",D(s.scheduledAt)]}):s.publishedAt?e.jsx("span",{title:ce(s.publishedAt),children:D(s.publishedAt)}):s.lastDraftAt?D(s.lastDraftAt):"—"})]},s.contentId)})})]}),A?.hasMore&&e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx(B,{variant:"outline",onClick:()=>X(A.cursor??void 0),children:"Load More"})})]}):C?.singleton?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Singleton content is missing. Click below to recreate it."}),e.jsxs(B,{onClick:ge,disabled:z.isPending,children:[z.isPending&&e.jsx(Ce,{className:"mr-2 h-4 w-4 animate-spin"}),"Recreate ",C.label]})]}):e.jsx("p",{className:"text-muted-foreground",children:ee?"No content matches the current filters.":"No content yet."})]})}export{us as ContentListPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as Qt}from"./index-
|
|
1
|
+
import{_ as Qt}from"./index-CwkwXbO-.js";import{j as q}from"./tanstack-BO6c-AOu.js";import{r as ie}from"./react-vendor-DNVhVxD7.js";class z{constructor(e,n,r,s,i){this.kind=e,this.input=n,this.begin=r,this.end=s,this.file=i}getText(){return this.input.slice(this.begin,this.end)}getPosition(){let[e,n]=[1,1];for(let r=0;r<this.begin;r++)this.input[r]===`
|
|
2
2
|
`?(e++,n=1):n++;return[e,n]}size(){return this.end-this.begin}}class J{liquidMethodMissing(e,n){}}const Gt=Object.prototype.toString,He=String.prototype.toLowerCase,Re=Object.hasOwnProperty;function f(t){return typeof t=="string"}function T(t){return typeof t=="function"}function Xt(t){return t&&T(t.then)}function he(t){return t&&T(t.next)&&T(t.throw)&&T(t.return)}function Kt(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function u(t){return t=p(t),f(t)?t:O(t)?"":_(t)?t.map(e=>u(e)).join(""):String(t)}function se(t){return t=p(t),_(t)?t:f(t)&&t.length>0?[t]:tn(t)?Array.from(t):me(t)?Object.keys(t).map(e=>[e,t[e]]):[]}function v(t){return t=p(t),O(t)?[]:_(t)?t:[t]}function p(t){return t instanceof J&&T(t.valueOf)?t.valueOf():t}function Se(t){return+p(t)||0}function ge(t){return typeof t=="number"}function wt(t){return t&&T(t.toLiquid)?wt(t.toLiquid()):t}function O(t){return t==null}function en(t){return t===void 0}function _(t){return Gt.call(t)==="[object Array]"}function bt(t){return t&&ge(t.length)}function tn(t){return me(t)&&Symbol.iterator in t}function We(t,e){t=t||{};for(const n in t)if(Re.call(t,n)&&e(t[n],n,t)===!1)break;return t}function xt(t){return t[t.length-1]}function me(t){const e=typeof t;return t!==null&&(e==="object"||e==="function")}function Tt(t,e,n=1){const r=[];for(let s=t;s<e;s+=n)r.push(s);return r}function re(t,e,n=" "){return vt(t,e,n,(r,s)=>s+r)}function nn(t,e,n=" "){return vt(t,e,n,(r,s)=>r+s)}function vt(t,e,n,r){t=String(t);let s=e-t.length;for(;s-- >0;)t=r(t,n);return t}function _t(t){return t}function rn(t){return[...t].some(n=>n>="a"&&n<="z")?t.toUpperCase():t.toLowerCase()}function sn(t,e){return t.length>e?t.slice(0,e-3)+"...":t}function Ye(t,e){return t==null&&e==null?0:t==null?1:e==null||(t=He.call(t),e=He.call(e),t<e)?-1:t>e?1:0}function ye(t){return function(...e){return t.call(this,...e.map(p))}}function D(t){return function(...e){return t.call(this,...e.map(Se))}}function Ee(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function*oe(t){const e=new Set;for(const n of t){const r=JSON.stringify(n);e.has(r)||(e.add(r),yield n)}}const Je="__liquidClass__";class Z extends Error{constructor(e,n){super(typeof e=="string"?e:e.message),this.context="",typeof e!="string"&&Object.defineProperty(this,"originalError",{value:e,enumerable:!1}),Object.defineProperty(this,"token",{value:n,enumerable:!1}),Object.defineProperty(this,Je,{value:"LiquidError",enumerable:!1})}update(){Object.defineProperty(this,"context",{value:fn(this.token),enumerable:!1}),this.message=dn(this.message,this.token),this.stack=this.message+`
|
|
3
3
|
`+this.context+`
|
|
4
4
|
`+this.stack,this.originalError&&(this.stack+=`
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{r as j}from"./react-vendor-DNVhVxD7.js";import{C as O,G as D,b as M,u as P,a as q,P as A,D as $,c as z}from"./core.esm-BtFZvlg0.js";import{T as V,u as _,C as G,b as U,c as Y,S as H,v as J,a as K}from"./sortable.esm-BUhmZW2_.js";import{I as p,w as T,N as Q,L as d,B as k}from"./index-CwkwXbO-.js";import{S as E,a as I,b as L,c as B,d as R}from"./select-Cj54Wt-H.js";import{d as F,i as W}from"./format-C88SDH8g.js";import{C as w}from"./checkbox-VtCfoGic.js";import{P as X}from"./plus-2Ds_MoqB.js";import{T as Z}from"./trash-2-CbbWF_O4.js";function ee({value:t,onChange:a,onBlur:x,readOnly:h,className:l,...s}){const[n,u]=j.useState(!1),m=j.useRef(void 0);j.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const g=j.useCallback(v=>{const N=v.target.value,f=F(N,"leading");a(f),N!==f&&N.length>0?(u(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>u(!1),2e3)):u(!1)},[a]),y=j.useCallback(()=>{const v=F(t,"all");v!==t&&a(v),x?.()},[t,a,x]);return e.jsxs("div",{className:"space-y-1",children:[e.jsx(p,{value:t,onChange:g,onBlur:y,disabled:h,"aria-invalid":n||void 0,autoComplete:"off","data-1p-ignore":!0,"data-lpignore":"true",className:T("font-mono",l),...s}),n&&e.jsx("p",{className:"text-xs text-destructive",children:"Must start with a letter. Only lowercase letters, numbers, hyphens, and underscores."})]})}function se({type:t,options:a,onChange:x}){const h=Q();function l(s,n){x({...a,[s]:n})}return e.jsxs("div",{className:"space-y-3",children:[!["boolean","blocks","array"].includes(t)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{id:"opt-required",checked:!!a.required,onCheckedChange:s=>l("required",!!s)}),e.jsx(d,{htmlFor:"opt-required",className:"text-sm",children:"Required"})]}),["text","textarea"].includes(t)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Placeholder"}),e.jsx(p,{value:a.placeholder??"",onChange:s=>l("placeholder",s.target.value),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Max Length"}),e.jsx(p,{type:"number",value:a.maxLength??"",onChange:s=>l("maxLength",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]})]}),t==="number"&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Min"}),e.jsx(p,{type:"number",value:a.min??"",onChange:s=>l("min",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Max"}),e.jsx(p,{type:"number",value:a.max??"",onChange:s=>l("max",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Step"}),e.jsx(p,{type:"number",value:a.step??"",onChange:s=>l("step",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]})]}),t==="select"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Choices (one per line)"}),e.jsx(V,{value:(a.choices??[]).join(`
|
|
2
|
+
`),onChange:s=>l("choices",s.target.value.split(`
|
|
3
|
+
`).map(n=>n.trim()).filter(Boolean)),rows:4,className:"text-sm"})]}),t==="media"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Allowed Types (e.g., image/*, video/*)"}),e.jsx(p,{value:(a.allowedTypes??[]).join(", "),onChange:s=>l("allowedTypes",s.target.value.split(",").map(n=>n.trim()).filter(Boolean)),className:"h-8 text-sm"})]}),t==="content"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Allowed Collections"}),h&&h.collections.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:h.collections.map(s=>{const n=a.collections??[],u=n.includes(s.name);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(w,{id:`col-${s.name}`,checked:u,onCheckedChange:m=>{m?l("collections",[...n,s.name]):l("collections",n.filter(g=>g!==s.name))}}),e.jsx(d,{htmlFor:`col-${s.name}`,className:"text-xs font-normal",children:s.label||s.name})]},s.name)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave all unchecked to allow any collection"})]}):e.jsx(p,{value:(a.collections??[]).join(", "),onChange:s=>l("collections",s.target.value.split(",").map(n=>n.trim()).filter(Boolean)),placeholder:"Comma-separated, leave empty for all",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{id:"opt-multiple",checked:!!a.multiple,onCheckedChange:s=>l("multiple",!!s)}),e.jsx(d,{htmlFor:"opt-multiple",className:"text-sm",children:"Allow multiple"})]})]}),t==="array"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Item Fields"}),e.jsx(te,{fields:a.itemFields??[],onChange:s=>l("itemFields",s),excludeTypes:["array"]})]})]})}const C=[{value:"text",label:"Text"},{value:"textarea",label:"Textarea"},{value:"number",label:"Number"},{value:"boolean",label:"Boolean"},{value:"select",label:"Select"},{value:"url",label:"URL"},{value:"email",label:"Email"},{value:"date",label:"Date"},{value:"media",label:"Media"},{value:"content",label:"Content"},{value:"blocks",label:"Blocks"},{value:"array",label:"Array"}];function ae({id:t,field:a,onChange:x,onRemove:h,excludeTypes:l,readOnlyName:s,defaultExpanded:n}){const[u,m]=j.useState(n??!1),[g,y]=j.useState(!!a.label),{attributes:v,listeners:N,setNodeRef:f,transform:S,transition:r}=_({id:t}),i=l?C.filter(c=>!l.includes(c.value)):C,o={transform:O.Transform.toString(S),transition:r};function b(c){x({...a,...c})}return e.jsx("div",{ref:f,style:o,className:"rounded-md border bg-card",children:e.jsxs(G,{open:u,onOpenChange:m,children:[e.jsxs("div",{className:"flex items-center gap-2 p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...v,...N,children:e.jsx(D,{className:"h-4 w-4"})}),e.jsx(U,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex items-center",children:e.jsx(M,{className:T("h-4 w-4 transition-transform",u&&"rotate-90")})})}),e.jsx("span",{className:"min-w-[80px] text-sm font-mono",children:a.name||"unnamed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a.type}),e.jsx("span",{className:"flex-1 truncate text-sm text-muted-foreground",children:a.label}),e.jsx(k,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"text-destructive",children:e.jsx(Z,{className:"h-3 w-3"})})]}),e.jsx(Y,{children:e.jsxs("div",{className:"space-y-3 border-t p-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),e.jsx(ee,{value:a.name,onChange:c=>b({name:c}),onBlur:()=>{a.name&&!g&&b({label:W(a.name)})},readOnly:s,className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Label"}),e.jsx(p,{value:a.label,onChange:c=>{b({label:c.target.value}),y(!0)},className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Type"}),e.jsxs(E,{value:a.type,onValueChange:c=>b({type:c,options:{}}),children:[e.jsx(I,{className:"h-8 text-sm",children:e.jsx(L,{})}),e.jsx(B,{children:i.map(c=>e.jsx(R,{value:c.value,children:c.label},c.value))})]})]})]}),e.jsx(se,{type:a.type,options:a.options??{},onChange:c=>b({options:c})})]})})]})})}function te({fields:t,onChange:a,excludeTypes:x,existingFieldNames:h}){const l=P(q(A)),s=t.map((r,i)=>`field-${i}`),[n,u]=j.useState("text"),[m,g]=j.useState(null),y=x?C.filter(r=>!x.includes(r.value)):C;function v(){g(t.length),a([...t,{name:"",label:"",type:n,options:{}}])}function N(r,i){const o=[...t];o[r]=i,a(o)}function f(r){a(t.filter((i,o)=>o!==r))}function S(r){const{active:i,over:o}=r;if(o&&i.id!==o.id){const b=s.indexOf(String(i.id)),c=s.indexOf(String(o.id));a(K(t,b,c))}}return e.jsx($,{sensors:l,collisionDetection:z,onDragEnd:S,children:e.jsx(H,{items:s,strategy:J,children:e.jsxs("div",{className:"space-y-2",children:[t.map((r,i)=>e.jsx(ae,{id:`field-${i}`,field:r,onChange:o=>N(i,o),onRemove:()=>f(i),excludeTypes:x,readOnlyName:!!(h?.has(r.name)&&r.name),defaultExpanded:i===m},`field-${i}`)),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(E,{value:n,onValueChange:u,children:[e.jsx(I,{className:"h-8 w-[130px] text-sm",children:e.jsx(L,{})}),e.jsx(B,{children:y.map(r=>e.jsx(R,{value:r.value,children:r.label},r.value))})]}),e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:v,children:[e.jsx(X,{className:"mr-2 h-3 w-3"})," Add Field"]})]})]})})})}export{te as F,ee as I};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-BO6c-AOu.js";import{r as o,N as Y}from"./react-vendor-DNVhVxD7.js";import{u as z,L as c,I as d,B as m,a as x,f as _,c as G}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{r as o,N as Y}from"./react-vendor-DNVhVxD7.js";import{u as z,L as c,I as d,B as m,a as x,f as _,c as G}from"./index-CwkwXbO-.js";import{C as J,a as X,b as Z,c as $}from"./card-DpNr7WTb.js";import"./radix-n1vDIPi6.js";function oe(){const{status:T,login:D,completeNewPassword:L,respondToMfaChallenge:O}=z(),[g,W]=o.useState(""),[j,I]=o.useState(""),[N,q]=o.useState(""),[v,E]=o.useState(""),[i,a]=o.useState(""),[n,r]=o.useState(!1),[l,y]=o.useState(null),[u,f]=o.useState("login"),[h,C]=o.useState(""),[S,P]=o.useState(""),[w,b]=o.useState(""),[F,R]=o.useState("");if(T==="authenticated")return e.jsx(Y,{to:"/sites",replace:!0});async function M(t){t.preventDefault(),a(""),r(!0);try{const s=await D(g,j);s.challenge==="NEW_PASSWORD_REQUIRED"&&s.cognitoUser?y({type:"NEW_PASSWORD_REQUIRED",user:s.cognitoUser}):s.challenge==="SOFTWARE_TOKEN_MFA"&&s.cognitoUser&&y({type:"SOFTWARE_TOKEN_MFA",user:s.cognitoUser})}catch(s){a(s instanceof Error?s.message:"Login failed")}finally{r(!1)}}async function U(t){if(t.preventDefault(),!!l){a(""),r(!0);try{await L(l.user,N)}catch(s){a(s instanceof Error?s.message:"Password change failed")}finally{r(!1)}}}async function k(t){if(t.preventDefault(),!!l){a(""),r(!0);try{await O(l.user,v)}catch(s){s&&typeof s=="object"&&"name"in s&&s.name==="NotAuthorizedException"?(a("Your session has expired. Please sign in again."),y(null),E("")):a(s instanceof Error?s.message:"Invalid code")}finally{r(!1)}}}async function B(t){t.preventDefault(),a(""),r(!0);try{await _(h),f("forgot-confirm")}catch(s){(s&&typeof s=="object"&&"name"in s?s.name:"")==="LimitExceededException"?a("Too many attempts. Please try again later."):f("forgot-confirm")}finally{r(!1)}}async function K(){a(""),r(!0);try{await _(h)}catch{}finally{r(!1)}}async function Q(t){if(t.preventDefault(),a(""),w.length<12){a("Password must be at least 12 characters.");return}if(w!==F){a("Passwords do not match.");return}r(!0);try{await G(h,S,w),f("forgot-success")}catch(s){const p=s&&typeof s=="object"&&"name"in s?s.name:"";a(p==="CodeMismatchException"?"Invalid verification code.":p==="ExpiredCodeException"?"Verification code has expired. Please request a new one.":p==="InvalidPasswordException"?"New password does not meet requirements (min 12 chars, uppercase, lowercase, number, symbol).":p==="LimitExceededException"?"Too many attempts. Please try again later.":s instanceof Error?s.message:"Password reset failed")}finally{r(!1)}}function A(){f("login"),a(""),P(""),b(""),R("")}function V(){return u==="forgot-email"?e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter your email and we'll send a code to reset your password."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"forgot-email",children:"Email"}),e.jsx(d,{id:"forgot-email",type:"email",value:h,onChange:t=>C(t.target.value),required:!0,autoFocus:!0,autoComplete:"email"})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Send Reset Code"]}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground w-full text-center text-sm underline",onClick:A,children:"Back to sign in"})]}):u==="forgot-confirm"?e.jsxs("form",{onSubmit:Q,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter the code sent to your email and choose a new password."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"reset-code",children:"Verification Code"}),e.jsx(d,{id:"reset-code",type:"text",value:S,onChange:t=>P(t.target.value),required:!0,autoFocus:!0,autoComplete:"one-time-code"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"reset-password",children:"New Password"}),e.jsx(d,{id:"reset-password",type:"password",value:w,onChange:t=>b(t.target.value),required:!0,autoComplete:"new-password"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"reset-confirm-password",children:"Confirm Password"}),e.jsx(d,{id:"reset-confirm-password",type:"password",value:F,onChange:t=>R(t.target.value),required:!0,autoComplete:"new-password"})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Reset Password"]}),e.jsxs("p",{className:"text-muted-foreground text-center text-sm",children:["Didn't receive a code?"," ",e.jsx("button",{type:"button",className:"text-foreground underline",onClick:K,disabled:n,children:"Resend code"})]})]}):u==="forgot-success"?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your password has been reset successfully."}),e.jsx(m,{className:"w-full",onClick:A,children:"Sign In"})]}):l?.type==="SOFTWARE_TOKEN_MFA"?e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter the 6-digit code from your authenticator app."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"mfa-code",children:"Authentication Code"}),e.jsx(d,{id:"mfa-code",type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:v,onChange:t=>E(t.target.value),required:!0,autoFocus:!0,autoComplete:"one-time-code"})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Verify"]})]}):l?.type==="NEW_PASSWORD_REQUIRED"?e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Please set a new password to continue."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"new-password",children:"New Password"}),e.jsx(d,{id:"new-password",type:"password",value:N,onChange:t=>q(t.target.value),required:!0,minLength:12,autoFocus:!0})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Set Password"]})]}):e.jsxs("form",{onSubmit:M,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"email",children:"Email"}),e.jsx(d,{id:"email",type:"email",value:g,onChange:t=>W(t.target.value),required:!0,autoFocus:!0,autoComplete:"email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"password",children:"Password"}),e.jsx(d,{id:"password",type:"password",value:j,onChange:t=>I(t.target.value),required:!0,autoComplete:"current-password"})]}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground text-sm underline",onClick:()=>{f("forgot-email"),C(g),a("")},children:"Forgot password?"}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Sign In"]})]})}function H(){return u==="forgot-email"||u==="forgot-confirm"?"Reset Password":u==="forgot-success"?"Password Reset":l?.type==="SOFTWARE_TOKEN_MFA"?"Two-Factor Authentication":l?.type==="NEW_PASSWORD_REQUIRED"?"Set New Password":"Sign in to Headroom"}return e.jsx("div",{className:"flex h-dvh items-center justify-center",children:e.jsxs(J,{className:"w-full max-w-sm",children:[e.jsx(X,{children:e.jsx(Z,{className:"text-center text-xl",children:H()})}),e.jsx($,{children:V()})]})})}export{oe as LoginPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-BO6c-AOu.js";import{r as u,R as S,L as kt,u as Dt}from"./react-vendor-DNVhVxD7.js";import{F as St,l as Mt,m as Tt,n as _t,o as It,T as Pe,A as Oe,p as Rt,e as Ue,f as He,g as Le,h as Xe,i as Ye,j as Be,k as Ke,b as ct,q as At,r as zt,s as Et,E as $t,U as Ne,u as Ft,a as Pt,t as Ot,v as Ut,w as Ht}from"./useMedia-DjiNKMOU.js";import{o as L,w as O,M as dt,B as k,t as M,D as le,j as oe,k as ce,l as de,m as he,L as H,I as V,n as me,a as ee,X as pe,O as Lt,P as Xt,R as Yt,V as nt,z as Bt,A as Kt,E as Vt,S as Wt}from"./index-CwkwXbO-.js";import{C as qt,c as Qt}from"./card-DpNr7WTb.js";import{C as Te}from"./checkbox-VtCfoGic.js";import{S as ge,a as fe,b as we,c as je,d as se,C as Gt,h as Zt}from"./select-Cj54Wt-H.js";import{s as Jt,t as es,u as ts,v as ss,w as as,A as ns}from"./radix-n1vDIPi6.js";import{d as ht,G as rs,e as is,b as ls,u as os,a as cs,D as ds,f as hs,P as ms}from"./core.esm-BtFZvlg0.js";import{b as ve,a as Ve,f as We}from"./format-C88SDH8g.js";import{m as W,u as us}from"./use-mobile-Cvl5tIVY.js";import{T as xs,a as ps,b as mt,c as B,d as gs,e as K}from"./table-D4rLgOKa.js";import{C as qe}from"./copy-fXL6Ngxi.js";import{B as Qe}from"./badge-ChZ2DZue.js";import{T as fs}from"./trash-2-CbbWF_O4.js";import{P as ws}from"./plus-2Ds_MoqB.js";import{C as js}from"./check-BMpruHpO.js";import{S as rt}from"./search-DRNC6QB5.js";const vs=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ys=L("chevron-left",vs);const bs=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],Ns=L("crop",bs);const Cs=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],ks=L("file-code",Cs);const Ds=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],Ss=L("film",Ds);const Ms=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Ts=L("folder-open",Ms);const _s=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],te=L("folder",_s);const Is=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Rs=L("layout-grid",Is);const As=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],zs=L("list",As);const Es=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],$s=L("maximize-2",Es);const Fs=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Ps=L("music",Fs);const Os=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Us=L("refresh-cw",Os);function Ce({delayDuration:a=0,...t}){return e.jsx(Jt,{"data-slot":"tooltip-provider",delayDuration:a,...t})}function ke({...a}){return e.jsx(es,{"data-slot":"tooltip",...a})}function De({...a}){return e.jsx(ts,{"data-slot":"tooltip-trigger",...a})}function Se({className:a,sideOffset:t=0,children:s,...l}){return e.jsx(ss,{children:e.jsxs(as,{"data-slot":"tooltip-content",sideOffset:t,className:O("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",a),...l,children:[s,e.jsx(ns,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function _e({mimeType:a,className:t}){return a==="application/pdf"?e.jsx(dt,{className:O("text-blue-500",t)}):a.startsWith("video/")?e.jsx(Ss,{className:O("text-purple-500",t)}):a.startsWith("audio/")?e.jsx(Ps,{className:O("text-green-500",t)}):a==="image/svg+xml"?e.jsx(ks,{className:O("text-orange-500",t)}):e.jsx(St,{className:O("text-muted-foreground",t)})}function Hs(a){return a==="application/pdf"?"PDF":a==="image/svg+xml"?"SVG":a.startsWith("image/")?"Image":a.startsWith("video/")?"Video":a.startsWith("audio/")?"Audio":a.split("/")[1]?.toUpperCase()??"File"}function Ls({item:a,selected:t,onToggle:s,onSelect:l,onLightbox:n,folderName:r}){const{attributes:c,listeners:h,setNodeRef:o,isDragging:i}=ht({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),x=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";return e.jsxs(mt,{ref:o,className:O("cursor-pointer",i&&"opacity-50"),onClick:l,children:[e.jsx(K,{onPointerDown:g=>g.stopPropagation(),onClick:g=>g.stopPropagation(),children:e.jsx(Te,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsx(K,{className:"w-6 p-1 hidden md:table-cell",children:e.jsx("div",{className:"cursor-grab text-muted-foreground",...c,...h,children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsx(K,{className:"p-1",children:x?e.jsx("img",{src:W(a.urls?.thumb_sm??a.url),alt:a.alt||a.filename,className:O("h-8 w-8 rounded object-cover",n&&"cursor-zoom-in"),onClick:n?g=>{g.stopPropagation(),n()}:void 0}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center",children:e.jsx(_e,{mimeType:a.mimeType,className:"h-5 w-5"})})}),e.jsxs(K,{className:"max-w-[200px]",children:[r&&e.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:r}),e.jsx("span",{className:"block truncate text-sm font-medium",children:a.filename})]}),e.jsx(K,{className:"hidden md:table-cell",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Hs(a.mimeType)})}),e.jsx(K,{className:"text-right",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:ve(a.size)})}),e.jsx(K,{className:"hidden lg:table-cell",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:a.width&&a.height?`${a.width}×${a.height}`:"—"})}),e.jsx(K,{className:"hidden lg:table-cell",children:a.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(g=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-[10px]",children:g},g)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})}),e.jsx(K,{className:"hidden md:table-cell",children:e.jsx(Ce,{children:e.jsxs(ke,{children:[e.jsx(De,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ve(a.uploadedAt)})}),e.jsx(Se,{children:We(a.uploadedAt)})]})})}),e.jsx(K,{onPointerDown:g=>g.stopPropagation(),onClick:g=>g.stopPropagation(),children:e.jsx(k,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(W(a.url)),M.success("URL copied to clipboard")},children:e.jsx(qe,{className:"h-3.5 w-3.5"})})})]})}function Xs({items:a,host:t,onSelect:s,selectedIds:l,onToggle:n,onToggleAll:r,allSelected:c,onLightbox:h,folderMap:o}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(xs,{children:[e.jsx(ps,{children:e.jsxs(mt,{children:[e.jsx(B,{className:"w-10",children:e.jsx(Te,{checked:c,onCheckedChange:r,"aria-label":"Select all"})}),e.jsx(B,{className:"w-6 hidden md:table-cell"}),e.jsx(B,{className:"w-12"}),e.jsx(B,{children:"Filename"}),e.jsx(B,{className:"w-20 hidden md:table-cell",children:"Type"}),e.jsx(B,{className:"w-24 text-right",children:"Size"}),e.jsx(B,{className:"w-28 hidden lg:table-cell",children:"Dimensions"}),e.jsx(B,{className:"w-40 hidden lg:table-cell",children:"Tags"}),e.jsx(B,{className:"w-32 hidden md:table-cell",children:"Uploaded"}),e.jsx(B,{className:"w-10"})]})}),e.jsx(gs,{children:a.map(i=>e.jsx(Ls,{item:i,host:t,selected:l.has(i.mediaId),onToggle:()=>n(i.mediaId),onSelect:()=>s(i),folderName:o?.get(i.folderId??""),onLightbox:h&&i.mimeType.startsWith("image/")&&i.mimeType!=="image/svg+xml"?()=>h(i):void 0},i.mediaId))})]})})}var Ys=Object.defineProperty,Bs=(a,t,s)=>t in a?Ys(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,T=(a,t,s)=>Bs(a,typeof t!="symbol"?t+"":t,s);const Me={x:0,y:0,width:0,height:0,unit:"px"},ne=(a,t,s)=>Math.min(Math.max(a,t),s),Ks=(...a)=>a.filter(t=>t&&typeof t=="string").join(" "),it=(a,t)=>a===t||a.width===t.width&&a.height===t.height&&a.x===t.x&&a.y===t.y&&a.unit===t.unit;function re(a,t,s){return a.unit==="%"?{...Me,...a,unit:"%"}:{unit:"%",x:a.x?a.x/t*100:0,y:a.y?a.y/s*100:0,width:a.width?a.width/t*100:0,height:a.height?a.height/s*100:0}}function G(a,t,s){return a.unit?a.unit==="px"?{...Me,...a,unit:"px"}:{unit:"px",x:a.x?a.x*t/100:0,y:a.y?a.y*s/100:0,width:a.width?a.width*t/100:0,height:a.height?a.height*s/100:0}:{...Me,...a,unit:"px"}}function lt(a,t,s,l,n,r=0,c=0,h=l,o=n){const i={...a};let x=Math.min(r,l),g=Math.min(c,n),m=Math.min(h,l),d=Math.min(o,n);t&&(t>1?(x=c?c*t:x,g=x/t,m=h*t):(g=r?r/t:g,x=g*t,d=o/t)),i.y<0&&(i.height=Math.max(i.height+i.y,g),i.y=0),i.x<0&&(i.width=Math.max(i.width+i.x,x),i.x=0);const b=l-(i.x+i.width);b<0&&(i.x=Math.min(i.x,l-x),i.width+=b);const p=n-(i.y+i.height);if(p<0&&(i.y=Math.min(i.y,n-g),i.height+=p),i.width<x&&((s==="sw"||s=="nw")&&(i.x-=x-i.width),i.width=x),i.height<g&&((s==="nw"||s=="ne")&&(i.y-=g-i.height),i.height=g),i.width>m&&((s==="sw"||s=="nw")&&(i.x-=m-i.width),i.width=m),i.height>d&&((s==="nw"||s=="ne")&&(i.y-=d-i.height),i.height=d),t){const j=i.width/i.height;if(j<t){const w=Math.max(i.width/t,g);(s==="nw"||s=="ne")&&(i.y-=w-i.height),i.height=w}else if(j>t){const w=Math.max(i.height*t,x);(s==="sw"||s=="nw")&&(i.x-=w-i.width),i.width=w}}return i}function Vs(a,t,s,l){const n={...a};return t==="ArrowLeft"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="w"?(n.x-=s,n.width+=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="e"?n.width-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowRight"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="w"?(n.x+=s,n.width-=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="e"?n.width+=s:l==="se"&&(n.width+=s,n.height+=s)),t==="ArrowUp"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="n"?(n.y-=s,n.height+=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="s"?n.height-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowDown"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="n"?(n.y+=s,n.height-=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="s"?n.height+=s:l==="se"&&(n.width+=s,n.height+=s)),n}const ie={capture:!0,passive:!1};let Ws=0;const Z=class U extends u.PureComponent{constructor(){super(...arguments),T(this,"docMoveBound",!1),T(this,"mouseDownOnCrop",!1),T(this,"dragStarted",!1),T(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),T(this,"componentRef",u.createRef()),T(this,"mediaRef",u.createRef()),T(this,"resizeObserver"),T(this,"initChangeCalled",!1),T(this,"instanceId",`rc-${Ws++}`),T(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),T(this,"onCropPointerDown",t=>{const{crop:s,disabled:l}=this.props,n=this.getBox();if(!s)return;const r=G(s,n.width,n.height);if(l)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const c=t.target.dataset.ord,h=!!c;let o=t.clientX,i=t.clientY,x=r.x,g=r.y;if(c){const m=t.clientX-n.x,d=t.clientY-n.y;let b=0,p=0;c==="ne"||c=="e"?(b=m-(r.x+r.width),p=d-r.y,x=r.x,g=r.y+r.height):c==="se"||c==="s"?(b=m-(r.x+r.width),p=d-(r.y+r.height),x=r.x,g=r.y):c==="sw"||c=="w"?(b=m-r.x,p=d-(r.y+r.height),x=r.x+r.width,g=r.y):(c==="nw"||c=="n")&&(b=m-r.x,p=d-r.y,x=r.x+r.width,g=r.y+r.height),o=x+n.x+b,i=g+n.y+p}this.evData={startClientX:o,startClientY:i,startCropX:x,startCropY:g,clientX:t.clientX,clientY:t.clientY,isResize:h,ord:c},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),T(this,"onComponentPointerDown",t=>{const{crop:s,disabled:l,locked:n,keepSelection:r,onChange:c}=this.props,h=this.getBox();if(l||n||r&&s)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const o=t.clientX-h.x,i=t.clientY-h.y,x={unit:"px",x:o,y:i,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:o,startCropY:i,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,c(G(x,h.width,h.height),re(x,h.width,h.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),T(this,"onDocPointerMove",t=>{const{crop:s,disabled:l,onChange:n,onDragStart:r}=this.props,c=this.getBox();if(l||!s||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,r&&r(t));const{evData:h}=this;h.clientX=t.clientX,h.clientY=t.clientY;let o;h.isResize?o=this.resizeCrop():o=this.dragCrop(),it(s,o)||n(G(o,c.width,c.height),re(o,c.width,c.height))}),T(this,"onComponentKeyDown",t=>{const{crop:s,disabled:l,onChange:n,onComplete:r}=this.props;if(l)return;const c=t.key;let h=!1;if(!s)return;const o=this.getBox(),i=this.makePixelCrop(o),x=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep;if(c==="ArrowLeft"?(i.x-=x,h=!0):c==="ArrowRight"?(i.x+=x,h=!0):c==="ArrowUp"?(i.y-=x,h=!0):c==="ArrowDown"&&(i.y+=x,h=!0),h){t.cancelable&&t.preventDefault(),i.x=ne(i.x,0,o.width-i.width),i.y=ne(i.y,0,o.height-i.height);const g=G(i,o.width,o.height),m=re(i,o.width,o.height);n(g,m),r&&r(g,m)}}),T(this,"onHandlerKeyDown",(t,s)=>{const{aspect:l=0,crop:n,disabled:r,minWidth:c=0,minHeight:h=0,maxWidth:o,maxHeight:i,onChange:x,onComplete:g}=this.props,m=this.getBox();if(r||!n)return;if(t.key==="ArrowUp"||t.key==="ArrowDown"||t.key==="ArrowLeft"||t.key==="ArrowRight")t.stopPropagation(),t.preventDefault();else return;const d=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep,b=G(n,m.width,m.height),p=Vs(b,t.key,d,s),j=lt(p,l,s,m.width,m.height,c,h,o,i);if(!it(n,j)){const w=re(j,m.width,m.height);x(j,w),g&&g(j,w)}}),T(this,"onDocPointerDone",t=>{const{crop:s,disabled:l,onComplete:n,onDragEnd:r}=this.props,c=this.getBox();this.unbindDocMove(),!(l||!s)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(t),n&&n(G(s,c.width,c.height),re(s,c.width,c.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),T(this,"onDragFocus",()=>{var t;(t=this.componentRef.current)==null||t.scrollTo(0,0)})}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:s,y:l,width:n,height:r}=t.getBoundingClientRect();return{x:s,y:l,width:n,height:r}}componentDidUpdate(t){const{crop:s,onComplete:l}=this.props;if(l&&!t.crop&&s){const{width:n,height:r}=this.getBox();n&&r&&l(G(s,n,r),re(s,n,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,ie),this.document.addEventListener("pointerup",this.onDocPointerDone,ie),this.document.addEventListener("pointercancel",this.onDocPointerDone,ie),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,ie),this.document.removeEventListener("pointerup",this.onDocPointerDone,ie),this.document.removeEventListener("pointercancel",this.onDocPointerDone,ie),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,s=this.getBox(),l=this.makePixelCrop(s),n=t.clientX-t.startClientX,r=t.clientY-t.startClientY;return l.x=ne(t.startCropX+n,0,s.width-l.width),l.y=ne(t.startCropY+r,0,s.height-l.height),l}getPointRegion(t,s,l,n){const{evData:r}=this,c=r.clientX-t.x,h=r.clientY-t.y;let o;n&&s?o=s==="nw"||s==="n"||s==="ne":o=h<r.startCropY;let i;return l&&s?i=s==="nw"||s==="w"||s==="sw":i=c<r.startCropX,i?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(t,s,l=0,n=0){const r=Math.min(l,t.width),c=Math.min(n,t.height);return!s||!r&&!c?[r,c]:s>1?r?[r,r/s]:[c*s,c]:c?[c*s,c]:[r,r/s]}resizeCrop(){const{evData:t}=this,{aspect:s=0,maxWidth:l,maxHeight:n}=this.props,r=this.getBox(),[c,h]=this.resolveMinDimensions(r,s,this.props.minWidth,this.props.minHeight);let o=this.makePixelCrop(r);const i=this.getPointRegion(r,t.ord,c,h),x=t.ord||i;let g=t.clientX-t.startClientX,m=t.clientY-t.startClientY;(c&&x==="nw"||x==="w"||x==="sw")&&(g=Math.min(g,-c)),(h&&x==="nw"||x==="n"||x==="ne")&&(m=Math.min(m,-h));const d={unit:"px",x:0,y:0,width:0,height:0};i==="ne"?(d.x=t.startCropX,d.width=g,s?(d.height=d.width/s,d.y=t.startCropY-d.height):(d.height=Math.abs(m),d.y=t.startCropY-d.height)):i==="se"?(d.x=t.startCropX,d.y=t.startCropY,d.width=g,s?d.height=d.width/s:d.height=m):i==="sw"?(d.x=t.startCropX+g,d.y=t.startCropY,d.width=Math.abs(g),s?d.height=d.width/s:d.height=m):i==="nw"&&(d.x=t.startCropX+g,d.width=Math.abs(g),s?(d.height=d.width/s,d.y=t.startCropY-d.height):(d.height=Math.abs(m),d.y=t.startCropY+m));const b=lt(d,s,i,r.width,r.height,c,h,l,n);return s||U.xyOrds.indexOf(x)>-1?o=b:U.xOrds.indexOf(x)>-1?(o.x=b.x,o.width=b.width):U.yOrds.indexOf(x)>-1&&(o.y=b.y,o.height=b.height),o.x=ne(o.x,0,r.width-o.width),o.y=ne(o.y,0,r.height-o.height),o}renderCropSelection(){const{ariaLabels:t=U.defaultProps.ariaLabels,disabled:s,locked:l,renderSelectionAddon:n,ruleOfThirds:r,crop:c}=this.props,h=this.getCropStyle();if(c)return S.createElement("div",{style:h,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!s&&!l&&S.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},S.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),S.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),S.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),S.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),S.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":t.nwDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"nw"),role:"button"}),S.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":t.nDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"n"),role:"button"}),S.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":t.neDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"ne"),role:"button"}),S.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":t.eDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"e"),role:"button"}),S.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":t.seDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"se"),role:"button"}),S.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":t.sDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"s"),role:"button"}),S.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":t.swDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"sw"),role:"button"}),S.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":t.wDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"w"),role:"button"})),n&&S.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:o=>o.stopPropagation()},n(this.state)),r&&S.createElement(S.Fragment,null,S.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),S.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){const s={...Me,...this.props.crop||{}};return G(s,t.width,t.height)}render(){const{aspect:t,children:s,circularCrop:l,className:n,crop:r,disabled:c,locked:h,style:o,ruleOfThirds:i}=this.props,{cropIsActive:x,newCropIsBeingDrawn:g}=this.state,m=r?this.renderCropSelection():null,d=Ks("ReactCrop",n,x&&"ReactCrop--active",c&&"ReactCrop--disabled",h&&"ReactCrop--locked",g&&"ReactCrop--new-crop",r&&t&&"ReactCrop--fixed-aspect",r&&l&&"ReactCrop--circular-crop",r&&i&&"ReactCrop--rule-of-thirds",!this.dragStarted&&r&&!r.width&&!r.height&&"ReactCrop--invisible-crop",l&&"ReactCrop--no-animate");return S.createElement("div",{ref:this.componentRef,className:d,style:o},S.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},s),r?S.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},S.createElement("defs",null,S.createElement("mask",{id:`hole-${this.instanceId}`},S.createElement("rect",{width:"100%",height:"100%",fill:"white"}),l?S.createElement("ellipse",{cx:`${r.x+r.width/2}${r.unit}`,cy:`${r.y+r.height/2}${r.unit}`,rx:`${r.width/2}${r.unit}`,ry:`${r.height/2}${r.unit}`,fill:"black"}):S.createElement("rect",{x:`${r.x}${r.unit}`,y:`${r.y}${r.unit}`,width:`${r.width}${r.unit}`,height:`${r.height}${r.unit}`,fill:"black"}))),S.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,m)}};T(Z,"xOrds",["e","w"]),T(Z,"yOrds",["n","s"]),T(Z,"xyOrds",["nw","ne","se","sw"]),T(Z,"nudgeStep",1),T(Z,"nudgeStepMedium",10),T(Z,"nudgeStepLarge",100),T(Z,"defaultProps",{ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}});let qs=Z;const Qs=[{label:"Free",value:""},{label:"1:1 Square",value:"1"},{label:"4:3",value:"4/3"},{label:"3:2",value:"3/2"},{label:"16:9",value:"16/9"},{label:"2:3",value:"2/3"},{label:"3:4",value:"3/4"}],ut=[{label:"Original",value:"",ext:""},{label:"JPEG",value:"jpeg",ext:".jpg"},{label:"PNG",value:"png",ext:".png"},{label:"WebP",value:"webp",ext:".webp"},{label:"AVIF",value:"avif",ext:".avif"}],Gs={"image/jpeg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/tiff":".tiff"};function $e(a,t){return a?ut.find(s=>s.value===a)?.ext||`.${a}`:Gs[t]||".jpg"}function Zs(a,t){const s=a.lastIndexOf(".");return(s>0?a.substring(0,s):a)+t}function Js({host:a,media:t,onClose:s,onSaved:l}){const n=u.useRef(null),[r,c]=u.useState(),[h,o]=u.useState(),[i,x]=u.useState(""),[g,m]=u.useState(""),[d,b]=u.useState(""),[p,j]=u.useState(""),[w,A]=u.useState("80"),[_,I]=u.useState(()=>{const v=$e("",t.mimeType),R=t.filename.lastIndexOf(".");return`${R>0?t.filename.substring(0,R):t.filename}-transformed${v}`});function E(v){const R=v==="__original__"?"":v;j(R);const q=$e(R,t.mimeType);I(ae=>Zs(ae,q))}const F=Mt(a,t.mediaId),[y,N]=u.useState(null),P=u.useCallback(()=>{if(!h||!y)return null;const v=(t.width??y.width)/y.width,R=(t.height??y.height)/y.height;return{cropX:Math.round(h.x*v),cropY:Math.round(h.y*R),cropW:Math.round(h.width*v),cropH:Math.round(h.height*R)}},[h,t.width,t.height,y]),X=u.useMemo(()=>P(),[P]);async function ue(){const v=X,R=g?parseInt(g):void 0,q=d?parseInt(d):void 0;if(!v&&!R&&!q&&!p){M.error("Please specify a crop, resize, or format change");return}if(!_.trim()){M.error("Filename is required");return}const ae=$e(p,t.mimeType);if(!_.trim().toLowerCase().endsWith(ae)){M.error(`Filename must end with ${ae} to match the output format`);return}try{const $=await F.mutateAsync({...v??{},...R?{width:R}:{},...q?{height:q}:{},...p?{format:p}:{},...w?{quality:parseInt(w)}:{},filename:_.trim()});M.success("Transform saved as new media"),l?.($),s()}catch($){M.error("Transform failed",{description:$ instanceof Error?$.message:void 0})}}function J(v){x(v==="__free__"?"":v),c(void 0),o(void 0)}function Ge(v){if(!v)return;const R=v.split("/");return R.length===2?Number(R[0])/Number(R[1]):Number(v)||void 0}const xe=Ge(i);return e.jsx(le,{open:!0,onOpenChange:()=>s(),children:e.jsxs(oe,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Transform Image"}),e.jsx(he,{className:"sr-only",children:"Crop, resize, or convert image format"})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_280px] gap-6",children:[e.jsx("div",{className:"min-h-0 overflow-hidden rounded border bg-muted/30 flex items-center justify-center",children:e.jsx(qs,{crop:r,onChange:v=>c(v),onComplete:v=>o(v),aspect:xe,children:e.jsx("img",{ref:n,src:W(t.url),alt:t.alt||t.filename,className:"max-h-[60vh] max-w-full object-contain",onLoad:v=>{const R=v.currentTarget;N({width:R.naturalWidth,height:R.naturalHeight})}})})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:["Original: ",t.width,"×",t.height]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Crop aspect ratio"}),e.jsxs(ge,{value:i||"__free__",onValueChange:J,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Free"})}),e.jsx(je,{children:Qs.map(v=>e.jsx(se,{value:v.value||"__free__",children:v.label},v.value||"__free__"))})]}),h&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Crop: ",X?.cropW,"×",X?.cropH," at (",X?.cropX,", ",X?.cropY,")"]}),h&&e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>{c(void 0),o(void 0)},children:"Clear crop"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Resize (optional)"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{children:e.jsx(V,{type:"number",placeholder:"Width",value:g,onChange:v=>m(v.target.value),min:1,max:2048})}),e.jsx("div",{children:e.jsx(V,{type:"number",placeholder:"Height",value:d,onChange:v=>b(v.target.value),min:1,max:2048})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Output format"}),e.jsxs(ge,{value:p||"__original__",onValueChange:E,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Original"})}),e.jsx(je,{children:ut.map(v=>e.jsx(se,{value:v.value||"__original__",children:v.label},v.value||"__original__"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Quality (1-100)"}),e.jsx(V,{type:"number",value:w,onChange:v=>A(v.target.value),min:1,max:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Save as filename"}),e.jsx(V,{value:_,onChange:v=>I(v.target.value)})]})]})]}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(k,{onClick:ue,disabled:F.isPending,children:[F.isPending&&e.jsx(ee,{className:"mr-2 h-4 w-4 animate-spin"}),"Save as New Image"]})]})]})})}const ea=new Set(["image/jpeg","image/png","image/gif","image/webp","image/avif","image/tiff"]);function ta({host:a,media:t,onClose:s,onDeleted:l,folders:n,tagSuggestions:r}){const[c,h]=u.useState(t.alt??""),[o,i]=u.useState(t.caption??""),[x,g]=u.useState(t.userTags??[]),[m,d]=u.useState(t.folderId||"__none__"),[b,p]=u.useState(!1),j=ea.has(t.mimeType),w=Tt(a,t.mediaId),A=_t(a,t.mediaId),{data:_,isLoading:I}=It(a,t.mediaId),E=t.tags.filter(N=>!t.userTags?.includes(N));async function F(){try{await w.mutateAsync({alt:c,caption:o,userTags:x,folderId:m==="__none__"?"":m}),M.success("Media updated"),s()}catch(N){M.error("Failed to update",{description:N instanceof Error?N.message:void 0})}}async function y(){try{await A.mutateAsync(),M.success("Media deleted"),l?.(t.mediaId),s()}catch(N){M.error("Failed to delete",{description:N instanceof Error?N.message:void 0})}}return e.jsxs(le,{open:!0,onOpenChange:()=>s(),children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsx(de,{children:t.filename}),e.jsx(he,{className:"sr-only",children:"View and edit media details"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:[t.mimeType," · ",ve(t.size),t.width&&t.height&&` · ${t.width}×${t.height}`," · ",We(t.uploadedAt)]}),e.jsxs("div",{className:"flex gap-2",children:[j&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>p(!0),children:[e.jsx(Ns,{className:"mr-1.5 h-3.5 w-3.5"}),"Transform"]}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(W(t.url)),M.success("URL copied to clipboard")},children:[e.jsx(qe,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy URL"]})]})]}),E.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(H,{className:"text-xs text-muted-foreground",children:"Auto-detected tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(N=>e.jsx(Qe,{variant:"outline",className:"text-xs",children:N},N))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Tags"}),e.jsx(Pe,{tags:x,onChange:g,placeholder:"Add tags...",suggestions:r})]}),n&&n.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Folder"}),e.jsxs(ge,{value:m,onValueChange:d,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"No folder"})}),e.jsxs(je,{children:[e.jsx(se,{value:"__none__",children:"No folder"}),n.map(N=>e.jsx(se,{value:N.folderId,children:N.name},N.folderId))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"alt",children:"Alt text"}),e.jsx(V,{id:"alt",value:c,onChange:N=>h(N.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"caption",children:"Caption"}),e.jsx(V,{id:"caption",value:o,onChange:N=>i(N.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{className:"text-xs text-muted-foreground",children:"Used in"}),I?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin"}),"Checking usage..."]}):_?.references.length?e.jsxs("div",{className:"space-y-1",children:[_.references.map(N=>e.jsxs(kt,{to:`/sites/${a}/content/${N.collection}/${N.contentId}`,className:"flex items-center gap-2 rounded px-2 py-1 text-sm hover:bg-muted",onClick:s,children:[e.jsx(dt,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:N.title||N.contentId}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",N.collection,")"]})]},N.contentId)),_.note&&e.jsx("p",{className:"text-muted-foreground text-xs italic",children:_.note})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Not referenced in any content."})]})]}),e.jsxs(me,{className:"flex justify-between",children:[e.jsxs(Oe,{children:[e.jsx(Rt,{asChild:!0,children:e.jsxs(k,{variant:"destructive",size:"sm",children:[e.jsx(fs,{className:"mr-2 h-4 w-4"}),"Delete"]})}),e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(Le,{children:"Delete media?"}),e.jsxs(Xe,{children:["This will permanently delete “",t.filename,"”. This action cannot be undone."]})]}),e.jsxs(Ye,{children:[e.jsx(Be,{children:"Cancel"}),e.jsx(Ke,{onClick:y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(k,{onClick:F,children:"Save"})]})]})]}),b&&e.jsx(Js,{host:a,media:t,onClose:()=>p(!1),onSaved:()=>s()})]})}function sa({tags:a,activeTag:t,onTagChange:s}){return a.length===0?null:e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-1.5",children:[a.map(l=>e.jsx(Qe,{variant:t===l?"default":"secondary",className:"cursor-pointer select-none",onClick:()=>s(t===l?void 0:l),children:l},l)),t&&e.jsxs(k,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>s(void 0),children:[e.jsx(pe,{className:"mr-1 h-3 w-3"}),"Clear"]})]})}function Fe({id:a,children:t}){const{setNodeRef:s,isOver:l}=is({id:a,data:{type:"folder"}});return e.jsx("div",{ref:s,children:t(l)})}function ot({host:a,selectedFolderId:t,onSelect:s}){const{data:l}=ct(a),n=At(a),r=zt(a),c=Et(a),[h,o]=u.useState(!1),[i,x]=u.useState(""),[g,m]=u.useState(null),[d,b]=u.useState(""),[p,j]=u.useState(null),w=u.useRef(null),A=u.useRef(null),_=l?.items??[];u.useEffect(()=>{h&&w.current?.focus()},[h]),u.useEffect(()=>{g&&A.current?.focus()},[g]);async function I(){const y=i.trim();if(!y){o(!1),x("");return}try{await n.mutateAsync(y),M.success("Folder created")}catch(N){M.error("Failed to create folder",{description:N instanceof Error?N.message:void 0})}o(!1),x("")}async function E(y){const N=d.trim();if(!N){m(null);return}try{await r.mutateAsync({folderId:y,name:N}),M.success("Folder renamed")}catch(P){M.error("Failed to rename folder",{description:P instanceof Error?P.message:void 0})}m(null)}async function F(){if(p){try{await c.mutateAsync(p.folderId),M.success("Folder deleted"),t===p.folderId&&s(null)}catch(y){M.error("Failed to delete folder",{description:y instanceof Error?y.message:void 0})}j(null)}}return e.jsxs("div",{className:"flex w-48 shrink-0 flex-col border-r",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Folders"}),e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>o(!0),children:e.jsx(ws,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[e.jsx(Fe,{id:"all-media",children:y=>e.jsx("button",{className:O("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t===null&&"bg-accent font-medium",y&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s(null),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"All Media"]})})}),_.map(y=>e.jsx(Fe,{id:y.folderId,children:N=>e.jsx("div",{className:O("group flex w-full items-center justify-between px-3 py-1.5 text-sm hover:bg-accent/50",t===y.folderId&&"bg-accent font-medium",N&&"ring-2 ring-primary bg-primary/10"),children:g===y.folderId?e.jsx(V,{ref:A,value:d,onChange:P=>b(P.target.value),onKeyDown:P=>{P.key==="Enter"&&E(y.folderId),P.key==="Escape"&&m(null)},onBlur:()=>E(y.folderId),className:"h-6 text-sm"}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"flex flex-1 items-center gap-2 text-left",onClick:()=>s(y.folderId),children:[e.jsx(te,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:y.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:y.count}),e.jsxs(Lt,{children:[e.jsx(Xt,{asChild:!0,children:e.jsx(k,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 group-hover:opacity-100",children:e.jsx($t,{className:"h-3.5 w-3.5"})})}),e.jsxs(Yt,{align:"end",children:[e.jsx(nt,{onClick:()=>{m(y.folderId),b(y.name)},children:"Rename"}),e.jsx(nt,{disabled:y.count>0,onClick:()=>j(y),children:"Delete"})]})]})]})]})})},y.folderId)),e.jsx(Fe,{id:"unfiled",children:y=>e.jsx("button",{className:O("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t==="unfiled"&&"bg-accent font-medium",y&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s("unfiled"),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"Unfiled"]})})}),h&&e.jsx("div",{className:"px-3 py-1.5",children:e.jsx(V,{ref:w,value:i,onChange:y=>x(y.target.value),onKeyDown:y=>{y.key==="Enter"&&I(),y.key==="Escape"&&(o(!1),x(""))},onBlur:I,placeholder:"Folder name...",className:"h-7 text-sm"})})]}),e.jsx(Oe,{open:!!p,onOpenChange:()=>j(null),children:e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(Le,{children:"Delete folder?"}),e.jsxs(Xe,{children:["This will delete the folder “",p?.name,"”. Media items in this folder will become unfiled."]})]}),e.jsxs(Ye,{children:[e.jsx(Be,{children:"Cancel"}),e.jsx(Ke,{onClick:F,children:"Delete"})]})]})})]})}function aa({selectedCount:a,folders:t,onDelete:s,onMove:l,onAddTags:n,onRemoveTags:r,onClear:c,isPending:h}){const[o,i]=u.useState(null),[x,g]=u.useState(""),[m,d]=u.useState([]);function b(){i(null),g(""),d([])}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 min-w-0",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:[a," selected"]}),e.jsx(k,{size:"sm",variant:"ghost",onClick:c,disabled:h,children:e.jsx(pe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto rounded-md border bg-muted/50 px-3 py-2 max-w-[calc(100vw-1.5rem)]",children:[e.jsx(k,{size:"sm",variant:"destructive",onClick:()=>i("delete"),disabled:h,className:"shrink-0",children:"Delete"}),e.jsx(k,{size:"sm",variant:"outline",onClick:()=>i("move"),disabled:h,className:"shrink-0",children:"Move to…"}),e.jsx(k,{size:"sm",variant:"outline",onClick:()=>i("addTags"),disabled:h,className:"shrink-0",children:"Add tags"}),e.jsx(k,{size:"sm",variant:"outline",onClick:()=>i("removeTags"),disabled:h,className:"shrink-0",children:"Remove tags"})]})]}),e.jsx(le,{open:o==="delete",onOpenChange:p=>!p&&b(),children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsxs(de,{children:["Delete ",a," item",a!==1?"s":"","?"]}),e.jsx(he,{children:"This action cannot be undone. The selected media items will be permanently deleted."})]}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(k,{variant:"destructive",onClick:async()=>{b(),await s()},disabled:h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})}),e.jsx(le,{open:o==="move",onOpenChange:p=>!p&&b(),children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsxs(de,{children:["Move ",a," item",a!==1?"s":""]}),e.jsx(he,{children:"Choose a destination folder."})]}),e.jsxs(ge,{value:x,onValueChange:g,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Select folder..."})}),e.jsxs(je,{children:[e.jsx(se,{value:"__unfiled__",children:"Unfiled"}),t.map(p=>e.jsx(se,{value:p.folderId,children:p.name},p.folderId))]})]}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(k,{onClick:async()=>{const p=x==="__unfiled__"?"":x;b(),await l(p)},disabled:!x||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Move"]})]})]})}),e.jsx(le,{open:o==="addTags",onOpenChange:p=>!p&&b(),children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsxs(de,{children:["Add tags to ",a," item",a!==1?"s":""]}),e.jsx(he,{className:"sr-only",children:"Select tags to add to the selected items"})]}),e.jsx(Pe,{tags:m,onChange:d,placeholder:"Add tags..."}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(k,{onClick:async()=>{const p=[...m];b(),await n(p)},disabled:m.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Add"]})]})]})}),e.jsx(le,{open:o==="removeTags",onOpenChange:p=>!p&&b(),children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsxs(de,{children:["Remove tags from ",a," item",a!==1?"s":""]}),e.jsx(he,{className:"sr-only",children:"Select tags to remove from the selected items"})]}),e.jsx(Pe,{tags:m,onChange:d,placeholder:"Tags to remove..."}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(k,{onClick:async()=>{const p=[...m];b(),await r(p)},disabled:m.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Remove"]})]})]})})]})}function na({onFiles:a,children:t}){const[s,l]=u.useState(!1),n=u.useRef(0),r=u.useCallback(i=>{i.preventDefault(),i.dataTransfer.types.includes("Files")&&(n.current++,l(!0))},[]),c=u.useCallback(i=>{i.preventDefault(),n.current--,n.current===0&&l(!1)},[]),h=u.useCallback(i=>{i.preventDefault(),i.dataTransfer.dropEffect="copy"},[]),o=u.useCallback(i=>{i.preventDefault(),n.current=0,l(!1);const x=Array.from(i.dataTransfer.files);x.length>0&&a(x)},[a]);return e.jsxs("div",{className:"relative flex-1",onDragEnter:r,onDragLeave:c,onDragOver:h,onDrop:o,children:[t,s&&e.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center rounded-lg border-2 border-dashed border-primary bg-primary/5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg bg-background/90 px-6 py-4 shadow-lg",children:[e.jsx(Ne,{className:"h-8 w-8 text-primary"}),e.jsx("p",{className:"text-lg font-medium",children:"Drop files to upload"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Files will be uploaded to the current folder"})]})})]})}function ra({queue:a}){const{items:t,retry:s,dismiss:l,clearCompleted:n}=a,[r,c]=u.useState(!1),h=t.filter(d=>d.status==="uploading").length,o=t.filter(d=>d.status==="pending").length,i=t.filter(d=>d.status==="complete").length,x=t.filter(d=>d.status==="error").length,g=h===0&&o===0;if(u.useEffect(()=>{if(g&&t.length>0){const d=setTimeout(()=>c(!0),2e3);return()=>clearTimeout(d)}},[g,t.length]),t.length===0)return null;const m=g?`${i} uploaded${x?`, ${x} failed`:""}`:`Uploading ${h+o} file${h+o!==1?"s":""}`;return e.jsxs("div",{className:"fixed bottom-4 right-4 z-50 w-80 rounded-lg border bg-background shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:m}),e.jsxs("div",{className:"flex items-center gap-1",children:[g&&e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:n,children:"Clear"}),e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>c(!r),children:r?e.jsx(Gt,{className:"h-4 w-4"}):e.jsx(Zt,{className:"h-4 w-4"})})]})]}),!r&&e.jsx("div",{className:"max-h-60 overflow-y-auto",children:t.map(d=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm",children:[d.status==="uploading"&&e.jsx(ee,{className:"h-4 w-4 shrink-0 animate-spin"}),d.status==="complete"&&e.jsx(js,{className:"h-4 w-4 shrink-0 text-green-500"}),d.status==="error"&&e.jsx(pe,{className:"h-4 w-4 shrink-0 text-destructive"}),d.status==="pending"&&e.jsx("div",{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate",children:d.file.name}),d.status==="uploading"&&e.jsx("div",{className:"bg-muted mt-0.5 h-1 w-full rounded-full",children:e.jsx("div",{className:"bg-primary h-full rounded-full transition-all",style:{width:`${d.progress}%`}})}),d.status==="error"&&e.jsx("p",{className:"text-destructive truncate text-xs",children:d.error})]}),d.status==="error"&&e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>s(d.id),children:e.jsx(Us,{className:"h-3 w-3"})}),(d.status==="complete"||d.status==="error")&&e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>l(d.id),children:e.jsx(pe,{className:"h-3 w-3"})})]},d.id))})]})}const ia=3;let la=0;function oa(a,t){const[s,l]=u.useState([]),n=Ft(a),r=Pt(a),c=u.useRef(0),h=u.useRef(s);h.current=s;const o=u.useRef(new Map),i=u.useCallback(async p=>{c.current++,l(j=>j.map(w=>w.id===p.id?{...w,status:"uploading",progress:0}:w));try{const{uploadUrl:j,mediaId:w}=await n.mutateAsync({filename:p.file.name,contentType:p.file.type,size:p.file.size});await new Promise((A,_)=>{const I=new XMLHttpRequest;o.current.set(p.id,I),I.upload.onprogress=E=>{if(E.lengthComputable){const F=Math.round(E.loaded/E.total*100);l(y=>y.map(N=>N.id===p.id?{...N,progress:F}:N))}},I.onload=()=>{o.current.delete(p.id),I.status>=200&&I.status<300?A():_(new Error(`Upload failed: ${I.status}`))},I.onerror=()=>{o.current.delete(p.id),_(new Error("Network error"))},I.onabort=()=>{o.current.delete(p.id),_(new Error("Upload aborted"))},I.open("PUT",j),I.setRequestHeader("Content-Type",p.file.type),I.send(p.file)}),await r.mutateAsync({mediaId:w,filename:p.file.name,folderId:p.folderId}),l(A=>A.map(_=>_.id===p.id?{..._,status:"complete",progress:100}:_))}catch(j){l(w=>w.map(A=>A.id===p.id?{...A,status:"error",error:j instanceof Error?j.message:"Upload failed"}:A))}finally{c.current--}},[n,r]),x=u.useRef(i);x.current=i,u.useEffect(()=>{const p=s.filter(w=>w.status==="pending"),j=ia-c.current;for(let w=0;w<Math.min(p.length,j);w++)x.current(p[w])},[s]),u.useEffect(()=>{const p=o.current;return()=>{p.forEach(j=>j.abort())}},[]);const g=u.useCallback(p=>{const j=Array.from(p).map(w=>({id:`upload-${la++}`,file:w,folderId:t||void 0,status:"pending",progress:0}));l(w=>[...w,...j])},[t]),m=u.useCallback(p=>{l(j=>j.map(w=>w.id===p?{...w,status:"pending",progress:0,error:void 0}:w))},[]),d=u.useCallback(p=>{l(j=>j.filter(w=>w.id!==p))},[]),b=u.useCallback(()=>{l(p=>p.filter(j=>j.status!=="complete"&&j.status!=="error"))},[]);return{items:s,addFiles:g,retry:m,dismiss:d,clearCompleted:b}}function ca({items:a,currentIndex:t,onClose:s,onNavigate:l}){const n=a[t],r=t>0,c=t<a.length-1,h=u.useRef(null),o=u.useCallback(i=>{i.key==="Escape"?s():i.key==="ArrowLeft"&&r?l(t-1):i.key==="ArrowRight"&&c&&l(t+1)},[s,l,t,r,c]);return u.useEffect(()=>(document.addEventListener("keydown",o),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",o),document.body.style.overflow=""}),[o]),n?e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/90",onClick:s,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 text-white",onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"min-w-0 flex-1 text-sm",children:[e.jsx("span",{className:"font-medium truncate block",children:n.filename}),e.jsxs("span",{className:"opacity-70 text-xs",children:[n.width&&n.height&&`${n.width}×${n.height} · `,ve(n.size)]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs("span",{className:"text-sm opacity-70",children:[t+1," / ",a.length]}),e.jsx(k,{variant:"ghost",size:"icon",className:"text-white hover:bg-white/20",onClick:s,children:e.jsx(pe,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative flex flex-1 items-center justify-center px-4 md:px-16",onClick:i=>i.stopPropagation(),onTouchStart:i=>{h.current=i.touches[0].clientX},onTouchEnd:i=>{if(h.current===null)return;const x=i.changedTouches[0].clientX-h.current;h.current=null,x>50&&r?l(t-1):x<-50&&c&&l(t+1)},children:[e.jsx("img",{src:W(n.url),alt:n.alt||n.filename,className:"max-h-full max-w-full object-contain"}),r&&e.jsx(k,{variant:"ghost",size:"icon",className:"absolute left-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t-1),children:e.jsx(ys,{className:"h-8 w-8"})}),c&&e.jsx(k,{variant:"ghost",size:"icon",className:"absolute right-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t+1),children:e.jsx(ls,{className:"h-8 w-8"})})]})]}):null}function da({open:a,duplicates:t,fileCount:s,onContinue:l,onCancel:n}){return e.jsx(Oe,{open:a,onOpenChange:r=>!r&&n(),children:e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(Le,{children:"Possible duplicates found"}),e.jsx(Xe,{children:s===1?"A file with the same name and size already exists:":`${t.length} of ${s} files may already exist:`})]}),e.jsx("div",{className:"max-h-48 space-y-2 overflow-y-auto",children:t.map(r=>e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[r.mimeType.startsWith("image/")&&r.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(r.urls?.thumb_sm??r.url),alt:r.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(_e,{mimeType:r.mimeType,className:"h-6 w-6"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:r.filename}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[ve(r.size)," ·"," ",Ve(r.uploadedAt)]})]})]},r.mediaId))}),e.jsxs(Ye,{children:[e.jsx(Be,{onClick:n,children:"Cancel"}),e.jsx(Ke,{onClick:l,children:"Upload Anyway"})]})]})})}function ha(a){const[t,s]=u.useState(()=>{try{const n=localStorage.getItem(`viewMode:${a}`);if(n==="grid"||n==="list")return n}catch{}return"grid"}),l=u.useCallback(n=>{s(n);try{localStorage.setItem(`viewMode:${a}`,n)}catch{}},[a]);return[t,l]}const ma=({activatorEvent:a,draggingNodeRect:t,transform:s})=>{if(a&&t){const l=a;if(l.clientX!==void 0)return{...s,x:s.x+l.clientX-t.left-t.width/2,y:s.y+l.clientY-t.top-t.height/2}}return s},ua=[{value:"date_desc",label:"Newest first"},{value:"date_asc",label:"Oldest first"},{value:"name_asc",label:"Name A-Z"},{value:"name_desc",label:"Name Z-A"},{value:"size_desc",label:"Size (largest)"},{value:"size_asc",label:"Size (smallest)"}];function xa({item:a,selected:t,onToggle:s,onClick:l,folderName:n,onLightbox:r}){const{attributes:c,listeners:h,setNodeRef:o,isDragging:i}=ht({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),x=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";function g(m){m.stopPropagation(),navigator.clipboard.writeText(W(a.url)),M.success("URL copied to clipboard")}return e.jsx(qt,{ref:o,...c,...h,className:O("group relative cursor-pointer overflow-hidden",i&&"opacity-50",t&&"ring-2 ring-primary"),onClick:l,children:e.jsxs(Qt,{className:"p-0",children:[e.jsx("div",{className:O("absolute left-2 top-2 z-10 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:rounded [@media(hover:none)]:bg-black/30 [@media(hover:none)]:p-0.5",t&&"opacity-100"),onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(Te,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex gap-1 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:[e.jsx(Ce,{children:e.jsxs(ke,{children:[e.jsx(De,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:g,children:e.jsx(qe,{className:"h-3.5 w-3.5"})})}),e.jsx(Se,{children:"Copy URL"})]})}),x&&r&&e.jsx(Ce,{children:e.jsxs(ke,{children:[e.jsx(De,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:m=>{m.stopPropagation(),r()},children:e.jsx($s,{className:"h-3.5 w-3.5"})})}),e.jsx(Se,{children:"View full size"})]})})]}),x?e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx("img",{src:W(a.urls?.thumb_md??a.url),alt:a.alt||a.filename,className:"h-full w-full object-cover"})}):e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx(_e,{mimeType:a.mimeType,className:"h-12 w-12"})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a.filename}),n&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(te,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate text-xs",children:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:ve(a.size)}),e.jsx(Ce,{children:e.jsxs(ke,{children:[e.jsx(De,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ve(a.uploadedAt)})}),e.jsx(Se,{children:We(a.uploadedAt)})]})})]}),a.tags.length>0&&e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(m=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-0.5 text-[10px]",children:m},m)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})]})]})})}function Aa(){const{host:a}=Dt(),t=us(),[s,l]=ha("media"),[n,r]=u.useState("date_desc"),[c,h]=u.useState(""),[o,i]=u.useState(""),[x,g]=u.useState(null),[m,d]=u.useState(null),[b,p]=u.useState(void 0),[j,w]=u.useState(new Set),[A,_]=u.useState(null),[I,E]=u.useState(null),[F,y]=u.useState(null),[N,P]=u.useState([]),[X,ue]=u.useState(!1),J=u.useRef(null),xe=oa(a,m&&m!=="unfiled"?m:void 0),v=Ot(a),R=Ut(a),q=os(cs(ms,{activationConstraint:{distance:t?1e5:8}}));u.useEffect(()=>{const f=setTimeout(()=>{i(C=>{const D=c;return C!==D&&w(new Set),D})},300);return()=>clearTimeout(f)},[c]);const ae=m===null?void 0:m==="unfiled"?"":m,{data:$,isLoading:xt}=Ht(a,{sort:n,q:o||void 0,folderId:ae,tag:b}),{data:Ze}=ct(a),ye=u.useMemo(()=>Ze?.items??[],[Ze?.items]),Ie=u.useMemo(()=>{const f=new Map;for(const C of ye)f.set(C.folderId,C.name);return f},[ye]),be=u.useMemo(()=>($?.items??[]).filter(f=>f.mimeType.startsWith("image/")&&f.mimeType!=="image/svg+xml"),[$?.items]),Re=u.useMemo(()=>{const f=new Map;return be.forEach((C,D)=>f.set(C.mediaId,D)),f},[be]),{allTags:pt,allUserTags:gt}=u.useMemo(()=>{const f=$?.items??[],C=new Set,D=new Set;for(const z of f){for(const Y of z.tags)C.add(Y);for(const Y of z.userTags??[])D.add(Y)}return{allTags:Array.from(C).sort(),allUserTags:Array.from(D).sort()}},[$?.items]),Ae=$?.items.map(f=>f.mediaId)??[],ze=Ae.length>0&&Ae.every(f=>j.has(f));function Je(f){w(C=>{const D=new Set(C);return D.has(f)?D.delete(f):D.add(f),D})}function et(){w(ze?new Set:new Set(Ae))}async function ft(){const f=[...j],D=(await v.mutateAsync({mediaIds:f,action:"delete"})).failed.length;D?M.error(`${D} of ${f.length} failed to delete`):M.success(`${f.length} item(s) deleted`),w(new Set)}async function wt(f){const C=[...j],z=(await v.mutateAsync({mediaIds:C,action:"move",folderId:f})).failed.length;z?M.error(`${z} of ${C.length} failed to move`):M.success(`${C.length} item(s) moved`),w(new Set)}async function jt(f){const C=[...j],z=(await v.mutateAsync({mediaIds:C,action:"addTags",tags:f})).failed.length;z?M.error(`${z} of ${C.length} failed`):M.success(`Tags added to ${C.length} item(s)`),w(new Set)}async function vt(f){const C=[...j],z=(await v.mutateAsync({mediaIds:C,action:"removeTags",tags:f})).failed.length;z?M.error(`${z} of ${C.length} failed`):M.success(`Tags removed from ${C.length} item(s)`),w(new Set)}async function tt(f){const C=Array.from(f),D=C.slice(0,5),z=[];for(const Y of D)try{const Ee=await R.mutateAsync({filename:Y.name,size:Y.size});z.push(...Ee.duplicates)}catch{}z.length>0?(y(C),P(z)):xe.addFiles(C)}function yt(f){f.target.files&&tt(f.target.files),J.current&&(J.current.value="")}function bt(f){_(String(f.active.id))}function Nt(f){_(null);const{active:C,over:D}=f;if(!D||D.data.current?.type!=="folder")return;const z=D.id==="unfiled"||D.id==="all-media"?"":String(D.id),Y=j.has(String(C.id))?[...j]:[String(C.id)];v.mutateAsync({mediaIds:Y,action:"move",folderId:z}).then(Ee=>{const at=Ee.failed.length;at?M.error(`${at} of ${Y.length} failed to move`):M.success(`${Y.length} item(s) moved`)})}function Ct(){_(null)}const Q=A?$?.items.find(f=>f.mediaId===A):null,st=A&&j.has(A)?j.size:1;return e.jsxs(ds,{sensors:q,modifiers:[ma],onDragStart:bt,onDragEnd:Nt,onDragCancel:Ct,children:[e.jsxs("div",{className:"-m-2 md:-m-6 relative flex min-h-[calc(100dvh-3.5rem)] md:h-[calc(100vh-3.5rem)]",children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(ot,{host:a,selectedFolderId:m,onSelect:f=>{d(f),w(new Set)}})}),e.jsx(Bt,{open:X,onOpenChange:ue,children:e.jsxs(Kt,{side:"left",className:"w-64 p-0 pt-[env(safe-area-inset-top,0px)] pl-[env(safe-area-inset-left,0px)] [&_[data-slot=sheet-close]]:top-[calc(1rem+env(safe-area-inset-top,0px))]","data-testid":"folder-overlay-backdrop",children:[e.jsx(Vt,{className:"sr-only",children:"Folders"}),e.jsx(ot,{host:a,selectedFolderId:m,onSelect:f=>{d(f),w(new Set),ue(!1)}})]})}),e.jsxs(na,{onFiles:f=>tt(f),children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 md:p-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Media"}),e.jsxs("div",{children:[e.jsx("input",{ref:J,type:"file",multiple:!0,className:"hidden",onChange:yt}),e.jsxs(k,{onClick:()=>J.current?.click(),children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),"Upload"]})]})]}),j.size>0?e.jsx(aa,{selectedCount:j.size,folders:ye,onDelete:ft,onMove:wt,onAddTags:jt,onRemoveTags:vt,onClear:()=>w(new Set),isPending:v.isPending}):e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative min-w-[200px] max-w-sm flex-1",children:[e.jsx(rt,{className:"text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4"}),e.jsx(V,{placeholder:"Search media...",value:c,onChange:f=>h(f.target.value),className:"pl-9"})]}),e.jsxs(ge,{value:n,onValueChange:r,children:[e.jsx(fe,{className:"w-[160px]",children:e.jsx(we,{})}),e.jsx(je,{children:ua.map(f=>e.jsx(se,{value:f.value,children:f.label},f.value))})]}),e.jsx(k,{variant:X?"secondary":"ghost",size:"sm",className:"md:hidden px-2",onClick:()=>ue(!X),"aria-label":"Toggle folders",children:e.jsx(Ts,{className:"h-4 w-4"})}),!X&&m!==null&&t&&e.jsxs(Qe,{variant:"secondary",className:"gap-1 md:hidden",children:[e.jsx(te,{className:"h-3 w-3"}),m==="unfiled"?"Unfiled":Ie.get(m)??"All Media"]}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx(k,{variant:s==="grid"?"secondary":"ghost",size:"sm",className:"rounded-r-none px-2",onClick:()=>l("grid"),children:e.jsx(Rs,{className:"h-4 w-4"})}),e.jsx(k,{variant:s==="list"?"secondary":"ghost",size:"sm",className:"rounded-l-none px-2",onClick:()=>l("list"),children:e.jsx(zs,{className:"h-4 w-4"})})]})]}),e.jsx(sa,{tags:pt,activeTag:b,onTagChange:f=>{p(f),w(new Set)}}),s==="grid"&&($?.items.length??0)>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Te,{checked:ze,onCheckedChange:et,"aria-label":"Select all"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:j.size>0?`${j.size} of ${$.items.length} selected`:"Select all"})]}),xt?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((f,C)=>e.jsx(Wt,{className:"aspect-square"},C))}):$?.items.length?s==="list"?e.jsx(Xs,{items:$.items,host:a,onSelect:g,selectedIds:j,onToggle:Je,onToggleAll:et,allSelected:ze,folderMap:m===null?Ie:void 0,onLightbox:f=>{const C=Re.get(f.mediaId);C!==void 0&&E(C)}}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:$.items.map(f=>e.jsx(xa,{item:f,selected:j.has(f.mediaId),onToggle:()=>Je(f.mediaId),onClick:()=>g(f),folderName:m===null?Ie.get(f.folderId??""):void 0,onLightbox:Re.has(f.mediaId)?()=>E(Re.get(f.mediaId)):void 0},f.mediaId))}):e.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:o||b?e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No results found"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Try adjusting your search or filters."})]}):m==="unfiled"?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No unfiled media"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"All media items are organized in folders."})]}):m?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"This folder is empty"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload files or drag media into this folder."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No media yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload your first file to get started."}),e.jsxs(k,{className:"mt-4",onClick:()=>J.current?.click(),children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),"Upload"]})]})}),x&&e.jsx(ta,{host:a,media:x,onClose:()=>g(null),onDeleted:f=>{w(C=>{if(!C.has(f))return C;const D=new Set(C);return D.delete(f),D})},folders:ye,tagSuggestions:gt})]}),e.jsx(ra,{queue:xe})]})]}),I!==null&&be.length>0&&e.jsx(ca,{items:be,currentIndex:I,host:a,onClose:()=>E(null),onNavigate:E}),e.jsx(da,{open:N.length>0,host:a,duplicates:N,fileCount:F?Array.from(F).length:0,onContinue:()=>{F&&xe.addFiles(F),y(null),P([])},onCancel:()=>{y(null),P([])}}),e.jsx(hs,{children:A&&Q&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-background p-2 shadow-lg",children:[Q.mimeType.startsWith("image/")&&Q.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(Q.urls?.thumb_sm??Q.url),alt:Q.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(_e,{mimeType:Q.mimeType,className:"h-6 w-6"})}),e.jsx("span",{className:"text-sm font-medium",children:st>1?`Moving ${st} items`:Q.filename})]})})]})}export{Aa as MediaPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,a as Q}from"./tanstack-BO6c-AOu.js";import{u as R,e as G,r as h}from"./react-vendor-DNVhVxD7.js";import{a8 as K,S as b,ac as Z,ad as z,ae as J,a7 as M,L as m,I as c,B as i,a as u,af as V,D as A,j as P,k,l as T,m as F,n as E,t as n}from"./index-CwkwXbO-.js";import{B as W}from"./badge-ChZ2DZue.js";import{C as g,a as p,b as f,c as S}from"./card-DpNr7WTb.js";import{f as X}from"./format-C88SDH8g.js";import"./radix-n1vDIPi6.js";function re(){const{host:a}=R(),{data:r,isLoading:t}=K(a);return t?e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{className:"h-8 w-64"}),e.jsx(b,{className:"h-48 w-full"})]}):r?e.jsx(Y,{site:r},r.host):e.jsx("p",{className:"text-muted-foreground",children:"Site not found."})}function Y({site:a}){const r=Q(),t=Z(a.host),x=z(a.host),j=J(a.host),y=G(),C=M()==="admin",v=a.status==="archived",[N,O]=h.useState(a.name),[B,l]=h.useState(!1),[L,d]=h.useState(!1),[D,o]=h.useState("");async function U(s){s.preventDefault();try{await t.mutateAsync({name:N}),n.success("Site updated")}catch(w){n.error("Failed to update site",{description:w instanceof Error?w.message:void 0})}}async function q(){try{await t.mutateAsync({status:"archived"}),n.success("Site archived"),l(!1),y("/sites")}catch(s){n.error("Failed to archive site",{description:s instanceof Error?s.message:void 0})}}async function H(){try{await t.mutateAsync({status:"active"}),n.success("Site unarchived")}catch(s){n.error("Failed to unarchive site",{description:s instanceof Error?s.message:void 0})}}async function I(){try{await x.mutateAsync(),await j.mutateAsync(),await r.invalidateQueries({queryKey:["sites"]}),n.success("Site deleted"),d(!1),o(""),y("/sites")}catch(s){n.error("Failed to delete site",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Site Settings"}),e.jsxs(g,{children:[e.jsx(p,{children:e.jsx(f,{children:"General"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"name",children:"Site Name"}),e.jsx(c,{id:"name",value:N,onChange:s=>O(s.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Host"}),e.jsx(c,{value:a.host,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Status"}),e.jsx("div",{className:"flex items-center gap-2",children:v?e.jsx(W,{variant:"outline",children:"Archived"}):e.jsx(c,{value:a.status,disabled:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Created"}),e.jsx(c,{value:X(a.createdAt),disabled:!0})]}),e.jsxs(i,{type:"submit",disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),C&&e.jsxs(g,{className:"mt-6",children:[e.jsx(p,{children:e.jsx(f,{children:"Site Status"})}),e.jsx(S,{className:"space-y-4",children:v?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"This site is archived. Unarchive it to allow content changes."}),e.jsxs(i,{variant:"outline",onClick:H,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Unarchive Site"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Archiving a site makes it read-only. Content cannot be created or modified while archived."}),e.jsxs(i,{variant:"outline",onClick:()=>l(!0),children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Archive Site"]}),e.jsx(A,{open:B,onOpenChange:l,children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Archive Site"}),e.jsxs(F,{children:["Are you sure you want to archive ",e.jsx("strong",{children:a.host}),"? The site will become read-only."]})]}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(i,{onClick:q,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Archive"]})]})]})})]})})]}),C&&v&&e.jsxs(g,{className:"border-destructive mt-6",children:[e.jsx(p,{children:e.jsx(f,{className:"text-destructive",children:"Danger Zone"})}),e.jsxs(S,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Permanently delete this site and all its content, media, collections, and block types. This action cannot be undone."}),e.jsx(i,{variant:"destructive",onClick:()=>d(!0),children:"Delete Site"}),e.jsx(A,{open:L,onOpenChange:s=>{d(s),s||o("")},children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Delete Site"}),e.jsxs(F,{children:["This will permanently delete this site and all its content. Type ",e.jsx("strong",{children:a.host})," to confirm."]})]}),e.jsx(c,{placeholder:a.host,value:D,onChange:s=>o(s.target.value)}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>{d(!1),o("")},children:"Cancel"}),e.jsxs(i,{variant:"destructive",onClick:I,disabled:D!==a.host||x.isPending||j.isPending,children:[(x.isPending||j.isPending)&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete Everything"]})]})]})})]})]})]})}export{re as SiteSettingsPage};
|