1import{r as i,j as e}from"./vendor-ui-Cp0o_ERz.js";import{B as p,X as te,y as Da,P as Ys,b as re,E as B,aB as Ve,L as R,k as ie,m as Ma,V as O,h as Fe,d as as,aL as he,an as Pe,a_ as ls,D as Le,e as $e,f as ze,g as Ue,b3 as pe,A as cs,s as C,bK as Ta,b9 as Ea,i as ds,I as Je,l as Ks,bF as Aa,bL as Ia,bM as Ja,u as w,n as Fa,aU as Pa,p as La,bN as xe,bO as Fs,S as $a,w as za,ax as ts,a8 as Ua,aa as Va,bC as Oa,ae as Ba,ab as Ra,ac as qa,ad as Ga,M as Ps,N as Ls,b1 as $s,bi as U,Q as zs,ah as Te,C as Wa,bD as Ya,bE as Ka,a as Ha,bl as Qa,bm as Xa,bn as Za,bo as V,aJ as et,bp as rs,R as st,T as at,W as tt,Y as rt,Z as it,a1 as nt,a2 as ot,a3 as lt,v as Ee,bP as ct,bQ as Ae}from"./index-U2qI6hth.js";import{C as is}from"./GroupedChipsFilter-DI9fmjR3.js";import{i as dt,a as mt,C as Us}from"./calendar-C5a4LOnb.js";import{b as Hs,u as ut}from"./vendor-react-DblKtrgV.js";import{G as ns}from"./GatedLink-DTpVqoQr.js";import{u as xt,J as ht,V as pt,A as gt}from"./AddCaptionsDialog-uCzQdNAc.js";import{A as ms,m as k}from"./vendor-motion-P7V77m0j.js";import{C as Qs}from"./captions-Jl7uQFwd.js";import{T as Xs}from"./trash-2-DQl3agPF.js";import{u as Zs,E as ft}from"./ExportPaywallModal-CvGvgPF1.js";import{P as yt}from"./party-popper-Bn_bBaqg.js";import{S as wt}from"./share-2-sIo8QWxu.js";import{u as vt}from"./useInfiniteScroll-C1wiIFT3.js";import{u as Nt,V as bt}from"./VerificationGateModal-D2QlibYm.js";import{L as jt}from"./linkedin-DMSC3g_Z.js";import{d as Vs}from"./downloadVideo-CcFVfqem.js";import{L as Ct}from"./layout-grid-dauEaVt9.js";import{L as kt}from"./list-CIgYnwL5.js";import{S as St}from"./square-check-big-BKtbrZi_.js";import{F as os}from"./folder-lwIccgZL.js";import{E as _t}from"./ellipsis-vertical-KqAMxaYO.js";import{F as Dt}from"./folder-minus-BxZgk_N8.js";import{F as Ie}from"./folder-plus-aD75zgJE.js";import"./vendor-charts-BTyV52R2.js";import"./vendor-query-Bv5ntzP6.js";import"./vendor-supabase-B0Jha54I.js";import"./actorFilterOptions-Bmyj_sBg.js";import"./startOfMonth-l-9f0XA8.js";import"./endOfWeek-BwrvE8dj.js";import"./usePreviewSound-DHm0GOB2.js";import"./VideoThumbnail-DEAuBjaq.js";import"./videoLocalCheck-xBq4jzmV.js";import"./wand-sparkles-hf8mXBjZ.js";import"./separator-CFU9jP8U.js";import"./label-CthT-n7x.js";import"./textarea-CJ3wtdnc.js";import"./useSocialConnections-TJHKmiDS.js";import"./coins-4cOuNMfH.js";import"./youtube-PVhoke2O.js";import"./music-Dh-ZwRdO.js";import"./crown-lZaTKUKT.js";import"./featureFlags-DhS8K_vw.js";import"./toggle-group-CCbRO1kH.js";import"./toggle-CSwWOykv.js";import"./useEmailVerification-BQjKZgSy.js";const Mt=3e4;function Tt({jobs:r,onDismiss:d}){const c=i.useMemo(()=>{const n=[...r].sort((x,m)=>new Date(m.created_at).getTime()-new Date(x.created_at).getTime()),u=[];let h=[],f=null;for(const x of n){const m=new Date(x.created_at);f?Math.abs(f.getTime()-m.getTime())<=Mt?h.push(x):(h.length>1&&h.some(D=>["queued","processing","generating","rendering"].includes(D.status))&&u.push(Os(h,f)),f=m,h=[x]):(f=m,h=[x])}return h.length>1&&h.some(m=>["queued","processing","generating","rendering"].includes(m.status))&&f&&u.push(Os(h,f)),u},[r]);return c.length===0?null:e.jsx("div",{className:"space-y-3",children:e.jsx(ms,{mode:"popLayout",children:c.map(n=>e.jsxs(k.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10,scale:.95},className:"relative bg-gradient-to-r from-primary/10 via-primary/5 to-transparent border border-primary/20 rounded-xl p-4",children:[d&&e.jsx(p,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>d(n.id),children:e.jsx(te,{className:"w-3 h-3"})}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Da,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"Batch Generation"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.totalJobs," videos"]})]}),e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(Ys,{value:n.averageProgress,className:"h-2 flex-1"}),e.jsx("span",{className:"ml-2 text-xs text-muted-foreground whitespace-nowrap",children:n.averageProgress<100?`~${Math.max(1,Math.ceil((100-n.averageProgress)*n.processingJobs*.03))}m`:"Done"})]})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.jobs.map(u=>e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-lg bg-secondary/50 border border-border",children:[e.jsx("div",{className:"w-5 h-5 rounded-full overflow-hidden flex-shrink-0 bg-secondary",children:u.actor?.image_url?e.jsx("img",{src:u.actor.image_url,alt:u.actor.name||"Actor",className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-primary/20"})}),e.jsx("span",{className:"text-xs font-medium truncate max-w-[80px]",children:u.actor?.name||`Job #${u.id.slice(0,4)}`}),e.jsx(Et,{status:u.status,progress:u.progress})]},u.id))}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 text-xs text-muted-foreground",children:[n.completedJobs>0&&e.jsxs("span",{className:"flex items-center gap-1 text-green-500",children:[e.jsx(re,{className:"w-3 h-3"}),n.completedJobs," completed"]}),n.processingJobs>0&&e.jsxs("span",{className:"flex items-center gap-1 text-primary",children:[e.jsx(B,{className:"w-3 h-3"}),n.processingJobs," in progress"]}),n.failedJobs>0&&e.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[e.jsx(Ve,{className:"w-3 h-3"}),n.failedJobs," failed"]})]})]})]})]},n.id))})})}function Os(r,d){const c=r.filter(x=>x.status==="completed"||x.status==="ready").length,n=r.filter(x=>x.status==="failed").length,u=r.filter(x=>["queued","processing","generating","rendering"].includes(x.status)).length,h=r.reduce((x,m)=>m.status==="completed"||m.status==="ready"?x+100:m.status==="failed"?x+0:x+(m.progress||0),0),f=Math.round(h/r.length);return{id:`batch-${d.getTime()}`,jobs:r,startTime:d,totalJobs:r.length,completedJobs:c,failedJobs:n,processingJobs:u,averageProgress:f}}function Et({status:r,progress:d}
1){if(r==="completed"||r==="ready")return e.jsx(re,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0"});if(r==="failed")return e.jsx(Ve,{className:"w-3.5 h-3.5 text-destructive flex-shrink-0"});const c=Math.max(1,Math.ceil((100-d)*.05));return e.jsxs("div",{className:"relative flex items-center justify-center flex-shrink-0 group",children:[e.jsxs("div",{className:"relative w-4 h-4",children:[e.jsx(k.div,{className:"absolute inset-0 rounded-full border border-primary/30",animate:{scale:[1,1.2,1],opacity:[.5,.2,.5]},transition:{duration:1.5,repeat:1/0}}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold text-primary",children:[d,"%"]})]}),e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1 px-2 py-1 bg-popover border border-border rounded text-[10px] text-muted-foreground whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10",children:["~",c,"m remaining"]})]})}const At=["queued","processing","generating","rendering","pending"];function It(r){if(r.status==="captioning")return!0;if(r.status!=="ready")return!1;const d=r.result_urls;if(!d)return!1;const c=d.zapcap_status;return c==="processing"||c==="pending"}function Jt({jobs:r,className:d}){const{generatingJobs:c,captioningJobs:n}=i.useMemo(()=>{const m=[],g=[];for(const y of r)At.includes(y.status)?m.push(y):It(y)&&g.push(y);return m.sort((y,D)=>new Date(D.created_at).getTime()-new Date(y.created_at).getTime()),g.sort((y,D)=>new Date(D.created_at).getTime()-new Date(y.created_at).getTime()),{generatingJobs:m,captioningJobs:g}},[r]),u=[...c,...n];if(u.length===0)return null;const h=c.length>0,f=n.length>0,x=h&&f?"Processing":f?"Adding Captions":"Generating Now";return e.jsxs(k.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:Ma("space-y-3",d),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k.div,{animate:{rotate:360},transition:{duration:2,repeat:1/0,ease:"linear"},children:e.jsx(R,{className:"w-4 h-4 text-primary"})}),e.jsx("span",{className:"text-sm font-medium",children:x})]}),e.jsxs(ie,{variant:"secondary",className:"bg-primary/10 text-primary text-xs animate-pulse",children:[u.length," ",u.length===1?"video":"videos"]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3",children:e.jsxs(ms,{mode:"popLayout",children:[c.map((m,g)=>e.jsx(Ft,{job:m,index:g},m.id)),n.map((m,g)=>e.jsx(Pt,{job:m,index:c.length+g},m.id))]})})]})}function Ft({job:r,index:d}){const c=r.actor?.image_url,n=r.actor?.name||`Video #${r.id.slice(0,6)}`,u=Math.max(1,Math.ceil((100-r.progress)*.03)),h={queued:"Queued",pending:"Pending",generating:"Generating",processing:"Processing",rendering:"Rendering"};return e.jsxs(k.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95,transition:{duration:.2}},transition:{delay:d*.05},className:"relative aspect-square rounded-xl overflow-hidden border-2 border-primary/30 bg-gradient-to-br from-primary/5 to-primary/10",children:[e.jsxs("div",{className:"absolute inset-0",children:[c?e.jsx("img",{src:c,alt:n,className:"w-full h-full object-cover blur-[2px] scale-105",loading:"lazy",crossOrigin:"anonymous"}):e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/20 to-accent/20 flex items-center justify-center",children:e.jsx(O,{className:"w-12 h-12 text-primary/30"})}),e.jsx("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-[2px]"})]}),e.jsxs("div",{className:"relative z-10 h-full flex flex-col items-center justify-center p-3 text-center",children:[e.jsxs("div",{className:"relative mb-3",children:[e.jsx(k.div,{className:"w-14 h-14 rounded-full border-2 border-primary/30",animate:{scale:[1,1.15,1],opacity:[.5,.2,.5]},transition:{duration:2,repeat:1/0}}),e.jsx(k.div,{className:"absolute inset-0 w-14 h-14 rounded-full border-[3px] border-t-primary border-r-transparent border-b-transparent border-l-transparent",animate:{rotate:360},transition:{duration:1.2,repeat:1/0,ease:"linear"}}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("span",{className:"text-lg font-bold text-primary",children:[r.progress,"%"]})})]}),e.jsx("p",{className:"text-sm font-medium text-foreground truncate max-w-full mb-1",children:n}),e.jsx(ie,{variant:"outline",className:"text-[10px] px-2 py-0.5 bg-primary/10 border-primary/30 text-primary mb-2",children:h[r.status]||r.status}),e.jsx("div",{className:"w-full px-2",children:e.jsx(Ys,{value:r.progress,className:"h-1.5"})}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 text-[10px] text-muted-foreground",children:[e.jsx(B,{className:"w-3 h-3"}),e.jsxs("span",{children:["~",u,"m remaining"]})]})]}),e.jsx(k.div,{className:"absolute top-2 right-2",animate:{rotate:[0,10,-10,0],scale:[1,1.1,1]},transition:{duration:3,repeat:1/0},children:e.jsx(Fe,{className:"w-4 h-4 text-primary/50"})})]})}function Pt({job:r,index:d}){const c=r.actor?.image_url;r.result_urls?.url;const u=r.actor?.name||`Video #${r.id.slice(0,6)}`;return e.jsxs(k.div,{initial:{opacity:0,scale:.95}
1,animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95,transition:{duration:.2}},transition:{delay:d*.05},className:"relative aspect-square rounded-xl overflow-hidden border-2 border-amber-400/40 bg-gradient-to-br from-amber-500/5 to-amber-600/10",children:[e.jsxs("div",{className:"absolute inset-0",children:[c?e.jsx("img",{src:c,alt:u,className:"w-full h-full object-cover scale-105",loading:"lazy",crossOrigin:"anonymous"}):e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-amber-500/20 to-amber-600/20 flex items-center justify-center",children:e.jsx(O,{className:"w-12 h-12 text-amber-500/30"})}),e.jsx("div",{className:"absolute inset-0 bg-background/60"})]}),e.jsxs("div",{className:"relative z-10 h-full flex flex-col items-center justify-center p-3 text-center",children:[e.jsx(k.div,{className:"mb-3 w-14 h-14 rounded-full bg-amber-500/15 border-2 border-amber-400/40 flex items-center justify-center",animate:{scale:[1,1.08,1],opacity:[.8,1,.8]},transition:{duration:1.5,repeat:1/0},children:e.jsx(Qs,{className:"w-7 h-7 text-amber-500"})}),e.jsx("p",{className:"text-sm font-medium text-foreground truncate max-w-full mb-1",children:u}),e.jsx(ie,{variant:"outline",className:"text-[10px] px-2 py-0.5 bg-amber-500/10 border-amber-400/40 text-amber-600 dark:text-amber-400 mb-2",children:"Adding Captions"}),e.jsx("div",{className:"w-full px-2",children:e.jsx("div",{className:"h-1.5 rounded-full bg-amber-500/20 overflow-hidden",children:e.jsx(k.div,{className:"h-full w-1/3 rounded-full bg-amber-500/60",animate:{x:["-100%","400%"]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"}})})}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 text-[10px] text-muted-foreground",children:[e.jsx(B,{className:"w-3 h-3"}),e.jsx("span",{children:"~1-2 min"})]})]})]})}function Lt({count:r=8}){return e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3",children:Array.from({length:r}).map((d,c)=>e.jsx("div",{className:"aspect-square rounded-xl overflow-hidden border border-border bg-secondary/30",style:{animationDelay:`${c*50}ms`},children:e.jsxs("div",{className:"relative w-full h-full",children:[e.jsx(as,{className:"w-full h-full"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3 bg-gradient-to-t from-muted/80 to-transparent",children:[e.jsx(as,{className:"h-4 w-2/3 mb-1"}),e.jsx(as,{className:"h-3 w-1/3"})]})]})},c))})}function $t({selectedCount:r,totalCount:d,onSelectAll:c,onClearSelection:n,onBulkDelete:u,onBulkDownload:h,onBulkMoveToCampaign:f,isDeleting:x=!1,isDownloading:m=!1,isMoving:g=!1}){return e.jsx(ms,{children:r>0&&e.jsx(k.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},className:"fixed bottom-4 pb-[env(safe-area-inset-bottom)] inset-x-0 mx-auto z-[80] w-[95%] max-w-xl",children:e.jsxs("div",{className:"flex items-center justify-between gap-1.5 sm:gap-2 px-3 sm:px-4 py-2.5 sm:py-3 rounded-xl bg-secondary/95 backdrop-blur-xl border border-border shadow-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx(p,{variant:"ghost",size:"icon",className:"h-7 w-7 sm:h-8 sm:w-8",onClick:n,children:e.jsx(te,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[r," selected"]}),r<d&&e.jsxs("button",{onClick:c,className:"text-xs text-primary hover:underline text-left",children:["Select all ",d]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[f&&e.jsxs(p,{variant:"outline",size:"sm",onClick:f,disabled:g,className:"gap-1.5",children:[g?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsx(he,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:h,disabled:m,className:"gap-1.5",children:[m?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsx(Pe,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Download"})]}),e.jsxs(p,{variant:"destructive",size:"sm",onClick:u,disabled:x,className:"gap-1.5",children:[x?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsx(Xs,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})]})]})})})}function zt({open:r,onOpenChange:d,videoId:c,videoTitle:n="Your Video",onShare:u,onDownload:h}){const f=Hs(),{canExport:x}=Zs(),[m,g]=i.useState(null);i.useEffect(()=>{async function M(){const{data:j}
1=await C.from("site_campaigns").select("discount_percent, code").eq("is_active",!0).eq("applies_to_packs",!0).limit(1).maybeSingle();j&&g({discount_percent:j.discount_percent,code:j.code})}M()},[]),i.useEffect(()=>{if(r){const j=Date.now()+2e3,G=["#f59e0b","#f97316","#22c55e","#3b82f6"];(function us(){ls({particleCount:3,angle:60,spread:55,origin:{x:0},colors:G}),ls({particleCount:3,angle:120,spread:55,origin:{x:1},colors:G}),Date.now()<j&&requestAnimationFrame(us)})()}},[r]);const y=()=>{d(!1),c&&u&&u(c)},D=()=>{d(!1),c&&h&&h(c)},L=()=>{d(!1),f("/create")},$=()=>{d(!1);const M=new URLSearchParams({from:"celebration"});m?.code&&M.set("code",m.code),f(`/pricing?${M.toString()}#credit-packs`)},q=m?`Get credit packs at ${m.discount_percent}% off â only for new creators`:"Special pricing for new creators",H=m?`Claim ${m.discount_percent}% Off`:"View Special Pricing",ne=[{icon:wt,label:"Share to earn 10 free credits",description:"Post to TikTok, Reels & earn rewards",onClick:y},{icon:x?Pe:pe,label:"Download your video",description:x?"Save to your device":"Upgrade to download",onClick:D},{icon:O,label:"Create more videos",description:"Try different actors & styles",onClick:L}];return e.jsx(Le,{open:r,onOpenChange:d,children:e.jsxs($e,{className:"sm:max-w-md p-0 overflow-hidden border-green-500/30",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-green-500 via-emerald-500 to-teal-500 p-6 pb-8 text-white text-center",children:[e.jsxs(ze,{children:[e.jsx(k.div,{initial:{scale:0,rotate:-180},animate:{scale:1,rotate:0},transition:{type:"spring",delay:.1,bounce:.5},className:"flex justify-center mb-3",children:e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-white/20 backdrop-blur-sm flex items-center justify-center",children:e.jsx(yt,{className:"w-8 h-8"})})}),e.jsx(Ue,{className:"text-2xl font-display text-white",children:"Congratulations! ð"})]}),e.jsxs(k.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2},children:[e.jsx("p",{className:"text-white/90 mt-2",children:"You just created your first AI video!"}),e.jsxs(ie,{className:"mt-3 bg-white/20 text-white border-white/30",children:[e.jsx(re,{className:"w-3 h-3 mr-1"}),"Video Ready"]})]}),e.jsx("div",{className:"absolute top-4 left-4 w-12 h-12 rounded-full bg-white/10 blur-xl"}),e.jsx("div",{className:"absolute bottom-4 right-4 w-20 h-20 rounded-full bg-white/10 blur-2xl"})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsxs(k.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.3},className:"flex items-center gap-3 p-3 rounded-lg bg-green-500/10 border border-green-500/20",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-green-500/20 flex items-center justify-center",children:e.jsx(Fe,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Achievement Unlocked!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"First Video Creator"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"What's Next?"}),e.jsx("div",{className:"space-y-2",children:ne.map((M,j)=>e.jsxs(k.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.4+j*.1},className:"flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/50 transition-colors cursor-pointer w-full text-left",onClick:M.onClick,children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(M.icon,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:M.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M.description})]}),e.jsx(cs,{className:"w-4 h-4 text-muted-foreground"})]},M.label))})]}),e.jsxs(k.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:.6},className:"p-3 rounded-lg bg-gradient-to-r from-amber-500/10 to-orange-500/10 border border-amber-500/20",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"ð¥ Limited-Time Offer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:q}),e.jsxs(p,{size:"sm",className:"w-full mt-2 bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white border-0",onClick:$,children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),H]})]}),e.jsx("div",{className:"space-y-2 pt-1",children:e.jsxs(p,{variant:"outline",className:"w-full",onClick:()=>d(!1),children:["Keep Exploring",e.jsx(cs,{className:"w-4 h-4 ml-2"})]})}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"You're off to a great start! ð"})]})]})})}const Bs="firstVideoCelebrated";function Ut(r){const[d,c]=i.useState(!1),[n,u]=i.useState(),h=r?`${Bs}_${r}`:Bs,f=()=>localStorage.getItem(h)==="true";return{showCelebration:d,setShowCelebration:c,celebrationVideoId:n,triggerCelebration:m=>{f()||(u(m),c(!0),localStorage.setItem(h,"true"))},hasCelebrated:f()}}const Rs=[5,10],qs="referral_nudges_shown",Gs="referral_nudge_last_check";function Vt(r){const[d,c]=i.useState(!1),[n,u]=i.useState(null),h=i.useCallback(()=>{try{const g=localStorage.getItem(qs);return g?JSON.parse(g):[]}catch{return[]}},[]),f=i.useCallback(g=>{const y=h();for(const D of Rs)if(g===D&&!y.includes(D))return!0;return!1},[h]),x=i.useCallback(g=>{try{const y=h();
1y.includes(g)||(y.push(g),localStorage.setItem(qs,JSON.stringify(y)))}catch(y){console.error("Failed to save nudge state:",y)}},[h]),m=i.useCallback(()=>{n!==null&&x(n),c(!1),u(null)},[n,x]);return i.useEffect(()=>{if(r<=0)return;const g=localStorage.getItem(Gs),y=Date.now();if(g&&y-parseInt(g,10)<5*60*1e3)return;const D=h();for(const L of Rs)if(r===L&&!D.includes(L)){const $=setTimeout(()=>{c(!0),u(L),localStorage.setItem(Gs,y.toString())},3e3);return()=>clearTimeout($)}},[r,h]),{shouldShowNudge:d,currentMilestone:n,dismissNudge:m,markNudgeShown:x,checkForNudge:f}}function Ot({isOpen:r,onClose:d,completedCount:c}){const[n,u]=i.useState(!1),{partner:h,loading:f,joining:x,joinProgram:m}=Ta(),g=h?.referral_code||"",y=`https://vidacious.ai/?ref=${g}`;i.useEffect(()=>{if(r){const j=setTimeout(()=>{ls({particleCount:60,spread:55,origin:{y:.7},colors:["#f59e0b","#8b5cf6","#10b981"]})},300);return()=>clearTimeout(j)}},[r]);const D=async()=>{try{await navigator.clipboard.writeText(y),u(!0),w.success("Link copied to clipboard!"),setTimeout(()=>u(!1),2e3)}catch{w.error("Failed to copy link")}},L=async()=>{try{await m()}catch{}},$=`Just created my ${c}th AI video with Vidacious! ð¬ Create professional videos in minutes. Sign up with my link for bonus credits!`,q=()=>{const j=`https://twitter.com/intent/tweet?text=${encodeURIComponent($)}&url=${encodeURIComponent(y)}`;window.open(j,"_blank","noopener,noreferrer"),d()},H=()=>{const j=`https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(y)}&title=${encodeURIComponent("Create AI Videos with Vidacious")}&summary=${encodeURIComponent($)}`;window.open(j,"_blank","noopener,noreferrer,width=600,height=600"),d()},ne=()=>{const j=`https://wa.me/?text=${encodeURIComponent(`${$} ${y}`)}`;window.open(j,"_blank","noopener,noreferrer"),d()},M=()=>{switch(c){case 5:return"5 videos created! You're on fire!";case 10:return"10 videos! You're a pro!";default:return`Video #${c} complete!`}};return e.jsx(Le,{open:r,onOpenChange:j=>!j&&d(),children:e.jsxs($e,{className:"sm:max-w-md",children:[e.jsxs("button",{onClick:d,className:"absolute right-4 top-4 roun
1ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[e.jsx(te,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),e.jsxs(ze,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gradient-to-br from-amber-400 to-orange-500",children:e.jsx(Ea,{className:"h-8 w-8 text-white"})}),e.jsxs(Ue,{className:"text-xl",children:["ð¬ ",M()]}),e.jsxs(ds,{className:"text-center pt-2",children:["Share Vidacious with friends â ",e.jsx("strong",{children:"you earn 5 credits"})," and"," ",e.jsx("span",{className:"text-primary font-semibold",children:"they get bonus credits"})," when they sign up!"]})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[!h&&!f?e.jsx("div",{className:"text-center space-y-4",children:e.jsxs("div",{className:"p-4 rounded-lg bg-primary/5 border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx(Fe,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Join the Partner Program"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Get your unique referral link to start earning credits"}),e.jsx(p,{onClick:L,disabled:x,className:"w-full",children:x?"Joining...":e.jsxs(e.Fragment,{children:["Get My Referral Link",e.jsx(cs,{className:"h-4 w-4 ml-2"})]})})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Je,{value:f?"Loading...":y,readOnly:!0,className:"font-mono text-sm"}),e.jsx(p,{variant:"outline",size:"icon",onClick:D,disabled:f||!g,children:n?e.jsx(Ks,{className:"h-4 w-4 text-primary"}):e.jsx(Aa,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(p,{variant:"outline",className:"flex-1",onClick:q,disabled:f||!g,children:[e.jsx(Ia,{className:"h-4 w-4 mr-2"}),"X"]}),e.jsxs(p,{variant:"outline",className:"flex-1",onClick:H,disabled:f||!g,children:[e.jsx(jt,{className:"h-4 w-4 mr-2"}),"LinkedIn"]}),e.jsxs(p,{variant:"outline",className:"flex-1",onClick:ne,disabled:f||!g,children:[e.jsx(Ja,{className:"h-4 w-4 mr-2"}),"WhatsApp"]})]})]}),e.jsx(p,{variant:"ghost",className:"w-full text-muted-foreground",onClick:d,children:"Maybe Later"})]})]})})}const Ws={ready:{label:"Completed",icon:re,color:"text-green-500 bg-green-500/10"},completed:{label:"Completed",icon:re,color:"text-green-500 bg-green-500/10"},processing:{label:"Processing",icon:B,color:"text-primary bg-primary/10"},generating:{label:"Generating",icon:B,color:"text-primary bg-primary/10"},rendering:{label:"Rendering",icon:B,color:"text-primary bg-primary/10"},queued:{label:"Queued",icon:B,color:"text-yellow-500 bg-yellow-500/10"},failed:{label:"Failed",icon:Ve,color:"text-destructive bg-destructive/10"}};function Pr(){const[r,d]=ut(),c=Hs(),{profile:n}=Fa(),{isBannerVisible:u}=Pa(),{showCelebration:h,setShowCelebration:f,celebrationVideoId:x,triggerCelebration:m,hasCelebrated:g}=Ut(n?.user_id),{isModalOpen:y,pendingAction:D,email:L,closeModal:$,checkAndGate:q}=Nt(),{checkExport:H,isPaywallOpen:ne,paywallAction:M,closePaywall:j,canExport:G}=Zs(),{subscription:us}=La(),[v,T]=i.useState([]),[ge,Oe]=i.useState([]),[J,xs]=i.useState(!0),[Q,hs]=i.useState(!1),[X,Be]=i.useState(0),[fe,Re]=i.useState(0),ps=20,[Z,qe]=i.useState(""),[z,Ge]=i.useState("all"),[b,ee]=i.useState(void 0),[S,se]=i.useState(void 0),[W,gs]=i.useState("newest"),[ea,fs]=i.useState(!1),[ye,ys]=i.useState("grid"),[We,we]=i.useState(null),[_,Ye]=i.useState(new Set),[Y,oe]=i.useState(!1),[sa,ws]=i.useState(!1),[aa,vs]=i.useState(!1),[F,K]=i.useState(null),[ta,Ns]=i.useState(!1),[ra,ve]=i.useState(!1),[le,Ne]=i.useState(""),[be,je]=i.useState(!1),[ia,Ce]=i.useState(!1),[bs,js]=i.useState(!1),[na,ke]=i.useState(!1),[ce,Se]=i.useState(""),[Cs,_e]=i.useState(null),[ks,De]=i.useState(null),[oa,la]=i.useState(()=>r.get("share_cta")==="prominent");i.useEffect(()=>{if(r.get("share_cta")){const s=new URLSearchParams(r);s.delete("share_cta"),d(s,{replace:!0})}},[]);const Ke=r.get("jobId");i.useEffect(()=>{if(!Ke||J||v.length===0)return;const s=v.find(t=>
1t.id===Ke);if(s){we(s);const t=new URLSearchParams(r);t.delete("jobId"),d(t,{replace:!0})}},[Ke,J,v]),i.useEffect(()=>{n?.user_id&&C.functions.invoke("track-education-event",{body:{event_name:"export_page_viewed",payload:{video_count:v.length}}}).catch(()=>{})},[n?.user_id]);const Ss=i.useMemo(()=>v.filter(s=>s.status==="ready"||s.status==="completed").length,[v]),{shouldShowNudge:ca,currentMilestone:da,dismissNudge:ma}=Vt(Ss);i.useMemo(()=>v.some(s=>s.status==="ready"||s.status==="completed"),[v]);const ua=i.useCallback((s,t)=>{T(a=>a.map(o=>o.id===s?{...o,...t}:o))},[]);xt({jobs:v,onJobUpdate:ua,enabled:!J&&v.length>0}),i.useEffect(()=>{(async()=>{if(!n?.user_id)return;const{data:t,error:a}=await C.from("campaigns").select("*").eq("user_id",n.user_id).order("name");a||Oe(t||[])})()},[n?.user_id]);const de=i.useCallback(async(s,t=!1)=>{if(n?.user_id){t?hs(!0):xs(!0);try{let a=C.from("jobs").select(` 2 id, 3 status, 4 progress, 5 created_at, 6 actor_id, 7 campaign_id, 8 result_urls, 9 branding_settings, 10 output_formats, 11 actors(id, name, image_url), 12 campaigns(id, name) 13 `,{count:"exact"}
13).eq("user_id",n.user_id);z!=="all"&&(a=a.eq("status",z)),b&&(a=a.gte("updated_at",xe(b).toISOString())),S&&(a=a.lte("updated_at",Fs(S).toISOString())),a=a.order("created_at",{ascending:W==="oldest"}).range(s,s+ps-1);const{data:o,error:l,count:N}=await a;if(l)throw l;const P=(o||[]).map(I=>({...I,actor:I.actors,campaign:I.campaigns,script:I.scripts}));T(t?I=>[...I,...P]:P),Be(N||0),Re(s+(o?.length||0))}catch(a){console.error("Error fetching exports:",a),w.error("Failed to load exports")}finally{xs(!1),hs(!1)}}},[n?.user_id,z,W,b,S,ps]),He=i.useCallback(()=>{Q||J||fe>=X||de(fe,!0)},[Q,J,fe,X,de]),Qe=fe<X,{sentinelRef:xa}=vt({onLoadMore:He,hasMore:Qe,isLoading:Q,rootMargin:"400px"});i.useEffect(()=>{T([]),Re(0),de(0,!1)},[n?.user_id,z,W,b,S]),i.useEffect(()=>{if(!n?.user_id)return;const s=C.channel("exports-realtime").on("postgres_changes",{event:"*",schema:"public",table:"jobs",filter:`user_id=eq.${n.user_id}`},async t=>{if(t.eventType==="INSERT"){const a=t.new;let o={...a};if(a.actor_id){const{data:l}=await C.from("actors").select("*").eq("id",a.actor_id).single();l&&(o.actor=l)}T(l=>[o,...l]),Be(l=>l+1),w.success("New job started!")}else if(t.eventType==="UPDATE"){const a=t.new;T(o=>o.map(l=>l.id===a.id?{...l,...a}:l))}else if(t.eventType==="DELETE"){const a=t.old;T(o=>o.filter(l=>l.id!==a.id)),Be(o=>Math.max(0,o-1))}}).subscribe();return()=>{C.removeChannel(s)}},[n?.user_id]);const ha=["queued","processing","generating","rendering","pending"],A=i.useMemo(()=>v.filter(s=>{if(ha.includes(s.status)||s.status==="captioning")return!1;if(s.status==="ready"){const I=s.result_urls?.zapcap_status;if(I==="processing"||I==="pending")return!1}const t=Z.toLowerCase(),a=!Z||s.actor?.name?.toLowerCase().includes(t)||s.id.toLowerCase().includes(t),o=new Date(s.created_at),l=!b||dt(o,xe(b)),N=!S||mt(o,Fs(S));return a&&l&&N}),[v,Z,b,S]),Xe=s=>s.result_urls?.video_url||null,pa=s=>{const t=s.result_urls;return t?.captioned_storage_path||t?.storage_path||null},E=s=>{const t=s.result_urls,a=s.branding_settings;return t?.is_watermarked===!0||a?.is_free_trial===!0},_s=async s=>{if(Ee("video_download_attempted",{video_id:s.id,is_paid_user:G,will_show_paywall:!G}),!q("download"))return;if(E(s)){c("/pricing");return}if(!H("download",s.id))return;if(!Xe(s)){w.error("No video available for download");return}w.info("Starting download..."),await Vs({jobId:s.id,displayName:s.actor?.name||"video",supabaseClient:C,onSuccess:()=>w.success("Download started!"),onError:a=>{console.error("Download error:",a),a.toLowerCase().includes("upgrade")?c("/pricing"):w.error("Failed to download video",{description:a})}})},Ds=async(s,t,a)=>{if(Ee("video_share_attempted",{video_id:a?.id||null,share_method:"copy_link",is_paid_user:G,will_show_paywall:!G}),!q("share"))return;if(a&&E(a)){c("/pricing");return}if(!H("share",a?.id))return;const o=ct(s,t)||s;try{await navigator.clipboard.writeText(o),w.success("Link copied!",{icon:e.jsx(Ks,{className:"w-4 h-4"})})}catch{w.error("Failed to copy link")}},[me,Ze]=i.useState(null),Ms=s=>{Ze(s)},ga=async()=>{if(me)try{const{error:s}=await C.from("jobs").delete().eq("id",me);if(s)throw s;T(v.filter(t=>t.id!==me)),w.success("Export deleted"),Ee("video_deleted",{video_id:me,videos_remaining_count:v.length-1})}catch(s){console.error("Error deleting export:",s),w.error("Failed to delete export")}finally{Ze(null)}},Ts=async s=>{const t=v.find(o=>o.id===s);if(!t?.actor_id){w.error("Cannot retry: missing actor information");return}try{const{data:o,error:l}=await C.from("jobs").select("*, scripts:script_id(content, tone)").eq("id",s).single();if(l)throw l;const N={actorId:o.actor_id,scriptContent:o.scripts?.content||null,tone:o.scripts?.tone||null,voiceSettings:o.voice_settings||null,outputFormats:o.output_formats||null,campaignId:o.campaign_id||null,brandingSettings:o.branding_settings||null};sessionStorage.setItem("retryJobData",JSON.stringify(N))}catch(o){console.warn("Could not fetch full job for retry, falling back to actorId only:",o)}const a=new URLSearchParams;a.set("actorId",t.actor_id),a.set("retry","1"),window.location.href=`/create?${a.toString()}`},es=(s,t,a,o,l)=>{const N=A.find(P=>P.result_urls?.video_url===s);N&&(we(N),Ee("video_previewed",{video_id:N.id}))},fa=async s=>{if(F){Ns(!0);try{const{error:t}=await C.from("jobs").update({campaign_id:s}).eq("id",F);if(t)throw t;const a=ge.find(o=>o.id===s);T(o=>o.map(l=>l.id===F?{...l,campaign_id:s,campaign:a}:l)),w.success(`Moved to "${a?.name}"`),K(null)}catch(t){console.error("Error moving job to campaign:",t),w.error("Failed to move job")}finally{Ns(!1)}}},Es=async()=>
13{if(!n?.user_id||!le.trim()){w.error("Please enter a campaign name");return}je(!0);try{const{data:s,error:t}=await C.from("campaigns").insert({user_id:n.user_id,name:le.trim(),platform:"tiktok",language:"en",status:"draft"}).select().single();if(t)throw t;if(F){const{error:a}=await C.from("jobs").update({campaign_id:s.id}).eq("id",F);if(a)throw a;T(o=>o.map(l=>l.id===F?{...l,campaign_id:s.id,campaign:s}:l))}Oe(a=>[s,...a]),w.success(`Created "${s.name}" and moved video`),K(null),Ne(""),ve(!1)}catch(s){console.error("Error creating campaign:",s),w.error("Failed to create campaign")}finally{je(!1)}},As=async()=>{if(!n?.user_id||!ce.trim()){w.error("Please enter a campaign name");return}je(!0);try{const{data:s,error:t}=await C.from("campaigns").insert({user_id:n.user_id,name:ce.trim(),platform:"tiktok",language:"en",status:"draft"}).select().single();if(t)throw t;const a=Array.from(_),{error:o}=await C.from("jobs").update({campaign_id:s.id}).in("id",a);if(o)throw o;T(l=>l.map(N=>_.has(N.id)?{...N,campaign_id:s.id,campaign:s}:N)),Oe(l=>[s,...l]),w.success(`Created "${s.name}" and moved ${_.size} videos`),Ce(!1),Se(""),ke(!1),ae()}catch(s){console.error("Error creating campaign:",s),w.error("Failed to create campaign")}finally{je(!1)}},Is=async s=>{try{const{error:t}=await C.from("jobs").update({campaign_id:null}).eq("id",s);if(t)throw t;T(a=>a.map(o=>o.id===s?{...o,campaign_id:null,campaign:void 0}:o)),w.success("Removed from campaign")}catch(t){console.error("Error removing job from campaign:",t),w.error("Failed to remove from campaign")}},ya=s=>{Ye(t=>{const a=new Set(t);return a.has(s)?a.delete(s):a.add(s),a.size>0&&!Y&&oe(!0),a.size===0&&oe(!1),a})},wa=()=>{const s=A.filter(t=>t.status==="completed"||t.status==="ready").map(t=>t.id);Ye(new Set(s)),oe(!0)},ae=()=>{Ye(new Set),oe(!1)},va=async()=>{if(_.size!==0){ws(!0);try{const{error:s}=await C.from("jobs").delete().in("id",Array.from(_));if(s)throw s;T(v.filter(t=>!_.has(t.id))),w.success(`Deleted ${_.size} videos`),ae()}catch(s){console.error("Error deleting jobs:",s),w.error("Failed to delete some videos")}finally{ws(!1)}}},Na=async()=>{if(!q("bulk_download")||_.size===0)return;vs(!0);const s=v.filter(a=>_.has(a.id));let t=0;for(const a of s)if(Xe(a))try{await Vs({jobId:a.id,displayName:a.actor?.name||"video",supabaseClient:C})&&t++,await new Promise(N=>setTimeout(N,300))}catch(l){console.error("Download failed for job:",a.id,l)}w.success(`Downloaded ${t} videos`),vs(!1),ae()},ba=async s=>{if(_.size!==0){js(!0);try{const t=Array.from(_),{error:a}=await C.from("jobs").update({campaign_id:s}).in("id",t);if(a)throw a;const o=ge.find(l=>l.id===s);T(l=>l.map(N=>_.has(N.id)?{...N,campaign_id:s,campaign:o}:N)),w.success(`Moved ${_.size} videos to "${o?.name}"`),Ce(!1),ae()}catch(t){console.error("Error moving jobs to campaign:",t),w.error("Failed to move some videos")}finally{js(!1)}}},ja=()=>{qe(""),Ge("all"),ee(void 0),se(void 0),gs("newest")},ue=Z||z!=="all"||b||S||W!=="newest",Me=i.useMemo(()=>{let s=0;return z!=="all"&&s++,b&&s++,S&&s++,W!=="newest"&&s++,s},[z,b,S,W]),Ca=[{id:"newest",name:"Newest First"},{id:"oldest",name:"Oldest First"}],Js=[{id:"all",name:"All"},{id:"ready",name:"Completed"},{id:"processing",name:"Processing"},{id:"queued",name:"Queued"},{id:"failed",name:"Failed"}],ka=[{id:"all",name:"All Time"},{id:"today",name:"Today"},{id:"7days",name:"Last 7 Days"},{id:"30days",name:"Last 30 Days"}],Sa=()=>!b&&!S?"all":b&&U(b,"yyyy-MM-dd")===U(new Date,"yyyy-MM-dd")&&!S?"today":b&&U(b,"yyyy-MM-dd")===U(Ae(new Date,7),"yyyy-MM-dd")&&!S?"7days":b&&U(b,"yyyy-MM-dd")===U(Ae(new Date,30),"yyyy-MM-dd")&&!S?"30days":"custom",_a=s=>{switch(s){case"today":ee(xe(new Date)),se(void 0);break;case"7days":ee(xe(Ae(new Date,7))),se(void 0);break;case"30days":ee(xe(Ae(new Date,30))),se(void 0);break;default:ee(void 0),se(void 0)}},ss=v.filter(s=>s.status==="ready"||s.status==="completed").length;return e.jsxs(e.Fragment,{children:[e.jsx($a,{title:"Videos",description:"Download and manage your generated AI videos. Access all your completed videos in one place.",url:"https://vidacious.ai/videos",noIndex:!0}),e.jsxs("div",{className:"bg-background flex overflow-hidden",style:{height:"calc(100vh - var(--campaign-banner-height, 0px) - var(--header-height))",marginTop:"calc(var(--campaign-banner-height, 0px) + var(--header-height))"},children:[e.jsxs("main",{className:"flex-1 lg:ml-64 flex flex-col h-full overflow-hidden",children:[e.jsx("header",{className:"border-b border-border bg-background/50 backdrop-blur-sm flex-shrink-0 z-30",children:e.jsxs("div",{className:"flex items-center justify-between px-4 lg:px-6 py-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl lg:text-2xl font-bold font-display",children:"Videos"}),e.jsx("p",{className:"text-sm text-muted-foreground hidden sm:block",children:"Download and manage your videos"})]}),e.jsx(ns,{to:"/create",action:"create_video",children:e.jsxs(p,{variant:"hero",size:"sm",className:"sm:h-10 sm:px-4",children:[e.jsx(za,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline ml-1",children:"New Video"})]})})]})}),oa&&e.jsxs("div",{className:"mx-4 lg:mx-6 mt-3 px-4 py-3 rounded-lg border border-primary/30 bg-primary/5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ts,{className:"w-4 h-4 text-primary shrink-0"}),e.jsx("p",{className:"text-sm font-medium truncate",children:"Your video is generating! Share it as soon as it's ready."})]}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>la(!1),className:"shrink-0 h-7 w-7 p-0",children:e.jsx(te,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"px-3 sm:px-4 lg:px-6 py-2 sm:py-3 border-b border-border/50 bg-gradient-to-r from-background via-background to-background flex-shrink-0 space-y-1.5 sm:space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("div",{className:"relative group flex-1 min-w-0",children:[e.jsx(Ua,{className:"absolute left-2.5 sm:left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-muted-foreground transition-colors group-focus-within:text-primary"}),e.jsx(Je,{placeholder:"Search...",value:Z,onChange:s=>qe(s.target.value),className:"pl-8 sm:pl-9 pr-8 sm:pr-9 h-8 sm:h-10 text-sm bg-secondary/50 border-border/50 shadow-sm transition-all duration-200 focus:bg-background focus:shadow-[0_0_0_2px_hsl(var(--primary)/0.2)] focus:border-primary/50 hover:border-primary/30 rounded-lg"}),Z&&e.jsx("button",{onClick:()=>qe(""),className:"absolute right-2.5 sm:right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Clear search",children:e.jsx(te,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]}),e.jsxs(Va,{open:ea,onOpenChange:fs,children:[e.jsx(Oa,{asChild:!0,children:e.jsxs(p,{variant:"outline",size:"sm",className:`h-8 sm:h-10 gap-1 sm:gap-2 px-2.5 sm:px-4 roun
13ded-lg border-border/50 bg-secondary/50 shadow-sm transition-all duration-200 hover:bg-secondary hover:border-primary/30 hover:shadow-md flex-shrink-0 ${Me>0?"border-primary/50 bg-primary/5":""}`,children:[e.jsx(Ba,{className:`w-3.5 h-3.5 sm:w-4 sm:h-4 ${Me>0?"text-primary":""}`}),e.jsx("span",{className:"text-sm hidden sm:inline",children:"Sort & Filter"}),Me>0&&e.jsx(ie,{className:"ml-0 sm:ml-0.5 h-4 sm:h-5 min-w-4 sm:min-w-5 p-0 justify-center text-[10px] sm:text-xs bg-primary text-primary-foreground shadow-sm",children:Me})]})}),e.jsxs(Ra,{side:"right",className:"w-[85vw] sm:w-96",children:[e.jsx(qa,{children:e.jsx(Ga,{children:"Sort & Filter"})}),e.jsxs("div",{className:"mt-6 space-y-5 overflow-y-auto max-h-[calc(100vh-120px)] pr-1",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-sm font-semibold text-foreground",children:"Sort By"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ca.map(s=>e.jsx(is,{label:s.name,isSelected:W===s.id,onClick:()=>gs(s.id),compact:!0},s.id))})]}),e.jsx("div",{className:"border-t border-border/50"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-sm font-semibold text-foreground",children:"Status"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Js.map(s=>e.jsx(is,{label:s.name,isSelected:z===s.id,onClick:()=>Ge(s.id),compact:!0},s.id))})]}),e.jsx("div",{className:"border-t border-border/50"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-sm font-semibold text-foreground",children:"Date Range"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ka.map(s=>e.jsx(is,{label:s.name,isSelected:Sa()===s.id,onClick:()=>_a(s.id),compact:!0},s.id))}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(Ps,{children:[e.jsx(Ls,{asChild:!0,children:e.jsxs(p,{variant:"outline",size:"sm",className:"flex-1 justify-start text-left font-normal h-9 text-xs",children:[e.jsx($s,{className:"w-3.5 h-3.5 mr-1.5"}),b?U(b,"MMM d, yyyy"):"From date"]})}),e.jsx(zs,{className:"w-auto p-0",align:"start",children:e.jsx(Us,{mode:"single",selected:b,onSelect:ee,initialFocus:!0,className:"pointer-events-auto"})})]}),e.jsxs(Ps,{children:[e.jsx(Ls,{asChild:!0,children:e.jsxs(p,{variant:"outline",size:"sm",className:"flex-1 justify-start text-left font-normal h-9 text-xs",children:[e.jsx($s,{className:"w-3.5 h-3.5 mr-1.5"}),S?U(S,"MMM d, yyyy"):"To date"]})}),e.jsx(zs,{className:"w-auto p-0",align:"start",children:e.jsx(Us,{mode:"single",selected:S,onSelect:se,initialFocus:!0,className:"pointer-events-auto"})})]})]})]}),ue&&e.jsxs(p,{variant:"outline",onClick:()=>{ja(),fs(!1)},className:"w-full",children:[e.jsx(te,{className:"w-4 h-4 mr-2"}),"Clear All Filters"]})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"h-7 sm:h-9 flex items-center bg-secondary/50 border border-border/50 shadow-sm p-0.5 rounded-lg min-w-0 flex-shrink",children:Js.slice(0,3).map(s=>e.jsx("button",{onClick:()=>Ge(s.id),className:`px-1.5 sm:px-2.5 py-0.5 sm:py-1.5 text-[11px] sm:text-sm rounded-md transition-all whitespace-nowrap ${z===s.id?"bg-background shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:s.name},s.id))}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("p",{className:"text-[10px] sm:text-xs text-muted-foreground mr-1 hidden sm:block",children:[A.length,"/",X]}),e.jsxs("div",{className:"flex bg-secondary/50 border border-border/50 rounded-lg p-0.5 shadow-sm",children:[e.jsx(p,{variant:"ghost",size:"icon",className:`h-6 w-6 rounded-md transition-all duration-200 ${ye==="grid"?"bg-background shadow-sm text-primary":"hover:bg-background/50"}`,onClick:()=>ys("grid"),children:e.jsx(Ct,{className:"w-3 h-3"})}),e.jsx(p,{variant:"ghost",size:"icon",className:`h-6 w-6 rounded-md transition-all duration-200 ${ye==="list"?"bg-background shadow-sm text-primary":"hover:bg-background/50"}`,onClick:()=>ys("list"),children:e.jsx(kt,{className:"w-3 h-3"})})]}),ss>0&&e.jsx(p,{variant:Y?"secondary":"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>Y?ae():oe(!0),"aria-label":Y?"Cancel selection":"Select videos","aria-pressed":Y,children:e.jsx(St,{className:`w-3 h-3 ${Y?"text-primary":""}`})}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>{T([]),Re(0),de(0,!1)},disabled:J,"aria-label":"Refresh videos",children:e.jsx(Te,{className:`w-3 h-3 ${J?"animate-spin":""}`})})]})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground sm:hidden",children:["Showing ",A.length," of ",X," videos"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 lg:px-6 py-4 space-y-6",children:[e.jsx(Jt,{jobs:v}),e.jsx(Tt,{jobs:v}),e.jsxs("div",{className:"hidden sm:grid grid-cols-4 gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-secondary/30 border border-border/30",children:[e.jsx(O,{className:"w-4 h-4 text-muted-foreground hidden sm:block"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total"}),e.jsx("p",{className:"text-lg font-bold font-display leading-tight",children:v.length})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-success/5 border border-success/20",children:[e.jsx(re,{className:"w-4 h-4 text-success hidden sm:block"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Done"}),e.jsx("p",{className:"text-lg font-bold font-display leading-tight text-success",children:ss})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/5 border border-primary/20",children:[e.jsx(B,{className:"w-4 h-4 text-primary hidden sm:block"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"}),e.jsx("p",{className:"text-lg font-bold font-display leading-tight text-primary",children:v.filter(s=>["processing","generating","rendering","queued"].includes(s.status)).length})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-destructive/5 border border-destructive/20",children:[e.jsx(Ve,{className:"w-4 h-4 text-destructive hidden sm:block"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Failed"}),e.jsx("p",{className:"text-lg font-bold font-display leading-tight text-destructive",children:v.filter(s=>s.status==="failed").length})]})]})]}),ye==="grid"?e.jsxs("div",{children:[J?e.jsx(Lt,{count:10}):A.length===0?e.jsxs("div",{className:"text-center py-20",children:[e.jsx(O,{className:"w-16 h-16 text-muted-foreground
13/30 mx-auto mb-4"}),e.jsx("p",{className:"text-lg text-muted-foreground mb-4",children:ue?"No exports match your filters":"No videos yet"}),!ue&&e.jsx(ns,{to:"/create",action:"create_video",children:e.jsx(p,{variant:"hero",children:"Create your first video"})})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 sm:gap-3",children:A.map((s,t)=>e.jsx(ht,{job:s,index:t,onDelete:Ms,onRetry:Ts,onPreview:es,onMoveToCampaign:K,onRemoveFromCampaign:Is,onMoveToDifferentCampaign:K,onViewDetails:a=>we(a),isSelected:_.has(s.id),onToggleSelect:ya,selectionMode:Y,onAddCaptions:(a,o)=>{_e(a),De(o)}},s.id))}),Qe&&!J&&A.length>0&&ye==="grid"&&e.jsx("div",{ref:xa,className:"py-8",children:Q?e.jsx("div",{className:"flex flex-col items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 bg-primary/5 rounded-full",children:[e.jsx(R,{className:"w-4 h-4 animate-spin text-primary"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Loading more videos..."})]})}):e.jsx("div",{className:"flex justify-center",children:e.jsxs(p,{variant:"outline",size:"sm",onClick:He,className:"gap-2 px-6 hover:bg-primary/5 hover:border-primary/30 transition-all",children:[e.jsx(O,{className:"w-4 h-4"}),"Load More Videos"]})})})]}):e.jsxs(Wa,{variant:"elevated",children:[e.jsx(Ya,{children:e.jsxs(Ka,{children:[A.length," Videos"]})}),e.jsxs(Ha,{children:[J?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Te,{className:"w-8 h-8 animate-spin mx-auto mb-4"}),"Loading..."]}):A.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(O,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:ue?"No videos match your filters":"No videos yet"}),!ue&&e.jsx(ns,{to:"/create",action:"create_video",children:e.jsx(p,{variant:"outline",children:"Create your first video"})})]}):e.jsx("div",{className:"space-y-3",children:A.map((s,t)=>{const a=Ws[s.status]||Ws.processing,o=a.icon,l=Xe(s),N=pa(s),P=s.status==="ready"||s.status==="completed";return e.jsxs(k.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.03},onClick:()=>P&&l&&es(l,s.actor?.name),className:`flex items-center gap-4 p-4 rounded-xl bg-secondary/30 hover:bg-secondary/50 transition-colors ${P&&l?"cursor-pointer":""}`,children:[e.jsx("div",{className:"relative w-20 h-14 rounded-lg overflow-hidden flex-shrink-0 bg-gradient-to-br from-primary/20 to-accent/20 flex items-center justify-center",children:l?e.jsx("video",{src:l,className:"w-full h-full object-cover",muted:!0}):s.actor?.image_url?e.jsx("img",{src:s.actor.image_url,alt:s.actor.name||"Actor",className:`w-full h-full object-cover ${["processing","generating","queued"].includes(s.status)?"blur-[2px]":""}`}):e.jsx(O,{className:"w-6 h-6 text-primary/50"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium truncate",children:s.actor?.name||`Job #${s.id.slice(0,8)}`}),s.campaign&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-primary/10 text-primary text-[10px] font-medium truncate max-w-[80px]",children:[e.jsx(os,{className:"w-2.5 h-2.5 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s.campaign.name})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:U(new Date(s.created_at),"MMM d, yyyy 'at' h:mm a")})]}),(s.status==="processing"||s.status==="generating")&&e.jsxs("div",{className:"w-24 hidden sm:block",children:[e.jsx("div",{className:"h-1.5 bg-secondary rounded-full overflow-hidden",children:e.jsx(k.div,{className:"h-full bg-primary rounded-full",initial:{width:0},animate:{width:`${s.progress}%`}})}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 text-center",children:[s.progress,"%"]})]}),e.jsxs(ie,{className:`${a.color} text-xs`,children:[e.jsx(o,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:a.label})]}),e.jsxs("div",{className:"flex items-center gap-1",onClick:I=>I.stopPropagation(),children:[P&&l&&e.jsxs(e.Fragment,{children:[e.jsx(p,{variant:"ghost",size:"icon",className:`h-8 w-8 hidden sm:flex ${E(s)?"opacity-70":""}`,onClick:()=>Ds(l,N,s),title:E(s)?"Upgrade to share":"Copy link",children:E(s)?e.jsx(pe,{className:"w-4 h-4"}):e.jsx(ts,{className:"w-4 h-4"})}),e.jsx(p,{variant:"ghost",size:"icon",className:`h-8 w-8 hidden sm:flex ${E(s)?"opacity-70":""}`,onClick:()=>_s(s),title:E(s)?"Upgrade to download":"Download",children:E(s)?e.jsx(pe,{className:"w-4 h-4"}):e.jsx(Pe,{className:"w-4 h-4"})})]}),e.jsxs(Qa,{children:[e.jsx(Xa,{asChild:!0,children:e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(_t,{className:"w-4 h-4"})})}),e.jsxs(Za,{align:"end",children:[s.status==="failed"&&e.jsxs(V,{onClick:()=>Ts(s.id),children:[e.jsx(Te,{className:"w-4 h-4 mr-2"}),"Retry"]}),P&&l&&e.jsxs(e.Fragment,{children:[e.jsxs(V,{onClick:()=>es(l,s.actor?.name,N,E(s)),children:[e.jsx(et,{className:"w-4 h-4 mr-2"}),"Preview"]}),e.jsxs(V,{onClick:()=>Ds(l,N,s),children:[E(s)?e.jsx(pe,{className:"w-4 h-4 mr-2"}):e.jsx(ts,{className:"w-4 h-4 mr-2"}),E(s)?"Copy Link (Upgrade)":"Copy Link"]}),e.jsxs(V,{onClick:()=>_s(s),children:[E(s)?e.jsx(pe,{className:"w-4 h-4 mr-2"}):e.jsx(Pe,{className:"w-4 h-4 mr-2"}),E(s)?"Download (Upgrade)":"Download"]}),e.jsxs(V,{onClick:()=>{_e(s.id),De(l)},disabled:E(s),children:[e.jsx(Qs,{className:"w-4 h-4 mr-2"}),"Add Captions"]})]}),!s.campaign_id&&e.jsxs(e.Fragment,{children:[e.jsx(rs,{}),e.jsxs(V,{onClick:()=>K(s.id),children:[e.jsx(he,{className:"w-4 h-4 mr-2"}),"Move to Campaign"]})]}),s.campaign_id&&e.jsxs(e.Fragment,{children:[e.jsx(rs,{}),e.jsxs(V,{onClick:()=>K(s.id),children:[e.jsx(he,{className:"w-4 h-4 mr-2"}),"Move to Different Campaign"]}),e.jsxs(V,{onClick:()=>Is(s.id),children:[e.jsx(Dt,{className:"w-4 h-4 mr-2"}),"Remove from Campaign"]})]}),e.jsx(rs,{}),e.jsxs(V,{className:"text-destructive",onClick:()=>Ms(s.id),children:[e.jsx(Xs,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})]})]},s.id)})}),Qe&&!J&&A.length>0&&e.jsxs("div",{className:"flex flex-col items-center gap-2 py-6 mt-4",children:[e.jsx(p,{variant:"outline",onClick:He,disabled:Q,className:"min-w-[150px]",children:Q?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}),"Loading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4 mr-2"}),"Load More Videos"]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing ",A.length," of ",X," videos"]})]})]})]})]})]}),e.jsx(pt,{job:We,open:!!We,onOpenChange:s=>{if(!s){const t=v.filter(a=>a.status==="ready"||a.status==="completed").length;t===1&&!g?setTimeout(()=>m(We?.id),300):t>1&&!g&&localStorage.setItem(`firstVideoCelebrated_${n?.user_id}`,"true"),we(null)}},onAddCaptions:(s,t)=>{_e(s),De(t)}}),e.jsx(zt,{open:h,onOpenChange:f,videoId:x}),e.jsx(Le,{open:!!F,onOpenChange:s=>{s||(K(null),ve(!1),Ne(""))},children:e.jsxs($e,{className:"max-w-md",children:[e.jsxs(ze,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-5 h-5"}),v.find(s=>
13s.id===F)?.campaign_id?"Move to Different Campaign":"Move to Campaign"]}),e.jsx(ds,{children:v.find(s=>s.id===F)?.campaign_id?"Select a different campaign or create a new one.":"Select a campaign or create a new one."})]}),e.jsxs("div",{className:"space-y-2",children:[ra?e.jsxs("div",{className:"p-3 rounded-lg border border-primary bg-primary/5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"New Campaign"})]}),e.jsx(Je,{placeholder:"Enter campaign name...",value:le,onChange:s=>Ne(s.target.value),autoFocus:!0,onKeyDown:s=>{s.key==="Enter"&&le.trim()&&Es()}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{size:"sm",variant:"ghost",onClick:()=>{ve(!1),Ne("")},children:"Cancel"}),e.jsx(p,{size:"sm",onClick:Es,disabled:!le.trim()||be,children:be?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-3 h-3 mr-1 animate-spin"}),"Creating..."]}):"Create & Move"})]})]}):e.jsxs("button",{onClick:()=>ve(!0),className:"w-full flex items-center gap-3 p-3 rounded-lg border-2 border-dashed border-primary/30 hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[e.jsx(Ie,{className:"w-5 h-5 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-primary",children:"Create New Campaign"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a new campaign for this video"})]})]}),e.jsx("div",{className:"max-h-[240px] overflow-y-auto space-y-2",children:(()=>{const s=v.find(a=>a.id===F),t=ge.filter(a=>a.id!==s?.campaign_id);return t.length===0?null:t.map(a=>e.jsxs("button",{onClick:()=>fa(a.id),disabled:ta,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-secondary/50 hover:bg-secondary transition-colors text-left disabled:opacity-50",children:[e.jsx(os,{className:"w-5 h-5 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.platform," ⢠Created ",new Date(a.created_at).toLocaleDateString()]})]})]},a.id))})()})]})]})}),e.jsx($t,{selectedCount:_.size,totalCount:ss,onSelectAll:wa,onClearSelection:ae,onBulkDelete:va,onBulkDownload:Na,onBulkMoveToCampaign:()=>Ce(!0),isDeleting:sa,isDownloading:aa,isMoving:bs}),e.jsx(Le,{open:ia,onOpenChange:s=>{Ce(s),s||(ke(!1),Se(""))},children:e.jsxs($e,{className:"max-w-md",children:[e.jsxs(ze,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-5 h-5"}),"Move ",_.size," Videos to Campaign"]}),e.jsx(ds,{children:"Select a campaign or create a new one."})]}),e.jsxs("div",{className:"space-y-2",children:[na?e.jsxs("div",{className:"p-3 rounded-lg border border-primary bg-primary/5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"New Campaign"})]}),e.jsx(Je,{placeholder:"Enter campaign name...",value:ce,onChange:s=>Se(s.target.value),autoFocus:!0,onKeyDown:s=>{s.key==="Enter"&&ce.trim()&&As()}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{size:"sm",variant:"ghost",onClick:()=>{ke(!1),Se("")},children:"Cancel"}),e.jsx(p,{size:"sm",onClick:As,disabled:!ce.trim()||be,children:be?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-3 h-3 mr-1 animate-spin"}),"Creating..."]}):`Create & Move ${_.size}`})]})]}):e.jsxs("button",{onClick:()=>ke(!0),className:"w-full flex items-center gap-3 p-3 rounded-lg border-2 border-dashed border-primary/30 hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[e.jsx(Ie,{className:"w-5 h-5 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-primary",children:"Create New Campaign"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a new campaign for these videos"})]})]}),e.jsx("div",{className:"max-h-[240px] overflow-y-auto space-y-2",children:ge.map(s=>e.jsxs("button",{onClick:()=>ba(s.id),disabled:bs,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-secondary/50 hover:bg-secondary transition-colors text-left disabled:opacity-50",children:[e.jsx(os,{className:"w-5 h-5 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:s.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.platform," ⢠Created ",new Date(s.created_at).toLocaleDateString()]})]})]},s.id))})]})]})}),e.jsx(gt,{open:!!Cs&&!!ks,onOpenChange:s=>{s||(_e(null),De(null))},jobId:Cs||"",videoUrl:ks||"",onSuccess:()=>{de(0,!1)}}),e.jsx(bt,{open:y,onOpenChange:$,action:D,email:L}),e.jsx(Ot,{isOpen:ca,onClose:ma,completedCount:da||Ss}),e.jsx(ft,{open:ne,onOpenChange:j,action:M}),e.jsx(st,{open:!!me,onOpenChange:s=>!s&&Ze(null),children:e.jsxs(at,{children:[e.jsxs(tt,{children:[e.jsx(rt,{children:"Delete this video?"}),e.jsx(it,{children:"This action cannot be undone. The video will be permanently removed."})]}),e.jsxs(nt,{children:[e.jsx(ot,{children:"Cancel"}),e.jsx(lt,{onClick:ga,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})]})}export{Pr as default};
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.