PageSourceSearch

https://floowy.ai/assets/Home-C3p3jHOR.js

js floowy.ai collected 2026-10-05 15:14:38 UTC 31,518 bytes, 1 lines download raw bytes

1import{N as me,Y as Re,j as e,a0 as Z,a1 as Q,a2 as Te,e as fe,a3 as Ee,a4 as Ve,a6 as Ke,a as Pe,a7 as $e,B as F,O as Ae,D as Me,r as l,Q as x,_ as ce,a8 as He,a9 as Ye,aa as be,v as We,ab as _,ac as je,H as L,ad as K,ae as $,af as H,ag as Y,ah as W,E as ve,K as ye,ai as Ze,aj as Qe,ak as de,I as Je,V as Xe,al as ue,am as we,an as es,ao as ss,ap as as,aq as le,ar as ie,as as oe,at as ts,Z as rs}from"./index-BQqp3ELx.js";import{I as ns}from"./ImageEditModal-BqvkDXq1.js";import{u as ls}from"./useSubscriptionStatus-BhLBrXeB.js";import{u as is}from"./useAdminCheck-CxhoN2ki.js";import{C as os}from"./CreditsPurchaseDialog-BfZXf3e6.js";import{u as cs}from"./useKnowledgeBaseBonus-LtvPypHR.js";import{B as ds}from"./BackendLayout-DfWaILuB.js";import{C as Ne}from"./crown-Xqu3AyBY.js";import{E as Ie}from"./eye-CC3lfbxz.js";import{S as Ce}from"./shopping-cart-OcRA-lli.js";import{L as ms}from"./layout-grid-BTIriMKX.js";import{L as us}from"./lock-DOnrueiW.js";import{C as xs}from"./coins-DJN8YWj1.js";import"./textarea-C9syxisA.js";import"./dropdown-menu-C_KM0mMI.js";import"./download-CMT8k-h_.js";import"./file-text-CeJn6JER.js";import"./paintbrush-Cd3LI3b_.js";import"./square-CpsHmYaA.js";import"./trash-2-z9k126IM.js";import"./rotate-ccw-BuJmDKPV.js";import"./zoom-in-CrveZn-6.js";import"./PlanCreditsDisplay-kuZSIOyC.js";import"./avatar-BE1oiuOE.js";import"./plus-lcgYWSQn.js";import"./log-out-DHfBQlYE.js";const hs=({open:s,onOpenChange:n})=>{const h=me(),o=Re(),m=()=>{n(!1),h("/knowledge-base?bonus=1")};return e.jsx(Z,{open:s,onOpenChange:n,children:e.jsxs(Q,{className:"sm:max-w-2xl",children:[e.jsxs(Te,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-gradient-to-br from-primary to-primary-glow flex items-center justify-center mb-4",children:e.jsx(fe,{className:"w-8 h-8 text-white"})}),e.jsx(Ee,{className:"text-2xl font-bold text-center",children:"Learn How to Create Amazing Content"}),e.jsx(Ve,{className:"text-center text-base mt-2",children:"Our knowledge base contains step-by-step guides to help you get the most out of Floowy.ai's powerful tools."})]}),e.jsx("div",{className:"relative overflow-hidden rounded-xl my-4",children:e.jsx("div",{className:"flex gap-3 w-max animate-scroll-left",children:[...o,...o].map((f,c)=>e.jsx("div",{className:"flex-shrink-0 w-32 h-40 rounded-lg overflow-hidden shadow-md",children:f.type==="video"?e.jsx("video",{src:f.src,className:"w-full h-full object-cover",autoPlay:!0,loop:!0,muted:!0,playsInline:!0}):e.jsx("img",{src:f.src,alt:f.alt,className:"w-full h-full object-cover"})},c))})}),e.jsx("div",{className:"bg-gradient-to-r from-primary/10 to-primary-glow/10 rounded-lg p-4 my-4 border border-primary/20",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Ke,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4 text-primary"}),"Earn 2 Free Credits!"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Visit the knowledge base to claim your bonus"})]})]})}),e.jsxs($e,{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(F,{variant:"outline",onClick:()=>n(!1),className:"w-full sm:w-auto",children:"Maybe Later"}),e.jsxs(F,{onClick:m,className:"w-full sm:w-auto bg-gradient-to-r from-primary to-primary-glow hover:shadow-glow",children:[e.jsx(fe,{className:"w-4 h-4 mr-2"}),"Learn How to Use the Tools"]})]})]})})},ps=()=>{const{toast:s}=Ae(),[n]=Me(),[h,o]=l.useState([]),[m,f]=l.useState([]),[c,b]=l.useState(new Set),[v,C]=l.useState(!0),[T,S]=l.useState(null),[k,u]=l.useState("all"),[A,U]=l.useState("all"),[a,g]=l.useState("all"),[y,I]=l.useState("all"),[E,xe]=l.useState("all"),[D,J]=l.useState("all"),[G,X]=l.useState("all");l.useEffect(()=>{const d=n.get("success"),p=n.get("model_id");d==="true"&&p&&q(p),n.get("canceled")==="true"&&s({title:"Purchase Canceled",description:"Your purchase was canceled. No charges were made.",variant:"destructive"})},[n]);const q=async d=>{try{const{data:{session:p}}=await x.auth.getSession();if(!p)return;const{error:w}=await x.functions.invoke("confirm-model-purchase",{body:{model_id:d}});if(w)throw w;s({title:"Purchase Complete! 🎉",description:"You now own this exclusive model. It's available in all your tools!"}),B(p.user.id),window.history.replaceState({},"","/home?tab=custom-models")}catch(p){console.error("Error confirming purchase:",p)}},R=async()=>{const{data:d}=await x.from("default_models").select("*").eq("is_active",!0).order("sort_order");d&&f(d)};l.useEffect(()=>{(async()=>{const{data:{session:M}}=await x.auth.getSession();M&&(z(),R(),B(M.user.id))})();const p=x.channel("default-models-changes").on("postgres_changes",{event:"*",schema:"public",table:"default_models"},()=>R()).subscribe(),w=x.channel("custom-models-changes").on("postgres_changes",{event:"*",schema:"public",table:"custom_models"},()=>z()).subscribe();return()=>{x.removeChannel(p),x.removeChannel(w)}},[]);const z=async()=>{C(!0);const{data:d}=await x.from("custom_models").select("*").eq("is_active",!0).order("created_at",{ascending:!1});d&&o(d),C(!1)},B=async d=>{const{data:p}=await x.from("user_purchased_models").select("model_id").eq("user_id",d);
1p&&b(new Set(p.map(w=>w.model_id)))},ee=async d=>{if(c.has(d)){s({title:"Already Owned",description:"You already own this model!"});return}S(d);try{const{data:p,error:w}=await x.functions.invoke("purchase-model",{body:{model_id:d}});if(w)throw w;p!=null&&p.url&&(window.location.href=p.url)}catch(p){s({title:"Purchase Failed",description:p.message||"Failed to initiate purchase",variant:"destructive"})}finally{S(null)}},se=d=>({European:"European",African:"African","Middle Eastern":"Middle Eastern","East Asian":"Asian","South Asian":"Asian","Latin American":"Latin American",Mixed:"Mixed"})[d]||d,ae=m.filter(d=>!(k!=="all"&&d.gender!==k||a!=="all"&&se(d.ethnicity)!==a||E!=="all"&&d.age_category!==E||D!=="all"&&d.body_type!==D||G!=="all"&&d.use_case!==G));h.filter(d=>c.has(d.id));const V=A==="all"?h:h.filter(d=>d.gender===A);return v?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(ce,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 bg-primary/10 rounded-full mb-4",children:[e.jsx(Pe,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-xs font-medium text-primary",children:"Model Collection"})]}),e.jsxs("h2",{className:"text-2xl md:text-3xl font-bold mb-2",children:[e.jsx("span",{className:"text-foreground",children:"AI"})," ",e.jsx("span",{className:"text-primary",children:"Model Avatars"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Browse free avatars or unlock exclusive premium models for your creations."})]}),e.jsxs(He,{defaultValue:"free",className:"w-full",children:[e.jsxs(Ye,{className:"mb-6",children:[e.jsxs(be,{value:"free",className:"gap-2",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),"Free Models",e.jsx(_,{variant:"secondary",className:"ml-1 text-[10px]",children:m.length})]}),e.jsxs(be,{value:"paid",className:"gap-2",children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),"Premium Models",e.jsx(_,{variant:"secondary",className:"ml-1 text-[10px]",children:h.length})]})]}),e.jsxs(je,{value:"free",children:[e.jsx(_e,{gender:k,onGenderChange:u,ethnicity:a,onEthnicityChange:g,showEthnicity:!0,ageCategory:E,onAgeCategoryChange:xe,bodyType:D,onBodyTypeChange:J,useCase:G,onUseCaseChange:X,showExtendedFilters:!0}),e.jsx(ys,{models:ae})]}),e.jsx(je,{value:"paid",children:h.length===0?e.jsxs(L,{className:"p-10 text-center",children:[e.jsx(Ne,{className:"h-12 w-12 mx-auto mb-3 text-muted-foreground/50"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No Premium Models Available"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Check back soon for exclusive model releases."})]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{gender:A,onGenderChange:U,ethnicity:y,onEthnicityChange:I}),e.jsx(vs,{models:V,onPurchase:ee,purchasingModelId:T,purchasedModelIds:c})]})})]})]})},gs=["all","European","African","Asian","Middle Eastern","Latin American","Mixed"],fs=["all","1 – 2.5","7 – 13","13 – 18","20 – 30","30 – 50","50 – 65","65+"],bs=["all","Slim","Athletic","Average","Curvy","Overweight","Plus size"],js=["all","Fashion","E-commerce","Lifestyle"],_e=({gender:s,onGenderChange:n,ethnicity:h,onEthnicityChange:o,showEthnicity:m=!1,ageCategory:f,onAgeCategoryChange:c,bodyType:b,onBodyTypeChange:v,useCase:C,onUseCaseChange:T,showExtendedFilters:S=!1})=>{const k=[{label:"All",value:"all"},{label:"Female",value:"female"},{label:"Male",value:"male"}];return e.jsxs("div",{className:"flex justify-end items-center gap-2 mb-4 flex-wrap",children:[m&&e.jsxs(K,{value:h,onValueChange:o,children:[e.jsx($,{className:"h-7 text-[11px] w-[140px]",children:e.jsx(H,{placeholder:"Ethnicity"})}),e.jsx(Y,{children:gs.map(u=>e.jsx(W,{value:u,className:"text-[11px]",children:u==="all"?"All Ethnicities":u},u))})]}),S&&c&&e.jsxs(K,{value:f||"all",onValueChange:c,children:[e.jsx($,{className:"h-7 text-[11px] w-[120px]",children:e.jsx(H,{placeholder:"Age"})}),e.jsx(Y,{children:fs.map(u=>e.jsx(W,{value:u,className:"text-[11px]",children:u==="all"?"All Ages":u},u))})]}),S&&v&&e.jsxs(K,{value:b||"all",onValueChange:v,children:[e.jsx($,{className:"h-7 text-[11px] w-[130px]",children:e.jsx(H,{placeholder:"Body Type"})}),e.jsx(Y,{children:bs.map(u=>e.jsx(W,{value:u,className:"text-[11px]",children:u==="all"?"All Body Types":u},u))})]}),S&&T&&e.jsxs(K,{value:C||"all",onValueChange:T,children:[e.jsx($,{className:"h-7 text-[11px] w-[130px]",children:e.jsx(H,{placeholder:"Use Case"})}),e.jsx(Y,{children:js.map(u=>e.jsx(W,{value:u,className:"text-[11px]",children:u==="all"?"All Use Cases":u},u))})]}),k.map(u=>e.jsx(F,{size:"sm",variant:s===u.value?"default":"outline",className:"h-7 text-[11px] px-3",onClick:()=>n(u.value),children:u.label},u.value))]})},vs=({models:s,onPurchase:n,purchasingModelId:h,purchasedModelIds:o})=>{const[m,f]=l.useState(null);return s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground text-sm",children:"No models available in this category yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-5 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10 gap-3",children:s.map(c=>{const b=o.has(c.id);return e.jsxs(L,{className:`overflow-hidden transition-all duration-300 group ${b?"border-primary/30 bg-gradient-to-br from-primary/5 to-background":"border-border/50 hover:border-primary/50 hover:shadow-glow"}`,children:[e.jsxs("div",{className:"aspect-[3/4] relative overflow-hidden bg-muted",children:[e.jsx("img",{src:c.image_url,alt:c.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",draggable:!1,onContextMenu:b?void 0:v=>v.preventDefault(),style:b?void 0:{pointerEvents:"none"}}),!b&&e.jsx("div",{className:"absolute inset-0 pointer-events-none select-none overflow-hidden",style:{zIndex:2}
1,children:e.jsx("div",{className:"absolute",style:{top:"-50%",left:"-50%",width:"200%",height:"200%",display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gridTemplateRows:"repeat(8, 1fr)",gap:"4px",transform:"rotate(-30deg)"},children:Array.from({length:48}).map((v,C)=>e.jsx("img",{src:ve,alt:"",className:"w-8 h-auto opacity-30",draggable:!1,style:{filter:"brightness(10)"}},C))})}),b&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(_,{className:"bg-primary text-primary-foreground text-[9px] px-1.5 py-0.5",children:[e.jsx(ye,{className:"h-2.5 w-2.5 mr-0.5"})," Owned"]})}),e.jsx("button",{className:"absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/30 transition-all duration-300 cursor-pointer",onClick:()=>f(c),style:{zIndex:3},children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-background/80 backdrop-blur-sm rounded-full p-2",children:e.jsx(Ie,{className:"h-4 w-4 text-foreground"})})}),!b&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-2 translate-y-full group-hover:translate-y-0 transition-transform duration-300 z-10",children:e.jsx(F,{size:"sm",className:"w-full gap-1.5 text-[11px] h-7 bg-primary hover:bg-primary/90 text-primary-foreground",onClick:v=>{v.stopPropagation(),n(c.id)},disabled:h===c.id,children:h===c.id?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"h-3 w-3 animate-spin"})," Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ce,{className:"h-3 w-3"})," Subscribe"]})})})]}),e.jsxs("div",{className:"p-2 text-center",children:[e.jsx("h4",{className:"font-medium text-xs truncate",children:c.name}),b?e.jsx("span",{className:"text-[10px] text-primary font-medium",children:"Active"}):e.jsx("span",{className:"text-[10px] font-semibold text-primary",children:"€19.95/mo"})]})]},c.id)})}),e.jsx(Z,{open:!!m,onOpenChange:c=>!c&&f(null),children:e.jsx(Q,{className:"sm:max-w-md p-0 overflow-hidden border-border/50",children:m&&e.jsxs("div",{className:"animate-scale-in",children:[e.jsxs("div",{className:"aspect-[3/4] relative overflow-hidden bg-muted",children:[e.jsx("img",{src:m.image_url,alt:m.name,className:"w-full h-full object-cover",draggable:!1,onContextMenu:o.has(m.id)?void 0:c=>c.preventDefault()}),!o.has(m.id)&&e.jsx("div",{className:"absolute inset-0 pointer-events-none select-none overflow-hidden",children:e.jsx("div",{className:"absolute",style:{top:"-50%",left:"-50%",width:"200%",height:"200%",display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gridTemplateRows:"repeat(8, 1fr)",gap:"8px",transform:"rotate(-30deg)"},children:Array.from({length:48}).map((c,b)=>e.jsx("img",{src:ve,alt:"",className:"w-10 h-auto opacity-30",draggable:!1,style:{filter:"brightness(10)"}},b))})}),o.has(m.id)&&e.jsx("div",{className:"absolute top-3 left-3",children:e.jsxs(_,{className:"bg-primary text-primary-foreground text-[10px]",children:[e.jsx(ye,{className:"h-3 w-3 mr-1"})," Owned"]})})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:m.name}),m.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:m.description}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",className:"text-[10px] capitalize",children:m.gender}),o.has(m.id)?e.jsx(_,{className:"text-[10px] bg-primary/10 text-primary border-primary/20",children:"Active Subscription"}):e.jsx(_,{variant:"secondary",className:"text-[10px]",children:"€19.95/mo"})]}),!o.has(m.id)&&e.jsx(F,{size:"sm",className:"w-full gap-2 mt-2 bg-primary hover:bg-primary/90 text-primary-foreground hover:border-primary/50 hover:shadow-glow",onClick:()=>{n(m.id),f(null)},disabled:h===m.id,children:h===m.id?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"h-3 w-3 animate-spin"})," Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ce,{className:"h-3 w-3"})," Subscribe"]})})]})]})})})]})},Se=s=>s.startsWith("http")?s:`${window.location.origin}${s}`,ys=({models:s})=>{const[n,h]=l.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-5 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10 gap-3",children:s.map(o=>e.jsxs(L,{className:"overflow-hidden border-border/50 hover:border-muted-foreground
1/30 transition-all duration-300 group relative",children:[e.jsxs("div",{className:"aspect-[3/4] relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Se(o.image_url),alt:o.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",loading:"lazy"}),e.jsx("button",{className:"absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/30 transition-all duration-300 cursor-pointer",onClick:()=>h(o),children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-background/80 backdrop-blur-sm rounded-full p-2",children:e.jsx(Ie,{className:"h-4 w-4 text-foreground"})})})]}),e.jsxs("div",{className:"p-2 text-center",children:[e.jsx("h4",{className:"font-medium text-xs truncate",children:o.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground capitalize",children:o.ethnicity}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[o.age_category," · ",o.body_type]})]})]},o.id))}),e.jsx(Z,{open:!!n,onOpenChange:o=>!o&&h(null),children:e.jsx(Q,{className:"sm:max-w-md p-0 overflow-hidden border-border/50",children:n&&e.jsxs("div",{className:"animate-scale-in",children:[e.jsx("div",{className:"aspect-[3/4] relative overflow-hidden bg-muted",children:e.jsx("img",{src:Se(n.image_url),alt:n.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"p-4 space-y-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:n.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(_,{variant:"outline",className:"text-[10px] capitalize",children:n.gender}),e.jsx(_,{variant:"secondary",className:"text-[10px] capitalize",children:n.ethnicity}),e.jsx(_,{variant:"secondary",className:"text-[10px]",children:n.age_category}),e.jsx(_,{variant:"secondary",className:"text-[10px]",children:n.body_type}),e.jsx(_,{variant:"secondary",className:"text-[10px]",children:n.use_case}),e.jsx(_,{className:"text-[10px] bg-primary/10 text-primary border-primary/20",children:"Free"})]})]})]})})})]})},ws=[{value:"all",label:"All",Icon:ms},{value:"image",label:"Images",Icon:Je},{value:"video",label:"Videos",Icon:Xe}],Ns=({email:s,hasToolAccess:n,userPlan:h,isAdmin:o})=>{const m=me(),{showLockedToolUpsell:f}=Ze(),[c,b]=l.useState("all"),[v,C]=l.useState("all"),T=l.useMemo(()=>Qe.filter(a=>{var g;return de[a.id]?!0:a.access==="allowlist"?((g=a.allow)==null?void 0:g.call(a,s))??!1:a.access==="plan"&&a.hideWhenLocked&&a.planKey?n(a.planKey):!0}),[s,n]),S=a=>{if(a.access==="coming-soon")return"coming-soon";const g=de[a.id];return g?o||ss(h,g)?"open":"locked":a.access==="plan"&&a.planKey&&!n(a.planKey)?"locked":"open"},k=(a,g)=>{var y;return a.category===g||(((y=a.secondaryCategories)==null?void 0:y.includes(g))??!1)},u=a=>(c==="all"||a.type===c)&&(v==="all"||k(a,v)),A=l.useMemo(()=>new Set(T.flatMap(a=>[a.category,...a.secondaryCategories??[]])),[T]),U=(a,g)=>{if(g!=="coming-soon"){if(g==="locked"){f(a.id)||m("/payment");return}a.route&&m(a.route)}};return e.jsxs("section",{className:"mb-12",children:[e.jsxs("h2",{className:"text-2xl font-semibold mb-5",children:[e.jsx("span",{className:"text-foreground",children:"Your AI"})," ",e.jsx("span",{className:"text-primary",children:"Tools"})]}),e.jsxs("div",{className:"sticky top-0 z-20 -mx-2 mb-8 flex flex-col gap-3 bg-background/90 px-2 py-3 backdrop-blur supports-[backdrop-filter]:bg-background/70 sm:flex-row sm:flex-wrap sm:items-center",children:[e.jsx("div",{role:"tablist","aria-label":"Filter tools by type",className:"inline-flex shrink-0 items-center gap-1 rounded-xl border border-border bg-muted/50 p-1",children:ws.map(({value:a,label:g,Icon:y})=>{const I=c===a;return e.jsxs("button",{role:"tab","aria-selected":I,onClick:()=>b(a),className:ue("inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors",I?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(y,{className:"h-4 w-4"}),g]},a)})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ke,{active:v==="all",onClick:()=>C("all"),children:"All categories"}),we.filter(a=>A.has(a.id)).map(a=>e.jsx(ke,{active:v===a.id,onClick:()=>C(a.id),children:a.label},a.id))]})]}),e.jsx("div",{className:"space-y-10",children:we.map(a=>{const g=T.filter(y=>k(y,a.id)&&u(y));return g.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("h3",{className:"text-[13px] font-semibold uppercase tracking-wide text-muted-foreground",children:a.wideLabel?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden md:inline",children:a.wideLabel}),e.jsx("span",{className:"md:hidden",children:a.label})]}):a.label}),e.jsxs("span",{className:"rounded-full border border-border px-2 py-0.5 text-[11px] font-medium text-muted-foreground",children:[g.length," ",g.length===1?"tool":"tools"]}),e.jsx("span",{className:"h-px flex-1 bg-border"})]}),e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:g.map(y=>e.jsx(_s,{tool:y,state:S(y),onActivate:U},y.id))})]},a.id)})})]})},ke=({active:s,onClick:n,children:h})=>e.jsx("button",{onClick:n,"aria-pressed":s,className:ue("rounded-full border px-4 py-1.5 text-sm font-medium transition-colors",s?"border-primary bg-primary/15 text-primary":"border-border bg-muted/40 text-muted-foreground hover:text-foreground"),children:h}),Cs=({type:s})=>s==="image"?e.jsx("span",{className:"rounded-full bg-primary/20 px-2 py-0.5 text-[10px] font-semibold text-primary backdrop-blur-sm",children:"Image"}):e.jsx("span",{className:"rounded-full bg-sky-500/20 px-2 py-0.5 text-[10px] font-semibold text-sky-400 backdrop-blur-sm",children:"Video"}),_s=({tool:s,state:n,onActivate:h})=>{const o=s.icon,m=n!=="coming-soon",f=de[s.id],c=n==="locked"?f?`Available from ${es[f]}`:"Upgrade Plan":n==="coming-soon"?"Coming soon":"Start creating";return e.jsxs("div",{onClick:()=>h(s,n),className:ue("group flex flex-col overflow-hidden rounded-xl border border-border bg-card transition-all duration-300",m?"cursor-pointer hover:-translate-y-1 hover:shadow-glow":"cursor-default opacity-80"),children:[e.jsxs("div",{className:"relative h-[150px] overflow-hidden bg-muted",children:[s.cover?s.coverType==="video"?e.jsx("video",{src:s.cover,className:"h-full w-full object-cover object-[center_30%]",autoPlay:!0,muted:!0,loop:!0,playsInl
1ine:!0}):e.jsx("img",{src:s.cover,alt:s.name,loading:"lazy",className:"h-full w-full object-cover object-[center_30%] transition-transform duration-500 group-hover:scale-105"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center text-muted-foreground/60",children:o?e.jsx(o,{className:"h-8 w-8",strokeWidth:1.5}):null}),e.jsxs("div",{className:"absolute left-2 top-2 flex gap-1",children:[s.badge&&e.jsx("span",{className:"rounded-full bg-amber-500/90 px-2 py-0.5 text-[10px] font-semibold text-white",children:s.badge}),s.isNew&&e.jsx("span",{className:"rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold text-primary-foreground",children:"New"})]}),e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(Cs,{type:s.type})}),n==="locked"&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(us,{className:"mx-auto mb-1 h-6 w-6"}),e.jsx("p",{className:"text-[11px] font-semibold",children:"Upgrade to unlock"})]})})]}),e.jsxs("div",{className:"flex flex-1 flex-col p-3",children:[e.jsx("p",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-wide text-primary",children:s.categoryLabel}),e.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:s.name}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] text-muted-foreground",children:s.description}),e.jsx(F,{size:"sm",variant:"outline",disabled:n==="coming-soon",onClick:b=>{b.stopPropagation(),h(s,n)},className:"mt-3 w-full border-primary bg-transparent text-primary hover:bg-primary hover:text-primary-foreground disabled:opacity-60",children:c})]})]})},Js=()=>{const[s,n]=l.useState(null),[h,o]=l.useState(null),[m,f]=l.useState(0),[c,b]=l.useState(0),[v,C]=l.useState([]),[T,S]=l.useState(0),[k,u]=l.useState({}),[A,U]=l.useState("free"),[a,g]=l.useState(null),[y,I]=l.useState(!1),[E,xe]=l.useState(1),[D,J]=l.useState(0),[G,X]=l.useState(!1),[q,R]=l.useState(!0),[z,B]=l.useState(null),[ee,se]=l.useState(!1),[ae,V]=l.useState(null),{isPaid:d}=ls(),p=t=>d?t.generated_image_url:t.watermarked_image_url??t.generated_image_url,w=10,M=me(),[Oe]=Me(),Le=Oe.get("tab");Ae();const{isAdmin:te}=is(),{hasClaimed:he,showPromptModal:Fe,setShowPromptModal:re,isLoading:pe}=cs();l.useEffect(()=>{if(!q&&!pe&&he===!1&&s&&!sessionStorage.getItem("kb_prompt_shown")){const r=setTimeout(()=>{re(!0),sessionStorage.setItem("kb_prompt_shown","true")},1500);return()=>clearTimeout(r)}},[q,pe,he,s,re]),l.useEffect(()=>{const{data:{subscription:t}}=x.auth.onAuthStateChange((r,i)=>{if(o(i),n((i==null?void 0:i.user)??null),!i)M("/auth");else{const j=i.user.id;setTimeout(()=>{Ue(j),ge(j),ne(j),Ge(j),qe(j),ze(j)},0)}});return x.auth.getSession().then(({data:{session:r}})=>{o(r),n((r==null?void 0:r.user)??null),r||M("/auth")}),()=>t.unsubscribe()},[M]),l.useEffect(()=>{s!=null&&s.id&&ne(s.id)},[E,s==null?void 0:s.id]),l.useEffect(()=>{if(!(s!=null&&s.id))return;const t=x.channel("generations-realtime").on("postgres_changes",{event:"*",schema:"public",table:"generations",filter:`user_id=eq.${s.id}`},r=>{r.eventType==="INSERT"&&r.new.status==="completed"?E===1?(C(i=>[r.new,...i].slice(0,w)),S(i=>i+1)):ne(s.id):r.eventType==="UPDATE"&&r.new.status==="completed"&&C(i=>i.find(N=>N.id===r.new.id)?i.map(N=>N.id===r.new.id?r.new:N):E===1?[r.new,...i].slice(0,w):i)}).subscribe();return()=>{x.removeChannel(t)}},[s==null?void 0:s.id,E]),l.useEffect(()=>{if(!(s!=null&&s.id))return;const t=()=>ge(s.id);window.addEventListener("credits:refresh",t);const r=x.channel("home-credits-realtime").on("postgres_changes",{event:"*",schema:"public",table:"credits",filter:`user_id=eq.${s.id}`},i=>{var P,O;const j=(P=i.new)==null?void 0:P.balance;typeof j=="number"&&f(j);const N=(O=i.new)==null?void 0:O.total_credits_used;typeof N=="number"&&b(N)}).subscribe();return()=>{window.removeEventListener("credits:refresh",t),x.removeChannel(r)}},[s==null?void 0:s.id]);const Ue=async t=>{const{data:r}=await x.from("profiles").select("onboarding_completed").eq("id",t).single();if(!(r!=null&&r.onboarding_completed)){M("/onboarding");return}R(!1)},ge=async t=>{const{data:r,error:i}=await x.from("credits").select("balance, total_credits_used").eq("user_id",t).single();if(i){console.error("Error fetching credits:",i);return}r&&(f(r.balance),b(r.total_credits_used??0))},ne=async t=>{const{count:r}=await x.from("generations").select("*",{count:"exact",head:!0}).eq("user_id",t).eq("status","completed");r!==null&&J(Math.ceil(r/w));const i=(E-1)*w,{data:j,error:N}=await x.from("generations").select("*").eq("user_id",t).eq("status","completed").order("created_at",{ascending:!1}).range(i,i+w-1);if(N){console.error("Error fetching recent generations:",N);return}j&&(console.log("Recent generations:",j),C(j))},Ge=async t=>{const{count:r,error:i}=await x.from("generations").select("*",{count:"exact",head:!0}).eq("user_id",t).eq("status","completed");if(i){console.error("Error fetching total generations:",i);return}r!==null&&S(r)},qe=async t=>{const{data:r,error:i}=await x.from("profiles").select("plan").eq("id",t).single();if(i){console.error("Error fetching user plan:",i);return}r&&U(r.plan)},ze=async t=>{const{data:r,error:i}=await x.from("user_tool_access").select("tool_name, has_access").eq("user_id",t);if(i){console.error("Error fetching tool access:",i);return}if(r){const j=r.reduce((N,P)=>(N[P.tool_name]=P.has_access,N),{});u(j)}},Be=t=>te?!0:k[t]!==void 0?k[t]:t==="fashion"||t==="atmospheric"||t==="creator-studio"||t==="idea-studio"||t==="ultimate-outfit-maker",De=t=>t.includes(".mp4")||t.includes(".webm")||t.includes(".mov")||t.toLowerCase().endsWith("_video.png");return e.jsxs(ds,{children:[e.jsx("div",{className:"p-6 md:p-8 max-w-7xl mx-auto",children:q?e.jsx(as,{context:"data",message:"Loading your dashboard..."}):Le==="custom-models"?e.jsx(ps,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-12",children:[e.jsxs("h1",{className:"text-3xl md:text-4xl font-bold mb-2",children:[e.jsx("span",{className:"text-primary",children:"Welcome"})," ",e.jsx("span",{className:"dark:text-white text-header-dark",children:"back!"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Create stunning AI-generated content with your tools"})]}),e.jsxs("div",{className:"mb-12 grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsx(L,{className:"border border-primary/40 bg-card bg-gradient-to-br from-primary/10 via-card to-card hover:shadow-glow transition-all duration-300",children:e.jsxs(le,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ie,{children:"Credits Remaining"}),e.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center",children:e.jsx(xs,{className:"w-5 h-5 text-primary"})})]}),e.jsx(oe,{className:"text-4xl font-bold mt-2",children:m})]})}),e.jsx(L,{className:"border border-primary/40 bg-card bg-gradient-to-br from-accent/10 via-card to-card hover:shadow-glow transition-all duration-300",children:e.jsxs(le,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ie,{children:"Credits Used"}),e.jsx("div",{className:"w-10 h-10 bg-accent/10 rounded-xl flex items-center justify-center",children:e.jsx(ts,{className:"w-5 h-5 text-accent-foreground"})})]}),e.jsx(oe,{className:"text-4xl font-bold mt-2",children:c})]})}),e.jsx(L,{className:"border border-primary/40 bg-card bg-gradient-to-br from-primary-glow/10 via-card to-card hover:shadow-glow transition-all duration-300",children:e.jsxs(le,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ie,{children:"Total Generations"}),e.jsx("div",{className:"w-10 h-10 bg-primary-glow/10 rounded-xl flex items-center justify-center",children:e.jsx(rs,{className:"w-5 h-5 text-primary"})})]}),e.jsx(oe,{className:"text-4xl font-bold mt-2",children:T})]})})]}),e.jsx(Ns,{email:s==null?void 0:s.email,hasToolAccess:Be,userPlan:A,isAdmin:te})]})}),e.jsx(Z,{open:y,onOpenChange:I,children:e.jsxs(Q,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Te,{children:e.jsx(Ee,{children:"Generated Content"})}),a&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative w-full max-h-[60vh] flex items-center justify-center",children:De(a.generated_image_url)?e.jsx("video",{src:a.generated_image_url,controls:!0,autoPlay:!0,loop:!0,className:"max-w-full max-h-[60vh] h-auto object-contain rounded-lg"}):e.jsx("img",{src:p(a),alt:"Generated content preview",className:"max-w-full max-h-[60vh] h-auto object-contain rounded-lg"})}),e.jsx("div",{className:"space-y-2",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-semibold",children:"Created:"}
1)," ",new Date(a.created_at).toLocaleString()]})})]})]})}),e.jsx(os,{open:G,onOpenChange:X}),e.jsx(hs,{open:Fe,onOpenChange:re}),z&&e.jsx(ns,{open:ee,onOpenChange:t=>{se(t),t||(B(null),V(null))},imageUrl:z,onEditComplete:async t=>{const{data:{session:r}}=await x.auth.getSession();if(!(r!=null&&r.user))return;const i=v.find(O=>O.id===ae),j=(i==null?void 0:i.prompt)||"Edited image",N=(i==null?void 0:i.original_image_url)||t,{data:P}=await x.from("generations").insert({user_id:r.user.id,prompt:`${j} (edited)`,original_image_url:N,generated_image_url:t,status:"completed"}).select().single();P&&(C(O=>[P,...O]),V(P.id)),B(t)},isAdmin:te})]})};export{Js 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.