1import{r as e,R as t,j as n,b as s}from"./react-vendor-BW0W7nrM.js";import{U as r}from"./UserMenu-BhjSzXEu.js";import{h as a,K as o,u as l,F as i,N as d,M as c,T as x}from"./index-BYV1u4qx.js";import{q as u,f as m,w as h,h as p,o as b,d as f,c as g,j,i as v,k as w,n as k}from"./firebase-data-CGCl_keZ.js";import{u as N,C as z}from"./useConfirmation-T7WFaiLA.js";import{u as y,a as C,b as S,c as F,D as I,d as D,e as M,P as E}from"./dnd-kit-BFDY2E7-.js";import{h as P,aY as A,aZ as O,a3 as T,a0 as R,a_ as L,p as $,T as W,aa as K,am as U,a$ as X,ao as B,Y as H,X as V,b0 as _,A as Y,b1 as Z,aw as q,b2 as G,t as J,j as Q,b3 as ee,at as te,b4 as ne,b5 as se,aX as re}from"./ui-libs-Dmw_7-1f.js";import{u as ae,s as oe}from"./spaceService-CBlbhpWi.js";import"./UserAvatar-BlgOYjXl.js";import"./firebase-core-Btor9Q66.js";const le=t.memo(({src:t,smallSrc:s,alt:r,className:a="",fallbackIcon:o,onError:l})=>{const[i,d]=e.useState(!1),[c,x]=e.useState(!1),[u,m]=e.useState(!1),[h,p]=e.useState(s||t),b=e.useRef(null),f=e.useRef(null);return e.useEffect(()=>{if(b.current)return f.current=new IntersectionObserver(e=>{e.forEach(e=>{var t;e.isIntersecting&&(d(!0),null==(t=f.current)||t.disconnect())})},{rootMargin:"50px",threshold:.01}),f.current.observe(b.current),()=>{var e;null==(e=f.current)||e.disconnect()}},[]),e.useEffect(()=>{if(!i||!t)return;let e=!0;if(s&&s!==t&&!c){const n=new Image;n.src=s,n.onload=()=>{if(e){p(s);const n=new Image;n.src=t,n.onload=()=>{e&&(p(t),x(!0))},n.onerror=()=>{e&&(m(!0),null==l||l())}}},n.onerror=()=>{if(e){const n=new Image;n.src=t,n.onload=()=>{e&&(p(t),x(!0))},n.onerror=()=>{e&&(m(!0),null==l||l())}}}}else{const n=new Image;n.src=t,n.onload=()=>{e&&(p(t),x(!0))},n.onerror=()=>{e&&(m(!0),null==l||l())}}return()=>{e=!1}},[i,t,s,c,l]),n.jsxs("div",{ref:b,className:(null==a?void 0:a.includes("absolute"))?a:`relative ${a||"w-full h-full"}`,children:[!u&&h?n.jsx("img",{src:h,alt:r,className:"absolute inset-0 w-full h-full object-cover transition-opacity duration-300",style:{opacity:c&&h===t?1:.9,filter:c&&h===t?"none":"blur(5px)",transform:c&&h===t?"scale(1)":"scale(1.05)",transition:"all 0.3s ease-out"}}):n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-zinc-100 dark:bg-zinc-900/50",children:o}),!c&&!u&&h&&n.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent animate-shimmer"})]})});function ie(e){if(null==e)return null;if("number"==typeof e)return e;if("object"==typeof e&&null!==e){const t=e;if("function"==typeof t.toMillis)return t.toMillis();if("number"==typeof t.seconds)return 1e3*t.seconds}return null}const de=t.memo(({project:e,iterationCount:t,onSelect:s,onRename:r,onDelete:a,formatDate:o,selectionMode:i,isSelected:d,onToggleSelect:c,onContextMenu:x})=>{const{t:u,fmt:m}=l(),{attributes:h,listeners:p,setNodeRef:b,transform:f,isDragging:g}=y({id:e.id,data:{type:"project"}}),j=f?{transform:`translate3d(${f.x}px, ${f.y}px, 0)`,opacity:g?.5:1}:void 0,v=ie(e.expiresAt),w=null!=v?Math.max(0,Math.ceil((v-Date.now())/864e5)):null,k=null!=w&&w<=14,N=null!=w&&w<=3;return n.jsxs("div",{ref:b,style:j,...h,...p,onContextMenu:t=>{x&&(t.preventDefault(),x(t,e))},className:"group relative aspect-[2/1.5] rounded-2xl bg-white dark:bg-zinc-900 border overflow-hidden cursor-grab active:cursor-grabbing transition-all hover:shadow-xl hover:shadow-[#8f3589]/20 hover:-translate-y-1 animate-in fade-in "+(d?"border-indigo-500 ring-2 ring-indigo-500/30":"border-zinc-200 dark:border-zinc-800 hover:border-[#8f3589]/30"),children:[i&&n.jsx("div",{className:"absolute top-2 start-2 z-20",children:n.jsx("button",{onClick:t=>{t.stopPropagation(),null==c||c(e.id)},className:"w-6 h-6 rounded-md border-2 flex items-center justify-center transition-all "+(d?"bg-indigo-500 border-indigo-500":"border-zinc-300 dark:border-zinc-600 bg-white/80 dark:bg-zinc-800/80 hover:border-indigo-400"),children:d&&n.jsx(P,{className:"w-4 h-4 text-white"})})}),n.jsxs("div",{onClick:t=>{if((t.ctrlKey||t.metaKey)&&c)return t.preventDefault(),void c(e.id);i&&c?c(e.id):s(e)},className:"absolute inset-0",children:[e.thumbnail||e.thumbnailSmall?n.jsx(le,{src:e.thumbnail,smallSrc:e.thumbnailSmall,alt:e.name,className:"absolute inset-0 transition-transform duration-700 group-hover:scale-110",fallbackIcon:n.jsx(L,{className:"w-6 h-6 text-zinc-300 dark:text-zinc-800"})}):n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-zinc-100 dark:bg-zinc-900/50",children:n.jsx(L,{className:"w-6 h-6 text-zinc-300 dark:text-zinc-800"})}),n.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-60 group-hover:opacity-80 transition-opacity"}),n.jsxs("div",{className:"absolute bottom-0 start-0 end-0 p-3",children:[n.jsx("h3",{className:"text-sm font-bold text-white mb-0.5 truncate",children:e.name}),n.jsxs("div",{className:"flex items-center gap-3 text-xs font-medium text-zinc-300",children:[n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx($,{className:"w-3 h-3"})," ",o(e.createdAt)]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx(W,{className:"w-3 h-3"})," ",t," ",1===t?"iteration":"iterations"]})]})]})]}),n.jsx("button",{onClick:t=>r(t,e),className:"absolute top-2 end-10 p-1.5 bg-black/40 hover:bg-blue-600 backdrop-blur rounded-lg text-white opacity-0 group-hover:opacity-100 transition-all hover:scale-110 z-10",children:n.jsx(T,{className:"w-3 h-3"})}),n.jsx("button",{onClick:t=>a(t,e),className:"absolute top-2 end-2 p-1.5 bg-black/40 hover:bg-[#
1E53935] backdrop-blur rounded-lg text-white opacity-0 group-hover:opacity-100 transition-all hover:scale-110 z-10",children:n.jsx(R,{className:"w-3 h-3"})}),k&&!i&&n.jsxs("div",{className:"absolute top-2 start-2 z-10 flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-semibold backdrop-blur shadow-sm "+(N?"bg-red-600/90 text-white":"bg-amber-500/90 text-white"),title:u("studio.retentionTooltipPlan",{date:m.date(v)}),children:[n.jsx(K,{className:"w-3 h-3"}),0===w?u("studio.expiresToday"):u("studio.expiresInDays",{n:w})]})]})},(e,t)=>e.project.id===t.project.id&&e.project.name===t.project.name&&e.project.thumbnail===t.project.thumbnail&&e.project.thumbnailSmall===t.project.thumbnailSmall&&e.project.createdAt===t.project.createdAt&&e.project.expiresAt===t.project.expiresAt&&e.iterationCount===t.iterationCount&&e.selectionMode===t.selectionMode&&e.isSelected===t.isSelected),ce=t.memo(({folder:t,projectCount:s,subFolderCount:r=0,onSelect:a,onRename:o,onDelete:l,selectionMode:i,isSelected:d,onToggleSelect:c,onContextMenu:x})=>{const{attributes:u,listeners:m,setNodeRef:h,isDragging:p}=y({id:t.id,data:{type:"folder"}}),{setNodeRef:b,isOver:f}=C({id:t.id,data:{type:"folder"}}),g=function(...t){return e.useCallback(e=>{t.forEach(t=>t(e))},t)}(h,b),j=t.color||"#6366f1";return n.jsxs("div",{ref:g,...u,...m,onClick:e=>{if((e.ctrlKey||e.metaKey)&&c)return e.preventDefault(),void c(t.id);i&&c?c(t.id):a(t.id)},onContextMenu:e=>{x&&(e.preventDefault(),x(e,t))},style:{opacity:p?.5:1},className:`group relative aspect-[2/1.5] rounded-2xl cursor-pointer transition-all animate-in fade-in hover:bg-zinc-100/80 dark:hover:bg-white/[0.04] ${f?"bg-zinc-100/80 dark:bg-white/[0.04] scale-[1.02]":""} ${d?"bg-indigo-50/70 dark:bg-indigo-500/10 ring-2 ring-inset ring-indigo-400/25":""}`,children:[i&&n.jsx("div",{className:"absolute top-2 start-2 z-20",children:n.jsx("button",{onClick:e=>{e.stopPropagation(),null==c||c(t.id)},className:"w-6 h-6 rounded-md border-2 flex items-center justify-center transition-all "+(d?"bg-indigo-500 border-indigo-500":"border-zinc-300 dark:border-zinc-600 bg-white/80 dark:bg-zinc-800/80 hover:border-indigo-400"),children:d&&n.jsx(P,{className:"w-4 h-4 text-white"})})}),n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-3",children:[n.jsxs("div",{className:"relative w-12 h-12 rounded-2xl flex items-center justify-center mb-2.5 group-hover:scale-110 transition-transform "+(f?"scale-110":""),style:{backgroundColor:`${j}18`},children:[f&&n.jsx("div",{className:"absolute inset-0 rounded-2xl border-2 border-dashed",style:{borderColor:`${j}90`}}),t.icon?n.jsx("span",{className:"text-xl",children:t.icon}):n.jsx(A,{className:"w-6 h-6",style:{color:j}})]}),n.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white mb-0.5 truncate w-full text-center",children:t.name}),n.jsxs("p",{className:"text-xs text-zinc-400 dark:text-zinc-500",children:[s," ",1===s?"project":"projects"]}),r>0&&n.jsxs("div",{className:"flex items-center gap-1 text-xs text-zinc-400 mt-0.5",children:[n.jsx(O,{className:"w-3 h-3"}),n.jsxs("span",{children:[r," sub-folder",r>1?"s":""]})]})]}),n.jsx("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 h-0.5 w-8 rounded-full opacity-0 group-hover:opacity-60 transition-all group-hover:w-12",style:{backgroundColor:j}}),n.jsx("button",{onClick:e=>{e.stopPropagation(),o(e,t)},className:"absolute top-2 end-9 p-1.5 rounded-lg text-zinc-400 dark:text-zinc-500 hover:text-blue-500 dark:hover:text-blue-400 opacity-0 group-hover:opacity-100 transition-all hover:scale-110 z-10",children:n.jsx(T,{className:"w-3 h-3"})}),n.jsx("button",{onClick:e=>{e.stopPropagation(),l(e,t.id,t.name)},className:"absolute top-2 end-2 p-1.5 rounded-lg text-zinc-400 dark:text-zinc-500 hover:text-[#E53935] dark:hover:text-[#E53935] opacity-0 group-hover:opacity-100 transition-all hover:scale-110 z-10",children:n.jsx(R,{className:"w-3 h-3"})})]})},(e,t)=>e.folder.id===t.folder.id&&e.folder.name===t.folder.name&&e.folder.color===t.folder.color&&e.folder.icon===t.folder.icon&&e.projectCount===t.projectCount&&e.subFolderCount===t.subFolderCount&&e.selectionMode===t.selectionMode&&e.isSelected===t.isSelected),xe=t.memo(({project:e,iterationCount:t,onSelect:s,onRename:r,onDelete:a,formatDate:o,selectionMode:i,isSelected:d,onToggleSelect:c,onContextMenu:x})=>{const{t:u,fmt:m}=l();return n.jsxs("div",{onClick:t=>{if((t.ctrlKey||t.metaKey)&&c)return t.preventDefault(),void c(e.id);i&&c?c(e.id):s(e)},onContextMenu:t=>{x&&(t.preventDefault(),x(t,e))},className:"group flex items-center justify-between p-4 bg-white dark:bg-zinc-900 border rounded-xl hover:shadow-lg transition-all cursor-pointer "+(d?"border-indigo-500 ring-2 ring-indigo-500/30":"border-zinc-200 dark:border-zinc-800 hover:border-[#8f3589]"),children:[n.jsxs("div",{className:"flex items-center gap-4",children:[i&&n.jsx("button",{onClick:t=>{t.stopPropagation(),null==c||c(e.id)},className:"w-6 h-6 rounded-md border-2 flex items-center justify-center flex-shrink-0 transition-all "+(d?"bg-indigo-500 border-indigo-500":"border-zinc-300 dark:border-zinc-600 bg-white dark:bg-zinc-800 hover:border-indigo-400"),children:d&&n.jsx(P,{className:"w-4 h-4 text-white"})}),n.jsx("div",{className:"w-16 h-12 rounded-lg overflow-hidden bg-zinc-100 dark:bg-zinc-800 flex-shrink-0",children:e.thumbnail||e.thumbnailSmall?n.jsx(le,{src:e.thumbnail,smallSrc:e.thumbnailSmall,alt:e.name,className:"w-full h-full",fallbackIcon:n.jsx(L,{className:"w-5 h-5 text-zinc-400"})}):n.jsx("div",{className:"w-full h-full flex items-center justify-center",children:n.jsx(L,{className:"w-5 h-5 text-zinc-400"})})}),n.jsxs("div",{children:[n.jsx("h3",{className:"font-bold text-zinc-900 dark:text-white",children:e.name}),n.jsxs("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 flex items-center gap-3",children:[n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx($,{className:"w-3 h-3"}),o(e.createdAt)]}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx(W,{className:"w-3 h-3"}),t," ",1===t?"iteration":"iterations"]}),(()=>{const t=ie(e.expiresAt);if(null==t)return null;const s=Math.max(0,Math.ceil((t-Date.now())/864e5));if(s>14)return null;const r=s<=3;return n.jsxs("span",{className:"flex items-center gap-1 font-semibold "+(r?"text-red-600 dark:text-red-400":"text-amber-600 dar
1k:text-amber-400"),title:u("studio.retentionTooltip",{date:m.date(t)}),children:[n.jsx(K,{className:"w-3 h-3"}),0===s?u("studio.expiresToday"):u("studio.expiresInDays",{n:s})]})})()]})]})]}),n.jsxs("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[n.jsx("button",{onClick:t=>r(t,e),className:"p-2 bg-zinc-100 dark:bg-zinc-800 hover:bg-blue-600 hover:text-white rounded-lg transition-all",children:n.jsx(T,{className:"w-4 h-4"})}),n.jsx("button",{onClick:t=>a(t,e),className:"p-2 bg-zinc-100 dark:bg-zinc-800 hover:bg-[#E53935] hover:text-white rounded-lg transition-all",children:n.jsx(R,{className:"w-4 h-4"})})]})]})},(e,t)=>e.project.id===t.project.id&&e.project.name===t.project.name&&e.project.thumbnail===t.project.thumbnail&&e.project.thumbnailSmall===t.project.thumbnailSmall&&e.project.createdAt===t.project.createdAt&&e.project.expiresAt===t.project.expiresAt&&e.iterationCount===t.iterationCount&&e.selectionMode===t.selectionMode&&e.isSelected===t.isSelected),ue=t.memo(({folder:e,projectCount:t,subFolderCount:s=0,onSelect:r,onRename:a,onDelete:o,selectionMode:l,isSelected:i,onToggleSelect:d,onContextMenu:c})=>{const x=e.color||"#6366f1";return n.jsxs("div",{onClick:t=>{if((t.ctrlKey||t.metaKey)&&d)return t.preventDefault(),void d(e.id);l&&d?d(e.id):r(e.id)},onContextMenu:t=>{c&&(t.preventDefault(),c(t,e))},className:"group relative flex items-center justify-between px-4 py-3 rounded-xl transition-all cursor-pointer hover:bg-zinc-100/80 dark:hover:bg-white/[0.04] "+(i?"bg-indigo-50/70 dark:bg-indigo-500/10 ring-2 ring-inset ring-indigo-400/25":""),children:[n.jsx("div",{className:"absolute start-0 top-2 bottom-2 w-0.5 rounded-full opacity-0 group-hover:opacity-50 transition-opacity",style:{backgroundColor:x}}),n.jsxs("div",{className:"flex items-center gap-4",children:[l&&n.jsx("button",{onClick:t=>{t.stopPropagation(),null==d||d(e.id)},className:"w-6 h-6 rounded-md border-2 flex items-center justify-center flex-shrink-0 transition-all "+(i?"bg-indigo-500 border-indigo-500":"border-zinc-300 dark:border-zinc-600 bg-white dark:bg-zinc-800 hover:border-indigo-400"),children:i&&n.jsx(P,{className:"w-4 h-4 text-white"})}),n.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center",style:{backgroundColor:`${x}20`},children:e.icon?n.jsx("span",{className:"text-lg",children:e.icon}):n.jsx(A,{className:"w-5 h-5",style:{color:x}})}),n.jsxs("div",{children:[n.jsx("h3",{className:"font-bold text-zinc-900 dark:text-white",children:e.name}),n.jsxs("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 flex items-center gap-3",children:[n.jsxs("span",{children:[t," ",1===t?"project":"projects"]}),s>0&&n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx(O,{className:"w-3 h-3"}),s," sub-folder",s>1?"s":""]})]})]})]}),n.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[n.jsx("button",{onClick:t=>{t.stopPropagation(),a(t,e)},className:"p-2 rounded-lg text-zinc-400 dark:text-zinc-500 hover:text-blue-500 dark:hover:text-blue-400 transition-all hover:scale-110",children:n.jsx(T,{className:"w-4 h-4"})}),n.jsx("button",{onClick:t=>{t.stopPropagation(),o(t,e.id,e.name)},className:"p-2 rounded-lg text-zinc-400 dark:text-zinc-500 hover:text-[#E53935] dark:hover:text-[#E53935] transition-all hover:scale-110",children:n.jsx(R,{className:"w-4 h-4"})})]})]})},(e,t)=>e.folder.id===t.folder.id&&e.folder.name===t.folder.name&&e.folder.color===t.folder.color&&e.folder.icon===t.folder.icon&&e.projectCount===t.projectCount&&e.subFolderCount===t.subFolderCount&&e.selectionMode===t.selectionMode&&e.isSelected===t.isSelected),me=({folder:e,folders:t,selectedFolderId:s,onSelect:r,disabledFolderIds:a,expandedIds:o,toggleExpanded:l})=>{const i=t.filter(t=>t.parentFolderId===e.id),d=i.length>0,c=o.has(e.id),x=s===e.id,u=a.has(e.id),m=e.color||"#6366f1";return n.jsxs("div",{children:[n.jsxs("button",{onClick:()=>!u&&r(e.id),disabled:u,className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-all "+(x?"bg-indigo-50 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-300 font-bold":u?"text-zinc-300 dark:text-zinc-600 cursor-not-allowed":"text-zinc-700 dark:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-zinc-800"),style:{paddingLeft:16*(e.depth+1)+"px"},children:[d?n.jsx("button",{onClick:t=>{t.stopPropagation(),l(e.id)},className:"p-0.5 -ms-1 hover:bg-zinc-200 dark:hover:bg-zinc-700 rounded",children:c?n.jsx(B,{className:"w-3.5 h-3.5"}):n.jsx(H,{className:"w-3.5 h-3.5"})}):n.jsx("span",{className:"w-4.5"}),n.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${m}20`},children:e.icon?n.jsx("span",{className:"text-xs",children:e.icon}):n.jsx(A,{className:"w-3 h-3",style:{color:m}})}),n.jsx("span",{className:"truncate",children:e.name})]}),d&&c&&n.jsx("div",{children:i.map(e=>n.jsx(me,{folder:e,folders:t,selectedFolderId:s,onSelect:r,disabledFolderIds:a,expandedIds:o,toggleExpanded:l},e.id))})]})},he=({folders:t,selectedFolderId:s,onSelect:r,disabledFolderIds:a=new Set,showRoot:o=!0})=>{const{t:i}=l(),[d,c]=e.useState(()=>{const e=new Set;if(s){let n=t.find(e=>e.id===s);for(;null==n?void 0:n.parentFolderId;)e.add(n.parentFolderId),n=t.find(e=>e.id===n.parentFolderId)}return e}),[x,u]=e.useState(""),m=e=>{c(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},h=e.useMemo(()=>x.trim()?t.filter(e=>e.name.toLowerCase().includes(x.toLowerCase())):t.filter(e=>null===e.parentFolderId),[t,x]);return n.jsxs("div",{className:"space-y-2",children:[t.length>5&&n.jsxs("div",{className:"relative mb-2",children:[n.jsx(U,{className:"absolute start-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-zinc-400"}),n.jsx("input",{id:"folder-search",name:"folder-search",type:"text",placeholder:i("studio.searchFolders"),value:x,onChange:e=>u(e.target.value),className:"w-full ps-9 pe-3 py-2 bg-zinc-100 dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg text-sm focus:ring-2 focus:ring-indigo-500/20 outline-none"})]}),n.jsxs("div",{className:"max-h-64 overflow-y-auto space-y-0.5 custom-scrollbar",children:[o&&n.jsxs("button",{onClick:()=>r(null),className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-all "+(null===s?"bg-indigo-50 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-300 font-bold":"text-zinc-700 dark:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-zinc-800"),children:[n.jsx(X,{className:"w-4 h-4"}),n.jsx("span",{children:i("studio.homeRoot")})]}),h.map(e=>n.jsx(me,{folder:e,folders:x.trim()?[]:t,selectedFolderId:s,onSelect:r,disabledFolderIds:a,expandedIds:d,toggleExpanded:m},e.id)),0===h.length&&n.jsx("p",{className:"text-xs text-zinc-400 text-center py-4",children:"No folders found"})]})]})},pe=({isOpen:t,onClose:r,onCreate:a})=>{const{t:o}=l(),[d,c]=e.useState(""),[x,u]=e.useState(!1),[m,h]=e.useState(null);return t?s.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/80 backdrop-blur-sm animate-in fade-in",children:n.jsxs("div",{className:"w-full max-w-md bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 rounded-3xl p-8 shadow-2xl relative animate-in zoom-in-95 duration-200",children:[n.jsx("button",{onClick:()=>{c(""),h(null),r()},className:"absolute top-6 end-6 text-zinc-400 hover:text-[#E53935] transition-colors",children:n.jsx(V,{className:"w-6 h-6"})}),n.jsxs("div",{className:"mb-8",children:[n.jsx("div",{className:"w-12 h-12 bg-[#8f3589]/10 rounded-2xl flex items-center justify-center mb-4 border border-[#8f3589]/20",children:n.jsx(_,{className:"w-6 h-6 text-[#8f3589]"})}),n.jsx("h2",{className:"text-2xl font-bold text-zinc-900 dark:text-white",children:"Create Project"}),n.jsx("p",{className:"text-zinc-500 text-sm mt-1",children:"Give your new workspace a name."})]}),n.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),d.trim()){u(!0),h(null);try{await a(d),c(""),r()}catch(t){h(t instanceof Error?t.message:"Couldn't create the project. Please try again.")}finally{u(!1)}}},className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-2",children:"Project Name"}),n.jsx("input",{id:"create-project-name",name:"create-project-name",autoFocus:!0,t
1ype:"text",value:d,onChange:e=>c(e.target.value),placeholder:o("studio.projectNameExample"),className:"w-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-xl px-4 py-4 text-zinc-900 dark:text-white placeholder:text-zinc-400 focus:ring-2 focus:ring-[#26C5F3] outline-none transition-all font-bold"})]}),m&&n.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-[#E53935]/30 bg-[#E53935]/10 px-4 py-3",children:[n.jsx(K,{className:"w-5 h-5 text-[#E53935] shrink-0 mt-0.5"}),n.jsx("p",{className:"text-sm text-[#E53935] font-medium",children:m})]}),n.jsx("button",{type:"submit",disabled:!d.trim()||x,className:"w-full py-4 bg-[#E53935] hover:bg-[#E53935]/90 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-xl font-bold shadow-lg shadow-[#8f3589]/20 transition-all flex items-center justify-center gap-2",children:x?n.jsx(i,{size:"sm"}):o("studio.createWorkspaceBtn")})]})]})}),document.body):null},be=({isOpen:r,projectName:a,onClose:o,onRename:d})=>{const{t:c}=l(),[x,u]=e.useState(a),[m,h]=e.useState(!1);return t.useEffect(()=>{u(a)},[a]),r?s.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/80 backdrop-blur-sm animate-in fade-in",children:n.jsxs("div",{className:"w-full max-w-md bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 rounded-3xl p-8 shadow-2xl relative animate-in zoom-in-95 duration-200",children:[n.jsx("button",{onClick:o,className:"absolute top-6 end-6 text-zinc-400 hover:text-[#E53935] transition-colors",children:n.jsx(V,{className:"w-6 h-6"})}),n.jsxs("div",{className:"mb-8",children:[n.jsx("div",{className:"w-12 h-12 bg-blue-600/10 rounded-2xl flex items-center justify-center mb-4 border border-blue-600/20",children:n.jsx(T,{className:"w-6 h-6 text-blue-600"})}),n.jsx("h2",{className:"text-2xl font-bold text-zinc-900 dark:text-white",children:"Rename Project"}),n.jsx("p",{className:"text-zinc-500 text-sm mt-1",children:"Enter a new name for your project."})]}),n.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),x.trim()){h(!0);try{await d(x),o()}finally{h(!1)}}},className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-2",children:"Project Name"}),n.jsx("input",{id:"edit-project-name",name:"edit-project-name",autoFocus:!0,t
1ype:"text",value:x,onChange:e=>u(e.target.value),placeholder:c("studio.projectNameExample"),className:"w-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-xl px-4 py-4 text-zinc-900 dark:text-white placeholder:text-zinc-400 focus:ring-2 focus:ring-blue-600 outline-none transition-all font-bold"})]}),n.jsx("button",{type:"submit",disabled:!x.trim()||m,className:"w-full py-4 bg-blue-600 hover:bg-blue-500 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-xl font-bold shadow-lg shadow-blue-900/20 transition-all flex items-center justify-center gap-2",children:m?n.jsx(i,{size:"sm"}):n.jsxs(n.Fragment,{children:[n.jsx(P,{className:"w-5 h-5"})," Save Changes"]})})]})]})}),document.body):null},fe=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f59e0b","#10b981","#06b6d4","#3b82f6","#6b7280","#ef4444","#84cc16","#14b8a6"],ge=["ð","ð ","ð¢","ðï¸","ð¨","ð","ð¿","ðï¸","â¨","ð","ð·","ð"],je=({isOpen:r,onClose:a,onCreate:o,currentFolderId:d=null,folders:c=[],maxDepthReached:x=!1})=>{const{t:u}=l(),[m,h]=e.useState(""),[p,b]=e.useState("#6366f1"),[f,g]=e.useState(""),[j,v]=e.useState(""),[w,k]=e.useState(d),[N,z]=e.useState(!1),[y,C]=e.useState(!1);return t.useEffect(()=>{k(d)},[d]),r?s.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/80 backdrop-blur-sm animate-in fade-in",children:n.jsxs("div",{className:"w-full max-w-md bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 rounded-3xl p-8 shadow-2xl relative animate-in zoom-in-95 duration-200 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[n.jsx("button",{onClick:()=>{h(""),b("#6366f1"),g(""),v(""),z(!1),a()},className:"absolute top-6 end-6 text-zinc-400 hover:text-[#E53935] transition-colors",children:n.jsx(V,{className:"w-6 h-6"})}),n.jsxs("div",{className:"mb-8",children:[n.jsx("div",{className:"w-12 h-12 bg-indigo-600/10 rounded-2xl flex items-center justify-center mb-4 border border-indigo-600/20",children:n.jsx(A,{className:"w-6 h-6 text-indigo-600"})}),n.jsx("h2",{className:"text-2xl font-bold text-zinc-900 dark:text-white",children:"Create Folder"}),n.jsx("p",{className:"text-zinc-500 text-sm mt-1",children:"Organize your projects into folders."})]}),n.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),m.trim()){C(!0);try{await o(m,p,w,f||void 0,j||void 0),h(""),b("#6366f1"),g(""),v(""),z(!1),a()}finally{C(!1)}}},className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-2",children:"Folder Name"}),n.jsx("input",{id:"create-folder-name",name:"create-folder-name",autoFocus:!0,t
1ype:"text",value:m,onChange:e=>h(e.target.value),placeholder:u("studio.folderNameExample"),className:"w-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-xl px-4 py-4 text-zinc-900 dark:text-white placeholder:text-zinc-400 focus:ring-2 focus:ring-indigo-600 outline-none transition-all font-bold"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-3",children:"Folder Color"}),n.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:fe.map(e=>n.jsx("button",{type:"button",onClick:()=>b(e),className:"w-9 h-9 rounded-xl transition-all hover:scale-110 "+(p===e?"ring-2 ring-offset-2 ring-zinc-400 dark:ring-zinc-500 scale-110":""),style:{backgroundColor:e}},e))})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-3",children:"Icon (Optional)"}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("button",{type:"button",onClick:()=>g(""),className:"w-9 h-9 rounded-xl border text-xs transition-all hover:scale-110 "+(f?"border-zinc-200 dark:border-zinc-700":"ring-2 ring-offset-2 ring-zinc-400 dark:ring-zinc-500 scale-110 border-zinc-400"),children:"â"}),ge.map(e=>n.jsx("button",{type:"button",onClick:()=>g(e),className:"w-9 h-9 rounded-xl transition-all hover:scale-110 text-lg flex items-center justify-center "+(f===e?"ring-2 ring-offset-2 ring-zinc-400 dark:ring-zinc-500 scale-110 bg-zinc-100 dark:bg-zinc-800":""),children:e},e))]})]}),n.jsx("button",{type:"button",onClick:()=>z(!N),className:"text-xs font-bold text-indigo-500 hover:text-indigo-400 transition-colors uppercase tracking-widest",children:N?"â Hide Advanced":"+ Advanced Options"}),N&&n.jsxs("div",{className:"space-y-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[c.length>0&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-2",children:"Location"}),n.jsx(he,{folders:c,selectedFolderId:w,onSelect:k,showRoot:!0})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-2",children:"Description (Optional)"}),n.jsx("textarea",{value:j,onChange:e=>v(e.target.value),placeholder:u("studio.folderDescPlaceholder"),rows:2,className:"w-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-xl px-4 py-3 text-zinc-900 dark:text-white placeholder:text-zinc-400 focus:ring-2 focus:ring-indigo-600 outline-none transition-all text-sm resize-none"})]})]}),x&&n.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-xs bg-amber-50 dark:bg-amber-900/20 p-3 rounded-lg",children:[n.jsx(K,{className:"w-4 h-4 flex-shrink-0"}),n.jsx("span",{children:u("studio.maxFolderDepth")})]}),n.jsx("button",{type:"submit",disabled:!m.trim()||y||x,className:"w-full py-4 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-xl font-bold shadow-lg shadow-indigo-900/20 transition-all flex items-center justify-center gap-2",children:y?n.jsx(i,{size:"sm"}):u("studio.createFolderBtn")})]})]})}),document.body):null},ve=({isOpen:r,folderName:a,folderColor:o,folderIcon:d="",onClose:c,onRename:x})=>{const{t:u}=l(),[m,h]=e.useState(a),[p,b]=e.useState(o),[f,g]=e.useState(d),[j,v]=e.useState(!1);return t.useEffect(()=>{h(a),b(o),g(d)},[a,o,d]),r?s.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/80 backdrop-blur-sm animate-in fade-in",children:n.jsxs("div",{className:"w-full max-w-md bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 rounded-3xl p-8 shadow-2xl relative animate-in zoom-in-95 duration-200 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[n.jsx("button",{onClick:c,className:"absolute top-6 end-6 text-zinc-400 hover:text-[#E53935] transition-colors",children:n.jsx(V,{className:"w-6 h-6"})}),n.jsxs("div",{className:"mb-8",children:[n.jsx("div",{className:"w-12 h-12 bg-indigo-600/10 rounded-2xl flex items-center justify-center mb-4 border border-indigo-600/20",children:n.jsx(T,{className:"w-6 h-6 text-indigo-600"})}),n.jsx("h2",{className:"text-2xl font-bold text-zinc-900 dark:text-white",children:"Rename Folder"}),n.jsx("p",{className:"text-zinc-500 text-sm mt-1",children:"Update your folder details."})]}),n.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),m.trim()){v(!0);try{await x(m,p,f||void 0),c()}finally{v(!1)}}},className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-2",children:"Folder Name"}),n.jsx("input",{id:"edit-folder-name",name:"edit-folder-name",autoFocus:!0,t
1ype:"text",value:m,onChange:e=>h(e.target.value),placeholder:u("studio.folderNameExample"),className:"w-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-xl px-4 py-4 text-zinc-900 dark:text-white placeholder:text-zinc-400 focus:ring-2 focus:ring-indigo-600 outline-none transition-all font-bold"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-3",children:"Folder Color"}),n.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:fe.map(e=>n.jsx("button",{type:"button",onClick:()=>b(e),className:"w-9 h-9 rounded-xl transition-all hover:scale-110 "+(p===e?"ring-2 ring-offset-2 ring-zinc-400 dark:ring-zinc-500 scale-110":""),style:{backgroundColor:e}},e))})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-bold text-zinc-500 uppercase tracking-widest mb-3",children:"Icon (Optional)"}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("button",{type:"button",onClick:()=>g(""),className:"w-9 h-9 rounded-xl border text-xs transition-all hover:scale-110 "+(f?"border-zinc-200 dark:border-zinc-700":"ring-2 ring-offset-2 ring-zinc-400 dark:ring-zinc-500 scale-110 border-zinc-400"),children:"â"}),ge.map(e=>n.jsx("button",{type:"button",onClick:()=>g(e),className:"w-9 h-9 rounded-xl transition-all hover:scale-110 text-lg flex items-center justify-center "+(f===e?"ring-2 ring-offset-2 ring-zinc-400 dark:ring-zinc-500 scale-110 bg-zinc-100 dark:bg-zinc-800":""),children:e},e))]})]}),n.jsx("button",{type:"submit",disabled:!m.trim()||j,className:"w-full py-4 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-xl font-bold shadow-lg shadow-indigo-900/20 transition-all flex items-center justify-center gap-2",children:j?n.jsx(i,{size:"sm"}):n.jsxs(n.Fragment,{children:[n.jsx(P,{className:"w-5 h-5"})," Save Changes"]})})]})]})}),document.body):null},we=({isOpen:t,onClose:r,onMove:a,folders:o,disabledFolderIds:l=[],itemLabel:d="item(s)"})=>{const[c,x]=e.useState(null),[u,m]=e.useState(!1);return t?s.createPortal(n.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:n.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-2xl shadow-2xl w-full max-w-md border border-zinc-200 dark:border-zinc-700 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-6 pt-6 pb-2",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-xl bg-indigo-100 dark:bg-indigo-900/40 flex items-center justify-center",children:n.jsx(Y,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),n.jsxs("div",{children:[n.jsxs("h3",{className:"text-lg font-bold text-zinc-800 dark:text-zinc-100",children:["Move ",d]}),n.jsx("p",{className:"text-sm text-zinc-500",children:"Choose a destination folder"})]})]}),n.jsx("button",{onClick:r,className:"p-2 hover:bg-zinc-100 dark:hover:bg-zinc-800 rounded-xl transition-colors",children:n.jsx(V,{className:"w-5 h-5 text-zinc-500"})})]}),n.jsx("div",{className:"px-6 py-4 max-h-80 overflow-y-auto",children:n.jsx(he,{folders:o,selectedFolderId:c,onSelect:x,disabledFolderIds:new Set(l),showRoot:!0})}),n.jsxs("div",{className:"px-6 pb-6 flex gap-3",children:[n.jsx("button",{onClick:r,className:"flex-1 py-3 border border-zinc-200 dark:border-zinc-700 text-zinc-600 dark:text-zinc-400 rounded-xl font-semibold hover:bg-zinc-50 dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),n.jsx("button",{onClick:async()=>{m(!0);try{await a(c),r()}catch(e){console.error("Move failed:",e)}finally{m(!1)}},disabled:u,className:"flex-1 py-3 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-xl font-bold shadow-lg shadow-indigo-900/20 transition-all flex items-center justify-center gap-2",children:u?n.jsx(i,{size:"sm"}):n.jsxs(n.Fragment,{children:[n.jsx(Y,{className:"w-5 h-5"})," Move Here"]})})]})]})}),document.body):null},ke=({isOpen:t,onClose:r,onDelete:a,folderName:o,projectCount:l,subFolderCount:d})=>{const[c,x]=e.useState("move-to-parent"),[u,m]=e.useState(!1),h=l>0||d>0;return t?s.createPortal(n.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:n.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-2xl shadow-2xl w-full max-w-md border border-zinc-200 dark:border-zinc-700 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-6 pt-6 pb-2",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#8f3589]/5 dark:bg-[#E53935]/10 flex items-center justify-center",children:n.jsx(R,{className:"w-5 h-5 text-[#8f3589] dark:text-[#E53935]"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-bold text-zinc-800 dark:text-zinc-100",children:"Delete Folder"}),n.jsxs("p",{className:"text-sm text-zinc-500",children:['"',o,'"']})]})]}),n.jsx("button",{onClick:r,className:"p-2 hover:bg-zinc-100 dark:hover:bg-zinc-800 rounded-xl transition-colors",children:n.jsx(V,{className:"w-5 h-5 text-zinc-500"})})]}),n.jsx("div",{className:"px-6 py-4 space-y-4",children:h?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-xl bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800",children:[n.jsx(K,{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5"}),n.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:["This folder contains"," ",l>0&&n.jsxs("strong",{children:[l," project",1!==l?"s":""]}),l>0&&d>0&&" and ",d>0&&n.jsxs("strong",{children:[d," sub-folder",1!==d?"s":""]}),". What would you like to do with them?"]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:"flex items-start gap-3 p-3 rounded-xl border cursor-pointer transition-all "+("move-to-parent"===c?"border-indigo-300 dark:border-indigo-600 bg-indigo-50 dark:bg-indigo-900/20":"border-zinc-200 dark:border-zinc-700 hover:bg-zinc-50 dark:hover:bg-zinc-800"),children:[n.jsx("input",{type:"radio",name:"deleteStrategy",checked:"move-to-parent"===c,onChange:()=>x("move-to-parent"),className:"mt-1 accent-indigo-600"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-semibold text-sm text-zinc-800 dark:text-zinc-100",children:"Move contents up"}),n.jsx("p",{className:"text-xs text-zinc-500 mt-0.5",children:"Projects and sub-folders will be moved to the parent folder"})]})]}),n.jsxs("label",{className:"flex items-start gap-3 p-3 rounded-xl border cursor-pointer transition-all "+("delete-all"===c?"border-[#8f3589]/30 dark:border-[#8f3589] bg-[#8f3589]/5 dark:bg-[#8f3589]/10":"border-zinc-200 dark:border-zinc-700 hover:bg-zinc-50 dark:hover:bg-zinc-800"),children:[n.jsx("input",{type:"radio",name:"deleteStrategy",checked:"delete-all"===c,onChange:()=>x("delete-all"),className:"mt-1 accent-[#8f3589]"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-semibold text-sm text-zinc-800 dark:text-zinc-100",children:"Delete everything"}),n.jsx("p",{className:"text-xs text-zinc-500 mt-0.5",children:"All sub-folders and their projects will be permanently deleted"})]})]})]})]}):n.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"This folder is empty. It will be permanently deleted."})}),n.jsxs("div",{className:"px-6 pb-6 flex gap-3",children:[n.jsx("button",{onClick:r,className:"flex-1 py-3 border border-zinc-200 dark:border-zinc-700 text-zinc-600 dark:text-zinc-400 rounded-xl font-semibold hover:bg-zinc-50 dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),n.jsx("button",{onClick:async()=>{m(!0);try{await a(c),r()}catch(e){console.error("Delete failed:",e)}finally{m(!1)}}
1,disabled:u,className:"flex-1 py-3 bg-[#E53935] hover:bg-[#E53935]/90 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-xl font-bold shadow-lg shadow-[#8f3589]/20 transition-all flex items-center justify-center gap-2",children:u?n.jsx(i,{size:"sm"}):n.jsxs(n.Fragment,{children:[n.jsx(R,{className:"w-5 h-5"})," Delete Folder"]})})]})]})}),document.body):null},Ne=({currentFolderId:e,currentFolder:s,ancestors:r,onNavigate:a})=>{if(!e||!s)return null;const o=[...r,s],l=o.length>4,i=({folderId:e,label:t,isCurrent:s,icon:r,color:o})=>{const{setNodeRef:l,isOver:i}=C({id:null===e?"root":`breadcrumb-${e}`,data:{type:"breadcrumb",folderId:e}});return n.jsxs("button",{ref:l,onClick:()=>a(e),className:`flex items-center gap-1.5 px-2 py-1 rounded-lg transition-all text-sm ${s?"text-zinc-900 dark:text-white font-bold":"text-zinc-500 hover:text-zinc-900 dark:hover:text-white hover:bg-zinc-100 dark:hover:bg-zinc-800"} ${i?"bg-indigo-50 dark:bg-indigo-900/30 ring-2 ring-indigo-400 scale-105":""}`,children:[r,n.jsx("span",{className:"max-w-[120px] truncate",style:o?{color:o}:void 0,children:t})]})};return n.jsxs("nav",{className:"mb-6 flex items-center gap-1 text-sm flex-wrap",children:[n.jsx(i,{folderId:null,label:"Home",isCurrent:!1,icon:n.jsx(X,{className:"w-4 h-4"})}),l?n.jsxs(n.Fragment,{children:[n.jsx(H,{className:"w-3.5 h-3.5 text-zinc-400 flex-shrink-0"}),n.jsx(i,{folderId:o[0].id,label:o[0].name,isCurrent:!1,color:o[0].color}),n.jsx(H,{className:"w-3.5 h-3.5 text-zinc-400 flex-shrink-0"}),n.jsxs("div",{className:"relative group",children:[n.jsx("button",{className:"px-2 py-1 text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300 rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-all",children:"â¢â¢â¢"}),n.jsx("div",{className:"absolute top-full start-0 mt-1 py-1 bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded-xl shadow-xl z-50 min-w-[160px] hidden group-hover:block",children:o.slice(1,-1).map(e=>n.jsx("button",{onClick:()=>a(e.id),className:"w-full px-3 py-2 text-start text-sm text-zinc-700 dark:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors truncate",children:e.name},e.id))})]}),n.jsx(H,{className:"w-3.5 h-3.5 text-zinc-400 flex-shrink-0"}),n.jsx(i,{folderId:s.id,label:s.name,isCurrent:!0,color:s.color})]}):o.map((e,s)=>n.jsxs(t.Fragment,{children:[n.jsx(H,{className:"w-3.5 h-3.5 text-zinc-400 flex-shrink-0"}),n.jsx(i,{folderId:e.id,label:e.name,isCurrent:s===o.length-1,color:e.color})]},e.id))]})},ze=({selectedCount:e,selectedProjectCount:t,selectedFolderCount:s,onMoveTo:r,onDelete:a,onDuplicate:o,onClear:i})=>{const{t:d}=l();if(0===e)return null;const c=(()=>{const e=[];return t>0&&e.push(`${t} project${t>1?"s":""}`),s>0&&e.push(`${s} folder${s>1?"s":""}`),e.join(", ")})();return n.jsx("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-50 animate-in slide-in-from-bottom-4 fade-in duration-200",children:n.jsxs("div",{className:"flex items-center gap-3 px-6 py-3 bg-zinc-900 dark:bg-white text-white dark:text-zinc-900 rounded-2xl shadow-2xl border border-zinc-700 dark:border-zinc-300",children:[n.jsxs("span",{className:"text-sm font-bold whitespace-nowrap",children:[c," selected"]}),n.jsx("div",{className:"h-5 w-px bg-zinc-600 dark:bg-zinc-400"}),n.jsxs("button",{onClick:r,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-lg hover:bg-zinc-700 dark:hover:bg-zinc-200 transition-colors",children:[n.jsx(Z,{className:"w-4 h-4"}),"Move to"]}),o&&t>0&&0===s&&n.jsxs("button",{onClick:o,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-lg hover:bg-zinc-700 dark:hover:bg-zinc-200 transition-colors",children:[n.jsx(q,{className:"w-4 h-4"}),"Duplicate"]}),n.jsxs("button",{onClick:a,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-lg hover:bg-[#E53935]/10 dark:hover:bg-[#E53935]/10 hover:text-[#E53935] dark:hover:text-[#E53935] text-[#E53935]/80 dark:text-[#E53935]/70 transition-colors",children:[n.jsx(R,{className:"w-4 h-4"}),"Delete"]}),n.jsx("div",{className:"h-5 w-px bg-zinc-600 dark:bg-zinc-400"}),n.jsx("button",{onClick:i,className:"p-1.5 rounded-lg hover:bg-zinc-700 dark:hover:bg-zinc-200 transition-colors",title:d("studio.clearSelection"),children:n.jsx(V,{className:"w-4 h-4"})})]})})},ye=({x:s,y:r,items:a,onClose:o})=>{const l=e.useRef(null);return e.useEffect(()=>{const e=e=>{l.current&&!l.current.contains(e.target)&&o()},t=e=>{"Escape"===e.key&&o()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[o]),e.useEffect(()=>{if(l.current){const e=l.current.getBoundingClientRect(),t=window.innerWidth,n=window.innerHeight;e.right>t&&(l.current.style.left=s-e.width+"px"),e.bottom>n&&(l.current.style.top=r-e.height+"px")}},[s,r]),n.jsx("div",{ref:l,className:"fixed z-[100] min-w-[180px] py-1.5 bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded-xl shadow-2xl animate-in zoom-in-95 fade-in duration-100",style:{left:s,top:r},children:a.map((e,s)=>n.jsxs(t.Fragment,{children:[e.separator&&s>0&&n.jsx("div",{className:"my-1 border-t border-zinc-100 dark:border-zinc-800"}),n.jsxs("button",{onClick:()=>{e.action(),o()},disabled:e.disabled,className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm transition-colors "+(e.disabled?"text-zinc-300 dark:text-zinc-600 cursor-not-allowed":"danger"===e.variant?"text-[#E53935] hover:bg-[#
1E53935]/10 dark:hover:bg-[#E53935]/10":"text-zinc-700 dark:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-zinc-800"),children:[e.icon,n.jsx("span",{children:e.label})]})]},s))})},Ce=({item:t,onClose:s})=>{const{t:r}=l(),{workspaces:a,loading:o}=ae(),[i,d]=e.useState(null),[c,x]=e.useState([]),[u,m]=e.useState(null);return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:n.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-2xl shadow-2xl w-full max-w-sm border border-zinc-200 dark:border-zinc-800",children:[n.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[n.jsxs("div",{className:"flex items-center gap-2.5",children:[n.jsx(J,{className:"w-5 h-5 text-purple-500"}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-sm font-bold text-zinc-900 dark:text-white",children:r("space.addToSpace")}),n.jsxs("p",{className:"text-xs text-zinc-400 dark:text-zinc-500 mt-0.5 max-w-[220px] truncate",children:['"',t.name,'"']})]})]}),n.jsx("button",{onClick:s,className:"p-1.5 rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors text-zinc-400",children:n.jsx(V,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"px-5 pb-5",children:[u&&n.jsx("p",{className:"mb-3 text-xs text-red-500 bg-red-50 dark:bg-red-900/20 rounded-lg px-3 py-2",children:u}),o?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Q,{className:"w-5 h-5 animate-spin text-purple-500"})}):0===a.length?n.jsxs("div",{className:"text-center py-8",children:[n.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:r("space.noWorkspaces")}),n.jsx("p",{className:"text-xs text-zinc-400 dark:text-zinc-600 mt-1",children:r("space.createWorkspaceFirst")})]}):n.jsx("div",{className:"space-y-1.5 max-h-72 overflow-y-auto",children:a.map(e=>{const s=c.includes(e.id),a=i===e.id;return n.jsxs("button",{onClick:()=>(async e=>{if(!i&&!c.includes(e)){d(e),m(null);try{"project"===t.type?await oe.linkProject(e,t.id,t.name):await oe.linkFolder(e,t.id,t.name),x(t=>[...t,e])}catch(n){const e=(null==n?void 0:n.message)??r("space.linkFailed");m(e.replace(/^.*?INTERNAL:\s*/i,""))}finally{d(null)}}})(e.id,e.name),disabled:a||s,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl border transition-all text-start "+(s?"border-emerald-300 dark:border-emerald-700 bg-emerald-50 dark:bg-emerald-900/20":"border-zinc-200 dark:border-zinc-800 hover:border-purple-300 dark:hover:border-purple-700 hover:bg-purple-50 dark:hover:bg-purple-900/10"),children:[n.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center text-base shrink-0",style:{backgroundColor:e.color??"#7c3aed22"},children:e.icon??"ðï¸"}),n.jsx("span",{className:"flex-1 text-sm font-medium text-zinc-800 dark:text-zinc-200 truncate",children:e.name}),a&&n.jsx(Q,{className:"w-4 h-4 animate-spin text-purple-500 shrink-0"}),s&&n.jsx(P,{className:"w-4 h-4 text-emerald-500 shrink-0"})]},e.id)})}),n.jsx("button",{onClick:s,className:"mt-4 w-full py-2 rounded-xl text-sm font-medium text-zinc-500 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors",children:r("common.done")})]})]})})},Se="projectViewMode",Fe=t.memo(({userId:t,userPlan:s,onSelectProject:y,onSwitchPersona:C,onOpenAccount:P,onOpenAdmin:O,onOpenOrgAdmin:L,onOpenSpace:$,onOpenWall:W,onOpenCadViewer:X,isVip:B,isAdmin:H,isOrgAdmin:Y,unreadCount:Q,initialFolderId:oe,notice:le,onDismissNotice:ie})=>{const{projects:me,isLoading:he,loadError:fe,createProject:ge,deleteProject:Fe,renameProject:Ie,moveProjectToFolder:De,bulkMoveProjects:Me,bulkDeleteProjects:Ee,duplicateProject:Pe}=d(t,s),{folders:Ae,isLoading:Oe,createFolder:Te,renameFolder:Re,deleteFolder:Le,moveFolder:$e,getFolderAncestors:We,getDescendantFolderIds:Ke,getRecursiveProjectCount:Ue,getSubFolderCount:Xe,wouldCreateCycle:Be,toggleFolderPinned:He,MAX_FOLDER_DEPTH:Ve}=(t=>{const[n,s]=e.useState([]),[r,l]=e.useState(!0);e.useEffect(()=>{if(!a||!t)return s([]),void l(!1);const e=u(p(a,"folders"),h("userId","==",t),m("createdAt","desc")),n=b(e,e=>{const t=e.docs.map(e=>{const t=e.data();return{id:e.id,userId:t.userId,name:t.name,createdAt:t.createdAt,updatedAt:t.updatedAt??t.createdAt??Date.now(),color:t.color,icon:t.icon,parentFolderId:t.parentFolderId??null,path:t.path??`/${e.id}`,depth:t.depth??0,description:t.description,isPinned:t.isPinned}});s(t),l(!1)},()=>{l(!1)});return()=>n()},[t]);const i=e.useCallback(e=>n.filter(t=>t.parentFolderId===e),[n]),d=e.useCallback(e=>{const t=[],s=[e];for(;s.length>0;){const e=s.shift(),r=n.filter(t=>t.parentFolderId===e);for(const n of r)t.push(n.id),s.push(n.id)}return t},[n]),c=e.useCallback(e=>{const t=[];let s=n.find(t=>
1t.id===e);for(;s&&s.parentFolderId;){const e=n.find(e=>e.id===s.parentFolderId);if(!e)break;t.unshift(e),s=e}return t},[n]),x=e.useCallback((e,t)=>null!==t&&(t===e||d(e).includes(t)),[d]),N=e.useCallback((e,t)=>{const n=[e,...d(e)];return t.filter(e=>e.folderId&&n.includes(e.folderId)).length},[d]),z=e.useCallback(e=>n.filter(t=>t.parentFolderId===e).length,[n]),y=e.useMemo(()=>n.filter(e=>e.isPinned),[n]);return{folders:n,isLoading:r,createFolder:async(e,s,r,l,i)=>{if(t&&a)try{let d="",c=0;if(r){const e=n.find(e=>e.id===r);if(e){if(e.depth>=5)throw new Error("Maximum folder depth of 5 reached");d=e.path,c=e.depth+1}}const x=Date.now(),u={userId:t,name:o(e)||"Untitled Folder",createdAt:x,updatedAt:x,color:s||"#6366f1",parentFolderId:r||null,depth:c};l&&(u.icon=l),i&&(u.description=i);const m=await k(p(a,"folders"),u),h=d?`${d}/${m.id}`:`/${m.id}`;return await g(m,{path:h}),m.id}catch(d){if(d instanceof Error&&d.message.includes("Maximum folder depth"))throw d}},renameFolder:async(e,t,n,s)=>{if(a)try{const r=f(a,"folders",e),l={name:o(t)||"Untitled Folder",updatedAt:Date.now()};void 0!==n&&(l.color=n),void 0!==s&&(l.icon=s),await g(r,l)}catch(r){}},deleteFolder:async(e,s="move-to-parent")=>{var r,o;if(a)try{const l=n.find(t=>t.id===e);if(!l)return;const i=l.parentFolderId||null;if("move-to-parent"===s){const s=n.filter(t=>t.parentFolderId===e);if(s.length>0){const e=j(a);for(const t of s){const s=i?((null==(r=n.find(e=>e.id===i))?void 0:r.path)||"")+"/"+t.id:`/${t.id}`,l=i?((null==(o=n.find(e=>e.id===i))?void 0:o.depth)??-1)+1:0;e.update(f(a,"folders",t.id),{parentFolderId:i,path:s,depth:l,updatedAt:Date.now()});const d=n.filter(e=>e.path.startsWith(t.path+"/"));for(const n of d){const r=n.path.substring(t.path.length);e.update(f(a,"folders",n.id),{path:s+r,depth:l+(n.depth-t.depth),updatedAt:Date.now()})}}await e.commit()}const l=u(p(a,"projects"),h("userId","==",t),h("folderId","==",e)),d=await v(l);if(d.docs.length>0){const e=j(a);d.docs.forEach(t=>{e.update(t.ref,{folderId:i})}),await e.commit()}}else{const n=d(e),s=[e,...n];for(const e of s){const n=u(p(a,"projects"),h("userId","==",t),h("folderId","==",e)),s=await v(n);if(s.docs.length>0){const e=j(a);s.docs.forEach(t=>{e.delete(t.ref)}),await e.commit()}}for(const e of n)await w(f(a,"folders",e))}await w(f(a,"folders",e))}catch(l){}},updateFolderColor:async(e,t)=>
1{if(a)try{const n=f(a,"folders",e);await g(n,{color:t,updatedAt:Date.now()})}catch(n){}},moveFolder:async(e,t)=>{if(!a)return;const s=n.find(t=>t.id===e);if(s&&s.parentFolderId!==t){if(x(e,t))throw new Error("Cannot move a folder into its own subfolder");if(t){const r=n.find(e=>e.id===t);if(!r)return;const a=d(e).reduce((e,t)=>{const r=n.find(e=>e.id===t);return r?Math.max(e,r.depth-s.depth):e},0);if(r.depth+1+a>5)throw new Error("Move would exceed maximum folder depth of 5")}try{const r=j(a),o=Date.now();let l,i;if(t){const s=n.find(e=>e.id===t);l=`${s.path}/${e}`,i=s.depth+1}else l=`/${e}`,i=0;const d=i-s.depth,c=s.path;r.update(f(a,"folders",e),{parentFolderId:t,path:l,depth:i,updatedAt:o});const x=n.filter(e=>e.path.startsWith(c+"/"));for(const e of x){const t=l+e.path.substring(c.length);r.update(f(a,"folders",e.id),{path:t,depth:e.depth+d,updatedAt:o})}await r.commit()}catch(r){if(r instanceof Error)throw r}}},getFolderChildren:i,getFolderAncestors:c,getDescendantFolderIds:d,getRecursiveProjectCount:N,getSubFolderCount:z,wouldCreateCycle:x,toggleFolderPinned:async e=>{if(a)try{const t=n.find(t=>t.id===e);if(!t)return;const s=f(a,"folders",e);await g(s,{isPinned:!t.isPinned,updatedAt:Date.now()})}catch(t){}},updateFolderDescription:async(e,t)=>
1{if(a)try{const n=f(a,"folders",e);await g(n,{description:t,updatedAt:Date.now()})}catch(n){}},pinnedFolders:y,MAX_FOLDER_DEPTH:5}})(t),_e=e.useMemo(()=>me.map(e=>e.id),[me]),{counts:Ye}=((t,n)=>{const[s,r]=e.useState({}),[o,l]=e.useState(!0);return e.useEffect(()=>{if(!a||!t||0===n.length)return r({}),void l(!1);let e=!0;return(async()=>{try{const s={},o=10,i=[];for(let e=0;e<n.length;e+=o)i.push(n.slice(e,e+o));await Promise.all(i.map(async e=>{const n=u(p(a,"renders"),h("userId","==",t),h("projectId","in",e));(await v(n)).docs.forEach(e=>{const t=e.data().projectId;t&&(s[t]=(s[t]||0)+1)})})),e&&(r(s),l(!1))}catch(s){e&&(r({}),l(!1))}})(),()=>{e=!1}},[t,n.join(",")]),{counts:s,isLoading:o}})(t,_e),Ze=(({folderIds:t,projectIds:n})=>{const[s,r]=e.useState(new Set),a=s.size>0,o=e.useCallback(e=>{r(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),l=e.useCallback(e=>{r(new Set(e))},[]),i=e.useCallback(()=>{r(new Set)},[]),d=e.useCallback(e=>s.has(e),[s]),c=e.useCallback((e,t)=>{r(n=>{const s=Array.from(n);if(0===s.length)return new Set([t]);const r=s[s.length-1],a=e.indexOf(r),o=e.indexOf(t);if(-1===a||-1===o)return new Set([...s,t]);const l=Math.min(a,o),i=Math.max(a,o),d=e.slice(l,i+1);return new Set([...s,...d])})},[]),x=e.useMemo(()=>{const e=new Set(t);return Array.from(s).filter(t=>e.has(t))},[s,t]),u=e.useMemo(()=>{const e=new Set(n);return Array.from(s).filter(t=>e.has(t))},[s,n]);return e.useEffect(()=>{r(new Set)},[t.join(","),n.join(",")]),{selectedIds:s,selectionMode:a,toggleSelect:o,selectAll:l,clearSelection:i,isSelected:d,selectRange:c,selectedFolders:x,selectedProjects:u}})({projectIds:_e,folderIds:e.useMemo(()=>Ae.map(e=>e.id),[Ae])}),[qe,Ge]=e.useState(oe||null),[Je,Qe]=e.useState(""),[et,tt]=e.useState(""),[nt,st]=e.useState(null),[rt,at]=e.useState(null),[ot,lt]=e.useState(()=>{try{return"list"===localStorage.getItem(Se)?"list":"cards"}catch{return"cards"}}),[it,dt]=e.useState("date-desc"),[ct,xt]=e.useState(null),[ut,mt]=e.useState(!1),[ht,pt]=e.useState(!1),[bt,ft]=e.useState(null),[gt,jt]=e.useState(null),[vt,wt]=e.useState(!1),[kt,Nt]=e.useState([]),[zt,yt]=e.useState("item(s)"),[Ct,St]=e.useState(null),[Ft,It]=e.useState(null),[Dt,Mt]=e.useState(null),{workspaces:Et}=ae(),Pt=Et.length>0,[At,Ot]=e.useState(null),{dialogProps:Tt,confirm:Rt}=N(),{t:Lt}=l(),$t=ut||ht||!!bt||!!gt||vt||!!Ft||!!Dt,Wt=S(F(E,{activationConstraint:{distance:8}}));e.useEffect(()=>{void 0!==oe&&Ge(oe)},[oe]),e.useEffect(()=>{const e=setTimeout(()=>{tt(Je)},300);return()=>clearTimeout(e)},[Je]),e.useEffect(()=>{try{localStorage.setItem(Se,ot)}catch{}},[ot]);const Kt=e.useCallback(e=>{Qe(e.target.value)},[]),Ut=e.useCallback((e,t)=>{e.stopPropagation(),ft(t)},[]),Xt=e.useCallback((e,t)=>{e.stopPropagation(),jt(t)},[]),Bt=e.useCallback((e,t)=>{e.stopPropagation(),Rt({title:Lt("dialogs.deleteProject"),message:Lt("studio.deleteProjectLongMsg",{name:t.name}),variant:"danger",confirmText:Lt("common.delete"),onConfirm:async()=>{await Fe(t.id)}})},[Rt,Fe]),Ht=e.useCallback((e,t,n)=>{const s=Ae.find(e=>e.id===t);s&&It(s)},[Ae]),Vt=e.useCallback(async e=>{Ft&&(await Le(Ft.id,e),qe===Ft.id&&Ge(Ft.parentFolderId||null),It(null))},[Ft,Le,qe]),_t=e.useCallback(async e=>{await ge(e,void 0,qe)},[ge,qe]),Yt=e.useCallback(async e=>{bt&&await Ie(bt.id,e)},[bt,Ie]),Zt=e.useCallback(async(e,t,n,s,r)=>{await Te(e,t,n??qe,s,r)},[Te,qe]),qt=e.useCallback(async(e,t,n)=>{gt&&await Re(gt.id,e,t,n)},[gt,Re]),Gt=e.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation();const s=(r={onOpen:()=>{y(t),Ot(null)},onRename:()=>{ft(t),Ot(null)},onMoveTo:()=>{yt(`"${t.name}"`),Nt([]),St(()=>async e=>{await De(t.id,e)}),wt(!0),Ot(null)},onDuplicate:()=>{xt(null),Pe(t.id).catch(e=>{xt(e instanceof Error?e.message:"Couldn't duplicate the project.")}),Ot(null)},onDelete:()=>{Rt({title:Lt("dialogs.deleteProject"),message:Lt("studio.deleteProjectShortMsg",{name:t.name}),variant:"danger",confirmText:Lt("common.delete"),onConfirm:async()=>{await Fe(t.id)}}),Ot(null)},...Pt?{onLinkToWorkspace:()=>{Mt({type:"project",id:t.id,name:t.name}),Ot(null)}}:{}}
1,[{label:"Open",icon:n.jsx(_,{className:"w-4 h-4"}),action:r.onOpen},{label:"Rename",icon:n.jsx(T,{className:"w-4 h-4"}),action:r.onRename},{label:"Move toâ¦",icon:n.jsx(Z,{className:"w-4 h-4"}),action:r.onMoveTo,separator:!0},{label:"Duplicate",icon:n.jsx(q,{className:"w-4 h-4"}),action:r.onDuplicate},...r.onLinkToWorkspace?[{label:"Add to MNKISpaceâ¦",icon:n.jsx(J,{className:"w-4 h-4"}),action:r.onLinkToWorkspace,separator:!0}]:[],{label:"Delete",icon:n.jsx(R,{className:"w-4 h-4"}),action:r.onDelete,variant:"danger",separator:!r.onLinkToWorkspace}]);var r;Ot({x:e.clientX,y:e.clientY,items:s})},[y,De,Pe,Fe,Rt]),Jt=e.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation();const s=Ke(t.id),r=(a={onOpen:()=>{Ge(t.id),Ot(null)},onRename:()=>{jt(t),Ot(null)},onMoveTo:()=>{yt(`"${t.name}"`),Nt([t.id,...s]),St(()=>async e=>{await $e(t.id,e)}),wt(!0),Ot(null)},onTogglePin:()=>{He(t.id),Ot(null)},onDelete:()=>{It(t),Ot(null)},isPinned:!!t.isPinned,...Pt?{onLinkToWorkspace:()=>{Mt({type:"folder",id:t.id,name:t.name}),Ot(null)}}:{}},[{label:"Open",icon:n.jsx(_,{className:"w-4 h-4"}),action:a.onOpen},{label:"Rename",icon:n.jsx(T,{className:"w-4 h-4"}),action:a.onRename},{label:"Move toâ¦",icon:n.jsx(Z,{className:"w-4 h-4"}),action:a.onMoveTo,separator:!0},{label:a.isPinned?"Unpin":"Pin",icon:n.jsx(G,{className:"w-4 h-4"}),action:a.onTogglePin},...a.onLinkToWorkspace?[{label:"Add to MNKISpaceâ¦",icon:n.jsx(J,{className:"w-4 h-4"}),action:a.onLinkToWorkspace,separator:!0}]:[],{label:"Delete",icon:n.jsx(R,{className:"w-4 h-4"}),action:a.onDelete,variant:"danger",separator:!a.onLinkToWorkspace}]);var a;Ot({x:e.clientX,y:e.clientY,items:r})},[Ke,$e,He]),Qt=e.useCallback(()=>{const e=Ze.selectedProjects,t=Ze.selectedFolders,n=t.flatMap(e=>[e,...Ke(e)]),s=e.length+t.length;yt(`${s} item${1!==s?"s":""}`),Nt(n),St(()=>async n=>{e.length>0&&await Me(e,n);for(const e of t)await $e(e,n);Ze.clearSelection()}),wt(!0)},[Ze,Ke,Me,$e]),en=e.useCallback(()=>{const e=Ze.selectedProjects,t=Ze.selectedFolders,n=e.length+t.length;Rt({title:Lt("studio.deleteSelected"),message:Lt("dialogs.deleteSelectedMsg",{n:n}),variant:"danger",confirmText:Lt("studio.deleteAll"),onConfirm:async()=>{e.length>0&&await Ee(e);for(const e of t)await Le(e,"move-to-parent");Ze.clearSelection()}})},[Ze,Rt,Ee,Le]),tn=e.useCallback(async()=>{xt(null);for(const t of Ze.selectedProjects)try{await Pe(t)}catch(e){xt(e instanceof Error?e.message:"Couldn't duplicate the project.");break}Ze.clearSelection()},[Ze,Pe]),nn=e.useCallback(e=>{const t=e.active.id;st(t),Ae.some(e=>e.id===t)?at("folder"):at("project")},[Ae]),sn=e.useCallback(async e=>{const{active:t,over:n}=e;if(st(null),at(null),!n)return;const s=t.id,r=n.id;if(s===r)return;const a=Ae.some(e=>e.id===s),o=Ae.find(e=>e.id===r),l="root"===r||"breadcrumb-root"===r,i=r.startsWith("breadcrumb-");if(a){let e=null;l?e=null:i?e=r.replace("breadcrumb-",""):o&&(e=o.id),Be(s,e)||await $e(s,e)}else if(l)await De(s,null);else if(i){const e=r.replace("breadcrumb-","");await De(s,"root"===e?null:e)}else o&&await De(s,o.id)},[Ae,De,$e,Be]);(({isActive:t,onCreateProject:n,onCreateFolder:s,onRenameSelected:r,onDeleteSelected:a,onSelectAll:o,onClearSelection:l,onNavigateUp:i,onOpenSelected:d,onDuplicateSelected:c,onMoveSelected:x,hasSelection:u})=>{const m=e.useCallback(e=>{if(!t)return;const m=e.target;if("INPUT"===m.tagName||"TEXTAREA"===m.tagName||m.isContentEditable)return;const h=e.ctrlKey||e.metaKey;return h&&!e.shiftKey&&"n"===e.key?(e.preventDefault(),void(null==n||n())):h&&e.shiftKey&&"N"===e.key?(e.preventDefault(),void(null==s||s())):"F2"===e.key&&u?(e.preventDefault(),void(null==r||r())):"Delete"===e.key&&u?(e.preventDefault(),void(null==a||a())):h&&"a"===e.key?(e.preventDefault(),void(null==o||o())):"Escape"===e.key?(e.preventDefault(),void(null==l||l())):"Backspace"===e.key?(e.preventDefault(),void(null==i||i())):"Enter"===e.key&&u?(e.preventDefault(),void(null==d||d())):h&&"d"===e.key&&u?(e.preventDefault(),void(null==c||c())):h&&e.shiftKey&&"M"===e.key&&u?(e.preventDefault(),void(null==x||x())):void 0},[t,u,n,s,r,a,o,l,i,d,c,x]);e.useEffect(()=>(document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)),[m])})({isActive:!$t,onCreateProject:()=>mt(!0),onCreateFolder:()=>pt(!0),onRenameSelected:()=>
1{if(1===Ze.selectedProjects.length){const e=me.find(e=>e.id===Ze.selectedProjects[0]);e&&ft(e)}else if(1===Ze.selectedFolders.length){const e=Ae.find(e=>e.id===Ze.selectedFolders[0]);e&&jt(e)}},onDeleteSelected:()=>{Ze.selectedIds.size>0&&en()},onSelectAll:()=>{const e=[...an.map(e=>e.id),...rn.map(e=>e.id)];Ze.selectAll(e)},onClearSelection:Ze.clearSelection,onNavigateUp:()=>{xn&&Ge(xn.parentFolderId||null)},onOpenSelected:()=>{if(1===Ze.selectedProjects.length){const e=me.find(e=>e.id===Ze.selectedProjects[0]);e&&y(e)}else 1===Ze.selectedFolders.length&&Ge(Ze.selectedFolders[0])},onDuplicateSelected:tn,onMoveSelected:()=>{Ze.selectedIds.size>0&&Qt()},hasSelection:Ze.selectedIds.size>0});const rn=e.useMemo(()=>{let e;if(et.trim()){const t=et.toLowerCase();if(null===qe)e=me.filter(e=>e.name.toLowerCase().includes(t));else{const n=Ke(qe),s=new Set([qe,...n]);e=me.filter(e=>{const n=e.folderId||null;return null!==n&&s.has(n)&&e.name.toLowerCase().includes(t)})}}else e=me.filter(e=>(e.folderId||null)===qe);return e.sort((e,t)=>{switch(it){case"date-desc":return t.createdAt-e.createdAt;case"date-asc":return e.createdAt-t.createdAt;case"name-asc":return e.name.localeCompare(t.name);case"name-desc":return t.name.localeCompare(e.name);default:return 0}})},[me,qe,et,it,Ke]),an=e.useMemo(()=>{let e;if(et.trim()){const t=et.toLowerCase();if(null===qe)e=Ae.filter(e=>e.name.toLowerCase().includes(t));else{const n=new Set(Ke(qe));e=Ae.filter(e=>n.has(e.id)&&e.name.toLowerCase().includes(t))}}else e=Ae.filter(e=>(e.parentFolderId||null)===qe);return e.sort((e,t)=>{if(e.isPinned&&!t.isPinned)return-1;if(!e.isPinned&&t.isPinned)return 1;switch(it){case"date-desc":return t.createdAt-e.createdAt;case"date-asc":return e.createdAt-t.createdAt;case"name-desc":return t.name.localeCompare(e.name);default:return e.name.localeCompare(t.name)}})},[Ae,qe,et,it,Ke]),on=e.useCallback(e=>me.filter(t=>t.folderId===e).length,[me]),ln=e.useMemo(()=>nt&&"project"===rt?me.find(e=>e.id===nt):null,[nt,rt,me]),dn=e.useMemo(()=>nt&&"folder"===rt?Ae.find(e=>e.id===nt):null,[nt,rt,Ae]),cn=e.useCallback(e=>new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),[]),xn=e.useMemo(()=>qe?Ae.find(e=>e.id===qe):null,[qe,Ae]),un=e.useMemo(()=>qe?We(qe):[],[qe,We]),mn=(xn?xn.depth:-1)+1>=Ve;return he||Oe?n.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:n.jsx(i,{})}):n.jsxs(I,{sensors:Wt,collisionDetection:D,onDragStart:nn,onDragEnd:sn,children:[n.jsxs("div",{className:"flex-1 flex flex-col h-screen relative bg-zinc-50 dark:bg-black overflow-hidden",children:[n.jsx("div",{className:"futuristic-grid opacity-20 dark:opacity-[0.07]"}),n.jsx("div",{className:"blueprint-hologram"}),n.jsx("div",{className:"blueprint-lines opacity-10 dark:opacity-[0.04]"}),n.jsx("div",{className:"hologram-circles"}),n.jsx("div",{className:"technical-overlay"}),n.jsx("div",{className:"gradient-orb gradient-orb-1"}),n.jsx("div",{className:"gradient-orb gradient-orb-2"}),n.jsxs("div",{className:"px-8 py-6 border-b border-zinc-200 dark:border-zinc-800 flex items-center justify-between bg-white/80 dark:bg-zinc-950/80 backdrop-blur-md sticky top-0 z-30 backdrop-blur-content",children:[n.jsx("div",{className:"flex items-center gap-4",children:n.jsx(c,{className:"scale-[1.2]"})}),n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsxs("button",{onClick:C,className:"flex items-center gap-2 px-4 py-2 rounded-xl border border-zinc-200 dark:border-zinc-800 text-xs font-bold uppercase tracking-widest text-zinc-500 dark:text-zinc-400 hover:text-black dark:hover:text-white hover:border-zinc-300 dark:hover:border-zinc-600 transition-all bg-white dark:bg-zinc-900",children:[n.jsx(ee,{className:"w-3.5 h-3.5"}),"Switch Persona"]}),n.jsx("div",{className:"h-6 w-px bg-zinc-200 dark:bg-zinc-800 mx-1"}),n.jsx(x,{}),n.jsx(r,{onOpenAccount:P,onOpenAdmin:O,onOpenOrgAdmin:L,onOpenSpace:$,onOpenWall:W,onOpenCadViewer:X,isVip:B,isAdmin:H,isOrgAdmin:Y,large:!0})]})]}),n.jsxs("div",{className:"flex-1 p-8 md:p-12 overflow-y-auto custom-scrollbar relative z-[2]",children:[n.jsx(Ne,{currentFolderId:qe,currentFolder:xn??null,ancestors:un,onNavigate:Ge}),n.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 mb-12 animate-in fade-in slide-in-from-top-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-4xl font-black text-zinc-900 dark:text-white mb-2 tracking-tight",children:xn?xn.name:Lt("studio.yourWorkspace")}),n.jsx("p",{className:"text-zinc-500",children:(null==xn?void 0:xn.description)||Lt("studio.dashboardManageBody")})]}),n.jsxs("div",{className:"flex items-center gap-4",children:[!mn&&n.jsxs("button",{onClick:()=>pt(!0),className:"px-6 py-4 bg-indigo-600 dark:bg-indigo-500 text-white rounded-2xl flex items-center gap-3 hover:scale-105 transition-all shadow-xl",children:[n.jsx(A,{className:"w-5 h-5"})," ",Lt("studio.newFolder")]}),n.jsxs("button",{onClick:()=>mt(!0),"data-tour":"dashboard-new-project",className:"px-6 py-4 bg-zinc-900 dark:bg-white text-white dark:text-black rounded-2xl flex items-center gap-3 hover:scale-105 transition-all shadow-xl",children:[n.jsx(te,{className:"w-5 h-5"}
1)," ",Lt("studio.newProject")]})]})]}),le&&n.jsxs("div",{className:"flex items-start gap-3 mb-6 rounded-2xl border border-amber-500/30 bg-amber-500/10 px-5 py-4 animate-in fade-in",children:[n.jsx(K,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 shrink-0 mt-0.5"}),n.jsx("p",{className:"flex-1 text-sm text-amber-800 dark:text-amber-200 font-medium",children:le}),ie&&n.jsx("button",{onClick:ie,"aria-label":"Dismiss",className:"text-amber-600 dark:text-amber-400 hover:opacity-70 transition-opacity shrink-0",children:n.jsx(V,{className:"w-4 h-4"})})]}),(fe||ct)&&n.jsxs("div",{className:"flex items-start gap-3 mb-6 rounded-2xl border border-[#E53935]/30 bg-[#E53935]/10 px-5 py-4 animate-in fade-in",children:[n.jsx(K,{className:"w-5 h-5 text-[#E53935] shrink-0 mt-0.5"}),n.jsx("p",{className:"flex-1 text-sm text-[#E53935] font-medium",children:fe||ct}),!fe&&n.jsx("button",{onClick:()=>xt(null),"aria-label":"Dismiss",className:"text-[#E53935] hover:opacity-70 transition-opacity shrink-0",children:n.jsx(V,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 mb-6 animate-in fade-in",children:[n.jsxs("div",{className:"relative flex-1 max-w-md",children:[n.jsx(U,{className:"absolute start-4 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400"}),n.jsx("input",{id:"project-search",name:"project-search",type:"text",placeholder:Lt("studio.searchProjects"),value:Je,onChange:Kt,className:"w-full ps-11 pe-4 py-3 bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-xl text-sm text-zinc-900 dark:text-white placeholder:text-zinc-400 focus:ring-2 focus:ring-[#26C5F3]/20 focus:border-[#8f3589] outline-none transition-all"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("div",{className:"flex items-center gap-1 p-1 bg-zinc-100 dark:bg-zinc-900 rounded-lg border border-zinc-200 dark:border-zinc-800",children:[n.jsxs("button",{onClick:()=>lt("cards"),className:"px-3 py-2 rounded-md text-sm font-medium transition-all flex items-center gap-2 "+("cards"===ot?"bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white shadow-sm":"text-zinc-500 hover:text-zinc-900 dark:hover:text-white"),children:[n.jsx(ne,{className:"w-4 h-4"}),n.jsx("span",{className:"hidden sm:inline",children:Lt("studio.viewCards")})]}),n.jsxs("button",{onClick:()=>lt("list"),className:"px-3 py-2 rounded-md text-sm font-medium transition-all flex items-center gap-2 "+("list"===ot?"bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white shadow-sm":"text-zinc-500 hover:text-zinc-900 dark:hover:text-white"),children:[n.jsx(se,{className:"w-4 h-4"}),n.jsx("span",{className:"hidden sm:inline",children:Lt("studio.listView")})]})]}),n.jsxs("div",{className:"relative",children:[n.jsxs("select",{id:"sort-by",name:"sort-by",value:it,onChange:e=>dt(e.target.value),className:"appearance-none ps-10 pe-10 py-3 bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded-xl text-sm font-medium text-zinc-900 dark:text-white hover:border-zinc-300 dark:hover:border-zinc-700 focus:ring-2 focus:ring-[#26C5F3]/20 focus:border-[#8f3589] outline-none transition-all cursor-pointer",children:[n.jsx("option",{value:"date-desc",children:Lt("studio.sortNewest")}),n.jsx("option",{value:"date-asc",children:Lt("studio.sortOldest")}),n.jsx("option",{value:"name-asc",children:Lt("studio.sortNameAsc")}),n.jsx("option",{value:"name-desc",children:Lt("studio.sortNameDesc")})]}),n.jsx(re,{className:"absolute start-3 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400 pointer-events-none"}),n.jsx("div",{className:"absolute end-3 top-1/2 -translate-y-1/2 pointer-events-none",children:n.jsx("svg",{className:"w-4 h-4 text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]})]}),"cards"===ot&&n.jsxs("div",{"data-tour":"dashboard-grid",className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:[an.map(e=>n.jsx(ce,{folder:e,projectCount:on(e.id),subFolderCount:Xe(e.id),onSelect:Ge,onRename:Xt,onDelete:Ht,selectionMode:Ze.selectionMode,isSelected:Ze.isSelected(e.id),onToggleSelect:Ze.toggleSelect,onContextMenu:Jt},e.id)),rn.map(e=>n.jsx(de,{project:e,iterationCount:Ye[e.id]??0,onSelect:y,onRename:Ut,onDelete:Bt,formatDate:cn,selectionMode:Ze.selectionMode,isSelected:Ze.isSelected(e.id),onToggleSelect:Ze.toggleSelect,onContextMenu:Gt},e.id))]}),"list"===ot&&n.jsxs("div",{className:"space-y-3",children:[an.map(e=>n.jsx(ue,{folder:e,projectCount:on(e.id),subFolderCount:Xe(e.id),onSelect:Ge,onRename:Xt,onDelete:Ht,selectionMode:Ze.selectionMode,isSelected:Ze.isSelected(e.id),onToggleSelect:Ze.toggleSelect,onContextMenu:Jt},e.id)),rn.map(e=>n.jsx(xe,{project:e,iterationCount:Ye[e.id]??0,onSelect:y,onRename:Ut,onDelete:Bt,formatDate:cn,selectionMode:Ze.selectionMode,isSelected:Ze.isSelected(e.id),onToggleSelect:Ze.toggleSelect,onContextMenu:Gt},e.id))]}),0===rn.length&&0===an.length&&n.jsx("div",{className:"mt-20 text-center space-y-4",children:n.jsx("p",{className:"text-zinc-400",children:Je.trim()?Lt("studio.noSearchMatch"):Lt(qe?"studio.folderEmptyDrag":"studio.noProjects")})})]})]}),n.jsx(M,{children:ln?n.jsx("div",{className:"opacity-50 rounded-3xl bg-white dark:bg-zinc-900 border-2 border-[#8f3589] p-6 shadow-2xl",children:n.jsx("h3",{className:"font-bold text-zinc-900 dark:text-white",children:ln.name})}):dn?n.jsxs("div",{className:"opacity-50 rounded-3xl bg-white dark:bg-zinc-900 border-2 border-indigo-500 p-6 shadow-2xl flex items-center gap-2",children:[n.jsx(A,{className:"w-5 h-5 text-indigo-500"}),n.jsx("h3",{className:"font-bold text-zinc-900 dark:text-white",children:dn.name})]}):null}),Ze.selectionMode&&n.jsx(ze,{selectedCount:Ze.selectedIds.size,selectedProjectCount:Ze.selectedProjects.length,selectedFolderCount:Ze.selectedFolders.length,onMoveTo:Qt,onDelete:en,onDuplicate:Ze.selectedProjects.length>0?tn:void 0,onClear:Ze.clearSelection}),At&&n.jsx(ye,{x:At.x,y:At.y,items:At.items,onClose:()=>Ot(null)}),n.jsx(pe,{isOpen:ut,onClose:()=>mt(!1),onCreate:_t}),n.jsx(be,{isOpen:!!bt,projectName:(null==bt?void 0:bt.name)||"",onClose:()=>ft(null),onRename:Yt}),n.jsx(je,{isOpen:ht,onClose:()=>pt(!1),onCreate:Zt,currentFolderId:qe,folders:Ae,maxDepthReached:mn}),n.jsx(ve,{isOpen:!!gt,folderName:(null==gt?void 0:gt.name)||"",folderColor:(null==gt?void 0:gt.color)||"#6366f1",folderIcon:null==gt?void 0:gt.icon,onClose:()=>jt(null),onRename:qt}),n.jsx(we,{isOpen:vt,onClose:()=>{wt(!1),St(null)},onMove:async e=>{Ct&&await Ct(e)},folders:Ae,disabledFolderIds:kt,itemLabel:zt}),n.jsx(ke,{isOpen:!!Ft,onClose:()=>It(null),onDelete:Vt,folderName:(null==Ft?void 0:Ft.name)||"",projectCount:Ft?Ue(Ft.id,me):0,subFolderCount:Ft?Xe(Ft.id):0}),n.jsx(z,{...Tt}),Dt&&n.jsx(Ce,{item:Dt,onClose:()=>Mt(null)})]})},(e,t)=>e.userId===t.userId&&e.userPlan===t.userPlan&&e.isAdmin===t.isAdmin&&e.unreadCount===t.unreadCount&&e.initialFolderId===t.initialFolderId);Fe.displayName="ProjectDashboard";export{Fe as ProjectDashboard};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.