headroom-cms 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/assets/AdminsPage-DYJhlQnA.js +1 -0
- package/admin/assets/AllContentPage-DShBvFru.js +1 -0
- package/admin/assets/{ApiKeysPage-B7eN8Oy5.js → ApiKeysPage-DONrd-TJ.js} +1 -1
- package/admin/assets/{AuditPage-hd-SaWMS.js → AuditPage-BwhYu96L.js} +1 -1
- package/admin/assets/{BlockEditor-BKqDtxKs.js → BlockEditor-C0KaZUHQ.js} +57 -57
- package/admin/assets/BlockTypeEditPage-BYJfEA6l.js +1 -0
- package/admin/assets/BlockTypesPage-Pf9u78-O.js +1 -0
- package/admin/assets/BulkActionBar-BX-t8fyM.js +1 -0
- package/admin/assets/CollectionEditPage-CQGo9Cbu.js +1 -0
- package/admin/assets/{CollectionsPage-CCtIb9WO.js → CollectionsPage-D-QTkoW_.js} +1 -1
- package/admin/assets/{ContentCreatePage-Ddc6j4WO.js → ContentCreatePage-DujNZXXj.js} +1 -1
- package/admin/assets/ContentEditPage-DyqgEoAe.js +3 -0
- package/admin/assets/ContentListPage-llAlhZTH.js +1 -0
- package/admin/assets/{CustomBlockPreview-A-nwA7RD.js → CustomBlockPreview-CCiZrZhi.js} +1 -1
- package/admin/assets/FieldBuilder-B3-3MTqp.js +3 -0
- package/admin/assets/{LoginPage-B5FcCn1S.js → LoginPage-BlJXP0GH.js} +1 -1
- package/admin/assets/MediaPage-Cad4n33B.js +1 -0
- package/admin/assets/SiteSettingsPage-xfAm3ZKQ.js +1 -0
- package/admin/assets/SitesPage-DnCiSu23.js +1 -0
- package/admin/assets/{TagsPage-CQ9k8IWa.js → TagsPage-DNlaoFCE.js} +1 -1
- package/admin/assets/UsersPage-D_nOx6W9.js +1 -0
- package/admin/assets/{WebhookEditPage-Cj6aTIwf.js → WebhookEditPage-BUvLl4rY.js} +1 -1
- package/admin/assets/{WebhooksPage-wSrRa63x.js → WebhooksPage-CG7WC9Bq.js} +1 -1
- package/admin/assets/{badge-DK6q6X8v.js → badge-ChZ2DZue.js} +1 -1
- package/admin/assets/{card-NiKFR8dW.js → card-DpNr7WTb.js} +1 -1
- package/admin/assets/check-BMpruHpO.js +1 -0
- package/admin/assets/{checkbox-Cv1_Hpta.js → checkbox-VtCfoGic.js} +1 -1
- package/admin/assets/command-98iA8Va4.js +1 -0
- package/admin/assets/contentStatus-BmaiYVOm.js +1 -0
- package/admin/assets/{copy-BIxYwzJE.js → copy-fXL6Ngxi.js} +1 -1
- package/admin/assets/{core.esm-C3N4hsfx.js → core.esm-BtFZvlg0.js} +1 -1
- package/admin/assets/format-C88SDH8g.js +1 -0
- package/admin/assets/index-CwkwXbO-.js +18 -0
- package/admin/assets/index-FYfbavkE.css +1 -0
- package/admin/assets/plus-2Ds_MoqB.js +1 -0
- package/admin/assets/popover-DFInMOpa.js +1 -0
- package/admin/assets/radix-n1vDIPi6.js +51 -0
- package/admin/assets/search-DRNC6QB5.js +1 -0
- package/admin/assets/select-Cj54Wt-H.js +1 -0
- package/admin/assets/{sortable.esm-CL-OXMRL.js → sortable.esm-BUhmZW2_.js} +1 -1
- package/admin/assets/{table-pnzwUf_S.js → table-D4rLgOKa.js} +1 -1
- package/admin/assets/{trash-2-H30Pytad.js → trash-2-CbbWF_O4.js} +1 -1
- package/admin/assets/use-mobile-Cvl5tIVY.js +1 -0
- package/admin/assets/useAdminResolver-B-_1f6SR.js +1 -0
- package/admin/assets/useContent-Cp41wBYR.js +1 -0
- package/admin/assets/useMedia-DjiNKMOU.js +1 -0
- package/admin/assets/{useTags-CiyJ7ytD.js → useTags-BB47vbXO.js} +1 -1
- package/admin/assets/{useWebhooks-D5KIBL2l.js → useWebhooks-DS4Ee8Wk.js} +1 -1
- package/admin/assets/workbox-window.prod.es5-BIl4cyR9.js +2 -0
- package/admin/icons/icon-180x180.png +0 -0
- package/admin/icons/icon-192x192.png +0 -0
- package/admin/icons/icon-512x512.png +0 -0
- package/admin/icons/maskable-icon-512x512.png +0 -0
- package/admin/index.html +11 -6
- package/admin/manifest.webmanifest +1 -0
- package/admin/sw.js +1 -0
- package/admin/workbox-7d58179f.js +1 -0
- package/dist/admin-site.d.ts.map +1 -1
- package/dist/admin-site.js +3 -0
- package/dist/admin-site.js.map +1 -1
- package/dist/image.d.ts.map +1 -1
- package/dist/image.js +3 -0
- package/dist/image.js.map +1 -1
- package/dist/storage.js +1 -1
- package/dist/storage.js.map +1 -1
- package/lambda/api/bootstrap +0 -0
- package/lambda/webhook-worker/bootstrap +0 -0
- package/package.json +2 -2
- package/src/admin-site.ts +3 -0
- package/src/image.ts +3 -0
- package/src/storage.ts +1 -1
- package/admin/assets/AdminsPage-Dc3Rzdwx.js +0 -1
- package/admin/assets/AllContentPage-BhNvrxDQ.js +0 -1
- package/admin/assets/BlockTypeEditPage-Cy3fkD1c.js +0 -1
- package/admin/assets/BlockTypesPage-B8lJ18bi.js +0 -1
- package/admin/assets/BulkActionBar-4v-SYM43.js +0 -1
- package/admin/assets/CollectionEditPage-j3KxUSoP.js +0 -1
- package/admin/assets/ContentEditPage-DOGQTv8S.js +0 -3
- package/admin/assets/ContentListPage-B51lrfUs.js +0 -1
- package/admin/assets/FieldBuilder-B5YuIrq9.js +0 -3
- package/admin/assets/MediaPage-DwVwPIir.js +0 -1
- package/admin/assets/SiteSettingsPage-CimBfAlF.js +0 -1
- package/admin/assets/SitesPage-BBXXQwRM.js +0 -1
- package/admin/assets/UsersPage-j6pRJvSa.js +0 -1
- package/admin/assets/check-UCoo7qN1.js +0 -1
- package/admin/assets/command-Da-hMl-c.js +0 -1
- package/admin/assets/contentStatus-DfWHjFVB.js +0 -1
- package/admin/assets/format-CZ9bpk32.js +0 -1
- package/admin/assets/index-CdJ9sfDz.js +0 -18
- package/admin/assets/index-DOqKbrpW.css +0 -1
- package/admin/assets/media-url-DIg_vSyf.js +0 -1
- package/admin/assets/plus-CTopr28W.js +0 -1
- package/admin/assets/radix-DQ3amgxj.js +0 -51
- package/admin/assets/search-CURbafxm.js +0 -1
- package/admin/assets/select-27FAx7H-.js +0 -1
- package/admin/assets/useAdminResolver-oE0-RZ44.js +0 -1
- package/admin/assets/useContent-CNxWXb6y.js +0 -1
- package/admin/assets/useMedia-BgfZGpqE.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-BO6c-AOu.js";import{r as x,R as D,L as yt,u as bt}from"./react-vendor-DNVhVxD7.js";import{F as Ct,l as Nt,m as kt,n as Dt,o as St,T as Fe,b as Ge,p as Mt,q as It,r as Tt,E as _t,A as Ze,e as Je,f as et,g as tt,h as st,i as at,j as nt,k as rt,U as ye,u as Rt,a as At,s as zt,t as $t,v as Et}from"./useMedia-BgfZGpqE.js";import{n as Y,x as P,F as it,B as C,s as S,D as ie,i as le,j as oe,k as ce,l as de,L as O,I as K,m as he,a as ee,X as xe,J as Ft,K as Pt,M as Ut,N as We,S as Ot}from"./index-CdJ9sfDz.js";import{C as Lt,c as Ht}from"./card-NiKFR8dW.js";import{C as Se}from"./checkbox-Cv1_Hpta.js";import{S as pe,a as ge,b as fe,c as we,d as te,C as Xt,h as Yt}from"./select-27FAx7H-.js";import{s as Bt,t as Kt,u as Wt,v as Vt,w as qt,A as Qt}from"./radix-DQ3amgxj.js";import{d as lt,G as Gt,e as Zt,b as Jt,u as es,a as ts,D as ss,f as as,P as ns}from"./core.esm-C3N4hsfx.js";import{b as je,a as Pe,f as Ue}from"./format-CZ9bpk32.js";import{m as W}from"./media-url-DIg_vSyf.js";import{T as rs,a as is,b as ot,c as H,d as ls,e as X}from"./table-pnzwUf_S.js";import{C as Oe}from"./copy-BIxYwzJE.js";import{B as ct}from"./badge-DK6q6X8v.js";import{T as os}from"./trash-2-H30Pytad.js";import{P as cs}from"./plus-CTopr28W.js";import{C as ds}from"./check-UCoo7qN1.js";import{S as Ve}from"./search-CURbafxm.js";const hs=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],us=Y("chevron-left",hs);const ms=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],xs=Y("crop",ms);const ps=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],gs=Y("file-code",ps);const fs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],ws=Y("film",fs);const js=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ue=Y("folder",js);const vs=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],ys=Y("layout-grid",vs);const bs=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Cs=Y("list",bs);const Ns=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ks=Y("maximize-2",Ns);const Ds=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Ss=Y("music",Ds);const Ms=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Is=Y("refresh-cw",Ms);function be({delayDuration:a=0,...t}){return e.jsx(Bt,{"data-slot":"tooltip-provider",delayDuration:a,...t})}function Ce({...a}){return e.jsx(Kt,{"data-slot":"tooltip",...a})}function Ne({...a}){return e.jsx(Wt,{"data-slot":"tooltip-trigger",...a})}function ke({className:a,sideOffset:t=0,children:s,...l}){return e.jsx(Vt,{children:e.jsxs(qt,{"data-slot":"tooltip-content",sideOffset:t,className:P("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(Qt,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Me({mimeType:a,className:t}){return a==="application/pdf"?e.jsx(it,{className:P("text-blue-500",t)}):a.startsWith("video/")?e.jsx(ws,{className:P("text-purple-500",t)}):a.startsWith("audio/")?e.jsx(Ss,{className:P("text-green-500",t)}):a==="image/svg+xml"?e.jsx(gs,{className:P("text-orange-500",t)}):e.jsx(Ct,{className:P("text-muted-foreground",t)})}function Ts(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 _s({item:a,selected:t,onToggle:s,onSelect:l,onLightbox:n,folderName:r}){const{attributes:u,listeners:h,setNodeRef:o,isDragging:i}=lt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),p=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";return e.jsxs(ot,{ref:o,className:P("cursor-pointer",i&&"opacity-50"),onClick:l,children:[e.jsx(X,{onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(Se,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsx(X,{className:"w-6 p-1",children:e.jsx("div",{className:"cursor-grab text-muted-foreground",...u,...h,children:e.jsx(Gt,{className:"h-4 w-4"})})}),e.jsx(X,{className:"p-1",children:p?e.jsx("img",{src:W(a.urls?.thumb_sm??a.url),alt:a.alt||a.filename,className:P("h-8 w-8 rounded object-cover",n&&"cursor-zoom-in"),onClick:n?m=>{m.stopPropagation(),n()}:void 0}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center",children:e.jsx(Me,{mimeType:a.mimeType,className:"h-5 w-5"})})}),e.jsxs(X,{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(X,{children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ts(a.mimeType)})}),e.jsx(X,{className:"text-right",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:je(a.size)})}),e.jsx(X,{children:e.jsx("span",{className:"text-muted-foreground text-xs",children:a.width&&a.height?`${a.width}×${a.height}`:"—"})}),e.jsx(X,{children:a.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(m=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-[10px]",children:m},m)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})}),e.jsx(X,{children:e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Pe(a.uploadedAt)})}),e.jsx(ke,{children:Ue(a.uploadedAt)})]})})}),e.jsx(X,{onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(C,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(W(a.url)),S.success("URL copied to clipboard")},children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})})]})}function Rs({items:a,host:t,onSelect:s,selectedIds:l,onToggle:n,onToggleAll:r,allSelected:u,onLightbox:h,folderMap:o}){return e.jsxs(rs,{children:[e.jsx(is,{children:e.jsxs(ot,{children:[e.jsx(H,{className:"w-10",children:e.jsx(Se,{checked:u,onCheckedChange:r,"aria-label":"Select all"})}),e.jsx(H,{className:"w-6"}),e.jsx(H,{className:"w-12"}),e.jsx(H,{children:"Filename"}),e.jsx(H,{className:"w-20",children:"Type"}),e.jsx(H,{className:"w-24 text-right",children:"Size"}),e.jsx(H,{className:"w-28",children:"Dimensions"}),e.jsx(H,{className:"w-40",children:"Tags"}),e.jsx(H,{className:"w-32",children:"Uploaded"}),e.jsx(H,{className:"w-10"})]})}),e.jsx(ls,{children:a.map(i=>e.jsx(_s,{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,zs=(a,t,s)=>t in a?As(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,T=(a,t,s)=>zs(a,typeof t!="symbol"?t+"":t,s);const De={x:0,y:0,width:0,height:0,unit:"px"},ae=(a,t,s)=>Math.min(Math.max(a,t),s),$s=(...a)=>a.filter(t=>t&&typeof t=="string").join(" "),qe=(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==="%"?{...De,...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"?{...De,...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}:{...De,...a,unit:"px"}}function Qe(a,t,s,l,n,r=0,u=0,h=l,o=n){const i={...a};let p=Math.min(r,l),m=Math.min(u,n),w=Math.min(h,l),c=Math.min(o,n);t&&(t>1?(p=u?u*t:p,m=p/t,w=h*t):(m=r?r/t:m,p=m*t,c=o/t)),i.y<0&&(i.height=Math.max(i.height+i.y,m),i.y=0),i.x<0&&(i.width=Math.max(i.width+i.x,p),i.x=0);const y=l-(i.x+i.width);y<0&&(i.x=Math.min(i.x,l-p),i.width+=y);const d=n-(i.y+i.height);if(d<0&&(i.y=Math.min(i.y,n-m),i.height+=d),i.width<p&&((s==="sw"||s=="nw")&&(i.x-=p-i.width),i.width=p),i.height<m&&((s==="nw"||s=="ne")&&(i.y-=m-i.height),i.height=m),i.width>w&&((s==="sw"||s=="nw")&&(i.x-=w-i.width),i.width=w),i.height>c&&((s==="nw"||s=="ne")&&(i.y-=c-i.height),i.height=c),t){const j=i.width/i.height;if(j<t){const v=Math.max(i.width/t,m);(s==="nw"||s=="ne")&&(i.y-=v-i.height),i.height=v}else if(j>t){const v=Math.max(i.height*t,p);(s==="sw"||s=="nw")&&(i.x-=v-i.width),i.width=v}}return i}function Es(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 Fs=0;const Z=class U extends x.PureComponent{constructor(){super(...arguments),T(this,"docMoveBound",!1),T(this,"mouseDownOnCrop",!1),T(this,"dragStarted",!1),T(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),T(this,"componentRef",x.createRef()),T(this,"mediaRef",x.createRef()),T(this,"resizeObserver"),T(this,"initChangeCalled",!1),T(this,"instanceId",`rc-${Fs++}`),T(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),T(this,"onCropPointerDown",t=>{const{crop:s,disabled:l}=this.props,n=this.getBox();if(!s)return;const r=G(s,n.width,n.height);if(l)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const u=t.target.dataset.ord,h=!!u;let o=t.clientX,i=t.clientY,p=r.x,m=r.y;if(u){const w=t.clientX-n.x,c=t.clientY-n.y;let y=0,d=0;u==="ne"||u=="e"?(y=w-(r.x+r.width),d=c-r.y,p=r.x,m=r.y+r.height):u==="se"||u==="s"?(y=w-(r.x+r.width),d=c-(r.y+r.height),p=r.x,m=r.y):u==="sw"||u=="w"?(y=w-r.x,d=c-(r.y+r.height),p=r.x+r.width,m=r.y):(u==="nw"||u=="n")&&(y=w-r.x,d=c-r.y,p=r.x+r.width,m=r.y+r.height),o=p+n.x+y,i=m+n.y+d}this.evData={startClientX:o,startClientY:i,startCropX:p,startCropY:m,clientX:t.clientX,clientY:t.clientY,isResize:h,ord:u},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),T(this,"onComponentPointerDown",t=>{const{crop:s,disabled:l,locked:n,keepSelection:r,onChange:u}=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,p={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,u(G(p,h.width,h.height),ne(p,h.width,h.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),T(this,"onDocPointerMove",t=>{const{crop:s,disabled:l,onChange:n,onDragStart:r}=this.props,u=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(),qe(s,o)||n(G(o,u.width,u.height),ne(o,u.width,u.height))}),T(this,"onComponentKeyDown",t=>{const{crop:s,disabled:l,onChange:n,onComplete:r}=this.props;if(l)return;const u=t.key;let h=!1;if(!s)return;const o=this.getBox(),i=this.makePixelCrop(o),p=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep;if(u==="ArrowLeft"?(i.x-=p,h=!0):u==="ArrowRight"?(i.x+=p,h=!0):u==="ArrowUp"?(i.y-=p,h=!0):u==="ArrowDown"&&(i.y+=p,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 m=G(i,o.width,o.height),w=ne(i,o.width,o.height);n(m,w),r&&r(m,w)}}),T(this,"onHandlerKeyDown",(t,s)=>{const{aspect:l=0,crop:n,disabled:r,minWidth:u=0,minHeight:h=0,maxWidth:o,maxHeight:i,onChange:p,onComplete:m}=this.props,w=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 c=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep,y=G(n,w.width,w.height),d=Es(y,t.key,c,s),j=Qe(d,l,s,w.width,w.height,u,h,o,i);if(!qe(n,j)){const v=ne(j,w.width,w.height);p(j,v),m&&m(j,v)}}),T(this,"onDocPointerDone",t=>{const{crop:s,disabled:l,onComplete:n,onDragEnd:r}=this.props,u=this.getBox();this.unbindDocMove(),!(l||!s)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(t),n&&n(G(s,u.width,u.height),ne(s,u.width,u.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),T(this,"onDragFocus",()=>{var t;(t=this.componentRef.current)==null||t.scrollTo(0,0)})}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:s,y:l,width:n,height:r}=t.getBoundingClientRect();return{x:s,y:l,width:n,height:r}}componentDidUpdate(t){const{crop:s,onComplete:l}=this.props;if(l&&!t.crop&&s){const{width:n,height:r}=this.getBox();n&&r&&l(G(s,n,r),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,u=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=u<r.startCropX,i?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(t,s,l=0,n=0){const r=Math.min(l,t.width),u=Math.min(n,t.height);return!s||!r&&!u?[r,u]:s>1?r?[r,r/s]:[u*s,u]:u?[u*s,u]:[r,r/s]}resizeCrop(){const{evData:t}=this,{aspect:s=0,maxWidth:l,maxHeight:n}=this.props,r=this.getBox(),[u,h]=this.resolveMinDimensions(r,s,this.props.minWidth,this.props.minHeight);let o=this.makePixelCrop(r);const i=this.getPointRegion(r,t.ord,u,h),p=t.ord||i;let m=t.clientX-t.startClientX,w=t.clientY-t.startClientY;(u&&p==="nw"||p==="w"||p==="sw")&&(m=Math.min(m,-u)),(h&&p==="nw"||p==="n"||p==="ne")&&(w=Math.min(w,-h));const c={unit:"px",x:0,y:0,width:0,height:0};i==="ne"?(c.x=t.startCropX,c.width=m,s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(w),c.y=t.startCropY-c.height)):i==="se"?(c.x=t.startCropX,c.y=t.startCropY,c.width=m,s?c.height=c.width/s:c.height=w):i==="sw"?(c.x=t.startCropX+m,c.y=t.startCropY,c.width=Math.abs(m),s?c.height=c.width/s:c.height=w):i==="nw"&&(c.x=t.startCropX+m,c.width=Math.abs(m),s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(w),c.y=t.startCropY+w));const y=Qe(c,s,i,r.width,r.height,u,h,l,n);return s||U.xyOrds.indexOf(p)>-1?o=y:U.xOrds.indexOf(p)>-1?(o.x=y.x,o.width=y.width):U.yOrds.indexOf(p)>-1&&(o.y=y.y,o.height=y.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:u}=this.props,h=this.getCropStyle();if(u)return D.createElement("div",{style:h,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!s&&!l&&D.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},D.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),D.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"}),D.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"}),D.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"}),D.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"}),D.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"}),D.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"}),D.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"}),D.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&&D.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:o=>o.stopPropagation()},n(this.state)),r&&D.createElement(D.Fragment,null,D.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),D.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){const s={...De,...this.props.crop||{}};return G(s,t.width,t.height)}render(){const{aspect:t,children:s,circularCrop:l,className:n,crop:r,disabled:u,locked:h,style:o,ruleOfThirds:i}=this.props,{cropIsActive:p,newCropIsBeingDrawn:m}=this.state,w=r?this.renderCropSelection():null,c=$s("ReactCrop",n,p&&"ReactCrop--active",u&&"ReactCrop--disabled",h&&"ReactCrop--locked",m&&"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 D.createElement("div",{ref:this.componentRef,className:c,style:o},D.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},s),r?D.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},D.createElement("defs",null,D.createElement("mask",{id:`hole-${this.instanceId}`},D.createElement("rect",{width:"100%",height:"100%",fill:"white"}),l?D.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"}):D.createElement("rect",{x:`${r.x}${r.unit}`,y:`${r.y}${r.unit}`,width:`${r.width}${r.unit}`,height:`${r.height}${r.unit}`,fill:"black"}))),D.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,w)}};T(Z,"xOrds",["e","w"]),T(Z,"yOrds",["n","s"]),T(Z,"xyOrds",["nw","ne","se","sw"]),T(Z,"nudgeStep",1),T(Z,"nudgeStepMedium",10),T(Z,"nudgeStepLarge",100),T(Z,"defaultProps",{ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}});let Ps=Z;const Us=[{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"}],dt=[{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"}],Os={"image/jpeg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/tiff":".tiff"};function $e(a,t){return a?dt.find(s=>s.value===a)?.ext||`.${a}`:Os[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=x.useRef(null),[r,u]=x.useState(),[h,o]=x.useState(),[i,p]=x.useState(""),[m,w]=x.useState(""),[c,y]=x.useState(""),[d,j]=x.useState(""),[v,_]=x.useState("80"),[R,I]=x.useState(()=>{const b=$e("",t.mimeType),k=t.filename.lastIndexOf(".");return`${k>0?t.filename.substring(0,k):t.filename}-transformed${b}`});function E(b){const k=b==="__original__"?"":b;j(k);const q=$e(k,t.mimeType);I(J=>Ls(J,q))}const F=Nt(a,t.mediaId),[g,A]=x.useState(null),$=x.useCallback(()=>{if(!h||!g)return null;const b=(t.width??g.width)/g.width,k=(t.height??g.height)/g.height;return{cropX:Math.round(h.x*b),cropY:Math.round(h.y*k),cropW:Math.round(h.width*b),cropH:Math.round(h.height*k)}},[h,t.width,t.height,g]),se=x.useMemo(()=>$(),[$]);async function me(){const b=se,k=m?parseInt(m):void 0,q=c?parseInt(c):void 0;if(!b&&!k&&!q&&!d){S.error("Please specify a crop, resize, or format change");return}if(!R.trim()){S.error("Filename is required");return}const J=$e(d,t.mimeType);if(!R.trim().toLowerCase().endsWith(J)){S.error(`Filename must end with ${J} to match the output format`);return}try{const B=await F.mutateAsync({...b??{},...k?{width:k}:{},...q?{height:q}:{},...d?{format:d}:{},...v?{quality:parseInt(v)}:{},filename:R.trim()});S.success("Transform saved as new media"),l?.(B),s()}catch(B){S.error("Transform failed",{description:B instanceof Error?B.message:void 0})}}function V(b){p(b==="__free__"?"":b),u(void 0),o(void 0)}function Ie(b){if(!b)return;const k=b.split("/");return k.length===2?Number(k[0])/Number(k[1]):Number(b)||void 0}const Te=Ie(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:b=>u(b),onComplete:b=>o(b),aspect:Te,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:b=>{const k=b.currentTarget;A({width:k.naturalWidth,height:k.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(O,{children:"Crop aspect ratio"}),e.jsxs(pe,{value:i||"__free__",onValueChange:V,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Free"})}),e.jsx(we,{children:Us.map(b=>e.jsx(te,{value:b.value||"__free__",children:b.label},b.value||"__free__"))})]}),h&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Crop: ",se?.cropW,"×",se?.cropH," at (",se?.cropX,", ",se?.cropY,")"]}),h&&e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{u(void 0),o(void 0)},children:"Clear crop"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{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:m,onChange:b=>w(b.target.value),min:1,max:2048})}),e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Height",value:c,onChange:b=>y(b.target.value),min:1,max:2048})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Output format"}),e.jsxs(pe,{value:d||"__original__",onValueChange:E,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Original"})}),e.jsx(we,{children:dt.map(b=>e.jsx(te,{value:b.value||"__original__",children:b.label},b.value||"__original__"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Quality (1-100)"}),e.jsx(K,{type:"number",value:v,onChange:b=>_(b.target.value),min:1,max:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Save as filename"}),e.jsx(K,{value:R,onChange:b=>I(b.target.value)})]})]})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(C,{onClick:me,disabled:F.isPending,children:[F.isPending&&e.jsx(ee,{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,folders:l,tagSuggestions:n}){const[r,u]=x.useState(t.alt??""),[h,o]=x.useState(t.caption??""),[i,p]=x.useState(t.userTags??[]),[m,w]=x.useState(t.folderId||"__none__"),[c,y]=x.useState(!1),d=Xs.has(t.mimeType),j=kt(a,t.mediaId),v=Dt(a,t.mediaId),{data:_,isLoading:R}=St(a,t.mediaId),I=t.tags.filter(g=>!t.userTags?.includes(g));async function E(){try{await j.mutateAsync({alt:r,caption:h,userTags:i,folderId:m==="__none__"?"":m}),S.success("Media updated"),s()}catch(g){S.error("Failed to update",{description:g instanceof Error?g.message:void 0})}}async function F(){try{await v.mutateAsync(),S.success("Media deleted"),s()}catch(g){S.error("Failed to delete",{description:g instanceof Error?g.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:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:[t.mimeType," · ",je(t.size),t.width&&t.height&&` · ${t.width}×${t.height}`," · ",Ue(t.uploadedAt)]}),e.jsxs("div",{className:"flex gap-2",children:[d&&e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[e.jsx(xs,{className:"mr-1.5 h-3.5 w-3.5"}),"Transform"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(W(t.url)),S.success("URL copied to clipboard")},children:[e.jsx(Oe,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy URL"]})]})]}),I.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(O,{className:"text-xs text-muted-foreground",children:"Auto-detected tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(g=>e.jsx(ct,{variant:"outline",className:"text-xs",children:g},g))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Tags"}),e.jsx(Fe,{tags:i,onChange:p,placeholder:"Add tags...",suggestions:n})]}),l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Folder"}),e.jsxs(pe,{value:m,onValueChange:w,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"No folder"})}),e.jsxs(we,{children:[e.jsx(te,{value:"__none__",children:"No folder"}),l.map(g=>e.jsx(te,{value:g.folderId,children:g.name},g.folderId))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"alt",children:"Alt text"}),e.jsx(K,{id:"alt",value:r,onChange:g=>u(g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"caption",children:"Caption"}),e.jsx(K,{id:"caption",value:h,onChange:g=>o(g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{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(ee,{className:"h-3.5 w-3.5 animate-spin"}),"Checking usage..."]}):_?.references.length?e.jsxs("div",{className:"space-y-1",children:[_.references.map(g=>e.jsxs(yt,{to:`/sites/${a}/content/${g.collection}/${g.contentId}`,className:"flex items-center gap-2 rounded px-2 py-1 text-sm hover:bg-muted",onClick:s,children:[e.jsx(it,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:g.title||g.contentId}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",g.collection,")"]})]},g.contentId)),_.note&&e.jsx("p",{className:"text-muted-foreground text-xs italic",children:_.note})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Not referenced in any content."})]})]}),e.jsxs(he,{className:"flex justify-between",children:[e.jsxs(C,{variant:"destructive",size:"sm",onClick:F,children:[e.jsx(os,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(C,{onClick:E,children:"Save"})]})]})]}),c&&e.jsx(Hs,{host:a,media:t,onClose:()=>y(!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(ct,{variant:t===l?"default":"secondary",className:"cursor-pointer select-none",onClick:()=>s(t===l?void 0:l),children:l},l)),t&&e.jsxs(C,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>s(void 0),children:[e.jsx(xe,{className:"mr-1 h-3 w-3"}),"Clear"]})]})}function Ee({id:a,children:t}){const{setNodeRef:s,isOver:l}=Zt({id:a,data:{type:"folder"}});return e.jsx("div",{ref:s,children:t(l)})}function Ks({host:a,selectedFolderId:t,onSelect:s}){const{data:l}=Ge(a),n=Mt(a),r=It(a),u=Tt(a),[h,o]=x.useState(!1),[i,p]=x.useState(""),[m,w]=x.useState(null),[c,y]=x.useState(""),[d,j]=x.useState(null),v=x.useRef(null),_=x.useRef(null),R=l?.items??[];x.useEffect(()=>{h&&v.current?.focus()},[h]),x.useEffect(()=>{m&&_.current?.focus()},[m]);async function I(){const g=i.trim();if(!g){o(!1),p("");return}try{await n.mutateAsync(g),S.success("Folder created")}catch(A){S.error("Failed to create folder",{description:A instanceof Error?A.message:void 0})}o(!1),p("")}async function E(g){const A=c.trim();if(!A){w(null);return}try{await r.mutateAsync({folderId:g,name:A}),S.success("Folder renamed")}catch($){S.error("Failed to rename folder",{description:$ instanceof Error?$.message:void 0})}w(null)}async function F(){if(d){try{await u.mutateAsync(d.folderId),S.success("Folder deleted"),t===d.folderId&&s(null)}catch(g){S.error("Failed to delete folder",{description:g instanceof Error?g.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(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>o(!0),children:e.jsx(cs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[e.jsx(Ee,{id:"all-media",children:g=>e.jsx("button",{className:P("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",g&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s(null),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"All Media"]})})}),R.map(g=>e.jsx(Ee,{id:g.folderId,children:A=>e.jsx("div",{className:P("group flex w-full items-center justify-between px-3 py-1.5 text-sm hover:bg-accent/50",t===g.folderId&&"bg-accent font-medium",A&&"ring-2 ring-primary bg-primary/10"),children:m===g.folderId?e.jsx(K,{ref:_,value:c,onChange:$=>y($.target.value),onKeyDown:$=>{$.key==="Enter"&&E(g.folderId),$.key==="Escape"&&w(null)},onBlur:()=>E(g.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(g.folderId),children:[e.jsx(ue,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:g.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:g.count}),e.jsxs(Ft,{children:[e.jsx(Pt,{asChild:!0,children:e.jsx(C,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 group-hover:opacity-100",children:e.jsx(_t,{className:"h-3.5 w-3.5"})})}),e.jsxs(Ut,{align:"end",children:[e.jsx(We,{onClick:()=>{w(g.folderId),y(g.name)},children:"Rename"}),e.jsx(We,{disabled:g.count>0,onClick:()=>j(g),children:"Delete"})]})]})]})]})})},g.folderId)),e.jsx(Ee,{id:"unfiled",children:g=>e.jsx("button",{className:P("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",g&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s("unfiled"),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"Unfiled"]})})}),h&&e.jsx("div",{className:"px-3 py-1.5",children:e.jsx(K,{ref:v,value:i,onChange:g=>p(g.target.value),onKeyDown:g=>{g.key==="Enter"&&I(),g.key==="Escape"&&(o(!1),p(""))},onBlur:I,placeholder:"Folder name...",className:"h-7 text-sm"})})]}),e.jsx(Ze,{open:!!d,onOpenChange:()=>j(null),children:e.jsxs(Je,{children:[e.jsxs(et,{children:[e.jsx(tt,{children:"Delete folder?"}),e.jsxs(st,{children:["This will delete the folder “",d?.name,"”. Media items in this folder will become unfiled."]})]}),e.jsxs(at,{children:[e.jsx(nt,{children:"Cancel"}),e.jsx(rt,{onClick:F,children:"Delete"})]})]})})]})}function Ws({selectedCount:a,folders:t,onDelete:s,onMove:l,onAddTags:n,onRemoveTags:r,onClear:u,isPending:h}){const[o,i]=x.useState(null),[p,m]=x.useState(""),[w,c]=x.useState([]);function y(){i(null),m(""),c([])}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-md border bg-muted/50 px-4 py-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:[a," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",variant:"destructive",onClick:()=>i("delete"),disabled:h,children:"Delete"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("move"),disabled:h,children:"Move to…"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("addTags"),disabled:h,children:"Add tags"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("removeTags"),disabled:h,children:"Remove tags"})]}),e.jsx(C,{size:"sm",variant:"ghost",onClick:u,className:"ml-auto",disabled:h,children:e.jsx(xe,{className:"h-4 w-4"})})]}),e.jsx(ie,{open:o==="delete",onOpenChange:d=>!d&&y(),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(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{variant:"destructive",onClick:async()=>{y(),await s()},disabled:h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})}),e.jsx(ie,{open:o==="move",onOpenChange:d=>!d&&y(),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(pe,{value:p,onValueChange:m,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Select folder..."})}),e.jsxs(we,{children:[e.jsx(te,{value:"__unfiled__",children:"Unfiled"}),t.map(d=>e.jsx(te,{value:d.folderId,children:d.name},d.folderId))]})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=p==="__unfiled__"?"":p;y(),await l(d)},disabled:!p||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Move"]})]})]})}),e.jsx(ie,{open:o==="addTags",onOpenChange:d=>!d&&y(),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(Fe,{tags:w,onChange:c,placeholder:"Add tags..."}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=[...w];y(),await n(d)},disabled:w.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Add"]})]})]})}),e.jsx(ie,{open:o==="removeTags",onOpenChange:d=>!d&&y(),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(Fe,{tags:w,onChange:c,placeholder:"Tags to remove..."}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=[...w];y(),await r(d)},disabled:w.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Remove"]})]})]})})]})}function Vs({onFiles:a,children:t}){const[s,l]=x.useState(!1),n=x.useRef(0),r=x.useCallback(i=>{i.preventDefault(),i.dataTransfer.types.includes("Files")&&(n.current++,l(!0))},[]),u=x.useCallback(i=>{i.preventDefault(),n.current--,n.current===0&&l(!1)},[]),h=x.useCallback(i=>{i.preventDefault(),i.dataTransfer.dropEffect="copy"},[]),o=x.useCallback(i=>{i.preventDefault(),n.current=0,l(!1);const p=Array.from(i.dataTransfer.files);p.length>0&&a(p)},[a]);return e.jsxs("div",{className:"relative flex-1",onDragEnter:r,onDragLeave:u,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(ye,{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 qs({queue:a}){const{items:t,retry:s,dismiss:l,clearCompleted:n}=a,[r,u]=x.useState(!1),h=t.filter(c=>c.status==="uploading").length,o=t.filter(c=>c.status==="pending").length,i=t.filter(c=>c.status==="complete").length,p=t.filter(c=>c.status==="error").length,m=h===0&&o===0;if(x.useEffect(()=>{if(m&&t.length>0){const c=setTimeout(()=>u(!0),2e3);return()=>clearTimeout(c)}},[m,t.length]),t.length===0)return null;const w=m?`${i} uploaded${p?`, ${p} 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:w}),e.jsxs("div",{className:"flex items-center gap-1",children:[m&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:n,children:"Clear"}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>u(!r),children:r?e.jsx(Xt,{className:"h-4 w-4"}):e.jsx(Yt,{className:"h-4 w-4"})})]})]}),!r&&e.jsx("div",{className:"max-h-60 overflow-y-auto",children:t.map(c=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm",children:[c.status==="uploading"&&e.jsx(ee,{className:"h-4 w-4 shrink-0 animate-spin"}),c.status==="complete"&&e.jsx(ds,{className:"h-4 w-4 shrink-0 text-green-500"}),c.status==="error"&&e.jsx(xe,{className:"h-4 w-4 shrink-0 text-destructive"}),c.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:c.file.name}),c.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:`${c.progress}%`}})}),c.status==="error"&&e.jsx("p",{className:"text-destructive truncate text-xs",children:c.error})]}),c.status==="error"&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>s(c.id),children:e.jsx(Is,{className:"h-3 w-3"})}),(c.status==="complete"||c.status==="error")&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>l(c.id),children:e.jsx(xe,{className:"h-3 w-3"})})]},c.id))})]})}const Qs=3;let Gs=0;function Zs(a,t){const[s,l]=x.useState([]),n=Rt(a),r=At(a),u=x.useRef(0),h=x.useRef(s);h.current=s;const o=x.useRef(new Map),i=x.useCallback(async d=>{u.current++,l(j=>j.map(v=>v.id===d.id?{...v,status:"uploading",progress:0}:v));try{const{uploadUrl:j,mediaId:v}=await n.mutateAsync({filename:d.file.name,contentType:d.file.type,size:d.file.size});await new Promise((_,R)=>{const I=new XMLHttpRequest;o.current.set(d.id,I),I.upload.onprogress=E=>{if(E.lengthComputable){const F=Math.round(E.loaded/E.total*100);l(g=>g.map(A=>A.id===d.id?{...A,progress:F}:A))}},I.onload=()=>{o.current.delete(d.id),I.status>=200&&I.status<300?_():R(new Error(`Upload failed: ${I.status}`))},I.onerror=()=>{o.current.delete(d.id),R(new Error("Network error"))},I.onabort=()=>{o.current.delete(d.id),R(new Error("Upload aborted"))},I.open("PUT",j),I.setRequestHeader("Content-Type",d.file.type),I.send(d.file)}),await r.mutateAsync({mediaId:v,filename:d.file.name,folderId:d.folderId}),l(_=>_.map(R=>R.id===d.id?{...R,status:"complete",progress:100}:R))}catch(j){l(v=>v.map(_=>_.id===d.id?{..._,status:"error",error:j instanceof Error?j.message:"Upload failed"}:_))}finally{u.current--}},[n,r]),p=x.useRef(i);p.current=i,x.useEffect(()=>{const d=s.filter(v=>v.status==="pending"),j=Qs-u.current;for(let v=0;v<Math.min(d.length,j);v++)p.current(d[v])},[s]),x.useEffect(()=>{const d=o.current;return()=>{d.forEach(j=>j.abort())}},[]);const m=x.useCallback(d=>{const j=Array.from(d).map(v=>({id:`upload-${Gs++}`,file:v,folderId:t||void 0,status:"pending",progress:0}));l(v=>[...v,...j])},[t]),w=x.useCallback(d=>{l(j=>j.map(v=>v.id===d?{...v,status:"pending",progress:0,error:void 0}:v))},[]),c=x.useCallback(d=>{l(j=>j.filter(v=>v.id!==d))},[]),y=x.useCallback(()=>{l(d=>d.filter(j=>j.status!=="complete"&&j.status!=="error"))},[]);return{items:s,addFiles:m,retry:w,dismiss:c,clearCompleted:y}}function Js({items:a,currentIndex:t,onClose:s,onNavigate:l}){const n=a[t],r=t>0,u=t<a.length-1,h=x.useCallback(o=>{o.key==="Escape"?s():o.key==="ArrowLeft"&&r?l(t-1):o.key==="ArrowRight"&&u&&l(t+1)},[s,l,t,r,u]);return x.useEffect(()=>(document.addEventListener("keydown",h),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",h),document.body.style.overflow=""}),[h]),n?e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/90",onClick:s,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 text-white",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:n.filename}),e.jsxs("span",{className:"ml-3 opacity-70",children:[n.width&&n.height&&`${n.width}×${n.height} · `,je(n.size)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm opacity-70",children:[t+1," / ",a.length]}),e.jsx(C,{variant:"ghost",size:"icon",className:"text-white hover:bg-white/20",onClick:s,children:e.jsx(xe,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative flex flex-1 items-center justify-center px-16",onClick:o=>o.stopPropagation(),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(C,{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(us,{className:"h-8 w-8"})}),u&&e.jsx(C,{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(Jt,{className:"h-8 w-8"})})]})]}):null}function ea({open:a,duplicates:t,fileCount:s,onContinue:l,onCancel:n}){return e.jsx(Ze,{open:a,onOpenChange:r=>!r&&n(),children:e.jsxs(Je,{children:[e.jsxs(et,{children:[e.jsx(tt,{children:"Possible duplicates found"}),e.jsx(st,{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(Me,{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:[je(r.size)," ·"," ",Pe(r.uploadedAt)]})]})]},r.mediaId))}),e.jsxs(at,{children:[e.jsx(nt,{onClick:n,children:"Cancel"}),e.jsx(rt,{onClick:l,children:"Upload Anyway"})]})]})})}function ta(a){const[t,s]=x.useState(()=>{try{const n=localStorage.getItem(`viewMode:${a}`);if(n==="grid"||n==="list")return n}catch{}return"grid"}),l=x.useCallback(n=>{s(n);try{localStorage.setItem(`viewMode:${a}`,n)}catch{}},[a]);return[t,l]}const sa=({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},aa=[{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 na({item:a,selected:t,onToggle:s,onClick:l,folderName:n,onLightbox:r}){const{attributes:u,listeners:h,setNodeRef:o,isDragging:i}=lt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),p=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";function m(w){w.stopPropagation(),navigator.clipboard.writeText(W(a.url)),S.success("URL copied to clipboard")}return e.jsx(Lt,{ref:o,...u,...h,className:P("group relative cursor-pointer overflow-hidden",i&&"opacity-50",t&&"ring-2 ring-primary"),onClick:l,children:e.jsxs(Ht,{className:"p-0",children:[e.jsx("div",{className:P("absolute left-2 top-2 z-10 opacity-0 group-hover:opacity-100",t&&"opacity-100"),onPointerDown:w=>w.stopPropagation(),onClick:w=>w.stopPropagation(),children:e.jsx(Se,{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",onPointerDown:w=>w.stopPropagation(),onClick:w=>w.stopPropagation(),children:[e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:m,children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{children:"Copy URL"})]})}),p&&r&&e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:w=>{w.stopPropagation(),r()},children:e.jsx(ks,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{children:"View full size"})]})})]}),p?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(Me,{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(ue,{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:je(a.size)}),e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Pe(a.uploadedAt)})}),e.jsx(ke,{children:Ue(a.uploadedAt)})]})})]}),a.tags.length>0&&e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(w=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-0.5 text-[10px]",children:w},w)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})]})]})})}function Ca(){const{host:a}=bt(),[t,s]=ta("media"),[l,n]=x.useState("date_desc"),[r,u]=x.useState(""),[h,o]=x.useState(""),[i,p]=x.useState(null),[m,w]=x.useState(null),[c,y]=x.useState(void 0),[d,j]=x.useState(new Set),[v,_]=x.useState(null),[R,I]=x.useState(null),[E,F]=x.useState(null),[g,A]=x.useState([]),$=x.useRef(null),me=Zs(a,m&&m!=="unfiled"?m:void 0),V=zt(a),Ie=$t(a),Te=es(ts(ns,{activationConstraint:{distance:8}}));x.useEffect(()=>{const f=setTimeout(()=>{o(N=>{const M=r;return N!==M&&j(new Set),M})},300);return()=>clearTimeout(f)},[r]);const b=m===null?void 0:m==="unfiled"?"":m,{data:k,isLoading:q}=Et(a,{sort:l,q:h||void 0,folderId:b,tag:c}),{data:J}=Ge(a),B=x.useMemo(()=>J?.items??[],[J?.items]),Le=x.useMemo(()=>{const f=new Map;for(const N of B)f.set(N.folderId,N.name);return f},[B]),ve=x.useMemo(()=>(k?.items??[]).filter(f=>f.mimeType.startsWith("image/")&&f.mimeType!=="image/svg+xml"),[k?.items]),_e=x.useMemo(()=>{const f=new Map;return ve.forEach((N,M)=>f.set(N.mediaId,M)),f},[ve]),{allTags:ht,allUserTags:ut}=x.useMemo(()=>{const f=k?.items??[],N=new Set,M=new Set;for(const z of f){for(const L of z.tags)N.add(L);for(const L of z.userTags??[])M.add(L)}return{allTags:Array.from(N).sort(),allUserTags:Array.from(M).sort()}},[k?.items]),Re=k?.items.map(f=>f.mediaId)??[],Ae=Re.length>0&&Re.every(f=>d.has(f));function He(f){j(N=>{const M=new Set(N);return M.has(f)?M.delete(f):M.add(f),M})}function Xe(){j(Ae?new Set:new Set(Re))}async function mt(){const f=[...d],M=(await V.mutateAsync({mediaIds:f,action:"delete"})).failed.length;M?S.error(`${M} of ${f.length} failed to delete`):S.success(`${f.length} item(s) deleted`),j(new Set)}async function xt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"move",folderId:f})).failed.length;z?S.error(`${z} of ${N.length} failed to move`):S.success(`${N.length} item(s) moved`),j(new Set)}async function pt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"addTags",tags:f})).failed.length;z?S.error(`${z} of ${N.length} failed`):S.success(`Tags added to ${N.length} item(s)`),j(new Set)}async function gt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"removeTags",tags:f})).failed.length;z?S.error(`${z} of ${N.length} failed`):S.success(`Tags removed from ${N.length} item(s)`),j(new Set)}async function Ye(f){const M=Array.from(f).slice(0,5),z=[];for(const L of M)try{const ze=await Ie.mutateAsync({filename:L.name,size:L.size});z.push(...ze.duplicates)}catch{}z.length>0?(F(f),A(z)):me.addFiles(f)}function ft(f){f.target.files&&Ye(f.target.files),$.current&&($.current.value="")}function wt(f){_(String(f.active.id))}function jt(f){_(null);const{active:N,over:M}=f;if(!M||M.data.current?.type!=="folder")return;const z=M.id==="unfiled"||M.id==="all-media"?"":String(M.id),L=d.has(String(N.id))?[...d]:[String(N.id)];V.mutateAsync({mediaIds:L,action:"move",folderId:z}).then(ze=>{const Ke=ze.failed.length;Ke?S.error(`${Ke} of ${L.length} failed to move`):S.success(`${L.length} item(s) moved`)})}function vt(){_(null)}const Q=v?k?.items.find(f=>f.mediaId===v):null,Be=v&&d.has(v)?d.size:1;return e.jsxs(ss,{sensors:Te,modifiers:[sa],onDragStart:wt,onDragEnd:jt,onDragCancel:vt,children:[e.jsxs("div",{className:"-m-6 flex h-[calc(100vh-3.5rem)]",children:[e.jsx(Ks,{host:a,selectedFolderId:m,onSelect:f=>{w(f),j(new Set)}}),e.jsxs(Vs,{onFiles:f=>Ye(f),children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Media"}),e.jsxs("div",{children:[e.jsx("input",{ref:$,type:"file",multiple:!0,className:"hidden",onChange:ft}),e.jsxs(C,{onClick:()=>$.current?.click(),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Upload"]})]})]}),d.size>0?e.jsx(Ws,{selectedCount:d.size,folders:B,onDelete:mt,onMove:xt,onAddTags:pt,onRemoveTags:gt,onClear:()=>j(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(Ve,{className:"text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4"}),e.jsx(K,{placeholder:"Search media...",value:r,onChange:f=>u(f.target.value),className:"pl-9"})]}),e.jsxs(pe,{value:l,onValueChange:n,children:[e.jsx(ge,{className:"w-[160px]",children:e.jsx(fe,{})}),e.jsx(we,{children:aa.map(f=>e.jsx(te,{value:f.value,children:f.label},f.value))})]}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx(C,{variant:t==="grid"?"secondary":"ghost",size:"sm",className:"rounded-r-none px-2",onClick:()=>s("grid"),children:e.jsx(ys,{className:"h-4 w-4"})}),e.jsx(C,{variant:t==="list"?"secondary":"ghost",size:"sm",className:"rounded-l-none px-2",onClick:()=>s("list"),children:e.jsx(Cs,{className:"h-4 w-4"})})]})]}),e.jsx(Bs,{tags:ht,activeTag:c,onTagChange:f=>{y(f),j(new Set)}}),t==="grid"&&(k?.items.length??0)>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Se,{checked:Ae,onCheckedChange:Xe,"aria-label":"Select all"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:d.size>0?`${d.size} of ${k.items.length} selected`:"Select all"})]}),q?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(Ot,{className:"aspect-square"},N))}):k?.items.length?t==="list"?e.jsx(Rs,{items:k.items,host:a,onSelect:p,selectedIds:d,onToggle:He,onToggleAll:Xe,allSelected:Ae,folderMap:m===null?Le:void 0,onLightbox:f=>{const N=_e.get(f.mediaId);N!==void 0&&I(N)}}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:k.items.map(f=>e.jsx(na,{item:f,selected:d.has(f.mediaId),onToggle:()=>He(f.mediaId),onClick:()=>p(f),folderName:m===null?Le.get(f.folderId??""):void 0,onLightbox:_e.has(f.mediaId)?()=>I(_e.get(f.mediaId)):void 0},f.mediaId))}):e.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:h||c?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No results found"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Try adjusting your search or filters."})]}):m==="unfiled"?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No unfiled media"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"All media items are organized in folders."})]}):m?e.jsxs(e.Fragment,{children:[e.jsx(ue,{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(ye,{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(C,{className:"mt-4",onClick:()=>$.current?.click(),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Upload"]})]})}),i&&e.jsx(Ys,{host:a,media:i,onClose:()=>p(null),folders:B,tagSuggestions:ut})]}),e.jsx(qs,{queue:me})]})]}),R!==null&&ve.length>0&&e.jsx(Js,{items:ve,currentIndex:R,host:a,onClose:()=>I(null),onNavigate:I}),e.jsx(ea,{open:g.length>0,host:a,duplicates:g,fileCount:E?Array.from(E).length:0,onContinue:()=>{E&&me.addFiles(E),F(null),A([])},onCancel:()=>{F(null),A([])}}),e.jsx(as,{children:v&&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(Me,{mimeType:Q.mimeType,className:"h-6 w-6"})}),e.jsx("span",{className:"text-sm font-medium",children:Be>1?`Moving ${Be} items`:Q.filename})]})})]})}export{Ca as MediaPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,a as Q}from"./tanstack-BO6c-AOu.js";import{u as R,e as G,r as h}from"./react-vendor-DNVhVxD7.js";import{a3 as K,S as b,a7 as Z,a8 as z,a9 as J,a2 as M,L as m,I as c,B as i,a as u,aa as V,D as A,i as P,j as k,k as T,l as F,m as E,s as n}from"./index-CdJ9sfDz.js";import{B as W}from"./badge-DK6q6X8v.js";import{C as g,a as p,b as f,c as S}from"./card-NiKFR8dW.js";import{f as X}from"./format-CZ9bpk32.js";import"./radix-DQ3amgxj.js";function re(){const{host:a}=R(),{data:r,isLoading:t}=K(a);return t?e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{className:"h-8 w-64"}),e.jsx(b,{className:"h-48 w-full"})]}):r?e.jsx(Y,{site:r},r.host):e.jsx("p",{className:"text-muted-foreground",children:"Site not found."})}function Y({site:a}){const r=Q(),t=Z(a.host),x=z(a.host),j=J(a.host),y=G(),C=M()==="admin",v=a.status==="archived",[N,O]=h.useState(a.name),[B,l]=h.useState(!1),[L,d]=h.useState(!1),[D,o]=h.useState("");async function U(s){s.preventDefault();try{await t.mutateAsync({name:N}),n.success("Site updated")}catch(w){n.error("Failed to update site",{description:w instanceof Error?w.message:void 0})}}async function q(){try{await t.mutateAsync({status:"archived"}),n.success("Site archived"),l(!1),y("/sites")}catch(s){n.error("Failed to archive site",{description:s instanceof Error?s.message:void 0})}}async function H(){try{await t.mutateAsync({status:"active"}),n.success("Site unarchived")}catch(s){n.error("Failed to unarchive site",{description:s instanceof Error?s.message:void 0})}}async function I(){try{await x.mutateAsync(),await j.mutateAsync(),await r.invalidateQueries({queryKey:["sites"]}),n.success("Site deleted"),d(!1),o(""),y("/sites")}catch(s){n.error("Failed to delete site",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Site Settings"}),e.jsxs(g,{children:[e.jsx(p,{children:e.jsx(f,{children:"General"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"name",children:"Site Name"}),e.jsx(c,{id:"name",value:N,onChange:s=>O(s.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Host"}),e.jsx(c,{value:a.host,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Status"}),e.jsx("div",{className:"flex items-center gap-2",children:v?e.jsx(W,{variant:"outline",children:"Archived"}):e.jsx(c,{value:a.status,disabled:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Created"}),e.jsx(c,{value:X(a.createdAt),disabled:!0})]}),e.jsxs(i,{type:"submit",disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),C&&e.jsxs(g,{className:"mt-6",children:[e.jsx(p,{children:e.jsx(f,{children:"Site Status"})}),e.jsx(S,{className:"space-y-4",children:v?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"This site is archived. Unarchive it to allow content changes."}),e.jsxs(i,{variant:"outline",onClick:H,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Unarchive Site"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Archiving a site makes it read-only. Content cannot be created or modified while archived."}),e.jsxs(i,{variant:"outline",onClick:()=>l(!0),children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Archive Site"]}),e.jsx(A,{open:B,onOpenChange:l,children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Archive Site"}),e.jsxs(F,{children:["Are you sure you want to archive ",e.jsx("strong",{children:a.host}),"? The site will become read-only."]})]}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(i,{onClick:q,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Archive"]})]})]})})]})})]}),C&&v&&e.jsxs(g,{className:"border-destructive mt-6",children:[e.jsx(p,{children:e.jsx(f,{className:"text-destructive",children:"Danger Zone"})}),e.jsxs(S,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Permanently delete this site and all its content, media, collections, and block types. This action cannot be undone."}),e.jsx(i,{variant:"destructive",onClick:()=>d(!0),children:"Delete Site"}),e.jsx(A,{open:L,onOpenChange:s=>{d(s),s||o("")},children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Delete Site"}),e.jsxs(F,{children:["This will permanently delete this site and all its content. Type ",e.jsx("strong",{children:a.host})," to confirm."]})]}),e.jsx(c,{placeholder:a.host,value:D,onChange:s=>o(s.target.value)}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>{d(!1),o("")},children:"Cancel"}),e.jsxs(i,{variant:"destructive",onClick:I,disabled:D!==a.host||x.isPending||j.isPending,children:[(x.isPending||j.isPending)&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete Everything"]})]})]})})]})]})]})}export{re as SiteSettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-BO6c-AOu.js";import{r as n,e as H}from"./react-vendor-DNVhVxD7.js";import{b as P,u as B,d as L,e as O,g as E,H as v,D as N,h as S,B as o,U as F,i as I,j as T,k as U,l as M,L as D,I as w,m as R}from"./index-CdJ9sfDz.js";import{C as $,a as q,b as z,d as G}from"./card-NiKFR8dW.js";import{B as J}from"./badge-DK6q6X8v.js";import{C as K}from"./checkbox-Cv1_Hpta.js";import{P as b}from"./plus-CTopr28W.js";import"./radix-DQ3amgxj.js";import"./check-UCoo7qN1.js";function ae(){const[t,d]=n.useState(!1),{data:l,isLoading:m}=P(t),c=H(),i=n.useMemo(()=>[...l?.items??[]].sort((s,C)=>(s.name||s.host).localeCompare(C.name||C.host)),[l]),{user:a}=B(),{data:A}=L(),k=a?(A?.superAdminIds??[]).includes(a.sub):!1,h=O(),[g,x]=n.useState(!1),[r,j]=n.useState(""),[u,p]=n.useState("");if(m)return e.jsx(E,{});const f=()=>{r.trim()&&h.mutate({host:r.trim(),name:u.trim()||r.trim()},{onSuccess:()=>{x(!1),j(""),p("")}})};return i.length===0?e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(v,{}),e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"No sites available."}),e.jsxs(N,{open:g,onOpenChange:x,children:[e.jsx(S,{asChild:!0,children:e.jsxs(o,{children:[e.jsx(b,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(y,{newHost:r,setNewHost:j,newName:u,setNewName:p,onSubmit:f,isPending:h.isPending})]})]})]}):e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(v,{}),e.jsxs("div",{className:"flex-1 p-8",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Select a site"}),k&&e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(K,{checked:t,onCheckedChange:s=>d(s===!0)}),"Show archived sites"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{variant:"outline",onClick:()=>c("/users"),children:[e.jsx(F,{className:"mr-2 h-4 w-4"}),"All Users"]}),e.jsxs(N,{open:g,onOpenChange:x,children:[e.jsx(S,{asChild:!0,children:e.jsxs(o,{children:[e.jsx(b,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(y,{newHost:r,setNewHost:j,newName:u,setNewName:p,onSubmit:f,isPending:h.isPending})]})]})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:i.map(s=>e.jsx($,{className:"cursor-pointer transition-shadow hover:shadow-md",onClick:()=>c(`/sites/${s.host}/content`),children:e.jsxs(q,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{children:s.name||s.host}),s.status==="archived"&&e.jsx(J,{variant:"outline",children:"Archived"})]}),e.jsx(G,{children:s.host})]})},s.host))})]})]})}function y({newHost:t,setNewHost:d,newName:l,setNewName:m,onSubmit:c,isPending:i}){return e.jsxs(I,{children:[e.jsxs(T,{children:[e.jsx(U,{children:"Create Site"}),e.jsx(M,{className:"sr-only",children:"Enter details for the new site"})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"host",children:"Host"}),e.jsx(w,{id:"host",placeholder:"example.com",value:t,onChange:a=>d(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"name",children:"Display Name"}),e.jsx(w,{id:"name",placeholder:"My Site",value:l,onChange:a=>m(a.target.value)})]})]}),e.jsx(R,{children:e.jsx(o,{onClick:c,disabled:!t.trim()||i,children:i?"Creating...":"Create"})})]})}export{ae as SitesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-BO6c-AOu.js";import{r as p}from"./react-vendor-DNVhVxD7.js";import{n as H,u as L,o as P,d as z,p as O,q as _,r as q,H as R,I as G,S as J,B as t,D as g,h as K,i as v,j as A,k as D,l as C,m as y,s as n}from"./index-CdJ9sfDz.js";import{C as Q}from"./checkbox-Cv1_Hpta.js";import{B as V}from"./badge-DK6q6X8v.js";import{T as W,a as X,b as N,c as r,d as Y,e as c}from"./table-pnzwUf_S.js";import{T as Z}from"./trash-2-H30Pytad.js";import"./radix-DQ3amgxj.js";import"./check-UCoo7qN1.js";const $=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],ee=H("shield-off",$);function oe(){const{user:w}=L(),{data:S,isLoading:T}=P(),{data:k}=z(),U=O(),m=_(),h=q(),u=S?.items??[],x=k?.superAdminIds??[],[j,F]=p.useState(""),[E,f]=p.useState(null),[d,o]=p.useState(null),b=j?u.filter(s=>s.email.toLowerCase().includes(j.toLowerCase())):u;async function M(s){try{await m.mutateAsync(s),n.success("User deleted"),f(null)}catch(a){n.error("Failed to delete user",{description:a instanceof Error?a.message:void 0})}}async function I(s){try{await h.mutateAsync(s),n.success("Two-factor authentication disabled"),o(null)}catch(a){n.error("Failed to disable 2FA",{description:a instanceof Error?a.message:void 0})}}async function B(s,a){const l=a?x.filter(i=>i!==s):[...x,s];if(l.length===0){n.error("At least one super admin is required");return}try{await U.mutateAsync({superAdminIds:l}),n.success(a?"Super admin removed":"Super admin added")}catch(i){n.error("Failed to update super admins",{description:i instanceof Error?i.message:void 0})}}return e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(R,{}),e.jsxs("div",{className:"flex-1 p-8",children:[e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsx("h1",{className:"text-2xl font-semibold",children:"All Users"})}),e.jsx("div",{className:"mb-4",children:e.jsx(G,{placeholder:"Search by email...",value:j,onChange:s=>F(s.target.value),className:"max-w-sm"})}),T?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,a)=>e.jsx(J,{className:"h-12 w-full"},a))}):b.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No users found."}):e.jsxs(W,{children:[e.jsx(X,{children:e.jsxs(N,{children:[e.jsx(r,{children:"Email"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"2FA"}),e.jsx(r,{children:"Super Admin"}),e.jsx(r,{})]})}),e.jsx(Y,{children:b.map(s=>{const a=s.sub===w?.sub,l=x.includes(s.sub);return e.jsxs(N,{children:[e.jsxs(c,{className:"text-sm",children:[s.email,a&&e.jsx("span",{className:"text-muted-foreground ml-2",children:"(you)"})]}),e.jsx(c,{className:"text-sm capitalize",children:s.status}),e.jsx(c,{children:s.mfaEnabled?e.jsx(V,{variant:"outline",className:"border-green-500 text-green-700",children:"Enabled"}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(c,{children:e.jsx(Q,{checked:l,onCheckedChange:()=>B(s.sub,l)})}),e.jsx(c,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[!a&&s.mfaEnabled&&e.jsx(t,{variant:"ghost",size:"sm",title:"Disable 2FA",onClick:()=>o(s.sub),children:e.jsx(ee,{className:"h-4 w-4"})}),!a&&e.jsxs(g,{open:E===s.sub,onOpenChange:i=>f(i?s.sub:null),children:[e.jsx(K,{asChild:!0,children:e.jsx(t,{variant:"ghost",size:"sm",className:"text-destructive",title:"Delete account",children:e.jsx(Z,{className:"h-4 w-4"})})}),e.jsxs(v,{children:[e.jsxs(A,{children:[e.jsx(D,{children:"Delete User Account"}),e.jsx(C,{className:"sr-only",children:"Confirm permanent deletion of this user account"})]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This will permanently delete the account for"," ",e.jsx("strong",{children:s.email}),". They will lose access to all sites."]}),e.jsxs(y,{children:[e.jsx(t,{variant:"outline",onClick:()=>f(null),children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:()=>M(s.sub),disabled:m.isPending,children:m.isPending?"Deleting...":"Delete Account"})]})]})]})]})})]},s.sub)})})]}),e.jsx(g,{open:d!==null,onOpenChange:s=>{s||o(null)},children:e.jsxs(v,{children:[e.jsxs(A,{children:[e.jsx(D,{children:"Disable Two-Factor Authentication"}),e.jsxs(C,{children:["This will disable 2FA for"," ",e.jsx("strong",{children:u.find(s=>s.sub===d)?.email}),". They will be able to log in with just their password."]})]}),e.jsxs(y,{children:[e.jsx(t,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:()=>{d&&I(d)},disabled:h.isPending,children:h.isPending?"Disabling...":"Disable 2FA"})]})]})})]})]})}export{oe as UsersPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as c}from"./index-CdJ9sfDz.js";const e=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=c("check",e);export{t as C};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as w}from"./tanstack-BO6c-AOu.js";import{r as l,b as Re}from"./react-vendor-DNVhVxD7.js";import{x as V}from"./index-CdJ9sfDz.js";import{W as je,X as Ae,Y as $e,Z as Pe,_ as L,$ as _,c as Ne,h as Me,O as De,e as _e}from"./radix-DQ3amgxj.js";import{S as Le}from"./search-CURbafxm.js";function xt({...e}){return w.jsx(je,{"data-slot":"popover",...e})}function wt({...e}){return w.jsx(Ae,{"data-slot":"popover-trigger",...e})}function Et({className:e,align:r="center",sideOffset:t=4,...i}){return w.jsx($e,{children:w.jsx(Pe,{"data-slot":"popover-content",align:r,sideOffset:t,className:V("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...i})})}var pe=1,Ve=.9,Oe=.8,ze=.17,te=.1,re=.999,Fe=.9999,Ke=.99,Te=/[\\\/_+.#"@\[\(\{&]/,We=/[\\\/_+.#"@\[\(\{&]/g,qe=/[\s-]/,he=/[\s-]/g;function le(e,r,t,i,a,o,d){if(o===r.length)return a===e.length?pe:Ke;var f=`${a},${o}`;if(d[f]!==void 0)return d[f];for(var p=i.charAt(o),s=t.indexOf(p,a),v=0,h,k,E,I;s>=0;)h=le(e,r,t,i,s+1,o+1,d),h>v&&(s===a?h*=pe:Te.test(e.charAt(s-1))?(h*=Oe,E=e.slice(a,s-1).match(We),E&&a>0&&(h*=Math.pow(re,E.length))):qe.test(e.charAt(s-1))?(h*=Ve,I=e.slice(a,s-1).match(he),I&&a>0&&(h*=Math.pow(re,I.length))):(h*=ze,a>0&&(h*=Math.pow(re,s-a))),e.charAt(s)!==r.charAt(o)&&(h*=Fe)),(h<te&&t.charAt(s-1)===i.charAt(o+1)||i.charAt(o+1)===i.charAt(o)&&t.charAt(s-1)!==i.charAt(o))&&(k=le(e,r,t,i,s+1,o+2,d),k*te>h&&(h=k*te)),h>v&&(v=h),s=t.indexOf(p,s+1);return d[f]=v,v}function ve(e){return e.toLowerCase().replace(he," ")}function Be(e,r,t){return e=t&&t.length>0?`${e+" "+t.join(" ")}`:e,le(e,r,ve(e),ve(r),0,0,{})}var He=Symbol.for("react.lazy"),q=Re[" use ".trim().toString()];function Ye(e){return typeof e=="object"&&e!==null&&"then"in e}function be(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===He&&"_payload"in e&&Ye(e._payload)}function ye(e){const r=Ge(e),t=l.forwardRef((i,a)=>{let{children:o,...d}=i;be(o)&&typeof q=="function"&&(o=q(o._payload));const f=l.Children.toArray(o),p=f.find(Ze);if(p){const s=p.props.children,v=f.map(h=>h===p?l.Children.count(s)>1?l.Children.only(null):l.isValidElement(s)?s.props.children:null:h);return w.jsx(r,{...d,ref:a,children:l.isValidElement(s)?l.cloneElement(s,void 0,v):null})}return w.jsx(r,{...d,ref:a,children:o})});return t.displayName=`${e}.Slot`,t}var St=ye("Slot");function Ge(e){const r=l.forwardRef((t,i)=>{let{children:a,...o}=t;if(be(a)&&typeof q=="function"&&(a=q(a._payload)),l.isValidElement(a)){const d=Je(a),f=Xe(o,a.props);return a.type!==l.Fragment&&(f.ref=i?L(i,d):d),l.cloneElement(a,f)}return l.Children.count(a)>1?l.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Ue=Symbol("radix.slottable");function Ze(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ue}function Xe(e,r){const t={...r};for(const i in r){const a=e[i],o=r[i];/^on[A-Z]/.test(i)?a&&o?t[i]=(...f)=>{const p=o(...f);return a(...f),p}:a&&(t[i]=a):i==="style"?t[i]={...a,...o}:i==="className"&&(t[i]=[a,o].filter(Boolean).join(" "))}return{...e,...t}}function Je(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning;return t?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Qe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],j=Qe.reduce((e,r)=>{const t=ye(`Primitive.${r}`),i=l.forwardRef((a,o)=>{const{asChild:d,...f}=a,p=d?t:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),w.jsx(p,{...f,ref:o})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),F='[cmdk-group=""]',ne='[cmdk-group-items=""]',et='[cmdk-group-heading=""]',xe='[cmdk-item=""]',ge=`${xe}:not([aria-disabled="true"])`,ae="cmdk-item-select",M="data-value",tt=(e,r,t)=>Be(e,r,t),we=l.createContext(void 0),K=()=>l.useContext(we),Ee=l.createContext(void 0),oe=()=>l.useContext(Ee),Se=l.createContext(void 0),Ce=l.forwardRef((e,r)=>{let t=D(()=>{var n,c;return{search:"",value:(c=(n=e.value)!=null?n:e.defaultValue)!=null?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=D(()=>new Set),a=D(()=>new Map),o=D(()=>new Map),d=D(()=>new Set),f=ke(e),{label:p,children:s,value:v,onValueChange:h,filter:k,shouldFilter:E,loop:I,disablePointerSelection:H=!1,vimBindings:A=!0,...T}=e,Y=_(),ie=_(),G=_(),$=l.useRef(null),y=ft();P(()=>{if(v!==void 0){let n=v.trim();t.current.value=n,S.emit()}},[v]),P(()=>{y(6,se)},[]);let S=l.useMemo(()=>({subscribe:n=>(d.current.add(n),()=>d.current.delete(n)),snapshot:()=>t.current,setState:(n,c,m)=>{var u,g,b,C;if(!Object.is(t.current[n],c)){if(t.current[n]=c,n==="search")J(),Z(),y(1,X);else if(n==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let x=document.getElementById(G);x?x.focus():(u=document.getElementById(Y))==null||u.focus()}if(y(7,()=>{var x;t.current.selectedItemId=(x=N())==null?void 0:x.id,S.emit()}),m||y(5,se),((g=f.current)==null?void 0:g.value)!==void 0){let x=c??"";(C=(b=f.current).onValueChange)==null||C.call(b,x);return}}S.emit()}},emit:()=>{d.current.forEach(n=>n())}}),[]),U=l.useMemo(()=>({value:(n,c,m)=>{var u;c!==((u=o.current.get(n))==null?void 0:u.value)&&(o.current.set(n,{value:c,keywords:m}),t.current.filtered.items.set(n,ue(c,m)),y(2,()=>{Z(),S.emit()}))},item:(n,c)=>(i.current.add(n),c&&(a.current.has(c)?a.current.get(c).add(n):a.current.set(c,new Set([n]))),y(3,()=>{J(),Z(),t.current.value||X(),S.emit()}),()=>{o.current.delete(n),i.current.delete(n),t.current.filtered.items.delete(n);let m=N();y(4,()=>{J(),m?.getAttribute("id")===n&&X(),S.emit()})}),group:n=>(a.current.has(n)||a.current.set(n,new Set),()=>{o.current.delete(n),a.current.delete(n)}),filter:()=>f.current.shouldFilter,label:p||e["aria-label"],getDisablePointerSelection:()=>f.current.disablePointerSelection,listId:Y,inputId:G,labelId:ie,listInnerRef:$}),[]);function ue(n,c){var m,u;let g=(u=(m=f.current)==null?void 0:m.filter)!=null?u:tt;return n?g(n,t.current.search,c):0}function Z(){if(!t.current.search||f.current.shouldFilter===!1)return;let n=t.current.filtered.items,c=[];t.current.filtered.groups.forEach(u=>{let g=a.current.get(u),b=0;g.forEach(C=>{let x=n.get(C);b=Math.max(x,b)}),c.push([u,b])});let m=$.current;z().sort((u,g)=>{var b,C;let x=u.getAttribute("id"),W=g.getAttribute("id");return((b=n.get(W))!=null?b:0)-((C=n.get(x))!=null?C:0)}).forEach(u=>{let g=u.closest(ne);g?g.appendChild(u.parentElement===g?u:u.closest(`${ne} > *`)):m.appendChild(u.parentElement===m?u:u.closest(`${ne} > *`))}),c.sort((u,g)=>g[1]-u[1]).forEach(u=>{var g;let b=(g=$.current)==null?void 0:g.querySelector(`${F}[${M}="${encodeURIComponent(u[0])}"]`);b?.parentElement.appendChild(b)})}function X(){let n=z().find(m=>m.getAttribute("aria-disabled")!=="true"),c=n?.getAttribute(M);S.setState("value",c||void 0)}function J(){var n,c,m,u;if(!t.current.search||f.current.shouldFilter===!1){t.current.filtered.count=i.current.size;return}t.current.filtered.groups=new Set;let g=0;for(let b of i.current){let C=(c=(n=o.current.get(b))==null?void 0:n.value)!=null?c:"",x=(u=(m=o.current.get(b))==null?void 0:m.keywords)!=null?u:[],W=ue(C,x);t.current.filtered.items.set(b,W),W>0&&g++}for(let[b,C]of a.current)for(let x of C)if(t.current.filtered.items.get(x)>0){t.current.filtered.groups.add(b);break}t.current.filtered.count=g}function se(){var n,c,m;let u=N();u&&(((n=u.parentElement)==null?void 0:n.firstChild)===u&&((m=(c=u.closest(F))==null?void 0:c.querySelector(et))==null||m.scrollIntoView({block:"nearest"})),u.scrollIntoView({block:"nearest"}))}function N(){var n;return(n=$.current)==null?void 0:n.querySelector(`${xe}[aria-selected="true"]`)}function z(){var n;return Array.from(((n=$.current)==null?void 0:n.querySelectorAll(ge))||[])}function Q(n){let c=z()[n];c&&S.setState("value",c.getAttribute(M))}function ee(n){var c;let m=N(),u=z(),g=u.findIndex(C=>C===m),b=u[g+n];(c=f.current)!=null&&c.loop&&(b=g+n<0?u[u.length-1]:g+n===u.length?u[0]:u[g+n]),b&&S.setState("value",b.getAttribute(M))}function de(n){let c=N(),m=c?.closest(F),u;for(;m&&!u;)m=n>0?dt(m,F):ct(m,F),u=m?.querySelector(ge);u?S.setState("value",u.getAttribute(M)):ee(n)}let ce=()=>Q(z().length-1),fe=n=>{n.preventDefault(),n.metaKey?ce():n.altKey?de(1):ee(1)},me=n=>{n.preventDefault(),n.metaKey?Q(0):n.altKey?de(-1):ee(-1)};return l.createElement(j.div,{ref:r,tabIndex:-1,...T,"cmdk-root":"",onKeyDown:n=>{var c;(c=T.onKeyDown)==null||c.call(T,n);let m=n.nativeEvent.isComposing||n.keyCode===229;if(!(n.defaultPrevented||m))switch(n.key){case"n":case"j":{A&&n.ctrlKey&&fe(n);break}case"ArrowDown":{fe(n);break}case"p":case"k":{A&&n.ctrlKey&&me(n);break}case"ArrowUp":{me(n);break}case"Home":{n.preventDefault(),Q(0);break}case"End":{n.preventDefault(),ce();break}case"Enter":{n.preventDefault();let u=N();if(u){let g=new Event(ae);u.dispatchEvent(g)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:pt},p),B(e,n=>l.createElement(Ee.Provider,{value:S},l.createElement(we.Provider,{value:U},n))))}),rt=l.forwardRef((e,r)=>{var t,i;let a=_(),o=l.useRef(null),d=l.useContext(Se),f=K(),p=ke(e),s=(i=(t=p.current)==null?void 0:t.forceMount)!=null?i:d?.forceMount;P(()=>{if(!s)return f.item(a,d?.id)},[s]);let v=Ie(a,o,[e.value,e.children,o],e.keywords),h=oe(),k=R(y=>y.value&&y.value===v.current),E=R(y=>s||f.filter()===!1?!0:y.search?y.filtered.items.get(a)>0:!0);l.useEffect(()=>{let y=o.current;if(!(!y||e.disabled))return y.addEventListener(ae,I),()=>y.removeEventListener(ae,I)},[E,e.onSelect,e.disabled]);function I(){var y,S;H(),(S=(y=p.current).onSelect)==null||S.call(y,v.current)}function H(){h.setState("value",v.current,!0)}if(!E)return null;let{disabled:A,value:T,onSelect:Y,forceMount:ie,keywords:G,...$}=e;return l.createElement(j.div,{ref:L(o,r),...$,id:a,"cmdk-item":"",role:"option","aria-disabled":!!A,"aria-selected":!!k,"data-disabled":!!A,"data-selected":!!k,onPointerMove:A||f.getDisablePointerSelection()?void 0:H,onClick:A?void 0:I},e.children)}),nt=l.forwardRef((e,r)=>{let{heading:t,children:i,forceMount:a,...o}=e,d=_(),f=l.useRef(null),p=l.useRef(null),s=_(),v=K(),h=R(E=>a||v.filter()===!1?!0:E.search?E.filtered.groups.has(d):!0);P(()=>v.group(d),[]),Ie(d,f,[e.value,e.heading,p]);let k=l.useMemo(()=>({id:d,forceMount:a}),[a]);return l.createElement(j.div,{ref:L(f,r),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},t&&l.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:s},t),B(e,E=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?s:void 0},l.createElement(Se.Provider,{value:k},E))))}),lt=l.forwardRef((e,r)=>{let{alwaysRender:t,...i}=e,a=l.useRef(null),o=R(d=>!d.search);return!t&&!o?null:l.createElement(j.div,{ref:L(a,r),...i,"cmdk-separator":"",role:"separator"})}),at=l.forwardRef((e,r)=>{let{onValueChange:t,...i}=e,a=e.value!=null,o=oe(),d=R(s=>s.search),f=R(s=>s.selectedItemId),p=K();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(j.input,{ref:r,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":f,id:p.inputId,type:"text",value:a?e.value:d,onChange:s=>{a||o.setState("search",s.target.value),t?.(s.target.value)}})}),ot=l.forwardRef((e,r)=>{let{children:t,label:i="Suggestions",...a}=e,o=l.useRef(null),d=l.useRef(null),f=R(s=>s.selectedItemId),p=K();return l.useEffect(()=>{if(d.current&&o.current){let s=d.current,v=o.current,h,k=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let E=s.offsetHeight;v.style.setProperty("--cmdk-list-height",E.toFixed(1)+"px")})});return k.observe(s),()=>{cancelAnimationFrame(h),k.unobserve(s)}}},[]),l.createElement(j.div,{ref:L(o,r),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":f,"aria-label":i,id:p.listId},B(e,s=>l.createElement("div",{ref:L(d,p.listInnerRef),"cmdk-list-sizer":""},s)))}),it=l.forwardRef((e,r)=>{let{open:t,onOpenChange:i,overlayClassName:a,contentClassName:o,container:d,...f}=e;return l.createElement(Ne,{open:t,onOpenChange:i},l.createElement(Me,{container:d},l.createElement(De,{"cmdk-overlay":"",className:a}),l.createElement(_e,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(Ce,{ref:r,...f}))))}),ut=l.forwardRef((e,r)=>R(t=>t.filtered.count===0)?l.createElement(j.div,{ref:r,...e,"cmdk-empty":"",role:"presentation"}):null),st=l.forwardRef((e,r)=>{let{progress:t,children:i,label:a="Loading...",...o}=e;return l.createElement(j.div,{ref:r,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},B(e,d=>l.createElement("div",{"aria-hidden":!0},d)))}),O=Object.assign(Ce,{List:ot,Item:rt,Input:at,Group:nt,Separator:lt,Dialog:it,Empty:ut,Loading:st});function dt(e,r){let t=e.nextElementSibling;for(;t;){if(t.matches(r))return t;t=t.nextElementSibling}}function ct(e,r){let t=e.previousElementSibling;for(;t;){if(t.matches(r))return t;t=t.previousElementSibling}}function ke(e){let r=l.useRef(e);return P(()=>{r.current=e}),r}var P=typeof window>"u"?l.useEffect:l.useLayoutEffect;function D(e){let r=l.useRef();return r.current===void 0&&(r.current=e()),r}function R(e){let r=oe(),t=()=>e(r.snapshot());return l.useSyncExternalStore(r.subscribe,t,t)}function Ie(e,r,t,i=[]){let a=l.useRef(),o=K();return P(()=>{var d;let f=(()=>{var s;for(let v of t){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(s=v.current.textContent)==null?void 0:s.trim():a.current}})(),p=i.map(s=>s.trim());o.value(e,f,p),(d=r.current)==null||d.setAttribute(M,f),a.current=f}),a}var ft=()=>{let[e,r]=l.useState(),t=D(()=>new Map);return P(()=>{t.current.forEach(i=>i()),t.current=new Map},[e]),(i,a)=>{t.current.set(i,a),r({})}};function mt(e){let r=e.type;return typeof r=="function"?r(e.props):"render"in r?r.render(e.props):e}function B({asChild:e,children:r},t){return e&&l.isValidElement(r)?l.cloneElement(mt(r),{ref:r.ref},t(r.props.children)):t(r)}var pt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function Ct({className:e,...r}){return w.jsx(O,{"data-slot":"command",className:V("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...r})}function kt({className:e,...r}){return w.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[w.jsx(Le,{className:"size-4 shrink-0 opacity-50"}),w.jsx(O.Input,{"data-slot":"command-input",className:V("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})}function It({className:e,...r}){return w.jsx(O.List,{"data-slot":"command-list",className:V("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...r})}function Rt({...e}){return w.jsx(O.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function jt({className:e,...r}){return w.jsx(O.Group,{"data-slot":"command-group",className:V("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...r})}function At({className:e,...r}){return w.jsx(O.Item,{"data-slot":"command-item",className:V("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}export{Ct as C,xt as P,St as S,wt as a,Et as b,kt as c,It as d,Rt as e,jt as f,At as g,j as h};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function u(e,s,t,a){return e?!t||!a||t===a?"published":"published-changes":s?"unpublished":"draft"}function n(e){switch(e){case"draft":return"Publish";case"published":return"";case"published-changes":return"Publish Changes";case"unpublished":return"Republish"}}function r(e){switch(e){case"draft":return{label:"Draft",variant:"secondary"};case"published":return{label:"Published",variant:"default"};case"published-changes":return{label:"Unsaved changes",variant:"outline"};case"unpublished":return{label:"Unpublished",variant:"destructive"}}}export{r as a,n as b,u as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const s=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}),c=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function u(e){return s.format(new Date(e))}function f(e){return c.format(new Date(e))}function l(e){const n=Date.now()-e,a=Math.floor(n/1e3);if(a<60)return"just now";const r=Math.floor(a/60);if(r<60)return`${r}m ago`;const o=Math.floor(r/60);if(o<24)return`${o}h ago`;const i=Math.floor(o/24);return i<7?`${i}d ago`:u(e)}function m(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function h(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}function d(e){return e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9_-]/g,"").replace(/[-_]{2,}/g,t=>t[0]).replace(/^[^a-z]+/,"").replace(/[-_]$/g,"")}function g(e){return e.split(/[-_]/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function p(e){const t=e.split(" ");if(t.length===0)return e;const n=t[t.length-1];return n.length>2&&n.endsWith("s")&&!n.endsWith("ss")&&(t[t.length-1]=n.slice(0,-1)),t.join(" ")}export{l as a,m as b,p as c,d,f,g as i,h as s};
|