1import{j as e,ae as U,_ as E,af as b,z as V,K as p,U as L,aa as P,I as $,L as I,ag as K}from"./ui-B1dMR2zo.js";import{L as Y,r as x}from"./vendor-MPt6aqX6.js";import{u as F}from"./useCharacters-B5lM1-l8.js";import{u as q}from"./useHasPurchase-C1K8gsa7.js";import{u as G,C as O,a as M,b as J}from"./CharacterModal-BlKyZARO.js";import{A as R}from"./aspect-ratio-CJmKx9rL.js";import{B as j}from"./button-Bpu3Na_L.js";import{A as Q,a as W,b as X,c as Z,d as ee,e as se,f as re,g as ae}from"./alert-dialog-BkwnCgD5.js";import{s as le,t as te}from"./index-UI575IED.js";import"./supabase-D_2IiIQD.js";import"./useMutation-Dq0Ky1ph.js";import"./dialog-CkiPYWIJ.js";import"./input-DIUOOEnN.js";import"./textarea-CyowIGuZ.js";import"./label-aYfuTRW4.js";const S=({character:r})=>{const{jobCount:a,isLoading:o}=G(r.id),{toggleFavorite:n}=F(),c=d=>{d.preventDefault(),d.stopPropagation(),n.mutate({id:r.id,is_favorite:!r.is_favorite})};return e.jsx(Y,{to:`/dashboard/characters/${r.id}`,className:"block no-underline group",children:e.jsxs(O,{className:"overflow-hidden border-0 glow-hover",style:{background:"var(--bg2)",border:"1px solid var(--brd)"},children:[e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsxs(R,{ratio:3/4,children:[r.profile_image_url?e.jsx("img",{src:r.profile_image_url,alt:r.name,className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",style:{background:"var(--bg3)"},children:e.jsx(U,{size:40,style:{color:"var(--tx3)"}})}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-1/3",style:{background:"linear-gradient(to top, var(--bg2), transparent)"}})]}),e.jsx("button",{onClick:c,className:"absolute top-2 left-2 rounded-full p-1.5 transition-colors hover:scale-110",style:{background:r.is_favorite?"var(--glow-p)":"rgba(0,0,0,0.5)"},children:e.jsx(E,{size:14,fill:r.is_favorite?"var(--purple-l)":"none",style:{color:r.is_favorite?"var(--purple-l)":"var(--tx3)"}})}),r.is_preset&&e.jsxs("div",{className:"absolute top-2 right-2 rounded-full px-2 py-0.5 text-[10px] font-semibold flex items-center gap-1",style:{background:"var(--glow-p)",color:"var(--purple-l)"},children:[e.jsx(b,{size:10})," Default"]})]}),e.jsxs(M,{className:"p-3",children:[e.jsx("p",{className:"text-sm font-semibold truncate",style:{color:"var(--tx)"},children:r.name}),e.jsx("div",{className:"flex items-center gap-3 mt-1",style:{color:"var(--tx3)"},children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(V,{size:11}),o?e.jsx(p,{size:11,className:"animate-spin"}):e.jsxs("span",{className:"text-[11px]",children:[a," job",a!==1?"s":""]})]})})]})]})})},ye=()=>{const{data:r,isLoading:a,createCharacter:o,updateCharacter:n,deleteCharacter:c}=F(),[d,u]=x.useState(!1),[t,y]=x.useState(null),[l,g]=x.useState(null),{hasPurchase:m,isLoading:N}=q(["stunt_pro_67"]),[C,k]=x.useState(!1),B=async()=>{k(!0);try{const{data:s,error:i}=await le.functions.invoke("create-upsell-checkout",{body:{price_key:"stunt_pro_67"}});if(i)throw new Error(i.message);s!=null&&s.url&&(window.location.href=s.url)}catch(s){te({title:"Checkout failed",description:s instanceof Error?s.message:"Something went wrong",variant:"destructive"})}finally{k(!1)}},w=()=>{y(null),u(!0)},_=()=>{u(!1),y(null)},H=async(s,i,D)=>{t?await n.mutateAsync({id:t.id,name:s,description:i,referenceImageUrl:D}):await o.mutateAsync({name:s,description:i,referenceImageUrl:D})},T=async()=>{l&&(await c.mutateAsync({id:l.id,profileImageUrl:l.profile_image_url,referenceImageUrl:l.reference_image_url}),g(null))},z=r??[],h=z.filter(s=>s.is_exclusive),v=z.filter(s=>!s.is_exclusive),f=v.filter(s=>s.is_favorite),A=v.filter(s=>!s.is_favorite);return e.jsxs("div",{className:"p-4 sm:p-6 md:p-8 max-w-[1200px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{size:22,style:{color:"var(--purple)"}}),e.jsx("h1",{className:"font-headline text-2xl font-extrabold tracking-[-0.03em]",children:"Characters"})]}),e.jsxs(j,{onClick:w,size:"sm",style:{background:"var(--purple)"},children:[e.jsx(P,{size:16,className:"mr-1"})," New Character"]})]}),e.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg px-4 py-3 mb-6",style:{background:"rgba(124,58,237,0.06)",border:"1px solid rgba(124,58,237,0.12)"},children:[e.jsx($,{size:15,className:"shrink-0 mt-0.5",style:{color:"var(--purple-l)"}}),e.jsxs("p",{className:"text-sm",style:{color:"var(--tx2)"},children:["For the best 1:1 pixel-perfect AI character clones, we recommend using a ",e.jsx("span",{className:"font-semibold",style:{color:"var(--tx)"},children:"text-based description"})," instead of a photo. Descriptions give the AI more creative control for accurate results."]})]}),a&&e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(p,{size:24,className:"animate-spin",style:{color:"var(--purple)"}})}),!a&&v.length===0&&h.length===0&&e.jsxs("div",{className:"rounded-xl p-10 text-center",style:{background:"var(--bg2)",border:"1px solid var(--brd)"},children:[e.jsx(L,{size:40,className:"mx-auto mb-3",style:{color:"var(--tx3)"}}),e.jsx("p",{className:"text-lg font-bold mb-2",children:"No characters yet"}),e.jsx("p",{className:"text-sm mb-5",style:{color:"var(--tx2)"},children:"Create your first AI character to start generating videos."}),e.jsxs(j,{onClick:w,style:{background:"var(--purple)"},children:[e.jsx(P,{size:16,className:"mr-1"})," Create Character"]})]}
1),!a&&f.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(E,{size:16,style:{color:"var(--purple-l)"},fill:"var(--purple-l)"}),e.jsx("h2",{className:"text-sm font-semibold",style:{color:"var(--tx2)"},children:"Favorites"})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:f.map(s=>e.jsx(S,{character:s},s.id))})]}),!a&&A.length>0&&e.jsxs("div",{children:[f.length>0&&e.jsx("h2",{className:"text-sm font-semibold mb-3",style:{color:"var(--tx2)"},children:"All Characters"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:A.map(s=>e.jsx(S,{character:s},s.id))})]}),!a&&h.length>0&&e.jsxs("div",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(b,{size:16,style:{color:"var(--purple-l)"}}),e.jsx("h2",{className:"font-headline text-lg font-bold",children:"Exclusive AI Faces"}),!N&&!m&&e.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:"var(--glow-p)",color:"var(--purple-l)"},children:"PRO ONLY"})]}),!N&&!m&&e.jsxs("div",{className:"rounded-xl p-5 mb-4 flex items-center gap-4",style:{background:"rgba(124,58,237,0.06)",border:"1px solid rgba(124,58,237,0.12)"},children:[e.jsx(I,{size:20,style:{color:"var(--purple)"}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Unlock 5 Exclusive AI Faces"}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--tx2)"},children:"Upgrade to Stunt Pro to access premium, exclusive AI characters."})]}),e.jsxs(j,{size:"sm",className:"gap-1.5",style:{background:"var(--purple)"},disabled:C,onClick:B,children:[C?e.jsx(p,{size:13,className:"animate-spin"}):e.jsx(K,{size:13}),"Upgrade to Pro â $67"]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:h.map(s=>e.jsxs("div",{className:"relative",children:[!m&&e.jsx("div",{className:"absolute inset-0 z-10 rounded-xl flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:e.jsx(I,{size:24,style:{color:"var(--purple-l)"}})}),e.jsxs(O,{className:"overflow-hidden border-0",style:{background:"var(--bg2)",border:"1px solid var(--brd)",opacity:m?1:.7},children:[e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsxs(R,{ratio:3/4,children:[s.profile_image_url?e.jsx("img",{src:s.profile_image_url,alt:s.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",style:{background:"var(--bg3)"},children:e.jsx(U,{size:40,style:{color:"var(--tx3)"}})}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-1/3",style:{background:"linear-gradient(to top, var(--bg2), transparent)"}})]}),e.jsxs("div",{className:"absolute top-2 right-2 rounded-full px-2 py-0.5 text-[10px] font-semibold flex items-center gap-1",style:{background:"var(--glow-p)",color:"var(--purple-l)"},children:[e.jsx(b,{size:10})," Exclusive"]})]}),e.jsxs(M,{className:"p-3",children:[e.jsx("p",{className:"text-sm font-semibold truncate",children:s.name}),e.jsx("p",{className:"text-[11px] mt-1 line-clamp-2",style:{color:"var(--tx2)"},children:s.description})]})]})]},s.id))})]}),e.jsx(J,{open:d,onOpenChange:s=>{s?u(!0):_()},character:t,onSubmit:H,onDelete:t&&!t.is_preset?()=>{g(t),_()}:void 0,isLoading:o.isPending||n.isPending}),e.jsx(Q,{open:!!l,onOpenChange:s=>!s&&g(null),children:e.jsxs(W,{style:{background:"var(--bg2)",border:"1px solid var(--brd)"},children:[e.jsxs(X,{children:[e.jsx(Z,{children:"Delete Character"}),e.jsxs(ee,{children:['Are you sure you want to delete "',l==null?void 0:l.name,'"? This cannot be undone.']})]}),e.jsxs(se,{children:[e.jsx(re,{children:"Cancel"}),e.jsxs(ae,{onClick:T,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[c.isPending?e.jsx(p,{size:14,className:"animate-spin mr-1"}):null,"Delete"]})]})]})})]})};export{ye 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.