PageSourceSearch

https://thumio.com/assets/index-Cqtzr4r-.js

js thumio.com collected 2026-10-02 00:09:05 UTC 149,661 bytes, 57 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MobileTemplateLibrary-D-13vx2K.js","assets/react-vendor-DvpaPdNC.js","assets/DotCrossSellCard-BeNxvHzK.js","assets/index-CC9uFMyS.js","assets/firebase-C-c4J6sC.js","assets/motion-CVWa5O5W.js","assets/Skeleton-CsZCfpDk.js","assets/ChannelStylesRail-vqLeeZcy.js","assets/starterThumbnails-CyYClr4U.js","assets/templates-TlpOyO2i.js","assets/studioTemplatesMeta-CqcwUatV.js","assets/toolIconConfig-C8HQMjdS.js","assets/message-circle-BSVbHbOi.js","assets/zoom-in-B9BMbSiC.js","assets/eye-4WlYYBMQ.js","assets/maximize-2-BxnKZoeU.js","assets/user-round-CqSw_s3p.js","assets/mouse-pointer-click-C_fzeVSl.js","assets/split-CLe5qq4-.js","assets/gamepad-2-Bkhl9AG4.js","assets/useUserRecipes-Dm9JSgA9.js","assets/recipesService-BX4QSxQr.js","assets/recipes-ChNo7QAy.js","assets/channelRecipesPublic-DXQWh0nJ.js","assets/useChannelCooking-Cgx0SQgE.js","assets/validateChannel-qkch1Qrc.js","assets/youtube-QnqNXXPt.js","assets/channelsService-B2TjtYQF.js","assets/useStudioOwnerUid-DulZtH0a.js","assets/timer-CWhOcWpb.js","assets/useRecipeLauncher-BDizNRp1.js","assets/ShareLinkButton-BINhicG6.js","assets/share-2-J_85g-R8.js","assets/RecipeZoneCanvas-8RLHPC-c.js","assets/useBrandFont-DZ59soTP.js","assets/heart-DRsUxCPz.js","assets/useTemplateTracking-B0Qfy-I4.js","assets/matchTemplateSearchToTool-DnGjEqNa.js","assets/useTrendingRecipes-fjhSMsIq.js","assets/MobileButton-DKgOKmK0.js","assets/mail-DLHnToTE.js","assets/haptics-BKjshfVA.js","assets/TemplateCard-CnL_Gp01.js","assets/templateImageCache-veCtyZ75.js","assets/ToolCard-8G8c2wBQ.js","assets/before-upscale-BbY0t1qC.js","assets/before-rethink-CQKrKavE.js","assets/TemplatePreviewModal-BD63kVn5.js","assets/trash-2-PEqMHUWg.js","assets/MobileCategoryRow-DKVXTxnm.js","assets/circle-check-BQuSVKna.js","assets/flame-Dtyizy_s.js","assets/plane-CAuSA1GO.js","assets/shield-DfiMaQWs.js","assets/trophy-7u2lvfcR.js","assets/usePageTitle-jlPgz_7r.js","assets/TopTenRow-Cr4Y1IMu.js","assets/calendar-J6pTilEO.js","assets/refresh-cw-D1PezkZY.js","assets/circle-x-BNb5gDhP.js","assets/chevron-up-Bz3IeRxN.js","assets/ResponsiveModal-CcCJoQC6.js","assets/user-DCysGZDz.js","assets/flask-conical-Cd6uHXBx.js","assets/square-UAmmZH95.js","assets/arrow-left-CDZhYzDt.js","assets/smile-BgwdCkpa.js","assets/video-BBm-NrVt.js"])))=>i.map(i=>d[i]);
2import{c as re,m as Ht,l as Lr,u as Ja,X as Ke,a4 as ks,Y as f,V as ce,a0 as Ge,dw as vs,E as xe,S as Ve,v as E,U as en,Z as tn,b7 as Er,i as We,N as Qt,W as sn,k as Dr,P as rn,b6 as ws,au as He,a as an,a3 as Ot,C as pe,$ as nn,ac as qr,ab as ln,ag as on,dz as cn,O as Gt,dA as $r,c4 as dn,j as xn,al as mn,a8 as un,aW as hn,dB as pn,dC as gn,dD as fn,dE as bn,dF as jn,dG as vn,Q as yn,dH as Nn,a1 as ps,aw as gs,g as kn,h as ys,b2 as wn,d1 as Cn,ae as Sn,c7 as Tn,a6 as Rn,dI as zn}from"./index-CC9uFMyS.js";import{r,R as oe,j as e,u as Fr,f as In,i as An}from"./react-vendor-DvpaPdNC.js";import{u as Mn}from"./usePageTitle-jlPgz_7r.js";import{Y as Pr,u as Ln,g as En,T as or,b as Dn}from"./ChannelStylesRail-vqLeeZcy.js";import{u as Cs,a as qn,r as Et,C as $n,R as cr}from"./useRecipeLauncher-BDizNRp1.js";import{v as Kt,w as pt,N as Vt,y as gt,x as Fn,P as Pn,u as Ss,T as Ts}from"./firebase-C-c4J6sC.js";import{u as _n}from"./useTemplateTracking-B0Qfy-I4.js";import{s as Bn,a as Un,d as On,b as Gn,r as Vn,c as Wn,e as dr,f as Hn}from"./templates-TlpOyO2i.js";import{i as Qn,D as Kn}from"./DotCrossSellCard-BeNxvHzK.js";import{M as _r}from"./mail-DLHnToTE.js";import{C as Br}from"./circle-check-BQuSVKna.js";import{a as _t,f as Ce,S as Yn}from"./starterThumbnails-CyYClr4U.js";import{m as Zn,s as Xn}from"./matchTemplateSearchToTool-DnGjEqNa.js";import{a as Rs,b as Bt,v as Jn,r as el,g as xr,s as tl,w as sl}from"./studioTemplatesMeta-CqcwUatV.js";import{u as rl,a as al}from"./useTrendingRecipes-fjhSMsIq.js";import{T as Dt}from"./TemplateCard-CnL_Gp01.js";import{T as mr,a as nl}from"./ToolCard-8G8c2wBQ.js";import{T as ll}from"./TemplatePreviewModal-BD63kVn5.js";import{F as ge}from"./flame-Dtyizy_s.js";import{T as ur}
2from"./TopTenRow-Cr4Y1IMu.js";import{G as Ur}from"./gamepad-2-Bkhl9AG4.js";import{u as Or}from"./useUserRecipes-Dm9JSgA9.js";import{i as il,r as hr,b as pr}from"./recipes-ChNo7QAy.js";import{P as Gr}from"./channelRecipesPublic-DXQWh0nJ.js";import{R as Qe}from"./RecipeZoneCanvas-8RLHPC-c.js";import{d as ol,s as cl}from"./recipesService-BX4QSxQr.js";import{E as dl,S as gr,P as xl,F as ml,B as ul}from"./shield-DfiMaQWs.js";import{C as Vr}from"./calendar-J6pTilEO.js";import{R as ht}from"./refresh-cw-D1PezkZY.js";import{C as Ut}from"./circle-x-BNb5gDhP.js";import{C as hl}from"./chevron-up-Bz3IeRxN.js";import{T as Yt}from"./trash-2-PEqMHUWg.js";import{R as Wr}from"./ResponsiveModal-CcCJoQC6.js";import{U as Ns}from"./user-DCysGZDz.js";import{F as fr}from"./flask-conical-Cd6uHXBx.js";import{H as fs}from"./heart-DRsUxCPz.js";import{S as br}from"./square-UAmmZH95.js";import{A as pl}from"./arrow-left-CDZhYzDt.js";import{S as gl}from"./smile-BgwdCkpa.js";import{T as fl}from"./trophy-7u2lvfcR.js";import{c as bl}from"./toolIconConfig-C8HQMjdS.js";import{V as jl}from"./video-BBm-NrVt.js";/**
3 * @license lucide-react v0.548.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const vl=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],yl=re("cpu",vl);/**
8 * @license lucide-react v0.548.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const Nl=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],jr=re("database",Nl);/**
13 * @license lucide-react v0.548.0 - ISC
14 *
15 * This source code is licensed under the ISC license.
16 * See the LICENSE file in the root directory of this source tree.
17 */const kl=[["path",{d:"M17.596 12.768a2 2 0 1 0 2.829-2.829l-1.768-1.767a2 2 0 0 0 2.828-2.829l-2.828-2.828a2 2 0 0 0-2.829 2.828l-1.767-1.768a2 2 0 1 0-2.829 2.829z",key:"9m4mmf"}],["path",{d:"m2.5 21.5 1.4-1.4",key:"17g3f0"}],["path",{d:"m20.1 3.9 1.4-1.4",key:"1qn309"}],["path",{d:"M5.343 21.485a2 2 0 1 0 2.829-2.828l1.767 1.768a2 2 0 1 0 2.829-2.829l-6.364-6.364a2 2 0 1 0-2.829 2.829l1.768 1.767a2 2 0 0 0-2.828 2.829z",key:"1t2c92"}],["path",{d:"m9.6 14.4 4.8-4.8",key:"6umqxw"}]],wl=re("dumbbell",kl);/**
18 * @license lucide-react v0.548.0 - ISC
19 *
20 * This source code is licensed under the ISC license.
21 * See the LICENSE file in the root directory of this source tree.
22 */const Cl=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],vr=re("file-text",Cl);/**
23 * @license lucide-react v0.548.0 - ISC
24 *
25 * This source code is licensed under the ISC license.
26 * See the LICENSE file in the root directory of this source tree.
27 */const Sl=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],Tl=re("git-fork",Sl);/**
28 * @license lucide-react v0.548.0 - ISC
29 *
30 * This source code is licensed under the ISC license.
31 * See the LICENSE file in the root directory of this source tree.
32 */const Rl=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],zl=re("graduation-cap",Rl);/**
33 * @license lucide-react v0.548.0 - ISC
34 *
35 * This source code is licensed under the ISC license.
36 * See the LICENSE file in the root directory of this source tree.
37 */const Il=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],Al=re("list-filter",Il);/**
38 * @license lucide-react v0.548.0 - ISC
39 *
40 * This source code is licensed under the ISC license.
41 * See the LICENSE file in the root directory of this source tree.
42 */const Ml=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],Ll=re("message-square-plus",Ml);/**
43 * @license lucide-react v0.548.0 - ISC
44 *
45 * This source code is licensed under the ISC license.
46 * See the LICENSE file in the root directory of this source tree.
47 */const El=[["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2",key:"39pd36"}
47],["rect",{width:"8",height:"4",x:"10",y:"6",rx:"1",key:"aywv1n"}]],Dl=re("newspaper",El);/**
48 * @license lucide-react v0.548.0 - ISC
49 *
50 * This source code is licensed under the ISC license.
51 * See the LICENSE file in the root directory of this source tree.
52 */const ql=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],xt=re("square-check-big",ql);/**
53 * @license lucide-react v0.548.0 - ISC
54 *
55 * This source code is licensed under the ISC license.
56 * See the LICENSE file in the root directory of this source tree.
57 */const $l=[["path",{d:"m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8",key:"n7qcjb"}],["path",{d:"M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7",key:"d0u48b"}],["path",{d:"m2.1 21.8 6.4-6.3",key:"yn04lh"}],["path",{d:"m19 5-7 7",key:"194lzd"}]],Fl=re("utensils-crossed",$l);function Pl(t,a=5){const[i,l]=r.useState([]),[c,h]=r.useState(!1),[g,n]=r.useState(null);return r.useEffect(()=>{if(!t||t==="all"){l([]);return}let m=!0;async function u(){h(!0),n(null);try{const x=Kt(Ht,"starterTemplates"),j=pt(x,Vt("status","==","active"),Vt("category","==",t),gt("stats.uses","desc"),Fn(100)),L=await Pn(j),k=new Map;for(const I of L.docs){const v=I.data().subcategory;if(v){const d=k.get(v)||0;k.set(v,d+1)}}const N=Array.from(k.entries()).map(([I,T])=>({subcategory:I,count:T})).sort((I,T)=>T.count-I.count).slice(0,a);m&&(l(N),h(!1))}catch(x){m&&(n(x),h(!1))}}return u(),()=>{m=!1}},[t,a]),{subcategories:i,isLoading:c,error:g}}const _l=1500;function Bl(t){return t.trim()}function Ul({query:t,resultsCount:a,isLoading:i,searchStatus:l="idle"}){const c=r.useRef(null),h=r.useRef(null),g=r.useCallback(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),n=r.useCallback(()=>{g();const x=c.current;!x||x.emitted||!x.query||!x.hasResolved||x.resultsCount===null||(Lr.app.searchPerformed({searchQuery:x.query,resultsCount:x.resultsCount,hadClick:x.hadClick}),x.emitted=!0)},[g]),m=r.useCallback(x=>{const j=c.current;!j||j.emitted||!j.query||(g(),h.current=setTimeout(()=>{h.current=null,n()},x))},[g,n]);return r.useEffect(()=>{const x=Bl(t),j=c.current;if(!x){n(),c.current=null;return}if((!j||j.query!==x)&&(n(),c.current={query:x,resultsCount:null,hadClick:!1,emitted:!1,hasResolved:!1}),l==="error"){g(),c.current=null;return}!i&&l==="success"&&c.current?(c.current.resultsCount=a,c.current.hasResolved=!0,m(a===0?0:_l)):i&&g()},[g,n,i,t,a,m,l]),r.useEffect(()=>()=>{n()},[n]),{markSearchResultClick:r.useCallback(()=>{const x=c.current;x&&(x.hadClick=!0,n())},[n])}}function qt(t){return t?t instanceof Date?t:t instanceof Ts?t.toDate():typeof t=="object"&&"seconds"in t?new Date(t.seconds*1e3):new Date:new Date}function $t(t={}){const{status:a="pending",enabled:i=!0}=t,[l,c]=r.useState({requests:[],isLoading:i,error:null});return r.useEffect(()=>{if(!i){c({requests:[],isLoading:!1,error:null});return}const h=Kt(Ht,"templateRequests");let g;a==="all"?g=pt(h,gt("requestCount","desc")):g=pt(h,Vt("status","==",a),gt("requestCount","desc"));const n=Ss(g,m=>{const u=m.docs.map(x=>{const j=x.data(),L=j.updatedAt?qt(j.updatedAt):null,k=j.status||"pending",N=1440*60*1e3,I=k==="processing"&&L&&Date.now()-L.getTime()>N,T=(j.failedVideos||[]).map(v=>{var d,C,A,z;return{videoId:v.videoId||"",video:{id:((d=v.video)==null?void 0:d.id)||v.videoId||"",title:((C=v.video)==null?void 0:C.title)||"Unknown",thumbnailUrl:((A=v.video)==null?void 0:A.thumbnailUrl)||"",channelTitle:(z=v.video)==null?void 0:z.channelTitle},failedStep:v.failedStep,errorMessage:v.errorMessage||"Unknown error",failedAt:qt(v.failedAt),templateId:v.templateId,targetGender:v.targetGender}});return{id:x.id,query:j.query||"",normalizedQuery:j.normalizedQuery||"",optimizedQuery:j.optimizedQuery||j.query||"",userId:j.userId||"",userEmail:j.userEmail||null,subscribedEmails:j.subscribedEmails||[],category:j.category||null,createdAt:qt(j.createdAt),lastRequestedAt:qt(j.lastRequestedAt),updatedAt:L,status:k,requestCount:j.requestCount||1,retryCount:j.retryCount||0,isStuck:I,failedVideos:T,videosQueued:j.videosQueued,videosCompleted:j.videosCompleted,videosFailed:j.videosFailed,sourceType:j.sourceType||"search",sourceChannelId:j.sourceChannelId}});c({requests:u,isLoading:!1,error:null})},m=>{console.error("[useTemplateRequests] Error fetching requests:",m),c(u=>({...u,isLoading:!1,error:m}))});return()=>n()},[a,i]),l}function yr(t){return t?t instanceof Date?t:t instanceof Ts?t.toDate():typeof t=="object"&&"seconds"in t?new Date(t.seconds*1e3):new Date:new Date}function Ol(t={}){const{enabled:a=!0}=t,[i,l]=r.useState({requests:[],isLoading:a,error:null});return r.useEffect(()=>{if(!a){l({requests:[],isLoading:!1,error:null});return}const c=pt(Kt(Ht,"featureRequests"),gt("requestCount","desc")),h=Ss(c,g=>{const n=g.docs.map(m=>{const u=m.data();return{id:m.id,kind:u.kind||"tool",query:u.query||"",normalizedQuery:u.normalizedQuery||"",userId:u.userId||"",userEmail:u.userEmail||null,subscribedEmails:u.subscribedEmails||[],status:"pending",requestCount:u.requestCount||1,createdAt:yr(u.createdAt),lastRequestedAt:yr(u.lastRequestedAt)}});l({requests:n,isLoading:!1,error:null})},g=>{console.error("[useFeatureRequests] Error fetching requests:",g),l(n=>({...n,isLoading:!1,error:g}))});return()=>h()},[a]),i}function Nr(t){return t?t instanceof Date?t:t instanceof Ts?t.toDate():typeof t=="object"&&"seconds"in t?new Date(t.seconds*1e3):null:null}function kr(t){return`https://firebasestorage.googleapis.com/v0/b/thumio-prod.firebasestorage.app/o/starterTemplates%2F${t}%2Fprocessing.png?alt=media`}function wr(t){const i=`https://firebasestorage.googleapis.com/v0/b/thumio-prod.firebasestorage.app/o/starterTemplates%2F${t}%2F`;return[`${i}processing-male.png?alt=media`,`${i}processing-female.png?alt=media`]}function Cr(t){return`https://firebasestorage.googleapis.com/v0/b/thumio-prod.firebasestorage.app/o/starterTemplates%2F${t}%2Ftemplate.png?alt=media`}function Gl(t={}){const{enabled:a=!0}=t,[i,l]=r.useState({templates:[],isLoading:a,error:null});return r.useEffect(()=>{if(!a){l({templates:[],isLoading:!1,error:null});return}const c=Kt(Ht,"starterTemplates"),h=pt(c,Vt("status","==","draft"),gt("publishedAt","desc")),g=Ss(h,n=>{const m=n.docs.map(u=>{const x=u.data();return{id:u.id,title:x.title||"Untitled",category:x.category||"unknown",subcategory:x.subcategory||null,subjectType:x.subjectType||"human",hasGenderVariants:(x.subjectType||"human")==="human"?x.hasGenderVariants??!1:!1,detectedGender:x.detectedGender||null,language:x.language||"en",sourceRegion:x.sourceRegion||"US",tags:x.tags||[],status:x.status||"draft",sourceRequestId:x.sourceRequestId||null,createdAt:Nr(x.publishedAt)||new Date,reviewedAt:Nr(x.reviewedAt),reviewedBy:x.reviewedBy||null}});l({templates:m,isLoading:!1,error:null})},n=>{console.error("[useDraftTemplates] Error fetching drafts:",n),l(m=>({...m,isLoading:!1,error:n}))});return()=>g()},[a]),i}const Vl=({isOpen:t,onClose:a,isOptedIn:i,onToggle:l,backgroundImages:c}
57)=>{const g=Ja(),[n,m]=oe.useState(!1),[u,x]=oe.useState(!1),j=oe.useRef(null),L=oe.useRef(null),k=oe.useRef(!1),N=oe.useCallback(()=>{a()},[a]),I=oe.useCallback(()=>{if(k.current)return;k.current=!0,x(!0),L.current!==null&&window.clearTimeout(L.current),L.current=window.setTimeout(()=>{k.current=!1,x(!1),L.current=null},350);const v=!i;l(),!(!v||!g)&&(j.current!==null&&window.clearTimeout(j.current),m(!0),j.current=window.setTimeout(()=>{m(!1),j.current=null},600))},[350,i,l,g]);if(oe.useEffect(()=>{if(!t)return;const v=d=>{d.key==="Escape"&&(d.stopPropagation(),N())};return window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)},[N,t]),oe.useEffect(()=>()=>{j.current!==null&&window.clearTimeout(j.current),L.current!==null&&window.clearTimeout(L.current),k.current=!1},[]),!t)return null;const T=c.slice(0,6);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",onClick:N,children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"relative w-full max-w-xl overflow-hidden rounded-2xl border border-ink/10 bg-rh-dark shadow-2xl animate-in fade-in zoom-in-95 duration-200",onClick:v=>v.stopPropagation(),children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("div",{className:"grid h-full grid-cols-3 gap-2 p-3 opacity-30",children:T.length>0?T.map((v,d)=>e.jsx("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-ink/5",children:e.jsx("img",{src:v.src,alt:"",className:"h-full w-full object-cover",onError:C=>{const A=C.currentTarget,z=parseInt(A.dataset.fallbackIndex||"0",10);z<v.fallbacks.length&&(A.dataset.fallbackIndex=String(z+1),A.src=v.fallbacks[z])}})},`${v.src}-${d}`)):Array.from({length:6}).map((v,d)=>e.jsx("div",{className:"rounded-lg border border-ink/10 bg-ink/5"},d))}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-rh-dark/40 via-rh-dark/85 to-rh-dark"})]}),e.jsx("button",{type:"button",onClick:N,className:"absolute right-4 top-4 z-20 rounded-lg p-2 transition-colors hover:bg-ink/10","aria-label":"Close Drops modal",children:e.jsx(Ke,{size:18,className:"text-fg/70"})}),e.jsxs("div",{className:"relative z-10 p-8 pt-11",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-rh-green/30 bg-rh-green/10 px-3 py-1 text-xs font-medium text-rh-green",children:[e.jsx(ks,{size:12}),"Drops"]}),e.jsx("h2",{className:"mt-4 text-2xl font-bold text-fg",children:"Never miss a thumbnail drop ;)"}),e.jsx("p",{className:"mt-2 max-w-md text-sm text-rh-text-light/80",children:"Turn this on and we will send new template drops and major feature launches."}),e.jsxs("div",{className:"relative mt-6 overflow-hidden rounded-xl border border-ink/10 bg-black/30 light:bg-ink/5 p-4",children:[n&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 overflow-visible",children:Array.from({length:12}).map((v,d)=>{const C=d/12*360,A=34+d%3*10,z=d%5*.02;return e.jsx("div",{className:"absolute left-1/2 top-1/2 h-1 w-1 rounded-full bg-rh-green",style:{animation:`confetti-burst 0.5s ease-out ${z}s forwards`,"--confetti-x":`${Math.cos(C*Math.PI/180)*A}px`,"--confetti-y":`${Math.sin(C*Math.PI/180)*A-12}px`,"--confetti-rotate":`${(d%2===0?1:-1)*(80+d*15)}deg`,opacity:0,transform:"translate(-50%, -50%)"}},d)})}),e.jsxs("button",{type:"button",onClick:I,disabled:u,className:f("relative z-20 flex w-full items-center justify-between rounded-lg border px-4 py-3 text-left transition-colors",i?"border-rh-green/30 bg-rh-green/10":"border-ink/10 bg-ink/5 hover:bg-ink/10",u&&"cursor-not-allowed opacity-80"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:f("flex h-9 w-9 items-center justify-center rounded-lg border",i?"border-rh-green/30 bg-rh-green/15":"border-ink/10 bg-ink/5"),children:e.jsx(_r,{size:16,className:i?"text-rh-green":"text-fg/70"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-fg",children:"Email me Drops"}),e.jsx("p",{className:"text-xs text-rh-text-dark",children:i?"On":"Off"})]})]}),e.jsx("span",{className:f("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out",i?"bg-rh-green":"bg-ink/20"),children:e.jsx("span",{className:f("pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out",i?"translate-x-4":"translate-x-0")})})]})]}),e.jsxs("p",{className:"mt-4 flex items-center gap-2 text-xs text-rh-text-dark",children:[e.jsx(Br,{size:14,className:i?"text-rh-green":"text-fg/40"}),i?"You are subscribed. You can change this anytime in Settings.":"One toggle. Easy on, easy off."]})]})]})})},Wl=["template","tool","recipe"],Wt={template:{label:"Template",title:"Request a Thumbnail Template",subt
57itle:"Tell us what your audience searches for and we'll create templates you can put yourself in!",placeholder:"How to grow on YouTube",helper:"What would your viewer search for?",steps:[{title:"Request",desc:"Tell us what you need"},{title:"Create",desc:"We design & add it"},{title:"Use",desc:"Ready for your video"}],successMessage:"Our designers will review your request. Check back soon!"},tool:{label:"Tool",title:"Request an Editor Tool",subtitle:"Missing a one-tap tool in the editor? Describe it and we'll consider building it.",placeholder:"e.g. Remove background, add glow outline...",helper:"What should the tool do?",steps:[{title:"Request",desc:"Describe the tool"},{title:"Build",desc:"We review & build it"},{title:"Use",desc:"It appears in your editor"}],successMessage:"We'll review your tool idea. The best requests ship in the editor!"},recipe:{label:"Recipe",title:"Request a Recipe",subtitle:"Want a reusable thumbnail layout for your niche? Tell us and we'll cook it up.",placeholder:"e.g. Fortnite victory royale layout...",helper:"What kind of thumbnail layout?",steps:[{title:"Request",desc:"Describe the layout"},{title:"Cook",desc:"We build the recipe"},{title:"Use",desc:"Find it in the Cookbook"}],successMessage:"We'll review your recipe idea. Check the Cookbook for new additions!"}},Hl={template:vs,tool:Ge,recipe:ce},Hr=({value:t,onChange:a,className:i})=>e.jsx("div",{role:"tablist","aria-label":"Request type",className:f("inline-flex items-center gap-1 p-1 rounded-full bg-ink/5 border border-ink/10",i),children:Wl.map(l=>{const c=Hl[l],h=t===l;return e.jsxs("button",{type:"button",role:"tab","aria-selected":h,onClick:()=>a(l),className:f("flex items-center gap-1.5 px-3.5 py-1.5 rounded-full text-sm font-medium transition-all",h?"bg-fg text-rh-dark shadow-sm":"text-rh-text-dark hover:text-fg hover:bg-ink/5"),children:[e.jsx(c,{size:14}),Wt[l].label]},l)})}),Qr=({query:t,onQueryChange:a,onSubmit:i,isSubmitting:l,isSubmitted:c,error:h,dailyCount:g,dailyLimit:n,placeholder:m,onBack:u,backLabel:x="Back to templates",onReset:j,showHowItWorks:L=!0,autoFocus:k=!1,notifyWhenReady:N=!1,onNotifyChange:I,requestKind:T="template",onRequestKindChange:v})=>{const d=g>=n,C=Wt[T],A=m??C.placeholder;return e.jsxs("div",{className:"flex flex-col items-center gap-4 w-full max-w-lg mx-auto",children:[c?e.jsxs("div",{className:"flex flex-col items-center gap-4 p-8 rounded-2xl bg-gradient-to-br from-green-500/10 to-green-500/5 border border-green-500/20 w-full animate-in fade-in zoom-in-95 duration-300",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center ring-4 ring-green-500/10",children:e.jsx(xe,{className:"w-8 h-8 text-green-400"})}),e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("h3",{className:"text-lg font-bold text-fg",children:"Request Received!"}),e.jsx("p",{className:"text-sm text-rh-text-light/80 max-w-xs mx-auto",children:C.successMessage})]}),j&&e.jsx("button",{onClick:j,className:"mt-2 px-4 py-2 rounded-lg bg-green-500/10 text-green-400 text-sm font-medium hover:bg-green-500/20 transition-colors",children:"Submit another request"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w-full space-y-2",children:[v&&e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx(Hr,{value:T,onChange:v})}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-px rounded-xl border border-rh-green/20 opacity-0 group-focus-within:opacity-100 transition-opacity duration-300"}),e.jsxs("div",{className:"relative flex items-center bg-rh-surface-2 border border-ink/10 rounded-xl overflow-hidden focus-within:border-ink/20 transition-colors",children:[e.jsx("div",{className:"pl-4 text-rh-text-dark",children:e.jsx(Ve,{size:20})}),e.jsx("input",{type:"text",value:t,onChange:z=>a(z.target.value),maxLength:50,placeholder:A,className:"flex-1 px-3 py-4 bg-transparent text-fg placeholder:text-rh-text-dark/60 focus:outline-none text-base",onKeyDown:z=>{z.key==="Enter"&&t.trim()&&!d&&i()},autoFocus:k}),e.jsx("button",{onClick:i,disabled:l||!t.trim()||d,className:f("mr-2 px-4 py-2 rounded-lg text-sm font-semibold transition-all",t.trim()&&!d?"bg-fg text-rh-dark hover:bg-fg/90 shadow-sm":"bg-ink/5 text-fg/30 curs
57or-not-allowed","flex items-center gap-2"),children:l?e.jsx(E,{size:16,className:"animate-spin"}):e.jsxs(e.Fragment,{children:["Request",e.jsx(en,{size:14})]})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-1 text-[11px] font-medium tracking-wide",children:[e.jsx("span",{className:"text-rh-text-dark/80",children:C.helper}),e.jsxs("span",{className:f("transition-colors",d?"text-orange-400":"text-rh-text-dark/60"),children:[g,"/",n," requests used"]})]}),I&&e.jsxs("button",{type:"button",onClick:()=>I(!N),role:"switch","aria-checked":N,className:"flex w-full items-center justify-between rounded-lg px-1 py-1.5 text-left transition-colors hover:bg-ink/[0.03] group/notify",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(_r,{size:14,className:f("transition-colors",N?"text-rh-green":"text-rh-text-dark")}),e.jsx("span",{className:f("text-[13px] font-medium transition-colors",N?"text-fg":"text-rh-text-dark group-hover/notify:text-rh-text-light"),children:"Email me when it's ready"})]}),e.jsx("span",{className:f("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out",N?"bg-rh-green":"bg-ink/15"),children:e.jsx("span",{className:f("pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out",N?"translate-x-4":"translate-x-0")})})]})]}),h&&e.jsx("div",{className:"w-full bg-red-500/10 text-red-400 text-sm px-4 py-3 rounded-xl border border-red-500/20 text-center animate-in slide-in-from-top-2",children:h})]}),u&&e.jsxs("button",{onClick:u,className:"text-sm font-medium text-rh-text-dark hover:text-fg transition-colors flex items-center gap-2 group",children:[e.jsx("span",{className:"group-hover:-translate-x-1 transition-transform",children:"←"}),x]}),L&&!c&&e.jsx("div",{className:"mt-2 w-full pt-4 border-t border-ink/[0.06]",children:e.jsx("div",{className:"flex items-center justify-between gap-2",children:C.steps.map((z,D)=>{const b=[Ll,xe,tn][D]??xe;return e.jsxs(oe.Fragment,{children:[D>0&&e.jsx("div",{className:"flex-1 h-px min-w-4 bg-gradient-to-r from-white/10 via-white/5 to-white/10","aria-hidden":"true"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-ink/[0.06] border border-ink/10 flex items-center justify-center flex-shrink-0",children:e.jsx(b,{size:14,className:"text-rh-text-light"})}),e.jsxs("div",{className:"leading-tight",children:[e.jsx("p",{className:"text-[11px] font-semibold text-fg",children:z.title}),e.jsx("p",{className:"hidden sm:block text-[10px] text-rh-text-dark whitespace-nowrap",children:z.desc})]})]})]},D)})})})]})};function Ql(t){var h;const a=t.toLowerCase().replace(/\s/g,"");return!!(a.length<3||(((h=a.match(/[aeiou]/g))==null?void 0:h.length)??0)/a.length<.15||/(.)\1{3,}/.test(a)||/(.{2,4})\1{2,}/.test(a)||["asdf","qwer","zxcv","hjkl","jkl;","uiop","bnm,","fdsa","rewq","vcxz"].some(g=>a.includes(g)))}function Kl(t){const a=t.trim();return a.length===0?{isValid:!1,error:"Please enter a template description"}:a.length<2?{isValid:!1,error:"Please enter a longer description"}:Ql(a)?{isValid:!1,error:'Please enter a valid template description (e.g., "gaming thumbnails")'}:{isValid:!0}}const Kr={template:"templateRequestCount",tool:"toolRequestCount",recipe:"recipeRequestCount"},Yl=5,Zl=300;function Xl(t){const a=localStorage.getItem(Kr[t]);if(!a)return 0;try{const{date:i,count:l}=JSON.parse(a),c=new Date().toISOString().split("T")[0];return i===c?l:0}catch{return 0}}function Yr(t={}){const{initialQuery:a="",onSuccess:i}=t,{isAdmin:l}=Er(),[c,h]=r.useState(a),[g,n]=r.useState("template"),[m,u]=r.useState(!1),[x,j]=r.useState(!1),[L,k]=r.useState(null),[N,I]=r.useState(0),[T,v]=r.useState(!0),d=l?Zl:Yl,C=N>=d;r.useEffect(()=>{I(Xl(g))},[g]);const A=r.useCallback(b=>{n(b),k(null)},[]),z=r.useCallback(async()=>{const b=c.trim();if(!b||m||C)return;const w=Kl(b);if(!w.isValid){k(w.error??"Invalid input");return}u(!0),k(null);try{g==="template"?await Bn(b,T):await Un(g,b,T),j(!0);const y=N+1;I(y);const O=new Date().toISOString().split("T")[0];localStorage.setItem(Kr[g],JSON.stringify({date:O,count:y})),i==null||i()}catch(y){k(y instanceof Error?y.message:"Failed to submit request")}finally{u(!1)}},[c,m,C,T,N,g,i]),D=r.useCallback(()=>{h(""),j(!1),k(null)},[]);return{query:c,isSubmitting:m,isSubmitted:x,error:L,dailyCount:N,dailyLimit:d,notifyWhenReady:T,isAtLimit:C,requestKind:g,setQuery:h,setNotifyWhenReady:v,setRequestKind:A,submit:z,reset:D}}function Jl({isOpen:t,onClose:a,backgroundImages:i=[]}){const l=Yr(),c=r.useCallback(()=>{a(),setTimeout(()=>{l.reset()},200)},[a,l]);return r.useEffect(()=>{if(!t)return;const h=g=>{g.key==="Escape"&&(g.stopPropagation(),c())};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[t,c]),t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",onClick:c,children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"relative w-full max-w-lg bg-rh-dark border border-ink/10 rounded-2xl shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-200",onClick:h=>h.stopPropagation(),children:[i.length>0&&e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("div",{className:"grid h-full grid-cols-3 gap-2 p-3 opacity-20",children:i.slice(0,6).map((h,g)=>e.jsx("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-ink/5",children:e.jsx("img",{src:h.src,alt:"",className:"h-full w-full object-cover",onError:n=>{const m=n.currentTarget,u=parseInt(m.dataset.fallbackIndex||"0",10);u<h.fallbacks.length&&(m.dataset.fallbackIndex=String(u+1),m.src=h.fallbacks[u])}})},`${h.src}-${g}`))}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-rh-dark/55 via-rh-dark/92 to-rh-dark"})]}),e.jsx("button",{onClick:c,className:"absolute top-4 right-4 p-2 rounded-lg hover:bg-ink/10 transition-colors z-20",children:e.jsx(Ke,{size:20,className:"text-rh-text-dark hover:text-fg"})}),e.jsxs("div",{className:"relative z-10 p-8 pt-10",children:[!l.isSubmitted&&e.jsx(Hr,{value:l.requestKind,onChange:l.setRequestKind,className:"mb-5"}),e.jsxs("div",{className:"animate-in fade-in slide-in-from-bottom-1 duration-200",children:[e.jsx("h2",{className:"text-2xl font-bold text-fg",children:Wt[l.requestKind].title}),e.jsx("p",{className:"mt-2 max-w-md text-sm text-rh-text-light/80",children:Wt[l.requestKind].subtitle})]},l.requestKind),e.jsx("div",{className:"mt-6 w-full",children:e.jsx(Qr,{query:l.query,onQueryChange:l.setQuery,onSubmit:l.submit,isSubmitting:l.isSubmitting,isSubmitted:l.isSubmitted,error:l.error,dailyCount:l.dailyCount,dailyLimit:l.dailyLimit,onReset:l.reset,showHowItWorks:!0,autoFocus:!0,notifyWhenReady:l.notifyWhenReady,onNotifyChange:l.setN
57otifyWhenReady,requestKind:l.requestKind})})]})]})}):null}function ei({initialQuery:t,showHowItWorks:a=!0,placeholder:i="e.g. gaming videos, cooking shows, vlogs...",autoFocus:l=!1,onSuccess:c}){const h=Yr({initialQuery:t,onSuccess:c});return e.jsx(Qr,{query:h.query,onQueryChange:h.setQuery,onSubmit:h.submit,isSubmitting:h.isSubmitting,isSubmitted:h.isSubmitted,error:h.error,dailyCount:h.dailyCount,dailyLimit:h.dailyLimit,placeholder:i,onReset:h.reset,showHowItWorks:a,autoFocus:l,notifyWhenReady:h.notifyWhenReady,onNotifyChange:h.setNotifyWhenReady})}const Sr=()=>e.jsxs("div",{className:"relative w-full min-h-[400px] rounded-2xl overflow-hidden mb-8 border border-ink/10 bg-ink/5",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent animate-shimmer",style:{backgroundSize:"200% 100%"}}),e.jsxs("div",{className:"relative z-10 flex flex-col lg:flex-row items-center justify-center gap-8 lg:gap-12 xl:gap-16 p-6 sm:p-8 md:p-10 lg:p-12 w-full h-full max-w-[1400px] mx-auto",children:[e.jsxs("div",{className:"flex-1 w-full md:max-w-2xl flex flex-col justify-center items-start",children:[e.jsx("div",{className:"w-32 h-7 rounded-full bg-ink/10 mb-4 animate-pulse"}),e.jsxs("div",{className:"space-y-3 mb-4 w-full",children:[e.jsx("div",{className:"h-10 w-3/4 bg-ink/10 rounded-lg animate-pulse"}),e.jsx("div",{className:"h-10 w-1/2 bg-ink/10 rounded-lg animate-pulse"})]}),e.jsxs("div",{className:"flex gap-2 mb-8",children:[e.jsx("div",{className:"w-24 h-8 rounded-lg bg-ink/10 animate-pulse"}),e.jsx("div",{className:"w-32 h-8 rounded-lg bg-ink/5 animate-pulse"})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-40 h-12 rounded-xl bg-ink/20 animate-pulse"}),e.jsx("div",{className:"w-32 h-12 rounded-xl bg-ink/10 animate-pulse"})]})]}),e.jsx("div",{className:"hidden lg:block w-full lg:w-[45%] max-w-[500px] flex-shrink-0",children:e.jsx("div",{className:"aspect-video relative rounded-xl overflow-hidden bg-ink/10 animate-pulse"})})]})]}),ti=({template:t,onUseTemplate:a})=>{const{stats:i}=t,[l,c]=r.useState(!1),[h,g]=r.useState(!1),n=_t(t.id,t.subjectType,{hasGenderVariants:t.hasGenderVariants,detectedGender:t.detectedGender});return e.jsxs("div",{className:"relative w-full min-h-[400px] rounded-2xl overflow-hidden group mb-8 border border-ink/10",children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:We(t.image,"large")||t.image,alt:"",className:f("w-full h-full object-cover blur-sm scale-105 transition-opacity duration-500",l?"opacity-50":"opacity-0"),onLoad:()=>c(!0),onError:m=>{const u=m.currentTarget,x=parseInt(u.dataset.fallbackIndex||"0",10);if(x<n.length){u.dataset.fallbackIndex=String(x+1),u.src=We(n[x],"large")||n[x];return}c(!0)}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-rh-bg via-rh-bg/90 to-transparent"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-rh-bg via-rh-bg/50 to-transparent"})]}),e.jsxs("div",{className:"relative z-10 flex flex-col lg:flex-row items-center justify-center gap-8 lg:gap-12 xl:gap-16 p-6 sm:p-8 md:p-10 lg:p-12 w-full h-full max-w-[1400px] mx-auto",children:[e.jsxs("div",{className:"flex-1 w-full md:max-w-2xl flex flex-col justify-center items-start",children:[e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-orange-500/20 text-orange-400 border border-orange-500/30 text-xs font-bold uppercase tracking-wider",children:[e.jsx(ge,{size:12,className:"fill-orange-400"}),"Trending #1"]})}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-bold text-fg mb-4 leading-tight",children:t.name}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-8",children:[e.jsx("span",{className:"px-3 py-1 rounded-lg bg-ink/10 text-fg/90 text-xs sm:text-sm font-medium",children:t.category.charAt(0).toUpperCase()+t.category.slice(1)}),(i==null?void 0:i.subcategory)&&e.jsx("span",{className:"px-3 py-1 rounded-lg bg-ink/5 text-fg/70 text-xs sm:text-sm border border-ink/5",children:i.subcategory})]}),e.jsx("div",{className:"flex flex-wrap gap-3 sm:gap-4 w-full sm:w-auto",children:e.jsxs("button",{onClick:a,className:"flex-1 sm:flex-none flex items-center justify-center gap-2 px-6 py-3 rounded-xl bg-fg text-rh-dark font-bold text-sm sm:text-base hover:bg-fg/90 transition-colors shadow-lg shadow-white/10 whitespace-nowrap",children:[e.jsx(Qt,{size:18,className:"fill-black"}),"Use Template"]})})]}),e.jsx("div",{className:"hidden lg:block w-full lg:w-[45%] max-w-[500px] flex-shrink-0",children:e.jsxs("div",{className:"aspect-video relative rounded-xl overflow-hidden shadow-2xl ring-1 ring-ink/10 rotate-1 transform hover:rotate-0 transition-transform duration-500 bg-ink/5",children:[!h&&e.jsx("div",{className:"absolute inset-0 bg-ink/10 animate-pulse"}),e.jsx("img",{src:We(t.image,"medium")||t.image,alt:t.name,className:f("w-full h-full object-cover transition-opacity duration-500",h?"opacity-100":"opacity-0"),onLoad:()=>g(!0),onError:m=>
57{const u=m.currentTarget,x=parseInt(u.dataset.fallbackIndex||"0",10);if(x<n.length){u.dataset.fallbackIndex=String(x+1),u.src=We(n[x],"medium")||n[x];return}g(!0)}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-tr from-white/0 via-white/5 to-white/0 opacity-0 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none"})]})})]})]})},si=({badge:t,title:a,description:i,tags:l,primaryLabel:c,primaryIcon:h,onPrimary:g,secondaryLabel:n,onSecondary:m,image:u,beforeImage:x})=>{const[j,L]=r.useState(!1),[k,N]=r.useState(!1);return e.jsxs("div",{className:"relative w-full min-h-[400px] rounded-2xl overflow-hidden group mb-8 border border-ink/10 bg-rh-bg",children:[e.jsxs("div",{className:"absolute inset-0",children:[!j&&e.jsx("img",{src:u,alt:"",className:"w-full h-full object-cover blur-sm scale-105 opacity-50",onError:()=>L(!0)}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-rh-bg via-rh-bg/90 to-transparent"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-rh-bg via-rh-bg/50 to-transparent"})]}),e.jsxs("div",{className:"relative z-10 flex flex-col lg:flex-row items-center justify-center gap-8 lg:gap-12 xl:gap-16 p-6 sm:p-8 md:p-10 lg:p-12 w-full h-full max-w-[1400px] mx-auto",children:[e.jsxs("div",{className:"flex-1 w-full md:max-w-2xl flex flex-col justify-center items-start",children:[e.jsx("div",{className:"flex items-center gap-2 mb-4",children:t}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-bold text-fg mb-4 leading-tight",children:a}),i&&e.jsx("p",{className:"text-sm sm:text-base text-fg/60 leading-relaxed mb-4 max-w-lg",children:i}),l&&e.jsx("div",{className:"flex flex-wrap gap-2 mb-8",children:l}),e.jsxs("div",{className:"flex flex-wrap gap-3 sm:gap-4 w-full sm:w-auto",children:[e.jsxs("button",{onClick:g,className:"flex-1 sm:flex-none flex items-center justify-center gap-2 px-6 py-3 rounded-xl bg-fg text-rh-dark font-bold text-sm sm:text-base hover:bg-fg/90 transition-colors shadow-lg shadow-white/10 whitespace-nowrap",children:[h,c]}),n&&m&&e.jsx("button",{onClick:m,className:"flex-1 sm:flex-none flex items-center justify-center gap-2 px-6 py-3 rounded-xl bg-ink/10 text-fg font-medium text-sm sm:text-base hover:bg-ink/20 transition-colors whitespace-nowrap",children:n})]})]}),e.jsx("div",{className:"hidden lg:block w-full lg:w-[45%] max-w-[500px] flex-shrink-0",children:e.jsxs("div",{className:"aspect-video relative rounded-xl overflow-hidden shadow-2xl ring-1 ring-ink/10 rotate-1 transform hover:rotate-0 transition-transform duration-500 bg-ink/5",children:[!k&&e.jsx("img",{src:u,alt:a,className:"absolute inset-0 w-full h-full object-cover",onError:()=>N(!0)}),x&&!k&&e.jsxs(e.Fragment,{children:[e.jsx("img",{src:x,alt:`${a} before`,className:"absolute inset-0 w-full h-full object-cover opacity-0 group-hover:opacity-100 transition-opacity duration-300",loading:"lazy"}),e.jsx("span",{className:"absolute bottom-2 left-2 px-1.5 py-0.5 rounded bg-black/60 backdrop-blur-sm text-[10px] font-bold uppercase tracking-wide text-white opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:"Before"})]}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-tr from-white/0 via-white/5 to-white/0 opacity-0 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none"})]})})]})]})},Zr=({recipe:t,compact:a})=>{const i=Jn(t),l=!i&&el(t);return e.jsx("span",{className:f("inline-flex items-center gap-1 rounded-md font-semibold",a?"px-1.5 py-0.5 text-[10px]":"px-3 py-1 text-xs sm:text-sm rounded-lg",i?"bg-emerald-500/20 text-emerald-300":l?"bg-violet-500/20 text-violet-300":"bg-ink/10 text-fg/80"),children:i?e.jsxs(e.Fragment,{children:[e.jsx(Ur,{size:a?11:14})," Uses a character"]}):l?e.jsxs(e.Fragment,{children:[e.jsx(sn,{size:a?11:14})," Uses your face"]}):"No face needed"})},Xr=({recipe:t,className:a})=>{const[i,l]=r.useState(!1);return i?e.jsx("div",{className:f("flex items-center justify-center bg-gradient-to-br from-rh-accent/25 via-rh-accent/10 to-rh-dark",a),children:e.jsx(ce,{className:"w-8 h-8 text-rh-accent/70",strokeWidth:1.5})}):e.jsx("img",{src:Rs(t),alt:`${t.name} example thumbnail`,className:f("object-cover",a),onError:()=>l(!0)})},ri=({recipe:t,rank:a,onClick:i})=>e.jsxs("button",{type:"button",onClick:i,title:t.description,"data-testid":`top-recipe
57-${a}`,className:"group/tile relative flex flex-col text-left rounded-xl overflow-hidden border border-ink/10 bg-rh-surface/80 hover:border-ink/30 hover:scale-[1.02] transition-all duration-200",children:[e.jsxs("div",{className:"relative w-full aspect-video overflow-hidden bg-rh-dark",children:[e.jsx(Xr,{recipe:t,className:"absolute inset-0 w-full h-full group-hover/tile:scale-[1.04] transition-transform duration-300"}),e.jsxs("span",{className:"absolute top-2 left-2 flex items-center justify-center min-w-[24px] h-6 px-1.5 rounded-md bg-black/70 backdrop-blur-sm text-white text-[11px] font-bold tabular-nums",children:["#",a]}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 group-hover/tile:opacity-100 transition-opacity duration-200",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-fg text-rh-dark text-xs font-bold",children:[e.jsx(Qt,{size:12,className:"fill-current"}),"Start"]})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 px-2.5 py-2 min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-fg truncate",children:t.name}),e.jsx(Zr,{recipe:t,compact:!0})]})]}),ai=({recipes:t,onSelect:a,onBrowseAll:i,className:l})=>{const[c,h]=r.useState(!1),g=t.slice(0,6),n=g[0];if(!n)return null;const m=g.slice(1);return e.jsxs("section",{"data-testid":"top-recipes-hero",className:f("relative w-full rounded-2xl overflow-hidden group mb-8 border border-ink/10 bg-rh-bg",l),children:[e.jsxs("div",{className:"absolute inset-0",children:[!c&&e.jsx("img",{src:Rs(n),alt:"",className:"w-full h-full object-cover blur-sm scale-105 opacity-40",onError:()=>h(!0)}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-rh-bg via-rh-bg/90 to-rh-bg/60"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-rh-bg via-rh-bg/40 to-transparent"})]}),e.jsxs("div",{className:"relative z-10 flex flex-col xl:flex-row gap-8 xl:gap-10 p-6 sm:p-8 lg:p-10 w-full max-w-[1400px] mx-auto",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-orange-500/20 text-orange-400 border border-orange-500/30 text-xs font-bold uppercase tracking-wider",children:[e.jsx(ge,{size:12}),"Top recipes"]})}),e.jsx("h1",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold text-fg mb-2 leading-tight",children:"The recipes creators cook most"}),e.jsx("p",{className:"text-sm sm:text-base text-fg/60 leading-relaxed mb-6 max-w-lg",children:"Proven one-shot layouts ranked by real cooks. Pick one, fill the slots, and get a finished thumbnail in one go."}),e.jsxs("button",{type:"button",onClick:()=>
57a(n),"data-testid":"top-recipe-1",className:"group/featured flex flex-col sm:flex-row gap-4 items-stretch text-left rounded-xl border border-ink/10 bg-rh-surface/70 hover:border-ink/30 transition-colors p-3 max-w-2xl",children:[e.jsxs("div",{className:"relative w-full sm:w-[260px] flex-shrink-0 aspect-video rounded-lg overflow-hidden shadow-2xl ring-1 ring-ink/10 rotate-1 group-hover/featured:rotate-0 transition-transform duration-500 bg-ink/5",children:[e.jsx(Xr,{recipe:n,className:"absolute inset-0 w-full h-full"}),e.jsx("span",{className:"absolute top-2 left-2 flex items-center justify-center h-6 px-2 rounded-md bg-black/70 backdrop-blur-sm text-white text-[11px] font-bold",children:"#1"})]}),e.jsxs("div",{className:"flex flex-col justify-center min-w-0 gap-2",children:[e.jsx("p",{className:"text-lg font-bold text-fg leading-tight",children:n.name}),e.jsx("p",{className:"text-xs text-fg/60 leading-snug line-clamp-3",children:n.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[e.jsx(Zr,{recipe:n}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-fg text-rh-dark text-xs font-bold group-hover/featured:bg-fg/90 transition-colors",children:[e.jsx(Qt,{size:12,className:"fill-current"}),"Start recipe"]})]})]})]}),i&&e.jsx("button",{type:"button",onClick:i,className:"self-start mt-4 text-xs font-medium text-fg/50 hover:text-fg transition-colors",children:"Browse every recipe below ↓"})]}),m.length>0&&e.jsx("div",{className:"w-full xl:w-[52%] flex-shrink-0 grid grid-cols-2 md:grid-cols-3 xl:grid-cols-3 gap-3 content-center",children:m.map((u,x)=>e.jsx(ri,{recipe:u,rank:x+2,onClick:()=>a(u)},Bt(u)))})]})]})},Tr=()=>Gr.flatMap(t=>t.recipes.map(a=>({channel:t,recipe:a}))),ni=t=>{const a=t.toLowerCase().trim();if(a.length<2)return[];const i=a.split(/\s+/).filter(Boolean);return Gr.filter(l=>{const c=[l.channelName,l.handle,...l.recipes.map(h=>h.name)].join(" ").toLowerCase();return i.every(h=>c.includes(h))})},Rr=(t,a,i)=>t.find(l=>{var c;return((c=l.sourceChannel)==null?void 0:c.channelId)===a.channelId&&l.name.includes(i.name)}),Jr=({studioId:t,userId:a,showToast:i})=>{const{activeStudio:l}=Dr(),c=(l==null?void 0:l.teamId)??null,{recipes:h}=Or(t??null,a),[g,n]=r.useState(null),{launchCustomRecipe:m,isCreating:u}=Cs({studioId:t,onError:k=>i==null?void 0:i(k,"error",4e3)}),x=(k,N)=>`${k.channelId}:${N.videoId}`;return{launchChannelRecipe:async(k,N)=>{if(g||u||!t)return;const I=x(k,N),T=Rr(h,k,N);if(T){n(I),await m(T.id,T.name,"user"),n(null);return}n(I);try{const v=await il({studioId:t,teamId:c,channelId:k.channelId});i==null||i(`Added ${v.imported} ${k.channelName} recipe${v.imported===1?"":"s"} to your library`,"success",4e3);const d=v.recipes.find(C=>C.name.includes(N.name))??v.recipes[0];d&&await m(d.id,d.name,"user")}catch(v){console.error("[useChannelRecipeLaunch] Import failed:",v),i==null||i(`Couldn't add ${k.channelName} recipes: try again`,"error",4e3)}finally{n(null)}},channelRecipeKey:x,isImported:(k,N)=>!!Rr(h,k,N),busyKey:g}},ea=({channel:t,recipe:a,isImported:i,isBusy:l,onClick:c,className:h})=>e.jsxs("div",{role:"button",tabIndex:0,onClick:c,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),c())},title:`${t.channelName}: ${a.name}`,className:f("group flex flex-col rounded-xl bg-rh-surface border border-ink/10 hover:border-ink/25 transition-colors overflow-hidden flex-shrink-0 text-left cursor-pointer",h??"w-[280px]"),children:[e.jsxs("div",{className:"relative w-full aspect-video bg-rh-dark overflow-hidden",children:[e.jsx("img",{src:a.previewImageUrl,alt:`${t.channelName} thumbnail this layout is based on`,referrerPolicy:"no-referrer",className:"w-full h-full object-cover group-hover:scale-[1.03] transition-transform duration-300",loading:"lazy"}),e.jsx("img",{src:t.avatarUrl,alt:t.channelName,referrerPolicy:"no-referrer",className:"absolute top-2 left-2 w-7 h-7 rounded-full border border-ink/40 shadow-lg"}),a.zones.length>0&&e.jsx("div",{className:"absolute bottom-2 right-2 w-[34%] rounded-md overflow-hidden ring-1 ring-ink/15 shadow-lg pointer-events-none",children:e.jsx(Qe,{zones:a.zones,compact:!0})}),l&&e.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:e.jsx(E,{className:"w-6 h-6 text-white animate-spin"})})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-sm font-bold text-fg truncate",children:a.name}),e.jsx("p",{className:"text-[11px] text-rh-text-dark leading-snug line-clamp-2 mt-0.5",children:i?`In your recipes: from ${t.channelName}'s top thumbnails`:`Layout from one of ${t.channelName}'s top thumbnails, click to add & use`})]})]}),li=({channels:t,studioId:a,userId:i,showToast:l,className:c})=>{const{launchChannelRecipe:h,channelRecipeKey:g,isImported:n,busyKey:m}=Jr({studioId:a,userId:i,showToast:l});return t.length===0?null:e.jsx("div",{className:f("space-y-6",c),children:t.map(u=>e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Pr,{size:16}),e.jsx("img",{src:u.avatarUrl,alt:"",referrerPolicy:"no-referrer",className:"w-5 h-5 rounded-full border border-ink/20"}),e.jsxs("h3",{className:"text-sm font-semibold text-rh-text-light",children:[u.channelName," recipes"]}),e.jsx("span",{className:"text-xs text-rh-text-dark",children:u.handle})]}),e.jsx("div",{className:"flex gap-3 overflow-x-auto pb-2 leet-scroll-hide",children:u.recipes.map(x=>e.jsx(ea,{channel:u,recipe:x,isImported:n(u,x),isBusy:m===g(u,x),onClick:()=>void h(u,x)},x.videoId))})]},u.channelId))})},zr=(t,a)=>
57{const i=t.toLowerCase().split(/\s+/).filter(Boolean);if(i.length===0)return!1;const l=a.filter(Boolean).join(" ").toLowerCase();return i.every(c=>l.includes(c))},Ir=({studioId:t,userId:a,allowCreate:i=!0,filterQuery:l,showToast:c,className:h})=>{const{recipes:g}=Or(t,a),n=Fr(),[m,u]=r.useState(null),[x,j]=r.useState(null),{launchCustomRecipe:L,isCreating:k}=Cs({studioId:t,onError:b=>c==null?void 0:c(b,"error",4e3)});r.useEffect(()=>{let b=!1;return ol(24).then(w=>{b||u(w)}).catch(w=>{console.error("[CustomRecipeSections] Failed to load community recipes:",w),b||u([])}),()=>{b=!0}},[]);const N=async(b,w,y)=>{k||(j(b),await L(b,w,y),j(null))},I=(l==null?void 0:l.trim())??"",T=I.length>0,v=T?g.filter(b=>{var w;return I.length>=2&&zr(I,[b.name,b.description,(w=b.sourceChannel)==null?void 0:w.title])}):g,d=T?(m??[]).filter(b=>I.length>=2&&zr(I,[b.payload.name,b.payload.description,b.authorName])):m??[],C=i&&!T,A=v.length>0,z=d.length>0;if(!A&&!z&&!C)return null;const D="relative flex-shrink-0 w-44 sm:w-52 rounded-xl overflow-hidden border border-ink/[0.06] hover:border-ink/25 transition-all cursor-pointer group";return e.jsxs("div",{className:f("space-y-8",h),children:[(A||C)&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ce,{size:16,className:"text-rh-accent"}),e.jsx("h3",{className:"text-sm font-semibold text-rh-text-light",children:"My Recipes"}),A&&e.jsx("span",{className:"text-xs text-rh-text-dark",children:v.length})]}),e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2 leet-scroll-hide",children:[C&&e.jsxs("button",{onClick:()=>n(`/studio/${t}/recipes/builder`),className:"relative flex-shrink-0 w-44 sm:w-52 aspect-video rounded-xl border-2 border-dashed border-ink/[0.1] bg-rh-surface hover:border-rh-accent/50 hover:bg-ink/[0.03] transition-all flex flex-col items-center justify-center gap-2 group",children:[e.jsx("span",{className:"p-2.5 rounded-lg bg-ink/[0.05] text-fg/40 group-hover:text-rh-accent group-hover:bg-rh-accent/10 transition-colors",children:e.jsx(rn,{className:"w-5 h-5"})}),e.jsx("span",{className:"text-xs font-medium text-fg/50 group-hover:text-fg/80",children:"Create your own"})]}),v.map(b=>{var w,y;return e.jsxs("div",{className:D,onClick:()=>void N(b.id,b.name,"user"),title:`Use "${b.name}"`,children:[e.jsx("div",{className:"aspect-video",children:e.jsx(Qe,{zones:b.zones,background:b.background,backgroundImageUrl:(w=b.backgroundImage)==null?void 0:w.storageUrl,compact:!0})}),b.previewImageUrl&&e.jsx("div",{className:"absolute top-1.5 right-1.5 w-[38%] rounded-md overflow-hidden ring-1 ring-black/25 shadow-lg pointer-events-none z-10",children:e.jsx("img",{src:b.previewImageUrl,alt:`${b.name} example`,className:"w-full aspect-video object-cover",loading:"lazy",referrerPolicy:"no-referrer"})}),((y=b.sourceChannel)==null?void 0:y.avatarUrl)&&e.jsx("div",{className:"absolute top-1.5 left-1.5 z-10",title:`Styled after ${b.sourceChannel.title}`,children:e.jsx("img",{src:b.sourceChannel.avatarUrl,alt:"",className:"w-6 h-6 rounded-full border border-ink/40 shadow-lg",referrerPolicy:"no-referrer",onError:O=>{(O.currentTarget.parentElement??O.currentTarget).style.display="none"}})}),e.jsxs("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent flex items-end p-2",children:[e.jsx("span",{className:"text-[11px] font-semibold text-white truncate flex-1",children:b.name}),x===b.id&&e.jsx(E,{className:"w-3.5 h-3.5 text-white animate-spin"})]})]},b.id)})]})]}),z&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ws,{size:16,className:"text-emerald-400"}),e.jsx("h3",{className:"text-sm font-semibold text-rh-text-light",children:"Community"}),e.jsx("span",{className:"text-xs text-rh-text-dark",children:d.length}),e.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded bg-emerald-500/15 text-emerald-400 uppercase tracking-wide",children:"Made by creators"})]}),e.jsx("div",{className:"flex gap-3 overflow-x-auto pb-2 leet-scroll-hide",children:d.map(b=>{var w;return e.jsxs("div",{className:D,onClick:()=>void N(b.id,b.payload.name,"community"),title:`Use "${b.payload.name}" by ${b.authorName}`,children:[e.jsx("div",{className:"aspect-video bg-rh-surface",children:b.previewImageUrl?e.jsx("img",{src:b.previewImageUrl,alt:b.payload.name,className:"w-full h-full object-cover",loading:"lazy"}):e.jsx(Qe,{zones:b.payload.zones,background:b.payload.background,backgroundImageUrl:(w=b.payload.backgroundImage)==null?void 0:w.storageUrl,compact:!0})}),e.jsxs("div",{className:"absolute inset-0 bg-gradient-to-t from-black/75 via-trans
57parent to-transparent flex items-end p-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold text-white truncate",children:b.payload.name}),e.jsxs("p",{className:"text-[9px] text-white/60 truncate flex items-center gap-1",children:[e.jsx(dl,{className:"w-2.5 h-2.5"})," ",b.authorName]})]}),x===b.id&&e.jsx(E,{className:"w-3.5 h-3.5 text-white animate-spin"})]})]},b.id)})})]})]})};function Ar(t){const i=new Date().getTime()-t.getTime(),l=Math.floor(i/(1e3*60*60*24));return l===0?"Today":l===1?"Yesterday":l<7?`${l} days ago`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Mr(t){return{reshoot:"Reshoot",silhouette:"Silhouette",genderSwap:"Gender Swap",oppositeSilhouette:"Opp. Silhouette",dna:"DNA",thumbnailText:"Text Extraction",title:"Title",subcategory:"Subcategory",tags:"Tags"}[t]||t}const ii=({request:t,onProcess:a,onRetry:i,onRequeueFailed:l,onDelete:c})=>{var O,K;const[h,g]=r.useState(!1),[n,m]=r.useState(!1),[u,x]=r.useState(!1),[j,L]=r.useState(!1),[k,N]=r.useState(!1),I=t.requestCount>=3,T=t.status==="processing",v=t.status==="failed",d=(t.isStuck||v)&&i,C=t.sourceType==="channel",A=((O=t.failedVideos)==null?void 0:O.length)||0,z=A>0,D=((K=t.failedVideos)==null?void 0:K.reduce((P,B)=>(P[B.failedStep]=(P[B.failedStep]||0)+1,P),{}))||{},b=async()=>{if(i){g(!0);try{await i(t)}finally{g(!1)}}},w=async()=>{if(l){m(!0);try{await l(t.id)}finally{m(!1)}}},y=async()=>{if(c){x(!0);try{await c(t)}finally{x(!1),L(!1)}}};return e.jsxs("div",{className:f("p-4 rounded-xl border transition-all","bg-rh-surface-2 border-ink/10","hover:border-ink/20 hover:bg-rh-surface-3",t.isStuck&&"border-red-500/30 bg-red-500/5",v&&"border-red-500/30 bg-red-500/5"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-start gap-2 flex-1 min-w-0",children:[e.jsx(Ve,{size:16,className:"text-rh-text-dark flex-shrink-0 mt-0.5"}),e.jsxs("span",{className:"text-fg font-medium truncate",title:t.optimizedQuery,children:['"',t.optimizedQuery,'"']})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[C&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-500/10 border border-red-500/20 text-red-400 text-[10px] font-bold uppercase",children:"Channel"}),t.isStuck&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-500/10 border border-red-500/20 text-red-400 text-[10px] font-bold uppercase",children:[e.jsx(He,{size:10}),"Stuck"]}),v&&!t.isStuck&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-500/10 border border-red-500/20 text-red-400 text-[10px] font-bold uppercase",children:[e.jsx(He,{size:10}),"Failed"]}),T&&!t.isStuck&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-blue-500/10 border border-blue-500/20 text-blue-400 text-[10px] font-bold uppercase",children:[e.jsx(E,{size:10,className:"animate-spin"}),"Processing"]}),I&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-orange-500/10 border border-orange-500/20 text-orange-400 text-[10px] font-bold uppercase",children:[e.jsx(ge,{size:10}),"Hot"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-xs text-rh-text-dark mb-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ws,{size:12}),e.jsxs("span",{children:[e.jsx("span",{className:"text-fg font-medium",children:t.requestCount})," ",t.requestCount===1?"request":"requests"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Vr,{size:12}),e.jsxs("span",{children:["First: ",Ar(t.createdAt)]})]}),t.requestCount>1&&e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs("span",{children:["Last: ",Ar(t.lastRequestedAt)]})}),t.retryCount>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[e.jsx(ht,{size:12}),e.jsxs("span",{children:["Retried ",t.retryCount,"x"]})]})]}),t.category&&e.jsx("div",{className:"mb-3",children:e.jsx("span",{className:"px-2 py-0.5 rounded bg-ink/5 text-[10px] text-rh-text-dark",children:t.category})}),(t.videosQueued!==void 0||z)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-rh-text-dark mb-3 pt-2 border-t border-ink/5",children:[t.videosQueued!==void 0&&e.jsxs("span",{children:["Queued: ",e.jsx("span",{className:"text-fg",children:t.videosQueued})]}),t.videosCompleted!==void 0&&e.jsxs("span",{children:["Completed: ",e.jsx("span",{className:"text-green-400",children:t.videosCompleted})]}),z&&e.jsxs("span",{className:"text-red-400",children:["Failed: ",e.jsx("span",{className:"font-medium",children:A})]})]}),z&&e.jsxs("div",{className:"mb-3 p-3 rounded-lg bg-red-500/5 border border-red-500/20",children:[e.jsxs("button",{onClick:()=>N(!k),className:"w-full flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ut,{size:14,className:"text-red-400"}),e.jsxs("span",{className:"text-red-400 font-medium",children:[A," Failed ",A===1?"Video":"Videos"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[Object.entries(D).slice(0,3).map(([P,B])=>e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-red-500/10 text-red-400 text-[10px]",children:[Mr(P),": ",B]},P)),Object.keys(D).length>3&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-red-500/10 text-red-400 text-[10px]",children:["+",Object.keys(D).length-3," more"]})]}),k?e.jsx(hl,{size:14,className:"text-rh-text-dark"}):e.jsx(an,{size:14,className:"text-rh-text-dark"})]})]}),k&&e.jsx("div",{className:"mt-3 space-y-2 max-h-48 overflow-y-auto",children:t.failedVideos.map((P,B)=>e.jsx("div",{className:"flex items-start gap-2 text-[11px] p-2 rounded bg-black/20 light:bg-ink/5",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-fg font-medium truncate",children:P.video.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-red-500/20 text-red-400",children:Mr(P.failedStep)}),P.templateId&&e.jsxs("span",{className:"text-rh-text-dark",children:["Template: ",P.templateId]})]}),e.jsx("div",{className:"text-rh-text-dark mt-1 line-clamp-1",title:P.errorMessage,children:P.errorMessage})]})},`${P.videoId}-${B}`))}),l&&e.jsxs("button",{onClick:w,disabled:n,className:f("mt-3 w-full px-3 py-2 rounded-lg text-xs font-medium transition-colors flex items-center justify-center gap-2","bg-orange-500/20 border border-orange-500/30 text-orange-400 hover:bg-orange-500/30",n&&"opacity-50 cursor-not-allowed"),children:[n?e.jsx(E,{size:14,className:"animate-spin"}):e.jsx(ht,{size:14}),"Requeue ",A," Failed ",A===1?"Video":"Videos"]})]}),e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[c&&e.jsx("button",{onClick:()=>L(!0),disabled:u,className:f("p-1.5 rounded-lg text-xs font-medium transition-colors flex items-center","bg-ink/5 border border-ink/10 text-rh-text-dark hover:bg-red-500/10 hover:border-red-500/20 hover:text-red-400",u&&"opacity-50 cursor-not-allowed"),title:"Delete request",children:u?e.jsx(E,{size:14,className:"animate-spin"}):e.jsx(Yt,{size:14})}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[d&&e.jsxs("button",{onClick:b,disabled:h,className:f("px-3 py-1.5 rounded-lg text-xs font-medium transition-colors flex items-center gap-1.5","bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20",h&&"opacity-50 cursor-not-allowed"),children:[h?e.jsx(E,{size:12,className:"animate-spin"}):e.jsx(ht,{size:12}),"Retry"]}),a&&t.status==="pending"&&e.jsx("button",{onClick:()=>a(t),className:"px-3 py-1.5 rounded-lg bg-rh-green/10 border border-rh-green/20 text-rh-green text-xs font-medium hover:bg-rh-green/20 transition-colors",children:"Process"})]})]}),e.jsx(Ot,{isOpen:j,onConfirm:()=>{y()},onCancel:()=>{u||L(!1)},title:"Delete request?",confirmLabel:"Delete request",cancelLabel:"Keep request",isLoading:u,children:"This will permanently remove this request from the admin queue."})]})};function oi(t){const a=Math.floor((Date.now()-t.getTime())/864e5);return a===0?"Today":a===1?"Yesterday":a<7?`${a} days ago`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}const ci=({request:t,onDelete:a})=>{const[i,l]=r.useState(!1),[c,h]=r.useState(!1),g=t.requestCount>=3,n=t.kind==="tool",m=n?Ge:ce,u=async()=>
57{l(!0);try{await a(t)}finally{l(!1),h(!1)}};return e.jsxs("div",{className:"p-4 rounded-xl border border-ink/10 bg-rh-surface-2 transition-all hover:border-ink/20",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("span",{className:f("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wide",n?"bg-sky-500/15 text-sky-400":"bg-amber-500/15 text-amber-400"),children:[e.jsx(m,{size:11}),n?"Tool":"Recipe"]}),g&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold bg-orange-500/15 text-orange-400",children:[e.jsx(ge,{size:11}),"Hot"]})]}),e.jsx("p",{className:"text-sm font-medium text-fg break-words",children:t.query}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 mt-2 text-[11px] text-rh-text-dark",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ws,{size:12}),t.requestCount," request",t.requestCount===1?"":"s"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vr,{size:12}),oi(t.createdAt)]}),t.userEmail&&e.jsx("span",{className:"truncate max-w-[180px]",children:t.userEmail})]})]}),e.jsx("button",{onClick:()=>h(!0),disabled:i,className:"flex-shrink-0 p-2 rounded-lg text-rh-text-dark hover:text-red-400 hover:bg-red-500/10 transition-colors",title:"Delete request",children:i?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(Yt,{size:16})})]}),e.jsx(Ot,{isOpen:c,title:"Delete request?",confirmLabel:"Delete request",cancelLabel:"Keep request",isLoading:i,onConfirm:()=>{u()},onCancel:()=>{i||h(!1)},children:e.jsxs("p",{children:['"',t.query,'" will be permanently removed from the queue.']})})]})},di=({template:t,onApprove:a,onReject:i,isProcessing:l=!1,isSelectionMode:c=!1,isSelected:h=!1,onToggleSelect:g})=>{const[n,m]=r.useState(!1),[u,x]=r.useState(!1),[j,L]=r.useState(!1),[k,N]=r.useState(""),[I,T]=r.useState(!1),v=r.useRef(null);r.useEffect(()=>(I&&(v.current=setTimeout(()=>{T(!1)},2e3)),()=>{v.current&&clearTimeout(v.current)}),[I]);const d=async()=>{x(!0);try{await a(t.id,k.trim()||void 0),m(!1),N("")}finally{x(!1)}},C=async()=>{if(!I){T(!0);return}T(!1),L(!0);try{await i(t.id,k.trim()||void 0),m(!1),N("")}finally{L(!1)}},A=l||u||j;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:f("rounded-xl border overflow-hidden transition-all group","bg-rh-surface-2 border-ink/10 hover:border-orange-500/50"),children:[e.jsxs("div",{className:f("relative aspect-video bg-rh-surface-3 cursor-pointer",c&&h&&"ring-2 ring-orange-500 ring-inset"),onClick:()=>{c&&g?g():m(!0)},children:[e.jsx("img",{src:t.subjectType==="human"?kr(t.id):Cr(t.id),alt:t.title,loading:"lazy",decoding:"async",className:"w-full h-full object-cover group-hover:brightness-110 transition-all",onError:z=>{const D=z.target,b=wr(t.id),w=parseInt(D.dataset.fallbackIndex||"0",10);if(t.subjectType==="human"&&w<b.length){D.dataset.fallbackIndex=String(w+1),D.src=b[w];return}D.src="/placeholder-thumbnail.png"}}),c&&e.jsx("div",{className:f("absolute top-2 left-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all shadow-lg z-10",h?"bg-orange-500 border-orange-500 scale-100":"bg-black/40 border-ink/60 backdrop-blur-sm hover:bg-black/60 hover:border-white"),children:h&&e.jsx(pe,{size:14,className:"text-white stroke-[3px]"})}),e.jsx("div",{className:f("absolute top-2 px-2 py-0.5 rounded bg-orange-500 text-white text-[10px] font-bold uppercase",c?"left-10":"left-2"),children:"Draft"}),t.subjectType==="human"?e.jsxs("div",{className:"absolute top-2 right-2 px-2 py-0.5 rounded bg-blue-500/50 backdrop-blur-sm text-white text-[10px] font-medium flex items-center gap-1",children:[e.jsx(Ns,{size:10}),"Human"]}):t.subjectType==="prop"?e.jsxs("div",{className:"absolute top-2 right-2 px-2 py-0.5 rounded bg-cyan-500/50 backdrop-blur-sm text-white text-[10px] font-medium flex items-center gap-1",children:[e.jsx(ks,{size:10}),"Prop"]}):t.subjectType==="text"?e.jsxs("div",{className:"absolute top-2 right-2 px-2 py-0.5 rounded bg-purple-500/50 backdrop-blur-sm text-white text-[10px] font-medium flex items-center gap-1",children:[e.jsx(nn,{size:10}),"Text"]}):null]}),e.jsxs("div",{className:"p-3 flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"text-sm font-medium text-fg line-clamp-2 cursor-pointer flex-1",onClick:()=>{c&&g?g():m(!0)},children:t.title}),!c&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("button",{onClick:C,disabled:A,className:f("p-1.5 rounded-lg transition-all",I?"bg-red-500 text-white animate-pulse":"bg-red-500/10 text-red-400 hover:bg-red-500/20","active:scale-95",A&&"opacity-50 cursor-not-allowed"),title:I?"Click again to confirm":"Reject",children:j?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(Ke,{size:16})}),e.jsx("button",{onClick:d,disabled:A,className:f("p-1.5 rounded-lg transition-all","bg-green-500/20 text-green-400 hover:bg-green-500/30 active:scale-95",A&&"opacity-50 cursor-not-allowed"),title:"Ap
57prove",children:u?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(pe,{size:16})})]})]})]}),e.jsx(Wr,{open:n,onOpenChange:m,title:"Review Template",size:"lg",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsxs("div",{className:"relative aspect-video bg-rh-surface-3 rounded-xl overflow-hidden",children:[e.jsx("img",{src:t.subjectType==="human"?kr(t.id):Cr(t.id),alt:t.title,className:"w-full h-full object-cover",onError:z=>{const D=z.target,b=wr(t.id),w=parseInt(D.dataset.fallbackIndex||"0",10);if(t.subjectType==="human"&&w<b.length){D.dataset.fallbackIndex=String(w+1),D.src=b[w];return}D.src="/placeholder-thumbnail.png"}}),t.subjectType==="prop"&&e.jsx("div",{className:"absolute top-3 left-3 px-2.5 py-1 rounded bg-cyan-500 text-white text-[10px] font-bold uppercase",children:"Prop Template"}),t.subjectType==="text"&&e.jsx("div",{className:"absolute top-3 left-3 px-2.5 py-1 rounded bg-purple-500 text-white text-[10px] font-bold uppercase",children:"Text Template"})]}),e.jsx("h2",{className:"text-lg font-semibold text-fg",children:t.title}),e.jsxs("div",{className:"p-4 rounded-xl border border-ink/10 bg-ink/5",children:[e.jsx("label",{className:"text-[11px] text-rh-text-dark uppercase tracking-wider mb-2 block",children:"Your Notes (training data)"}),e.jsx("textarea",{value:k,onChange:z=>N(z.target.value),placeholder:"Why approve/reject? Any feedback...",className:"w-full px-3 py-2 rounded-lg bg-black/30 light:bg-ink/5 border border-ink/10 text-sm text-fg placeholder:text-rh-text-dark/50 resize-none focus:outline-none focus:border-ink/20",rows:2})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[11px]",children:[e.jsx("span",{className:"px-2 py-1 rounded-lg bg-ink/5 text-rh-text-dark",children:t.category}),t.subcategory&&e.jsx("span",{className:"px-2 py-1 rounded-lg bg-ink/5 text-rh-text-dark",children:t.subcategory}),e.jsx("span",{className:"px-2 py-1 rounded-lg bg-ink/5 text-rh-text-dark",children:t.subjectType})]}),t.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.tags.slice(0,10).map(z=>e.jsx("span",{className:"px-2 py-0.5 rounded-full bg-orange-500/10 border border-orange-500/20 text-[10px] text-orange-400",children:z},z)),t.tags.length>10&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-ink/5 text-[10px] text-rh-text-dark",children:["+",t.tags.length-10]})]}),e.jsx("div",{className:"flex flex-col gap-3 pt-2",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:C,disabled:A,className:f("flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-xl text-sm font-semibold transition-all","bg-red-500/10 text-red-400 hover:bg-red-500/20 active:scale-[0.98]",A&&"opacity-50 cursor-not-allowed"),children:[j?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(Yt,{size:16}),"Reject"]}),e.jsxs("button",{onClick:d,disabled:A,className:f("flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-xl text-sm font-semibold transition-all","bg-green-500 text-white hover:bg-green-600 active:scale-[0.98]",A&&"opacity-50 cursor-not-allowed"),children:[u?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(pe,{size:16}),"Approve"]})]})})]})})]})},xi={pending:{label:"Pending",className:"bg-orange-500 text-white"},approved:{label:"Approved",className:"bg-green-500 text-white"},rejected:{label:"Rejected",className:"bg-red-500 text-white"}},mi=({creation:t,onApprove:a,onReject:i,isSelectionMode:l=!1,isSelected:c=!1,onToggleSelect:h})=>{const[g,n]=r.useState(!1),[m,u]=r.useState(!1),[x,j]=r.useState(!1),[L,k]=r.useState(""),[N,I]=r.useState(!1),T=r.useRef(null);r.useEffect(()=>(N&&(T.current=setTimeout(()=>I(!1),2e3)),()=>{T.current&&clearTimeout(T.current)}),[N]);const v=async()=>{u(!0);try{await a(t.id),n(!1)}finally{u(!1)}},d=async()=>{if(!N){I(!0);return}I(!1),j(!0);try{await i(t.id,L.trim()||void 0),n(!1),k("")}finally{j(!1)}},C=m||x,A=t.status==="pending",z=l&&A&&!!h,D=xi[t.status],{name:b,description:w,zones:y,background:O,backgroundImage:K,forkedFrom:P,sourceChannel:B}=t.payload,R=t.source==="channel_import",M=K==null?void 0:K.storageUrl,Ye=new Date(t.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl border overflow-hidden transition-all group bg-rh-surface-2 border-ink/10 hover:border-orange-500/50",children:[e.jsxs("div",{className:f("relative aspect-video bg-rh-surface-3 cursor-pointer",z&&c&&"ring-2 ring-orange-500 ring-inset",l&&!A&&"opacity-40"),onClick:()=>{z?h():l||n(!0)},children:[t.previewImageUrl?e.jsx("img",{src:t.previewImageUrl,alt:b,loading:"lazy",decoding:"async",className:"w-full h-full object-cover group-hover:brightness-110 transition-all"}):e.jsx(Qe,{zones:y,background:O,backgroundImageUrl:M,compact:!0,className:"pointer-events-none"}),z&&e.jsx("div",{className:f("absolute top-2 left-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all shadow-lg z-10",c?"bg-orange-500 border-orange-500":"bg-black/40 border-ink/60 backdrop-blur-sm hover:bg-black/60 hover:border-white"),children:c&&e.jsx(pe,{size:14,className:"text-white stroke-[3px]"})}),e.jsx("div",{className:f("absolute top-2 px-2 py-0.5 rounded text-[10px] font-bold uppercase",z?"left-10":"left-2",D.className),children:D.label}),R&&e.jsx("div",{className:"absolute top-2 right-2 px-2 py-0.5 rounded text-[10px] font-bold uppercase bg-black/60 backdrop-blur-sm text-white",children:(B==null?void 0:B.title)??"Channel import"}),t.previewImageUrl&&e.jsx("div",{className:"absolute bottom-2 right-2 w-[30%] rounded-md overflow-hidden border border-ink/25 shadow-lg op
57acity-90",children:e.jsx(Qe,{zones:y,background:O,backgroundImageUrl:M,compact:!0,className:"pointer-events-none"})})]}),e.jsxs("div",{className:"p-3 flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>{z?h():l||n(!0)},children:[e.jsx("h3",{className:"text-sm font-medium text-fg truncate",children:b}),e.jsxs("p",{className:"text-[11px] text-rh-text-dark truncate flex items-center gap-1 mt-0.5",children:[e.jsx(Ns,{size:10,className:"flex-shrink-0"}),t.authorName,e.jsxs("span",{className:"text-rh-text-dark/60",children:["· ",Ye]})]})]}),A&&!l&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("button",{onClick:d,disabled:C,className:f("p-1.5 rounded-lg transition-all active:scale-95",N?"bg-red-500 text-white animate-pulse":"bg-red-500/10 text-red-400 hover:bg-red-500/20",C&&"opacity-50 cursor-not-allowed"),title:N?"Click again to confirm":"Reject",children:x?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(Ke,{size:16})}),e.jsx("button",{onClick:v,disabled:C,className:f("p-1.5 rounded-lg transition-all bg-green-500/20 text-green-400 hover:bg-green-500/30 active:scale-95",C&&"opacity-50 cursor-not-allowed"),title:"Approve",children:m?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(pe,{size:16})})]})]})]}),e.jsx(Wr,{open:g,onOpenChange:n,title:"Review Recipe",size:"lg",children:e.jsxs("div",{className:"p-6 space-y-5",children:[t.previewImageUrl?e.jsxs("div",{className:"relative aspect-video bg-rh-surface-3 rounded-xl overflow-hidden",children:[e.jsx("img",{src:t.previewImageUrl,alt:b,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute top-3 left-3 px-2.5 py-1 rounded bg-black/60 backdrop-blur-sm text-white text-[10px] font-bold uppercase",children:"Real output from this recipe"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-xl bg-orange-500/10 border border-orange-500/20 text-xs text-orange-300",children:[e.jsx(ce,{size:14,className:"flex-shrink-0"}),"No generated output was attached to this submission."]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[11px] text-rh-text-dark uppercase tracking-wider mb-2 block",children:["Layout (",y.length," zone",y.length===1?"":"s",")"]}),e.jsx(Qe,{zones:y,background:O,backgroundImageUrl:M,className:"rounded-xl border border-ink/10"})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-fg",children:b}),w&&e.jsx("p",{className:"text-sm text-rh-text-dark mt-1",children:w})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[11px]",children:[e.jsxs("span",{className:"px-2 py-1 rounded-lg bg-ink/5 text-rh-text-dark flex items-center gap-1",children:[e.jsx(Ns,{size:11}),t.authorName]}),e.jsxs("span",{className:"px-2 py-1 rounded-lg bg-ink/5 text-rh-text-dark flex items-center gap-1",children:[e.jsx(qr,{size:11}),Ye]}),e.jsxs("span",{className:"px-2 py-1 rounded-lg bg-ink/5 text-rh-text-dark flex items-center gap-1",children:[e.jsx(ln,{size:11}),y.length," zones"]}),P&&e.jsxs("span",{className:"px-2 py-1 rounded-lg bg-ink/5 text-rh-text-dark flex items-center gap-1",children:[e.jsx(Tl,{size:11}),"Forked from ",P]}),R&&e.jsxs("span",{className:"px-2 py-1 rounded-lg bg-ink/5 text-rh-text-dark flex items-center gap-1",children:[e.jsx(ce,{size:11}),"Channel import",B!=null&&B.title?`: ${B.title}`:""]}),e.jsx("span",{className:f("px-2 py-1 rounded-lg text-[11px] font-medium",D.className),children:D.label})]}),t.status==="rejected"&&t.rejectionReason&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-500/10 border border-red-500/20 text-xs text-red-300",children:["Rejected: ",t.rejectionReason]}),A&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 rounded-xl border border-ink/10 bg-ink/5",children:[e.jsx("label",{className:"text-[11px] text-rh-text-dark uppercase tracking-wider mb-2 block",children:"Rejection reason (shown to the creator)"}),e.jsx("textarea",{value:L,onChange:fe=>k(fe.target.value),placeholder:"Optional, why is this being rejected?",className:"w-full px-3 py-2 rounded-lg bg-black/30 light:bg-ink/5 border border-ink/10 text-sm text-fg placeholder:text-rh-text-dark/50 resize-none focus:outline-none focus:border-ink/20",rows:2})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsxs("button",{onClick:d,disabled:C,className:f("flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-xl text-sm font-semibold transition-all active:scale-[0.98]",N?"bg-red-500 text-white animate-pulse":"bg-red-500/10 text-red-400 hover:bg-red-500/20",C&&"opacity-50 cursor-not-allowed"),children:[x?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(Ke,{size:16}),N?"Confirm Reject":"Reject"]}),e.jsxs("button",{onClick:v,disabled:C,className:f("flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-xl text-sm font-semibold transition-all","bg-green-500 text-white hover:bg-green-600 active:scale-[0.98]",C&&"opacity-50 cursor-not-allowed"),children:[m?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(pe,{size:16}),"Approve"]})]})]})]})})]})},ui=async()=>await on("getLearningSystemStats",{});function me(t){if(!t)return"never";const a=Date.now()-t;if(a<0)return"just now";const i=Math.floor(a/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const l=Math.floor(i/60);if(l<24)return`${l}h ago`;const c=Math.floor(l/24);return c<30?`${c}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function mt(t,a=1){return t==null||!Number.isFinite(t)?"...":`${(t*100).toFixed(a)}%`}
57function F(t){return t==null?"...":t.toLocaleString()}const ue=({title:t,icon:a,subtitle:i,children:l,className:c})=>e.jsxs("div",{className:f("bg-ink/5 border border-ink/10 rounded-xl p-4",c),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-orange-400",children:a}),e.jsx("h3",{className:"text-sm font-bold text-fg",children:t}),i&&e.jsx("span",{className:"text-[11px] text-rh-text-dark ml-auto",children:i})]}),l]}),Q=({label:t,value:a,tone:i="neutral"})=>e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:f("text-lg font-bold",i==="good"&&"text-emerald-400",i==="bad"&&"text-red-400",i==="neutral"&&"text-fg"),children:a}),e.jsx("span",{className:"text-[11px] text-rh-text-dark",children:t})]}),hi=({status:t})=>{if(!t)return e.jsx("span",{className:"text-rh-text-dark",children:"..."});const a={confirmed:"bg-emerald-500/15 text-emerald-400",corrected:"bg-amber-500/15 text-amber-400",provisional:"bg-sky-500/15 text-sky-400"};return e.jsx("span",{className:f("px-1.5 py-0.5 rounded text-[10px] font-bold",a[t]||"bg-ink/10 text-rh-text-light"),children:t})},pi=()=>{var T,v;const[t,a]=r.useState(null),[i,l]=r.useState(!0),[c,h]=r.useState(null),g=r.useCallback(async()=>{l(!0),h(null);try{const d=await ui();a(d)}catch(d){console.error("[IntelligencePanel] Failed to load stats:",d),h(d instanceof Error?d.message:"Failed to load learning stats")}finally{l(!1)}},[]);if(r.useEffect(()=>{g()},[g]),i&&!t)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(E,{size:24,className:"text-orange-500 animate-spin mb-3"}),e.jsx("p",{className:"text-sm text-rh-text-dark",children:"Loading learning system health..."})]});if(c&&!t)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-4",children:e.jsx(He,{size:24,className:"text-red-400"})}),e.jsx("h3",{className:"text-fg font-medium mb-1",children:"Couldn't load intelligence stats"}),e.jsx("p",{className:"text-sm text-rh-text-dark max-w-sm mb-4",children:c}),e.jsxs("button",{onClick:()=>void g(),className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium bg-orange-500 text-white hover:bg-orange-600 transition-colors",children:[e.jsx(ht,{size:14})," Retry"]})]});if(!t)return null;const n=t.worker||{},m=t.learningHealth,u=t.campaigns,x=n.abOutcomes,j=!!n.error,L=!!(m!=null&&m.lastFailureAt&&(!m.lastSuccessAt||m.lastFailureAt>m.lastSuccessAt)),k=!!(m&&(m.successCount>0||m.failureCount>0)),N=((T=u==null?void 0:u.byStatus)==null?void 0:T.active)??0,I=((v=u==null?void 0:u.byStatus)==null?void 0:v.completed)??0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs text-rh-text-dark",children:["Snapshot generated ",me(t.generatedAt)]}),e.jsxs("button",{onClick:()=>void g(),disabled:i,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs font-medium bg-ink/5 border border-ink/10 text-rh-text-light hover:bg-ink/10 transition-colors disabled:opacity-50",children:[e.jsx(ht,{size:12,className:f(i&&"animate-spin")})," Refresh"]})]}),j&&e.jsxs("div",{className:"flex items-start gap-3 bg-red-500/10 border border-red-500/30 rounded-xl p-4",children:[e.jsx(He,{size:18,className:"text-red-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-red-400",children:"D1 worker unreachable"}),e.jsx("p",{className:"text-xs text-rh-text-dark mt-1 break-all",children:n.error})]})]}),n.sectionErrors&&e.jsxs("div",{className:"flex items-start gap-3 bg-amber-500/10 border border-amber-500/30 rounded-xl p-4",children:[e.jsx(He,{size:18,className:"text-amber-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-amber-400",children:"Some D1 tables failed to query (possible schema drift)"}),e.jsx("p",{className:"text-xs text-rh-text-dark mt-1",children:Object.entries(n.sectionErrors).map(([d,C])=>`${d}: ${C}`).join(" · ")})]})]}),e.jsxs("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))"},children:[e.jsx(ue,{title:"Learning Writes",icon:e.jsx(cn,{size:16}),children:k?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:L?e.jsxs(e.Fragment,{children:[e.jsx(He,{size:16,className:"text-red-400"}),e.jsx("span",{className:"text-sm font-bold text-red-400",children:"Writes failing"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Br,{size:16,className:"text-emerald-400"}),e.jsx("span",{className:"text-sm font-bold text-emerald-400",children:"Writes healthy"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Q,{label:`succeeded · last ${me(m==null?void 0:m.lastSuccessAt)}`,value:F(m==null?void 0:m.successCount),tone:"good"}),e.jsx(Q,{label:`failed · last ${me(m==null?void 0:m.lastFailureAt)}`,value:F(m==null?void 0:m.failureCount),tone:m!=null&&m.failureCount?"bad":"neutral"})]}),L&&(m==null?void 0:m.lastFailureMessage)&&e.jsx("p",{className:"text-[11px] text-red-400/80 break-all",children:m.lastFailureMessage})]}):e.jsx("p",{className:"text-xs text-rh-text-dark",children:"No heartbeat data yet. This populates the first time a campaign or roun
57d learning record is sent to D1 after this update ships."})}),e.jsx(ue,{title:"A/B Campaigns",icon:e.jsx(fr,{size:16}),subtitle:"Firestore",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Q,{label:"total",value:F(u.total)}),e.jsx(Q,{label:"active",value:F(N),tone:N>0?"good":"neutral"}),e.jsx(Q,{label:"completed",value:F(I)})]}),e.jsxs("div",{className:"text-[11px] text-rh-text-dark space-y-0.5",children:[e.jsxs("p",{children:["Modes:"," ",Object.entries(u.byMeasurementMode).map(([d,C])=>`${d} × ${C}`).join(" · ")||"..."]}),e.jsxs("p",{children:["AI challenger won ",F(u.completedWithChallengerWin)," of ",F(I)," completed · newest campaign ",me(u.lastCreatedAtMs)]})]})]}):e.jsx("p",{className:"text-xs text-rh-text-dark",children:"Census unavailable."})}),e.jsx(ue,{title:"Learning Records",icon:e.jsx(jr,{size:16}),subtitle:"D1 ab_outcomes",children:x?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Q,{label:"total",value:F(x.total),tone:x.total>0?"neutral":"bad"}),e.jsx(Q,{label:"round experiments",value:F(x.roundRecords??0)}),e.jsx(Q,{label:"campaign records",value:F(x.campaignRecords??0)})]}),e.jsxs("p",{className:"text-[11px] text-rh-text-dark",children:[F(x.distinctChannels)," channels · ",F(x.aiWins??0)," AI wins · last record ",me(x.lastRecordAt)]}),x.total===0&&e.jsx("p",{className:"text-[11px] text-red-400/80",children:"Empty: no learning has ever been persisted. Expected until the pending migrations + worker deploy go out."})]}):e.jsx("p",{className:"text-xs text-rh-text-dark",children:"Table unavailable."})})]}),e.jsx(ue,{title:"Dimension Experiments",icon:e.jsx(Gt,{size:16}),subtitle:"what single-dimension mutations have proven",children:!n.dimensionStats||n.dimensionStats.length===0?e.jsx("p",{className:"text-xs text-rh-text-dark",children:"No round experiments recorded yet. Rows appear as CTR-hybrid campaigns complete mutation rounds."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-rh-text-dark border-b border-ink/10",children:[e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Dimension"}),e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Value"}),e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Experiments"}),e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Wins"}),e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Avg lift"}),e.jsx("th",{className:"py-2 font-medium",children:"Avg confidence"})]})}),e.jsx("tbody",{children:n.dimensionStats.map((d,C)=>e.jsxs("tr",{className:"border-b border-ink/5 text-rh-text-light",children:[e.jsx("td",{className:"py-2 pr-4 text-fg font-medium",children:d.dimension}),e.jsx("td",{className:"py-2 pr-4",children:d.value}),e.jsx("td",{className:"py-2 pr-4",children:F(d.experiments)}),e.jsx("td",{className:"py-2 pr-4",children:F(d.wins)}),e.jsx("td",{className:f("py-2 pr-4",(d.avgLift??0)>0?"text-emerald-400":"text-rh-text-light"),children:mt(d.avgLift)}),e.jsx("td",{className:"py-2",children:mt(d.avgConfidence,0)})]},`${d.dimension}-${d.value}-${C}`))})]})})}),e.jsxs("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(ue,{title:"Insight Patterns",icon:e.jsx(xe,{size:16}),subtitle:"D1 insight_patterns",children:n.insightPatterns?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Q,{label:"patterns",value:F(n.insightPatterns.total)}),e.jsx(Q,{label:"promoted to DNA",value:F(n.insightPatterns.promoted??0)}),e.jsx(Q,{label:"channels",value:F(n.insightPatterns.distinctChannels)})]}),e.jsxs("p",{className:"text-[11px] text-rh-text-dark",children:["Last pattern seen ",me(n.insightPatterns.lastSeenAt)]}),n.topPatterns&&n.topPatterns.length>0&&e.jsx("div",{className:"space-y-1.5 max-h-64 overflow-y-auto pr-1",children:n.topPatterns.map((d,C)=>e.jsxs("div",{className:"bg-ink/5 rounded-lg px-3 py-2",children:[e.jsx("p",{className:"text-xs text-fg leading-snug",children:d.patternText}),e.jsxs("p",{className:"text-[10px] text-rh-text-dark mt-0.5",children:[d.winCount," wins · ",mt(d.avgLift,0)," avg lift · conf ",mt(d.confidenceScore,0),d.promotedToDna===1&&e.jsx("span",{className:"text-emerald-400",children:" · promoted"}),d.channelId?" · channel-scoped":d.clusterId?" · niche-scoped":" · global"]})]},C))})]}):e.jsx("p",{className:"text-xs text-rh-text-dark",children:"Table unavailable."})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ue,{title:"Analysis Pipeline",icon:e.jsx($r,{size:16}),subtitle:"D1 video_analysis / ctr_history",children:n.videoAnalysis?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Q,{label:"videos analyzed",value:F(n.videoAnalysis.total)}),e.jsx(Q,{label:"clustered",value:F(n.videoAnalysis.clustered??0)}),e.jsx(Q,{label:"last 7 days",value:F(n.videoAnalysis.analyzedLast7d??0),tone:(n.videoAnalysis.analyzedLast7d??0)>0?"good":"bad"})]}),e.jsxs("p",{className:"text-[11px] text-rh-text-dark",children:[F(n.videoAnalysis.distinctChannels)," channels · last analysis ",me(n.videoAnalysis.lastAnalyzedAt),n.ctrHistory&&e.jsxs(e.Fragment,{children:[" ","· CTR history: ",F(n.ctrHistory.rows)," rows, latest ",n.ctrHistory.latestDate??"..."]})]})]}):e.jsx("p",{className:"text-xs text-rh-text-dark",children:"Table unavailable."})}),e.jsx(ue,{title:"Exploration System",icon:e.jsx(fr,{size:16}),subtitle:"trends · novel combos",children:n.exploration?e.jsxs("div",{className:"text-[11px] text-rh-text-dark space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg font-medium",children:"Trends:"})," ",n.exploration.trendsByStatus.length>0?n.exploration.trendsByStatus.map(d=>`${d.status} × ${d.count}`).join(" · "):"none detected yet"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg font-medium",children:"Novel combos:"})," ",n.exploration.combosByStatus.length>0?n.exploration.combosByStatus.map(d=>`${d.status} × ${d.count}`).join(" · "):"none generated yet"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg font-medium",children:"Exploration outcomes:"})," ",n.exploration.outcomesByType.length>0?n.exploration.outcomesByType.map(d=>`${d.explorationType}: ${d.wins??0}/${d.attempts??0} wins`).join(" · "):"none recorded yet"]}),n.promotionCandidates&&n.promotionCandidates.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg font-medium",children:"Promotion queue:"})," ",n.promotionCandidates.map(d=>`${d.status} × ${d.count}`).join(" · ")]})]}):e.jsx("p",{className:"text-xs text-rh-text-dark",children:"Tables unavailable."})})]})]}),e.jsx(ue,{title:"Recent Learning Records",icon:e.jsx(jr,{size:16}),subtitle:"latest 15 from ab_outcomes",children:!n.recentOutcomes||n.recentOutcomes.length===0?e.jsx("p",{className:"text-xs text-rh-text-dark",children:"No records yet."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-rh-text-dark border-b border-ink/10",children:[e.jsx("th",{className:"py-2 pr-4 font-medium",children:"When"}),e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Type"}),e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Experiment"}),e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Verdict"}),e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Winner"}),e.jsx("th",{className:"py-2 pr-4 font-medium",children:"Lift"}),e.jsx("th",{className:"py-2 font-medium",children:"Channel"})]})}),e.jsx("tbody",{children:n.recentOutcomes.map(d=>e.jsxs("tr",{className:"border-b border-ink/5 text-rh-text-light",children:[e.jsx("td",{className:"py-2 pr-4 whitespace-nowrap",children:me(d.createdAt)}),e.jsx("td",{className:"py-2 pr-4",children:d.recordType==="round"?`round ${d.roundNumber??"?"}${d.phase?` · ${d.phase}`:""}`:"campaign"}),e.jsx("td",{className:"py-2 pr-4",children:d.mutatedDimension?e.jsxs("span",{className:"text-fg",children:[d.mutatedDimension,": ",d.mutatedFrom??"?"," → ",d.mutatedTo??"?"]}):e.jsx("span",{className:"text-rh-text-dark",children:"..."})}),e.jsx("td",{className:"py-2 pr-4",children:e.jsx(hi,{status:d.verdictStatus})}),e.jsx("td",{className:"py-2 pr-4",children:d.winnerGeneration>0?e.jsxs("span",{className:"text-emerald-400 font-medium",children:["AI gen ",d.winnerGeneration]}):e.jsx("span",{className:"text-rh-text-light",children:"original"})}),e.jsx("td",{className:f("py-2 pr-4",d.improvementPct>0?"text-emerald-400":"text-rh-text-light"),children:Number.isFinite(d.improvementPct)?`+${mt(d.improvementPct)}`:"..."}),e.jsx("td",{className:"py-2 text-rh-text-dark truncate max-w-[140px]",children:d.channelId})]},d.id))})]})})})]})},gi=r.lazy(()=>Rn(()=>import("./MobileTemplateLibrary-D-13vx2K.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67])).then(t=>({default:t.MobileTemplateLibrary}))),fi=t=>{const a=new Set(t.map(i=>i.category));return["all",...Array.from(a).sort()]},bi={film:"movie reviews, film breakdowns...",autos:"car reviews, engine builds...",music:"guitar covers, beat making...",pets:"dog training, cat behaviors...",sports:"football highlights, basketball tricks...",travel:"hidden gems, travel vlogs...",gaming:"Minecraft builds, game reviews...",blogs:"day in my life, storytime...",comedy:"sketch ideas, funny reactions...",entertainment:"celebrity news, pop culture...",news:"breaking news, current events...",howto:"DIY projects, life hacks...",education:"study tips, science explained...",tech:"phone reviews, app tutorials...",tools:"productivity apps, gear reviews..."},ta=["education","howto","tools"],ji=new Set(["music","film","news","autos","comedy","pets"]),ut=(t,a={})=>a.enforceBeta??!0?t.filter(l=>ta.includes(l.category)):t,ie="grid w-full gap-3 sm:gap-4",X=260,vi=220,Ft=16,yi=280,se=t=>({gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`}),Ni=(t=2)=>{const[a,i]=r.useState(()=>{const g=window.innerWidth-yi;return Math.max(Math.floor((g+Ft)/(X+Ft)),2)*t}),l=r.useRef(null),c=r.useRef(t);c.current=t;const h=r.useCallback(g=>{var u;if((u=l.current)==null||u.disconnect(),l.current=null,!g)return;const n=()=>{const x=g.clientWidth;if(!x)return;const j=Math.max(Math.floor((x+Ft)/(X+Ft)),2);i(j*c.current)};n();const m=new ResizeObserver(n);m.observe(g),l.current=m},[]);return r.useEffect(()=>()=>{var g;return(g=l.current)==null?void 0:g.disconnect()},[]),{limit:a,gridRef:h}},Oe=()=>e.jsxs("div",{className:"w-full animate-pulse",children:[e.jsx("div",{className:"aspect-video rounded-xl bg-ink/5 mb-2 sm:mb-3"}),e.jsx("div",{className:"h-4 bg-ink/5 rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-4 bg-ink/5 rounded w-1/2 mb-2"}),e.jsx("div",{className:"h-3 bg-ink/5 rounded w-1/3"})]}),he=({icon:t,title:a,onSeeAll:i,actions:l})=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t,e.jsx("h2",{className:"text-lg font-bold text-fg",children:a})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap justify-end",children:[l,i&&e.jsxs("button",{onClick:i,className:"flex items-center gap-1 text-sm font-medium text-rh-text-dark hover:text-fg transition-colors",children:["See all",e.jsx(ys,{size:16})]})]})]}),Pt=new Set(["templates","tools","recipes"]),ki={gaming:e.jsx(Ur,{size:16,className:"text-emerald-400"}),finance:e.jsx(ul,{size:16,className:"text-green-400"}),food:e.jsx(Fl,{size:16,className:"text-orange-400"}),tech:e.jsx(yl,{size:16,className:"text-sky-400"}),fitness:e.jsx(wl,{size:16,className:"text-red-400"}),lifestyle:e.jsx(jl,{size:16,className:"text-pink-400"}),commentary:e.jsx(zn,{size:16,className:"text-yellow-400"}),education:e.jsx(zl,{size:16,className:"text-blue-400"}),mystery:e.jsx(ml,{size:16,className:"text-purple-400"}),people:e.jsx(bl,{size:16,className:"text-violet-400"}),sports:e.jsx(fl,{size:16,className:"text-amber-400"}),fun:e.jsx(xl,{size:16,className:"text-teal-400"}),news:e.jsx(Dl,{size:16,className:"text-rose-400"}),more:e.jsx(xe,{size:16,className:"text-rh-accent"})},bs=24,js={trending:{title:"Trending This Week",icon:e.jsx(ge,{size:20,className:"text-orange-500"})},popular:{title:"Popular Templates",icon:e.jsx(Gt,{size:20,className:"text-green-500"})},new:{title:"New Templates",icon:e.jsx(xe,{size:20,className:"text-rh-accent"})}},wi=()=>{var nr,lr,ir;Mn("Library");const{studioId:t,templateId:a}=In(),[i,l]=An(),c=Fr(),{toastMessage:h,toastVariant:g,showToast:n,dismissToast:m}=dn(),{user:u}=xn(),{activeStudio:x}=Dr(),j=(x==null?void 0:x.ownerUid)??(u==null?void 0:u.uid)??null,{accountSettings:L,privacySettings:k,togglePrivacy:N}=mn(),{isTouchDevice:I}=un(),{isAdmin:T}=Er(),{budget:v}=hn(),d=!v.isEmpty,{createProjectFromTemplate:C,isCreating:A,error:z,clearError:D}=Ln({trackingSource:"library",activationEntrySurface:"template_library",deviceClass:"desktop"}),b=i.get("feed"),w=b&&js[b]?b:null,[y,O]=r.useState(()=>a&&Pt.has(a)?a:"all"),[K,P]=r.useState(null),B=y==="recipes"||y==="templates",R=i.get("q")||"",[M,Ye]=r.useState(R),[fe,Se]=r.useState(null),[sa,Ze]=r.useState(!1),[ra,zs]=r.useState(!1),[G,Zt]=r.useState("new"),[J,Xt]=r.useState("all"),[Xe,Is]=r.useState("popular"),[As,Ms]=r.useState(bs),[aa,na]=r.useState(!1),Je=r.useRef(null);r.useEffect(()=>{const s=Je.current;if(!s)return;const o=()=>{na(s.scrollTop>600)};return s.addEventListener("scroll",o,{passive:!0}),()=>s.removeEventListener("scroll",o)},[]);const la=r.useCallback(()=>{var s;(s=Je.current)==null||s.scrollTo({top:0,behavior:"smooth"})},[]);r.useEffect(()=>{i.get("request")==="1"&&(Ze(!0),l(s=>{const o=new URLSearchParams(s);return o.delete("request"),o},{replace:!0}))},[i,l]);const ia=r.useRef(null),[,oa]=r.useState(!1),[,ca]=r.useState(!1),Te=r.useCallback(()=>{const s=ia.current;s&&(oa(s.scrollLeft>0),ca(s.scrollLeft<s.scrollWidth-s.clientWidth-1))},[]);r.useEffect(()=>(Te(),window.addEventListener("resize",Te),()=>window.removeEventListener("resize",Te)),[Te]),r.useEffect(()=>{if(!R){Ye("");return}const s=setTimeout(()=>{Ye(R)},300);return()=>clearTimeout(s)},[R]);const _=!0,{templates:Ls,categories:ft,isLoading:bt,hasMore:et,loadMore:Es,setFilter:da,refresh:xa,options:tt}=pn({status:"active",category:y==="all"||B?void 0:y}),{limit:Re,gridRef:ma}=Ni(2),{isLoading:ua}=gn(6),{templates:Ds,isLoading:jt}=fn(w==="trending"?150:Math.max(Re,12)),{templates:qs,isLoading:Jt}=bn(w==="popular"?150:Re),{templates:$s,isLoading:es}=jn(w==="new"?150:Re),{templates:Fs,isLoading:ha,currentQuery:pa,status:ga}=vn(M,500),{trackClick:Ps}=_n({source:"library"}),{favorites:be}=qn(),[q,st]=r.useState(!1),[U,vt]=r.useState(!1),[V,yt]=r.useState("requests"),[rt,_s]=r.useState(0),ze=5,[Bs,Nt]=r.useState(!1),[ee,Ie]=r.useState(new Set),[kt,Us]=r.useState(!1),[fa,ts]=r.useState(!1),ba=s=>{Ie(o=>{const p=new Set(o);return p.has(s)?p.delete(s):p.add(s),p})},ja=()=>{ee.size===ne.length?Ie(new Set):Ie(new Set(ne.map(s=>s.id)))},va=()=>{Nt(!1),Ie(new Set)},ya=()=>{ee.size!==0&&ts(!0)},Na=async()=>{Us(!0);try{const s=[...ee].map(S=>
57dr(S,"Bulk delete from admin").catch($=>(console.error(`[Admin] Failed to delete draft ${S}:`,$),{failed:S,error:$}))),p=(await Promise.all(s)).filter(S=>S&&typeof S=="object"&&"failed"in S);if(p.length>0){const S=ee.size-p.length;n(`Deleted ${S} draft${S===1?"":"s"}. ${p.length} could not be deleted - please try again.`,"info",5e3)}Ie(new Set),Nt(!1)}catch(s){console.error("[Admin] Bulk delete error:",s),n("Bulk delete failed. Please try again.","error",5e3)}finally{Us(!1),ts(!1)}};r.useEffect(()=>{(V!=="drafts"||!U)&&(Nt(!1),Ie(new Set))},[V,U]);const[ss,at]=r.useState(!1),[Y,Ae]=r.useState(new Set),[de,wt]=r.useState(null),[Me,Os]=r.useState(!1),[Le,Gs]=r.useState("all"),[je,rs]=r.useState("manual"),ka=s=>{Ae(o=>{const p=new Set(o);return p.has(s)?p.delete(s):p.add(s),p})},wa=()=>{at(!1),Ae(new Set)};r.useEffect(()=>{(V!=="recipes"||!U)&&(at(!1),Ae(new Set))},[V,U]);const{requests:as,isLoading:Ca}=$t({status:"pending",enabled:T}),Ct=T&&U,{requests:Sa,isLoading:Ta}=$t({status:"processing",enabled:Ct}),{requests:Ra,isLoading:za}=$t({status:"failed",enabled:Ct}),{requests:Ee,isLoading:Ia}=$t({status:"completed",enabled:Ct}),ns=(s,o)=>s.sourceType==="search"&&o.sourceType==="channel"?-1:s.sourceType==="channel"&&o.sourceType==="search"?1:0,ve=[...[...Sa].filter(s=>s.isStuck).sort(ns),...[...Ra].sort(ns),...[...as].sort(ns)],Aa=Ca||Ta||za,{requests:ae}=Ol({enabled:T}),{templates:ne,isLoading:Ma}=Gl({enabled:Ct}),[De,La]=r.useState([]),[Ea,ls]=r.useState(!0);r.useEffect(()=>T?(ls(!0),cl(o=>{La(o),ls(!1)},o=>{console.error("[Admin] Community creations listener error:",o),ls(!1)},{pendingOnly:!U})):void 0,[T,U]);const te=r.useMemo(()=>{const s=o=>o.status==="pending"?0:1;return De.filter(o=>o.status!=="rejected").sort((o,p)=>s(o)-s(p)||p.createdAt-o.createdAt)},[De]),qe=s=>s.source==="channel_import",nt=r.useMemo(()=>De.filter(s=>s.status==="pending"&&!qe(s)).length,[De]),lt=r.useMemo(()=>De.filter(s=>s.status==="pending"&&qe(s)).length,[De]),ye=r.useMemo(()=>je==="all"?te:te.filter(s=>je==="channel"===qe(s)),[te,je]),Da=r.useMemo(()=>({manual:te.filter(s=>!qe(s)).length,channel:te.filter(qe).length,all:te.length}),[te]),qa=r.useMemo(()=>({all:ye.length,pending:ye.filter(s=>s.status==="pending").length,approved:ye.filter(s=>s.status==="approved").length}),[ye]),St=r.useMemo(()=>Le==="all"?ye:ye.filter(s=>s.status===Le),[ye,Le]),Ne=r.useMemo(()=>St.filter(s=>s.status==="pending").map(s=>s.id),[St]),Tt=r.useMemo(()=>te.filter(s=>s.status==="pending"&&qe(s)).map(s=>s.id),[te]),$a=()=>{rs("channel"),Gs("pending"),at(!0),Ae(new Set(Tt))},Fa=()=>{Ae(s=>s.size===Ne.length?new Set:new Set(Ne))},Pa=async()=>{if(!de||Y.size===0)return;Os(!0);const s=de==="approve";try{const o=[...Y],p=[],S=20;for(let Z=0;Z<o.length;Z+=S){const Lt=await Promise.all(o.slice(Z,Z+S).map(Ue=>(s?pr(Ue):hr(Ue,void 0)).then(()=>null).catch(Xa=>(console.error(`[Admin] Failed to ${de} creation ${Ue}:`,Xa),Ue))));p.push(...Lt.filter(Ue=>Ue!==null))}const $=Y.size-p.length;n(p.length>0?`${s?"Approved":"Rejected"} ${$} recipe${$===1?"":"s"}, ${p.length} failed, please retry.`:`${s?"Approved":"Rejected"} ${$} recipe${$===1?"":"s"}.`,p.length>0?"info":"success",4500),Ae(new Set),at(!1)}finally{Os(!1),wt(null)}};Pl(y!=="all"&&!B?y:null,5),r.useEffect(()=>{P(null)},[y]);const it=r.useRef(null),Vs=r.useCallback(s=>{if(it.current&&(it.current.disconnect(),it.current=null),bt||!s)return;const o=Je.current;it.current=new IntersectionObserver(p=>{p[0].isIntersecting&&et&&_&&Es()},{root:o,rootMargin:"200px"}),it.current.observe(s)},[bt,et,Es,_]),ot=r.useRef(null),_a=r.useCallback(s=>{ot.current&&(ot.current.disconnect(),ot.current=null),s&&(ot.current=new IntersectionObserver(o=>{o[0].isIntersecting&&Ms(p=>p+bs)},{root:Je.current,rootMargin:"200px"}),ot.current.observe(s))},[]),W=r.useMemo(()=>Ls.map(s=>Ce(s)),[_,Ls]),H=r.useMemo(()=>{const o=Ds.map(Ce).filter(p=>p.name!=="Blank Canvas");return ut(o,{enforceBeta:!1})},[_,Ds]),$e=r.useMemo(()=>{const s=qs.map(Ce);return ut(s)},[_,qs]),Fe=r.useMemo(()=>{const s=$s.map(Ce);return ut(s,{enforceBeta:!1})},[_,$s]),Ws=r.useMemo(()=>{const s=new Set,o=[];for(const p of[...Fe,...H,...$e,...W])if(!(!p.image||s.has(p.id))&&(s.add(p.id),o.push({src:p.image,fallbacks:_t(p.id,p.subjectType,{hasGenderVariants:p.hasGenderVariants,detectedGender:p.detectedGender})}),o.length>=6))break;return o},[W,Fe,$e,H]),Ba=r.useCallback(()=>{N("marketingCommunicationsOptIn")},[N]);r.useEffect(()=>{!a||!Pt.has(a)||(O(a),st(!1),vt(!1))},[a]),r.useEffect(()=>{if(!a||Pt.has(a))return;const s=W.find(o=>o.id===a)||H.find(o=>o.id===a)||Fe.find(o=>o.id===a)||$e.find(o=>o.id===a);if(s){Se(s);return}yn(a).then(o=>{o?Se(Ce(o)):c(`/studio/${t}/templates`,{replace:!0})}).catch(()=>{c(`/studio/${t}/templates`,{replace:!0})})},[a,W,H,Fe,$e,_,t,c]);const Hs=r.useMemo(()=>{const s=be.filter(p=>p.startsWith("recipe:"));if(s.length===0)return[];const o=xr();return s.map(p=>o.find(S=>Et(S)===p)).filter(p=>p!==void 0)},[be]),[Qs,is]=r.useState([]),[Ua,Ks]=r.useState(!1),Rt=r.useMemo(()=>be.filter(s=>!s.startsWith("recipe:")),[be]);r.useEffect(()=>{if(Rt.length===0){is([]);return}let s=!1;return Ks(!0),Nn(Rt).then(o=>{if(s)return;const p=o.map(Ce),S=Rt.map($=>p.find(Z=>Z.id===$)).filter($=>$!==void 0);is(ut(S,{enforceBeta:!1}))}).catch(o=>{console.error("[TemplateLibrary] Failed to fetch favorite templates:",o),s||is([])}).finally(()=>{s||Ks(!1)}),()=>{s=!0}},[_,Rt]);const os=r.useMemo(()=>{const s=Fs.map(Ce);return ut(s,{enforceBeta:!1})},[_,Fs]),Oa=r.useMemo(()=>{let s;return ft.length>0?s=["all",...ft.map(o=>o.slug)]:s=fi(W),s.filter(o=>o!=="tools"&&(o==="all"||!ji.has(o)))},[_,ft,W]),Ys=y==="tools"?"tools":y==="recipes"?"recipes":"templates";r.useEffect(()=>{const s=setTimeout(Te,100);return()=>clearTimeout(s)},[Oa,Te]);const Pe=r.useMemo(()=>q?Qs:M||R?os:W.filter(s=>{var S;const o=y==="all"?ta.includes(s.category):y==="templates"?!0:s.category===y,p=!K||((S=s.stats)==null?void 0:S.subcategory)===K;return o&&p}),[_,M,os,W,y,K,R,q,Qs]),Ga=bt&&W.length===0,Va=ua||jt||Jt||es,ct=(M||R)&&(ha||M&&M!==pa||R&&R!==M),{markSearchResultClick:Zs}=Ul({query:R||M,resultsCount:os.length,isLoading:ct,searchStatus:ga}),cs=Ga,Wa=(y==="all"||B?void 0:y)!==tt.category,ds=bt||Wa,zt=y==="all"&&!R&&!w&&!q,ke=r.useCallback((s,o)=>{const p=R||M,S=p?"search":y!=="all"&&y!=="templates"?"category":w||zt?"recommendation":"library";S==="search"&&Zs(),Ps(s.id,o,{templateSource:S,searchQuery:p||void 0,templateCategory:s.category,selectedCategory:y!=="all"?y:void 0,selectedSubcategory:K??void 0}),Se(s),c(`/studio/${t}/templates/${s.id}`,{replace:!0})},[Ps,R,M,y,K,w,zt,t,c,Zs]),Ha=r.useCallback(()=>{Se(null),c(`/studio/${t}/templates`,{replace:!0})},[t,c]),Xs=r.useCallback(s=>{l({feed:s})},[l]),Qa=r.useCallback(()=>
57{l({})},[l]),Ka=r.useCallback(async s=>{if(!fe||!t)return;const o=await C(fe,t);if(o){Se(null);let p=`/studio/${t}/editor/${o.projectId}`;if(s){const S=new URLSearchParams({action:s});p=`${p}?${S.toString()}`}c(p)}},[fe,t,C,c]),xs=r.useCallback(s=>{O(s),st(!1),vt(!1);const o=`/studio/${t}/templates`,p=Pt.has(s)?`${o}/${s}`:o,S=new URLSearchParams(i);S.delete("q"),c({pathname:p,search:S.toString()},{replace:!0})},[t,i,c]),ms=r.useMemo(()=>{const s=R||M;return s?Zn(s):null},[R,M]),It=r.useCallback(s=>{if(!t)return;const o=(R||M).trim();o&&Lr.app.searchRescued({searchQuery:o,toolName:s}),c(`/studio/${t}/new`,{state:{startPath:"image",prefillTool:s}})},[t,c,R,M]),_e=r.useMemo(()=>{if(q)return[];const s=R||M;return s?Xn(s):y!=="tools"?[]:En()},[y,R,M,q]),we=r.useMemo(()=>_e.find(s=>s.name==="Reshoot")??_e[0]??null,[_e]),le=r.useMemo(()=>{if(q)return Hs;const s=R||M;return s?tl(s):y==="recipes"?xr():[]},[q,Hs,R,M,y]),us=r.useMemo(()=>{if(q)return[];const s=R||M;return s?ni(s):[]},[q,R,M]),Ya=r.useCallback(s=>{n(s,"error")},[n]),{launchRecipe:Be,launcherUI:Za}=Cs({studioId:t,onError:Ya}),{recipes:At}=rl(10),{recipes:Js}=al(6),er=r.useRef(null),Mt=r.useMemo(()=>H.slice(0,10).map((s,o)=>({key:s.id,name:s.name,image:We(s.image,"medium")||s.image,fallbackImages:_t(s.id,s.subjectType,{hasGenderVariants:s.hasGenderVariants,detectedGender:s.detectedGender}).map(p=>We(p,"medium")||p),onClick:()=>ke(s,o)})),[H,ke]),tr=r.useMemo(()=>At.map(s=>({key:Et(s),name:s.name,image:Rs(s),onClick:()=>Be(s)})),[At,Be]),hs=r.useMemo(()=>sl(le),[le]),sr=r.useMemo(()=>{var p;const s=J==="all"?le:((p=hs.find(S=>S.id===J))==null?void 0:p.recipes)??[];if(Xe==="new")return[...s].reverse();const o=new Map(At.map((S,$)=>[Bt(S),$]));return[...s].sort((S,$)=>(o.get(Bt(S))??1/0)-(o.get(Bt($))??1/0))},[le,hs,J,Xe,At]),rr=r.useMemo(()=>J==="channels"?Tr().map(s=>({kind:"channel",entry:s})):sr.map(s=>({kind:"builtin",recipe:s})),[sr,J]),dt=Jr({studioId:t,userId:j,showToast:n});r.useEffect(()=>{Ms(bs)},[J,Xe]);const ar=r.useMemo(()=>{const s=new Set([2,5,8]),o=e.jsx("span",{className:"flex-shrink-0 px-1.5 py-0.5 rounded bg-rh-accent/15 text-[9px] font-bold uppercase tracking-wide text-rh-accent",children:"Recipe"}),p=[...Mt],S=tr.map(Z=>({...Z,badge:o})),$=[];for(let Z=0;Z<10;Z++){const Lt=s.has(Z)?S.shift()??p.shift():p.shift()??S.shift();if(!Lt)break;$.push(Lt)}return $},[Mt,tr]);return I?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"h-full bg-rh-dark"}),children:e.jsx(gi,{})}):e.jsxs("div",{className:"h-full w-full flex flex-col bg-rh-dark sm:rounded-2xl p-3 sm:p-6 md:p-8 relative",children:[ct&&e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 z-50 overflow-hidden",children:e.jsx("div",{className:"h-full animate-loading-bar"})}),e.jsx("div",{className:"flex-shrink-0 sticky top-0 z-30 bg-rh-dark/95 backdrop-blur-xl border-b border-ink/5 -mx-3 sm:-mx-6 md:-mx-8 px-3 sm:px-6 md:px-8 py-3 mb-6 transition-all",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-xl bg-ink/5 border border-ink/10",children:[{id:"all",label:"All",icon:e.jsx(ps,{size:16})},{id:"templates",label:"Templates",icon:e.jsx(vs,{size:16})},{id:"recipes",label:"Recipes",icon:e.jsx(ce,{size:16})},{id:"tools",label:"Tools",icon:e.jsx(Ge,{size:16})}].map(s=>{const o=!q&&!U&&(s.id==="all"?y==="all":s.id==="templates"?Ys==="templates"&&y!=="all":Ys===s.id);return e.jsxs("button",{onClick:()=>xs(s.id),className:f("flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-semibold transition-all",o?"bg-fg text-rh-dark shadow-sm":"text-rh-text-light hover:text-fg hover:bg-ink/10"),children:[s.icon,s.label]},s.id)})}),e.jsxs("div",{className:"hidden lg:flex items-center gap-2 min-w-0 ml-3",children:[e.jsx("span",{className:"text-sm text-rh-text-dark truncate",children:"Thumbnail designs our users are requesting, added daily."}),e.jsx("a",{href:"/help-center/templates-tools/can-i-use-templates-commercially",target:"_blank",rel:"noopener noreferrer",className:"flex-shrink-0 px-2 py-0.5 rounded-full bg-ink/10 text-fg/70 text-xs font-medium hover:bg-ink/15 hover:text-fg transition-colors cursor-pointer",children:"✓ Use & sell freely"})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[be.length>0&&e.jsxs("button",{onClick:()=>{st(!q),vt(!1),q||(O("all"),P(null)),l(s=>{const o=new URLSearchParams(s);return o.delete("q"),o},{replace:!0})},className:f("flex-shrink-0 flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-medium transition-all border",q&&!U?"bg-red-500/10 border-red-500/20 text-red-400":"bg-ink/5 border-ink/10 text-rh-text-light hover:bg-ink/10 hover:text-fg"),children:[e.jsx(fs,{size:14,className:q&&!U?"fill-red-400":""}),e.jsx("span",{className:"hidden sm:inline",children:"Favorites"}),e.jsx("span",{className:f("px-1.5 py-0.5 rounded text-[10px] font-bold",q?"bg-red-500/20":"bg-ink/10"),children:be.length})]}),T&&e.jsxs("button",{onClick:()=>{vt(!0),st(!1),O("all"),l(s=>{const o=new URLSearchParams(s);return o.delete("q"),o},{replace:!0})},className:f("flex-shrink-0 flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-medium transition-all border",U?"bg-orange-500 text-white border-orange-500":"bg-orange-500/10 border-orange-500/30 text-orange-400 hover:bg-orange-500/20"),children:[e.jsx(gr,{size:14}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"}),as.length+ae.length+nt>0&&e.jsx("span",{className:f("px-1.5 py-0.5 rounded-full text-[10px] font-bold min-w-[18px] text-center",U?"bg-ink/20 text-white":"bg-orange-500 text-white"),children:as.length+ae.length+nt})]}),e.jsxs("button",{onClick:()=>zs(!0),className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-medium transition-all border bg-ink/5 border-ink/10 text-rh-text-light hover:bg-ink/10 hover:text-fg",children:[e.jsx(ks,{size:14}),"Drops"]}),e.jsxs("button",{onClick:()=>Ze(!0),className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-medium transition-all border bg-fg text-rh-dark border-fg hover:bg-fg/90",children:[e.jsx(gs,{size:14}),"Request"]})]})]})}),z&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-red-500/10 border border-red-500/20 flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-red-400",children:z}),e.jsx("button",{onClick:D,className:"p-1 hover:bg-red-500/20 rounded",children:e.jsx(Ke,{size:14,className:"text-red-400"})})]}),e.jsxs("div",{ref:Je,className:f("flex-grow leet-scroll-hide",!cs&&!U&&!w&&Pe.length===0&&le.length===0&&!ct&&!ds?"overflow-hidden":"overflow-y-auto"),children:[(R||M)&&!q&&!U&&!w&&e.jsx(or,{onSelectTool:It,highlightTool:ms==null?void 0:ms.name}),(R||M)&&Qn(M||R)&&!q&&!U&&!w&&e.jsx(Kn,{variant:"block",className:"mb-6 max-w-2xl"}),cs&&zt?e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"hidden xl:block",children:e.jsx(Sr,{})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"h-9 w-20 bg-ink/10 rounded-lg"}),e.jsx("div",{className:"h-9 w-24 bg-ink/5 rounded-lg"}),e.jsx("div",{className:"h-9 w-20 bg-ink/5 rounded-lg"})]}),e.jsx("div",{className:ie,style:se(X),children:Array.from({length:Re}).map((s,o)=>e.jsx(Oe,{},o))})]}),e.jsxs("section",{className:"mt-12",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-ink/10"}),e.jsx("div",{className:"h-5 w-40 bg-ink/10 rounded"})]}),e.jsx("div",{className:ie,style:se(X),children:Array.from({length:8}).map((s,o)=>e.jsx(Oe,{},o))})]})]}):cs||ds&&Pe.length===0&&_e.length===0&&le.length===0?e.jsxs("div",{className:"animate-pulse",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-ink/10"}),e.jsx("div",{className:"h-5 w-32 bg-ink/10 rounded"})]}),e.jsx("div",{className:"h-8 w-24 bg-ink/5 rounded-lg"})]}),e.jsx("div",{className:ie,style:se(X),children:Array.from({length:12}).map((s,o)=>e.jsx(Oe,{},o))})]}):U?e.jsxs("div",{className:"pb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(gr,{size:20,className:"text-orange-500"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-fg",children:"Admin Dashboard"}),e.jsxs("p",{className:"text-xs text-rh-text-dark",children:[ve.length+ae.length," requests · ",ne.length," drafts · ",nt," recipes",lt>0?` (+${lt} channel imports)`:""]})]})]})}),e.jsxs("div",{className:"flex gap-2 mb-6",children:[e.jsxs("button",{onClick:()=>yt("requests"),className:f("flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all border",V==="requests"?"bg-
57orange-500 text-white border-orange-500":"bg-ink/5 border-ink/10 text-rh-text-light hover:bg-ink/10"),children:[e.jsx(Ve,{size:16}),"Requests",ve.length+ae.length>0&&e.jsx("span",{className:f("px-1.5 py-0.5 rounded text-[10px] font-bold",V==="requests"?"bg-ink/20":"bg-orange-500/20 text-orange-400"),children:ve.length+ae.length})]}),e.jsxs("button",{onClick:()=>yt("drafts"),className:f("flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all border",V==="drafts"?"bg-orange-500 text-white border-orange-500":"bg-ink/5 border-ink/10 text-rh-text-light hover:bg-ink/10"),children:[e.jsx(vr,{size:16}),"Drafts",ne.length>0&&e.jsx("span",{className:f("px-1.5 py-0.5 rounded text-[10px] font-bold",V==="drafts"?"bg-ink/20":"bg-orange-500/20 text-orange-400"),children:ne.length})]}),e.jsxs("button",{onClick:()=>yt("recipes"),className:f("flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all border",V==="recipes"?"bg-orange-500 text-white border-orange-500":"bg-ink/5 border-ink/10 text-rh-text-light hover:bg-ink/10"),children:[e.jsx(ce,{size:16}),"Recipes",nt>0&&e.jsx("span",{className:f("px-1.5 py-0.5 rounded text-[10px] font-bold",V==="recipes"?"bg-ink/20":"bg-orange-500/20 text-orange-400"),children:nt})]}),e.jsxs("button",{onClick:()=>yt("intelligence"),className:f("flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all border",V==="intelligence"?"bg-orange-500 text-white border-orange-500":"bg-ink/5 border-ink/10 text-rh-text-light hover:bg-ink/10"),children:[e.jsx($r,{size:16}),"Intelligence"]})]}),V==="requests"&&e.jsxs(e.Fragment,{children:[ae.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ge,{size:16,className:"text-sky-400"}),e.jsx("h3",{className:"text-sm font-bold text-fg",children:"Tool & Recipe Requests"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold bg-sky-500/15 text-sky-400",children:ae.length})]}),e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))"},children:ae.map(s=>e.jsx(ci,{request:s,onDelete:async o=>{try{await On(o.id)}catch(p){console.error("[Admin] Failed to delete feature request:",p),n("Could not delete this request right now. Please try again.","error",4500)}}},s.id))})]}),Aa?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(E,{size:24,className:"text-orange-500 animate-spin mb-3"}),e.jsx("p",{className:"text-sm text-rh-text-dark",children:"Loading requests..."})]}):ve.length===0&&ae.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-rh-surface-2 flex items-center justify-center mb-4",children:e.jsx(Ve,{size:24,className:"text-rh-text-dark"})}),e.jsx("h3",{className:"text-fg font-medium mb-1",children:"No pending requests"}),e.jsx("p",{className:"text-sm text-rh-text-dark max-w-sm",children:"When users request templates, tools, or recipes that don't exist, they'll appear here for review."})]}):ve.length===0?null:e.jsxs("div",{children:[ae.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ve,{size:16,className:"text-orange-400"}),e.jsx("h3",{className:"text-sm font-bold text-fg",children:"Template Requests"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold bg-orange-500/15 text-orange-400",children:ve.length})]}),e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))"},children:ve.map(s=>e.jsx(ii,{request:s,onRetry:async o=>{try{await Wn(o.id)}catch(p){console.error("[Admin] Failed to retry request:",p),n("Could not retry this request right now. Please try again.","error",4500)}},onRequeueFailed:async o=>{try{const p=await Vn(o);p.errors.length>0?n(`Requeued ${p.requeued} failed item${p.requeued===1?"":"s"}. ${p.errors.length} still need${p.errors.length===1?"s":""} attention.`,"info",5e3):n(`Requeued ${p.requeued} failed item${p.requeued===1?"":"s"} and retried ${p.retried} right away.`,"success",4e3)}catch(p){console.error("[Admin] Failed to requeue failed videos:",p),n("Could not requeue failed items right now. Please try again.","error",4500)}},onDelete:async o=>{try{await Gn(o.id)}catch(p){console.error("[Admin] Failed to delete request:",p),n("Could not delete this request right now. Please try again.","error",4500)}}},s.id))})]})]}),V==="drafts"&&e.jsxs(e.Fragment,{children:[ne.length>0&&e.jsx("div",{className:"mb-4",children:Bs?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-orange-500/10 border border-orange-500/30 rounded-lg",children:[e.jsxs("button",{onClick:va,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium bg-ink/10 hover:bg-ink/20 text-fg transition-colors",children:[e.jsx(Ut,{size:16}),"Exit"]}),e.jsx("button",{onClick:ja,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium bg-ink/10 hover:bg-ink/20 text-fg transition-colors",children:ee.size===ne.length?e.jsxs(e.Fragment,{children:[e.jsx(br,{size:16}),"Deselect All"]}):e.jsxs(e.Fragment,{children:[e.jsx(xt,{size:16}),"Select All (",ne.length,")"]})}),e.jsx("div",{className:"flex-grow"}),e.jsxs("span",{className:"text-sm text-orange-300",children:[ee.size," selected"]}),e.jsxs("button",{onClick:ya,disabled:ee.size===0||kt,className:f("flex items-center gap-2 px-4 py-1.5 rounded-lg text-sm font-medium transition-colors",ee.size>0?"bg-red-500 hover:bg-red-600 text-white":"bg-ink/5 text-rh-text-dark cursor-not-allowed"),children:[kt?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(Yt,{size:16}),"Delete Selected"]})]}):e.jsxs("button",{onClick:()=>Nt(!0),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium bg-ink/5 border border-ink/10 hover:bg-ink/10 text-rh-text-light transition-colors",children:[e.jsx(xt,{size:16}),"Select"]})}),Ma?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(E,{size:24,className:"text-orange-500 animate-spin mb
57-3"}),e.jsx("p",{className:"text-sm text-rh-text-dark",children:"Loading drafts..."})]}):ne.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-rh-surface-2 flex items-center justify-center mb-4",children:e.jsx(vr,{size:24,className:"text-rh-text-dark"})}),e.jsx("h3",{className:"text-fg font-medium mb-1",children:"No draft templates"}),e.jsx("p",{className:"text-sm text-rh-text-dark max-w-sm",children:"When the pipeline processes requests, draft templates will appear here for approval."})]}):e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))"},children:ne.map(s=>e.jsx(di,{template:s,isSelectionMode:Bs,isSelected:ee.has(s.id),onToggleSelect:()=>ba(s.id),onApprove:async(o,p)=>{try{await Hn(o,p)}catch(S){console.error("[Admin] Failed to approve template:",S),n("Could not approve this template right now. Please try again.","error",4500)}},onReject:async(o,p)=>{try{await dr(o,p)}catch(S){console.error("[Admin] Failed to reject template:",S),n("Could not reject this template right now. Please try again.","error",4500)}}},s.id))})]}),V==="recipes"&&e.jsxs(e.Fragment,{children:[te.length>0&&e.jsxs("div",{className:"mb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"admin-creation-source-filter",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-rh-text-dark mr-1",children:"Source"}),[{id:"manual",label:"Shared by users"},{id:"channel",label:"Channel imports"},{id:"all",label:"All"}].map(s=>e.jsxs("button",{onClick:()=>rs(s.id),className:f("px-3 py-1.5 rounded-lg text-xs font-medium transition-colors border",je===s.id?"bg-fg text-rh-dark border-fg":"bg-ink/5 border-ink/10 text-rh-text-light hover:bg-ink/10"),children:[s.label," (",Da[s.id],")"]},s.id)),Tt.length>0&&!ss&&e.jsxs("button",{onClick:$a,"data-testid":"admin-select-pending-channel",className:"ml-auto flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-red-500/10 border border-red-500/20 text-red-300 hover:bg-red-500/20 transition-colors",title:"Select every pending channel-sourced submission so it can be rejected in bulk",children:[e.jsx(xt,{size:14}),"Select ",Tt.length," pending channel recipe",Tt.length===1?"":"s"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-rh-text-dark mr-1",children:"Status"}),["all","pending","approved"].map(s=>e.jsxs("button",{onClick:()=>Gs(s),className:f("px-3 py-1.5 rounded-lg text-xs font-medium capitalize transition-colors border",Le===s?"bg-orange-500 text-white border-orange-500":"bg-ink/5 border-ink/10 text-rh-text-light hover:bg-ink/10"),children:[s," (",qa[s],")"]},s))]}),ss?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-orange-500/10 border border-orange-500/30 rounded-lg flex-wrap",children:[e.jsxs("button",{onClick:wa,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium bg-ink/10 hover:bg-ink/20 text-fg transition-colors",children:[e.jsx(Ut,{size:16}),"Exit"]}),e.jsx("button",{onClick:Fa,disabled:Ne.length===0,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium bg-ink/10 hover:bg-ink/20 text-fg transition-colors disabled:opacity-40",children:Y.size===Ne.length&&Ne.length>0?e.jsxs(e.Fragment,{children:[e.jsx(br,{size:16}),"Deselect All"]}):e.jsxs(e.Fragment,{children:[e.jsx(xt,{size:16}),"Select All Pending (",Ne.length,")"]})}),e.jsx("div",{className:"flex-grow"}),e.jsxs("span",{className:"text-sm text-orange-300",children:[Y.size," selected"]}),e.jsxs("button",{onClick:()=>wt("reject"),disabled:Y.size===0||Me,className:f("flex items-center gap-2 px-4 py-1.5 rounded-lg text-sm font-medium transition-colors",Y.size>0?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-ink/5 text-rh-text-dark cursor-not-allowed"),children:[Me&&de==="reject"?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(Ut,{size:16}),"Reject Selected"]}),e.jsxs("button",{onClick:()=>wt("approve"),disabled:Y.size===0||Me,className:f("flex items-center gap-2 px-4 py-1.5 rounded-lg text-sm font-medium transition-colors",Y.size>0?"bg-green-500 hover:bg-green-600 text-white":"bg-ink/5 text-rh-text-dark cursor-not-allowed"),children:[Me&&de==="approve"?e.jsx(E,{size:16,className:"animate-spin"}):e.jsx(pe,{size:16}),"Approve Selected"]})]}):e.jsxs("button",{onClick:()=>at(!0),disabled:Ne.length===0,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium bg-ink/5 border border-ink/10 hover:bg-ink/10 text-rh-text-light transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(xt,{size:16}),"Select"]})]}),Ea?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(E,{size:24,className:"text-orange-500 animate-spin mb
57-3"}),e.jsx("p",{className:"text-sm text-rh-text-dark",children:"Loading recipe submissions..."})]}):te.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-rh-surface-2 flex items-center justify-center mb-4",children:e.jsx(ce,{size:24,className:"text-rh-text-dark"})}),e.jsx("h3",{className:"text-fg font-medium mb-1",children:"No recipe submissions"}),e.jsx("p",{className:"text-sm text-rh-text-dark max-w-sm",children:"When creators share their custom recipes with the community, they'll appear here for review."})]}):St.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("p",{className:"text-sm text-rh-text-dark",children:["No ",Le==="all"?"":`${Le} `,je==="manual"?"user-shared":je==="channel"?"channel-import":""," submissions."]}),je==="manual"&&lt>0&&e.jsxs("button",{onClick:()=>rs("channel"),className:"mt-2 text-xs text-fg/60 hover:text-fg underline-offset-2 hover:underline",children:[lt," pending channel import",lt===1?"":"s"," hidden"]})]}):e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))"},children:St.map(s=>e.jsx(mi,{creation:s,isSelectionMode:ss,isSelected:Y.has(s.id),onToggleSelect:()=>ka(s.id),onApprove:async o=>{try{await pr(o),n("Recipe approved and live in the community library.","success",4e3)}catch(p){console.error("[Admin] Failed to approve recipe:",p),n("Could not approve this recipe right now. Please try again.","error",4500)}},onReject:async(o,p)=>{try{await hr(o,p),n("Recipe rejected and removed from the queue.","info",3e3)}catch(S){console.error("[Admin] Failed to reject recipe:",S),n("Could not reject this recipe right now. Please try again.","error",4500)}}},s.id))})]}),V==="intelligence"&&e.jsx(pi,{}),e.jsxs("div",{className:"mt-8 pt-6 border-t border-ink/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-sm font-medium text-rh-text-light flex items-center gap-2",children:[e.jsx(qr,{size:14}),"Recent History"]}),Ee.length>ze&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>_s(s=>Math.max(0,s-1)),disabled:rt===0,className:"p-1.5 rounded-lg hover:bg-ink/10 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:e.jsx(kn,{size:16,className:"text-rh-text-dark"})}),e.jsxs("span",{className:"text-xs text-rh-text-dark min-w-[60px] text-center",children:[rt+1," / ",Math.ceil(Ee.length/ze)]}),e.jsx("button",{onClick:()=>_s(s=>Math.min(Math.ceil(Ee.length/ze)-1,s+1)),disabled:rt>=Math.ceil(Ee.length/ze)-1,className:"p-1.5 rounded-lg hover:bg-ink/10 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:e.jsx(ys,{size:16,className:"text-rh-text-dark"})})]})]}),Ia?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-rh-text-dark",children:[e.jsx(E,{size:12,className:"animate-spin"}),"Loading..."]}):Ee.length===0?e.jsx("p",{className:"text-xs text-rh-text-dark",children:"No completed requests yet."}):e.jsx("div",{className:"space-y-2",children:Ee.slice(rt*ze,(rt+1)*ze).map(s=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-ink/5 border border-ink/5",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-green-500/10 flex items-center justify-center flex-shrink-0",children:e.jsx(pe,{size:12,className:"text-green-500"})}),e.jsxs("span",{className:"text-sm text-fg truncate",children:['"',s.query,'"']})]}),e.jsx("span",{className:"text-xs text-rh-text-dark flex-shrink-0 ml-3",children:s.createdAt.toLocaleDateString()})]},s.id))})]})]}):w?e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-6",children:[e.jsx("button",{onClick:Qa,className:"p-2 -ml-2 rounded-lg hover:bg-rh-surface-3 transition-colors",children:e.jsx(pl,{size:20,className:"text-rh-text-dark"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[js[w].icon,e.jsx("h2",{className:"text-xl font-bold text-fg",children:js[w].title})]})]}),e.jsx("div",{className:ie,style:se(X),children:(w==="trending"?H:w==="popular"?$e:Fe).map((s,o)=>e.jsx(Dt,{template:s,onClick:()=>ke(s,o),href:t?`/studio/${t}/templates/${s.id}`:void 0,showTitle:!0,fillContainer:!0,showStats:_,showFavorite:_},s.id))}),w==="trending"&&jt||w==="popular"&&Jt||w==="new"&&es?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(E,{size:24,className:"text-rh-green animate-spin"})}):null]}):q&&Ua?e.jsxs("div",{className:"animate-pulse",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(fs,{size:20,className:"text-red-400"}),e.jsx("div",{className:"h-5 w-32 bg-ink/10 rounded"})]}),e.jsx("div",{className:ie,style:se(X),children:Array.from({length:Math.min(be.length||4,8)}).map((s,o)=>e.jsx(Oe,{},o))})]}):Pe.length===0&&_e.length===0&&le.length===0&&us.length===0&&!ct&&!ds?e.jsxs("div",{className:"relative flex flex-col items-center justify-center py-16 md:py-20 min-h-[60vh] overflow-hidden px-4 w-full max-w-5xl mx-auto",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none opacity-[0.15] select-none overflow-hidden",children:e.jsx("div",{className:"grid w-full h-full gap-4 p-4 grayscale mask-image-fade",style:{...se(vi),maskImage:"radial-gradient(circle at center, transparent 30%, black 100%)",WebkitMaskImage:"radial-gradient(circle at center, transparent 30%, black 100%)"},children:(W.length>0?W:Yn).slice(0,20).map(s=>e.jsxs("div",{className:"aspect-video rounded-xl bg-rh-surface border border-ink/10 overflow-hidden relative",children:[e.jsx("img",{src:s.image,alt:"",className:"w-full h-full object-cover opacity-50",onError:o=>{const p=o.currentTarget,S=_t(s.id,s.subjectType,{hasGenderVariants:s.hasGenderVariants,detectedGender:s.detectedGender}),$=parseInt(p.dataset.fallbackIndex||"0",10);$<S.length&&(p.dataset.fallbackIndex=String($+1),p.src=S[$])}}),e.jsx("div",{className:"absolute inset-0 bg-rh-surface/50"})]},s.id))})}),e.jsx("div",{className:"relative z-10 flex flex-col items-center justify-center text-center max-w-2xl mx-auto px-6",children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:f("relative mb-8 group",R?"
57scale-110":""),children:[e.jsx("div",{className:"absolute -inset-4 bg-gradient-to-tr from-rh-green/20 to-blue-500/20 rounded-full blur-xl opacity-0 group-hover:opacity-100 transition-opacity duration-700"}),e.jsx("div",{className:"relative w-24 h-24 rounded-3xl bg-gradient-to-br from-rh-surface-2 to-rh-surface-3 border border-ink/10 flex items-center justify-center shadow-2xl transform group-hover:-translate-y-2 transition-transform duration-500",children:e.jsx(wn,{className:f("text-rh-green transition-all duration-500",R?"w-14 h-14":"w-12 h-12"),outfit:L.leetOutfit,showTrail:!1})})]}),e.jsx("h3",{className:"text-3xl sm:text-4xl font-bold text-fg mb-4 tracking-tight",children:R?"No templates found":q?"No favorite templates":`No ${((nr=ft.find(s=>s.slug===y))==null?void 0:nr.name)||y} templates`}),e.jsx("p",{className:"text-rh-text-light/80 text-lg mb-10 max-w-lg leading-relaxed",children:q?"Browse templates and click the heart icon to add them to your favorites.":R?"Request a template! Tell us what your audience searches for and we'll create templates you can put yourself in.":"Request a template for your content. Describe what your viewers would search for on YouTube."}),!q&&e.jsx("div",{className:"w-full",children:e.jsx(ei,{initialQuery:R,placeholder:R?"e.g. gaming videos, cooking shows, vlogs...":`e.g. ${bi[y]||"gaming videos, cooking shows, vlogs..."}`,showHowItWorks:!0,autoFocus:!1})}),q&&e.jsxs("button",{onClick:()=>st(!1),className:"inline-flex items-center gap-2 px-6 py-3 bg-rh-green text-white font-medium rounded-xl hover:bg-rh-green/90 transition-colors",children:[e.jsx(ps,{size:18}),"Browse Templates"]})]})})]}):zt?e.jsxs("div",{children:[e.jsx("div",{className:"hidden xl:block",children:jt?e.jsx(Sr,{}):H.length>0?e.jsx(ti,{template:H[0],onUseTemplate:()=>{Se(H[0]),ke(H[0],0)}}):null}),ar.length>=3&&e.jsxs("section",{className:"mb-10",children:[e.jsx(he,{icon:e.jsx(ge,{size:20,className:"text-orange-500"}),title:"Top 10 This Week"}),e.jsx(ur,{items:ar})]}),e.jsxs("section",{children:[e.jsx(he,{icon:e.jsx(Ge,{size:20,className:"text-rh-text-dark"}),title:"Quick Tools",onSeeAll:()=>xs("tools")}),e.jsx(or,{onSelectTool:It})]}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsxs("button",{onClick:()=>Zt("new"),className:f("flex items-center gap-2 px-4 py-2 rounded-lg font-medium text-sm transition-all",G==="new"?"bg-fg text-rh-dark":"bg-ink/5 text-fg/70 hover:bg-ink/10 hover:text-fg"),children:[e.jsx(xe,{size:16}),"New"]}),e.jsxs("button",{onClick:()=>Zt("trending"),className:f("flex items-center gap-2 px-4 py-2 rounded-lg font-medium text-sm transition-all",G==="trending"?"bg-fg text-rh-dark":"bg-ink/5 text-fg/70 hover:bg-ink/10 hover:text-fg"),children:[e.jsx(ge,{size:16}),"Trending"]}),e.jsxs("button",{onClick:()=>Zt("popular"),className:f("flex items-center gap-2 px-4 py-2 rounded-lg font-medium text-sm transition-all",G==="popular"?"bg-fg text-rh-dark":"bg-ink/5 text-fg/70 hover:bg-ink/10 hover:text-fg"),children:[e.jsx(Gt,{size:16}),"Popular"]}),e.jsxs("button",{onClick:()=>Xs(G),className:"ml-auto flex items-center gap-1 text-sm font-medium text-rh-text-dark hover:text-fg transition-colors",children:["See all",e.jsx(ys,{size:16})]})]}),e.jsxs("div",{ref:ma,className:f(ie,"animate-fade-in"),style:se(X),children:[e.jsxs("button",{onClick:()=>{t&&c(`/studio/${t}/new`,{state:{activePath:"composition"}})},className:"group block w-full max-w-full self-start text-left",children:[e.jsxs("div",{className:"relative aspect-video w-full rounded-xl overflow-hidden bg-gradient-to-br from-[#0f2019] via-[#0c1411] to-[#090c0a] border border-emerald-500/25 group-hover:border-emerald-400/60 transition-all duration-200",children:[e.jsx("div",{className:"absolute -top-12 -right-12 w-44 h-44 rounded-full bg-emerald-500/15 blur-3xl group-hover:bg-emerald-400/25 transition-colors"}),e.jsx("div",{className:"absolute -bottom-14 -left-14 w-44 h-44 rounded-full bg-emerald-500/10 blur-3xl"}),e.jsx("div",{className:"absolute left-[5%] top-[12%] bottom-[12%] w-[30%] rounded-lg border-2 border-dashed border-emerald-300/20"}),e.jsx("div",{className:"absolute right-[5%] top-[12%] h-[32%] w-[52%] rounded-lg border-2 border-dashed border-emerald-300/20"}
57),e.jsx("div",{className:"absolute right-[5%] bottom-[12%] h-[32%] w-[52%] rounded-lg border-2 border-dashed border-emerald-300/20"}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2.5",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-emerald-400 to-emerald-600 shadow-lg shadow-emerald-500/30 flex items-center justify-center group-hover:scale-105 transition-transform",children:e.jsx(Cn,{size:28,className:"text-white"})}),e.jsx("span",{className:"text-emerald-200/90 font-bold text-xs uppercase tracking-[0.2em]",children:"Composite"})]})]}),e.jsxs("div",{className:"px-0.5 mt-2 sm:mt-3 sm:px-1",children:[e.jsx("h3",{className:"font-medium text-fg leading-snug truncate text-sm md:text-base",children:"Create Your Own Template"}),e.jsx("div",{className:"mt-1 text-rh-text-dark text-[10px] sm:text-xs",children:"Upload a reference and make it reusable"})]})]}),G==="new"&&es||G==="trending"&&jt||G==="popular"&&Jt?Array.from({length:Math.max(Re-1,1)}).map((s,o)=>e.jsx(Oe,{},o)):(G==="new"?Fe:G==="trending"?H.length>0?H.slice(1):H:$e).slice(0,Math.max(Re-1,1)).map((s,o)=>e.jsx(Dt,{template:s,onClick:()=>ke(s,G==="trending"?o+1:o),href:t?`/studio/${t}/templates/${s.id}`:void 0,showTitle:!0,fillContainer:!0,showStats:_,showFavorite:_},s.id))]},G),e.jsxs("p",{className:"text-rh-text-dark/50 text-xs mt-3 animate-fade-in",children:[G==="new"&&"Fresh templates added daily across all categories.",G==="trending"&&"Top performing templates this week based on usage.",G==="popular"&&"Most used templates of all time."]},`desc-${G}`)]}),Va&&e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(E,{size:24,className:"text-rh-green animate-spin"})}),e.jsxs("section",{children:[e.jsx(he,{icon:e.jsx(ce,{size:20,className:"text-rh-accent"}),title:"Cookbook",onSeeAll:()=>xs("recipes"),actions:e.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded bg-rh-accent/20 text-rh-accent uppercase tracking-wide",children:"One-shot recipes"})}),e.jsx($n,{onSelectRecipe:Be,hideHeader:!0})]}),e.jsxs("section",{className:"mt-12",children:[e.jsx(he,{icon:e.jsx(ps,{size:20,className:"text-rh-text-dark"}),title:"Browse All Templates"}),e.jsx("div",{className:ie,style:se(X),children:W.map((s,o)=>e.jsx(Dt,{template:s,onClick:()=>ke(s,o),href:t?`/studio/${t}/templates/${s.id}`:void 0,showTitle:!0,fillContainer:!0,showStats:_,showFavorite:_},s.id))}),et&&e.jsx("div",{ref:Vs,className:"flex justify-center py-8",children:e.jsx(E,{size:24,className:"text-rh-green animate-spin"})}),!et&&W.length>0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsxs("p",{className:"text-rh-text-dark/50 text-sm flex items-center justify-center gap-2 mb-6",children:["You've seen all ",W.length," templates",e.jsx(gl,{size:16,className:"text-rh-text-dark/50"})]}),e.jsx("p",{className:"text-rh-text-dark/70 text-sm mb-3",children:"Can't find what you need?"}),e.jsxs("button",{onClick:()=>Ze(!0),className:"inline-flex items-center gap-2 px-4 py-2 bg-ink/5 hover:bg-ink/10 rounded-lg text-fg text-sm font-medium transition-colors",children:[e.jsx(gs,{size:16}),"Request a Template"]})]})]})]}):e.jsxs("div",{children:[y==="tools"&&we&&e.jsx("div",{className:"hidden xl:block",children:e.jsx(si,{badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-sky-500/20 text-sky-400 border border-sky-500/30 text-xs font-bold uppercase tracking-wider",children:[e.jsx(Ge,{size:12}),"Featured Tool"]}),title:we.name,description:we.description,primaryLabel:`Try ${we.name}`,primaryIcon:e.jsx(Qt,{size:18,className:"fill-black"}),onPrimary:()=>It(we.name),image:((lr=mr[we.name])==null?void 0:lr.after)??"",beforeImage:(ir=mr[we.name])==null?void 0:ir.before})}),y==="recipes"&&!q&&!(R||M)&&Js.length>0&&e.jsx(ai,{recipes:Js,onSelect:Be,onBrowseAll:()=>{var s;return(s=er.current)==null?void 0:s.scrollIntoView({behavior:"smooth",block:"start"})}}),y==="templates"&&!q&&!(R||M)&&Mt.length>=3&&e.jsxs("section",{className:"mb-10",children:[e.jsx(he,{icon:e.jsx(ge,{size:20,className:"text-orange-500"}),title:"Top 10 Templates This Week",onSeeAll:()=>Xs("trending")}),e.jsx(ur,{items:Mt})]}),q?e.jsx(he,{icon:e.jsx(fs,{size:20,className:"text-red-400 fill-red-400"}),title:"Your Favorites"}):R||M?e.jsx(he,{icon:e.jsx(Ve,{size:20,className:"text-rh-text-dark"}),title:`Search Results for "${R||M}"`}):y!=="all"&&y!=="recipes"&&e.jsx(he,{icon:e.jsx(vs,{size:20,className:"text-rh-text-dark"}),title:y.charAt(0).toUpperCase()+y.slice(1),actions:e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg bg-rh-surface border border-ink/10 text-xs font-medium text-rh-text-light hover:bg-ink/5 transition-colors",children:[e.jsx(Al,{size:14}),tt.sortBy==="popular"?"Popular":tt.sortBy==="trending"?"Trending":tt.sortBy==="new"?"Newest":"Sort"]}),e.jsx("div",{className:"absolute right-0 top-full pt-2 w-32 z-20 hidden group-hover:block",children:e.jsx("div",{className:"bg-rh-surface-2 border border-ink/10 rounded-lg shadow-xl overflow-hidden",children:["popular","trending","new"].map(s=>e.jsx("button",{onClick:()=>
57da({sortBy:s}),className:f("w-full text-left px-3 py-2 text-xs hover:bg-ink/5 transition-colors",tt.sortBy===s?"text-rh-green bg-rh-green/10":"text-rh-text-light"),children:s==="popular"?"Popular":s==="trending"?"Trending":"Newest"},s))})})]})}),(R||M)&&!q&&!U&&t&&us.length>0&&e.jsx(li,{channels:us,studioId:t,userId:j,showToast:n,className:"mb-8"}),(R||M)&&!q&&!U&&t&&e.jsx(Ir,{studioId:t,userId:j,allowCreate:!1,filterQuery:R||M,showToast:n,className:"mb-8"}),ct&&Pe.length===0&&le.length===0?e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:ie,style:se(X),children:Array.from({length:12}).map((s,o)=>e.jsx(Oe,{},o))})}):y==="recipes"&&!q&&!(R||M)?e.jsxs("div",{className:"space-y-8",children:[t&&e.jsx(Ir,{studioId:t,userId:j,showToast:n}),e.jsxs("section",{ref:er,className:"scroll-mt-24",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto leet-scroll-hide min-w-0 flex-1",children:[e.jsx("button",{onClick:()=>Xt("all"),className:f("flex-shrink-0 flex items-center gap-1.5 px-3.5 py-1.5 rounded-full text-xs font-medium transition-all",J==="all"?"bg-fg text-rh-dark":"bg-ink/5 text-fg/70 hover:bg-ink/10 hover:text-fg"),children:"All"}),e.jsxs("button",{onClick:()=>Xt("channels"),className:f("flex-shrink-0 flex items-center gap-1.5 px-3.5 py-1.5 rounded-full text-xs font-medium transition-all",J==="channels"?"bg-fg text-rh-dark":"bg-ink/5 text-fg/70 hover:bg-ink/10 hover:text-fg"),children:[e.jsx(Pr,{size:14,linked:!1}),"Channels",e.jsx("span",{className:f("text-[10px]",J==="channels"?"text-rh-dark/50":"text-fg/35"),children:Tr().length})]}),hs.map(s=>e.jsxs("button",{onClick:()=>Xt(s.id),className:f("flex-shrink-0 flex items-center gap-1.5 px-3.5 py-1.5 rounded-full text-xs font-medium transition-all",J===s.id?"bg-fg text-rh-dark":"bg-ink/5 text-fg/70 hover:bg-ink/10 hover:text-fg"),children:[e.jsx("span",{className:"[&>svg]:w-3.5 [&>svg]:h-3.5",children:ki[s.id]??e.jsx(xe,{size:14,className:"text-rh-accent"})}),s.label,e.jsx("span",{className:f("text-[10px]",J===s.id?"text-rh-dark/50":"text-fg/35"),children:s.recipes.length})]},s.id))]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>Is("popular"),className:f("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all",Xe==="popular"?"bg-fg text-rh-dark":"bg-ink/5 text-fg/70 hover:bg-ink/10 hover:text-fg"),children:[e.jsx(Gt,{size:13}),"Popular"]}),e.jsxs("button",{onClick:()=>Is("new"),className:f("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all",Xe==="new"?"bg-fg text-rh-dark":"bg-ink/5 text-fg/70 hover:bg-ink/10 hover:text-fg"),children:[e.jsx(xe,{size:13}),"New"]})]})]}),e.jsx("div",{className:ie,style:se(X),children:rr.slice(0,As).map(s=>s.kind==="builtin"?e.jsx(cr,{recipe:s.recipe,onClick:()=>Be(s.recipe),className:"w-full"},Et(s.recipe)):e.jsx(ea,{channel:s.entry.channel,recipe:s.entry.recipe,isImported:dt.isImported(s.entry.channel,s.entry.recipe),isBusy:dt.busyKey===dt.channelRecipeKey(s.entry.channel,s.entry.recipe),onClick:()=>void dt.launchChannelRecipe(s.entry.channel,s.entry.recipe),className:"w-full"},dt.channelRecipeKey(s.entry.channel,s.entry.recipe)))}),As<rr.length&&e.jsx("div",{ref:_a,className:"flex justify-center py-8",children:e.jsx(E,{size:24,className:"text-rh-green animate-spin"})})]}),t&&e.jsx(Dn,{studioId:t,userId:j,showToast:n,recipes:le})]}):e.jsxs("div",{className:ie,style:se(X),children:[le.map(s=>e.jsx(cr,{recipe:s,onClick:()=>Be(s),className:"w-full"},Et(s))),Pe.map((s,o)=>e.jsx(Dt,{template:s,onClick:()=>ke(s,o),href:t?`/studio/${t}/templates/${s.id}`:void 0,showTitle:!0,fillContainer:!0,showStats:_,showFavorite:_},s.id)),_e.map(s=>e.jsx(nl,{tool:s,onClick:()=>It(s.name)},s.name)),M&&Pe.length>0&&e.jsxs("button",{onClick:()=>Ze(!0),className:"group aspect-video rounded-xl overflow-hidden bg-ink/5 border-2 border-dashed border-ink/20 hover:border-rh-green/50 hover:bg-rh-green/5 transition-all duration-200 flex flex-col items-center justify-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-ink/10 group-hover:bg-rh-green/20 flex items-center justify-center transition-colors",children:e.jsx(gs,{size:24,className:"text-fg/50 group-hover:text-rh-green transition-colors"})}),e.jsxs("div",{className:"text-center px-4",children:[e.jsx("p",{className:"text-fg/80 font-medium text-sm group-hover:text-fg transition-colors",children:"Request More"}),e.jsx("p",{className:"text-fg/40 text-xs mt-1",children:"Need a different style? (automatic)"})]})]})]}),et&&!q&&y!=="recipes"&&!R&&!M&&e.jsx("div",{ref:Vs,className:"flex justify-center py-8",children:e.jsx(E,{size:24,className:"text-rh-green animate-spin"})})]})]}),e.jsx(ll,{template:fe,isOpen:!!fe,onClose:Ha,onUseTemplate:Ka,isCreating:A,isMobile:!1,onDeleted:xa,hasCredits:d}),e.jsx(Jl,{isOpen:sa,onClose:()=>Ze(!1),backgroundImages:Ws}),e.jsx(Vl,{isOpen:ra,onClose:()=>zs(!1),isOptedIn:k.marketingCommunicationsOptIn,onToggle:Ba,backgroundImages:Ws}),e.jsx("button",{onClick:la,className:f("fixed bottom-6 right-6 z-50 p-3 rounded-full bg-ink/10 backdrop-blur-sm border border-ink/10 text-fg shadow-lg transition-all duration-300","hover:bg-ink/20 hover:scale-110",aa?"opacity-100 translate-y-0":"opacity-0 translate-y-4 pointer-events-none"),"aria-label":"Back to top",children:e.jsx(Sn,{size:20})}),e.jsx(Ot,{isOpen:fa,onConfirm:()=>{Na()},onCancel:()=>{kt||ts(!1)},title:`Delete ${ee.size} draft template${ee.size===1?"":"s"}?`,confirmLabel:"Delete drafts",cancelLabel:"Keep drafts",isLoading:kt,children:"This action cannot be undone."}),e.jsx(Ot,{isOpen:de!==null,onConfirm:()=>{Pa()},onCancel:()=>{Me||wt(null)},title:`${de==="approve"?"Approve":"Reject"} ${Y.size}
57 recipe${Y.size===1?"":"s"}?`,confirmLabel:de==="approve"?"Approve all":"Reject all",cancelLabel:"Cancel",isLoading:Me,children:de==="approve"?"Approved recipes go live in the community library immediately.":"Rejected submissions are hidden from the community; the creators keep their private recipes."}),e.jsx(Tn,{message:h,variant:g,onDismiss:m}),Za]})},fo=Object.freeze(Object.defineProperty({__proto__:null,TemplateLibraryPage:wi},Symbol.toStringTag,{value:"Module"}));export{li as C,zl as G,Ll as M,Dl as N,Wt as R,Wl as a,Ul as b,Jr as c,Ir as d,ea as e,ni as f,Tr as g,fo as i,Yr as u};

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.