PageSourceSearch

https://behindtheworkflow.ai/_next/static/chunks/27820.3756a019303b21b7.js

js behindtheworkflow.ai collected 2026-10-02 00:28:27 UTC 64,501 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[27820],{1375:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(71847).A)("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]])},17036:(e,t,r)=>{r.d(t,{n:()=>o});var l=r(96648),a=r(34773);let n=(0,a.h)("lib/workflow/delete-asset");async function o(e,t,r){let o=(0,l.createClient)();if(null==r?void 0:r.mediaPath){let{error:t}=await o.storage.from("media").remove([r.mediaPath]);t&&n.warn("delete asset storage cleanup failed",{event:"workflow.asset.delete",phase:"branch",branch:"storageRemove",assetId:e,error:(0,a.P5)(t)})}let{error:i}=await o.from("assets").delete().eq("id",e).eq("project_id",t);return i?{error:Error(i.message)}:{error:null}}},27820:(e,t,r)=>{r.r(t),r.d(t,{AssetFolderPanel:()=>ef});var l=r(95155),a=r(12115),n=r(99776),o=r(65820),i=r(27937),s=r(58734),d=r(59847),u=r(37772),c=r(89715),f=r(26754),p=r(1375),h=r(71360),m=r(22198),v=r(18514),x=r(4788),w=r(71847);let g=(0,w.A)("ChevronsDownUp",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]);var b=r(90368);let k=(0,w.A)("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);var y=r(6259),j=r(74719),C=r(51834),D=r(65142),N=r(76444),A=r(59135),_=r(34581),S=r(26497),R=r(3089),M=r(65229),E=r(3998),F=r(46767);
1function T(e){let{count:t,readOnly:r,onOpenMovePicker:a,onArchive:n,onDelete:o,onClear:i}=e;return(0,l.jsx)(S.N,{children:t>1?(0,l.jsxs)(R.P.div,{initial:{opacity:0,y:8,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.94},transition:{type:"spring",damping:26,stiffness:360,mass:.55},className:"pointer-events-auto inline-flex items-center gap-0.5 rounded-full border bg-card/95 py-1 pl-2 pr-1 shadow-[var(--elev-3)] backdrop-blur",role:"toolbar","aria-label":"".concat(t," items selected"),children:[(0,l.jsx)("span",{className:"select-none pr-1 text-[11px] font-semibold tabular-nums text-foreground",children:t}),(0,l.jsx)("span",{"aria-hidden":!0,className:"mr-0.5 h-4 w-px bg-border"}),(0,l.jsx)(F.Y6,{label:"Move the selected items into a folder.",children:(0,l.jsx)(E.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,disabled:r,"aria-label":"Move ".concat(t," items to a folder"),children:(0,l.jsx)(f.A,{className:"h-3.5 w-3.5","aria-hidden":!0})})}),(0,l.jsx)(F.Y6,{label:"Archive the selected items so they leave the canvas but can be brought back.",children:(0,l.jsx)(E.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:n,disabled:r,"aria-label":"Archive ".concat(t," items"),children:(0,l.jsx)(p.A,{className:"h-3.5 w-3.5","aria-hidden":!0})})}),(0,l.jsx)(F.Y6,{label:"Delete the selected items. The Backspace key does the same.",children:(0,l.jsx)(E.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:o,disabled:r,"aria-label":"Delete ".concat(t," items"),children:(0,l.jsx)(h.A,{className:"h-3.5 w-3.5","aria-hidden":!0})})}),(0,l.jsx)("span",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"}),(0,l.jsx)(F.Y6,{label:"Clear the selection. The Escape key does the same.",children:(0,l.jsx)(E.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:i,"aria-label":"Clear selection",children:(0,l.jsx)(M.A,{className:"h-3.5 w-3.5","aria-hidden":!0})})})]},"explorer-bulk-floater"):null})}var I=r(58702),L=r(82317),q=r(68378),O=r(64269);function Q(e){let{items:t,forbiddenTargetIds:r,folders:n,onPick:o,onClose:i}=e,[s,d]=(0,a.useState)(""),[u,c]=(0,a.useState)(0),p=(0,a.useRef)(null),h=(0,a.useMemo)(()=>[{id:null,path:"Unfiled"},...n.filter(e=>!r.has(e.id)).map(e=>({id:e.id,path:(0,q.hz)(e.id,n)})).sort((e,t)=>e.path.localeCompare(t.path,void 0,{sensitivity:"base"}))],[n,r]),m=(0,a.useMemo)(()=>{let e=s.trim().toLowerCase();return e?h.filter(t=>t.path.toLowerCase().includes(e)):h},[h,s]);(0,a.useEffect)(()=>{c(0)},[s]),(0,a.useEffect)(()=>{let e=p.current;if(!e)return;let t=e.querySelector('[data-active="true"]');null==t||t.scrollIntoView({block:"nearest"})},[u,m]);let v=t.length,x=e=>{o(e.id,t)};return(0,l.jsx)(C.lG,{open:!0,onOpenChange:e=>{e||i()},children:(0,l.jsxs)(C.Cf,{className:"gap-0 overflow-hidden p-0 sm:max-w-md",children:[(0,l.jsxs)(C.c7,{className:"px-4 pb-2 pt-4",children:[(0,l.jsxs)(C.L3,{children:["Move ",v," item",1===v?"":"s"," to…"]}),(0,l.jsx)(C.rr,{children:"Pick a destination folder, or file it under Unfiled."})]}),(0,l.jsx)("div",{className:"px-4 pb-2",children:(0,l.jsx)(D.p,{autoFocus:!0,value:s,onChange:e=>d(e.target.value),onKeyDown:e=>{if("ArrowDown"===e.key)e.preventDefault(),c(e=>Math.min(e+1,Math.max(m.length-1,0)));else if("ArrowUp"===e.key)e.preventDefault(),c(e=>Math.max(e-1,0));else if("Enter"===e.key){e.preventDefault();let t=m[u];t&&x(t)}},placeholder:"Search folders…",className:"h-9","aria-label":"Search destination folders"})}),(0,l.jsx)("div",{ref:p,className:"max-h-[320px] overflow-auto border-t border-border px-2 py-2",role:"listbox","aria-label":"Destination folders",children:0===m.length?(0,l.jsxs)("p",{className:"px-2 py-6 text-center text-[12px] text-muted-foreground",children:["No folders match “",s.trim(),"”."]}):m.map((e,t)=>{var r;let a=null===e.id,n=t===u;return(0,l.jsxs)("button",{type:"button",role:"option","aria-selected":n,"data-active":n?"true":void 0,onMouseMove:()=>c(t),onClick:()=>x(e),className:(0,O.cn)("flex w-full items-center gap-2 rounded-[8px] px-2 py-1.5 text-left text-[13px] transition-colors",n?"bg-accent text-foreground":"text-foreground"),children:[a?(0,l.jsx)(I.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}):(0,l.jsx)(f.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,l.jsx)("span",{className:(0,O.cn)("flex-1 truncate",a?"italic text-muted-foreground":"font-mono text-[11px]"),children:e.path}),n?(0,l.jsx)(L.A,{className:"h-3 w-3 shrink-0 text-muted-foreground","aria-hidden":!0}):null]},null!=(r=e.id)?r:"__unfiled__")})})]})})}var P=r(86655),z=r(96648),K=r(97850),U=r(20243),Y=r(11647),$=r(44540),B=r(69723),W=r(17036);let V="application/x-btw-wf-tree",X="application/x-btw-wf-folder",J="application/x-btw-wf-asset",G="__archived__";function H(e){let t=Array.from(e.dataTransfer.types);return t.includes(X)?"folder":t.includes("application/x-btw-wf-stack")?"stack":t.includes(J)?"asset":(t.includes(V),null)}function Z(e){try{let t=e.dataTransfer.getData(V)||e.dataTransfer.getData("text/plain");if(!t)return null;let r=JSON.parse(t);if(("asset"===r.kind||"folder"===r.kind||"stack"===r.kind)&&r.id){let e=Array.isArray(r.bulk)?r.bulk.filter(e=>"string"==typeof(null==e?void 0:e.id)&&("asset"===e.kind||"folder"===e.kind||"stack"===e.kind)).map(e=>({id:e.id,kind:e.kind})):void 0;return e&&e.length>1?{kind:r.kind,id:r.id,bulk:e}:{kind:r.kind,id:r.id}}}catch(e){}return null}function ee(e,t){if("undefined"!=typeof document)try{let r=document.createElement("div");r.textContent="".concat(t," item").concat(1===t?"":"s"),r.style.cssText="position:fixed;top:-1000px;left:-1000px;padding:3px 9px;border-radius:9999px;font-size:11px;font-weight:600;line-height:1.4;color:#fff;background:var(--app-accent);box-shadow:0 6px 16px -4px rgba(0,0,0,0.45);white-space:nowrap;pointer-events:none;z-index:2147483647;",document.body.appendChild(r),e.dataTransfer.setDragImage(r,10,10),window.setTimeout(()=>r.remove(),0)}catch(e){}}function et(e,t,r,l){let a=e.find(e=>e.id===t);if(!a)return e;let n=e.filter(e=>e.id!==t),o=n.filter(e=>{var t;return(null!=(t=e.parent_id)?t:null)===r}).sort((e,t)=>
1{var r,l;let a=e.sort_order-t.sort_order;return 0!==a?a:(null!=(r=e.name)?r:"").localeCompare(null!=(l=t.name)?l:"",void 0,{sensitivity:"base"})}),i=Math.max(0,Math.min(l,o.length)),s=[...o.slice(0,i),{...a,parent_id:r},...o.slice(i)].map((e,t)=>({...e,parent_id:r,sort_order:t}));return function(e){var t;let r=new Set;for(let l of e)r.add(null!=(t=l.parent_id)?t:null);let l=e.map(e=>({...e})),a=new Map(l.map(e=>[e.id,e]));for(let e of r)l.filter(t=>{var r;return(null!=(r=t.parent_id)?r:null)===e}).sort((e,t)=>{var r,l;let a=e.sort_order-t.sort_order;return 0!==a?a:(null!=(r=e.name)?r:"").localeCompare(null!=(l=t.name)?l:"",void 0,{sensitivity:"base"})}).forEach((e,t)=>{let r=a.get(e.id);r&&(r.sort_order=t)});return l}([...n.filter(e=>{var t;return(null!=(t=e.parent_id)?t:null)!==r}),...s])}function er(e){let{parentId:t,insertIndex:r,depth:a,readOnly:n,onDropFolderReorder:o}=e;return n?null:(0,l.jsx)("div",{role:"separator","aria-orientation":"horizontal",className:"wf-sib-zone relative h-px shrink-0",onDragEnter:e=>{"folder"===H(e)&&e.preventDefault()},onDragOver:e=>{"folder"===H(e)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",e.currentTarget.dataset.over="1")},onDragLeave:e=>{e.currentTarget.dataset.over="0"},onDrop:e=>{e.currentTarget.dataset.over="0";let l=Z(e);e.preventDefault(),(null==l?void 0:l.kind)==="folder"&&o(l.id,r,t)},children:(0,l.jsx)("span",{"aria-hidden":!0,className:"wf-sib-line pointer-events-none absolute top-1/2 h-0.5 -translate-y-1/2 rounded-full bg-[var(--app-accent)]",style:{left:el(a),right:4}})})}function el(e){return 4+12*e}let ea=[];function en(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function eo(e){let{ancestorIds:t}=e;return 0===t.length?null:(0,l.jsx)(l.Fragment,{children:t.map((e,t)=>(0,l.jsx)("span",{"aria-hidden":!0,"data-guide-folder":e,className:"wf-indent-guide pointer-events-none absolute inset-y-0 w-px",style:{left:4+12*t+7}},t))})}function ei(e){try{let t=window.localStorage.getItem((0,P.fo)(e));if(!t)return new Set;let r=JSON.parse(t);if(Array.isArray(r))return new Set(r.filter(e=>"string"==typeof e))}catch(e){}return new Set}let es=(0,a.memo)(function e(t){var r,n;let{parentId:o,grouped:c,assetsByFolder:f,depth:p,expanded:h,toggle:m,readOnly:v,onMoveAsset:x,onDeleteAsset:w,selectedFolderFilter:g,onDropAssetOnFolder:b,onDropFolderOnFolder:k,onDropStackOnFolder:y,onDropFolderReorder:j,onScheduleAutoExpand:C,onCancelAutoExpand:D,creatingParentId:N,creatingDraft:A,onCreatingDraftChange:_,onCreatingCommit:S,onCreatingCancel:R,onRequestDeleteFolder:M,onRequestDeleteAsset:E,onArchiveAsset:T,renaming:I,renameDraft:L,onStartRename:q,onRenameDraftChange:Q,onRenameCommit:P,onRenameCancel:z,onRequestNewSubfolder:K,activeId:U,ancestorIds:Y,childChainByFolder:$,selectedIds:B,multiDragIds:W,onRowSelect:J,onRowContextMenu:G,onBulkDrop:et,onOpenFolder:en,onOpenAsset:ei}=t,es=null!=(r=c.get(o))?r:[],ec=null===o&&null!=(n=f.get(null))?n:[],ef=(null==I?void 0:I.kind)==="asset"?I.id:null;return(0,l.jsxs)("div",{role:null===o?"tree":"group","aria-label":null===o?"Folders":void 0,children:[null===o&&0===ec.length&&0===es.length?(0,l.jsx)("p",{className:"px-2 py-6 text-center text-[11px] leading-relaxed text-muted-foreground",children:"No folders yet. Create one to organize assets, or leave assets unfiled."}):null,es.map((t,r)=>{var n,es;let ed=h.has(t.id),ec=null!=(n=f.get(t.id))?n:[],ep=g===t.id,eh=el(p),em=!!(null==B?void 0:B.has(t.id)),ev=U===t.id,ex=(null==I?void 0:I.kind)==="folder"&&I.id===t.id;return(0,l.jsxs)(a.Fragment,{children:[(0,l.jsx)(er,{parentId:o,insertIndex:r,depth:p,readOnly:v,onDropFolderReorder:j}),(0,l.jsxs)("div",{role:"treeitem","aria-expanded":ed,"aria-selected":em,"data-explorer-selected":em?"1":void 0,"data-workflow-folder-drop":t.id,"data-row-id":t.id,"data-explain-title":"Folder","data-explain-hint":"Single-click to select. Double-click or press Enter to open this folder on the canvas. Use F2 to rename.","data-explain-shortcut":"Double-click open \xb7 F2 rename","data-explain-skill":"daily.folders-vs-stacks",draggable:!v,onDragStart:e=>{if(v)return;let r=W&&W.length>1&&W.some(e=>e.id===t.id),l=JSON.stringify(r?{kind:"folder",id:t.id,bulk:W}:{kind:"folder",id:t.id});e.dataTransfer.setData(V,l),e.dataTransfer.setData("text/plain",l),e.dataTransfer.setData(X,"1"),e.dataTransfer.effectAllowed="move",ee(e,r&&W?W.length:1)},onDragEnter:e=>{let t=H(e);("folder"===t||"asset"===t||"stack"===t)&&e.preventDefault()},onDragOver:e=>{let r=H(e);("folder"===r||"asset"===r||"stack"===r)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",e.currentTarget.setAttribute("data-workflow-folder-drop-over","1"),ed||C(t.id))},onDragLeave:e=>{e.currentTarget.removeAttribute("data-workflow-folder-drop-over"),D(t.id)},onDrop:e=>{e.currentTarget.removeAttribute("data-workflow-folder-drop-over"),D(t.id);let r=Z(e);if(e.preventDefault(),r){if(r.bulk&&et)return void et(t.id,r.bulk);"asset"===r.kind?b(r.id,t.id):"folder"===r.kind&&r.id!==t.id?k(r.id,t.id):"stack"===r.kind&&y(r.id,t.id)}},onClick:e=>{null==J||J({id:t.id,kind:"folder"},{meta:e.metaKey||e.ctrlKey,shift:e.shiftKey}),e.metaKey||e.ctrlKey||e.shiftKey||ex||en(t.id)},onContextMenu:e=>
1{G&&(e.preventDefault(),e.stopPropagation(),G({id:t.id,kind:"folder"},e))},onDoubleClick:e=>{e.stopPropagation(),e.preventDefault(),en(t.id)},tabIndex:ev?0:-1,className:(0,O.cn)("group/row relative flex h-7 select-none items-center gap-1 pr-1 text-[13px] leading-none text-[var(--shell-text)] outline-none transition-colors",v||ex?"cursor-default":"cursor-grab active:cursor-grabbing","hover:bg-[var(--shell-hover)]","focus-visible:shadow-[inset_0_0_0_1px_var(--app-accent-ring)]",em&&"bg-[var(--shell-active)] text-[var(--shell-text)]"),style:{paddingLeft:eh,contentVisibility:"auto",containIntrinsicSize:"28px"},children:[(0,l.jsx)(eo,{ancestorIds:Y}),ep?(0,l.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute left-0 top-1/2 h-3.5 w-0.5 -translate-y-1/2 rounded-full bg-[var(--app-accent)]"}):null,(0,l.jsx)("button",{type:"button",tabIndex:-1,"aria-label":ed?"Collapse":"Expand",onClick:e=>{e.stopPropagation(),m(t.id)},className:"flex h-4 w-4 shrink-0 items-center justify-center text-[var(--shell-text-muted)]",children:(0,l.jsx)(i.A,{className:(0,O.cn)("h-3 w-3 transition-transform duration-100",ed&&"rotate-90"),"aria-hidden":!0})}),ep||ed?(0,l.jsx)(s.A,{className:(0,O.cn)("h-[14px] w-[14px] shrink-0",ep?"text-[var(--app-accent)]":"text-[var(--shell-text-muted)]"),"aria-hidden":!0}):(0,l.jsx)(d.A,{className:"h-[14px] w-[14px] shrink-0 text-[var(--shell-text-muted)]","aria-hidden":!0}),ex?(0,l.jsx)("input",{type:"text",value:L,autoFocus:!0,onChange:e=>Q(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),P()),"Escape"===e.key&&(e.preventDefault(),z())},onBlur:P,onClick:e=>e.stopPropagation(),onFocus:e=>{let t=e.currentTarget.value;e.currentTarget.setSelectionRange(0,t.length)},className:"min-w-0 flex-1 truncate rounded border border-[var(--app-accent)] bg-[var(--shell-bg)] px-1 py-0 text-[13px] leading-none text-[var(--shell-text)] outline-none focus:border-[var(--app-accent)]","aria-label":"Folder name"}):(0,l.jsx)("span",{className:"min-w-0 flex-1 truncate",title:t.name.trim()||"Untitled folder",children:t.name.trim()||"Untitled folder"}),v||ex?null:(0,l.jsx)(F.Y6,{label:"Open the actions for this folder, such as new subfolder, rename, move and delete.",children:(0,l.jsx)("button",{type:"button",tabIndex:-1,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-[var(--shell-text-subtle)] opacity-0 transition-opacity duration-[var(--dur-quick)] hover:bg-[var(--shell-active)] hover:text-[var(--shell-text)] pointer-events-none group-hover/row:pointer-events-auto group-hover/row:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100","aria-label":"Folder actions",onClick:e=>{e.stopPropagation(),null==G||G({id:t.id,kind:"folder"},e)},children:(0,l.jsx)(u.A,{className:"h-3 w-3","aria-hidden":!0})})})]}),ed?(0,l.jsxs)(l.Fragment,{children:[ec.map(e=>{var r;return(0,l.jsx)(eu,{asset:e,depth:p+1,readOnly:v,onRequestDeleteAsset:E,onArchiveAsset:T,parentFolderId:t.id,onDropAssetOnFolder:(e,t)=>{t?b(e,t):x(e,null)},selected:!!(null==B?void 0:B.has(e.id)),active:U===e.id,ancestorIds:null!=(r=$.get(t.id))?r:ea,multiDragIds:W,onRowSelect:J,onRowContextMenu:G,onBulkDrop:et,onOpenAsset:ei,renamingId:ef,renameDraft:L,onRenameDraftChange:Q,onRenameCommit:P,onRenameCancel:z},e.id)}),(0,l.jsx)(e,{parentId:t.id,grouped:c,assetsByFolder:f,depth:p+1,expanded:h,toggle:m,readOnly:v,onMoveAsset:x,onDeleteAsset:w,selectedFolderFilter:g,onDropAssetOnFolder:b,onDropFolderOnFolder:k,onDropStackOnFolder:y,onDropFolderReorder:j,onScheduleAutoExpand:C,onCancelAutoExpand:D,creatingParentId:N,creatingDraft:A,onCreatingDraftChange:_,onCreatingCommit:S,onCreatingCancel:R,onRequestDeleteFolder:M,onRequestDeleteAsset:E,onArchiveAsset:T,renaming:I,renameDraft:L,onStartRename:q,onRenameDraftChange:Q,onRenameCommit:P,onRenameCancel:z,onRequestNewSubfolder:K,activeId:U,ancestorIds:null!=(es=$.get(t.id))?es:ea,childChainByFolder:$,selectedIds:B,multiDragIds:W,onRowSelect:J,onRowContextMenu:G,onBulkDrop:et,onOpenFolder:en,onOpenAsset:ei})]}):null]},t.id)}
1),(0,l.jsx)(er,{parentId:o,insertIndex:es.length,depth:p,readOnly:v,onDropFolderReorder:j}),N===o?(0,l.jsx)(ed,{depth:p,value:A,onChange:_,onCommit:S,onCancel:R}):null,null===o&&ec.length>0?(0,l.jsx)(l.Fragment,{children:ec.map(e=>(0,l.jsx)(eu,{asset:e,depth:0,readOnly:v,onRequestDeleteAsset:E,onArchiveAsset:T,parentFolderId:null,onDropAssetOnFolder:(e,t)=>{t?b(e,t):x(e,null)},selected:!!(null==B?void 0:B.has(e.id)),active:U===e.id,ancestorIds:ea,multiDragIds:W,onRowSelect:J,onRowContextMenu:G,onBulkDrop:et,onOpenAsset:ei,renamingId:ef,renameDraft:L,onRenameDraftChange:Q,onRenameCommit:P,onRenameCancel:z},e.id))}):null]})});function ed(e){let{depth:t,value:r,onChange:n,onCommit:o,onCancel:i}=e,s=(0,a.useRef)(null);(0,a.useEffect)(()=>{var e,t;null==(e=s.current)||e.focus(),null==(t=s.current)||t.select()},[]);let u=el(t);return(0,l.jsxs)("div",{className:"flex h-7 items-center gap-1 pr-1 text-[13px] leading-none text-[var(--shell-text)]",style:{paddingLeft:u},children:[(0,l.jsx)("span",{className:"h-4 w-4 shrink-0","aria-hidden":!0}),(0,l.jsx)(d.A,{className:"h-[14px] w-[14px] shrink-0 text-[var(--shell-text-muted)]","aria-hidden":!0}),(0,l.jsx)("input",{ref:s,type:"text",value:r,onChange:e=>n(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),o()):"Escape"===e.key&&(e.preventDefault(),i())},onBlur:()=>{r.trim()?o():i()},placeholder:"untitled folder",spellCheck:!1,className:"min-w-0 flex-1 truncate rounded-sm border border-[var(--app-accent-ring)] bg-[var(--shell-bg)] px-1 text-[13px] leading-none text-[var(--shell-text)] outline-none focus:ring-1 focus:ring-[var(--app-accent-ring)]"})]})}let eu=(0,a.memo)(function(e){var t,r;let{asset:a,depth:n,readOnly:o,onRequestDeleteAsset:i,onArchiveAsset:s,parentFolderId:d,onDropAssetOnFolder:f,selected:p,active:h,ancestorIds:m,multiDragIds:v,onRowSelect:x,onRowContextMenu:w,onBulkDrop:g,renamingId:b,renameDraft:k,onRenameDraftChange:y,onRenameCommit:j,onRenameCancel:C,onOpenAsset:D}=e,N=(null!=(t=a.name)?t:"").trim()||(null!=(r=a.prompt)?r:"").trim().slice(0,48)||"Untitled asset",A=!!b&&b===a.id,_=el(n)+16,S=void 0===d?void 0:null===d?"__unfiled__":d;return(0,l.jsxs)("div",{role:"treeitem","aria-selected":!!p,"data-explorer-selected":p?"1":void 0,"data-row-id":a.id,draggable:!o&&!A,...void 0!==S?{"data-workflow-folder-drop":S}:{},onClick:e=>{null==x||x({id:a.id,kind:"asset"},{meta:e.metaKey||e.ctrlKey,shift:e.shiftKey})},onDoubleClick:e=>{A||(e.preventDefault(),e.stopPropagation(),null==D||D(a.id))},onContextMenu:e=>{w&&(e.preventDefault(),e.stopPropagation(),w({id:a.id,kind:"asset"},e))},onDragStart:e=>{if(o)return;let t=v&&v.length>1&&v.some(e=>e.id===a.id),r=JSON.stringify(t?{kind:"asset",id:a.id,bulk:v}:{kind:"asset",id:a.id});e.dataTransfer.setData(V,r),e.dataTransfer.setData("text/plain",r),e.dataTransfer.setData(J,"1"),e.dataTransfer.effectAllowed="move",ee(e,t&&v?v.length:1)},onDragEnter:e=>{!o&&f&&"asset"===H(e)&&e.preventDefault()},onDragOver:e=>{!o&&f&&"asset"===H(e)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",e.currentTarget.setAttribute("data-workflow-folder-drop-over","1"))},onDragLeave:e=>{e.currentTarget.removeAttribute("data-workflow-folder-drop-over")},onDrop:e=>{if(e.currentTarget.removeAttribute("data-workflow-folder-drop-over"),o||!f)return;let t=Z(e);if(e.preventDefault(),t){if(t.bulk&&g)return void g(null!=d?d:null,t.bulk);"asset"===t.kind&&t.id!==a.id&&f(t.id,null!=d?d:null)}},tabIndex:h?0:-1,className:(0,O.cn)("group/asset relative flex h-7 cursor-grab select-none items-center gap-1 pr-1 text-[13px] leading-none text-[var(--shell-text-muted)] outline-none transition-colors active:cursor-grabbing","hover:bg-[var(--shell-hover)]","focus-visible:shadow-[inset_0_0_0_1px_var(--app-accent-ring)]",p&&"bg-[var(--shell-active)] text-[var(--shell-text)]"),style:{paddingLeft:_,contentVisibility:"auto",containIntrinsicSize:"28px"},children:[(0,l.jsx)(eo,{ancestorIds:m}),(0,l.jsx)(c.A,{className:"h-[14px] w-[14px] shrink-0 text-[var(--shell-text-subtle)]","aria-hidden":!0}),A?(0,l.jsx)("input",{type:"text",value:null!=k?k:"",autoFocus:!0,onChange:e=>null==y?void 0:y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),null==j||j()),"Escape"===e.key&&(e.preventDefault(),null==C||C())},onBlur:()=>null==j?void 0:j(),onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onFocus:e=>{let t=e.currentTarget.value;e.currentTarget.setSelectionRange(0,t.length)},className:"min-w-0 flex-1 truncate rounded border border-[var(--app-accent)] bg-[var(--shell-bg)] px-1 py-0 text-[13px] leading-none text-[var(--shell-text)] outline-none focus:border-[var(--app-accent)]","aria-label":"Asset name"}):(0,l.jsx)("span",{className:"min-w-0 flex-1 truncate",title:N,children:N}),o||A||!w?null:(0,l.jsx)(F.Y6,{label:"Open the actions for this asset, such as open, rename, move, archive and delete.",children:(0,l.jsx)("button",{type:"button",tabIndex:-1,
1className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-[var(--shell-text-subtle)] opacity-0 transition-opacity duration-[var(--dur-quick)] hover:bg-[var(--shell-active)] hover:text-[var(--shell-text)] pointer-events-none group-hover/asset:pointer-events-auto group-hover/asset:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100","aria-label":"Asset actions",onClick:e=>{e.stopPropagation(),w({id:a.id,kind:"asset"},e)},children:(0,l.jsx)(u.A,{className:"h-3 w-3","aria-hidden":!0})})})]})});function ec(e,t){var r,l,a;let n=new Map;for(let e of t){let t=null!=(r=e.parent_id)?r:null,a=null!=(l=n.get(t))?l:[];a.push(e),n.set(t,a)}let o=new Set,i=[e];for(;i.length;){let e=i.pop();if(!o.has(e))for(let t of(o.add(e),null!=(a=n.get(e))?a:[]))i.push(t.id)}return o}function ef(e){var t,r,i;let{projectId:d,folders:u,assets:w,readOnly:S,onStructureChanged:R,className:M,selectedFolderFilter:I,onSelectedFolderFilterChange:L,onOpenAsset:X,loading:J,folderDiskHydration:ee}=e,er=(0,n.jE)(),{data:el}=(0,K.i)(),[eo,ed]=(0,a.useState)(()=>ei(d)),eu=(0,a.useRef)(d);(0,a.useEffect)(()=>
1{eu.current!==d&&(eu.current=d,ed(ei(d)))},[d]);let ef=(0,a.useCallback)(e=>{ed(t=>{let r=e(t);if(r===t)return t;try{window.localStorage.setItem((0,P.fo)(d),JSON.stringify(Array.from(r)))}catch(e){}return r})},[d]),[ep,eh]=(0,a.useState)(()=>new Map),em=(0,a.useRef)(null),ev=(0,a.useRef)(null),ex=(0,a.useRef)({buffer:"",at:0}),ew=(0,a.useCallback)(()=>{eh(e=>0===e.size?e:new Map),em.current=null},[]);(0,a.useEffect)(()=>{eh(e=>{if(0===e.size)return e;let t=new Set(u.map(e=>e.id)),r=new Set(w.map(e=>e.id)),l=!1,a=new Map(e);for(let[n,o]of e)("asset"===o?r.has(n):t.has(n))||(a.delete(n),l=!0);return l?a:e})},[u,w]);let[eg,eb]=(0,a.useState)(void 0),[ek,ey]=(0,a.useState)(""),[ej,eC]=(0,a.useState)(!1),[eD,eN]=(0,a.useState)(null),[eA,e_]=(0,a.useState)(""),[eS,eR]=(0,a.useState)(null),[eM,eE]=(0,a.useState)(null),[eF,eT]=(0,a.useState)(""),eI=(0,a.useRef)(""),[eL,eq]=(0,a.useState)(null),[eO,eQ]=(0,a.useState)(!1),eP=(0,$.mM)(),ez=(0,a.useMemo)(()=>{let e=new Set;for(let r of w){var t;let l=null!=(t=r.deck_id)?t:null;l&&e.add(l)}return e},[w]),eK=(0,a.useMemo)(()=>u.filter(e=>!ez.has(e.id)),[u,ez]),eU=eL&&null!=(t=eL.split(/[\\/]/).filter(Boolean).pop())?t:null,eY=(0,a.useMemo)(()=>(0,q.dP)(eK),[eK]),e$=(0,a.useMemo)(()=>{let e=new Map;
1for(let t of eK)e.set(t.id,t);return e},[eK]),eB=(0,a.useMemo)(()=>{let e=new Map;for(let t of w)e.set(t.id,t);return e},[w]),eW=(0,a.useMemo)(()=>{let e=new Map,t=r=>{var l;let a=e.get(r);if(a)return a;let n=e$.get(r),o=null!=(l=null==n?void 0:n.parent_id)?l:null,i=o&&e$.has(o)?[...t(o),r]:[r];return e.set(r,i),i};for(let e of eK)t(e.id);return e},[eK,e$]),eV=(0,a.useMemo)(()=>{let e=new Map;for(let l of w){var t,r;let a=null!=(t=l.folder_id)?t:null,n=a&&ez.has(a)?null:a,o=null!=(r=e.get(n))?r:[];o.push(l),e.set(n,o)}return e},[w,ez]),eX=(0,a.useCallback)(e=>{ef(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[ef]),eJ=(0,a.useCallback)(e=>{L(e),ef(t=>{if(t.has(e))return t;let r=new Set(t);return r.add(e),r})},[L,ef]),eG=(0,a.useCallback)(e=>{ew(),L(e)},[ew,L]),eH=(0,a.useCallback)(()=>{ef(e=>0===e.size?e:new Set)},[ef]),eZ=(0,a.useMemo)(()=>(function(e){var t;let{grouped:r,assetsByFolder:l,expanded:a}=e,n=[];for(let e of(!function e(t){var o,i;for(let s of null!=(o=r.get(t))?o:[])if(n.push({id:s.id,kind:"folder"}),a.has(s.id)){for(let e of null!=(i=l.get(s.id))?i:[])n.push({id:e.id,kind:"asset"});e(s.id)}}(null),null!=(t=l.get(null))?t:[]))n.push({id:e.id,kind:"asset"});return n})({grouped:eY,assetsByFolder:eV,expanded:eo}),[eY,eV,eo]),[e0,e1]=(0,a.useState)(null);(0,a.useEffect)(()=>{e1(e=>{var t,r;return e&&eZ.some(t=>t.id===e)?e:null!=(r=null==(t=eZ[0])?void 0:t.id)?r:null})},[eZ]);let e2=(0,a.useCallback)((e,t)=>{if(e1(e.id),t.meta){eh(t=>{let r=new Map(t);return r.has(e.id)?r.delete(e.id):r.set(e.id,e.kind),r}),em.current=e;return}if(t.shift){let t=em.current,r=t?eZ.findIndex(e=>e.id===t.id):-1,l=eZ.findIndex(t=>t.id===e.id);if(-1===r||-1===l){eh(new Map([[e.id,e.kind]])),em.current=e;return}let[a,n]=r<=l?[r,l]:[l,r],o=new Map;for(let e=a;e<=n;e++){let t=eZ[e];o.set(t.id,t.kind)}eh(o);return}eh(new Map([[e.id,e.kind]])),em.current=e},[eZ]),[e5,e3]=(0,a.useState)(!1);(0,a.useEffect)(()=>{function e(e){e.dataTransfer&&Array.from(e.dataTransfer.types).includes(V)&&e3(!0)}function t(){e3(!1)}return window.addEventListener("dragstart",e),window.addEventListener("dragend",t),window.addEventListener("drop",t),()=>{window.removeEventListener("dragstart",e),window.removeEventListener("dragend",t),window.removeEventListener("drop",t)}},[]);let e4=(0,a.useRef)(null),e6=(0,a.useCallback)(e=>{var t;if((null==(t=e4.current)?void 0:t.folderId)===e)return;e4.current&&(window.clearTimeout(e4.current.timer),e4.current=null);let r=window.setTimeout(()=>{e4.current=null,ef(t=>{if(t.has(e))return t;let r=new Set(t);return r.add(e),r})},450);e4.current={folderId:e,timer:r}},[ef]),e7=(0,a.useCallback)(e=>{var t;(null==(t=e4.current)?void 0:t.folderId)===e&&(window.clearTimeout(e4.current.timer),e4.current=null)},[]);(0,a.useEffect)(()=>()=>{e4.current&&window.clearTimeout(e4.current.timer)},[]);let e8=(0,a.useCallback)(e=>{er.setQueryData(["workflow",d],t=>t?e(t):t)},[d,er]),e9=(0,a.useCallback)(async()=>{if(!(0,$.mM)())return void eq(null);eq(await window.btwDesktop.getLinkedLocalProjectFolder(d))},[d]),te=(0,a.useCallback)(async()=>{if(S)return void o.oR.error("You cannot change the linked folder in read-only mode.");if((0,$.mM)()){eQ(!0);try{let e=await window.btwDesktop.selectLocalProjectFolder();if(e.canceled||!("path"in e))return;await window.btwDesktop.setLinkedLocalProjectFolder(d,e.path),await e9()}finally{eQ(!1)}}},[d,S,e9]),tt=(0,a.useCallback)(async()=>{if((0,$.mM)()){eQ(!0);try{let t=await window.btwDesktop.exportWorkflowFoldersToLinkedRoot(d,u.map(e=>({id:e.id,name:e.name,parent_id:e.parent_id})));if(!t.ok){var e;o.oR.error(null!=(e=t.error)?e:"Export failed.");return}o.oR.success(t.manifestPath?"Folder tree written under your linked directory. Manifest: ".concat(t.manifestPath):"Folder tree written under your linked directory.")}finally{eQ(!1)}}},[u,d]),tr=(0,a.useCallback)(async()=>{if((0,$.mM)()){eQ(!0);try{var e;let t=await window.btwDesktop.revealLinkedLocalProjectFolder(d);t.ok||o.oR.error(null!=(e=t.error)?e:"Could not reveal folder.")}finally{eQ(!1)}}},[d]),tl=(0,a.useCallback)(async()=>{if((0,$.mM)()&&confirm("Remove the linked disk folder for this project? The workspace folder tree is unchanged.")){eQ(!0);try{await window.btwDesktop.clearLinkedLocalProjectFolder(d),await e9()}finally{eQ(!1)}}},[d,e9]);(0,a.useEffect)(()=>{e9()},[e9]),(0,a.useEffect)(()=>{var e;if((0,$.mM)()&&(null==(e=window.btwDesktop)?void 0:e.onMenuLinkLocalProjectFolder))return window.btwDesktop.onMenuLinkLocalProjectFolder(()=>{te()})},[te]);let ta=(0,a.useCallback)(async(e,t)=>{var r;let l=new Map(e.map(e=>[e.id,e])),a=t.filter(e=>{let t=l.get(e.id);return!t||t.parent_id!==e.parent_id||t.sort_order!==e.sort_order});if(!a.length)return;let n=(0,z.createClient)(),o=null==(r=(await Promise.all(a.map(e=>n.from("asset_folders").update({parent_id:e.parent_id,sort_order:e.sort_order}).eq("id",e.id).eq("project_id",d)))).find(e=>e.error))?void 0:r.error;if(o)throw o},[d]),tn=(0,a.useCallback)(async(e,t,r)=>{var l;let a=er.getQueryData(["workflow",d]),n=null!=(l=null==a?void 0:a.folders)?l:u,i=et(n,e,r,t);e8(e=>({...e,folders:i}));try{await ta(n,i),R()}catch(e){a?er.setQueryData(["workflow",d],a):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Could not reorder folders. Try again.")}},[u,e8,ta,d,er,R]),to=(0,a.useCallback)(async(e,t)=>{var r,l,a,n,i;if(e===t)return;let s=er.getQueryData(["workflow",d]),c=null!=(n=null==s?void 0:s.folders)?n:u;if((0,B.hl)(e,t,c))return void o.oR.error("A folder can't be moved into itself or one of its subfolders.");let f=c.find(t=>
1t.id===e);if(f&&(null!=(i=f.parent_id)?i:null)===t)return;let p=(null==f||null==(r=f.name)?void 0:r.trim())||"Folder",h=(null==(a=c.find(e=>e.id===t))||null==(l=a.name)?void 0:l.trim())||"Folder",m=c.filter(r=>{var l;return(null!=(l=r.parent_id)?l:null)===t&&r.id!==e}).length,v=et(c,e,t,m);e8(e=>({...e,folders:v}));try{await ta(c,v),R(),o.oR.success("“".concat(p,"” → “").concat(h,"”"))}catch(e){s?er.setQueryData(["workflow",d],s):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Couldn't move the folder.")}},[u,e8,ta,d,er,R]),ti=(0,a.useCallback)(async(e,t)=>{var r,l,a,n,i,s,c;let f=er.getQueryData(["workflow",d]),p=null!=(a=null==f?void 0:f.assets)?a:w,h=p.find(t=>t.id===e);if(h&&(null!=(n=h.folder_id)?n:null)===t)return;let m=(null==(l=(null!=(i=null==f?void 0:f.folders)?i:u).find(e=>e.id===t))||null==(r=l.name)?void 0:r.trim())||"Folder",v=(null!=(s=null==h?void 0:h.name)?s:"").trim()||(null!=(c=null==h?void 0:h.prompt)?c:"").trim().slice(0,32)||"Asset",x=p.map(r=>r.id===e?{...r,folder_id:t}:r);e8(e=>({...e,assets:x}));try{let r=(0,z.createClient)(),{error:l}=await r.from("assets").update({folder_id:t}).eq("id",e).eq("project_id",d);if(l)throw l;R(),o.oR.success("“".concat(v,"” → “").concat(m,"”"))}catch(e){f?er.setQueryData(["workflow",d],f):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Couldn't move the asset.")}},[w,u,e8,d,er,R]),ts=(0,a.useCallback)(async(e,t)=>{},[]),td=(0,a.useCallback)(async(e,t)=>{var r,l,a;let n=(0,z.createClient)();if("__delete_folder__"===e&&t){let e=er.getQueryData(["workflow",d]),a=(null!=(r=null==e?void 0:e.folders)?r:u).filter(e=>e.id!==t),i=(null!=(l=null==e?void 0:e.assets)?l:w).map(e=>e.folder_id===t?{...e,folder_id:null}:e);e8(e=>({...e,folders:a,assets:i}));try{let{error:e}=await n.from("asset_folders").delete().eq("id",t);if(e)throw e;R()}catch(t){e?er.setQueryData(["workflow",d],e):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Could not delete folder.")}return}let i=er.getQueryData(["workflow",d]),s=(null!=(a=null==i?void 0:i.assets)?a:w).map(r=>r.id===e?{...r,folder_id:t}:r);e8(e=>({...e,assets:s}));try{let{error:r}=await n.from("assets").update({folder_id:t}).eq("id",e).eq("project_id",d);if(r)throw r;R()}catch(e){i?er.setQueryData(["workflow",d],i):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Could not move asset.")}},[w,u,R,e8,d,er]),tu=(0,a.useCallback)(async e=>{var t,r,l;let a=er.getQueryData(["workflow",d]),n=(null!=(t=null==a?void 0:a.assets)?t:w).find(t=>t.id===e),i=(null!=(r=null==a?void 0:a.assets)?r:w).filter(t=>t.id!==e);e8(e=>({...e,assets:i}));try{let{error:t}=await (0,W.n)(e,d,{mediaPath:null!=(l=null==n?void 0:n.media_path)?l:null});if(t)throw t;R()}catch(e){a?er.setQueryData(["workflow",d],a):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Could not delete asset. Try again.")}},[w,R,e8,d,er]),tc=(0,a.useCallback)(async e=>{var t;let r=er.getQueryData(["workflow",d]),l=(null!=(t=null==r?void 0:r.assets)?t:w).filter(t=>t.id!==e);e8(e=>({...e,assets:l}));try{let t=(0,z.createClient)(),{error:r}=await t.from("assets").update({archived_at:new Date().toISOString()}).eq("id",e).eq("project_id",d);if(r)throw r;R()}catch(e){r?er.setQueryData(["workflow",d],r):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Could not archive asset. Try again.")}},[w,R,e8,d,er]),tf=(0,a.useCallback)(async(e,t)=>{var r,l,a,n,i;if(S)return;let s=null!=t?t:Array.from(ep.entries()).map(e=>{let[t,r]=e;return{id:t,kind:r}});if(0===s.length)return;let c=s.filter(e=>"folder"===e.kind||"stack"===e.kind).map(e=>e.id),f=s.filter(e=>"asset"===e.kind).map(e=>e.id);for(let t of c){if(e===t)return void o.oR.error("A folder can't be moved into itself.");if(e&&(0,B.hl)(t,e,u))return void o.oR.error("A folder can't be moved into one of its subfolders.")}let p=er.getQueryData(["workflow",d]),h=null!=(r=null==p?void 0:p.folders)?r:u,m=null!=(l=null==p?void 0:p.assets)?l:w,v=new Set(c),x=new Set(f),g=c.length>0?h.map(t=>v.has(t.id)?{...t,parent_id:e}:t):h,b=f.length>0?m.map(t=>x.has(t.id)?{...t,folder_id:e}:t):m;e8(e=>({...e,folders:g,assets:b}));try{let t=(0,z.createClient)(),r=[];c.length>0&&r.push((async()=>{let{error:r}=await t.from("asset_folders").update({parent_id:e}).in("id",c).eq("project_id",d);return{error:r}})()),f.length>0&&r.push((async()=>{let{error:r}=await t.from("assets").update({folder_id:e}).in("id",f).eq("project_id",d);return{error:r}})());let l=null==(a=(await Promise.all(r)).find(e=>e.error))?void 0:a.error;if(l)throw l;let u=e?(null==(i=h.find(t=>
1t.id===e))||null==(n=i.name)?void 0:n.trim())||"Folder":"Unfiled";o.oR.success("".concat(s.length," item").concat(1===s.length?"":"s"," → “").concat(u,"”")),ew(),R()}catch(e){p?er.setQueryData(["workflow",d],p):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Move failed.")}},[S,ep,u,w,er,d,e8,ew,R]),tp=(0,a.useCallback)(async()=>{var e,t,r;if(S||0===ep.size)return;let l=Array.from(ep.entries()).map(e=>{let[t,r]=e;return{id:t,kind:r}}),a=l.filter(e=>"folder"===e.kind||"stack"===e.kind).map(e=>e.id),n=l.filter(e=>"asset"===e.kind).map(e=>e.id),i=er.getQueryData(["workflow",d]),s=null!=(e=null==i?void 0:i.folders)?e:u,c=null!=(t=null==i?void 0:i.assets)?t:w,f=new Set;for(let e of a)for(let t of ec(e,s))f.add(t);let p=new Set(n),h=s.filter(e=>!f.has(e.id)),m=c.filter(e=>!p.has(e.id)).map(e=>{var t;let r=null!=(t=e.folder_id)?t:null;return r&&f.has(r)?{...e,folder_id:null}:e});e8(e=>({...e,folders:h,assets:m}));let v=c.filter(e=>p.has(e.id));try{let e=(0,z.createClient)(),t=[];for(let r of(a.length>0&&t.push((async()=>{let{error:t}=await e.from("asset_folders").delete().in("id",a);return{error:t}})()),v))t.push((async()=>{var e;let{error:t}=await (0,W.n)(r.id,d,{mediaPath:null!=(e=r.media_path)?e:null});return{error:t}})());let n=null==(r=(await Promise.all(t)).find(e=>e.error))?void 0:r.error;if(n)throw n;o.oR.success("".concat(l.length," item").concat(1===l.length?"":"s"," deleted")),ew(),R()}catch(e){i?er.setQueryData(["workflow",d],i):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Delete failed.")}},[S,ep,u,w,er,d,e8,ew,R]),th=(0,a.useCallback)(async()=>{var e;if(S||0===ep.size)return;let t=Array.from(ep.entries()).filter(e=>{let[,t]=e;return"asset"===t}).map(e=>{let[t]=e;return t});if(0===t.length)return void o.oR.message("No assets in the selection to archive.");let r=er.getQueryData(["workflow",d]),l=new Set(t),a=(null!=(e=null==r?void 0:r.assets)?e:w).filter(e=>!l.has(e.id));e8(e=>({...e,assets:a}));try{let e=(0,z.createClient)(),{error:r}=await e.from("assets").update({archived_at:new Date().toISOString()}).in("id",t).eq("project_id",d);if(r)throw r;o.oR.success("".concat(t.length," asset").concat(1===t.length?"":"s"," archived")),ew(),R()}catch(e){r?er.setQueryData(["workflow",d],r):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Archive failed.")}},[S,ep,w,er,d,e8,ew,R]),tm=(0,a.useCallback)(()=>{S||(eb(null),ey(""))},[S]),tv=(0,a.useCallback)(()=>{eb(void 0),ey("")},[]),tx=(0,a.useCallback)(async()=>{let e=ek.trim(),t=null!=eg?eg:null;if(!e)return void tv();eC(!0);try{var r,l,a,n;let i=(0,z.createClient)(),{data:s,error:c}=await i.from("asset_folders").insert({project_id:d,parent_id:t,name:e,sort_order:0,created_by:null!=(l=null==el?void 0:el.id)?l:null}).select("*").single();if(c)throw c;if(s&&(0,$.mM)()&&(null==(r=window.btwDesktop)?void 0:r.mkdirpUnderLinkedRoot)){let e=er.getQueryData(["workflow",d]),t=[...null!=(a=null==e?void 0:e.folders)?a:u,s],r=(0,q.yc)(s.id,t),l=await window.btwDesktop.mkdirpUnderLinkedRoot(d,r);l.ok||o.oR.error("Folder saved in the workspace, but creating it on disk failed: ".concat(null!=(n=l.error)?n:"unknown error"))}tv(),R()}finally{eC(!1)}},[tv,ek,eg,u,R,d,er]),tw=(0,a.useCallback)((e,t,r)=>{eI.current=r,eN({id:e,kind:t}),e_(r)},[]),tg=(0,a.useCallback)(()=>{eN(null),e_(""),eI.current=""},[]),tb=(0,a.useCallback)(async(e,t)=>{var r;eE(null),eT("");let l=er.getQueryData(["workflow",d]),a=(null!=(r=null==l?void 0:l.folders)?r:u).map(r=>r.id===e?{...r,naming_template:t}:r);e8(e=>({...e,folders:a}));try{let r=(0,z.createClient)(),{data:l,error:a}=await r.from("asset_folders").update({naming_template:t}).eq("id",e).eq("project_id",d).select("id");if(a)throw a;if(!(null==l?void 0:l.length))throw Error("no row updated");R(),o.oR.success(t?"Naming preset saved":"Naming preset removed")}catch(e){l?er.setQueryData(["workflow",d],l):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Could not save the naming preset.")}},[u,e8,d,er,R]),tk=(0,a.useCallback)(async()=>{var e,t;if(!eD)return;let r=eD.id,l=eD.kind,a=eA.trim(),n=eI.current.trim();if(eN(null),e_(""),eI.current="",!a||a===n)return;let i=er.getQueryData(["workflow",d]);if("folder"===l){let t=(null!=(e=null==i?void 0:i.folders)?e:u).map(e=>e.id===r?{...e,name:a}:e);e8(e=>({...e,folders:t}));try{let e=(0,z.createClient)(),{error:t}=await e.from("asset_folders").update({name:a}).eq("id",r).eq("project_id",d);if(t)throw t;R()}catch(e){i?er.setQueryData(["workflow",d],i):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Could not rename folder.")}return}let s=(null!=(t=null==i?void 0:i.assets)?t:w).map(e=>e.id===r?{...e,name:a}:e);e8(e=>({...e,assets:s}));try{let e=(0,z.createClient)(),{error:t}=await e.from("assets").update({name:a}).eq("id",r).eq("project_id",d);if(t)throw t;R()}catch(e){i?er.setQueryData(["workflow",d],i):er.invalidateQueries({queryKey:["workflow",d]}),o.oR.error("Could not rename asset.")}},[eD,eA,er,d,u,w,e8,R]),ty=(0,a.useCallback)(e=>{ef(t=>{if(t.has(e))return t;let r=new Set(t);return r.add(e),r}),eb(e),ey("")},[ef]),[tj,tC]=(0,a.useState)(null),tD=(0,a.useCallback)((e,t)=>{tC({kind:"folder",id:e,label:t})},[]),tN=(0,a.useCallback)((e,t)=>{tC({kind:"asset",id:e,label:t})},[]),tA=(0,a.useCallback)(()=>
1{if(0===ep.size)return;let e=0,t=0;for(let r of ep.values())"asset"===r?t+=1:e+=1;tC({kind:"bulk",count:ep.size,folderLikeCount:e,assetCount:t})},[ep]),t_=(0,a.useCallback)(()=>{tj&&("folder"===tj.kind?(td("__delete_folder__",tj.id),o.oR.success("Folder deleted")):"asset"===tj.kind?(tu(tj.id),o.oR.success("Asset deleted")):tp(),tC(null))},[tj,td,tu,tp]),tS=(0,a.useMemo)(()=>new Set(ep.keys()),[ep]),tR=(0,a.useMemo)(()=>Array.from(ep.entries()).map(e=>{let[t,r]=e;return{id:t,kind:r}}),[ep]),tM=(0,a.useMemo)(()=>{let e=new Set;for(let[t,r]of ep)if("folder"===r||"stack"===r)for(let r of ec(t,u))e.add(r);return e},[ep,u]),[tE,tF]=(0,a.useState)(null),tT=(0,a.useCallback)(()=>tF(null),[]),tI=(0,a.useCallback)((e,t)=>{let r=ep.has(e.id),l=ep.size;l>1&&r||(eh(new Map([[e.id,e.kind]])),em.current=e,e1(e.id));let a=[],n=!!ee;if(l>1&&r)a.push({kind:"info",label:"".concat(l," selected")}),a.push({label:"Move ".concat(l," to…"),icon:f.A,disabled:S,onSelect:()=>eR({items:Array.from(ep.entries()).map(e=>{let[t,r]=e;return{id:t,kind:r}}),forbiddenTargetIds:tM})}),a.push({label:"Archive ".concat(l),icon:p.A,disabled:S,onSelect:()=>void th()}),a.push({label:"Delete ".concat(l),icon:h.A,destructive:!0,disabled:S,onSelect:tA}),a.push({kind:"separator"}),a.push({label:"Clear",onSelect:ew});else if("folder"===e.kind){let t=u.find(t=>t.id===e.id);a.push({label:"Open",icon:s.A,onSelect:()=>eJ(e.id)}),a.push({label:"New subfolder",icon:m.A,disabled:S,onSelect:()=>ty(e.id)}),a.push({label:"Rename",icon:v.A,disabled:S,onSelect:()=>{t&&tw(t.id,"folder",t.name)}}),a.push({label:"Move to…",icon:f.A,disabled:S,onSelect:()=>eR({items:[{id:e.id,kind:"folder"}],forbiddenTargetIds:ec(e.id,u)})}),a.push({label:"Naming preset…",icon:c.A,disabled:S,onSelect:()=>{var e;t&&(eT(null!=(e=t.naming_template)?e:""),eE(t.id))}}),a.push({kind:"separator"}),a.push({label:"Delete",icon:h.A,destructive:!0,disabled:S,onSelect:()=>{t&&tD(t.id,t.name)}})}else if("asset"===e.kind){var o,i;let t=w.find(t=>t.id===e.id),r=(null!=(o=null==t?void 0:t.name)?o:"").trim()||(null!=(i=null==t?void 0:t.prompt)?i:"").trim().slice(0,32)||"Asset";a.push({label:"Open",icon:c.A,disabled:n,onSelect:()=>{n||null==X||X(e.id)}}),a.push({label:"Rename",icon:v.A,disabled:S||n,onSelect:()=>tw(e.id,"asset",r)}),a.push({label:"Move to…",icon:f.A,disabled:S,onSelect:()=>eR({items:[{id:e.id,kind:"asset"}],forbiddenTargetIds:new Set})}),a.push({kind:"separator"}),a.push({label:"Archive",icon:p.A,disabled:S,onSelect:()=>void tc(e.id)}),a.push({label:"Delete",icon:h.A,destructive:!0,disabled:S,onSelect:()=>tN(e.id,r)})}tF({position:{x:t.clientX,y:t.clientY},items:a})},[ep,ew,S,tA,th,tM,u,w,ee,X,eJ,tw,ty,tD,tc,tN]),tL=!!ee,tq=(0,a.useCallback)(e=>{let t=ev.current;if(!t)return;let r=t.querySelector('[data-row-id="'.concat(en(e),'"]'));r&&(r.focus({preventScroll:!0}),r.scrollIntoView({block:"nearest"}))},[]),tO=(0,a.useCallback)(e=>{var t,r,l,a;if("asset"===e.kind){let t=eB.get(e.id);return(null!=(r=null==t?void 0:t.name)?r:"").trim()||(null!=(l=null==t?void 0:t.prompt)?l:"").trim().slice(0,48)||"Untitled asset"}return(null!=(a=null==(t=e$.get(e.id))?void 0:t.name)?a:"").trim()||"Untitled folder"},[eB,e$]),tQ=(0,a.useCallback)(e=>{var t,r,l,a;if("asset"===e.kind){let t=null!=(l=null==(r=eB.get(e.id))?void 0:r.folder_id)?l:null;return t&&ez.has(t)?null:t}return null!=(a=null==(t=e$.get(e.id))?void 0:t.parent_id)?a:null},[eB,e$,ez]);(0,a.useLayoutEffect)(()=>{var e,t,r,l;let a=ev.current;if(!a||(a.querySelectorAll('.wf-indent-guide[data-guide-active="1"]').forEach(e=>e.removeAttribute("data-guide-active")),!e0))return;let n=[];if(e$.has(e0))n=null!=(e=eW.get(e0))?e:[e0];else{let e=null!=(r=null==(t=eB.get(e0))?void 0:t.folder_id)?r:null,a=e&&ez.has(e)?null:e;a&&(n=null!=(l=eW.get(a))?l:[a])}for(let e of n)a.querySelectorAll('.wf-indent-guide[data-guide-folder="'.concat(en(e),'"]')).forEach(e=>e.setAttribute("data-guide-active","1"))},[e0,eZ,e$,eB,eW,ez]);let tP=I===B.dx,tz=I===G,tK=(0,a.useMemo)(()=>{if(null===I)return"All project files";if(tP)return"Unfiled";if(tz)return"Archive";let e=(0,q.yc)(I,u);return e.length>0?e.join(" / "):"All project files"},[I,tP,tz,u]),[tU,tY]=(0,a.useState)([]),[t$,tB]=(0,a.useState)(!1);(0,a.useEffect)(()=>
1{if(!tz)return;let e=!1;return tB(!0),(0,z.createClient)().from("assets").select("*").eq("project_id",d).not("archived_at","is",null).order("archived_at",{ascending:!1}).then(t=>{let{data:r}=t;e||(tY(null!=r?r:[]),tB(!1))}),()=>{e=!0}},[tz,d]);let tW=(0,a.useCallback)(async e=>{try{let t=(0,z.createClient)(),{error:r}=await t.from("assets").update({archived_at:null}).eq("id",e).eq("project_id",d);if(r)throw r;tY(t=>t.filter(t=>t.id!==e)),R()}catch(e){o.oR.error("Could not restore asset. Try again.")}},[d,R]),tV=(0,a.useCallback)(async e=>{try{var t;let r=tU.find(t=>t.id===e);await (0,W.n)(e,d,{mediaPath:null!=(t=null==r?void 0:r.media_path)?t:null}),tY(t=>t.filter(t=>t.id!==e)),R(),o.oR.success("Asset permanently deleted")}catch(e){o.oR.error("Could not delete asset. Try again.")}},[tU,R,d]),[tX,tJ]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{let e=window.localStorage.getItem(P.GL);tJ("1"===e)}catch(e){}},[]);let tG=(0,a.useCallback)(()=>{tJ(e=>{let t=!e;try{window.localStorage.setItem(P.GL,t?"1":"0")}catch(e){}return t})},[]);return((0,a.useEffect)(()=>{let e=()=>{tJ(!1),tm()},t=()=>{tJ(!1);try{window.localStorage.setItem(P.GL,"0")}catch(e){}};return window.addEventListener("btw-new-folder",e),window.addEventListener("btw-workflow-new-folder",e),window.addEventListener("btw-workflow-open-folders",t),()=>{window.removeEventListener("btw-new-folder",e),window.removeEventListener("btw-workflow-new-folder",e),window.removeEventListener("btw-workflow-open-folders",t)}},[tm]),tX)?(0,l.jsx)("aside",{className:(0,O.cn)("flex min-h-0 w-16 shrink-0 flex-col items-center gap-2 border-r border-border bg-[color-mix(in_srgb,var(--canvas-toolbar-bg)_82%,transparent)] py-3 backdrop-blur-xl",M),"aria-label":"Workflow folders","data-explain-title":"Explorer","data-explain-hint":"Folders and stacks for this project. Open the panel to browse them, to drag any asset row into a folder, or to drop an asset on a stack to iterate.","data-explain-skill":"daily.folders-vs-stacks",children:(0,l.jsxs)("button",{type:"button",className:"tap-press group/edge-tab flex w-[56px] flex-col items-center gap-1 rounded-[10px] border border-border bg-card/70 px-1 py-2 text-muted-foreground shadow-[var(--elev-1)] transition-colors hover:bg-card hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40","aria-label":"Show the folders panel","aria-expanded":!1,onClick:tG,children:[(0,l.jsx)(s.A,{className:"size-4","aria-hidden":!0}),(0,l.jsx)("span",{className:"text-[10px] font-semibold leading-tight tracking-tight",children:"Folders"}),(0,l.jsx)("span",{className:"text-[9px] font-medium leading-tight text-[var(--shell-text-muted)] opacity-0 transition-opacity duration-150 group-hover/edge-tab:opacity-100 group-focus-visible/edge-tab:opacity-100","aria-hidden":!0,children:"Show"})]})}):(0,l.jsxs)("aside",{className:(0,O.cn)("relative flex min-h-0 w-64 shrink-0 flex-col border-r border-border bg-[color-mix(in_srgb,var(--canvas-toolbar-bg)_88%,transparent)] backdrop-blur-xl",e5&&"wf-panel-drag-mode",M),"aria-label":"Workflow folders","data-replay-private":!0,"data-explain-title":"Explorer","data-explain-hint":"Folders and stacks for this project. Drag any asset row to organize; drop on a stack to iterate. Drag a folder onto another folder to nest.","data-explain-skill":"daily.folders-vs-stacks",children:[(0,l.jsxs)("div",{className:"flex h-10 shrink-0 items-center justify-between gap-1 border-b border-border px-3",children:[(0,l.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,l.jsx)("span",{className:"type-eyebrow min-w-0 truncate text-[var(--shell-text-muted)]",children:"Explorer"}),eU?(0,l.jsxs)("span",{className:"truncate text-[10px] font-normal lowercase tracking-normal text-[var(--app-accent)]",title:"Mirroring Finder folder: ".concat(eL),children:["\xb7 ",eU]}):null,ee?(0,l.jsx)(F.Y6,{label:"This tree is showing a copy that was saved on this machine at ".concat(ee.diskSavedAtIso,". The last time it agreed with the server was ").concat(ee.serverSyncedAtIso,"."),children:(0,l.jsx)("span",{className:"inline-flex min-w-0",children:(0,l.jsx)(Y.E,{variant:"outline",className:"max-w-[110px] truncate border-amber-700/60 bg-amber-950/40 text-[9px] font-normal text-amber-100",children:"offline"===ee.reason?"Offline":"degraded_schema"===ee.reason?"Schema":"Stale"})})}):null]}),(0,l.jsxs)("span",{className:"flex shrink-0 items-center gap-0",children:[eP?(0,l.jsxs)(y.rI,{children:[(0,l.jsx)(F.Y6,{label:eL?"This tree mirrors the Finder folder ".concat(eL,"."):"Connect this tree to a folder on your Mac so both keep the same contents.",children:(0,l.jsx)(y.ty,{asChild:!0,children:(0,l.jsx)(E.$,{type:"button",variant:"ghost",size:"icon",className:(0,O.cn)("h-6 w-6 text-[var(--shell-text-muted)] hover:bg-[var(--shell-hover)] hover:text-[var(--shell-text)]",eL&&"text-[var(--app-accent)] hover:text-[var(--app-accent)]"),"aria-label":"Finder folder",children:(0,l.jsx)(x.A,{className:"h-3.5 w-3.5","aria-hidden":!0})})})}),(0,l.jsxs)(y.SQ,{align:"end",className:"w-[280px] p-3",children:[(0,l.jsx)("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Finder folder"}),(0,l.jsx)("p",{className:"mb-2 truncate font-mono text-[10px] text-muted-foreground",title:null!=eL?eL:void 0,children:null!=eL?eL:"Not linked — pick a folder on disk to mirror this tree."}),S?null:(0,l.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(0,l.jsxs)(E.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 gap-1 px-2 text-[10px]",disabled:eO,onClick:()=>void te(),children:[(0,l.jsx)(s.A,{className:"size-3","aria-hidden":!0}),eL?"Change…":"Link folder…"]}),(0,l.jsx)(E.$,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-[10px]",disabled:eO||!eL,onClick:()=>void tr(),children:"Reveal"}),(0,l.jsx)(E.$,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-[10px]",disabled:eO||!eL||0===u.length,onClick:()=>void tt(),children:"Export tree"}),(0,l.jsx)(E.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px] text-muted-foreground",disabled:eO||!eL,onClick:()=>void tl(),children:"Unlink"})]})]})]}):null,S?null:(0,l.jsx)(F.Y6,{label:"Create a new folder in the place you are looking at.",children:(0,l.jsxs)(E.$,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0 text-[var(--shell-text-muted)] hover:bg-[var(--shell-hover)] hover:text-[var(--shell-text)]","aria-label":"New folder",disabled:ej,onClick:tm,children:[(0,l.jsx)(m.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),(0,l.jsx)("span",{className:"sr-only",children:"New folder"})]})}),(0,l.jsx)(F.Y6,{label:"Collapse every folder in this tree back to the top level.",children:(0,l.jsx)(E.$,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-[var(--shell-text-muted)] hover:bg-[var(--shell-hover)] hover:text-[var(--shell-text)]","aria-label":"Collapse all folders",onClick:eH,children:(0,l.jsx)(g,{className:"h-3.5 w-3.5","aria-hidden":!0})})}),(0,l.jsx)(F.Y6,{label:"Hide the folders panel and leave the narrow strip on the left.",children:(0,l.jsx)(E.$,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-[var(--shell-text-muted)] hover:bg-[var(--shell-hover)] hover:text-[var(--shell-text)]","aria-label":"Hide the folders panel","aria-expanded":!0,onClick:tG,children:(0,l.jsx)(b.A,{className:"h-3.5 w-3.5","aria-hidden":!0})})})]})]}),(0,l.jsxs)("div",{className:"flex h-8 shrink-0 items-center gap-2 border-b border-border/70 px-3 text-[11px] text-[var(--shell-text-muted)]",children:[(0,l.jsx)(s.A,{className:"h-3.5 w-3.5 shrink-0 text-[var(--app-accent)]","aria-hidden":!0}),(0,l.jsx)("span",{className:"min-w-0 flex-1 truncate",title:tK,children:tK}),(0,l.jsx)("span",{className:"shrink-0 tabular-nums text-[var(--shell-text-subtle)]",children:ep.size>0?"".concat(ep.size," selected"):"".concat(eZ.length," items")})]}),(0,l.jsx)("div",{ref:ev,onKeyDown:e=>{var t,r,l,a,n,o;let i=e.target;if(!i||"INPUT"===i.tagName||"TEXTAREA"===i.tagName||i.isContentEditable||!i.closest("[data-row-id]"))return;let s=e.metaKey||e.ctrlKey,d=e.shiftKey;if("Escape"===e.key)return void(eD?tg():ep.size>0&&ew());if(0===eZ.length)return;let u=e0?eZ.findIndex(e=>e.id===e0):-1,c=-1===u?0:u,f=eZ[c],p=e=>{e1(e.id),eh(new Map([[e.id,e.kind]])),em.current=e,tq(e.id)},h=e=>{var t;let r=null!=(t=em.current)?t:f;em.current=r,e1(e.id);let l=eZ.findIndex(e=>e.id===r.id),a=eZ.findIndex(t=>t.id===e.id);if(-1===l||-1===a)eh(new Map([[e.id,e.kind]])),em.current=e;else{let[e,t]=l<=a?[l,a]:[a,l],r=new Map;for(let l=e;l<=t;l++)r.set(eZ[l].id,eZ[l].kind);eh(r)}tq(e.id)},m=e=>{let t=Math.min(Math.max(c+e,0),eZ.length-1);if(t===c)return;let r=eZ[t];
1if(s)e1(r.id),tq(r.id);else d?h(r):p(r)};if(s&&("a"===e.key||"A"===e.key)){e.preventDefault();let t=new Map;for(let e of eZ)t.set(e.id,e.kind);eh(t);return}switch(e.key){case"ArrowDown":e.preventDefault(),m(1);return;case"ArrowUp":e.preventDefault(),m(-1);return;case"Home":e.preventDefault(),d?h(eZ[0]):p(eZ[0]);return;case"End":e.preventDefault(),d?h(eZ[eZ.length-1]):p(eZ[eZ.length-1]);return;case"ArrowRight":{if(e.preventDefault(),"folder"!==f.kind)return;let n=(null!=(l=null==(t=eY.get(f.id))?void 0:t.length)?l:0)>0||(null!=(a=null==(r=eV.get(f.id))?void 0:r.length)?a:0)>0;if(eo.has(f.id)){if(n){let e=eZ[c+1];e&&p(e)}}else n&&eX(f.id);return}case"ArrowLeft":{if(e.preventDefault(),"folder"===f.kind&&eo.has(f.id))return void eX(f.id);let t=tQ(f);if(t){let e=eZ.find(e=>e.id===t&&"folder"===e.kind);e&&p(e)}return}case"Enter":e.preventDefault(),"folder"===f.kind?eJ(f.id):tL||null==X||X(f.id);return;case" ":e.preventDefault(),eh(e=>{let t=new Map(e);return t.has(f.id)?t.delete(f.id):t.set(f.id,f.kind),t}),em.current=f;return;case"F2":if(e.preventDefault(),S)return;if("folder"===f.kind){let e=e$.get(f.id);e&&tw(e.id,"folder",e.name)}else if("asset"===f.kind&&!tL){let e=eB.get(f.id),t=(null!=(n=null==e?void 0:e.name)?n:"").trim()||(null!=(o=null==e?void 0:e.prompt)?o:"").trim().slice(0,48)||"Untitled asset";tw(f.id,"asset",t)}return;case"Delete":case"Backspace":if(e.preventDefault(),S)return;tA();return}if(1===e.key.length&&!s&&!e.altKey){e.preventDefault();let t=e.timeStamp||Date.now(),r=ex.current,l=(t-r.at>600?"":r.buffer)+e.key.toLowerCase();r.buffer=l,r.at=t;let a=1===l.length?c+1:c;for(let e=0;e<eZ.length;e++){let t=(a+e)%eZ.length;if(tO(eZ[t]).toLowerCase().startsWith(l)){p(eZ[t]);break}}}},className:"min-h-0 flex-1 overflow-auto py-1 text-left",children:J?(0,l.jsxs)("div",{className:"space-y-1 px-2 py-1","aria-busy":"true","aria-label":"Loading folders",children:[(0,l.jsx)(U.EA,{className:"h-6 w-full"}),(0,l.jsx)(U.EA,{className:"h-6 w-5/6"}),(0,l.jsx)(U.EA,{className:"h-6 w-4/6"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{role:"tablist","aria-label":"Canvas scope",className:"seg-control mx-3 mb-1.5 mt-1 w-[calc(100%-1.5rem)]",children:[(0,l.jsx)(F.Y6,{label:"Show every asset in this project, whatever folder it sits in.",children:(0,l.jsx)("button",{type:"button",role:"tab","aria-selected":null===I,onClick:()=>eG(null),className:"seg-control-item flex-1",children:"All"})}),(0,l.jsx)(F.Y6,{label:"Show only the assets that do not sit in a folder yet.",children:(0,l.jsx)("button",{type:"button",role:"tab","aria-selected":tP,"data-workflow-folder-drop":"__unfiled__",onClick:()=>eG(B.dx),onDragEnter:e=>{if(S)return;let t=H(e);("asset"===t||"stack"===t)&&e.preventDefault()},onDragOver:e=>{if(S)return;let t=H(e);("asset"===t||"stack"===t)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",e.currentTarget.setAttribute("data-workflow-folder-drop-over","1"))},onDragLeave:e=>{e.currentTarget.removeAttribute("data-workflow-folder-drop-over")},onDrop:e=>{if(e.currentTarget.removeAttribute("data-workflow-folder-drop-over"),S)return;let t=Z(e);if(e.preventDefault(),t){if(t.bulk)return void tf(null,t.bulk);"asset"===t.kind?td(t.id,null):"stack"===t.kind&&ts(t.id,null)}},className:"seg-control-item flex-1",children:"Unfiled"})}),(0,l.jsx)(F.Y6,{label:"Show the assets that were archived out of this project.",children:(0,l.jsx)("button",{type:"button",role:"tab","aria-selected":tz,onClick:()=>eG(G),className:"seg-control-item flex-1",children:"Archived"})})]}),tz?(0,l.jsx)("div",{className:"flex flex-col gap-0.5 px-1",children:t$?(0,l.jsx)("div",{className:"px-2 py-4",children:(0,l.jsx)(U.EA,{className:"h-4 w-full"})}):0===tU.length?(0,l.jsx)("p",{className:"px-2 py-4 text-xs text-[var(--shell-text-muted)]",children:"No archived assets."}):tU.map(e=>(0,l.jsxs)("div",{className:"group flex items-center gap-1.5 rounded px-2 py-1 text-xs hover:bg-[var(--shell-bg-hover)]",children:[(0,l.jsx)(c.A,{className:"h-3.5 w-3.5 flex-shrink-0 text-[var(--shell-text-muted)]"}),(0,l.jsx)("span",{className:"flex-1 truncate opacity-60",children:e.name||"Untitled"}),(0,l.jsx)(F.Y6,{label:"Put this asset back into the project so it appears on the canvas again.",children:(0,l.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium text-[var(--shell-text-muted)] hover:bg-[var(--shell-bg
1-hover)] hover:text-[var(--shell-text)]",onClick:()=>tW(e.id),children:[(0,l.jsx)(k,{className:"h-3 w-3","aria-hidden":!0}),"Restore"]})}),(0,l.jsx)(F.Y6,{label:"Delete this asset for good. This cannot be undone.",children:(0,l.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium text-red-500 hover:bg-red-500/10",onClick:()=>tC({kind:"permanent",id:e.id,label:e.name||"Untitled"}),children:[(0,l.jsx)(h.A,{className:"h-3 w-3","aria-hidden":!0}),"Delete"]})})]},e.id))}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(es,{parentId:null,grouped:eY,assetsByFolder:eV,depth:0,expanded:eo,toggle:eX,readOnly:S,onMoveAsset:td,onDeleteAsset:tu,selectedFolderFilter:I,onDropAssetOnFolder:ti,onDropFolderOnFolder:to,onDropStackOnFolder:ts,onDropFolderReorder:tn,onScheduleAutoExpand:e6,onCancelAutoExpand:e7,creatingParentId:eg,creatingDraft:ek,onCreatingDraftChange:ey,onCreatingCommit:()=>void tx(),onCreatingCancel:tv,onRequestDeleteFolder:tD,onRequestDeleteAsset:tN,onArchiveAsset:tc,renaming:eD,renameDraft:eA,onStartRename:tw,onRenameDraftChange:e_,onRenameCommit:()=>void tk(),onRenameCancel:tg,onRequestNewSubfolder:ty,activeId:e0,ancestorIds:ea,childChainByFolder:eW,selectedIds:tS,multiDragIds:tR,onRowSelect:e2,onRowContextMenu:tI,onBulkDrop:(e,t)=>{tf(e,t)},onOpenFolder:eJ,onOpenAsset:tL?void 0:X}),S?null:(0,l.jsx)("div",{"data-workflow-folder-drop":"__unfiled__",className:"mt-1 min-h-[80px] flex-1 rounded-sm transition-colors",onClick:ew,onDragEnter:e=>{let t=H(e);("asset"===t||"stack"===t)&&e.preventDefault()},onDragOver:e=>{let t=H(e);("asset"===t||"stack"===t)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",e.currentTarget.setAttribute("data-workflow-folder-drop-over","1"))},onDragLeave:e=>{e.currentTarget.removeAttribute("data-workflow-folder-drop-over")},onDrop:e=>{e.currentTarget.removeAttribute("data-workflow-folder-drop-over");let t=Z(e);if(e.preventDefault(),t){if(t.bulk)return void tf(null,t.bulk);"asset"===t.kind?td(t.id,null):"stack"===t.kind&&ts(t.id,null)}},"aria-label":"Drop here to make unfiled"})]})]})}),(0,l.jsx)(j.T,{open:null!==tj,onOpenChange:e=>{e||tC(null)},title:(null==tj?void 0:tj.kind)==="folder"?'Delete folder "'.concat(tj.label,'"?'):(null==tj?void 0:tj.kind)==="asset"?'Delete "'.concat(tj.label,'"?'):(null==tj?void 0:tj.kind)==="permanent"?'Permanently delete "'.concat(tj.label,'"?'):(null==tj?void 0:tj.kind)==="bulk"?"Delete ".concat(tj.count," item").concat(1===tj.count?"":"s","?"):"",description:(null==tj?void 0:tj.kind)==="folder"?"This will delete the folder and any nested folders. Assets inside will become unfiled.":(null==tj?void 0:tj.kind)==="asset"?"This cannot be undone.":(null==tj?void 0:tj.kind)==="permanent"?"This removes the archived asset and its stored files for good. It cannot be undone.":(null==tj?void 0:tj.kind)==="bulk"?tj.folderLikeCount>0&&tj.assetCount>0?"".concat(tj.folderLikeCount," folder/stack").concat(1===tj.folderLikeCount?"":"s"," (with their contents) and ").concat(tj.assetCount," asset").concat(1===tj.assetCount?"":"s"," will be deleted. This can't be undone."):tj.folderLikeCount>0?"".concat(tj.folderLikeCount," folder/stack").concat(1===tj.folderLikeCount?"":"s"," and all nested subfolders will be deleted. Assets inside will become unfiled."):"".concat(tj.assetCount," asset").concat(1===tj.assetCount?"":"s"," will be deleted. This can't be undone."):"",confirmLabel:(null==tj?void 0:tj.kind)==="permanent"?"Delete forever":"Delete",variant:"destructive",onConfirm:()=>{(null==tj?void 0:tj.kind)==="permanent"?(tV(tj.id),tC(null)):t_()}}),(0,l.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-2 z-30 flex justify-center","aria-hidden":ep.size<2,children:(0,l.jsx)(T,{count:ep.size,readOnly:S,onOpenMovePicker:()=>eR({items:tR,forbiddenTargetIds:tM}),onArchive:()=>void th(),onDelete:tA,onClear:ew})}),(0,l.jsx)(_.t,{open:null!==tE,position:null!=(r=null==tE?void 0:tE.position)?r:null,items:null!=(i=null==tE?void 0:tE.items)?i:[],onClose:tT}),eS?(0,l.jsx)(Q,{items:eS.items,forbiddenTargetIds:eS.forbiddenTargetIds,folders:u,onPick:(e,t)=>{tf(e,t),eR(null)},onClose:()=>eR(null)}):null,(()=>{var e,t,r;let a=eM&&null!=(t=u.find(e=>e.id===eM))?t:null;if(!a)return null;let n=a.parent_id&&null!=(r=null==(e=u.find(e=>e.id===a.parent_id))?void 0:e.name)?r:null,o=(0,A.or)(w.filter(e=>e.folder_id===a.id).map(e=>e.name)),i=(0,A.XW)(eF)?(0,A.Vv)(eF,{date:new Date,folderName:a.name,parentFolder
1Name:n,nr:o}):null,s=(0,A.XW)(eF)&&!i;return(0,l.jsx)(C.lG,{open:!0,onOpenChange:e=>{e||eE(null)},children:(0,l.jsxs)(C.Cf,{className:"sm:max-w-md",children:[(0,l.jsxs)(C.c7,{children:[(0,l.jsxs)(C.L3,{children:["Naming preset — “",a.name,"”"]}),(0,l.jsx)(C.rr,{children:"New assets in this folder get their name prefilled from this pattern. You can always overwrite it — existing assets are never renamed."})]}),(0,l.jsxs)("div",{className:"space-y-3 py-1",children:[(0,l.jsxs)("div",{className:"space-y-1.5",children:[(0,l.jsx)(N.J,{htmlFor:"naming-template",children:"Pattern"}),(0,l.jsx)(D.p,{id:"naming-template",value:eF,onChange:e=>eT(e.target.value),placeholder:"e.g. {date}_{parent}_{folder}_{nr}",autoFocus:!0})]}),(0,l.jsx)("div",{className:"flex flex-wrap gap-1.5",children:A.DS.map(e=>(0,l.jsx)(E.$,{type:"button",size:"sm",variant:"outline",className:"h-7 font-mono text-[11px]",onClick:()=>eT(t=>"".concat(t).concat(t&&!t.endsWith("_")?"_":"").concat(e.token)),children:e.token},e.token))}),(0,l.jsx)("ul",{className:"space-y-0.5 text-[11px] text-muted-foreground",children:A.DS.map(e=>(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-mono text-foreground",children:e.token})," — ",e.hint]},e.token))}),(0,l.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 px-3 py-2",children:[(0,l.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Next asset would be named"}),(0,l.jsx)("p",{className:"truncate font-mono text-[13px] text-foreground",children:i||"— type a pattern above —"}),s?(0,l.jsx)("p",{className:"mt-1 text-[11px] text-destructive",children:"This pattern produces an empty name for this folder — add more tokens or text."}):null]})]}),(0,l.jsxs)(C.Es,{className:"gap-2 sm:justify-between",children:[(0,l.jsx)("div",{children:(0,A.XW)(a.naming_template)?(0,l.jsx)(E.$,{type:"button",variant:"ghost",className:"text-destructive hover:bg-destructive/10",onClick:()=>void tb(a.id,null),children:"Remove preset"}):null}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(E.$,{type:"button",variant:"ghost",onClick:()=>eE(null),children:"Cancel"}),(0,l.jsx)(E.$,{type:"button",disabled:!(0,A.XW)(eF)||!i,onClick:()=>void tb(a.id,eF.trim()),children:"Save preset"})]})]})]})})})()]})}},58702:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(71847).A)("FolderX",[["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"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]])},82317:(e,t,r)=>{r.d(t,{A:()=>l});let l=(0,r(71847).A)("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]])}}]);

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.