headroom-cms 0.1.5 → 0.1.6
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-C4tJy6Vj.js → AdminsPage-BqfhR4Zc.js} +1 -1
- package/admin/assets/{AllContentPage-DL0-UlYh.js → AllContentPage-C11eeRMt.js} +1 -1
- package/admin/assets/{ApiKeysPage-pZ6nKCZ_.js → ApiKeysPage-DJjOSLoR.js} +1 -1
- package/admin/assets/AuditPage-DJNk7IaW.js +1 -0
- package/admin/assets/{BlockEditor-D0Jk8u7w.js → BlockEditor-DDsml97y.js} +2 -2
- package/admin/assets/BlockTypeEditPage-Cg7BifaZ.js +1 -0
- package/admin/assets/{BlockTypesPage-Q7keQKxn.js → BlockTypesPage-BDFj8TSL.js} +1 -1
- package/admin/assets/{BulkActionBar-BGDrNwCg.js → BulkActionBar-CastJGEP.js} +1 -1
- package/admin/assets/CollectionEditPage-DGW4iMfo.js +1 -0
- package/admin/assets/{CollectionsPage-DDZ-5H7Y.js → CollectionsPage-C8XNxRda.js} +1 -1
- package/admin/assets/{ContentCreatePage-C3jn0Etf.js → ContentCreatePage-CX4aOzTR.js} +1 -1
- package/admin/assets/ContentEditPage-Dj3RK2BF.js +2 -0
- package/admin/assets/ContentListPage-CoDanHrR.js +1 -0
- package/admin/assets/{CustomBlockPreview-f9j4g35U.js → CustomBlockPreview-DfDOcbmR.js} +1 -1
- package/admin/assets/{FieldBuilder-p1Y8RubR.js → FieldBuilder-8VVLG_j0.js} +2 -2
- package/admin/assets/FilterBar-JCp03kkK.js +1 -0
- package/admin/assets/{LoginPage-9YUPS1YH.js → LoginPage-gPNC9XRN.js} +1 -1
- package/admin/assets/{MediaField-DJpYbUA8.js → MediaField-Du7_gRse.js} +1 -1
- package/admin/assets/MediaPage-D9763lEk.js +1 -0
- package/admin/assets/RelationshipPicker-D7dFI43Q.js +1 -0
- package/admin/assets/SiteSettingsPage-Tfiex2yn.js +1 -0
- package/admin/assets/{SiteUsersPage-CtVaB0vq.js → SiteUsersPage-CSV8syR3.js} +1 -1
- package/admin/assets/{SitesPage-B-sNyP-Y.js → SitesPage-BFIZ3Y5K.js} +1 -1
- package/admin/assets/SubmissionDetailPage-8vtUQsLd.js +1 -0
- package/admin/assets/SubmissionEditPage-PgowJuvq.js +1 -0
- package/admin/assets/SubmissionListPage-HFDQxPhn.js +1 -0
- package/admin/assets/{TagInput-CrI2BIuz.js → TagInput-CDkKZboX.js} +1 -1
- package/admin/assets/{TagsPage-BSX5KQvZ.js → TagsPage-BW15-W4H.js} +1 -1
- package/admin/assets/{UsersPage-BCTpWULa.js → UsersPage-C-zlDeTy.js} +1 -1
- package/admin/assets/{WebhookEditPage-CQO3nmaT.js → WebhookEditPage-cPPALIbH.js} +1 -1
- package/admin/assets/{WebhooksPage-ByaTlUGU.js → WebhooksPage-vkPC4m9a.js} +1 -1
- package/admin/assets/{card-uKxSQehY.js → card-10FqkZPA.js} +1 -1
- package/admin/assets/{checkbox-z1kYnX5o.js → checkbox-fC1QPb_4.js} +1 -1
- package/admin/assets/collapsible-B414SspL.js +1 -0
- package/admin/assets/{command-CuWC4GrT.js → command-BeacdV75.js} +1 -1
- package/admin/assets/{index-HoCNSqv2.css → index-Do_SK4Zl.css} +1 -1
- package/admin/assets/{index-b-u0-VCO.js → index-wYNPRVrc.js} +12 -12
- package/admin/assets/{popover-rcnajqN6.js → popover-BJDj8C6y.js} +1 -1
- package/admin/assets/{select-BKaV0BO_.js → select-BV3jemT6.js} +1 -1
- package/admin/assets/{serializeToText-BfR2RCzd.js → serializeToText-BJy0Ms5I.js} +1 -1
- package/admin/assets/sortable.esm-QyXA6fio.js +1 -0
- package/admin/assets/{table-Bozosvl6.js → table-WkEcC9MH.js} +1 -1
- package/admin/assets/{textarea-BnjAxJtk.js → textarea-CHQ9tT69.js} +1 -1
- package/admin/assets/{useAdminResolver-B0ady82Q.js → useAdminResolver-CpZj93vH.js} +1 -1
- package/admin/assets/useContent-D8yDRTTy.js +1 -0
- package/admin/assets/useContentSearch-B-_p0_QX.js +1 -0
- package/admin/assets/useFilterParams-DYdEuWPE.js +1 -0
- package/admin/assets/{useMedia-CXQpRNYL.js → useMedia-m6zKB__r.js} +1 -1
- package/admin/assets/usePageTitle-Bwf-MpTD.js +1 -0
- package/admin/assets/{useSiteUsers-BfzIdhvs.js → useSiteUsers-QbiItSH1.js} +1 -1
- package/admin/assets/{useTags-B6FtXCHF.js → useTags-CLPWVUB3.js} +1 -1
- package/admin/assets/{useWebhooks-iPRX5y4s.js → useWebhooks-no0l3-mF.js} +1 -1
- package/admin/index.html +3 -3
- package/admin/sw.js +1 -1
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/cdn.js +1 -1
- package/dist/cdn.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/lambda/api/bootstrap +0 -0
- package/lambda/image-lambda/index.mjs +1 -1
- package/lambda/webhook-worker/bootstrap +0 -0
- package/package.json +1 -1
- package/src/api.ts +2 -1
- package/src/cdn.ts +1 -1
- package/src/index.ts +1 -0
- package/admin/assets/AuditPage-aVmcP6Ts.js +0 -1
- package/admin/assets/BlockTypeEditPage-DIe2yYEr.js +0 -1
- package/admin/assets/CollectionEditPage-Bq75MpXk.js +0 -1
- package/admin/assets/ContentEditPage-9tODvFEv.js +0 -2
- package/admin/assets/ContentListPage-VCT6GTCF.js +0 -1
- package/admin/assets/MediaPage-BgDRQR21.js +0 -1
- package/admin/assets/SiteSettingsPage-Diy-PauR.js +0 -1
- package/admin/assets/SubmissionDetailPage-DW6QJvAy.js +0 -1
- package/admin/assets/SubmissionEditPage-CxYPdI9-.js +0 -1
- package/admin/assets/SubmissionListPage-BHF82NF3.js +0 -1
- package/admin/assets/sortable.esm-BHilUL-2.js +0 -1
- package/admin/assets/useContent-B2MUK4An.js +0 -1
- package/admin/assets/usePageTitle-Do4xyFdL.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlockEditor-D0Jk8u7w.js","assets/tanstack-Bs3zYPPV.js","assets/react-vendor-C2CvUxFh.js","assets/index-b-u0-VCO.js","assets/radix-C1kb_NqW.js","assets/index-HoCNSqv2.css","assets/command-CuWC4GrT.js","assets/MediaField-DJpYbUA8.js","assets/useMedia-CXQpRNYL.js","assets/select-BKaV0BO_.js","assets/card-uKxSQehY.js","assets/media-url-DIg_vSyf.js","assets/CustomBlockPreview-f9j4g35U.js","assets/useContent-B2MUK4An.js","assets/useAdminResolver-B0ady82Q.js","assets/usePageTitle-Do4xyFdL.js","assets/serializeToText-BfR2RCzd.js","assets/format-C88SDH8g.js","assets/textarea-BnjAxJtk.js","assets/TagInput-CrI2BIuz.js","assets/sortable.esm-BHilUL-2.js","assets/core.esm-B_kcYf6n.js","assets/useTags-B6FtXCHF.js","assets/popover-rcnajqN6.js","assets/useDebouncedValue-C-cQUcLG.js","assets/checkbox-z1kYnX5o.js","assets/contentStatus-BmaiYVOm.js","assets/BlockEditor-Cp_wZ2xN.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{j as e,u as Ct}from"./tanstack-Bs3zYPPV.js";import{r as d,u as Ss,f as St,m as wt,L as kt}from"./react-vendor-C2CvUxFh.js";import{f as Dt,g as ws,h as Pt,i as ks,j as It,k as At,l as Tt,m as Lt,n as Ft,o as Ot,p as Rt,q as Et,r as Ds}from"./useContent-B2MUK4An.js";import{C as De,v as P,E as Mt,y as Ps,F as Vt,G as $t,J as Bt,K as Ut,S as F,M as Is,N as As,O as me,Q as xe,e as Ts,R as Ls,V as G,j as se,B as g,X as ee,P as Me,I as pe,T as Fs,W as _t,x as Os,_ as Ht,L as X,w as zt,Y as Rs,Z as Wt,$ as fs,a0 as qt,a1 as gs,a2 as Kt,a as B,a3 as js,a4 as bs,a5 as Jt,a6 as vs,a7 as Se,a8 as Gt,a9 as Qt,D as Pe,k as Ie,l as Ae,m as Te,n as Le,o as Fe,aa as Yt,i as Xt}from"./index-b-u0-VCO.js";import{u as Zt}from"./useAdminResolver-B0ady82Q.js";import{u as en}from"./usePageTitle-Do4xyFdL.js";import{s as Z,T as sn,d as tn}from"./serializeToText-BfR2RCzd.js";import{S as Es,a as Ms,b as Vs,c as $s,d as he,e as nn,f as an,g as ln}from"./select-BKaV0BO_.js";import{f as z,a as we}from"./format-C88SDH8g.js";import{T as Bs}from"./textarea-BnjAxJtk.js";import{C as U,a as Oe,b as Re,c as _}from"./card-uKxSQehY.js";import{T as rn,A as cn,a as on,b as dn,c as un,d as hn,e as mn,f as xn,g as pn}from"./TagInput-CrI2BIuz.js";import{u as Us,S as Ve,v as $e,a as Be,C as _s,b as Hs,c as zs}from"./sortable.esm-BHilUL-2.js";import{u as fn}from"./useTags-B6FtXCHF.js";import{M as gn,a as jn}from"./MediaField-DJpYbUA8.js";import{u as bn}from"./useMedia-CXQpRNYL.js";import{m as vn}from"./media-url-DIg_vSyf.js";import{C as Ws,u as Ue,a as _e,P as He,D as ze,c as We}from"./core.esm-B_kcYf6n.js";import{P as yn,a as Nn,b as Cn}from"./popover-rcnajqN6.js";import{C as Sn,a as wn,b as kn,c as Dn,d as Pn,e as In}from"./command-CuWC4GrT.js";import{u as An}from"./useDebouncedValue-C-cQUcLG.js";import{C as Tn}from"./checkbox-z1kYnX5o.js";import{g as Ln,a as Fn,b as On}from"./contentStatus-BmaiYVOm.js";const Rn=3e3,En="__HEADROOM_API_URL__".replace(/\/+$/,"");function Mn(t,n,a,s){const i=Dt(t,n),r=d.useRef(null),o=d.useRef(a?JSON.stringify(a):""),h=d.useRef(void 0),[f,u]=d.useState(null),[j,N]=d.useState(null),c=d.useRef(!1),m=d.useCallback(x=>{JSON.stringify(x)!==o.current&&(r.current=x,clearTimeout(h.current),h.current=window.setTimeout(()=>{if(r.current){const I=r.current,y=JSON.stringify(I);r.current=null,i.mutate(I,{onSuccess:C=>{if(c.current){c.current=!1;return}o.current=y,u(Date.now()),C?.blockId&&N(C.blockId)},onError:C=>{C instanceof De&&C.code==="SLUG_TAKEN"?s?.():C instanceof De&&C.status===400&&P.error("Auto-save failed",{description:C.message})}})}},Rn))},[i,s]),p=d.useCallback(async x=>{if(clearTimeout(h.current),r.current){const k={...r.current};x?.createVersion&&(k.createVersion=!0);const I=JSON.stringify(r.current);r.current=null;const y=await i.mutateAsync(k);o.current=I,u(Date.now()),y?.blockId&&N(y.blockId)}else if(x?.createVersion&&o.current){const I={...JSON.parse(o.current),createVersion:!0},y=await i.mutateAsync(I);u(Date.now()),y?.blockId&&N(y.blockId)}},[i]),v=d.useCallback(()=>{clearTimeout(h.current),r.current=null},[]),S=d.useCallback(x=>{o.current=JSON.stringify(x)},[]),w=d.useCallback(()=>{clearTimeout(h.current),r.current=null,c.current=!0,N(null)},[]);return d.useEffect(()=>()=>{if(clearTimeout(h.current),r.current){const x=JSON.stringify(r.current),k=Mt(),I=`${En}/v1/admin/sites/${t}/content/${n}/draft`;fetch(I,{method:"PUT",body:x,headers:{"Content-Type":"application/json",...k?{Authorization:`Bearer ${k}`}:{}},keepalive:!0}).catch(()=>{}),r.current=null}},[t,n]),{schedule:m,flush:p,cancel:v,resetBaseline:S,discard:w,isSaving:i.isPending,lastSavedAt:f,lastSavedBlockId:j}}function Vn({lines:t}){return e.jsx("div",{className:"font-mono text-sm leading-relaxed",children:t.map((n,a)=>e.jsx("div",{style:{paddingLeft:`${n.indent*1.5}rem`},className:Ps("min-h-[1.5em]",n.type==="label"&&"text-muted-foreground font-semibold mt-1",n.type==="heading"&&"font-bold",n.type==="empty"&&"h-2"),children:n.text},a))})}function Ee(t){switch(t.kind){case"draft":return"Draft";case"published":return"Published";case"history":return z(t.createdAt)}}function fe(t){switch(t.kind){case"draft":return"draft";case"published":return"published";case"history":return`history:${t.blockId}`}}function ys({value:t,onChange:n,isPublished:a,versions:s,exclude:i,size:r}){const o=i?fe(i):null;function h(f){if(f==="draft")n({kind:"draft"});else if(f==="published")n({kind:"published"});else if(f.startsWith("history:")){const u=f.slice(8),j=s.find(N=>N.blockId===u);j&&n({kind:"history",blockId:j.blockId,createdAt:j.createdAt,title:j.title})}}return e.jsxs(Es,{value:fe(t),onValueChange:h,children:[e.jsx(Ms,{size:r,children:e.jsx(Vs,{children:Ee(t)})}),e.jsxs($s,{position:"popper",children:[o!=="draft"&&e.jsx(he,{value:"draft",children:"Draft"}),a&&o!=="published"&&e.jsx(he,{value:"published",children:"Published"}),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(nn,{}),e.jsxs(an,{children:[e.jsx(ln,{children:"Version History"}),s.map(f=>{const u=`history:${f.blockId}`;return u===o?null:e.jsx(he,{value:u,children:z(f.createdAt)},u)})]})]})]})]})}function Ns({ref:t,host:n,contentId:a,collectionFields:s,isSingleton:i,draftBody:r,draftMetadata:o,collectionRelationships:h,draftRelationships:f}){const u=t?.kind==="published",j=t?.kind==="history",N=j?t.blockId:null,{data:c,isLoading:m}=ws(n,a,u),{data:p,isLoading:v}=Pt(n,a,j?N:null),S=d.useMemo(()=>(h??[]).map(k=>({name:k.name,label:k.label})),[h]);function w(k){if(S.length!==0)return{defs:S,values:k??{}}}const x=d.useMemo(()=>{if(!t)return[];if(t.kind==="draft")return r?Z(s,r,i?void 0:o,w(f)):[];if(t.kind==="published"){if(!c)return[];const y=i?void 0:{title:c.title,slug:c.slug,snippet:c.snippet,tags:c.tags},C=c.relationships;return Z(s,c.body??{},y,w(C))}if(!p)return[];const k=i?void 0:{title:p.title,slug:p.slug,snippet:p.snippet,tags:p.tags},I=p.relationships;return Z(s,p.body??{},k,w(I))},[t,r,o,f,c,p,s,i,S]);return t?t.kind==="draft"?{lines:x,isLoading:!1,hasData:!!r}:t.kind==="published"?{lines:x,isLoading:m,hasData:!!c}:{lines:x,isLoading:v,hasData:!!p}:{lines:[],isLoading:!1,hasData:!1}}function $n({open:t,onOpenChange:n,host:a,contentId:s,collectionFields:i,isSingleton:r,isPublished:o,draftBody:h,draftMetadata:f,initialVersion:u,collectionRelationships:j,draftRelationships:N}){const[c,m]=d.useState(u??{kind:"published"}),[p,v]=d.useState({kind:"draft"}),[S,w]=d.useState(t),[x,k]=d.useState(u);if((t!==S||u!==x)&&(w(t),k(u),t)){const T=u??{kind:"published"};m(T),v(T.kind==="draft"?{kind:"published"}:{kind:"draft"})}fe(c)===fe(p)&&(c.kind!=="draft"?v({kind:"draft"}):o&&v({kind:"published"}));const{data:I}=ks(a,s),y=I?.items??[],C={host:a,contentId:s,collectionFields:i,isSingleton:r,draftBody:h,draftMetadata:f,collectionRelationships:j,draftRelationships:N},A=Ns({ref:c,...C}),D=Ns({ref:p,...C}),W=A.isLoading;return e.jsx(Vt,{open:t,onOpenChange:n,children:e.jsxs($t,{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(Bt,{children:e.jsxs(Ut,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground text-sm font-normal",children:"Viewing"}),e.jsx(ys,{value:c,onChange:m,isPublished:o,versions:y,size:"sm"})]})}),W&&e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(F,{className:"h-6 w-48"}),e.jsx(F,{className:"h-4 w-full"}),e.jsx(F,{className:"h-4 w-full"}),e.jsx(F,{className:"h-4 w-2/3"})]}),!W&&!A.hasData&&e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"No data available for this version."}),!W&&A.hasData&&e.jsx("div",{className:"p-4",children:e.jsxs(Is,{defaultValue:"changes",children:[e.jsxs(As,{variant:"line",className:"mb-4",children:[e.jsx(me,{value:"content",children:"Content"}),e.jsx(me,{value:"changes",children:"Changes"})]}),e.jsx(xe,{value:"content",children:e.jsx(Vn,{lines:A.lines})}),e.jsxs(xe,{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(ys,{value:p,onChange:v,isPublished:o,versions:y,exclude:c,size:"sm"})]}),D.isLoading?e.jsxs("div",{className:"space-y-4",children:[e.jsx(F,{className:"h-4 w-full"}),e.jsx(F,{className:"h-4 w-full"}),e.jsx(F,{className:"h-4 w-2/3"})]}):D.hasData?e.jsx(sn,{published:A.lines,draft:D.lines,leftLabel:Ee(c),rightLabel:Ee(p)}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No data available for comparison."})]})]})})]})})}function Bn(t,n,a){const s=Ts(),i=a?.length===1?a[0]:void 0,r=new URLSearchParams;return n?(r.set("q",n),r.set("search","full")):r.set("limit","5"),i&&r.set("collection",i),Ct({queryKey:["sites",t,"content-search",n,a??[]],queryFn:async()=>{const o=await s.apiFetch(`/v1/admin/sites/${t}/content?${r.toString()}`);return a&&a.length>1?{...o,items:o.items.filter(h=>a.includes(h.collection))}:o},enabled:!!t,staleTime:3e4})}function Un({field:t,value:n,onChange:a}){const{host:s}=Ss(),i=t.options,r=!!i?.multiple,o=i?.collections;return r?e.jsx(Hn,{host:s,collections:o,value:n??[],onChange:a}):e.jsx(_n,{host:s,collections:o,value:n,onChange:a})}function _n({host:t,collections:n,value:a,onChange:s}){const[i,r]=d.useState(!1),o=a?[a.contentId]:[];function h(f){s(f),r(!1)}return e.jsx("div",{children:a?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[e.jsx(G,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:a.title}),e.jsx(se,{variant:"secondary",children:a.collection}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:()=>s(null),children:e.jsx(ee,{className:"h-3 w-3"})})]}):e.jsx(ge,{host:t,collections:n,selectedIds:o,open:i,onOpenChange:r,onSelect:h,trigger:e.jsxs(g,{type:"button",variant:"outline",children:[e.jsx(G,{className:"mr-2 h-4 w-4"}),"Select Content"]})})})}function Hn({host:t,collections:n,value:a,onChange:s}){const i=Ue(_e(He)),[r,o]=d.useState(!1),h=a??[],f=h.map(m=>m.contentId),u=h.map(m=>m.contentId);function j(m){s([...h,m]),o(!1)}function N(m){s(h.filter((p,v)=>v!==m))}function c(m){const{active:p,over:v}=m;if(v&&p.id!==v.id){const S=h.findIndex(x=>x.contentId===String(p.id)),w=h.findIndex(x=>x.contentId===String(v.id));S!==-1&&w!==-1&&s(Be(h,S,w))}}return e.jsx(ze,{sensors:i,collisionDetection:We,onDragEnd:c,children:e.jsx(Ve,{items:f,strategy:$e,children:e.jsxs("div",{className:"space-y-2",children:[h.map(m=>e.jsx(qs,{id:m.contentId,contentRef:m,onRemove:()=>N(h.indexOf(m))},m.contentId)),e.jsx(ge,{host:t,collections:n,selectedIds:u,open:r,onOpenChange:o,onSelect:j,trigger:e.jsxs(g,{type:"button",variant:"outline",size:"sm",children:[e.jsx(Me,{className:"mr-2 h-3 w-3"}),"Add Content"]})})]})})})}function qs({id:t,contentRef:n,onRemove:a}){const{attributes:s,listeners:i,setNodeRef:r,transform:o,transition:h}=Us({id:t}),f={transform:Ws.Transform.toString(o),transition:h};return e.jsxs("div",{ref:r,style:f,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",...s,...i,children:e.jsx(Ls,{className:"h-4 w-4"})}),e.jsx(G,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:n.title}),e.jsx(se,{variant:"secondary",children:n.collection}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:a,className:"text-destructive",children:e.jsx(ee,{className:"h-3 w-3"})})]})}function ge({host:t,collections:n,selectedIds:a,open:s,onOpenChange:i,onSelect:r,trigger:o}){const[h,f]=d.useState(""),u=An(h,300),{data:j,isLoading:N}=Bn(t,u,n);return e.jsxs(yn,{open:s,onOpenChange:i,children:[e.jsx(Nn,{asChild:!0,children:o}),e.jsx(Cn,{className:"w-80 p-0",align:"start",children:e.jsxs(Sn,{shouldFilter:!1,children:[e.jsx(wn,{placeholder:"Search content...",value:h,onValueChange:f}),e.jsx(kn,{children:N?e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}):e.jsxs(e.Fragment,{children:[e.jsx(Dn,{children:"No content found."}),e.jsx(Pn,{heading:u.length===0?"Recent":void 0,children:j?.items.map(c=>{const m=a.includes(c.contentId);return e.jsxs(In,{value:c.contentId,disabled:m,onSelect:()=>r({contentId:c.contentId,collection:c.collection,slug:c.slug??"",title:c.title}),children:[e.jsx(G,{className:"h-4 w-4"}),e.jsx("span",{className:"flex-1 truncate",children:c.title}),e.jsx(se,{variant:"outline",className:"text-xs",children:c.collection})]},c.contentId)})})]})})]})})]})}function zn({relationships:t,values:n,onChange:a,host:s}){return e.jsxs(U,{children:[e.jsx(Oe,{children:e.jsx(Re,{children:"Relationships"})}),e.jsx(_,{className:"space-y-4",children:t.map(i=>i.multiple?e.jsx(qn,{rel:i,items:n[i.name]??[],host:s,onChange:r=>a({...n,[i.name]:r})},i.name):e.jsx(Wn,{rel:i,value:n[i.name]?.[0]??null,host:s,onChange:r=>a({...n,[i.name]:r?[r]:[]})},i.name))})]})}function Wn({rel:t,value:n,host:a,onChange:s}){const[i,r]=d.useState(!1),o=n?[n.contentId]:[];return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t.label}),n?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[e.jsx(G,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:n.title}),e.jsx(se,{variant:"secondary",children:n.collection}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:()=>s(null),children:e.jsx(ee,{className:"h-3 w-3"})})]}):e.jsx(ge,{host:a,collections:[t.targetCollection],selectedIds:o,open:i,onOpenChange:r,onSelect:h=>{s(h),r(!1)},trigger:e.jsxs(g,{type:"button",variant:"outline",size:"sm",children:[e.jsx(G,{className:"mr-2 h-4 w-4"}),"Select ",t.label]})})]})}function qn({rel:t,items:n,host:a,onChange:s}){const i=Ue(_e(He)),[r,o]=d.useState(!1),h=n.map(c=>c.contentId),f=n.map(c=>c.contentId);function u(c){s([...n,c]),o(!1)}function j(c){s(n.filter((m,p)=>p!==c))}function N(c){const{active:m,over:p}=c;if(p&&m.id!==p.id){const v=n.findIndex(w=>w.contentId===String(m.id)),S=n.findIndex(w=>w.contentId===String(p.id));v!==-1&&S!==-1&&s(Be(n,v,S))}}return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t.label}),e.jsx(ze,{sensors:i,collisionDetection:We,onDragEnd:N,children:e.jsx(Ve,{items:h,strategy:$e,children:e.jsxs("div",{className:"space-y-2",children:[n.map(c=>e.jsx(qs,{id:c.contentId,contentRef:c,onRemove:()=>j(n.indexOf(c))},c.contentId)),e.jsx(ge,{host:a,collections:[t.targetCollection],selectedIds:f,open:r,onOpenChange:o,onSelect:u,trigger:e.jsxs(g,{type:"button",variant:"outline",size:"sm",children:[e.jsx(Me,{className:"mr-2 h-3 w-3"}),"Add ",t.label]})})]})})})]})}function ke({field:t,value:n,onChange:a}){const s=t.options;return e.jsx(pe,{value:n??"",onChange:i=>a(i.target.value),placeholder:s?.placeholder,maxLength:s?.maxLength,required:!!s?.required,type:t.type==="url"?"url":t.type==="email"?"email":"text"})}function Kn({field:t,value:n,onChange:a}){const s=t.options;return e.jsx(Bs,{value:n??"",onChange:i=>a(i.target.value),placeholder:s?.placeholder,maxLength:s?.maxLength,required:!!s?.required,rows:4})}function Jn({field:t,value:n,onChange:a}){const s=t.options;return e.jsx(pe,{type:"number",value:n??"",onChange:i=>a(i.target.value===""?void 0:Number(i.target.value)),min:s?.min,max:s?.max,step:s?.step,required:!!s?.required})}function Gn({field:t,value:n,onChange:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{id:`field-${t.name}`,checked:!!n,onCheckedChange:s=>a(!!s)}),e.jsx("label",{htmlFor:`field-${t.name}`,className:"text-sm text-muted-foreground",children:t.label})]})}function Qn({field:t,value:n,onChange:a}){const i=t.options?.choices??[];return e.jsxs(Es,{value:n??"",onValueChange:r=>a(r),children:[e.jsx(Ms,{children:e.jsx(Vs,{placeholder:"Select..."})}),e.jsx($s,{children:i.map(r=>e.jsx(he,{value:r,children:r},r))})]})}function Yn({field:t,value:n,onChange:a}){const s=Ue(_e(He)),i=n??[],o=t.options?.itemFields??[],h=i.map((c,m)=>`item-${m}`);function f(){a([...i,{}])}function u(c){a(i.filter((m,p)=>p!==c))}function j(c,m){const p=[...i];p[c]=m,a(p)}function N(c){const{active:m,over:p}=c;if(p&&m.id!==p.id){const v=h.indexOf(String(m.id)),S=h.indexOf(String(p.id));a(Be(i,v,S))}}return e.jsx(ze,{sensors:s,collisionDetection:We,onDragEnd:N,children:e.jsx(Ve,{items:h,strategy:$e,children:e.jsxs("div",{className:"space-y-3",children:[i.map((c,m)=>e.jsx(Xn,{id:`item-${m}`,itemFields:o,item:c,onUpdate:p=>j(m,p),onRemove:()=>u(m)},`item-${m}`)),e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(Me,{className:"mr-2 h-3 w-3"})," Add Item"]})]})})})}function Xn({id:t,itemFields:n,item:a,onUpdate:s,onRemove:i}){const{attributes:r,listeners:o,setNodeRef:h,transform:f,transition:u}=Us({id:t}),j={transform:Ws.Transform.toString(f),transition:u};return e.jsx(U,{ref:h,style:j,children:e.jsxs(_,{className:"flex gap-2 p-3",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...r,...o,children:e.jsx(Ls,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1",children:e.jsx(qe,{fields:n,values:a,onChange:s})}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:i,className:"text-destructive",children:e.jsx(Fs,{className:"h-3 w-3"})})]})})}const Zn=d.lazy(()=>Ht(()=>import("./BlockEditor-D0Jk8u7w.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]))),ea=2,Cs=d.createContext(0);function sa({value:t,onChange:n,compact:a=!0}){const s=d.useContext(Cs),r=_t()?.blockTypes??[],o=Os();return s>=ea?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(Cs.Provider,{value:s+1,children:e.jsx("div",{className:o?"":"rounded-md border",children:e.jsx(d.Suspense,{fallback:e.jsx(F,{className:"h-48"}),children:e.jsx(Zn,{initialBlocks:t??[],onChange:n,blockTypes:r,compact:a})})})})}function ta({field:t,value:n,onChange:a}){const i=t.options?.fields??[],r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return e.jsx(U,{children:e.jsx(_,{className:"p-3",children:e.jsx(qe,{fields:i,values:r,onChange:o=>a(o)})})})}function qe({fields:t,values:n,onChange:a}){function s(i,r){a({...n,[i]:r})}return e.jsx("div",{className:"space-y-4",children:t.map(i=>e.jsxs("div",{className:"space-y-2",children:[i.type!=="boolean"&&e.jsx(X,{children:i.label}),na(i,n[i.name],r=>s(i.name,r))]},i.name))})}function na(t,n,a){switch(t.type){case"text":case"url":case"email":return e.jsx(ke,{field:t,value:n,onChange:a});case"textarea":return e.jsx(Kn,{field:t,value:n,onChange:a});case"number":return e.jsx(Jn,{field:t,value:n,onChange:a});case"boolean":return e.jsx(Gn,{field:t,value:n,onChange:a});case"select":return e.jsx(Qn,{field:t,value:n,onChange:a});case"media":return e.jsx(gn,{field:t,value:n,onChange:a});case"content":return e.jsx(Un,{field:t,value:n,onChange:a});case"blocks":return e.jsx(sa,{field:t,value:n,onChange:a});case"array":return e.jsx(Yn,{field:t,value:n,onChange:a});case"container":return e.jsx(ta,{field:t,value:n,onChange:a});case"date":return e.jsx(ke,{field:{...t,type:"text"},value:n,onChange:a});default:return e.jsx(ke,{field:t,value:n,onChange:a})}}function aa(){const{host:t,collection:n,id:a}=Ss(),{data:s,isLoading:i}=It(t,a);return i?e.jsxs("div",{className:"space-y-4",children:[e.jsx(F,{className:"h-8 w-64"}),e.jsx(F,{className:"h-64 w-full"})]}):s?.content?e.jsx(ia,{host:t,collection:n,contentId:a,content:s.content,draft:s.draft,publishedBlockId:s.publishedBlockId}):e.jsx("p",{className:"text-muted-foreground",children:"Content not found."})}function ia({host:t,collection:n,contentId:a,content:s,draft:i,publishedBlockId:r}){const o=St(),h=Ts(),{collections:f}=zt(),u=At(t,a),j=Tt(t,a),N=Lt(t,a),c=Ft(t,a),m=Ot(t,a),p=Rt(t,a),v=i?{title:i.title??s.title,slug:i.slug??s.slug??"",snippet:i.snippet??s.snippet??"",tags:i.tags??s.tags??[],coverUrl:i.coverUrl??s.coverUrl??"",coverMediaId:i.coverMediaId??s.coverMediaId??"",coverWidth:i.coverWidth??s.coverWidth??0,coverHeight:i.coverHeight??s.coverHeight??0,body:i.body??{},relationships:i.relationships??{}}:void 0,[S,w]=d.useState(null),x=Mn(t,a,v,()=>{w("This slug is already in use by another item in this collection")}),{data:k}=fn(t),I=k?.map(l=>l.tag),y=f.find(l=>l.name===n),C=d.useMemo(()=>y?.fields??[],[y?.fields]),A=d.useMemo(()=>y?.relationships??[],[y?.relationships]),D=y?.singleton??!1,W=Os(),[T,Ke]=d.useState(i?.title??s.title),[E,Je]=d.useState(i?.slug??s.slug??""),[M,Ge]=d.useState(i?.snippet??s.snippet??""),Qe=i?.autoSnippet??"",[q,Ye]=d.useState(i?.tags??s.tags??[]),[je,Xe]=d.useState(i?.coverUrl??s.coverUrl??""),[te,Ze]=d.useState(i?.coverMediaId??s.coverMediaId??""),[es,ss]=d.useState(i?.coverWidth??s.coverWidth??0),[ts,ns]=d.useState(i?.coverHeight??s.coverHeight??0),[K,as]=d.useState(i?.body??{}),[J,is]=d.useState(i?.relationships??{}),[Ks,Js]=d.useState(0),[Gs,Qs]=d.useState(!1),[Ys,ne]=d.useState(!1),[Xs,Q]=d.useState(!1),[Zs,ae]=d.useState(null),[be,ie]=d.useState(!1),[et,le]=d.useState(!1),[st,re]=d.useState(!1),[ce,ls]=d.useState(""),[tt,ve]=d.useState(!1),[ye,rs]=d.useState(""),cs=Et(t,a),{data:os}=bn(t,te),H=d.useCallback(()=>({title:T,slug:E,snippet:M,tags:q,coverUrl:je,coverMediaId:te,coverWidth:es,coverHeight:ts,body:K,relationships:J}),[T,E,M,q,je,te,es,ts,K,J]);function nt(l){Ke(l),x.schedule({...H(),title:l})}function at(l){Je(l),w(null),x.schedule({...H(),slug:l})}function it(l){Ge(l),x.schedule({...H(),snippet:l})}function lt(l){Ye(l),x.schedule({...H(),tags:l})}function ds(l,b,$,Y){Xe(l),Ze(b),ss($),ns(Y),x.schedule({...H(),coverUrl:l,coverMediaId:b,coverWidth:$,coverHeight:Y})}function rt(l){as(l),x.schedule({...H(),body:l})}function ct(l){is(l),x.schedule({...H(),relationships:l})}const ot=x.lastSavedBlockId??i?.blockId,O=Ln(s.publishedAt,s.lastPublishedAt,r,ot,s.scheduledAt,s.scheduledFailed),oe=Fn(O),de=On(O),{data:V}=ws(t,a,!!s.publishedAt),R=d.useMemo(()=>{if(!be||!V)return null;const l=D?void 0:{title:V.title,slug:V.slug,snippet:V.snippet,tags:V.tags},b=A.map(L=>({name:L.name,label:L.label})),$=V.relationships,Y=b.length>0?{defs:b,values:$??{}}:void 0,jt=Z(C,V.body??{},l,Y),bt=D?void 0:{title:T,slug:E,snippet:M,tags:q},vt=b.length>0?{defs:b,values:J}:void 0,yt=Z(C,K,bt,vt),Nt=tn(jt,yt,{comparator:(L,Ce)=>L.text===Ce.text&&L.indent===Ce.indent&&L.type===Ce.type});let xs=0,ps=0;for(const L of Nt)L.added?xs+=L.count??0:L.removed&&(ps+=L.count??0);return{added:xs,removed:ps}},[be,V,C,A,D,T,E,M,q,K,J]),[dt]=wt(),ut=dt.get("from")==="recent"?`/sites/${t}/content`:`/sites/${t}/content/${n}`;en({title:D?y?.label??n:T||"Untitled",showBack:!D,backTo:D?void 0:ut,badge:{label:oe.label,variant:oe.variant}});function us(){if(s.publishedAt&&s.slug&&E!==s.slug){le(!0);return}O==="published-changes"?ie(!0):ue()}async function ue(){try{x.cancel(),await x.flush({createVersion:!0}),await u.mutateAsync(void 0),P.success("Content published")}catch(l){if(l instanceof De&&l.code==="SLUG_TAKEN"){w("This slug is already in use by another item in this collection"),P.error("Slug already in use",{description:"Please choose a different slug before publishing."});return}P.error("Failed to publish",{description:l instanceof Error?l.message:void 0})}}async function ht(){try{await j.mutateAsync(),Q(!1),P.success("Content unpublished")}catch(l){P.error("Failed to unpublish",{description:l instanceof Error?l.message:void 0})}}async function mt(){try{x.discard();const l=await h.apiFetch(`/v1/admin/sites/${t}/content/${a}/published`);await cs.mutateAsync();const b={title:l.title??"",slug:l.slug??"",snippet:l.snippet??"",tags:l.tags??[],coverUrl:l.coverUrl??"",coverMediaId:l.coverMediaId??"",coverWidth:l.coverWidth??0,coverHeight:l.coverHeight??0,body:l.body??{},relationships:l.relationships??{}};Ke(b.title),Je(b.slug),Ge(b.snippet),Ye(b.tags),Xe(b.coverUrl),Ze(b.coverMediaId),ss(b.coverWidth),ns(b.coverHeight),as(b.body),is(b.relationships),Js($=>$+1),x.resetBaseline(b),P.success("Changes discarded")}catch(l){P.error("Failed to discard changes",{description:l instanceof Error?l.message:void 0})}}async function xt(){try{await N.mutateAsync(),P.success("Content deleted"),o(`/sites/${t}/content/${n}`)}catch(l){P.error("Failed to delete",{description:l instanceof Error?l.message:void 0})}}async function pt(){if(ce)try{x.cancel(),await x.flush({createVersion:!0});const l=new Date(ce).getTime();await m.mutateAsync(l),re(!1),ls(""),P.success("Content scheduled for publishing")}catch(l){P.error("Failed to schedule",{description:l instanceof Error?l.message:void 0})}}async function ft(){try{await p.mutateAsync(),P.success("Schedule cancelled")}catch(l){P.error("Failed to cancel schedule",{description:l instanceof Error?l.message:void 0})}}async function gt(){if(ye)try{const l=new Date(ye).getTime();await c.mutateAsync(l),ve(!1),P.success("Publish date updated")}catch(l){P.error("Failed to update publish date",{description:l instanceof Error?l.message:void 0})}}function Ne(l){const b=new Date(l),$=b.getTimezoneOffset();return new Date(b.getTime()-$*6e4).toISOString().slice(0,16)}const hs=e.jsx("div",{className:"space-y-6",children:C.length>0?e.jsx(qe,{fields:C,values:K,onChange:rt},Ks):e.jsx(U,{children:e.jsx(_,{className:"py-8 text-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No fields defined for this collection."," ",e.jsx(kt,{to:`/sites/${t}/settings/collections/${n}`,className:"underline",children:"Configure fields"})]})})})}),ms=e.jsxs("div",{className:"space-y-6",children:[!D&&e.jsx(U,{children:e.jsxs(_,{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"title",children:"Title"}),e.jsx(pe,{id:"title",value:T,onChange:l=>nt(l.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"slug",children:"Slug"}),e.jsx(pe,{id:"slug",value:E,onChange:l=>at(l.target.value),className:S?"border-destructive":""}),S&&e.jsx("p",{className:"text-sm text-destructive",children:S})]}),e.jsxs(_s,{defaultOpen:!!M,children:[e.jsxs(Hs,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(Rs,{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(zs,{className:"mt-2 space-y-2",children:[e.jsx(Bs,{id:"snippet",value:M,onChange:l=>it(l.target.value),rows:3,placeholder:"Brief summary of this content..."}),!M&&Qe&&e.jsxs("p",{className:"text-xs italic text-muted-foreground",children:["Auto-generated: ",Qe]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:"Cover Image"}),te?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>ne(!0),children:[e.jsx("img",{src:vn(je),alt:os?.filename??"",className:"h-10 w-10 rounded object-cover bg-muted"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:os?.filename??"Loading..."}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:l=>{l.stopPropagation(),ds("","",0,0)},children:e.jsx(ee,{className:"h-3 w-3"})})]}):e.jsxs(g,{type:"button",variant:"outline",className:"w-full",onClick:()=>ne(!0),children:[e.jsx(Wt,{className:"mr-2 h-4 w-4"}),"Select Image"]}),e.jsx(jn,{open:Ys,onClose:()=>ne(!1),onSelect:l=>{ds(l.url,l.mediaId,l.width??0,l.height??0),ne(!1)},allowedTypes:["image/*"]})]})]})}),!D&&e.jsxs(U,{children:[e.jsx(Oe,{children:e.jsx(Re,{children:"Tags"})}),e.jsx(_,{children:e.jsx(rn,{tags:q,onChange:lt,suggestions:I})})]}),A.length>0&&e.jsx(zn,{relationships:A,values:J,onChange:ct,host:t}),e.jsxs(U,{children:[e.jsx(Oe,{children:e.jsx(Re,{children:"Info"})}),e.jsxs(_,{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:s.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:s.contentId})]}),s.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"}),tt?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"datetime-local",value:ye,onChange:l=>rs(l.target.value),className:"text-xs border rounded px-1 py-0.5",max:Ne(Date.now())}),e.jsx(g,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:gt,disabled:c.isPending,children:e.jsx(fs,{className:"h-3 w-3"})}),e.jsx(g,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>ve(!1),children:e.jsx(ee,{className:"h-3 w-3"})})]}):e.jsxs("span",{className:"cursor-pointer hover:underline",title:z(s.publishedAt),onClick:()=>{rs(Ne(s.publishedAt)),ve(!0)},children:[we(s.publishedAt),e.jsx(qt,{className:"inline ml-1 h-3 w-3 text-muted-foreground"})]})]}),s.lastPublishedAt&&s.lastPublishedAt!==s.publishedAt&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last published"}),e.jsx("span",{title:z(s.lastPublishedAt),children:we(s.lastPublishedAt)})]})]}):s.lastPublishedAt?e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last published"}),e.jsx("span",{title:z(s.lastPublishedAt),children:we(s.lastPublishedAt)})]}):null,O==="scheduled"&&s.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(gs,{className:"h-3 w-3"}),z(s.scheduledAt)]})]}),O==="schedule-failed"&&e.jsx("div",{className:"text-destructive text-xs",children:"Scheduled publishing failed after multiple attempts."}),s.publishedAt&&e.jsxs(g,{variant:"outline",size:"sm",className:"w-full mt-2",onClick:()=>{ae({kind:"published"}),Q(!0)},children:[e.jsx(Kt,{className:"mr-2 h-4 w-4"}),"View published"]})]})]}),e.jsx(ca,{host:t,contentId:a,onViewVersion:l=>{ae({kind:"history",blockId:l.blockId,createdAt:l.createdAt,title:l.title}),Q(!0)}}),!D&&e.jsx(ra,{deleteOpen:Gs,setDeleteOpen:Qs,onDelete:xt,host:t,contentId:a})]});return e.jsxs("div",{className:"mx-auto max-w-6xl",children:[!W&&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?y?.label??n:T||"Untitled"}),e.jsx(se,{variant:oe.variant,children:oe.label}),x.isSaving&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(B,{className:"h-3 w-3 animate-spin"}),"Saving..."]}),!x.isSaving&&x.lastSavedAt&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(fs,{className:"h-3 w-3"}),"Saved"]})]}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(g,{variant:"outline",onClick:()=>x.flush({createVersion:!0}),disabled:x.isSaving,children:[x.isSaving&&e.jsx(B,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Draft"]}),O==="scheduled"&&e.jsxs(e.Fragment,{children:[e.jsxs(g,{variant:"outline",onClick:ft,disabled:p.isPending,children:[p.isPending&&e.jsx(B,{className:"mr-2 h-4 w-4 animate-spin"}),"Cancel Schedule"]}),e.jsxs(g,{onClick:()=>void ue(),disabled:u.isPending,children:[u.isPending&&e.jsx(B,{className:"mr-2 h-4 w-4 animate-spin"}),"Publish Now"]})]}),O!=="scheduled"&&de&&e.jsxs("div",{className:"flex",children:[e.jsxs(g,{onClick:us,disabled:u.isPending,className:"rounded-r-none",children:[u.isPending&&e.jsx(B,{className:"mr-2 h-4 w-4 animate-spin"}),de]}),!s.publishedAt&&e.jsxs(js,{children:[e.jsx(bs,{asChild:!0,children:e.jsx(g,{className:"rounded-l-none border-l px-2",disabled:u.isPending,children:e.jsx(Jt,{className:"h-4 w-4"})})}),e.jsx(vs,{align:"end",children:e.jsxs(Se,{onClick:()=>re(!0),children:[e.jsx(gs,{className:"mr-2 h-4 w-4"}),"Schedule for later"]})})]})]}),s.publishedAt&&e.jsxs(js,{children:[e.jsx(bs,{asChild:!0,children:e.jsx(g,{variant:"outline",size:"icon",children:e.jsx(Gt,{className:"h-4 w-4"})})}),e.jsxs(vs,{align:"end",children:[O==="published-changes"&&e.jsxs(Se,{onClick:mt,disabled:cs.isPending,children:[e.jsx(Qt,{className:"mr-2 h-4 w-4"}),"Discard Changes"]}),e.jsx(Se,{onClick:ht,className:"text-destructive focus:text-destructive",children:"Unpublish"})]})]})]})]}),W?e.jsxs(Is,{defaultValue:"content",children:[e.jsxs("div",{className:"mb-2 flex items-center",children:[e.jsxs(As,{variant:"line",children:[e.jsx(me,{value:"content",children:"Content"}),e.jsx(me,{value:"info",children:"Info"})]}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>x.flush({createVersion:!0}),disabled:x.isSaving,children:[x.isSaving&&e.jsx(B,{className:"mr-1 h-3 w-3 animate-spin"}),"Save"]}),O!=="scheduled"&&de&&e.jsxs(g,{size:"sm",onClick:us,disabled:u.isPending,children:[u.isPending&&e.jsx(B,{className:"mr-1 h-3 w-3 animate-spin"}),de]})]})]}),e.jsx(xe,{value:"content",className:"mt-0",children:hs}),e.jsx(xe,{value:"info",className:"mt-0",children:ms})]}):e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx("div",{className:"lg:col-span-2",children:hs}),e.jsx("div",{children:ms})]}),e.jsx($n,{open:Xs,onOpenChange:l=>{Q(l),l||ae(null)},host:t,contentId:a,collectionFields:C,isSingleton:D,isPublished:!!s.publishedAt,draftBody:K,draftMetadata:D?void 0:{title:T,slug:E,snippet:M,tags:q},initialVersion:Zs,collectionRelationships:A,draftRelationships:J}),e.jsx(cn,{open:be,onOpenChange:ie,children:e.jsxs(on,{children:[e.jsxs(dn,{children:[e.jsx(un,{children:"Publish changes?"}),e.jsx(hn,{children:R?e.jsxs(e.Fragment,{children:[R.added>0&&e.jsxs("span",{className:"text-green-600",children:["+",R.added," added"]}),R.added>0&&R.removed>0&&", ",R.removed>0&&e.jsxs("span",{className:"text-red-600",children:["-",R.removed," removed"]}),R.added===0&&R.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(g,{variant:"link",className:"p-0 h-auto text-sm",onClick:()=>{ie(!1),ae({kind:"published"}),Q(!0)},children:"View full diff"})}),e.jsxs(mn,{children:[e.jsx(xn,{children:"Cancel"}),e.jsx(pn,{onClick:()=>{ie(!1),ue()},children:"Publish Update"})]})]})}),e.jsx(Pe,{open:et,onOpenChange:le,children:e.jsxs(Ie,{children:[e.jsxs(Ae,{children:[e.jsx(Te,{children:"Slug change detected"}),e.jsxs(Le,{children:["You are changing the slug from “",s.slug,"” to “",E,"”. This may break external bookmarks and SEO links."]})]}),e.jsx(la,{host:t,contentId:a}),e.jsxs(Fe,{children:[e.jsx(g,{variant:"outline",onClick:()=>le(!1),children:"Cancel"}),e.jsx(g,{onClick:()=>{le(!1),ue()},children:"Publish Anyway"})]})]})}),e.jsx(Pe,{open:st,onOpenChange:re,children:e.jsxs(Ie,{children:[e.jsxs(Ae,{children:[e.jsx(Te,{children:"Schedule publishing"}),e.jsx(Le,{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(X,{htmlFor:"schedule-date",children:"Publish at"}),e.jsx("input",{id:"schedule-date",type:"datetime-local",value:ce,onChange:l=>ls(l.target.value),min:Ne(Date.now()+1200*1e3),className:"w-full rounded-md border px-3 py-2 text-sm",step:"900"})]}),e.jsxs(Fe,{children:[e.jsx(g,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsxs(g,{onClick:pt,disabled:!ce||m.isPending,children:[m.isPending&&e.jsx(B,{className:"mr-2 h-4 w-4 animate-spin"}),"Schedule"]})]})]})})]})}function la({host:t,contentId:n}){const{data:a}=Ds(t,n,!0);return!a||a.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 ",a.count," other"," ",a.count===1?"item":"items",":"]}),e.jsxs("ul",{className:"mt-1 list-disc pl-5 text-yellow-700 dark:text-yellow-300",children:[a.items.slice(0,5).map(s=>e.jsxs("li",{children:[s.title," (",s.collection,")"]},`${s.contentId}-${s.fieldName}`)),a.items.length>5&&e.jsxs("li",{children:["and ",a.items.length-5," more..."]})]})]})}function ra({deleteOpen:t,setDeleteOpen:n,onDelete:a,host:s,contentId:i}){const{data:r}=Ds(s,i,t);return e.jsxs(e.Fragment,{children:[e.jsx(Yt,{}),e.jsxs(Pe,{open:t,onOpenChange:n,children:[e.jsx(Xt,{asChild:!0,children:e.jsxs(g,{variant:"destructive",className:"w-full",children:[e.jsx(Fs,{className:"mr-2 h-4 w-4"}),"Delete"]})}),e.jsxs(Ie,{children:[e.jsxs(Ae,{children:[e.jsx(Te,{children:"Delete content?"}),e.jsx(Le,{children:"This action cannot be undone. The content will be permanently deleted."})]}),r&&r.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 ",r.count," other"," ",r.count===1?"item":"items",":"]}),e.jsxs("ul",{className:"mt-1 list-disc pl-5 text-yellow-700 dark:text-yellow-300",children:[r.items.slice(0,5).map(o=>e.jsxs("li",{children:[o.title," (",o.collection,")"]},`${o.contentId}-${o.fieldName}`)),r.items.length>5&&e.jsxs("li",{children:["and ",r.items.length-5," more..."]})]})]}),e.jsxs(Fe,{children:[e.jsx(g,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(g,{variant:"destructive",onClick:a,children:"Delete"})]})]})]})]})}function ca({host:t,contentId:n,onViewVersion:a}){const{data:s}=ks(t,n),[i,r]=d.useState(!1),o=s?.items??[],h=o.map(u=>u.createdBy).filter(Boolean),{resolve:f}=Zt(h);return o.length===0?null:e.jsx(U,{children:e.jsx(_,{className:"pt-4",children:e.jsxs(_s,{open:i,onOpenChange:r,children:[e.jsxs(Hs,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(Rs,{className:Ps("h-4 w-4 transition",i&&"rotate-90")}),"Version History (",o.length,")"]}),e.jsx(zs,{className:"mt-2",children:e.jsx("div",{className:"space-y-1",children:o.map((u,j)=>e.jsxs("button",{className:"py-1 text-sm hover:bg-muted rounded px-1 -mx-1 transition-colors w-full text-left",onClick:()=>a(u),children:[e.jsx("span",{children:z(u.createdAt)}),u.createdBy&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:f(u.createdBy)}),u.title&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:u.title})]},`${u.createdAt}-${j}`))})})]})})})}const La=Object.freeze(Object.defineProperty({__proto__:null,ContentEditPage:aa},Symbol.toStringTag,{value:"Module"}));export{ge as C,qe as F,La as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as ve,f as be,r as o}from"./react-vendor-C2CvUxFh.js";import{w as Ne,x as Se,B as I,P as ae,v as j,z as te,I as ne,X as P,A as Ce,L as D,j as S,S as we,a as ke,y as _e}from"./index-b-u0-VCO.js";import{d as Ae,e as ye,a as Ie,b as Pe,c as Te}from"./useContent-B2MUK4An.js";import{u as $e}from"./useTags-B6FtXCHF.js";import{u as Be}from"./useDebouncedValue-C-cQUcLG.js";import{u as Ue}from"./usePageTitle-Do4xyFdL.js";import{m as ce}from"./media-url-DIg_vSyf.js";import{C as De,c as Ve}from"./card-uKxSQehY.js";import{C as q}from"./checkbox-z1kYnX5o.js";import{P as Me,a as Le,b as ze}from"./popover-rcnajqN6.js";import{S as p,a as g,b as f,c as v,d as i}from"./select-BKaV0BO_.js";import{T as Oe,a as Fe,b as re,c as T,d as Re,e as $}from"./table-Bozosvl6.js";import{a as V,f as ie}from"./format-C88SDH8g.js";import{g as de,a as oe}from"./contentStatus-BmaiYVOm.js";import{B as qe}from"./BulkActionBar-BGDrNwCg.js";import"./radix-C1kb_NqW.js";const M=3,ue=[{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"}],E=[{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 rs(){const{host:c,collection:t}=ve(),C=be(),{collections:he}=Ne(),[k,_]=o.useState(""),[A,H]=o.useState("prefix"),[u,L]=o.useState(),[h,z]=o.useState(),[w,X]=o.useState("updated_desc"),[xe,Z]=o.useState(),[d,b]=o.useState(new Set),O=Se(),m=he.find(s=>s.name===t);Ue({title:m?.label??t??"",actions:m?.singleton?void 0:e.jsx(I,{size:"sm",onClick:()=>C(`/sites/${c}/content/${t}/new`),children:e.jsx(ae,{className:"h-4 w-4"})})});const N=Be(k,300),a=o.useCallback(()=>Z(void 0),[]),me=o.useMemo(()=>{const s={};return N&&(s.q=N,s.search=A),u&&(s.tag=u),h&&(s.status=h),w!=="updated_desc"&&(s.sort=w),s},[N,A,u,h,w]),{data:y,isLoading:je}=Ae(c,t,me,xe),F=ye(c),G=Ie(c),Q=Pe(c),J=Te(c),{data:K}=$e(c),B=o.useMemo(()=>K?.map(s=>s.tag)??[],[K]);if(m?.singleton&&y?.items.length===1)return C(`/sites/${c}/content/${t}/${y.items[0].contentId}`,{replace:!0}),null;const U=y?.items,R=U?.map(s=>s.contentId)??[],W=R.length>0&&R.every(s=>d.has(s));function Y(s){b(r=>{const l=new Set(r);return l.has(s)?l.delete(s):l.add(s),l})}function pe(){b(W?new Set:new Set(R))}const ee=!!(N||u||h),se=!!N,le=[A!=="prefix"?1:0,u?1:0,h?1:0,w!=="updated_desc"?1:0].reduce((s,r)=>s+r,0),ge=G.isPending||Q.isPending||J.isPending;async function fe(){try{const s=await F.mutateAsync({collection:t,title:m?.label??t});j.success("Singleton content recreated"),C(`/sites/${c}/content/${t}/${s.contentId}`)}catch(s){j.error("Failed to recreate singleton",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{children:[!O&&e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:m?.label??t}),!m?.singleton&&e.jsxs(I,{onClick:()=>C(`/sites/${c}/content/${t}/new`),children:[e.jsx(ae,{className:"mr-2 h-4 w-4"}),"New"]})]}),d.size>0?e.jsx(qe,{selectedCount:d.size,onPublish:async()=>{const s=[...d],l=(await G.mutateAsync(s)).filter(n=>n.status==="rejected").length;l?j.error(`${l} of ${s.length} failed to publish`):j.success(`${s.length} item(s) published`),b(new Set)},onUnpublish:async()=>{const s=[...d],l=(await Q.mutateAsync(s)).filter(n=>n.status==="rejected").length;l?j.error(`${l} of ${s.length} failed to unpublish`):j.success(`${s.length} item(s) unpublished`),b(new Set)},onDelete:async()=>{const s=[...d],l=(await J.mutateAsync(s)).filter(n=>n.status==="rejected").length;l?j.error(`${l} of ${s.length} failed to delete`):j.success(`${s.length} item(s) deleted`),b(new Set)},onClear:()=>b(new Set),isPending:ge}):O?e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(te,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"Search...",value:k,onChange:s=>{_(s.target.value),a()},className:"pl-8 pr-8"}),k&&e.jsx("button",{onClick:()=>{_(""),a()},className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",children:e.jsx(P,{className:"h-4 w-4"})})]}),e.jsxs(Me,{children:[e.jsx(Le,{asChild:!0,children:e.jsxs(I,{variant:"outline",size:"icon",className:"relative shrink-0","aria-label":"Filters",children:[e.jsx(Ce,{className:"h-4 w-4"}),le>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:le})]})}),e.jsxs(ze,{className:"w-64 space-y-3",align:"end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"text-xs font-medium",children:"Search Mode"}),e.jsxs(p,{value:A,onValueChange:s=>{H(s),a()},children:[e.jsx(g,{children:e.jsx(f,{})}),e.jsxs(v,{children:[e.jsx(i,{value:"prefix",children:"Starts with"}),e.jsx(i,{value:"full",children:"Contains"})]})]})]}),B.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"text-xs font-medium",children:"Tag"}),e.jsxs(p,{value:u??"__all__",onValueChange:s=>{L(s==="__all__"?void 0:s),a()},children:[e.jsx(g,{children:e.jsx(f,{})}),e.jsxs(v,{children:[e.jsx(i,{value:"__all__",children:"All tags"}),B.map(s=>e.jsx(i,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"text-xs font-medium",children:"Status"}),e.jsxs(p,{value:h??"all",onValueChange:s=>{z(s==="all"?void 0:s),a()},children:[e.jsx(g,{children:e.jsx(f,{})}),e.jsx(v,{children:E.map(s=>e.jsx(i,{value:s.value??"all",children:s.label},s.value??"all"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"text-xs font-medium",children:"Sort"}),e.jsxs(p,{value:w,onValueChange:s=>{X(s),a()},disabled:se,children:[e.jsx(g,{children:e.jsx(f,{})}),e.jsx(v,{children:ue.map(s=>e.jsx(i,{value:s.value,disabled:s.requiresCollection&&!t,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(te,{className:"absolute left-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"Search titles...",value:k,onChange:s=>{_(s.target.value),a()},className:"w-56 pl-8 pr-8"}),k&&e.jsx("button",{onClick:()=>{_(""),a()},className:"absolute right-2 text-muted-foreground hover:text-foreground",children:e.jsx(P,{className:"h-4 w-4"})})]}),e.jsxs(p,{value:A,onValueChange:s=>{H(s),a()},children:[e.jsx(g,{className:"w-[130px]",children:e.jsx(f,{})}),e.jsxs(v,{children:[e.jsx(i,{value:"prefix",children:"Starts with"}),e.jsx(i,{value:"full",children:"Contains"})]})]}),B.length>0&&e.jsxs(p,{value:u??"__all__",onValueChange:s=>{L(s==="__all__"?void 0:s),a()},children:[e.jsx(g,{className:"w-[140px]",children:e.jsx(f,{placeholder:"Tag"})}),e.jsxs(v,{children:[e.jsx(i,{value:"__all__",children:"All tags"}),B.map(s=>e.jsx(i,{value:s,children:s},s))]})]}),e.jsxs(p,{value:h??"all",onValueChange:s=>{z(s==="all"?void 0:s),a()},children:[e.jsx(g,{className:"w-[150px]",children:e.jsx(f,{})}),e.jsx(v,{children:E.map(s=>e.jsx(i,{value:s.value??"all",children:s.label},s.value??"all"))})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(p,{value:w,onValueChange:s=>{X(s),a()},disabled:se,children:[e.jsx(g,{className:"w-[170px]",children:e.jsx(f,{})}),e.jsx(v,{children:ue.map(s=>e.jsx(i,{value:s.value,disabled:s.requiresCollection&&!t,children:s.label},s.value))})]})})]}),ee&&d.size===0&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[N&&e.jsxs(S,{variant:"secondary",className:"gap-1",children:["Search: ",N,e.jsx("button",{onClick:()=>{_(""),a()},children:e.jsx(P,{className:"h-3 w-3"})})]}),u&&e.jsxs(S,{variant:"secondary",className:"gap-1",children:["Tag: ",u,e.jsx("button",{onClick:()=>{L(void 0),a()},children:e.jsx(P,{className:"h-3 w-3"})})]}),h&&e.jsxs(S,{variant:"secondary",className:"gap-1",children:["Status: ",E.find(s=>s.value===h)?.label,e.jsx("button",{onClick:()=>{z(void 0),a()},children:e.jsx(P,{className:"h-3 w-3"})})]})]}),je?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,r)=>e.jsx(we,{className:"h-12 w-full"},r))}):U?.length?e.jsxs(e.Fragment,{children:[O?e.jsx("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"content-card-view",children:U.map(s=>{const r=de(s.publishedAt,s.lastPublishedAt,s.publishedBlockId,s.lastDraftBlockId,s.scheduledAt,s.scheduledFailed),l=oe(r),n=s.tags??[];return e.jsx(De,{className:_e("cursor-pointer gap-0 overflow-hidden py-0 transition-shadow hover:shadow-md",d.has(s.contentId)&&"ring-2 ring-primary"),onClick:()=>C(`/sites/${c}/content/${t}/${s.contentId}`),children:e.jsxs(Ve,{className:"p-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[s.coverUrl&&e.jsx("img",{src:ce(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(S,{variant:l.variant,className:"shrink-0",children:l.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?V(s.lastDraftAt):"—"})]}),e.jsx(q,{checked:d.has(s.contentId),onCheckedChange:()=>Y(s.contentId),onClick:x=>x.stopPropagation(),className:"mt-1"})]}),n.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:n.slice(0,M).map(x=>e.jsx(S,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:x},x))})]})},s.contentId)})}):e.jsxs(Oe,{children:[e.jsx(Fe,{children:e.jsxs(re,{children:[e.jsx(T,{className:"w-10",children:e.jsx(q,{checked:W,onCheckedChange:pe,"aria-label":"Select all"})}),e.jsx(T,{children:"Title"}),e.jsx(T,{children:"Slug"}),e.jsx(T,{children:"Status"}),e.jsx(T,{children:"Updated"})]})}),e.jsx(Re,{children:U.map(s=>{const r=de(s.publishedAt,s.lastPublishedAt,s.publishedBlockId,s.lastDraftBlockId),l=oe(r),n=s.tags??[];return e.jsxs(re,{className:"cursor-pointer",onClick:()=>C(`/sites/${c}/content/${t}/${s.contentId}`),children:[e.jsx($,{onClick:x=>x.stopPropagation(),children:e.jsx(q,{checked:d.has(s.contentId),onCheckedChange:()=>Y(s.contentId),"aria-label":`Select ${s.title||"Untitled"}`})}),e.jsx($,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-3",children:[s.coverUrl&&e.jsx("img",{src:ce(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"}),n.length>0&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-1",children:[n.slice(0,M).map(x=>e.jsx(S,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal text-muted-foreground",children:x},x)),n.length>M&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",n.length-M," more"]})]})]})]})}),e.jsx($,{className:"text-muted-foreground text-sm",children:s.slug||"—"}),e.jsx($,{children:e.jsx(S,{variant:l.variant,children:l.label})}),e.jsx($,{className:"text-muted-foreground",children:s.scheduledAt&&!s.publishedAt?e.jsxs("span",{title:ie(s.scheduledAt),children:["Scheduled ",V(s.scheduledAt)]}):s.publishedAt?e.jsx("span",{title:ie(s.publishedAt),children:V(s.publishedAt)}):s.lastDraftAt?V(s.lastDraftAt):"—"})]},s.contentId)})})]}),y?.hasMore&&e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx(I,{variant:"outline",onClick:()=>Z(y.cursor??void 0),children:"Load More"})})]}):m?.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(I,{onClick:fe,disabled:F.isPending,children:[F.isPending&&e.jsx(ke,{className:"mr-2 h-4 w-4 animate-spin"}),"Recreate ",m.label]})]}):e.jsx("p",{className:"text-muted-foreground",children:ee?"No content matches the current filters.":"No content yet."})]})}export{rs as ContentListPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as m,R as S,L as Nt,u as Dt}from"./react-vendor-C2CvUxFh.js";import{a as kt,b as St,c as Tt,d as It,e as ot,f as Mt,g as Rt,h as _t,i as At,j as Et,k as zt,l as Ft,m as $t}from"./useMedia-CXQpRNYL.js";import{y as O,V as ct,ab as Pt,ac as Ot,ad as Ut,ae as Lt,R as Ht,B as D,af as Pe,v as T,D as ie,k as le,l as oe,m as ce,n as de,L,I as K,o as he,a as J,ag as Xt,j as Oe,T as Yt,X as pe,P as Bt,ah as ee,a3 as Kt,a4 as Wt,a8 as Vt,a6 as qt,a7 as at,ai as xe,aj as Qt,ak as Gt,$ as Zt,al as Jt,am as es,Y as ts,x as ss,F as as,G as ns,K as rs,z as nt,an as is,ao as ls,ap as os,S as cs,aq as ds}from"./index-b-u0-VCO.js";import{C as hs,c as us}from"./card-uKxSQehY.js";import{C as Te}from"./checkbox-z1kYnX5o.js";import{S as ge,a as fe,b as we,c as je,d as te}from"./select-BKaV0BO_.js";import{s as ms,t as xs,u as ps,v as gs,w as fs,A as ws}from"./radix-C1kb_NqW.js";import{b as dt,d as js,u as vs,a as ys,D as bs,e as Cs,P as Ns}from"./core.esm-B_kcYf6n.js";import{b as ve,a as Ue,f as Le}from"./format-C88SDH8g.js";import{m as W}from"./media-url-DIg_vSyf.js";import{T as Ds,a as ks,b as ht,c as Y,d as Ss,e as B}from"./table-Bozosvl6.js";import{T as $e,A as He,h as Ts,a as Xe,b as Ye,c as Be,d as Ke,e as We,f as Ve,g as qe}from"./TagInput-CrI2BIuz.js";import{u as Is}from"./usePageTitle-Do4xyFdL.js";function Ce({delayDuration:a=0,...t}){return e.jsx(ms,{"data-slot":"tooltip-provider",delayDuration:a,...t})}function Ne({...a}){return e.jsx(xs,{"data-slot":"tooltip",...a})}function De({...a}){return e.jsx(ps,{"data-slot":"tooltip-trigger",...a})}function ke({className:a,sideOffset:t=0,children:s,...l}){return e.jsx(gs,{children:e.jsxs(fs,{"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(ws,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Ie({mimeType:a,className:t}){return a==="application/pdf"?e.jsx(ct,{className:O("text-blue-500",t)}):a.startsWith("video/")?e.jsx(Pt,{className:O("text-purple-500",t)}):a.startsWith("audio/")?e.jsx(Ot,{className:O("text-green-500",t)}):a==="image/svg+xml"?e.jsx(Ut,{className:O("text-orange-500",t)}):e.jsx(Lt,{className:O("text-muted-foreground",t)})}function Ms(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 Rs({item:a,selected:t,onToggle:s,onSelect:l,onLightbox:n,folderName:r}){const{attributes:c,listeners:h,setNodeRef:o,isDragging:i}=dt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),x=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";return e.jsxs(ht,{ref:o,className:O("cursor-pointer",i&&"opacity-50"),onClick:l,children:[e.jsx(B,{onPointerDown:g=>g.stopPropagation(),onClick:g=>g.stopPropagation(),children:e.jsx(Te,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsx(B,{className:"w-6 p-1 hidden md:table-cell",children:e.jsx("div",{className:"cursor-grab text-muted-foreground",...c,...h,children:e.jsx(Ht,{className:"h-4 w-4"})})}),e.jsx(B,{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(Ie,{mimeType:a.mimeType,className:"h-5 w-5"})})}),e.jsxs(B,{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(B,{className:"hidden md:table-cell",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ms(a.mimeType)})}),e.jsx(B,{className:"text-right",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:ve(a.size)})}),e.jsx(B,{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(B,{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(B,{className:"hidden md:table-cell",children:e.jsx(Ce,{children:e.jsxs(Ne,{children:[e.jsx(De,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ue(a.uploadedAt)})}),e.jsx(ke,{children:Le(a.uploadedAt)})]})})}),e.jsx(B,{onPointerDown:g=>g.stopPropagation(),onClick:g=>g.stopPropagation(),children:e.jsx(D,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(W(a.url)),T.success("URL copied to clipboard")},children:e.jsx(Pe,{className:"h-3.5 w-3.5"})})})]})}function _s({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(Ds,{children:[e.jsx(ks,{children:e.jsxs(ht,{children:[e.jsx(Y,{className:"w-10",children:e.jsx(Te,{checked:c,onCheckedChange:r,"aria-label":"Select all"})}),e.jsx(Y,{className:"w-6 hidden md:table-cell"}),e.jsx(Y,{className:"w-12"}),e.jsx(Y,{children:"Filename"}),e.jsx(Y,{className:"w-20 hidden md:table-cell",children:"Type"}),e.jsx(Y,{className:"w-24 text-right",children:"Size"}),e.jsx(Y,{className:"w-28 hidden lg:table-cell",children:"Dimensions"}),e.jsx(Y,{className:"w-40 hidden lg:table-cell",children:"Tags"}),e.jsx(Y,{className:"w-32 hidden md:table-cell",children:"Uploaded"}),e.jsx(Y,{className:"w-10"})]})}),e.jsx(Ss,{children:a.map(i=>e.jsx(Rs,{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 As=Object.defineProperty,Es=(a,t,s)=>t in a?As(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,I=(a,t,s)=>Es(a,typeof t!="symbol"?t+"":t,s);const Se={x:0,y:0,width:0,height:0,unit:"px"},ae=(a,t,s)=>Math.min(Math.max(a,t),s),zs=(...a)=>a.filter(t=>t&&typeof t=="string").join(" "),rt=(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 ne(a,t,s){return a.unit==="%"?{...Se,...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"?{...Se,...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}:{...Se,...a,unit:"px"}}function it(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),u=Math.min(h,l),d=Math.min(o,n);t&&(t>1?(x=c?c*t:x,g=x/t,u=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>u&&((s==="sw"||s=="nw")&&(i.x-=u-i.width),i.width=u),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 Fs(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 re={capture:!0,passive:!1};let $s=0;const Z=class U extends m.PureComponent{constructor(){super(...arguments),I(this,"docMoveBound",!1),I(this,"mouseDownOnCrop",!1),I(this,"dragStarted",!1),I(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),I(this,"componentRef",m.createRef()),I(this,"mediaRef",m.createRef()),I(this,"resizeObserver"),I(this,"initChangeCalled",!1),I(this,"instanceId",`rc-${$s++}`),I(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),I(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 u=t.clientX-n.x,d=t.clientY-n.y;let b=0,p=0;c==="ne"||c=="e"?(b=u-(r.x+r.width),p=d-r.y,x=r.x,g=r.y+r.height):c==="se"||c==="s"?(b=u-(r.x+r.width),p=d-(r.y+r.height),x=r.x,g=r.y):c==="sw"||c=="w"?(b=u-r.x,p=d-(r.y+r.height),x=r.x+r.width,g=r.y):(c==="nw"||c=="n")&&(b=u-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})}),I(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),ne(x,h.width,h.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),I(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(),rt(s,o)||n(G(o,c.width,c.height),ne(o,c.width,c.height))}),I(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=ae(i.x,0,o.width-i.width),i.y=ae(i.y,0,o.height-i.height);const g=G(i,o.width,o.height),u=ne(i,o.width,o.height);n(g,u),r&&r(g,u)}}),I(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,u=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,u.width,u.height),p=Fs(b,t.key,d,s),j=it(p,l,s,u.width,u.height,c,h,o,i);if(!rt(n,j)){const w=ne(j,u.width,u.height);x(j,w),g&&g(j,w)}}),I(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),ne(s,c.width,c.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),I(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),ne(s,n,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,re),this.document.addEventListener("pointerup",this.onDocPointerDone,re),this.document.addEventListener("pointercancel",this.onDocPointerDone,re),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,re),this.document.removeEventListener("pointerup",this.onDocPointerDone,re),this.document.removeEventListener("pointercancel",this.onDocPointerDone,re),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=ae(t.startCropX+n,0,s.width-l.width),l.y=ae(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,u=t.clientY-t.startClientY;(c&&x==="nw"||x==="w"||x==="sw")&&(g=Math.min(g,-c)),(h&&x==="nw"||x==="n"||x==="ne")&&(u=Math.min(u,-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(u),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=u):i==="sw"?(d.x=t.startCropX+g,d.y=t.startCropY,d.width=Math.abs(g),s?d.height=d.width/s:d.height=u):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(u),d.y=t.startCropY+u));const b=it(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=ae(o.x,0,r.width-o.width),o.y=ae(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={...Se,...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,u=r?this.renderCropSelection():null,d=zs("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,u)}};I(Z,"xOrds",["e","w"]),I(Z,"yOrds",["n","s"]),I(Z,"xyOrds",["nw","ne","se","sw"]),I(Z,"nudgeStep",1),I(Z,"nudgeStepMedium",10),I(Z,"nudgeStepLarge",100),I(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 Ps=Z;const Os=[{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"}],Us={"image/jpeg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/tiff":".tiff"};function ze(a,t){return a?ut.find(s=>s.value===a)?.ext||`.${a}`:Us[t]||".jpg"}function Ls(a,t){const s=a.lastIndexOf(".");return(s>0?a.substring(0,s):a)+t}function Hs({host:a,media:t,onClose:s,onSaved:l}){const n=m.useRef(null),[r,c]=m.useState(),[h,o]=m.useState(),[i,x]=m.useState(""),[g,u]=m.useState(""),[d,b]=m.useState(""),[p,j]=m.useState(""),[w,A]=m.useState("80"),[M,R]=m.useState(()=>{const v=ze("",t.mimeType),_=t.filename.lastIndexOf(".");return`${_>0?t.filename.substring(0,_):t.filename}-transformed${v}`});function z(v){const _=v==="__original__"?"":v;j(_);const q=ze(_,t.mimeType);R(se=>Ls(se,q))}const $=kt(a,t.mediaId),[y,C]=m.useState(null),P=m.useCallback(()=>{if(!h||!y)return null;const v=(t.width??y.width)/y.width,_=(t.height??y.height)/y.height;return{cropX:Math.round(h.x*v),cropY:Math.round(h.y*_),cropW:Math.round(h.width*v),cropH:Math.round(h.height*_)}},[h,t.width,t.height,y]),H=m.useMemo(()=>P(),[P]);async function ue(){const v=H,_=g?parseInt(g):void 0,q=d?parseInt(d):void 0;if(!v&&!_&&!q&&!p){T.error("Please specify a crop, resize, or format change");return}if(!M.trim()){T.error("Filename is required");return}const se=ze(p,t.mimeType);if(!M.trim().toLowerCase().endsWith(se)){T.error(`Filename must end with ${se} to match the output format`);return}try{const F=await $.mutateAsync({...v??{},..._?{width:_}:{},...q?{height:q}:{},...p?{format:p}:{},...w?{quality:parseInt(w)}:{},filename:M.trim()});T.success("Transform saved as new media"),l?.(F),s()}catch(F){T.error("Transform failed",{description:F instanceof Error?F.message:void 0})}}function V(v){x(v==="__free__"?"":v),c(void 0),o(void 0)}function Qe(v){if(!v)return;const _=v.split("/");return _.length===2?Number(_[0])/Number(_[1]):Number(v)||void 0}const me=Qe(i);return e.jsx(ie,{open:!0,onOpenChange:()=>s(),children:e.jsxs(le,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Transform Image"}),e.jsx(de,{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(Ps,{crop:r,onChange:v=>c(v),onComplete:v=>o(v),aspect:me,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 _=v.currentTarget;C({width:_.naturalWidth,height:_.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(L,{children:"Crop aspect ratio"}),e.jsxs(ge,{value:i||"__free__",onValueChange:V,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Free"})}),e.jsx(je,{children:Os.map(v=>e.jsx(te,{value:v.value||"__free__",children:v.label},v.value||"__free__"))})]}),h&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Crop: ",H?.cropW,"×",H?.cropH," at (",H?.cropX,", ",H?.cropY,")"]}),h&&e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>{c(void 0),o(void 0)},children:"Clear crop"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Resize (optional)"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Width",value:g,onChange:v=>u(v.target.value),min:1,max:2048})}),e.jsx("div",{children:e.jsx(K,{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(L,{children:"Output format"}),e.jsxs(ge,{value:p||"__original__",onValueChange:z,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Original"})}),e.jsx(je,{children:ut.map(v=>e.jsx(te,{value:v.value||"__original__",children:v.label},v.value||"__original__"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Quality (1-100)"}),e.jsx(K,{type:"number",value:w,onChange:v=>A(v.target.value),min:1,max:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Save as filename"}),e.jsx(K,{value:M,onChange:v=>R(v.target.value)})]})]})]}),e.jsxs(he,{children:[e.jsx(D,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(D,{onClick:ue,disabled:$.isPending,children:[$.isPending&&e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}),"Save as New Image"]})]})]})})}const Xs=new Set(["image/jpeg","image/png","image/gif","image/webp","image/avif","image/tiff"]);function Ys({host:a,media:t,onClose:s,onDeleted:l,folders:n,tagSuggestions:r}){const[c,h]=m.useState(t.alt??""),[o,i]=m.useState(t.caption??""),[x,g]=m.useState(t.userTags??[]),[u,d]=m.useState(t.folderId||"__none__"),[b,p]=m.useState(!1),j=Xs.has(t.mimeType),w=St(a,t.mediaId),A=Tt(a,t.mediaId),{data:M,isLoading:R}=It(a,t.mediaId),z=t.tags.filter(C=>!t.userTags?.includes(C));async function $(){try{await w.mutateAsync({alt:c,caption:o,userTags:x,folderId:u==="__none__"?"":u}),T.success("Media updated"),s()}catch(C){T.error("Failed to update",{description:C instanceof Error?C.message:void 0})}}async function y(){try{await A.mutateAsync(),T.success("Media deleted"),l?.(t.mediaId),s()}catch(C){T.error("Failed to delete",{description:C instanceof Error?C.message:void 0})}}return e.jsxs(ie,{open:!0,onOpenChange:()=>s(),children:[e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsx(ce,{children:t.filename}),e.jsx(de,{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}`," · ",Le(t.uploadedAt)]}),e.jsxs("div",{className:"flex gap-2",children:[j&&e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>p(!0),children:[e.jsx(Xt,{className:"mr-1.5 h-3.5 w-3.5"}),"Transform"]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(W(t.url)),T.success("URL copied to clipboard")},children:[e.jsx(Pe,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy URL"]})]})]}),z.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(L,{className:"text-xs text-muted-foreground",children:"Auto-detected tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:z.map(C=>e.jsx(Oe,{variant:"outline",className:"text-xs",children:C},C))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Tags"}),e.jsx($e,{tags:x,onChange:g,placeholder:"Add tags...",suggestions:r})]}),n&&n.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Folder"}),e.jsxs(ge,{value:u,onValueChange:d,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"No folder"})}),e.jsxs(je,{children:[e.jsx(te,{value:"__none__",children:"No folder"}),n.map(C=>e.jsx(te,{value:C.folderId,children:C.name},C.folderId))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"alt",children:"Alt text"}),e.jsx(K,{id:"alt",value:c,onChange:C=>h(C.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"caption",children:"Caption"}),e.jsx(K,{id:"caption",value:o,onChange:C=>i(C.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{className:"text-xs text-muted-foreground",children:"Used in"}),R?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}),"Checking usage..."]}):M?.references.length?e.jsxs("div",{className:"space-y-1",children:[M.references.map(C=>e.jsxs(Nt,{to:`/sites/${a}/content/${C.collection}/${C.contentId}`,className:"flex items-center gap-2 rounded px-2 py-1 text-sm hover:bg-muted",onClick:s,children:[e.jsx(ct,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:C.title||C.contentId}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",C.collection,")"]})]},C.contentId)),M.note&&e.jsx("p",{className:"text-muted-foreground text-xs italic",children:M.note})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Not referenced in any content."})]})]}),e.jsxs(he,{className:"flex justify-between",children:[e.jsxs(He,{children:[e.jsx(Ts,{asChild:!0,children:e.jsxs(D,{variant:"destructive",size:"sm",children:[e.jsx(Yt,{className:"mr-2 h-4 w-4"}),"Delete"]})}),e.jsxs(Xe,{children:[e.jsxs(Ye,{children:[e.jsx(Be,{children:"Delete media?"}),e.jsxs(Ke,{children:["This will permanently delete “",t.filename,"”. This action cannot be undone."]})]}),e.jsxs(We,{children:[e.jsx(Ve,{children:"Cancel"}),e.jsx(qe,{onClick:y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(D,{onClick:$,children:"Save"})]})]})]}),b&&e.jsx(Hs,{host:a,media:t,onClose:()=>p(!1),onSaved:()=>s()})]})}function Bs({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(Oe,{variant:t===l?"default":"secondary",className:"cursor-pointer select-none",onClick:()=>s(t===l?void 0:l),children:l},l)),t&&e.jsxs(D,{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}=js({id:a,data:{type:"folder"}});return e.jsx("div",{ref:s,children:t(l)})}function lt({host:a,selectedFolderId:t,onSelect:s}){const{data:l}=ot(a),n=Mt(a),r=Rt(a),c=_t(a),[h,o]=m.useState(!1),[i,x]=m.useState(""),[g,u]=m.useState(null),[d,b]=m.useState(""),[p,j]=m.useState(null),w=m.useRef(null),A=m.useRef(null),M=l?.items??[];m.useEffect(()=>{h&&w.current?.focus()},[h]),m.useEffect(()=>{g&&A.current?.focus()},[g]);async function R(){const y=i.trim();if(!y){o(!1),x("");return}try{await n.mutateAsync(y),T.success("Folder created")}catch(C){T.error("Failed to create folder",{description:C instanceof Error?C.message:void 0})}o(!1),x("")}async function z(y){const C=d.trim();if(!C){u(null);return}try{await r.mutateAsync({folderId:y,name:C}),T.success("Folder renamed")}catch(P){T.error("Failed to rename folder",{description:P instanceof Error?P.message:void 0})}u(null)}async function $(){if(p){try{await c.mutateAsync(p.folderId),T.success("Folder deleted"),t===p.folderId&&s(null)}catch(y){T.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(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>o(!0),children:e.jsx(Bt,{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(ee,{className:"h-4 w-4"}),"All Media"]})})}),M.map(y=>e.jsx(Fe,{id:y.folderId,children:C=>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",C&&"ring-2 ring-primary bg-primary/10"),children:g===y.folderId?e.jsx(K,{ref:A,value:d,onChange:P=>b(P.target.value),onKeyDown:P=>{P.key==="Enter"&&z(y.folderId),P.key==="Escape"&&u(null)},onBlur:()=>z(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(ee,{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(Kt,{children:[e.jsx(Wt,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 group-hover:opacity-100",children:e.jsx(Vt,{className:"h-3.5 w-3.5"})})}),e.jsxs(qt,{align:"end",children:[e.jsx(at,{onClick:()=>{u(y.folderId),b(y.name)},children:"Rename"}),e.jsx(at,{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(ee,{className:"h-4 w-4"}),"Unfiled"]})})}),h&&e.jsx("div",{className:"px-3 py-1.5",children:e.jsx(K,{ref:w,value:i,onChange:y=>x(y.target.value),onKeyDown:y=>{y.key==="Enter"&&R(),y.key==="Escape"&&(o(!1),x(""))},onBlur:R,placeholder:"Folder name...",className:"h-7 text-sm"})})]}),e.jsx(He,{open:!!p,onOpenChange:()=>j(null),children:e.jsxs(Xe,{children:[e.jsxs(Ye,{children:[e.jsx(Be,{children:"Delete folder?"}),e.jsxs(Ke,{children:["This will delete the folder “",p?.name,"”. Media items in this folder will become unfiled."]})]}),e.jsxs(We,{children:[e.jsx(Ve,{children:"Cancel"}),e.jsx(qe,{onClick:$,children:"Delete"})]})]})})]})}function Ks({selectedCount:a,folders:t,onDelete:s,onMove:l,onAddTags:n,onRemoveTags:r,onClear:c,isPending:h}){const[o,i]=m.useState(null),[x,g]=m.useState(""),[u,d]=m.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(D,{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(D,{size:"sm",variant:"destructive",onClick:()=>i("delete"),disabled:h,className:"shrink-0",children:"Delete"}),e.jsx(D,{size:"sm",variant:"outline",onClick:()=>i("move"),disabled:h,className:"shrink-0",children:"Move to…"}),e.jsx(D,{size:"sm",variant:"outline",onClick:()=>i("addTags"),disabled:h,className:"shrink-0",children:"Add tags"}),e.jsx(D,{size:"sm",variant:"outline",onClick:()=>i("removeTags"),disabled:h,className:"shrink-0",children:"Remove tags"})]})]}),e.jsx(ie,{open:o==="delete",onOpenChange:p=>!p&&b(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Delete ",a," item",a!==1?"s":"","?"]}),e.jsx(de,{children:"This action cannot be undone. The selected media items will be permanently deleted."})]}),e.jsxs(he,{children:[e.jsx(D,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(D,{variant:"destructive",onClick:async()=>{b(),await s()},disabled:h,children:[h&&e.jsx(J,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})}),e.jsx(ie,{open:o==="move",onOpenChange:p=>!p&&b(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Move ",a," item",a!==1?"s":""]}),e.jsx(de,{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(te,{value:"__unfiled__",children:"Unfiled"}),t.map(p=>e.jsx(te,{value:p.folderId,children:p.name},p.folderId))]})]}),e.jsxs(he,{children:[e.jsx(D,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(D,{onClick:async()=>{const p=x==="__unfiled__"?"":x;b(),await l(p)},disabled:!x||h,children:[h&&e.jsx(J,{className:"mr-1 h-3 w-3 animate-spin"}),"Move"]})]})]})}),e.jsx(ie,{open:o==="addTags",onOpenChange:p=>!p&&b(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Add tags to ",a," item",a!==1?"s":""]}),e.jsx(de,{className:"sr-only",children:"Select tags to add to the selected items"})]}),e.jsx($e,{tags:u,onChange:d,placeholder:"Add tags..."}),e.jsxs(he,{children:[e.jsx(D,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(D,{onClick:async()=>{const p=[...u];b(),await n(p)},disabled:u.length===0||h,children:[h&&e.jsx(J,{className:"mr-1 h-3 w-3 animate-spin"}),"Add"]})]})]})}),e.jsx(ie,{open:o==="removeTags",onOpenChange:p=>!p&&b(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Remove tags from ",a," item",a!==1?"s":""]}),e.jsx(de,{className:"sr-only",children:"Select tags to remove from the selected items"})]}),e.jsx($e,{tags:u,onChange:d,placeholder:"Tags to remove..."}),e.jsxs(he,{children:[e.jsx(D,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(D,{onClick:async()=>{const p=[...u];b(),await r(p)},disabled:u.length===0||h,children:[h&&e.jsx(J,{className:"mr-1 h-3 w-3 animate-spin"}),"Remove"]})]})]})})]})}function Ws({onFiles:a,children:t}){const[s,l]=m.useState(!1),n=m.useRef(0),r=m.useCallback(i=>{i.preventDefault(),i.dataTransfer.types.includes("Files")&&(n.current++,l(!0))},[]),c=m.useCallback(i=>{i.preventDefault(),n.current--,n.current===0&&l(!1)},[]),h=m.useCallback(i=>{i.preventDefault(),i.dataTransfer.dropEffect="copy"},[]),o=m.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(xe,{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 Vs({queue:a}){const{items:t,retry:s,dismiss:l,clearCompleted:n}=a,[r,c]=m.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(m.useEffect(()=>{if(g&&t.length>0){const d=setTimeout(()=>c(!0),2e3);return()=>clearTimeout(d)}},[g,t.length]),t.length===0)return null;const u=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:u}),e.jsxs("div",{className:"flex items-center gap-1",children:[g&&e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:n,children:"Clear"}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>c(!r),children:r?e.jsx(Qt,{className:"h-4 w-4"}):e.jsx(Gt,{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(J,{className:"h-4 w-4 shrink-0 animate-spin"}),d.status==="complete"&&e.jsx(Zt,{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(D,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>s(d.id),children:e.jsx(Jt,{className:"h-3 w-3"})}),(d.status==="complete"||d.status==="error")&&e.jsx(D,{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 qs=3;let Qs=0;function Gs(a,t){const[s,l]=m.useState([]),n=At(a),r=Et(a),c=m.useRef(0),h=m.useRef(s);h.current=s;const o=m.useRef(new Map),i=m.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,M)=>{const R=new XMLHttpRequest;o.current.set(p.id,R),R.upload.onprogress=z=>{if(z.lengthComputable){const $=Math.round(z.loaded/z.total*100);l(y=>y.map(C=>C.id===p.id?{...C,progress:$}:C))}},R.onload=()=>{o.current.delete(p.id),R.status>=200&&R.status<300?A():M(new Error(`Upload failed: ${R.status}`))},R.onerror=()=>{o.current.delete(p.id),M(new Error("Network error"))},R.onabort=()=>{o.current.delete(p.id),M(new Error("Upload aborted"))},R.open("PUT",j),R.setRequestHeader("Content-Type",p.file.type),R.send(p.file)}),await r.mutateAsync({mediaId:w,filename:p.file.name,folderId:p.folderId}),l(A=>A.map(M=>M.id===p.id?{...M,status:"complete",progress:100}:M))}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=m.useRef(i);x.current=i,m.useEffect(()=>{const p=s.filter(w=>w.status==="pending"),j=qs-c.current;for(let w=0;w<Math.min(p.length,j);w++)x.current(p[w])},[s]),m.useEffect(()=>{const p=o.current;return()=>{p.forEach(j=>j.abort())}},[]);const g=m.useCallback(p=>{const j=Array.from(p).map(w=>({id:`upload-${Qs++}`,file:w,folderId:t||void 0,status:"pending",progress:0}));l(w=>[...w,...j])},[t]),u=m.useCallback(p=>{l(j=>j.map(w=>w.id===p?{...w,status:"pending",progress:0,error:void 0}:w))},[]),d=m.useCallback(p=>{l(j=>j.filter(w=>w.id!==p))},[]),b=m.useCallback(()=>{l(p=>p.filter(j=>j.status!=="complete"&&j.status!=="error"))},[]);return{items:s,addFiles:g,retry:u,dismiss:d,clearCompleted:b}}function Zs({items:a,currentIndex:t,onClose:s,onNavigate:l}){const n=a[t],r=t>0,c=t<a.length-1,h=m.useRef(null),o=m.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 m.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 pt-[max(0.75rem,env(safe-area-inset-top,0px))] pl-[max(1rem,env(safe-area-inset-left,0px))] pr-[max(1rem,env(safe-area-inset-right,0px))] 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(D,{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(D,{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(es,{className:"h-8 w-8"})}),c&&e.jsx(D,{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(ts,{className:"h-8 w-8"})})]})]}):null}function Js({open:a,duplicates:t,fileCount:s,onContinue:l,onCancel:n}){return e.jsx(He,{open:a,onOpenChange:r=>!r&&n(),children:e.jsxs(Xe,{children:[e.jsxs(Ye,{children:[e.jsx(Be,{children:"Possible duplicates found"}),e.jsx(Ke,{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(Ie,{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)," ·"," ",Ue(r.uploadedAt)]})]})]},r.mediaId))}),e.jsxs(We,{children:[e.jsx(Ve,{onClick:n,children:"Cancel"}),e.jsx(qe,{onClick:l,children:"Upload Anyway"})]})]})})}function ea(a){const[t,s]=m.useState(()=>{try{const n=localStorage.getItem(`viewMode:${a}`);if(n==="grid"||n==="list")return n}catch{}return"grid"}),l=m.useCallback(n=>{s(n);try{localStorage.setItem(`viewMode:${a}`,n)}catch{}},[a]);return[t,l]}const ta=({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},sa=[{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 aa({item:a,selected:t,onToggle:s,onClick:l,folderName:n,onLightbox:r}){const{attributes:c,listeners:h,setNodeRef:o,isDragging:i}=dt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),x=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";function g(u){u.stopPropagation(),navigator.clipboard.writeText(W(a.url)),T.success("URL copied to clipboard")}return e.jsx(hs,{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(us,{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:u=>u.stopPropagation(),onClick:u=>u.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:u=>u.stopPropagation(),onClick:u=>u.stopPropagation(),children:[e.jsx(Ce,{children:e.jsxs(Ne,{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(Pe,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{children:"Copy URL"})]})}),x&&r&&e.jsx(Ce,{children:e.jsxs(Ne,{children:[e.jsx(De,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:u=>{u.stopPropagation(),r()},children:e.jsx(ds,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{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(Ie,{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(ee,{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(Ne,{children:[e.jsx(De,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ue(a.uploadedAt)})}),e.jsx(ke,{children:Le(a.uploadedAt)})]})})]}),a.tags.length>0&&e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(u=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-0.5 text-[10px]",children:u},u)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})]})]})})}function wa(){const{host:a}=Dt(),t=ss(),[s,l]=ea("media"),[n,r]=m.useState("date_desc"),[c,h]=m.useState(""),[o,i]=m.useState(""),[x,g]=m.useState(null),[u,d]=m.useState(null),[b,p]=m.useState(void 0),[j,w]=m.useState(new Set),[A,M]=m.useState(null),[R,z]=m.useState(null),[$,y]=m.useState(null),[C,P]=m.useState([]),[H,ue]=m.useState(!1),V=m.useRef(null);Is({title:"Media",actions:e.jsx(D,{size:"sm",onClick:()=>V.current?.click(),children:e.jsx(xe,{className:"h-4 w-4"})})});const me=Gs(a,u&&u!=="unfiled"?u:void 0),v=zt(a),_=Ft(a),q=vs(ys(Ns,{activationConstraint:{distance:t?1e5:8}}));m.useEffect(()=>{const f=setTimeout(()=>{i(N=>{const k=c;return N!==k&&w(new Set),k})},300);return()=>clearTimeout(f)},[c]);const se=u===null?void 0:u==="unfiled"?"":u,{data:F,isLoading:mt}=$t(a,{sort:n,q:o||void 0,folderId:se,tag:b}),{data:Ge}=ot(a),ye=m.useMemo(()=>Ge?.items??[],[Ge?.items]),Me=m.useMemo(()=>{const f=new Map;for(const N of ye)f.set(N.folderId,N.name);return f},[ye]),be=m.useMemo(()=>(F?.items??[]).filter(f=>f.mimeType.startsWith("image/")&&f.mimeType!=="image/svg+xml"),[F?.items]),Re=m.useMemo(()=>{const f=new Map;return be.forEach((N,k)=>f.set(N.mediaId,k)),f},[be]),{allTags:xt,allUserTags:pt}=m.useMemo(()=>{const f=F?.items??[],N=new Set,k=new Set;for(const E of f){for(const X of E.tags)N.add(X);for(const X of E.userTags??[])k.add(X)}return{allTags:Array.from(N).sort(),allUserTags:Array.from(k).sort()}},[F?.items]),_e=F?.items.map(f=>f.mediaId)??[],Ae=_e.length>0&&_e.every(f=>j.has(f));function Ze(f){w(N=>{const k=new Set(N);return k.has(f)?k.delete(f):k.add(f),k})}function Je(){w(Ae?new Set:new Set(_e))}async function gt(){const f=[...j],k=(await v.mutateAsync({mediaIds:f,action:"delete"})).failed.length;k?T.error(`${k} of ${f.length} failed to delete`):T.success(`${f.length} item(s) deleted`),w(new Set)}async function ft(f){const N=[...j],E=(await v.mutateAsync({mediaIds:N,action:"move",folderId:f})).failed.length;E?T.error(`${E} of ${N.length} failed to move`):T.success(`${N.length} item(s) moved`),w(new Set)}async function wt(f){const N=[...j],E=(await v.mutateAsync({mediaIds:N,action:"addTags",tags:f})).failed.length;E?T.error(`${E} of ${N.length} failed`):T.success(`Tags added to ${N.length} item(s)`),w(new Set)}async function jt(f){const N=[...j],E=(await v.mutateAsync({mediaIds:N,action:"removeTags",tags:f})).failed.length;E?T.error(`${E} of ${N.length} failed`):T.success(`Tags removed from ${N.length} item(s)`),w(new Set)}async function et(f){const N=Array.from(f),k=N.slice(0,5),E=[];for(const X of k)try{const Ee=await _.mutateAsync({filename:X.name,size:X.size});E.push(...Ee.duplicates)}catch{}E.length>0?(y(N),P(E)):me.addFiles(N)}function vt(f){f.target.files&&et(f.target.files),V.current&&(V.current.value="")}function yt(f){M(String(f.active.id))}function bt(f){M(null);const{active:N,over:k}=f;if(!k||k.data.current?.type!=="folder")return;const E=k.id==="unfiled"||k.id==="all-media"?"":String(k.id),X=j.has(String(N.id))?[...j]:[String(N.id)];v.mutateAsync({mediaIds:X,action:"move",folderId:E}).then(Ee=>{const st=Ee.failed.length;st?T.error(`${st} of ${X.length} failed to move`):T.success(`${X.length} item(s) moved`)})}function Ct(){M(null)}const Q=A?F?.items.find(f=>f.mediaId===A):null,tt=A&&j.has(A)?j.size:1;return e.jsxs(bs,{sensors:q,modifiers:[ta],onDragStart:yt,onDragEnd:bt,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(lt,{host:a,selectedFolderId:u,onSelect:f=>{d(f),w(new Set)}})}),e.jsx(as,{open:H,onOpenChange:ue,children:e.jsxs(ns,{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(rs,{className:"sr-only",children:"Folders"}),e.jsx(lt,{host:a,selectedFolderId:u,onSelect:f=>{d(f),w(new Set),ue(!1)}})]})}),e.jsxs(Ws,{onFiles:f=>et(f),children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 md:p-6",children:[!t&&e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Media"}),e.jsx("div",{children:e.jsxs(D,{onClick:()=>V.current?.click(),children:[e.jsx(xe,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),e.jsx("input",{ref:V,type:"file",multiple:!0,className:"hidden",onChange:vt}),j.size>0?e.jsx(Ks,{selectedCount:j.size,folders:ye,onDelete:gt,onMove:ft,onAddTags:wt,onRemoveTags:jt,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(nt,{className:"text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4"}),e.jsx(K,{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:sa.map(f=>e.jsx(te,{value:f.value,children:f.label},f.value))})]}),e.jsx(D,{variant:H?"secondary":"ghost",size:"sm",className:"md:hidden px-2",onClick:()=>ue(!H),"aria-label":"Toggle folders",children:e.jsx(is,{className:"h-4 w-4"})}),!H&&u!==null&&t&&e.jsxs(Oe,{variant:"secondary",className:"gap-1 md:hidden",children:[e.jsx(ee,{className:"h-3 w-3"}),u==="unfiled"?"Unfiled":Me.get(u)??"All Media"]}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx(D,{variant:s==="grid"?"secondary":"ghost",size:"sm",className:"rounded-r-none px-2",onClick:()=>l("grid"),children:e.jsx(ls,{className:"h-4 w-4"})}),e.jsx(D,{variant:s==="list"?"secondary":"ghost",size:"sm",className:"rounded-l-none px-2",onClick:()=>l("list"),children:e.jsx(os,{className:"h-4 w-4"})})]})]}),e.jsx(Bs,{tags:xt,activeTag:b,onTagChange:f=>{p(f),w(new Set)}}),s==="grid"&&(F?.items.length??0)>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Te,{checked:Ae,onCheckedChange:Je,"aria-label":"Select all"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:j.size>0?`${j.size} of ${F.items.length} selected`:"Select all"})]}),mt?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,N)=>e.jsx(cs,{className:"aspect-square"},N))}):F?.items.length?s==="list"?e.jsx(_s,{items:F.items,host:a,onSelect:g,selectedIds:j,onToggle:Ze,onToggleAll:Je,allSelected:Ae,folderMap:u===null?Me:void 0,onLightbox:f=>{const N=Re.get(f.mediaId);N!==void 0&&z(N)}}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:F.items.map(f=>e.jsx(aa,{item:f,selected:j.has(f.mediaId),onToggle:()=>Ze(f.mediaId),onClick:()=>g(f),folderName:u===null?Me.get(f.folderId??""):void 0,onLightbox:Re.has(f.mediaId)?()=>z(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(nt,{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."})]}):u==="unfiled"?e.jsxs(e.Fragment,{children:[e.jsx(ee,{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."})]}):u?e.jsxs(e.Fragment,{children:[e.jsx(ee,{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(xe,{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(D,{className:"mt-4",onClick:()=>V.current?.click(),children:[e.jsx(xe,{className:"mr-2 h-4 w-4"}),"Upload"]})]})}),x&&e.jsx(Ys,{host:a,media:x,onClose:()=>g(null),onDeleted:f=>{w(N=>{if(!N.has(f))return N;const k=new Set(N);return k.delete(f),k})},folders:ye,tagSuggestions:pt})]}),e.jsx(Vs,{queue:me})]})]}),R!==null&&be.length>0&&e.jsx(Zs,{items:be,currentIndex:R,host:a,onClose:()=>z(null),onNavigate:z}),e.jsx(Js,{open:C.length>0,host:a,duplicates:C,fileCount:$?Array.from($).length:0,onContinue:()=>{$&&me.addFiles($),y(null),P([])},onCancel:()=>{y(null),P([])}}),e.jsx(Cs,{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(Ie,{mimeType:Q.mimeType,className:"h-6 w-6"})}),e.jsx("span",{className:"text-sm font-medium",children:tt>1?`Moving ${tt} items`:Q.filename})]})})]})}export{wa as MediaPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,a as Q}from"./tanstack-Bs3zYPPV.js";import{r as u,u as R,f as Z}from"./react-vendor-C2CvUxFh.js";import{L as r,I as h,B as d,v as l,aG as K,S as D,aX as V,aY as X,aZ as z,aF as J,x as W,j as $,a as S,aM as ee,D as P,k as E,l as k,m as L,n as B,o as O}from"./index-b-u0-VCO.js";import{C,a as N,b,d as se,c as w}from"./card-uKxSQehY.js";import{f as ae}from"./format-C88SDH8g.js";import{u as ie}from"./usePageTitle-Do4xyFdL.js";import{u as te,a as ne,b as re}from"./useSiteUsers-BfzIdhvs.js";import{C as q}from"./checkbox-z1kYnX5o.js";import{T as M}from"./textarea-BnjAxJtk.js";import"./radix-C1kb_NqW.js";function le({host:a}){const{data:c,isLoading:n}=te(a),x=ne(a),j=re(a),[i,o]=u.useState({}),[m,g]=u.useState("");u.useEffect(()=>{c&&o(c)},[c]);async function v(){try{await x.mutateAsync(i),l.success("Auth settings saved")}catch(s){l.error("Failed to save",{description:s instanceof Error?s.message:void 0})}}async function A(){if(m)try{await j.mutateAsync(m),l.success("Test email sent")}catch(s){l.error("Failed to send test email",{description:s instanceof Error?s.message:void 0})}}return n||!c?null:e.jsxs(C,{children:[e.jsxs(N,{children:[e.jsx(b,{children:"Site Authentication"}),e.jsx(se,{children:"Enable email OTP authentication for site visitors."})]}),e.jsxs(w,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(q,{id:"auth-enabled",checked:i.enabled??!1,onCheckedChange:s=>o({...i,enabled:s})}),e.jsx(r,{htmlFor:"auth-enabled",children:"Enable site auth"})]}),i.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(q,{id:"allow-signup",checked:i.allowSignup??!1,onCheckedChange:s=>o({...i,allowSignup:s})}),e.jsx(r,{htmlFor:"allow-signup",children:"Allow self-registration"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"session-ttl",children:"Session duration (days)"}),e.jsx(h,{id:"session-ttl",type:"number",min:1,value:Math.round((i.sessionTtl??2592e3)/86400),onChange:s=>o({...i,sessionTtl:parseInt(s.target.value)*86400})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"from-name",children:"Sender name"}),e.jsx(h,{id:"from-name",placeholder:"My Site",value:i.fromName??"",onChange:s=>o({...i,fromName:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-subject",children:"Email subject (Liquid)"}),e.jsx(h,{id:"email-subject",placeholder:"Your login code for {{ site_name }}",value:i.emailSubject??"",onChange:s=>o({...i,emailSubject:s.target.value})}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Variables: ","{{ code }}",", ","{{ site_name }}",", ","{{ user_email }}",", ","{{ user_name }}",", ","{{ expires_minutes }}"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-body",children:"Email HTML body (Liquid)"}),e.jsx(M,{id:"email-body",rows:5,placeholder:"<p>Your code: <strong>{{ code }}</strong></p>",value:i.emailBody??"",onChange:s=>o({...i,emailBody:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-text",children:"Email text body (Liquid)"}),e.jsx(M,{id:"email-text",rows:3,placeholder:"Your code: {{ code }}",value:i.emailTextBody??"",onChange:s=>o({...i,emailTextBody:s.target.value})})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(r,{htmlFor:"test-email",children:"Send test email"}),e.jsx(h,{id:"test-email",type:"email",placeholder:"admin@example.com",value:m,onChange:s=>g(s.target.value)})]}),e.jsx(d,{variant:"outline",onClick:A,disabled:j.isPending||!m,children:"Send"})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(d,{onClick:v,disabled:x.isPending,children:"Save"})})]})]})}function fe(){const{host:a}=R(),{data:c,isLoading:n}=K(a);return n?e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{className:"h-8 w-64"}),e.jsx(D,{className:"h-48 w-full"})]}):c?e.jsx(ce,{site:c},c.host):e.jsx("p",{className:"text-muted-foreground",children:"Site not found."})}function ce({site:a}){const c=Q(),n=V(a.host),x=X(a.host),j=z(a.host),i=Z(),m=J()==="admin",g=a.status==="archived",[v,A]=u.useState(a.name),[s,p]=u.useState(!1),[U,f]=u.useState(!1),[T,y]=u.useState(""),_=W();ie({title:"Configuration"});async function H(t){t.preventDefault();try{await n.mutateAsync({name:v}),l.success("Site updated")}catch(F){l.error("Failed to update site",{description:F instanceof Error?F.message:void 0})}}async function I(){try{await n.mutateAsync({status:"archived"}),l.success("Site archived"),p(!1),i("/sites")}catch(t){l.error("Failed to archive site",{description:t instanceof Error?t.message:void 0})}}async function Y(){try{await n.mutateAsync({status:"active"}),l.success("Site unarchived")}catch(t){l.error("Failed to unarchive site",{description:t instanceof Error?t.message:void 0})}}async function G(){try{await x.mutateAsync(),await j.mutateAsync(),await c.invalidateQueries({queryKey:["sites"]}),l.success("Site deleted"),f(!1),y(""),i("/sites")}catch(t){l.error("Failed to delete site",{description:t instanceof Error?t.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(C,{children:[e.jsx(N,{children:e.jsx(b,{children:"General"})}),e.jsx(w,{children:e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"name",children:"Site Name"}),e.jsx(h,{id:"name",value:v,onChange:t=>A(t.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Host"}),e.jsx(h,{value:a.host,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Status"}),e.jsx("div",{className:"flex items-center gap-2",children:g?e.jsx($,{variant:"outline",children:"Archived"}):e.jsx(h,{value:a.status,disabled:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Created"}),e.jsx(h,{value:ae(a.createdAt),disabled:!0})]}),e.jsxs(d,{type:"submit",disabled:n.isPending,children:[n.isPending&&e.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),m&&e.jsxs(C,{className:"mt-6",children:[e.jsx(N,{children:e.jsx(b,{children:"Site Status"})}),e.jsx(w,{className:"space-y-4",children:g?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(d,{variant:"outline",onClick:Y,disabled:n.isPending,children:[n.isPending&&e.jsx(S,{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(d,{variant:"outline",onClick:()=>p(!0),children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),"Archive Site"]}),e.jsx(P,{open:s,onOpenChange:p,children:e.jsxs(E,{children:[e.jsxs(k,{children:[e.jsx(L,{children:"Archive Site"}),e.jsxs(B,{children:["Are you sure you want to archive ",e.jsx("strong",{children:a.host}),"? The site will become read-only."]})]}),e.jsxs(O,{children:[e.jsx(d,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(d,{onClick:I,disabled:n.isPending,children:[n.isPending&&e.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Archive"]})]})]})})]})})]}),m&&e.jsx("div",{className:"mt-6",children:e.jsx(le,{host:a.host})}),m&&g&&e.jsxs(C,{className:"border-destructive mt-6",children:[e.jsx(N,{children:e.jsx(b,{className:"text-destructive",children:"Danger Zone"})}),e.jsxs(w,{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(d,{variant:"destructive",onClick:()=>f(!0),children:"Delete Site"}),e.jsx(P,{open:U,onOpenChange:t=>{f(t),t||y("")},children:e.jsxs(E,{children:[e.jsxs(k,{children:[e.jsx(L,{children:"Delete Site"}),e.jsxs(B,{children:["This will permanently delete this site and all its content. Type ",e.jsx("strong",{children:a.host})," to confirm."]})]}),e.jsx(h,{placeholder:a.host,value:T,onChange:t=>y(t.target.value)}),e.jsxs(O,{children:[e.jsx(d,{variant:"outline",onClick:()=>{f(!1),y("")},children:"Cancel"}),e.jsxs(d,{variant:"destructive",onClick:G,disabled:T!==a.host||x.isPending||j.isPending,children:[(x.isPending||j.isPending)&&e.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete Everything"]})]})]})})]})]})]})}export{fe as SiteSettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as v,f as C,r as w}from"./react-vendor-C2CvUxFh.js";import{j as S,m as T}from"./useContent-B2MUK4An.js";import{x as $,w as k,S as h,B as r,a_ as A,a0 as B,aa as E,D as F,i as M,T as O,k as P,l as I,m as U,n as z,o as H,v as j}from"./index-b-u0-VCO.js";import{u as L}from"./usePageTitle-Do4xyFdL.js";import{C as _,a as R,b as V,c as Y}from"./card-uKxSQehY.js";import{f as q}from"./format-C88SDH8g.js";import{M as G}from"./MediaField-DJpYbUA8.js";import"./radix-C1kb_NqW.js";import"./useMedia-CXQpRNYL.js";import"./select-BKaV0BO_.js";import"./media-url-DIg_vSyf.js";function rs(){const{host:a,collection:n,id:o}=v(),c=C(),p=$(),{collections:f}=k(),{data:m,isLoading:b}=S(a,o),N=T(a,o),[g,u]=w.useState(!1),d=f.find(e=>e.name===n);if(L({title:"Submission Detail",showBack:!0,backTo:`/sites/${a}/submissions/${n}`}),b)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(h,{className:"h-8 w-64"}),s.jsx(h,{className:"h-64 w-full"})]});if(!m?.content)return s.jsx("p",{className:"text-muted-foreground",children:"Submission not found."});const i=m.content,l=m.body??i.body,x=i.siteUser;function y(e,t){return t==null?"—":typeof t=="boolean"?t?"Yes":"No":Array.isArray(t)?t.join(", "):String(t)}async function D(){try{await N.mutateAsync(),j.success("Submission deleted"),c(`/sites/${a}/submissions/${n}`)}catch(e){j.error("Failed to delete",{description:e instanceof Error?e.message:void 0})}}return s.jsxs("div",{className:"mx-auto max-w-2xl",children:[!p&&s.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[s.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/sites/${a}/submissions/${n}`),children:[s.jsx(A,{className:"mr-1.5 h-4 w-4"}),"Back"]}),s.jsx("h1",{className:"text-2xl font-semibold",children:"Submission Detail"}),s.jsx("div",{className:"ml-auto",children:s.jsxs(r,{variant:"outline",size:"sm",onClick:()=>c(`/sites/${a}/submissions/${n}/${o}/edit`),children:[s.jsx(B,{className:"mr-1.5 h-4 w-4"}),"Edit"]})})]}),s.jsxs(_,{children:[s.jsx(R,{children:s.jsx(V,{children:i.title||"Untitled"})}),s.jsxs(Y,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:"ID"}),s.jsx("span",{className:"font-mono text-xs",children:i.contentId})]}),!!i.publishedAt&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:"Submitted"}),s.jsx("span",{children:q(i.publishedAt)})]}),x&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:"Submitted by"}),s.jsx("span",{children:x.name||x.email})]})]}),s.jsx(E,{}),s.jsxs("div",{className:"space-y-3",children:[d?.fields?.map(e=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:e.label||e.name}),e.type==="media"?s.jsx(G,{field:e,value:l?.[e.name],onChange:()=>{},disabled:!0}):s.jsx("p",{className:"text-sm whitespace-pre-wrap",children:y(e,l?.[e.name])})]},e.name)),(!d?.fields||d.fields.length===0)&&l&&s.jsx("div",{className:"space-y-3",children:Object.entries(l).map(([e,t])=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:e}),s.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t==null?"—":String(t)})]},e))})]})]})]}),s.jsx("div",{className:"mt-6",children:s.jsxs(F,{open:g,onOpenChange:u,children:[s.jsx(M,{asChild:!0,children:s.jsxs(r,{variant:"destructive",children:[s.jsx(O,{className:"mr-2 h-4 w-4"}),"Delete Submission"]})}),s.jsxs(P,{children:[s.jsxs(I,{children:[s.jsx(U,{children:"Delete submission?"}),s.jsx(z,{children:"This will permanently delete this submission."})]}),s.jsxs(H,{children:[s.jsx(r,{variant:"outline",onClick:()=>u(!1),children:"Cancel"}),s.jsx(r,{variant:"destructive",onClick:D,children:"Delete"})]})]})]})})]})}export{rs as SubmissionDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as I,f as T,r as x}from"./react-vendor-C2CvUxFh.js";import{x as A,w as L,S as f,B as $,a_ as P,L as B,a$ as M,I as m,v as h}from"./index-b-u0-VCO.js";import{j as z,s as U,t as V}from"./useContent-B2MUK4An.js";import{u as D}from"./usePageTitle-Do4xyFdL.js";import{T as H}from"./textarea-BnjAxJtk.js";import{C as O}from"./checkbox-z1kYnX5o.js";import{S as R,a as _,b as q,c as G,d as J}from"./select-BKaV0BO_.js";import{C as K,a as Q,b as W,c as X}from"./card-uKxSQehY.js";import{M as Y}from"./MediaField-DJpYbUA8.js";import"./radix-C1kb_NqW.js";import"./useMedia-CXQpRNYL.js";import"./media-url-DIg_vSyf.js";function ds(){const{host:i,collection:r,id:l}=I(),u=T(),N=A(),{collections:w}=L(),n=!!l,p=w.find(e=>e.name===r),{data:d,isLoading:y}=z(i,l??""),b=U(i),j=V(i,l??""),[v,g]=x.useState({}),[S,k]=x.useState(!n);if(D({title:n?"Edit Submission":"New Submission",showBack:!0,backTo:n?`/sites/${i}/submissions/${r}/${l}`:`/sites/${i}/submissions/${r}`}),x.useEffect(()=>{if(n&&d&&!S){const e=d.body;e&&g({...e}),k(!0)}},[n,d,S]),n&&y)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(f,{className:"h-8 w-64"}),s.jsx(f,{className:"h-64 w-full"})]});function o(e,t){g(a=>({...a,[e]:t}))}function E(e){const t=v[e.name];switch(e.type){case"text":return s.jsx(m,{value:t??"",onChange:a=>o(e.name,a.target.value)});case"textarea":return s.jsx(H,{value:t??"",onChange:a=>o(e.name,a.target.value),rows:4});case"number":return s.jsx(m,{type:"number",value:t!=null?String(t):"",onChange:a=>o(e.name,a.target.value===""?void 0:Number(a.target.value))});case"boolean":return s.jsx(O,{checked:!!t,onCheckedChange:a=>o(e.name,!!a)});case"select":{const a=e.options?.choices??[];return s.jsxs(R,{value:t??"",onValueChange:c=>o(e.name,c),children:[s.jsx(_,{children:s.jsx(q,{placeholder:"Select..."})}),s.jsx(G,{children:a.map(c=>s.jsx(J,{value:c,children:c},c))})]})}case"array":return s.jsx(m,{value:Array.isArray(t)?t.join(", "):t??"",onChange:a=>o(e.name,a.target.value?a.target.value.split(",").map(c=>c.trim()):[]),placeholder:"Comma-separated values"});case"media":return s.jsx(Y,{field:e,value:t,onChange:()=>{},disabled:!0});default:return s.jsx(m,{value:t??"",onChange:a=>o(e.name,a.target.value)})}}async function F(){const e={};for(const[t,a]of Object.entries(v))a!==void 0&&a!==""&&(e[t]=a);try{if(n)await j.mutateAsync(e),h.success("Submission updated"),u(`/sites/${i}/submissions/${r}/${l}`);else{const t=await b.mutateAsync({collection:r,fields:e});h.success("Submission created"),u(`/sites/${i}/submissions/${r}/${t.contentId}`)}}catch(t){h.error(n?"Failed to update":"Failed to create",{description:t instanceof Error?t.message:void 0})}}const C=b.isPending||j.isPending;return s.jsxs("div",{className:"mx-auto max-w-2xl",children:[!N&&s.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[s.jsxs($,{variant:"ghost",size:"sm",onClick:()=>u(n?`/sites/${i}/submissions/${r}/${l}`:`/sites/${i}/submissions/${r}`),children:[s.jsx(P,{className:"mr-1.5 h-4 w-4"}),"Back"]}),s.jsx("h1",{className:"text-2xl font-semibold",children:n?"Edit Submission":"New Submission"})]}),s.jsxs(K,{children:[s.jsx(Q,{children:s.jsx(W,{children:p?.label??r})}),s.jsxs(X,{className:"space-y-4",children:[p?.fields?.map(e=>s.jsxs("div",{className:"space-y-2",children:[s.jsx(B,{htmlFor:`field-${e.name}`,children:e.label||e.name}),s.jsx("div",{id:`field-${e.name}`,children:E(e)})]},e.name)),s.jsx("div",{className:"pt-4",children:s.jsxs($,{onClick:F,disabled:C,children:[s.jsx(M,{className:"mr-1.5 h-4 w-4"}),C?"Saving...":n?"Update":"Create"]})})]})]})]})}export{ds as SubmissionEditPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as O,f as R,r as o}from"./react-vendor-C2CvUxFh.js";import{w as V,x as z,B as S,P as F,T as q,v as T,S as E,y as H}from"./index-b-u0-VCO.js";import{d as Y,c as G}from"./useContent-B2MUK4An.js";import{u as J}from"./usePageTitle-Do4xyFdL.js";import{C as K,c as Q}from"./card-uKxSQehY.js";import{C as N}from"./checkbox-z1kYnX5o.js";import{S as W,a as X,b as Z,c as ee,d as se}from"./select-BKaV0BO_.js";import{T as te,a as ae,b as $,c as h,d as ne,e as x}from"./table-Bozosvl6.js";import{a as A,f as le}from"./format-C88SDH8g.js";import"./radix-C1kb_NqW.js";const re=[{value:"created_desc",label:"Newest first"},{value:"created_asc",label:"Oldest first"}];function be(){const{host:i,collection:l}=O(),f=R(),{collections:P}=V(),[d,M]=o.useState("created_desc"),[U,v]=o.useState(),[r,u]=o.useState(new Set),C=z(),c=P.find(e=>e.name===l);J({title:c?.label??l??""});const _=o.useMemo(()=>{const e={};return d!=="created_desc"&&(e.sort=d),e},[d]),{data:j,isLoading:B}=Y(i,l,_,U),w=G(i),m=j?.items,p=c?.fields,y=o.useMemo(()=>p?p.filter(e=>["text","number","boolean","select"].includes(e.type)).slice(0,4):[],[p]),b=m?.map(e=>e.contentId)??[],I=b.length>0&&b.every(e=>r.has(e));function k(e){u(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})}function D(){u(I?new Set:new Set(b))}function L(e,t){const n=e.fields?.[t];if(n==null)return"—";if(typeof n=="boolean")return n?"Yes":"No";if(typeof n=="number")return String(n);const g=String(n);return g.length>60?g.slice(0,60)+"…":g}return s.jsxs("div",{children:[!C&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:c?.label??l}),s.jsxs(S,{onClick:()=>f(`/sites/${i}/submissions/${l}/new`),children:[s.jsx(F,{className:"mr-1.5 h-4 w-4"}),"New Submission"]})]}),s.jsx("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.size>0&&s.jsxs(S,{variant:"destructive",size:"sm",onClick:async()=>{const e=[...r],a=(await w.mutateAsync(e)).filter(n=>n.status==="rejected").length;a?T.error(`${a} of ${e.length} failed to delete`):T.success(`${e.length} submission(s) deleted`),u(new Set)},disabled:w.isPending,children:[s.jsx(q,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete (",r.size,")"]}),s.jsxs(W,{value:d,onValueChange:e=>{M(e),v(void 0)},children:[s.jsx(X,{className:"w-[150px]",children:s.jsx(Z,{})}),s.jsx(ee,{children:re.map(e=>s.jsx(se,{value:e.value,children:e.label},e.value))})]})]})}),B?s.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((e,t)=>s.jsx(E,{className:"h-12 w-full"},t))}):m?.length?s.jsxs(s.Fragment,{children:[C?s.jsx("div",{className:"grid gap-3","data-testid":"submission-card-view",children:m.map(e=>s.jsx(K,{className:H("cursor-pointer gap-0 overflow-hidden py-0 transition-shadow hover:shadow-md",r.has(e.contentId)&&"ring-2 ring-primary"),onClick:()=>f(`/sites/${i}/submissions/${l}/${e.contentId}`),children:s.jsx(Q,{className:"p-3",children:s.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"font-medium truncate",children:["Submission ",e.contentId.slice(-6)]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e.publishedAt?A(e.publishedAt):"—"}),e.siteUser&&s.jsxs("p",{className:"text-xs text-muted-foreground",children:["by ",e.siteUser.name||e.siteUser.email]})]}),s.jsx(N,{checked:r.has(e.contentId),onCheckedChange:()=>k(e.contentId),onClick:t=>t.stopPropagation(),className:"mt-1"})]})})},e.contentId))}):s.jsxs(te,{children:[s.jsx(ae,{children:s.jsxs($,{children:[s.jsx(h,{className:"w-10",children:s.jsx(N,{checked:I,onCheckedChange:D,"aria-label":"Select all"})}),y.map(e=>s.jsx(h,{children:e.label||e.name},e.name)),c?.requireAuth&&s.jsx(h,{children:"Submitted by"}),s.jsx(h,{children:"Submitted"})]})}),s.jsx(ne,{children:m.map(e=>s.jsxs($,{className:"cursor-pointer",onClick:()=>f(`/sites/${i}/submissions/${l}/${e.contentId}`),children:[s.jsx(x,{onClick:t=>t.stopPropagation(),children:s.jsx(N,{checked:r.has(e.contentId),onCheckedChange:()=>k(e.contentId),"aria-label":`Select submission ${e.contentId.slice(-6)}`})}),y.map(t=>s.jsx(x,{className:"text-muted-foreground text-sm",children:L(e,t.name)},t.name)),c?.requireAuth&&s.jsx(x,{className:"text-muted-foreground text-sm",children:e.siteUser?e.siteUser.name||e.siteUser.email:"—"}),s.jsx(x,{className:"text-muted-foreground",children:e.publishedAt?s.jsx("span",{title:le(e.publishedAt),children:A(e.publishedAt)}):"—"})]},e.contentId))})]}),j?.hasMore&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(S,{variant:"outline",onClick:()=>v(j.cursor??void 0),children:"Load More"})})]}):s.jsx("p",{className:"text-muted-foreground",children:"No submissions yet."})]})}export{be as SubmissionListPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as M}from"./tanstack-Bs3zYPPV.js";import{K as ue,M as de,N as fe}from"./radix-C1kb_NqW.js";import{r as g,R as k}from"./react-vendor-C2CvUxFh.js";import{f as ge,g as pe,h as q,d as be,b as ve,i as me,j as xe,C as B,k as Ie,K as N}from"./core.esm-B_kcYf6n.js";function ze({...e}){return M.jsx(ue,{"data-slot":"collapsible",...e})}function Ke({...e}){return M.jsx(de,{"data-slot":"collapsible-trigger",...e})}function Pe({...e}){return M.jsx(fe,{"data-slot":"collapsible-content",...e})}function F(e,n,t){const r=e.slice();return r.splice(t<0?r.length+t:t,0,r.splice(n,1)[0]),r}function he(e,n){return e.reduce((t,r,s)=>{const a=n.get(r);return a&&(t[s]=a),t},Array(e.length))}function O(e){return e!==null&&e>=0}function ye(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function Re(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const H=e=>{let{rects:n,activeIndex:t,overIndex:r,index:s}=e;const a=F(n,r,t),o=n[s],i=a[s];return!i||!o?null:{x:i.left-o.left,y:i.top-o.top,scaleX:i.width/o.width,scaleY:i.height/o.height}},A={scaleX:1,scaleY:1},Xe=e=>{var n;let{activeIndex:t,activeNodeRect:r,index:s,rects:a,overIndex:o}=e;const i=(n=a[t])!=null?n:r;if(!i)return null;if(s===t){const l=a[o];return l?{x:0,y:t<o?l.top+l.height-(i.top+i.height):l.top-i.top,...A}:null}const d=Ce(a,s,t);return s>t&&s<=o?{x:0,y:-i.height-d,...A}:s<t&&s>=o?{x:0,y:i.height+d,...A}:{x:0,y:0,...A}};function Ce(e,n,t){const r=e[n],s=e[n-1],a=e[n+1];return r?t<n?s?r.top-(s.top+s.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):s?r.top-(s.top+s.height):0:0}const U="Sortable",V=k.createContext({activeIndex:-1,containerId:U,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:H,disabled:{draggable:!1,droppable:!1}});function _e(e){let{children:n,id:t,items:r,strategy:s=H,disabled:a=!1}=e;const{active:o,dragOverlay:i,droppableRects:d,over:l,measureDroppableContainers:c}=ge(),b=pe(U,t),m=i.rect!==null,f=g.useMemo(()=>r.map(x=>typeof x=="object"&&"id"in x?x.id:x),[r]),T=o!=null,y=o?f.indexOf(o.id):-1,v=l?f.indexOf(l.id):-1,E=g.useRef(f),R=!ye(f,E.current),C=v!==-1&&y===-1||R,p=Re(a);q(()=>{R&&T&&c(f)},[R,f,T,c]),g.useEffect(()=>{E.current=f},[f]);const D=g.useMemo(()=>({activeIndex:y,containerId:b,disabled:p,disableTransforms:C,items:f,overIndex:v,useDragOverlay:m,sortedRects:he(f,d),strategy:s}),[y,b,p.draggable,p.droppable,C,f,v,d,m,s]);return k.createElement(V.Provider,{value:D},n)}const De=e=>{let{id:n,items:t,activeIndex:r,overIndex:s}=e;return F(t,r,s).indexOf(n)},Se=e=>{let{containerId:n,isSorting:t,wasDragging:r,index:s,items:a,newIndex:o,previousItems:i,previousContainerId:d,transition:l}=e;return!l||!r||i!==a&&s===o?!1:t?!0:o!==s&&n===d},we={duration:200,easing:"ease"},J="transform",Te=B.Transition.toString({property:J,duration:0,easing:"linear"}),Ee={roleDescription:"sortable"};function Ne(e){let{disabled:n,index:t,node:r,rect:s}=e;const[a,o]=g.useState(null),i=g.useRef(t);return q(()=>{if(!n&&t!==i.current&&r.current){const d=s.current;if(d){const l=Ie(r.current,{ignoreTransform:!0}),c={x:d.left-l.left,y:d.top-l.top,scaleX:d.width/l.width,scaleY:d.height/l.height};(c.x||c.y)&&o(c)}}t!==i.current&&(i.current=t)},[n,t,r,s]),g.useEffect(()=>{a&&o(null)},[a]),a}function Ge(e){let{animateLayoutChanges:n=Se,attributes:t,disabled:r,data:s,getNewIndex:a=De,id:o,strategy:i,resizeObserverConfig:d,transition:l=we}=e;const{items:c,containerId:b,activeIndex:m,disabled:f,disableTransforms:T,sortedRects:y,overIndex:v,useDragOverlay:E,strategy:R}=g.useContext(V),C=Oe(r,f),p=c.indexOf(o),D=g.useMemo(()=>({sortable:{containerId:b,index:p,items:c},...s}),[b,s,p,c]),x=g.useMemo(()=>c.slice(c.indexOf(o)),[c,o]),{rect:$,node:z,isOver:Q,setNodeRef:K}=be({id:o,data:D,disabled:C.droppable,resizeObserverConfig:{updateMeasurementsFor:x,...d}}),{active:S,activatorEvent:W,activeNodeRect:Z,attributes:ee,setNodeRef:P,listeners:te,isDragging:j,over:re,setActivatorNodeRef:ne,transform:se}=ve({id:o,data:D,attributes:{...Ee,...t},disabled:C.draggable}),oe=me(K,P),I=!!S,X=I&&!T&&O(m)&&O(v),_=!E&&j,G=_&&X?se:null,ae=X?G??(i??R)({rects:y,activeNodeRect:Z,activeIndex:m,overIndex:v,index:p}):null,w=O(m)&&O(v)?a({id:o,items:c,activeIndex:m,overIndex:v}):p,h=S?.id,u=g.useRef({activeId:h,items:c,newIndex:w,containerId:b}),ie=c!==u.current.items,Y=n({active:S,containerId:b,isDragging:j,isSorting:I,id:o,index:p,items:c,newIndex:u.current.newIndex,previousItems:u.current.items,previousContainerId:u.current.containerId,transition:l,wasDragging:u.current.activeId!=null}),L=Ne({disabled:!Y,index:p,node:z,rect:$});return g.useEffect(()=>{I&&u.current.newIndex!==w&&(u.current.newIndex=w),b!==u.current.containerId&&(u.current.containerId=b),c!==u.current.items&&(u.current.items=c)},[I,w,b,c]),g.useEffect(()=>{if(h===u.current.activeId)return;if(h!=null&&u.current.activeId==null){u.current.activeId=h;return}const le=setTimeout(()=>{u.current.activeId=h},50);return()=>clearTimeout(le)},[h]),{active:S,activeIndex:m,attributes:ee,data:D,rect:$,index:p,newIndex:w,items:c,isOver:Q,isSorting:I,isDragging:j,listeners:te,node:z,overIndex:v,over:re,setNodeRef:oe,setActivatorNodeRef:ne,setDroppableNodeRef:K,setDraggableNodeRef:P,transform:L??ae,transition:ce()};function ce(){if(L||ie&&u.current.newIndex===p)return Te;if(!(_&&!xe(W)||!l)&&(I||Y))return B.Transition.toString({...l,property:J})}}function Oe(e,n){var t,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(t=e?.draggable)!=null?t:n.draggable,droppable:(r=e?.droppable)!=null?r:n.droppable}}N.Down,N.Right,N.Up,N.Left;export{ze as C,_e as S,F as a,Ke as b,Pe as c,Ge as u,Xe as v};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as r,a as u,b as c}from"./tanstack-Bs3zYPPV.js";import{e as a}from"./index-b-u0-VCO.js";function y(e,t,i,n){const s=a(),o=new URLSearchParams({collection:t});return n&&o.set("cursor",n),i?.q&&o.set("q",i.q),i?.search&&o.set("search",i.search),i?.tag&&o.set("tag",i.tag),i?.status&&o.set("status",i.status),i?.sort&&o.set("sort",i.sort),r({queryKey:["sites",e,"content",t,i??{},n??""],queryFn:()=>s.apiFetch(`/v1/admin/sites/${e}/content?${o.toString()}`),enabled:!!e&&!!t})}function v(e,t){const i=a(),n=new URLSearchParams;t&&n.set("cursor",t);const s=n.toString();return r({queryKey:["sites",e,"content","__all__",t??""],queryFn:()=>i.apiFetch(`/v1/admin/sites/${e}/content${s?`?${s}`:""}`),enabled:!!e})}function m(e,t){const i=a();return r({queryKey:["sites",e,"content-detail",t],queryFn:()=>i.apiFetch(`/v1/admin/sites/${e}/content/${t}`),enabled:!!e&&!!t})}function q(e){const t=a(),i=u();return c({mutationFn:n=>t.apiFetch(`/v1/admin/sites/${e}/content`,{method:"POST",body:JSON.stringify({collection:n.collection,params:{title:n.title,slug:n.slug,body:{}}})}),onSuccess:()=>i.invalidateQueries({queryKey:["sites",e,"content"]})})}function p(e,t){const i=a(),n=u();return c({mutationFn:s=>i.apiFetch(`/v1/admin/sites/${e}/content/${t}/draft`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["sites",e,"content"]}),n.invalidateQueries({queryKey:["sites",e,"content-detail",t]})}})}function $(e,t,i){const n=a();return r({queryKey:["sites",e,"content-published",t],queryFn:()=>n.apiFetch(`/v1/admin/sites/${e}/content/${t}/published`),enabled:!!e&&!!t&&i})}function F(e,t){const i=a(),n=u();return c({mutationFn:s=>i.apiFetch(`/v1/admin/sites/${e}/content/${t}/publish`,{method:"POST",...s!=null?{body:JSON.stringify({publishDate:s})}:{}}),onSuccess:()=>{n.invalidateQueries({queryKey:["sites",e,"content"]}),n.invalidateQueries({queryKey:["sites",e,"content-detail",t]}),n.invalidateQueries({queryKey:["sites",e,"content-published",t]}),n.invalidateQueries({queryKey:["sites",e,"tags"]})}})}function S(e,t){const i=a(),n=u();return c({mutationFn:()=>i.apiFetch(`/v1/admin/sites/${e}/content/${t}/unpublish`,{method:"POST"}),onSuccess:()=>{n.invalidateQueries({queryKey:["sites",e,"content"]}),n.invalidateQueries({queryKey:["sites",e,"content-detail",t]}),n.invalidateQueries({queryKey:["sites",e,"content-published",t]}),n.invalidateQueries({queryKey:["sites",e,"tags"]})}})}function K(e,t){const i=a(),n=u();return c({mutationFn:()=>i.apiFetch(`/v1/admin/sites/${e}/content/${t}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["sites",e,"content"]}),n.invalidateQueries({queryKey:["sites",e,"tags"]})}})}function f(e,t){const i=a(),n=u();return c({mutationFn:s=>i.apiFetch(`/v1/admin/sites/${e}/content/${t}/publish-date`,{method:"PATCH",body:JSON.stringify({publishDate:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["sites",e,"content"]}),n.invalidateQueries({queryKey:["sites",e,"content-detail",t]})}})}function b(e,t){const i=a(),n=u();return c({mutationFn:s=>i.apiFetch(`/v1/admin/sites/${e}/content/${t}/schedule`,{method:"POST",body:JSON.stringify({scheduleAt:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["sites",e,"content"]}),n.invalidateQueries({queryKey:["sites",e,"content-detail",t]})}})}function Q(e,t){const i=a(),n=u();return c({mutationFn:()=>i.apiFetch(`/v1/admin/sites/${e}/content/${t}/unschedule`,{method:"POST"}),onSuccess:()=>{n.invalidateQueries({queryKey:["sites",e,"content"]}),n.invalidateQueries({queryKey:["sites",e,"content-detail",t]})}})}function g(e){const t=a(),i=u();return c({mutationFn:n=>Promise.allSettled(n.map(s=>t.apiFetch(`/v1/admin/sites/${e}/content/${s}/publish`,{method:"POST"}))),onSettled:()=>{i.invalidateQueries({queryKey:["sites",e,"content"]}),i.invalidateQueries({queryKey:["sites",e,"tags"]})}})}function P(e){const t=a(),i=u();return c({mutationFn:n=>Promise.allSettled(n.map(s=>t.apiFetch(`/v1/admin/sites/${e}/content/${s}/unpublish`,{method:"POST"}))),onSettled:()=>{i.invalidateQueries({queryKey:["sites",e,"content"]}),i.invalidateQueries({queryKey:["sites",e,"tags"]})}})}function C(e){const t=a(),i=u();return c({mutationFn:n=>Promise.allSettled(n.map(s=>t.apiFetch(`/v1/admin/sites/${e}/content/${s}`,{method:"DELETE"}))),onSettled:()=>{i.invalidateQueries({queryKey:["sites",e,"content"]}),i.invalidateQueries({queryKey:["sites",e,"tags"]})}})}function O(e,t){const i=a(),n=u();return c({mutationFn:()=>i.apiFetch(`/v1/admin/sites/${e}/content/${t}/discard`,{method:"POST"}),onSuccess:()=>{n.invalidateQueries({queryKey:["sites",e,"content"]}),n.invalidateQueries({queryKey:["sites",e,"content-detail",t]})}})}function h(e,t,i){const n=a();return r({queryKey:["sites",e,"content-detail",t,"versions",i],queryFn:()=>n.apiFetch(`/v1/admin/sites/${e}/content/${t}/versions/${i}`),enabled:!!e&&!!t&&!!i})}function T(e,t){const i=a();return r({queryKey:["sites",e,"content-detail",t,"versions"],queryFn:async()=>({items:(await i.apiFetch(`/v1/admin/sites/${e}/content/${t}/versions`)).versions??[]}),enabled:!!e&&!!t})}function U(e){const t=a(),i=u();return c({mutationFn:n=>t.apiFetch(`/v1/admin/sites/${e}/submissions/${n.collection}`,{method:"POST",body:JSON.stringify({fields:n.fields})}),onSuccess:()=>i.invalidateQueries({queryKey:["sites",e,"content"]})})}function D(e,t){const i=a(),n=u();return c({mutationFn:s=>i.apiFetch(`/v1/admin/sites/${e}/submissions/${t}`,{method:"PUT",body:JSON.stringify({fields:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["sites",e,"content"]}),n.invalidateQueries({queryKey:["sites",e,"content-detail",t]})}})}function J(e,t,i){const n=a();return r({queryKey:["sites",e,"content-references",t],queryFn:()=>n.apiFetch(`/v1/admin/sites/${e}/content/${t}/references`),enabled:!!e&&!!t&&i})}export{g as a,P as b,C as c,y as d,q as e,p as f,$ as g,h,T as i,m as j,F as k,S as l,K as m,f as n,b as o,Q as p,O as q,J as r,U as s,D as t,v as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as c}from"./react-vendor-C2CvUxFh.js";import{b0 as i}from"./index-b-u0-VCO.js";function f(e){const r=i(),o=c.useRef("");c.useEffect(()=>{if(!r)return;const t=`${e.title}|${e.showBack??""}|${e.backTo??""}|${e.badge?.label??""}|${e.badge?.variant??""}|${e.subtitle??""}`;t!==o.current&&(o.current=t,r.setTitleBar(e))})}export{f as u};
|