1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9199],{9199:(e,s,t)=>{t.r(s),t.d(s,{AssetDeleteConfirmationModal:()=>y});var r=t(47631),l=t(38759),n=t(95107),a=t(64035),i=t(75202),d=t(80928),o=t(6106),m=t(43620),c=t(55960),u=t(41479),x=t(21787);let h=(e,s)=>"music"===s?e.title||e.filename||"Untitled asset":e.filename||"Untitled asset",p=(e,s)=>"video"===e.assetType||"music"===e.assetType?e.assetType:"title"in e||"artist"in e?"music":s,f=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`,g=e=>"video"===e?(0,r.jsx)(n.A,{className:"h-5 w-5 text-muted-foreground"}):(0,r.jsx)(a.A,{className:"h-5 w-5 text-muted-foreground"}),v=({children:e})=>(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-sm font-medium text-muted-foreground",children:e});function j({asset:e,assetType:s}){let t="video"!==s?null:e.thumbnail_proxy_url||e.thumbnail_url||null;return(0,r.jsx)("div",{className:"relative flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border/70 bg-muted/50",children:t?(0,r.jsx)(m.default,{src:t,alt:`Preview of ${h(e,s)}`,fill:!0,sizes:"80px",unoptimized:!0,className:"object-cover"}):(0,r.jsx)("div",{className:"flex h-full w-full items-center justify-center bg-muted",children:g(s)})})}function w({asset:e,assetType:s}){let t=h(e,s),l="music"===s&&t!==e.filename?e.filename:null,n=[e.format?e.format.toUpperCase():null,(e=>{if(null==e||!Number.isFinite(e)||e<0)return null;if(0===e)return"0 Bytes";let s=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,s)).toFixed(2))} ${["Bytes","KB","MB","GB","TB"][s]}`})(e.size),(e=>{if(!e||e<=0)return null;let s=Math.floor(e/3600),t=Math.floor(e%3600/60),r=Math.floor(e%60);return s>0?`${s}:${t.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${t}:${r.toString().padStart(2,"0")}`})(e.duration),e.uploaded_at?`Uploaded ${new Date(e.uploaded_at).toLocaleDateString()}`:null].filter(e=>!!e),a=e.tags?.slice(0,3)??[],i=Math.max((e.tags?.length??0)-a.length,0);return(0,r.jsx)("div",{className:"rounded-lg bg-muted/40 p-4",children:(0,r.jsxs)("div",{className:"flex items-start gap-4",children:[(0,r.jsx)(j,{asset:e,assetType:s}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("div",{className:"min-w-0 text-sm font-semibold leading-5 text-foreground [overflow-wrap:anywhere]",children:t}),"artist"in e&&e.artist?(0,r.jsx)("div",{className:"min-w-0 text-sm text-muted-foreground [overflow-wrap:anywhere]",children:e.artist}):null,l?(0,r.jsxs)("div",{className:"min-w-0 text-sm text-muted-foreground [overflow-wrap:anywhere]",children:["File: ",l]}):null]}),n.length>0?(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map(e=>(0,r.jsx)(v,{children:e},e))}):null,a.length>0?(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[a.map(e=>(0,r.jsx)(c.Badge,{variant:"outline",className:"rounded-full border-border/70 bg-background/80 px-2.5 py-1 text-sm font-medium text-muted-foreground",children:e},e)),i>0?(0,r.jsxs)(c.Badge,{variant:"outline",className:"rounded-full border-border/70 bg-background/80 px-2.5 py-1 text-sm font-medium text-muted-foreground",children:["+",i," more"]}):null]}):null]})]})})}function b({bulkAssets:e,bulkCount:s,fallbackType:t}){let l=e.map(e=>({...e,assetType:p(e,t)})),n=l.filter(e=>"video"===e.assetType).length,a=l.filter(e=>"music"===e.assetType).length,i=l.slice(0,5),d=Math.max(s-i.length,0);return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:[n>0?f(n,"video","videos"):null,a>0?f(a,"music file"):null].filter(Boolean).join(" \xb7 ")}),(0,r.jsx)("ul",{className:"divide-y divide-border rounded-lg border border-border px-3",children:i.map(e=>(0,r.jsxs)("li",{className:"flex min-w-0 items-start gap-3 py-3",children:[(0,r.jsx)("span",{className:"shrink-0 pt-0.5","aria-hidden":"true",children:g(e.assetType)}),(0,r.jsx)("div",{className:"min-w-0 text-sm leading-5 [overflow-wrap:anywhere]",children:h(e,e.assetType)})]},e.id))}),d>0?(0,r.jsxs)("p",{className:"text-sm text-muted-foreground",children:["+",d," more selected"]}):null]})}function N({impact:e,isLoading:s,error:t,onRetry:l}){if(s)return(0,r.jsxs)("div",{className:"flex items-center gap-3 rounded-lg bg-muted/40 p-4 text-sm text-muted-foreground","aria-live":"polite",children:[(0,r.jsx)(i.A,{"aria-hidden":"true",className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none"}),(0,r.jsx)("span",{children:"Checking Variation Builder and saved video editsâ¦"})]});if(t)return(0,r.jsxs)("div",{className:"rounded-xl border border-destructive/25 bg-destructive/6 p-4",role:"alert",children:[(0,r.jsx)("div",{className:"text-sm font-semibold text-destructive",children:"Usage check failed"}),(0,r.jsxs)("p",{className:"mt-1 text-sm leading-6 text-destructive/90",children:[t," Deleti
1on stays disabled until the check succeeds."]}),(0,r.jsxs)(u.Button,{type:"button",variant:"outline",size:"sm",onClick:l,className:"mt-3 h-11 gap-2 sm:h-9",children:[(0,r.jsx)(d.A,{className:"h-3.5 w-3.5"}),"Try again"]})]});if(!e)return null;let n=e.workshop.blockPlacementCount+e.workshop.musicPlacementCount,a=e.workshop.sequences.slice(0,6),o=Math.max(e.workshop.sequences.length-a.length,0);return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"rounded-lg border border-border p-4",children:[(0,r.jsx)("div",{className:"text-sm font-semibold text-foreground",children:n>0?"Used in Variation Builder":"Not currently used in Variation Builder"}),(0,r.jsx)("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:n>0?`${f(n,"placement")} across ${f(e.workshop.sequenceCount,"sequence")} will be removed automatically. The remaining clips stay in place.`:"No sequence or music placements will change."}),a.length>0?(0,r.jsxs)("div",{className:"mt-3 divide-y divide-border/60 border-t border-border/60",children:[a.map(e=>{let s=e.locations.map(e=>"music"===e.kind?"Music":e.label?.trim()||`Block ${(e.position??0)+1}`);return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-1 px-3 py-2.5 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[(0,r.jsx)("span",{className:"min-w-0 text-sm font-medium text-foreground [overflow-wrap:anywhere]",children:e.sequenceName}),(0,r.jsx)("span",{className:"min-w-0 text-sm leading-5 text-muted-foreground [overflow-wrap:anywhere] sm:max-w-[45%] sm:text-right",children:s.join(" \xb7 ")})]},e.sequenceId)}),o>0?(0,r.jsxs)("div",{className:"px-3 py-2.5 text-sm font-medium text-muted-foreground",children:["+",o," more ",1===o?"sequence":"sequences"]}):null]}):null]}),e.editorProjects.length>0?(0,r.jsxs)("div",{className:"rounded-lg border border-destructive/25 p-4",children:[(0,r.jsx)("div",{className:"text-sm font-semibold text-foreground",children:"Saved video edits will have missing media"}),(0,r.jsx)("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"Timing stays unchanged. Replace or remove the missing media before you export."}),(0,r.jsxs)("div",{className:"mt-3 space-y-1.5 text-sm text-foreground",children:[e.editorProjects.slice(0,6).map(e=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-1 sm:flex-row sm:items-start sm:justify-between sm:gap-3",children:[(0,r.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:e.title}),(0,r.jsxs)("span",{className:"shrink-0 text-sm text-muted-foreground",children:[f(e.assetCount,"selected asset")," used"]})]},e.id)),e.editorProjects.length>6?(0,r.jsxs)("div",{className:"text-sm font-medium text-muted-foreground",children:["+",e.editorProjects.length-6," more saved edits"]}):null]})]}):null]})}function y({isOpen:e,onClose:s,onConfirm:t,asset:n,assetType:a,isLoading:i=!1,errorMessage:d,bulkCount:m,bulkAssets:c}){let[h,f]=l.useState(null),[g,v]=l.useState(!1),[j,k]=l.useState(null),[C,T]=l.useState(0),$=l.useMemo(()=>Array.from(new Set((m&&m>0?c??[]:n?[n]:[]).map(e=>e.id).filter(e=>"string"==typeof e&&e.length>0))),[n,c,m]),B=l.useMemo(()=>JSON.stringify([...$].sort()),[$]);l.useEffect(()=>{let s=JSON.parse(B);if(!e||0===s.length){f(null),k(null),v(!1);return}let t=new AbortController;return f(null),k(null),v(!0),fetch("/api/assets/delete-impact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetIds:s}),signal:t.signal}).then(async e=>{let s=await e.json().catch(()=>null);if(!e.ok)throw Error("string"==typeof s?.error?s.error:"Could not check asset usage.");return s}).then(e=>{t.signal.aborted||f(e)}).catch(e=>{t.signal.aborted||k(e instanceof Error?e.message:"Could not check asset usage.")}).finally(()=>{t.signal.aborted||v(!1)}),()=>t.abort()},[C,e,B]);let S=l.useRef(null),M=l.useRef(null);if(!n&&!m)return null;let D=e=>{i&&e.preventDefault()},A=!!(m&&m>0),E=A&&1===m?c?.[0]:n,q=E?p(E,a):a,P=!i&&!g&&!j&&!!h,_=A?`Delete ${m} ${1===m?"asset":"assets"}?`:`Delete ${"video"===a?"video asset":"music asset"}?`,O=A?`Delete ${m} ${1===m?"asset":"assets"}`:"Delete asset";return(0,r.jsx)(x.lG,{open:e,onOpenChange:e=>{e||i||s()},children:(0,r.jsxs)(x.Cf,{className:"flex max-h-[min(42rem,calc(100dvh-2rem))] flex-col gap-0 overflow-hidden p-0 sm:max-h-[min(46rem,calc(100dvh-4rem))] sm:max-w-[36rem]",showCloseButton:!i,"aria-busy":i,onOpenAutoFocus:e=>{e.preventDefault(),M.current=document.activeElement instanceof HTMLElement?document.activeElement:null,S.current?.focus()},onCloseAutoFocus:e=>{M.current?.isConnected&&(e.preventDefault(),M.current.focus())},onEscapeKeyDown:D,onInteractOutside:D,onPointerDownOutside:D,children:[(0,r.jsxs)(x.c7,{className:"shrink-0 border-b border-border/70 px-5 py-5 pr-12 text-left sm:px-6 sm:pr-12",children:[(0,r.jsx)(x.L3,{className:"text-lg leading-6",children:_}),(0,r.jsx)(x.rr,{className:"max-w-[46ch] text-sm leading-6",children:"This permanently deletes the selected media from this project. This cannot be undone."})]}),(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:(0,r.jsxs)("div",{className:"space-y-4 px-5 py-5 sm:px-6",children:[E?(0,r.jsx)(w,{asset:E,assetType:q}):A?(0,r.jsx)(b,{bulkAssets:c??[],bulkCount:m??0,fallbackType:a}):null,(0,r.jsx)(N,{impact:h,isLoading:g,error:j,onRetry:()=>T(e=>e+1)})]})}),d?(0,r.jsxs)("div",{role:"alert",className:"shrink-0 border-t border-border px-5 py-3 text-sm text-destructive sm:px-6",children:[(0,r.jsx)("p",{className:"font-medium",children:"Deletion did not finish"}),(0,r.jsxs)("p",{className:"mt-1 [overflow-wrap:anywhere]",children:[d," Review the remaining selection and try again."]})]}):null,(0,r.jsxs)(x.Es,{className:"shrink-0 gap-2 border-t border-border/70 bg-muted/15 px-5 py-4 sm:px-6 sm:justify-end",children:[(0,r.jsx)(u.Button,{ref:S,variant:"outline",onClick:s,disabled:i,className:"h-11 w-full sm:h-9 sm:w-auto
1sm:min-w-24",children:"Cancel"}),(0,r.jsxs)(u.Button,{variant:"destructive",onClick:t,disabled:!P,className:"h-11 w-full gap-2 sm:h-9 sm:w-auto sm:min-w-fit",loading:i,loadingLabel:"Deletingâ¦",children:[(0,r.jsx)(o.A,{"aria-hidden":"true",className:"h-4 w-4"}),O]})]})]})})}}}]);
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.