1import{w as W,r as x,q as Y,j as e}from"./vendor-Dv-3sXqF.js";import{h as z,A as H,r as v,s as N,t as _,w as f,D as K}from"./AppLayout-32UUpbQe.js";import{s as g,y as k,b as u,B as C,i as I,j as P,d as S,l as G,a as Q,V as b}from"./index-CKltqG2G.js";import{B as X}from"./badge-LnndQe-B.js";import{P as D,T as J}from"./trash-2-CSoqoW2c.js";import{S as U}from"./sparkles-07iGjkRu.js";import{S as $}from"./scissors-DUe7n7O9.js";import{P as Z}from"./pen-tool-qw9Sfxy0.js";import{C as ee}from"./clock-BpliSLbF.js";import{F as te}from"./film-JszzU_o1.js";import{P as se}from"./play-Bx9jn7UV.js";import{E as oe}from"./ellipsis-vertical-BqhHNqO1.js";import{E as re}from"./external-link-Ri44Mx0m.js";import"./input-ekPZrweW.js";import"./agent-friendly-names-BBUOeOXb.js";import"./index-DpmD1sJG.js";import"./supabase-BjSdOukk.js";import"./feedback-dialog-DmYcqD-f.js";import"./CadegentLogo-egmyV_8e.js";import"./zernio-pricing-CZUMQZFW.js";import"./check-DclDyPLv.js";import"./dialog-CFPuEAaN.js";import"./label-DZwg_MGE.js";import"./layers-Bd-1Xam7.js";import"./file-text-BYSuAOwM.js";import"./vite-preload-helper-D7HrI6pR.js";import"./wand-sparkles-BYWpSZ2P.js";import"./image-DVopPXV8.js";import"./book-open-BLZoajBo.js";import"./send-85Nrvcc1.js";import"./chart-column-B2seJYOT.js";import"./bot-DkzkmLM2.js";import"./users-DGIUPr4s.js";import"./shield-check-Db-IwVvm.js";import"./circle-help-CihWnu8j.js";import"./index-CbsHg4rg.js";import"./key-round-DAOIygYF.js";import"./zap-tJF15SCT.js";import"./circle-x-OkcU55iD.js";import"./circle-check-big-DTNd9mCS.js";import"./thumbs-up-CCP1g-Zj.js";import"./formatDistanceToNow-fORfyKE-.js";import"./textarea-YESMRp7n.js";import"./bug-Bq94vuce.js";import"./search-CDTuYWEc.js";import"./shield-B-Lhs9j-.js";import"./framer-motion-CkSWtcOc.js";import"./mic-rG8SGVFU.js";import"./menu-CpfFeEFe.js";import"./SEOHead-XUrAbTor.js";const E=["bg-gradient-to-br from-amber-900 to-amber-700","bg-gradient-to-br from-amber-900 to-amber-700","bg-gradient-to-br from-yellow-900 to-yellow-700","bg-gradient-to-br from-amber-800 to-yellow-700","bg-gradient-to-br from-amber-800 to-amber-600"],ae=[{title:"Camera Ready",description:"Upload raw footage, AI adds captions, safe trims, and branding",icon:U,route:"/camera-ready",color:"from-gold to-gold-light"},{title:"Long to Clips",description:"AI detects viral moments and batch-exports clips",icon:$,route:"/auto-clip",color:"from-gold to-gold-light"},{title:"Whiteboard Explainer",description:"Draw & explain, record whiteboard videos with webcam overlay",icon:Z,route:"/studio/whiteboard",color:"from-gold to-gold-light"}],T="This videoâs server copy has expired. Sources are kept about a day; re-export from the editor to get a fresh file.";function ie(r){try{const a=new URL(r,window.location.origin);if(a.searchParams.has("token")||a.searchParams.has("api_key"))return!1;const d=new URL(b,window.location.origin);return a.host===d.host}catch{return!1}}async function R(r){if(r.job_id)try{const a=await Q(`${b}/api/asset-token/${encodeURIComponent(r.job_id)}`);if(a.ok){const d=await a.json();if(d.assetToken)return`${b}/api/download/${encodeURIComponent(r.job_id)}?asset_token=${encodeURIComponent(d.assetToken)}`}return a.status===404||a.status===410?(u.info(T),null):(u.error("Could not reach the video server. Try again in a moment."),null)}catch{return u.error("Could not reach the video server. Try again in a moment."),null}return r.download_url&&ie(r.download_url)?r.download_url:(u.info(T),null)}function ot(){z([{label:"Studio",href:"/studio"},{label:"Video"}]);const r=W(),[a,d]=x.useState([]),[w,L]=x.useState(!0),[V,q]=Y(),h=V.get("project"),[A,j]=x.useState(null);x.useEffect(()=>{if(!h||w)return;let t=!1;return(async()=>{var o,n;let s=a.find(i=>i.id===h)??null;if(!s){const{data:i}=await g.auth.getSession(),c=(n=(o=i==null?void 0:i.session)==null?void 0:o.user)==null?void 0:n.id;let l=g.from("processed_videos").select("id, title, original_filename, duration, download_url, thumbnail_url, job_id, status, created_at").eq("id",h);l=c?l.eq("user_id",c):l.eq("device_id",k());const{data:m}=await l.maybeSingle();if(t)return;m&&(s=m,d(p=>p.some(F=>F.id===m.id)?p:[m,...p]))}t||(s?(j(h),window.setTimeout(()=>{var i;(i=document.getElementById(`video-project-${h}`))==null||i.scrollIntoView({behavior:"smooth",block:"center"})},50),window.setTimeout(()=>!t&&j(null),4e3)):u.info("That video is no longer available."),q(i=>{const c=new URLSearchParams(i);return c.delete("project"),c},{replace:!0}))})(),()=>{t=!0}},[h,w]),x.useEffect(()=>{(async()=>{var s,o;try{const{data:n}=await g.auth.getSession(),i=(o=(s=n==null?void 0:n.session)==null?void 0:s.user)==null?void 0:o.id,c=k();let l=g.from("processed_videos").select("id, title, original_filename, duration, download_url, thumbnail_url, job_id, status, created_at").order("created_at",{ascending:!1}).limit(5);i?l=l.eq("user_id",i):l=l.eq("device_id",c);const{data:m,error:p}=await l;!p&&m&&d(m)}catch{}L(!1)})()},[]);const y=async t=>{const s=window.open("","_blank"),o=await R(t);o?s?s.location.href=o:window.open(o,"_blank"):s==null||s.close()},B=async t=>{try{await g.from("processed_videos").delete().eq("id",t),d(s=>s.filter(o=>o.id!==t)),u.success("Project deleted")}catch{u.error("Failed to delete project")}},M=t=>{if(!t)return"--:--";const s=Math.floor(t/60),o=Math.floor(t%60);return`${String(s).padStart(2,"0")}
1:${String(o).padStart(2,"0")}`},O=G;return e.jsx(H,{children:e.jsxs("div",{className:"container max-w-6xl py-6 md:py-10 px-4 space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold font-heading",children:"Video Workspace"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Recent Camera Ready exports and focused video tools. Your complete archive stays in Library."})]}),e.jsxs(v,{children:[e.jsx(N,{asChild:!0,children:e.jsxs(C,{className:"gap-2",children:[e.jsx(D,{className:"h-4 w-4"}),"New Project"]})}),e.jsxs(_,{align:"end",className:"w-52",children:[e.jsxs(f,{onClick:()=>r("/camera-ready"),children:[e.jsx(U,{className:"h-4 w-4 mr-2 text-rose-500"}),"Camera Ready"]}),e.jsxs(f,{onClick:()=>r("/auto-clip"),children:[e.jsx($,{className:"h-4 w-4 mr-2 text-stone-500"}),"Long to Clips"]})]})]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground/70 mb-4 font-heading",children:"Quick Start"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:ae.map(t=>{const s=t.icon;return e.jsx(I,{className:"group cursor-pointer hover:shadow-md transition-shadow border-0 shadow-sm active:scale-[0.98]",role:"button",tabIndex:0,onClick:()=>r(t.route),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),r(t.route))},children:e.jsxs(P,{className:"p-5 sm:p-6",children:[e.jsx("div",{className:`w-12 h-12 rounded-2xl bg-gradient-to-br ${t.color} flex items-center justify-center mb-3 group-hover:scale-105 transition-transform shadow-sm`,children:e.jsx(s,{className:"h-6 w-6 text-white"})}),e.jsx("h3",{className:"font-bold text-sm sm:text-base mb-1 font-heading",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:t.description})]})},t.title)})})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-sm font-semibold text-foreground/70 mb-4 font-heading flex items-center gap-2",children:[e.jsx(ee,{className:"h-3.5 w-3.5"}),"Recent Projects"]}),e.jsx("div",{"aria-live":"polite",children:w?e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3",children:Array.from({length:3}).map((t,s)=>e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"aspect-[9/16] bg-muted rounded-lg mb-1.5"}),e.jsx("div",{className:"h-2.5 bg-muted rounded w-3/4 mb-1"}),e.jsx("div",{className:"h-2 bg-muted rounded w-1/2"})]},s))}):a.length===0?e.jsx(I,{className:"border-dashed border-2",children:e.jsxs(P,{className:"py-12 flex flex-col items-center justify-center gap-4",children:[e.jsx(te,{className:"h-12 w-12 text-primary/40"}),e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your video projects will appear here"}),e.jsxs("p",{className:"text-xs text-muted-foreground max-w-sm",children:["Upload raw footage or record yourself. We","â","ll add captions, safe trims, branding, and optional B-roll when you want it."]})]}),e.jsxs(C,{size:"sm",onClick:()=>r("/camera-ready"),children:[e.jsx(D,{className:"h-3.5 w-3.5 mr-1.5"}),"Create your first video"]})]})}):e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3",children:a.map(t=>e.jsxs("div",{id:`video-project-${t.id}`,className:S("group cursor-pointer rounded-lg transition-shadow",A===t.id&&"ring-2 ring-primary ring-offset-2 ring-offset-background"),role:"button",tabIndex:0,onClick:()=>{t.download_url||t.job_id?y(t):r(`/camera-ready?projectId=${t.id}`)},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),t.download_url||t.job_id?y(t):r(`/camera-ready?projectId=${t.id}`))},children:[e.jsxs("div",{className:"relative aspect-[9/16] bg-muted rounded-lg overflow-hidden mb-1.5 shadow-sm group-hover:shadow-md transition-shadow",children:[e.jsx("div",{className:S("absolute inset-0 flex items-center justify-center",E[a.indexOf(t)%E.length]),children:e.jsx("span",{className:"text-2xl font-bold text-white/40",children:(t.title||t.original_filename||"V")[0].toUpperCase()})}),t.download_url&&e.jsx("video",{src:t.download_url,className:"absolute inset-0 w-full h-full object-cover z-[1]",muted:!0,playsInl
1ine:!0,preload:"metadata",onLoadedData:s=>{const o=s.currentTarget;o.duration>1&&(o.currentTime=1)},onError:s=>{s.currentTarget.style.display="none"}}),e.jsx("div",{className:"absolute bottom-1.5 right-1.5 bg-black/70 text-white text-[9px] font-mono px-1 py-0.5 rounded",children:M(t.duration)}),t.status==="complete"&&e.jsx(X,{className:"absolute top-1.5 left-1.5 bg-amber-600 text-white text-[8px] px-1 py-0 border-0",children:"Exported"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/20",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-white/90 flex items-center justify-center shadow-lg",children:e.jsx(se,{className:"h-4 w-4 text-black ml-0.5"})})})]}),e.jsxs("div",{className:"flex items-start justify-between gap-0.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:t.title||t.original_filename||"Untitled"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:O(t.created_at)})]}),e.jsxs(v,{children:[e.jsx(N,{asChild:!0,children:e.jsx("button",{className:"flex h-10 w-10 items-center justify-center rounded hover:bg-muted opacity-100 sm:h-8 sm:w-8 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity shrink-0","aria-label":"More options",onClick:s=>s.stopPropagation(),children:e.jsx(oe,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(_,{align:"end",children:[e.jsxs(f,{onClick:s=>{s.stopPropagation(),r(`/camera-ready?projectId=${t.id}`)},children:[e.jsx(re,{className:"h-3.5 w-3.5 mr-2"}),"Open in Editor"]}),(t.download_url||t.job_id)&&e.jsxs(f,{onClick:async s=>{s.stopPropagation();const o=await R(t);if(!o)return;const n=document.createElement("a");n.href=o,n.download=t.title||t.original_filename||"video",n.target="_blank",n.click()},children:[e.jsx(K,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),e.jsxs(f,{className:"text-destructive",onClick:s=>{s.stopPropagation(),B(t.id)},children:[e.jsx(J,{className:"h-3.5 w-3.5 mr-2"}),"Delete"]})]})]})]})]},t.id))})})]})]})})}export{ot 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.