1import{u as zt,a8 as Po,r as n,j as e,q as On,y as To,J as ee,a as hi,L as Mt,t as fi,s as Lo}from"./vendor-CSpQeQFa.js";import{s as be,aj as Vs,k as Ao,as as Mo,u as xr,C as hr,B as Ee,R as xi,U as Jr,W as en,X as tn,T as gi,N as Dn,o as Ro}from"./entry-main-PLc9_a6q.js";import{a as $o}from"./useContests-Db0m_Md2.js";import{h as Uo,e as Eo,d as Do,b as Bo}from"./useSubmissions-gPqCzRk0.js";import{b as bi,A as $s,u as vi,h as zo,f as Ko,g as qo}from"./useContestQuestions-DnE2mGLW.js";import{A as sn,b as rn,c as nn,d as an,e as zs,f as on,g as ln,h as dn}from"./alert-dialog-B3s9CDLG.js";import{T as xs,d as wi,b as yi,f as ji,a as Fo,C as Oo,u as Ia}from"./useCreditPurchaseRedirect-BG4b5Ixo.js";import{a5 as Vo,p as _i,a6 as Wo,bc as Go,bd as Ho,be as Yo,ad as Qo,ae as Zo,af as Xo}from"./HomePage-BpRny74E.js";import{P as bs,a as Ks,b as vs,c as Jo}from"./popover-BxDuN_sr.js";import{g as Ws}from"./creatorAnonymizer-BTo0VopR.js";import{u as cn}from"./useViewerHasSubmissions-BSoOudbE.js";import{e as un}from"./useContestApplications-NuSdWVnr.js";import{D as Vn,a as Wn,c as Gn,U as el,j as Pa,P as tl,b as sl,d as Ni,e as rl}from"./creationMetadata-DV63esj7.js";import{u as nl,C as al}from"./CreatorSubmissionDetailDrawer-C52T4sAW.js";import{C as In}from"./ToucanAvatar-C2aJLt9E.js";import{P as il,b as ol,c as ll}from"./usePartialApprovalGate-D3g_NTH5.js";import{F as Ta}from"./Footer-CGWiw4oR.js";import{I as Kt}from"./globalAnnouncements-nxd9yA1b.js";import{T as Hn}from"./useEducators-CyXRHIo7.js";import{L as Lt}from"./contestTypes-D51N3MT-.js";import{S as dl,a as cl,b as ul,c as ml,d as pl,g as hl,k as fl,e as xl,n as gl,j as bl}from"./contestPrizeTypes-lwm66WfQ.js";import{c as Us,r as La}from"./videoHelpers-amuxf0rZ.js";import{n as vl,F as ki}from"./creatorQuality-IctvKKPg.js";import{r as ws,a as Si,g as ys,b as wl}from"./refresh-S4T5V5GX-C28ZG0BP.js";import{c as yl,a as h,z as Ci,h as jl,i as _l,X as qs,j as Aa,s as Ds,S as Ii,N as Pi}from"./zerionWallet-YD6NMGW7-anviiTIZ.js";import{C as Ti}from"./complimentaryVideoIntent-BYKb2Exc.js";import{q as Fr}from"./promptBarStyles-D9caz4KD.js";import{g as Nl,u as Li,a as kl,r as Bn,S as Ai,b as Sl,P as Ma,c as Wr,d as Bt,e as gs,f as cr,h as Cl,i as Mi,j as ur,k as Zt,l as hs,m as fs,n as mr,o as Ri,p as Qt,q as Il,s as Ra,t as Pl,I as Tl,v as lr,w as Ll,x as Er,R as Al}from"./ReplaceSubmissionModal-2dgHmgP9.js";import{u as $i,s as Ml,p as Rl}from"./useContestProject-gZv46J48.js";import{C as Ui,f as Gr,a as $l,m as Hr,d as Ei,e as Ul,r as El,s as Dl}from"./CloudflareVideoUpload-CoFAFW62.js";import{V as Yn}from"./VideoPlayer-D_ds20g5.js";import{u as Bl,L as zn}from"./useMediaUpload-Dy2RQHik.js";import{g as Or}from"./metaMaskWallet-SITXT2FV-DKDUz3lW.js";import{R as zl,f as Kl,U as Qn,C as $a,c as Ua,a as ql,b as Fl,d as Ol}from"./uploadLimits-Bk-o1hAt.js";import{U as Di}from"./collabEvents-CdfKyDkH.js";import{F as Fs,T as Vl,Y as Wl,f as Ea,a4 as Gl,g as Hl}from"./creatorAdMetrics-D-hKyv8p.js";import{C as Jt}from"./PendingApproval-BMg-Cjnx.js";import{C as Gs}from"./brandClaimErrors-DKWl3Kz1.js";import{o as Yl,p as Ql}from"./CreatorApplication-VT12n6MM.js";import{B as Pn,S as fr,L as xt}from"./BonusExpiryCountdown-DZAQV4Wx.js";import{p as Bi,r as zi,d as Zl,e as Xl,c as Jl,b as Da,a as ed,g as Ki,S as Ba,h as td,i as sd,j as rd,A as nd,k as ad,D as za}from"./MarketingHeader-DURgYL2j.js";import{b as Kn,c as id,L as od}from"./submissionLatePenalty-BPl_opqH.js";import{S as Yr}from"./signatureCeremonyModalGuard-vHUWzdXW.js";import{C as ld}from"./blog-editorial-defaults-GYihUdxa.js";import{I as gr}from"./SentryExamplePage-CGO0uJ8O.js";import{C as qn,t as Ka,v as qa}from"./brandOutreachLogo-DX112xbb.js";import{B as js}from"./useReportTemplate-CZAtBovG.js";import{P as ss}from"./package-s6MTOm3Q.js";import{T as dd}from"./perfOps-Bj62-pGn.js";import{C as es}from"./AccountCreated-Bo6ZhvJn.js";import{M as cd}from"./ScoutJoinRedirect-quAeHLrn.js";import{P as ud}from"./GcSectionHeading-77mgzsCj.js";import{D as md}from"./prizeUtils-9swa3d5r.js";import{W as pd}from"./useMetaSyncOps-DEw1bA94.js";import{P as qi,a as hd}from"./PrizeWonGlowBadge-3pjAMLjt.js";import{J as fd}from"./zip-BomCoFzN.js";import{A as At,u as xd}from"./perfAdLaunches-B45H8lGX.js";import{g as gd,a as bd}from"./WinnerVideoLightbox-DXGzWUaN.js";import{s as vd,C as wd,b as yd}from"./submissionAdPerformance-C3Aqqvgw.js";
1import{F as jd,g as _d,C as Nd,B as kd}from"./BriefSurface-CrI-XMC-.js";import{LiquidMetal as mn}from"./liquid-metal-BcjiSF4R.js";import{S as br}from"./videoPosterCapture-FF-4z82m.js";import{u as Sd}from"./useHlsPlayer-D1OF9gnk.js";import{a as Cd,P as Os}from"./canvasNodeAspect-CSXmIim1.js";import{T as wt,f as Dr,B as Id}from"./bookingIdentityPing-D51nG8yv.js";import{L as Pd}from"./list-checks-BEoV4Zbb.js";import{C as Fa}from"./modelFamilies-Dcg73pIM.js";import{p as qt,S as Td}from"./plural-BbOexbm1.js";import{C as Fi}from"./useCampaignBriefs-DIusq7Nu.js";import{P as Oi}from"./GcField-CGlx4mC4.js";import{D as Ld,c as Ad,d as Md,e as Oa}from"./useConversations-D2UlDKEh.js";import{U as Br}from"./useProductHuntRedemption-zAUPPnZC.js";import{a as Qr,E as vr,i as Vi,s as Rd}from"./perfConfigSelect-DHd8mvGs.js";import{A as zr}from"./arrow-up-pBcUOBFB.js";import{A as $d}from"./arrow-up-narrow-wide-DsFuLcGh.js";import{T as Zn}from"./thumbs-up-CC7PKscT.js";import{m as Xt}from"./use-motion-value-DTB6dbb9.js";import{C as Ud}from"./usePendingWinnerClaims-44a49UrJ.js";import{R as Wi}from"./ribbon-b7xPh443.js";import{M as Ed}from"./medal-D5rfcC3m.js";import{C as Dd}from"./judgingPredictionSettings-BfoDoEEc.js";import{B as Bd}from"./badge-percent-DJV3xwZk.js";import{I as Gi}from"./types-BtjBQUsZ.js";import{c as Hi,a as Xn,b as Yi}from"./contestMediaDisplay-WupF8w-m.js";import{u as Qi}from"./useCachedMetaAds-CjGIB17C.js";import{M as zd,a as Kd,C as qd}from"./StudioInspirationPanel-C8RRTiJI.js";import{e as Fd,a as Od,m as Tn}from"./metaAdMediaPins-BJoD77EB.js";import{a as Zi,G as Vd}from"./useCreatorPartnerProgram-DMoI_okX.js";import{S as Wd}from"./dataFreshness-Bix4sAZZ.js";import{u as Gd,R as Hd}from"./useFirstContestStudioClaim-BZoQYnY9.js";import{f as Yd}from"./CreditBalanceBreakdown-CVPOQZnI.js";import{C as Qd}from"./useH2HMatchups-DVn4rK6b.js";import{C as Zd}from"./collapsible-DPqEgDV7.js";import{M as Xd}from"./lenis-YuULh0It.js";import{T as Jd}from"./useBrandKit-BgNPh7Xl.js";import{a as ec}from"./EmbeddedBriefDocumentViewer-D0DY8Myv.js";import{E as tc}from"./adCenterPlatform-Cp7ggMTG.js";import{S as Va}from"./shield-alert-B3fbTekS.js";import{M as sc}from"./mouse-pointer-click-DQ3QtGD-.js";import{M as rc,r as nc}from"./index-Dl5z8yIx.js";import{F as ac}from"./utils-D3pSZr0D.js";import{K as Wa}from"./AnimatedLogoLoader-ya0CYMD-.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ic=yl("PartyPopper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]);async function oc(t,s){const{data:r,error:a}=await t.from("profiles").select("creator_quality").eq("id",s).maybeSingle();return a?(console.error("[submissionAdminHidden] failed to load creator quality",a),!0):vl(r?.creator_quality)!=="verified"}function lc(t,s,r,a,i){const c=!t||!s||r==="public"||a===s||i==="admin"||i==="business",{data:d,isLoading:f,refetch:x}=zt({queryKey:["contest-access",t,s],queryFn:async()=>{const{data:p,error:m}=await be.from("contest_access_keys").select("id").eq("contest_id",t).eq("used_by",s).maybeSingle();return m?(console.warn("Contest access check failed:",m.code,m.message),!1):!!p},enabled:!c,retry:!1});return c?{hasAccess:!0,isLoading:!1,refetch:()=>{}}:{hasAccess:d??!1,isLoading:f,refetch:x}}const Fn="text-[10px] font-medium uppercase tracking-wide px-1.5 py-0.5 rounded bg-black/55 backdrop-blur-md",Ga={submitted:{label:"Submitted",className:"bg-muted text-muted-foreground",icon:null},shortlisted:{label:"Shortlisted",className:"bg-violet-500/20 text-violet-400 border-violet-500/30",icon:e.jsx(Pd,{className:"w-3 h-3"})},finalist:{label:"Finalist",className:"bg-amber-500/20 text-amber-400 border-amber-500/30",icon:e.jsx(At,{className:"w-3 h-3"})},approved:{label:"Accepted",className:"bg-green-500/20 text-green-400 border-green-500/30",icon:e.jsx(es,{className:"w-3 h-3"})},accepted:{label:"Accepted",className:"bg-green-500/20 text-green-400 border-green-500/30",icon:e.jsx(es,{className:"w-3 h-3"})},rejected:{label:"Rejected",className:"bg-destructive/20 text-destructive border-destructive/30",icon:e.jsx(Fa,{className:"w-3 h-3"})},winner:{label:"Winner",className:"bg-gradient-to-r from-yellow-500/30 to-amber-500/30 text-yellow-300 border-yellow-500/50",icon:e.jsx(wt,{className:"w-3 h-3"})}
6,reviewed:{label:"Reviewed",className:"bg-muted-foreground/20 text-muted-foreground border-border/30",icon:e.jsx(es,{className:"w-3 h-3"})},disqualified:{label:"Disqualified",className:"bg-destructive/20 text-destructive border-destructive/30",icon:e.jsx(Fa,{className:"w-3 h-3"})}},Xi=({submission:t,onClick:s,showTrackBadge:r=!1,onShortlist:a,isBrand:i=!1,isTop30:c=!1,challengeId:d,showWinnerBadges:f=!0,anonymizeCreator:x,campaignsStyle:p=!1,showCreatorElo:m=!1,hideTrackLabel:v=!1,aspectRatio:A,statusBadgeOverride:y=null,categoryTags:N=[],earningsWonUsd:P=null})=>{const{navigateToVideo:R}=Vo(),{isPreviewMode:B}=Vs(),S=x??(i||B);Po();const[K,b]=n.useState(!1),[F,E]=n.useState(!1),[Q,O]=n.useState(!1),[H,te]=n.useState(!1),z=n.useRef(null),ie=n.useRef(null),se=n.useRef(!1),Z=n.useRef(0),{preloadVideo:w}=Ao(),j=n.useMemo(()=>ws(t),[t]),T=j.type==="image",_=n.useMemo(()=>A&&/^\d+(\.\d+)?:\d+(\.\d+)?$/.test(A.trim())?Cd(A.trim()):T&&j.type==="image"&&j.width&&j.height?`${j.width} / ${j.height}`:null,[A,T,j]),U=Si(j),$=j.type==="cloudflare"||U.endsWith(".m3u8"),M=$,D=j.type==="cloudflare"?j.metadata?.thumbnailTime:void 0,[Y,W]=n.useState(!M),[u,ue]=n.useState(!1),{attachToVideo:ve,cleanup:q,isReady:me}=Sd({videoUrl:U,videoRef:z,autoAttach:$&&Q});n.useEffect(()=>{const G=ie.current;if(!G)return;const _e=new IntersectionObserver(Re=>{Re.forEach($e=>{O($e.isIntersecting),$e.isIntersecting&&!T&&w(U)})},{rootMargin:"200px",threshold:0});return _e.observe(G),()=>_e.disconnect()},[U,w,T]);const X=n.useCallback(()=>{const G=ie.current;if(!G)return!1;const _e=G.getBoundingClientRect(),Re=window.__lastMouseX??-1,$e=window.__lastMouseY??-1;return Re>=_e.left&&Re<=_e.right&&$e>=_e.top&&$e<=_e.bottom},[]);n.useEffect(()=>{const G=_e=>{window.__lastMouseX=_e.clientX,window.__lastMouseY=_e.clientY};return window.addEventListener("mousemove",G,{passive:!0}),()=>window.removeEventListener("mousemove",G)},[]);const fe=n.useCallback(()=>{if(T)return;const G=z.current;if(!G||!se.current||!G.src&&!G.currentSrc)return;const _e=++Z.current;window.setTimeout(()=>{if(Z.current!==_e||!se.current)return;G.currentTime=0,G.loop=!0,G.muted=!0;const Re=G.play();Re!==void 0&&Re.then(()=>{se.current&&E(!0)}).catch(()=>{})},30)},[T]),qe=n.useCallback(()=>{se.current||(se.current=!0,b(!0),(!$||H)&&fe())},[$,H,fe]),Ve=n.useCallback(()=>{if(se.current&&(se.current=!1,Z.current++,b(!1),!T)){const G=z.current;G&&(G.pause(),G.currentTime=0),E(!1)}},[T]),I=n.useCallback(()=>{te(!0),se.current&&fe()},[fe]);n.useEffect(()=>{let G;const _e=()=>{clearTimeout(G),G=window.setTimeout(()=>{const Re=X();Re&&!se.current?qe():!Re&&se.current&&Ve()},50)};return window.addEventListener("scroll",_e,{passive:!0}),()=>{window.removeEventListener("scroll",_e),clearTimeout(G)}},[qe,Ve,X]),n.useEffect(()=>{const G=z.current;!G||!Q||u||$||T||(ue(!0),G.src=U,G.load())},[Q,U,$,u,T]),n.useEffect(()=>{const G=z.current;!G||!Q||u||!$||T||G.canPlayType("application/vnd.apple.mpegurl")&&(ue(!0),G.src=U,G.load())},[Q,U,$,u,T]),n.useEffect(()=>{me&&$&&(te(!0),se.current&&fe())},[me,$,fe]),n.useEffect(()=>()=>q(),[q]);const De=()=>{qe()},Le=()=>{Ve()},Ae=t.creator_profile?.current_elo??1e3,ke=n.useMemo(()=>Mo(Ae),[Ae]),he=n.useMemo(()=>S?Ws(t.creator_id)||null:t.creator_profile?.display_name?.trim()||t.creator_profile?.username?.trim()||null,[S,t.creator_id,t.creator_profile?.display_name,t.creator_profile?.username]),je=t.status||"submitted",xe=!i&&je==="shortlisted"?"submitted":je,Be=Ga[xe]||Ga.submitted;return e.jsx("div",{ref:ie,"data-submission-id":t.id,role:"button",tabIndex:0,className:h("group relative w-full cursor-pointer overflow-hidden rounded-xl transition-[box-shadow,transform,border-color] duration-200","outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background",p?"border border-white/[0.06] bg-zinc-900 hover:border-white/[0.12] hover:shadow-lg hover:shadow-black/25":"bg-background hover:ring-2 hover:ring-primary/40 hover:ring-offset-2 hover:ring-offset-background"),onMouseEnter:De,onMouseLeave:Le,onTouchStart:()=>{T||w(U)},onKeyDown:G=>{G.key!=="Enter"&&G.key!==" "||G.target===G.currentTarget&&(G.preventDefault(),s?s():R(t.id,d?"contest":void 0))},onClick:()=>{s?s():R(t.id,d?"contest":void 0)},children:e.jsxs("div",{className:h("relative overflow-hidden",!_&&"aspect-[9/16]",p?"bg-zinc-900":"bg-background"),style:_?{aspectRatio:_}:void 0,children:[e.jsxs("div",{className:h("absolute inset-0 transition-transform duration-300",!p&&K&&"scale-105"),children:[!Y&&e.jsx("div",{className:h("absolute inset-0 flex items-center justify-center",p?"bg-zinc-900":"bg-background"),children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-border border-t-primary"})}),!T&&Q&&M&&e.jsx(br,{videoUrl:U,thumbnailUrl:ys(j)||void 0,alt:t.title,loading:"lazy",thumbnailTime:D||void 0,className:"absolute inset-0",imgClassName:h("absolute inset-0 w-full h-full object-cover transition-opacity duration-300",Y?"opacity-100":"opacity-0"),onLoad:()=>W(!0)}),T&&Q&&e.jsx("img",{src:ys(j),alt:t.title,loading:"lazy",className:"absolute inset-0 w-full h-full object-cover",draggable:!1}),!T&&Q&&e.jsx("video",{ref:z,preload:"metadata",muted:!0,className:h("absolute inset-0 w-full h-full object-cover transition-opacity duration-300",K?"opacity-100":"opacity-0"),loop:!0,playsInl
6ine:!0,onPlay:()=>E(!0),onPause:()=>E(!1),onCanPlay:I,onLoadedData:I}),!p&&e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent"})]}),!T&&K&&!F&&!H&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center pointer-events-none",children:e.jsx("div",{className:h("flex h-12 w-12 items-center justify-center rounded-full backdrop-blur-sm",p?"border border-white/10 bg-black/60":"bg-muted"),children:e.jsx(Os,{className:"ml-0.5 h-6 w-6 fill-white text-white"})})}),m&&e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsxs("span",{className:h("inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-[10px] font-semibold tabular-nums backdrop-blur-sm",ke.bgColor,ke.borderColor,ke.color),title:`${ke.name} tier · ${Ae} ELO`,children:[e.jsx(wt,{className:"h-3 w-3 shrink-0 opacity-80"}),Ae.toLocaleString()]})}),f&&t.winner_rank&&e.jsxs("div",{className:"absolute top-3 left-3 z-10 flex flex-col gap-1",children:[(()=>{const G=t.winner_category==="participant"?"Ranked":t.contest_challenge?.title||(t.winner_category==="brand_pick"?"Brand Pick":t.winner_category==="judge_pick"?"Judge Pick":t.winner_category==="community_pick"?"Community Pick":"Winner"),_e=$e=>{const L=$e.toLowerCase();return L.includes("brand")?"bg-gradient-to-r from-amber-500 to-yellow-500 text-black shadow-amber-500/30":L.includes("judge")?"bg-gradient-to-r from-blue-500 to-purple-500 text-white shadow-blue-500/30":L.includes("community")?"bg-gradient-to-r from-emerald-500 to-green-500 text-white shadow-emerald-500/30":L.includes("sound")?"bg-gradient-to-r from-purple-500 to-pink-500 text-white shadow-purple-500/30":L.includes("multi")?"bg-gradient-to-r from-cyan-500 to-blue-500 text-white shadow-electric-cyan/30":"bg-gradient-to-r from-amber-500 to-yellow-500 text-black shadow-amber-500/30"},Re=t.winner_rank===1?"1st":t.winner_rank===2?"2nd":t.winner_rank===3?"3rd":`${t.winner_rank}th`;return e.jsxs(Pn,{className:h("gap-1.5 px-2.5 py-1 font-semibold shadow-lg border-0",_e(G)),children:[t.winner_rank===1?e.jsx(wt,{className:"w-3.5 h-3.5"}):t.winner_rank===2?e.jsx(At,{className:"w-3.5 h-3.5"}):e.jsx(fr,{className:"w-3.5 h-3.5"}),G," â ",Re]})})(),t.secondary_winner_category&&t.secondary_winner_rank&&(()=>{const G=t.secondary_winner_category==="brand_pick"?"Brand Pick":t.secondary_winner_category==="judge_pick"?"Judge Pick":"Community Pick",_e=$e=>$e.includes("Brand")?"bg-gradient-to-r from-amber-500 to-yellow-500 text-black shadow-amber-500/30":$e.includes("Judge")?"bg-gradient-to-r from-blue-500 to-purple-500 text-white shadow-blue-500/30":"bg-gradient-to-r from-emerald-500 to-green-500 text-white shadow-emerald-500/30",Re=t.secondary_winner_rank===1?"1st":t.secondary_winner_rank===2?"2nd":t.secondary_winner_rank===3?"3rd":`${t.secondary_winner_rank}th`;return e.jsxs(Pn,{className:h("gap-1.5 px-2.5 py-1 font-semibold shadow-lg border-0",_e(G)),children:[t.secondary_winner_rank===1?e.jsx(wt,{className:"w-3.5 h-3.5"}):t.secondary_winner_rank===2?e.jsx(At,{className:"w-3.5 h-3.5"}):e.jsx(fr,{className:"w-3.5 h-3.5"}),G," â ",Re]})})()]}),y?e.jsx("div",{className:"absolute bottom-3 left-3 z-10",children:e.jsx("span",{className:h(Fn,y.className??"text-sky-300/90"),children:y.label})}
6):(!f||!t.winner_rank&&!t.winner_category)&&!c&&!t.manual_include&&xe!=="submitted"&&xe!=="reviewed"&&xe!=="winner"&&Be.label!=="Submitted"&&e.jsx("div",{className:"absolute bottom-3 left-3 z-10",children:e.jsx("span",{className:h(Fn,xe==="shortlisted"&&"text-violet-400/80",(xe==="accepted"||xe==="approved")&&"text-emerald-400/80",xe==="rejected"&&"text-red-400/80",xe==="finalist"&&"text-amber-400/80",!["shortlisted","accepted","approved","rejected","finalist"].includes(xe)&&"text-muted-foreground/80"),children:Be.label})}),P!=null&&P>0||N.length>0?e.jsxs("div",{className:"absolute top-2 left-2 z-10 flex max-w-[85%] flex-wrap items-start gap-1",children:[P!=null&&P>0&&e.jsx(qi,{amountUsd:P,size:"responsive",label:"earned"}),N.map(G=>e.jsx("span",{className:"rounded-md border border-amber-400/40 bg-black/70 px-1.5 py-0.5 text-[10px] font-semibold text-amber-200 backdrop-blur-sm",children:G.label},G.key))]}):null,r&&t.contest_challenge?.title&&(!f||xe!=="winner")&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx("span",{className:"px-1.5 py-0.5 md:px-2 md:py-1 text-[10px] md:text-xs font-medium bg-primary/80 text-primary-foreground rounded-md backdrop-blur-sm max-w-[100px] md:max-w-[180px] truncate block",children:t.contest_challenge.title})}),t.bundle_videos&&t.bundle_videos.length>1&&e.jsx("div",{className:"absolute bottom-3 right-3 z-10",children:e.jsxs(Pn,{className:"gap-1 px-2 py-0.5 bg-indigo-500/90 text-white border-0 text-[10px] font-medium backdrop-blur-sm",children:[e.jsx(ss,{className:"w-3 h-3"}),t.bundle_videos.length," videos"]})}),p&&e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-[5] opacity-0 transition-opacity duration-200 ease-out group-hover:opacity-100 [@media(hover:none)]:opacity-100",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/10 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-3 pb-10",children:[t.contest_challenge?.title&&!v&&e.jsx("span",{className:"mb-0.5 block truncate text-[9px] font-medium uppercase tracking-[0.2em] text-white/45",children:t.contest_challenge.title}),e.jsx("h3",{className:"line-clamp-2 text-sm font-semibold leading-snug text-white",children:t.title}),e.jsx("p",{className:"mt-0.5 truncate text-[11px] leading-relaxed text-white/50",children:he?`@${he}`:e.jsx("span",{title:"This creator hasn't set a public name",children:"â"})})]})]}),!p&&e.jsxs("div",{className:h("pointer-events-none absolute bottom-0 left-0 right-0 p-3 transition-opacity duration-300",K?"opacity-100":"opacity-0"),children:[r&&t.contest_challenge?.title&&e.jsx("span",{className:"mb-1.5 inline-block rounded bg-primary/80 px-2 py-0.5 text-[10px] font-medium text-primary-foreground",children:t.contest_challenge.title}),e.jsx("h3",{className:"truncate text-sm font-medium text-white",children:t.title}),e.jsx("p",{className:"mt-0.5 text-xs text-emerald-400",children:he?`@${he}`:e.jsx("span",{title:"This creator hasn't set a public name",children:"â"})})]})]})})},dc=5;function cc(t){if(!t||typeof t!="object"||Array.isArray(t))return{count:0,participantIds:[]};const s=t,r=typeof s.participant_count=="number"?s.participant_count:Number(s.participant_count)||0,a=Array.isArray(s.participant_ids)?s.participant_ids.filter(i=>typeof i=="string"):[];return{count:r,participantIds:a}}function uc(t){const{user:s}=xr(),r=On(),a=["contest-participation",t,s?.id],i=["contest-participation-summary",t],c=zt({queryKey:i,enabled:!!t,staleTime:12e3,refetchInterval:2e4,refetchOnWindowFocus:!0,queryFn:async()=>{const{data:p,error:m}=await be.rpc("get_contest_participation_summary",{p_challenge_id:t,p_avatar_limit:dc});if(m)throw m;const{count:v,participantIds:A}=cc(p);if(A.length===0)return{count:v,participants:[]};const{data:y,error:N}=await be.from("creator_profiles_public").select("id, display_name, username, default_avatar_config").in("id",A);if(N)throw N;const P=new Map;for(const R of y??[])R.id&&P.set(R.id,{displayName:R.display_name??null,username:R.username??null,defaultAvatarConfig:R.default_avatar_config??null});return{count:v,participants:A.map(R=>{const B=P.get(R);return{creatorId:R,displayName:B?.displayName??null,username:B?.username??null,defaultAvatarConfig:B?.defaultAvatarConfig??null}})}}}),d=zt({queryKey:a,enabled:!!(t&&s?.id),staleTime:3e4,queryFn:async()=>{const{data:p,error:m}=await be.from("contest_participations").select("id").eq("challenge_id",t).eq("user_id",s.id).maybeSingle();if(m)throw m;return!!p}}),f=To({mutationFn:async p=>{if(!t||!s?.id)throw new Error("Authentication required");const{data:m,error:v}=await be.rpc("set_contest_participation",{p_challenge_id:t,p_participating:p});if(v)throw v;return m},onMutate:async p=>{await r.cancelQueries({queryKey:a});const m=r.getQueryData(a);return r.setQueryData(a,p),{previous:m}},onError:(p,m,v)=>{r.setQueryData(a,v?.previous??!1),ee.error("Could not update your participation. Please try again.")},onSuccess:p=>{r.setQueryData(a,p)},onSettled:()=>{r.invalidateQueries({queryKey:a}),r.invalidateQueries({queryKey:i})}}),x=n.useCallback(()=>{r.invalidateQueries({queryKey:["contest-participation",t,s?.id]}),r.invalidateQueries({queryKey:["contest-participation-summary",t]})},[r,t,s?.id]);return{isParticipating:d.data??!1,isViewerLoading:d.isPending&&!!s,participantCount:c.data?.count??0,participantSlots:c.data?.participants??[],isSummaryLoading:c.isPending,setParticipation:f,refreshParticipation:x}}function mc(t,s=!0){return zt({queryKey:["contest-brand-identity",t],enabled:!!t&&s,staleTime:30*60*1e3,queryFn:async()=>{const{data:r,error:a}=await be.from("challenges").select("business_profile:profiles!challenges_business_id_fkey(company_name, display_name, avatar_url, company_logo_url)").eq("id",t).maybeSingle();if(a)throw a;const i=r?.business_profile,c=Array.isArray(i)?i[0]??null:i??null;return{name:c?.company_name?.trim()||c?.display_name?.trim()||null,logoUrl:c?.company_logo_url||c?.avatar_url||null}}})}const pr=({cloudflareUid:t,r2Key:s,posterR2Key:r,title:a,duration:i,aspect:c,selected:d=!1,disabled:f=!1,reason:x,shapeWarning:p,indexLabel:m,isUpload:v=!1,compact:A=!1,onClick:y}
6)=>{const N=c==="9:16"?"aspect-[9/16]":c==="1:1"?"aspect-square":c==="4:5"?"aspect-[4/5]":c==="5:4"?"aspect-[5/4]":c==="4:3"?"aspect-[4/3]":c==="3:4"?"aspect-[3/4]":"aspect-video",P=Ci({posterR2Key:r,r2Key:s,cloudflareUid:t});return e.jsxs("button",{type:"button",onClick:y,disabled:f,"aria-pressed":v?void 0:d,className:Nl(d,f),title:A?[a??"Untitled",x,p].filter(Boolean).join(" · "):void 0,children:[e.jsxs("div",{className:h("relative w-full bg-black/40",N),children:[v?e.jsxs("div",{className:"absolute inset-0 m-1.5 flex flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-foreground/25 text-muted-foreground transition-colors group-hover:border-violet-500/45 group-hover:text-foreground dark:border-white/25",children:[e.jsx(Di,{className:"h-5 w-5"}),e.jsx("span",{className:"text-[11px] font-medium",children:"Upload new"})]}):P?e.jsx("img",{src:P,alt:"",loading:"lazy",decoding:"async",className:"absolute inset-0 h-full w-full object-cover",onError:R=>{R.currentTarget.style.opacity="0"}}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted-foreground/40",children:e.jsx(Fs,{className:"h-6 w-6"})}),d&&!v&&e.jsx("div",{className:"absolute left-1.5 top-1.5 rounded-full bg-violet-500 p-0.5 text-white shadow-[0_4px_12px_-4px_rgba(139,92,246,0.9)]",children:e.jsx(Jt,{className:A?"h-3 w-3":"h-3.5 w-3.5"})}),p&&!v&&e.jsxs("div",{className:"absolute right-1.5 top-1.5 rounded-full bg-amber-400 p-0.5 text-amber-950 shadow-sm",children:[e.jsx(xs,{className:A?"h-3 w-3":"h-3.5 w-3.5","aria-hidden":!0}),A&&e.jsx("span",{className:"sr-only",children:p})]}),!v&&!A&&i!=null&&e.jsxs("div",{className:"absolute right-1.5 bottom-1.5 rounded-full bg-black/65 px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-white backdrop-blur-sm",children:[Math.round(i),"s"]}),d&&m&&!v&&e.jsx("div",{className:"absolute left-1.5 bottom-1.5 rounded-full bg-violet-500/90 px-1.5 py-0.5 text-[10px] font-medium text-white backdrop-blur-sm",children:m})]}),e.jsxs("div",{className:h("px-2 py-1.5",A&&"hidden"),children:[v?e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[zl.ACCEPTED_FORMATS.join(", ")," · max ",Kl(Qn.MAX_SIZE_MB)]}):e.jsx("p",{className:"text-[11px] font-medium text-foreground truncate",children:a||"Untitled"}),f&&x?e.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3 text-amber-400/80 shrink-0"}),e.jsx("p",{className:"text-[10px] text-amber-700 dark:text-amber-300/90 truncate",title:x,children:x})]}):p&&!v?e.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[e.jsx(xs,{className:"h-3 w-3 text-amber-500 shrink-0"}),e.jsx("p",{className:"text-[10px] text-amber-700 dark:text-amber-300/90 truncate",title:p,children:p})]}):null]})]})};function Ji(t){return{width:t.width,height:t.height,duration:t.duration}}function eo(t,s,r){const a=[],i=[],c={short:0,long:0};for(const d of t){const f=Ul({width:d.width,height:d.height,duration:d.duration},{acceptedAspects:s,minSeconds:r.minSeconds,maxSeconds:r.maxSeconds}),x={...d,aspect:f.aspect,offShape:f.offShape};f.durationMiss?(c[f.durationMiss]+=1,i.push({...x,reason:f.reason})):a.push(x)}return{eligible:a,ineligible:i,missCounts:c}}function Vr(t){return`Not ${t.join(" or ")}`}const pc=({loading:t,ineligibleCount:s=0,durationLimits:r})=>e.jsx("div",{className:"flex min-h-[76px] items-center justify-center rounded-xl border border-dashed border-foreground
6/15 bg-foreground/[0.03] px-4 py-3 text-center dark:border-white/15 dark:bg-white/[0.03]",children:e.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:t?"Loading your project videosâ¦":s>0?`None of your ${s} project ${s===1?"video is":"videos are"} the right length for this contest (${Gr(r)}). Open the list below to see each one's length.`:"No ready videos in this project yet."})}),hc=({mode:t,projectId:s,durationLimits:r,acceptedAspects:a,value:i,onChange:c,onFileSelected:d,onUploadingChange:f,onUploadKeyAssigned:x,adPreview:p,acceptImages:m=!1,imageValue:v=null,onImageChange:A})=>{const{data:y=[],isLoading:N}=Li(s),{data:P=[]}=kl(m?s:null),R=t==="upload-only"||t==="pick-or-upload",B=(t==="pick-or-upload"||t==="pick-only")&&!!s,{eligible:S,ineligible:K,missCounts:b}=n.useMemo(()=>eo(y,a,r),[y,a,r]),[F,E]=n.useState([]),[Q,O]=n.useState(!1),H=n.useRef(null),te=n.useRef([]),{uploadFiles:z,uploading:ie}=Bl(void 0,s),[se,Z]=n.useState([]),[w,j]=n.useState(null),[T,_]=n.useState(!1),U=n.useRef([]);U.current=se,n.useEffect(()=>()=>{for(const I of U.current)I.localPreviewUrl?.startsWith("blob:")&&URL.revokeObjectURL(I.localPreviewUrl)},[]),n.useEffect(()=>{f?.(T||ie)},[T,ie,f]);const $=n.useCallback(async I=>{const De=URL.createObjectURL(I);j(De);const[Le]=await z([I]);if(!Le){URL.revokeObjectURL(De),j(null);return}const Ae={imageId:Le.id,r2Key:Le.r2Key,cfImageId:Le.cfImageId,width:Le.width,height:Le.height,localPreviewUrl:De};Z(ke=>[Ae,...ke]),j(null),A?.(Ae)},[z,A]);n.useEffect(()=>{te.current=F},[F]),n.useEffect(()=>()=>{te.current.forEach(I=>{I.localPreviewUrl&&URL.revokeObjectURL(I.localPreviewUrl)})},[]);const M=i?.cloudflareUid||i?.r2Key,D=n.useMemo(()=>{const I=i?.cloudflareUid||i?.r2Key;if(!I)return null;const De=F.find(Le=>(Le.cloudflareUid||Le.r2Key)===I);return De?.localPreviewUrl?De.localPreviewUrl:!i?.cloudflareUid&&i?.r2Key?jl(i.r2Key):_l(i.cloudflareUid)},[i,F]),Y=n.useMemo(()=>{if(!i)return null;const I=F.find(De=>(De.cloudflareUid||De.r2Key)===(i.cloudflareUid||i.r2Key));return Ci({posterR2Key:I?.posterR2Key??i.posterR2Key,r2Key:i.r2Key,cloudflareUid:i.cloudflareUid})},[i,F]),W=I=>Hr(I.width,I.height,a)?void 0:Vr(a),u=n.useMemo(()=>w&&!T?w:v?v.localPreviewUrl??Or({r2_key:v.r2Key,cf_image_id:v.cfImageId,pointer_url:v.pointerUrl},"detail"):null,[w,T,v]),ue=!!u,ve=ue||!!D,q=S.length+F.length+P.length+se.length>0,me=Bn(a),X=Cl(me),fe=R?e.jsx(Ui,{compact:!0,className:p&&!ve?"flex flex-col gap-2":void 0,dropZoneClassName:ve?h(Ai,"flex-row justify-center gap-2 px-3 py-2"):p?"min-h-[96px] flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-white/25 bg-white/[0.04] px-3 py-4 text-center hover:border-white/40":"absolute inset-0 flex-col items-center justify-center gap-2 rounded-2xl border-0 bg-transparent text-center",queueClassName:p&&!ve?"shrink-0 border-white/15 bg-black/70 backdrop-blur-sm":void 0,archiveOriginalToR2:!0,r2OnlyWhenSupported:!0,onUploadingStateChange:_,onUploadKeyAssigned:x,onImageFile:m?$:void 0,onVideoUploaded:(I,De,Le,Ae,ke,he)=>{const je=De||Ae;if(!je)return;const xe=H.current??void 0;H.current=null;const Be={cloudflareUid:De,r2Key:Ae??void 0,posterR2Key:ke??void 0,localPreviewUrl:xe,media:he??void 0};E(G=>G.some(_e=>(_e.cloudflareUid||_e.r2Key)===je)?G:[...G,Be]),c(Be)},onFileSelected:I=>{H.current=I,d?.(I)},maxSizeMB:Qn.MAX_SIZE_MB,maxDurationSeconds:r.maxSeconds,minDurationSeconds:r.minSeconds}):null,qe=m?"videos or images":"videos",Ve=N?`Loading your project ${qe}â¦`:q?`Pick one of your ${qe} below.`:K.length>0?`None of your project videos are the right length for this contest (${Gr(r)}).`:`No ready ${qe} in this project yet.`;return e.jsxs("div",{className:"space-y-3",children:[p?e.jsx(Sl,{aspect:me,context:p,format:ue?"image":"video",mediaUrl:ue?u:D,thumbnailUrl:ue?null:Y,mediaSlot:e.jsx("div",{className:h("absolute inset-0 z-10 flex flex-col justify-center",me==="9:16"?"dark px-3 pb-[30%] pr-[19%] [&_p]:text-white/85 [&_svg]:text-white/75":"px-5 py-4 [&_p]:text-[#65676B] [&_svg]:text-[#65676B]"),children:R?fe:e.jsx("p",{className:h("text-center text-xs leading-relaxed",me==="9:16"?"text-white/85":"text-[#65676B]"),children:Ve})})}):e.jsx("div",{className:h("relative mx-auto overflow-hidden rounded-2xl border",ve?"border-foreground
6/12 bg-black dark:border-white/12":"border-dashed border-foreground/20 bg-foreground/[0.03] dark:border-white/20 dark:bg-white/[0.03]",X),children:ue?e.jsx("img",{src:u,alt:"Selected submission",className:"h-full w-full object-contain"}):D?e.jsx(Yn,{src:D,controls:!0,autoPlay:!1,className:"h-full w-full"}):R?fe:e.jsx("div",{className:"flex h-full w-full items-center justify-center px-4 text-center",children:e.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:Ve})})}),B&&S.length+P.length>0&&e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-1 scrollbar-thin",children:[se.map(I=>e.jsx("div",{className:"w-[72px] shrink-0",children:e.jsx(Ma,{url:I.localPreviewUrl??Or({r2_key:I.r2Key},"card"),title:"Uploaded image",isUpload:!0,shapeWarning:W(I),selected:v?.imageId===I.imageId,onClick:()=>A?.(I)})},`upload-image-${I.imageId}`)),F.map((I,De)=>{const Le=I.cloudflareUid||I.r2Key;return e.jsx("div",{className:"w-[72px] shrink-0",children:e.jsx(pr,{cloudflareUid:I.cloudflareUid,r2Key:I.r2Key,posterR2Key:I.posterR2Key,title:`Uploaded${F.length>1?` ${De+1}`:""}`,duration:I.media?.duration??null,aspect:$l(I.media?.width,I.media?.height)??me,shapeWarning:Hr(I.media?.width,I.media?.height,a)?void 0:Vr(a),compact:!0,selected:!!Le&&M===Le,onClick:()=>c(I)})},`upload-${Le}`)}),S.map(I=>e.jsx("div",{className:"w-[72px] shrink-0",children:e.jsx(pr,{cloudflareUid:I.cloudflare_video_id,r2Key:I.r2_key,title:I.title,duration:I.duration,aspect:I.aspect??me,shapeWarning:I.offShape?Vr(a):void 0,compact:!0,selected:!!i?.videoId&&i.videoId===I.id,onClick:()=>c({cloudflareUid:I.cloudflare_video_id??"",videoId:I.id,r2Key:I.r2_key??void 0,media:Ji(I)})})},I.id)),P.map(I=>e.jsx("div",{className:"w-[72px] shrink-0",children:e.jsx(Ma,{url:Or({r2_key:I.r2_key,cf_image_id:I.cf_image_id,pointer_url:I.pointer_url},"card"),title:I.title,shapeWarning:W(I),selected:v?.imageId===I.id,onClick:()=>A?.({imageId:I.id,r2Key:I.r2_key,cfImageId:I.cf_image_id,pointerUrl:I.pointer_url,width:I.width,height:I.height})})},`image-${I.id}`))]}),ve&&fe,B&&K.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>O(I=>!I),"aria-expanded":Q,className:Wr,children:[e.jsx(Gs,{className:h("h-3.5 w-3.5 transition-transform",Q&&"rotate-180")}),Q?"Hide":"Show"," ",Ei(b,r)]}),Q&&e.jsx("div",{className:"mt-2.5 flex gap-2 overflow-x-auto pb-1 scrollbar-thin",children:K.map(I=>e.jsx("div",{className:"w-[72px] shrink-0",children:e.jsx(pr,{cloudflareUid:I.cloudflare_video_id,r2Key:I.r2_key,title:I.title,duration:I.duration,aspect:I.aspect,compact:!0,disabled:!0,reason:I.reason??void 0,onClick:()=>{}})},I.id))})]})]})},fc=({mode:t,projectId:s,durationLimits:r,acceptedAspects:a,value:i,requiredVideos:c,onChange:d,onSlotFileSelected:f,onSlotUploaded:x,onUploadingChange:p,onUploadKeyAssigned:m})=>{const{data:v=[],isLoading:A}=Li(s),y=i.filter(Q=>Q.cloudflareUid||Q.r2Key||Q.videoId).length,{eligible:N,ineligible:P,missCounts:R}=n.useMemo(()=>eo(v,a,r),[v,a,r]),[B,S]=n.useState(!1),[K,b]=n.useState({}),F=Object.values(K).some(Boolean);if(n.useEffect(()=>{p?.(F)},[F,p]),t==="pick-only"&&!!s){const Q=O=>{const H=i.findIndex(te=>te.videoId===O.id);if(H!==-1)d(i.map((te,z)=>z===H?{cloudflareUid:"",title:""}:te));else if(y<c){const te=i.findIndex(se=>!se.cloudflareUid&&!se.r2Key&&!se.videoId),z=(te===-1?i.length:te)+1,ie={cloudflareUid:O.cloudflare_video_id??"",videoId:O.id,r2Key:O.r2_key??void 0,title:O.title||`Video ${z}`,media:Ji(O)};d(te!==-1?i.map((se,Z)=>Z===te?ie:se):[...i,ie])}};return e.jsxs("section",{className:h(Bt,"space-y-3"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("h3",{className:gs,children:["Pick ",c," videos"]}),e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[y,"/",c," picked · first one is the cover"]})]}),N.length===0?e.jsx(pc,{loading:A,ineligibleCount:P.length,durationLimits:r}):e.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3 max-h-[28rem] overflow-y-auto scrollbar-thin",children:N.map(O=>{const H=i.findIndex(z=>z.videoId===O.id),te=H!==-1;return e.jsx(pr,{cloudflareUid:O.cloudflare_video_id,r2Key:O.r2_key,title:O.title,duration:O.duration,aspect:O.aspect,shapeWarning:O.offShape?Vr(a):void 0,selected:te,disabled:!te&&y>=c,indexLabel:te?`V${H+1}${H===0?" · thumb":""}`:void 0,onClick:()=>Q(O)},O.id)})}),P.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>S(O=>!O),"aria-expanded":B,className:Wr,children:[e.jsx(Gs,{className:h("h-3.5 w-3.5 transition-transform",B&&"rotate-180")}
6),B?"Hide":"Show"," ",Ei(R,r)]}),B&&e.jsx("div",{className:"mt-2.5 grid grid-cols-2 gap-2.5 sm:grid-cols-3 max-h-[28rem] overflow-y-auto scrollbar-thin",children:P.map(O=>e.jsx(pr,{cloudflareUid:O.cloudflare_video_id,r2Key:O.r2_key,title:O.title,duration:O.duration,aspect:O.aspect,disabled:!0,reason:O.reason??void 0,onClick:()=>{}},O.id))})]})]})}return e.jsx("div",{className:"space-y-3",children:Array.from({length:c}).map((Q,O)=>{const H=i[O]??{cloudflareUid:"",title:""},te=!!(H.cloudflareUid||H.r2Key);return e.jsxs("section",{className:h(Bt,"space-y-3"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("h3",{className:gs,children:["Video ",O+1,O===0?" · cover":""]}),e.jsx("span",{className:h("inline-flex items-center gap-1 text-xs",te?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:te?e.jsxs(e.Fragment,{children:[e.jsx(Jt,{className:"h-3.5 w-3.5"})," Ready"]}):"Not added yet"})]}),e.jsx(Kt,{value:H.title,onChange:z=>{const ie=[...i];ie[O]={...H,title:z.target.value},d(ie)},placeholder:`Title for video ${O+1}`,"aria-label":`Title for video ${O+1}`,className:cr}),e.jsx(Ui,{compact:!0,dropZoneClassName:Ai,archiveOriginalToR2:!0,r2OnlyWhenSupported:!0,onUploadingStateChange:z=>b(ie=>ie[O]===z?ie:{...ie,[O]:z}),onUploadKeyAssigned:m,onVideoUploaded:(z,ie,se,Z,w,j)=>{if(!(!ie&&!Z))if(x)x(O,ie,Z??void 0,w??void 0,j??void 0);else{const T=[...i];T[O]={...H,cloudflareUid:ie,r2Key:Z??void 0,posterR2Key:w??void 0,media:j??void 0},d(T)}},onFileSelected:z=>f?.(O,z),maxSizeMB:Qn.MAX_SIZE_MB,maxDurationSeconds:r.maxSeconds,minDurationSeconds:r.minSeconds}),H.localPreviewUrl&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-xl border border-foreground
6/10 bg-black dark:border-white/10",children:e.jsx(Yn,{src:H.localPreviewUrl,controls:!0,autoPlay:!1,className:"h-full w-full"})})]},O)})})},Ha=t=>t.variant==="single"?e.jsx(hc,{...t}):e.jsx(fc,{...t});async function xc(t){if(!t)return!1;try{const{data:s,error:r}=await be.functions.invoke("video-stream-upload-v1",{body:{action:"delete",r2Key:t}});return r?(console.warn("[submission] abandoned upload reclaim failed",t,r.message),!1):!!s?.deleted}catch(s){return console.warn("[submission] abandoned upload reclaim threw",t,s),!1}}async function Ya(t){const s=[...new Set(t.filter(Boolean))];s.length!==0&&await Promise.all(s.map(r=>xc(r)))}const Kr=Yl().map(t=>({key:t.key,label:t.label,body:t.body})),Qa={originality:!1,winner_assignment_commitment:!1,holdback_acknowledgment:!1,anthum_training_acknowledgment:!1,confidentiality_acknowledgment:!1,compliance_and_brand_assets_acknowledgment:!1};function gc(t){if(!t)return null;try{const s=typeof t=="string"?new Date(t):t;return Number.isNaN(s.getTime())?null:s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}catch{return null}}function bc({open:t,contestName:s,prizePoolUsd:r,numWinners:a,closesAt:i,isEditing:c=!1,submitting:d=!1,isPerformanceCampaign:f=!1,onCancel:x,onClose:p,onConfirm:m}){const[v,A]=n.useState(Qa),[y,N]=n.useState({});n.useEffect(()=>{t&&(A(Qa),N({}))},[t]),n.useEffect(()=>{if(!t||!p||d)return;const b=F=>{F.key==="Escape"&&(F.preventDefault(),p())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[t,p,d]);const P=n.useMemo(()=>Kr.every(b=>v[b.key]),[v]),R=gc(i);if(!t||typeof document>"u")return null;const B=async()=>{!P||d||await m({checkboxStates:{...v},capturedAt:new Date().toISOString()})},S=Kr.filter(b=>v[b.key]).length,K=[typeof r=="number"?`$${r.toLocaleString()} prize pool`:null,typeof a=="number"?`${a} winners`:null,R?`Closes ${R}`:null].filter(Boolean);return hi.createPortal(e.jsx("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm",role:"dialog","aria-modal":"true","aria-labelledby":"submission-consent-title",children:e.jsxs("div",{className:h(Mi,"max-h-[92dvh] w-full max-w-2xl"),children:[e.jsxs("div",{className:"flex-shrink-0 border-b studio-border-soft px-5 pb-4 pt-5 sm:px-7",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-violet-600 dark:text-violet-300",children:c?"Re-confirm to update":"Last step"}),e.jsx("h2",{id:"submission-consent-title",className:"mt-1.5 text-lg font-semibold leading-tight tracking-tight text-foreground line-clamp-2 sm:text-xl",children:s})]}),p&&e.jsx("button",{type:"button",onClick:p,disabled:d,className:h(Fr(),"h-8 w-8 shrink-0 disabled:cursor-not-allowed disabled:opacity-35"),"aria-label":"Close",children:e.jsx(qs,{className:"h-4 w-4"})})]}),K.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:K.map(b=>e.jsx("span",{className:ur,children:b},b))}),e.jsx("p",{className:h(Zt,"mt-3"),children:"Confirm the commitments below. They are the same for every Anthum entry, and you only check them once per entry."}),f&&e.jsx("div",{className:h(hs("emerald"),"mt-3"),children:e.jsxs("p",{className:fs,children:["On a performance campaign you keep ownership of your work, grant the brand a license to run it as an ad, and earn from the results it drives at the rates shown on the campaign page. The winner-assignment and holdback commitments below apply to prize contests only, and the"," ",e.jsx(Mt,{to:"/terms#section-7c",target:"_blank",rel:"noopener noreferrer",className:"font-medium underline underline-offset-2 hover:no-underline",children:"Performance Campaign Terms"})," ","govern this one."]})})]}),e.jsx("div",{className:"flex-1 space-y-2 overflow-y-auto px-5 py-4 scrollbar-thin sm:px-7",children:Kr.map((b,F)=>{const E=v[b.key],Q=!E||!!y[b.key];return e.jsxs("label",{htmlFor:`submission-consent-${b.key}`,className:h("flex cursor-pointer select-none items-start gap-3 rounded-xl border p-3.5","transition-[background-color,border-color]",E?"border-violet-500/35 bg-violet-500/[0.08] dark:border-violet-400/35 dar
6k:bg-violet-400/[0.08]":"border-foreground/10 bg-foreground/[0.035] hover:border-foreground/20 dark:border-white/10 dark:bg-white/[0.035] dark:hover:border-white/20"),children:[e.jsx(Ti,{id:`submission-consent-${b.key}`,checked:E,onCheckedChange:O=>{A(H=>({...H,[b.key]:O===!0})),N(H=>({...H,[b.key]:!1}))},className:"mt-0.5 shrink-0 border-foreground/25 data-[state=checked]:border-violet-500 data-[state=checked]:bg-violet-500 data-[state=checked]:text-white dark:border-white/25"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-semibold leading-relaxed text-foreground",children:[F+1,". ",b.label]}),Q&&e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:b.body})]}),E&&e.jsx("button",{type:"button",onClick:O=>{O.preventDefault(),N(H=>({...H,[b.key]:!H[b.key]}))},"aria-expanded":Q,"aria-label":Q?`Hide the detail of ${b.label}`:`Read the detail of ${b.label}`,className:"mt-0.5 shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-foreground
6/[0.06] hover:text-foreground dark:hover:bg-white/[0.06]",children:e.jsx(Gs,{className:h("h-4 w-4 transition-transform",Q&&"rotate-180")})})]},b.key)})}),e.jsxs("div",{className:"flex-shrink-0 space-y-3 border-t studio-border-soft px-5 py-4 sm:px-7",children:[e.jsxs("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:["By submitting you agree to the"," ",e.jsx(Mt,{to:"/terms",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:no-underline",children:"Terms of Service"}),", the"," ",e.jsx(Mt,{to:"/privacy",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:no-underline",children:"Privacy Policy"}),", and"," ",f?e.jsx(Mt,{to:"/terms#section-7c",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:no-underline",children:"Section 7C (Performance Campaigns)"}):"Section 7A (Submission Consent and Holdback)"," ","specifically."]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("p",{className:h("text-xs tabular-nums",P?"text-muted-foreground":"text-foreground/80"),children:P?"All six confirmed":`${S} of ${Kr.length} confirmed`}),e.jsxs("div",{className:"flex flex-col-reverse gap-3 sm:flex-row sm:items-center",children:[e.jsx(Ee,{type:"button",variant:"outline",onClick:x,disabled:d,className:h(mr,"w-full sm:w-auto"),children:"Back"}),e.jsx(Ee,{type:"button",onClick:B,disabled:!P||d,className:h(Ri,"w-full sm:w-auto"),children:d?e.jsxs(e.Fragment,{children:[e.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Submittingâ¦"]}):e.jsx(e.Fragment,{children:"Submit my entry"})})]})]})]})]})}),document.body)}const vc=["twitter.com","x.com","instagram.com","tiktok.com","youtube.com","youtu.be","facebook.com","fb.com","linkedin.com","threads.net"];function Es(t){const s=t.trim();if(!s)return!1;let r;try{r=new URL(s)}catch{return!1}if(r.protocol!=="http:"&&r.protocol!=="https:")return!1;const a=r.hostname.toLowerCase().replace(/^www\./,"");return vc.some(i=>a===i||a.endsWith(`.${i}`))}const wc=({isOpen:t,onClose:s,challengeId:r,challengeTitle:a,onSubmissionCreated:i,preSelectedChallengeId:c,bundleSize:d,selectedBrandOptionId:f,reservedBrands:x=[],brandSelectionRequired:p=!1,selectedProductOptionId:m,reservedProducts:v=[],productSelectionRequired:A=!1,isEditing:y=!1,existingSubmission:N,initialVideoId:P,lateSubmissionMode:R=!1,isPerformanceCampaign:B=!1})=>{const S=B?"campaign":"contest",{user:K}=xr(),{data:b}=bi(r),F=Uo(),[E,Q]=n.useState(!1),[O,H]=n.useState(!1),[te,z]=n.useState("video"),[ie,se]=n.useState("video"),[Z,w]=n.useState(null),[j,T]=n.useState(0),[_,U]=n.useState(0),[$,M]=n.useState(!1),[D,Y]=n.useState(!1),[W,u]=n.useState(0),[ue,ve]=n.useState({prizeAmount:null,numWinners:null,deadline:null});n.useEffect(()=>{if(!t)return;let o=!1;return(async()=>{const{data:k,error:V}=await be.from("challenges_public").select("require_platform_generation, strict_studio_only, min_image_generations, min_video_generations, prize_amount, prize_distribution, deadline, penalize_late_submissions, late_submission_winning_penalty_pct, submission_media_type, aspect_ratio, accepted_aspect_ratios").eq("id",r).maybeSingle();if(V&&console.error("[VideoSubmissionModal] Failed to load contest penalty flags:",V),o)return;const ae=k;Q(k?.require_platform_generation===!0),H(k?.strict_studio_only===!0);const Ne=k?.submission_media_type;z(Ne==="image"||Ne==="both"?Ne:"video"),T(Math.max(0,k?.min_image_generations??0)),U(Math.max(0,k?.min_video_generations??0));const ce=Array.isArray(k?.prize_distribution)?k?.prize_distribution:null;ve({prizeAmount:typeof k?.prize_amount=="number"?k.prize_amount:null,numWinners:ce?ce.length:null,deadline:typeof k?.deadline=="string"?k.deadline:null}),Y(ae?.penalize_late_submissions===!0),u(Math.min(100,Math.max(0,ae?.late_submission_winning_penalty_pct??0)));const Pe=k;jr(El(Pe?.accepted_aspect_ratios??null,Pe?.aspect_ratio??null)),M(!0)})(),()=>{o=!0}},[t,r]);const{project:q,hasResolved:me}=$i(E?r:void 0,a),{data:X}=mc(r,t),fe=O?"pick-only":q?"pick-or-upload":"upload-only",[qe,Ve]=n.useState(null),[I,De]=n.useState(null);n.useEffect(()=>{if(!t||!E||!q?.id){Ve(null),De(null);return}let o=!1;return(async()=>{const[k,V]=await Promise.all([be.from("images").select("id",{count:"exact",head:!0}).eq("project_id",q.id).in("source",["generated","upscale"]),be.from("videos").select("id",{count:"exact",head:!0}).eq("project_id",q.id).eq("source","ai-generated")]);o||(Ve(k.count??0),De(V.count??0))})(),()=>{o=!0}},[t,E,q?.id]);const[Le,Ae]=n.useState(30);n.useEffect(()=>{if(!t||!E)return;let o=!1;return(async()=>{const{data:k}=await be.from("app_settings").select("value").eq("key","non_anthum_reward_penalty_pct").maybeSingle();if(o)return;const V=Bi(k?.value);V!==null&&Ae(V)})(),()=>{o=!0}},[t,E]);const ke=n.useMemo(()=>zi(ue.deadline,Le),[ue.deadline,Le]),[he,je]=n.useState(null);n.useEffect(()=>{if(!t||!y||!N){je(null);return}let o=!1;return(async()=>{const{data:k,error:V}=await be.rpc("is_submission_anthum_generation",{p_submission_id:N.id});if(!o){if(V){console.warn("is_submission_anthum_generation failed in edit modal:",V),je(null);return}je(k===!0)}})(),()=>{o=!0}},[t,y,N]);const xe=n.useMemo(()=>
6E?q?qe===null||I===null?"qualifies":qe<j||I<_?"below-min":"qualifies":"no-project":"n/a",[E,q,qe,I,j,_]),Be=x.length>0||p,[G,_e]=n.useState(f),Re=G??f,$e=v.length>0||A,[L,Se]=n.useState(m),Ce=L??m,[g,J]=n.useState({title:"",description:"",cloudflareVideoId:"",pickedVideoId:"",uploadR2Key:"",uploadPosterR2Key:"",videoMedia:null,selectedChallengeId:c||"",socialPostUrl:""}),[pe,Fe]=n.useState(null),Ue=n.useMemo(()=>({brandName:X?.name??null,brandLogoUrl:X?.logoUrl??null,headline:g.title,primaryText:g.description}),[X?.name,X?.logoUrl,g.title,g.description]),[re,ze]=n.useState(!1),[Oe,lt]=n.useState(new Map),[mt,Rt]=n.useState({minSeconds:10,maxSeconds:120}),[He,at]=n.useState(null),[gt,Ft]=n.useState(!1),[yt,Hs]=n.useState(d??null),[Ke,Te]=n.useState([]),[et,$t]=n.useState(!1),Ys=n.useRef(null),[rs,pn]=n.useState(!1),[pt,Ot]=n.useState([]),[Qs,Vt]=n.useState(""),[St,Zs]=n.useState(""),[Ct,_s]=n.useState(""),Nt=n.useRef(new Set),Wt=n.useCallback(o=>{o&&Nt.current.add(o)},[]),[Ze,ns]=n.useState(!1),[wr,jt]=n.useState(!1),[It,Ns]=n.useState(3),[Ie,as]=n.useState(1),ks=y?1:2;n.useEffect(()=>{t&&as(1)},[t]);const yr=n.useRef(null);n.useEffect(()=>{yr.current?.querySelectorAll("video").forEach(o=>o.pause())},[Ie]);const[bt,jr]=n.useState([]),tt=te==="image"||te==="both"&&ie==="image",ht=!tt&&yt!=null&&yt>1,Ye=!tt&&(ht||wr),Ut=te==="both"&&!y&&!Ye,Xs=Ut&&!Z&&!g.cloudflareVideoId&&!g.uploadR2Key&&!g.pickedVideoId,dt=ht?yt:wr?It:1;n.useEffect(()=>{if(t)if(y&&N){J({title:N.title||"",description:N.description||"",cloudflareVideoId:"",pickedVideoId:"",uploadR2Key:"",uploadPosterR2Key:"",videoMedia:null,selectedChallengeId:N.contest_challenge_id||"",socialPostUrl:""}),Ot([]),Zs(""),_s(""),_e(N.selected_brand_id??void 0),Se(N.selected_product_id??void 0),jt(!1),Fe(null);const o=ws(N),k=o.type==="cloudflare"?o.videoUid:null,V=N.bundle_videos??[];if(V.length>1){const Ne=[...V].sort((ce,Pe)=>ce.display_order-Pe.display_order).map((ce,Pe)=>({cloudflareUid:ce.video?.cloudflare_video_id||"",videoId:ce.video?.id,r2Key:ce.video?.r2_key??void 0,title:ce.video?.title||`Video ${Pe+1}`})).filter(ce=>ce.cloudflareUid||ce.videoId);Te(Ne),!ht&&Ne.length>1&&(jt(!0),Ns(Ne.length))}else if(Te([]),k){const ae=o.type==="cloudflare"?o.r2Key:null;J(Ne=>({...Ne,cloudflareVideoId:k,...ae?{uploadR2Key:ae,pickedVideoId:N.video_id??""}:{}}))}else{const ae=o.type==="cloudflare"?o.r2Key:null;ae&&J(Ne=>({...Ne,uploadR2Key:ae,pickedVideoId:N.video_id??""}))}N.media_type==="image"||N.image_id?(se("image"),w(N.image_id?{imageId:N.image_id,r2Key:N.image_r2_key??N.image?.r2_key??null,cfImageId:N.image?.cf_image_id??null,pointerUrl:N.image?.pointer_url??null,width:N.image?.width??null,height:N.image?.height??null}:null)):(se("video"),w(null))}else{se("video"),w(null),J({title:"",description:"",cloudflareVideoId:"",pickedVideoId:"",uploadR2Key:"",uploadPosterR2Key:"",videoMedia:null,selectedChallengeId:c||"",socialPostUrl:""}),Ot([]),Vt(""),Zs(""),_s(""),ns(!1),Nt.current.clear(),_e(f),Se(m),jt(!1),Ns(3),Fe(V=>(V&&URL.revokeObjectURL(V),null));const o=d??yt??0,k=o>1;Te(V=>(V.forEach(ae=>{ae.localPreviewUrl&&URL.revokeObjectURL(ae.localPreviewUrl)}),k?Array.from({length:o},()=>({cloudflareUid:"",title:""})):[]))}},[t,y,N,c,d,ht,f,P]),n.useEffect(()=>{if(!t||y||!P)return;let o=!1;return(async()=>{const{data:k}=await be.from("videos").select("cloudflare_video_id, r2_key, width, height, duration").eq("id",P).maybeSingle();!o&&(k?.cloudflare_video_id||k?.r2_key)&&J(V=>({...V,cloudflareVideoId:k.cloudflare_video_id??"",uploadR2Key:k.r2_key??"",pickedVideoId:P,videoMedia:{width:k.width,height:k.height,duration:k.duration}}))})(),()=>{o=!0}},[t,y,P]),n.useEffect(()=>{!t||!Ye||Te(o=>o.length===dt?o:Array.from({length:dt},(k,V)=>o[V]??{cloudflareUid:"",title:""}))},[t,Ye,dt]),n.useEffect(()=>{(async()=>{if(!K||!t)return;const{data:k}=await be.from("submissions").select("contest_challenge_id, status").eq("challenge_id",r).eq("creator_id",K.id).not("status","in",'("rejected","withdrawn","disqualified")');if(k){const ae=new Map;
6k.forEach(Ne=>{const ce=Ne.contest_challenge_id;ce&&ae.set(ce,(ae.get(ce)??0)+1)}),lt(ae)}const{data:V}=await be.from("challenges_public").select("min_video_length_seconds, max_video_length_seconds, max_submissions_per_creator, require_social_post, bundle_size").eq("id",r).single();if(V){const ae=V;Rt({minSeconds:ae.min_video_length_seconds??10,maxSeconds:ae.max_video_length_seconds||120}),at(ae.max_submissions_per_creator??null),Ft(ae.require_social_post||!1),d===void 0&&Hs(ae.bundle_size??null)}})()},[K,r,t,d]);const Ss=n.useCallback(o=>He==null||He===0?!1:(Oe.get(o)??0)>=He,[Oe,He]);n.useEffect(()=>{c&&!Ss(c)&&J(o=>({...o,selectedChallengeId:c}))},[c,Ss]),n.useEffect(()=>{if(b&&!g.selectedChallengeId){const o=b.filter(k=>!Ss(k.id));o.length===1&&J(k=>({...k,selectedChallengeId:o[0].id}))}},[b,g.selectedChallengeId,Ss]);const _r=n.useCallback(o=>{J(k=>({...k,cloudflareVideoId:o?.cloudflareUid??"",pickedVideoId:o?.videoId??"",uploadR2Key:o?.r2Key??"",uploadPosterR2Key:o?.posterR2Key??"",videoMedia:o?.media??null})),Fe(o?.localPreviewUrl??null),o&&(se("video"),w(null))},[]),Nr=n.useCallback(o=>{w(o),o&&(se("image"),J(k=>({...k,cloudflareVideoId:"",pickedVideoId:"",uploadR2Key:"",uploadPosterR2Key:"",videoMedia:null})),Fe(null))},[]),kr=n.useCallback(o=>{Fe(k=>(k&&URL.revokeObjectURL(k),o))},[]),hn=n.useCallback(o=>{Te(o)},[]),is=n.useCallback((o,k)=>{Te(V=>{const ae=[...V],Ne=ae[o];return Ne&&(Ne.localPreviewUrl&&URL.revokeObjectURL(Ne.localPreviewUrl),ae[o]={...Ne,localPreviewUrl:k}),ae})},[]),Js=n.useCallback((o,k,V,ae,Ne)=>{Te(ce=>{const Pe=[...ce],ne=Pe[o]??{cloudflareUid:"",title:""};return Pe[o]={...ne,cloudflareUid:k,r2Key:V,posterR2Key:ae,media:Ne,videoId:void 0},Pe})},[]),os=n.useCallback(async o=>{const k=Ys.current;if(!(!K||!o||!k))try{const V=await Ql({submissionId:o,contestId:r,creatorAccountId:K.id,checkboxStates:k.checkboxStates});V.ok||console.warn("[legal] submission consent insert failed",V.error)}catch(V){console.warn("[legal] submission consent insert threw",V)}},[K,r]),Gt=n.useCallback(o=>{const k=new Set(o.filter(ae=>!!ae)),V=[...Nt.current].filter(ae=>!k.has(ae));Nt.current.clear(),V.length>0&&Ya(V)},[]),Xe=n.useCallback(async o=>{if(o.preventDefault(),!K){ee.error("Not logged in");return}if(Be&&!Re){ee.error("Brand Required",{description:"Please select which brand this submission is for."});return}if($e&&!Ce){ee.error("Product Required",{description:"Please select which product this submission is for."});return}if(Ye){if(!(Ke.length===dt&&Ke.every(V=>V.cloudflareUid||V.r2Key||V.videoId))){ee.error("Complete all videos",{description:`You need ${dt} videos before submitting.`});return}}else if(tt){if(!Z){ee.error("Image Required",{description:"Pick or upload an image for your submission."});return}}else if(!g.cloudflareVideoId&&!g.uploadR2Key){ee.error("Video Required",{description:"Pick or upload a video for your submission."});return}if(!y&&!g.title.trim()&&!Ye){ee.error("Title Required");return}if(b&&b.length>1&&!g.selectedChallengeId){ee.error("Track Required",{description:"Please select a challenge track for your submission."});return}if(gt&&!y){if(!g.socialPostUrl.trim()){ee.error("Social Post Required");return}if(!Es(g.socialPostUrl)){ee.error("Invalid social media URL");return}}if(E&&O&&!q){ee.error("Studio project required",{description:`This ${S} is strict Studio-Only. Create your entry in the Studio first.`});return}try{ze(!0);const{data:{session:k}}=await be.auth.getSession();if(!k?.user){ee.error("Session Expired",{description:"Please log in again."});return}const V=k.user;if(!y){const{data:ne,error:Me}=await be.from("challenges_public").select("*").eq("id",r).maybeSingle();if(Me){console.error("Contest state check failed:",Me),ee.error("Could not reach Anthum",{description:"Check your connection and try submitting again."});return}if(!ne){ee.error(B?"Campaign Closed":"Contest Closed",{description:"Not accepting submissions."});return}const oe=ne.submissions_paused_at??null;if(!Kn({status:ne.status,deadline:ne.deadline,allowLate:ne.allow_late_submission===!0,lateSubmissionMode:R,pausedAt:oe})){const Qe=ne.deadline&&new Date(ne.deadline).getTime()<Date.now();oe?ee.error("Submissions paused",{description:`This ${S} is not taking new entries right now. Your time remaining is held until it reopens.`}):Qe&&!R?ee.error("Deadline Passed",{description:"Use the late-submission link if this contest still accepts late entr
6ies."}):Qe?ee.error("Late submission window closed",{description:"Submissions are no longer accepted for this contest."}):ee.error(B?"Campaign Closed":"Contest Closed",{description:"Not accepting submissions."});return}}const{data:ae}=await be.from("creator_elo").select("current_elo").eq("user_id",V.id).maybeSingle(),Ne=await oc(be,V.id),ce=(ae?.current_elo??0)>1050,Pe=q?.id??null;if(y&&N){const ne=ws(N),Me=ne.type==="cloudflare"?ne.videoUid:null;if(Ye){const oe=Ke[0],Qe=N.video_r2_key??N.video?.r2_key??"",it=(oe.cloudflareUid||"")!==(Me||"")||(oe.r2Key||"")!==Qe||!!oe.videoId&&oe.videoId!==(N.video_id??"");let we;if(it)if(oe.videoId)we=oe.videoId;else{const{videoId:ct,error:ut}=await Us({creatorId:V.id,title:g.title.trim()||oe.title||"Video 1",description:g.description.trim()||void 0,projectId:E?Pe:null,r2Key:oe.r2Key,media:oe.media});if(ut)throw ut;we=ct}await F.mutateAsync({submissionId:N.id,updates:{title:g.title.trim(),description:g.description.trim()||void 0,...we&&{video_id:we,video_r2_key:oe.cloudflareUid?null:oe.r2Key??null}}}),we&&!oe.cloudflareUid&&oe.r2Key&&oe.posterR2Key&&await La(N.id,oe.posterR2Key);const Je=[];for(let ct=0;ct<Ke.length;ct++){const ut=Ke[ct];let ft;if(ct===0&&we)ft=we;else if(ct===0){if(!N.video_id)throw new Error("Existing submission has no primary video to reuse");ft=N.video_id}else if(ut.videoId)ft=ut.videoId;else{const{videoId:Ts,error:sr}=await Us({creatorId:V.id,title:`${g.title.trim()} - Video ${ct+1}`,description:g.description.trim()||void 0,projectId:E?Pe:null,r2Key:ut.r2Key,media:ut.media});if(sr)throw sr;ft=Ts}Je.push({submission_id:N.id,video_id:ft,display_order:ct,is_primary:ct===0})}const{error:rt}=await be.from("submission_videos").delete().eq("submission_id",N.id);if(rt)throw rt;const{error:ot}=await be.from("submission_videos").insert(Je);if(ot)throw ot}else if(tt){const oe=!!Z&&Z.imageId!==(N.image_id??null);await F.mutateAsync({submissionId:N.id,updates:{title:g.title.trim(),description:g.description.trim()||void 0,...oe&&Z&&{image_id:Z.imageId,image_r2_key:Z.r2Key,media_type:"image"}}})}else{const oe=N.video_r2_key??N.video?.r2_key??"",Qe=(g.cloudflareVideoId||"")!==(Me||"")||!!g.pickedVideoId&&g.pickedVideoId!==(N.video_id??"")||(g.uploadR2Key||"")!==oe;let it,we;if(Qe)if(we=!g.cloudflareVideoId&&g.uploadR2Key?g.uploadR2Key:null,g.pickedVideoId)it=g.pickedVideoId;else{const{videoId:Je,error:rt}=await Us({creatorId:V.id,title:g.title.trim(),description:g.description.trim()||void 0,projectId:E?Pe:null,r2Key:g.uploadR2Key||void 0,media:g.videoMedia});if(rt)throw rt;it=Je}await F.mutateAsync({submissionId:N.id,updates:{title:g.title.trim(),description:g.description.trim()||void 0,...it&&{video_id:it},...we!==void 0&&{video_r2_key:we}}}),Qe&&we&&g.uploadPosterR2Key&&await La(N.id,g.uploadPosterR2Key)}await os(N.id),Gt([g.uploadR2Key,...Ke.map(oe=>oe.r2Key)]),s(),i();return}if(Ye){const ne=Ke[0],Me=ne.title.trim()||g.title.trim()||"Video 1";let oe;if(ne.videoId)oe=ne.videoId;else{const{videoId:rt,error:ot}=await Us({creatorId:V.id,title:Me,description:g.description.trim()||void 0,projectId:E?Pe:null,r2Key:ne.r2Key,media:ne.media});if(ot)throw ot;oe=rt}const{data:Qe,error:it}=await be.from("submissions").insert({challenge_id:r,creator_id:V.id,title:Me,description:g.description.trim()||null,video_id:oe,...!ne.cloudflareUid&&ne.r2Key?{video_r2_key:ne.r2Key}:{},...!ne.cloudflareUid&&ne.r2Key&&ne.posterR2Key?{thumbnail_url:Aa(ne.posterR2Key)}:{},contest_challenge_id:g.selectedChallengeId||null,social_post_url:g.socialPostUrl.trim()||null,selected_brand_id:Re||null,selected_product_id:Ce||null,tools_used:pt.length>0?pt:null,production_time:St||null,usd_spent:Ct||null,admin_hidden:Ne,...ce&&{manual_include:!0},...Pe&&{project_id:Pe}}).select("id").single();if(it)throw it;const we=[];for(let rt=0;rt<Ke.length;rt++){const ot=Ke[rt],ct=ot.title.trim()||`Video ${rt+1}`;let ut;if(rt===0)ut=oe;else if(ot.videoId)ut=ot.videoId;else{const{videoId:ft,error:Ts}=await Us({creatorId:V.id,title:ct,description:g.description.trim()||void 0,projectId:E?Pe:null,r2Key:ot.r2Key,media:ot.media});if(Ts)throw Ts;ut=ft}
6we.push({submission_id:Qe.id,video_id:ut,display_order:rt,is_primary:rt===0})}const{error:Je}=await be.from("submission_videos").insert(we);if(Je)throw Je;await os(Qe.id),ee("Bundle submitted!",{description:`${Ke.length} videos submitted.`})}else if(tt){const ne=Z,Me=Or({r2_key:ne.r2Key,cf_image_id:ne.cfImageId,pointer_url:ne.pointerUrl},"card"),{data:oe,error:Qe}=await be.from("submissions").insert({challenge_id:r,creator_id:V.id,title:g.title.trim(),description:g.description.trim()||null,media_type:"image",image_id:ne.imageId,image_r2_key:ne.r2Key,thumbnail_url:Me,contest_challenge_id:g.selectedChallengeId||null,social_post_url:g.socialPostUrl.trim()||null,selected_brand_id:Re||null,selected_product_id:Ce||null,tools_used:pt.length>0?pt:null,production_time:St||null,usd_spent:Ct||null,admin_hidden:Ne,...ce&&{manual_include:!0},...Pe&&{project_id:Pe}}).select("id").single();if(Qe)throw Qe;oe?.id&&await os(oe.id),ee("Submission Successful!",{description:B?"Your image has been submitted to the campaign. We will let you know once it is approved.":"Your image has been submitted to the contest. Good luck!"})}else{let ne;if(g.pickedVideoId)ne=g.pickedVideoId;else{const{videoId:Qe,error:it}=await Us({creatorId:V.id,title:g.title.trim(),description:g.description.trim()||void 0,projectId:E?Pe:null,r2Key:g.uploadR2Key||void 0,media:g.videoMedia});if(it)throw it;ne=Qe}const{data:Me,error:oe}=await be.from("submissions").insert({challenge_id:r,creator_id:V.id,title:g.title.trim(),description:g.description.trim()||null,video_id:ne,...!g.cloudflareVideoId&&g.uploadR2Key?{video_r2_key:g.uploadR2Key}:{},...!g.cloudflareVideoId&&g.uploadR2Key&&g.uploadPosterR2Key?{thumbnail_url:Aa(g.uploadPosterR2Key)}:{},contest_challenge_id:g.selectedChallengeId||null,social_post_url:g.socialPostUrl.trim()||null,selected_brand_id:Re||null,selected_product_id:Ce||null,tools_used:pt.length>0?pt:null,production_time:St||null,usd_spent:Ct||null,admin_hidden:Ne,...ce&&{manual_include:!0},...Pe&&{project_id:Pe}}).select("id").single();if(oe)throw oe;Me?.id&&await os(Me.id),ee("Submission Successful!",{description:B?"Your video has been submitted to the campaign. We will let you know once it is approved.":"Your video has been submitted to the contest. Good luck!"})}if(g.selectedChallengeId){const ne=g.selectedChallengeId;lt(Me=>{const oe=new Map(Me);return oe.set(ne,(oe.get(ne)??0)+1),oe})}if(rs&&q?.id){const ne=new Date().toISOString(),Me=q.id;try{await be.from("creator_projects").update({archived_at:ne,updated_at:ne}).eq("id",Me).eq("user_id",V.id).is("archived_at",null),await Promise.all([be.from("images").update({archived_at:ne,archived_by:"project"}).eq("user_id",V.id).eq("project_id",Me).is("archived_at",null),be.from("videos").update({archived_at:ne,archived_by:"project"}).eq("creator_id",V.id).eq("project_id",Me).is("archived_at",null),be.from("audio_files").update({archived_at:ne,archived_by:"project"}).eq("user_id",V.id).eq("project_id",Me).is("archived_at",null)])}catch(oe){console.warn("Failed to auto-archive project after submission",oe)}}Gt([g.uploadR2Key,...Ke.map(ne=>ne.r2Key)]),s(),i()}catch(k){console.error("Submission error:",k);const V=k;V.message?.includes("row-level security")||V.code==="42501"?ee.error("Submission Not Allowed",{description:`This ${S} may have ended or isn't accepting submissions.`}):V.message?.includes("duplicate")||V.code==="23505"?ee.error("Already Submitted"):ee.error("Submission Failed",{description:"Something went wrong on our side. Your entry was not submitted, so please try again."})}finally{ze(!1)}},[K,Be,Re,$e,Ce,Ye,Ke,dt,g,tt,Z,y,N,b,gt,E,O,q,r,pt,St,Ct,s,i,F,rs,Gt,os,B,S,R]),er=Ke.filter(o=>o.cloudflareUid||o.r2Key||o.videoId).length,kt=dt>0?er/dt*100:0,Cs=!!ue.deadline&&new Date(ue.deadline).getTime()<Date.now(),st=!y&&D&&W>0&&Cs,Sr=E&&(xe==="no-project"||xe==="below-min"),ls=Ut?"a video or an image":"a video",Ht=n.useMemo(()=>{if(!$||E&&!me)return null;if(B)return O?{tone:"violet",text:q?`Linked to project "${q.name}". Pick ${ls} from the project to submit.`:`This ${S} requires Anthum Studio. Create your entry in the Studio first.`}:E&&!q?{tone:"violet",text:`Anthum Studio is recommended for this ${S}. Create your entry in the Studio, or upload one.`}:E&&q?{tone:"emerald",text:`Linked to project "${q.name}". Select ${ls} from the project or upload a submission.`}:null;if(st&&Sr){const o=id({nonAnthumPenaltyPct:ke,latePenaltyPct:W,isNonAnthum:!0,isLate:!0}),k=Math.max(0,100-o),V=xe==="no-project"?"without a qualifying Anthum Studio project":(()=>{const ae=[];j>0&&ae.push(`${j} image`),_>0&&ae.push(`${_} video`);const Ne=ae.join(" + ");return`with project "${q?.name??""}" below the required ${Ne} Anthum generations`})();return{tone:"amber",text:Zl({bonusPct:ke,nonAnthumReason:V,receivePct:k,lateAdjustmentPct:W})}}if(st){const o=Math.max(0,100-W);return{tone:"amber",text:`You are submitting after the ${S} deadline. If you win, you'll receive ${o}% of the payout (${W}% late-submission penalty).`}}return O?{tone:"violet",text:q?`Linked to project "${q.name}". Pick ${ls} from the project to submit. External editing disabled for this ${S}.`:`This ${S} requires Anthum Studio. Create your entry in the Studio first.`}:E?xe==="no-project"?{tone:"amber",text:Xl(ke)}:xe==="below-min"?{tone:"amber",text:Jl(ke)}:q?{tone:"emerald",text:`${Da(ke,q.name)} Select ${ls} from the project or upload a submission.`}:{tone:"violet",text:`This ${S} requires Anthum Studio. Create your entry in the Studio first.`}:null},[$,st,Sr,W,O,E,q,me,xe,ke,j,_,S,ls,B]),[fn,tr]=n.useState(!1),Is=n.useMemo(()=>y||re?!1:Ze||g.cloudflareVideoId||g.uploadR2Key||g.pickedVideoId||Z||Ke.some(o=>o.cloudflareUid||o.r2Key||o.videoId)||g.title.trim()||g.description.trim()?!0:pt.length>0||!!St||!!Ct,[y,re,Ze,g,Z,Ke,pt,St,Ct]);n.useEffect(()=>{if(!t||!Is&&!Ze)return;const o=k=>{k.preventDefault(),k.returnValue=""};return window.addEventListener("beforeunload",o),()=>window.removeEventListener("beforeunload",o)},[t,Is,Ze]);const ds=n.useCallback(()=>{const o=[...Nt.current];Nt.current.clear(),o.length>0&&Ya(o)},[]);n.useEffect(()=>ds,[ds]);const Ps=n.useCallback(()=>
6{if(Is){tr(!0);return}ds(),s()},[Is,s,ds]),Cr=e.jsxs("div",{className:hs("violet"),children:[e.jsx(Yr,{className:Qt("violet")}),e.jsxs("p",{className:fs,children:[y?"Saving re-confirms the six commitments every Anthum entry makes":"One more step after this: you'll confirm the six commitments every Anthum entry makes"," ","(originality, winner assignment, 30-day holdback, AI training license, confidentiality, and brand compliance). The"," ",e.jsx(Mt,{to:"/terms",target:"_blank",rel:"noopener noreferrer",className:"font-medium underline underline-offset-2 hover:no-underline",onClick:o=>o.stopPropagation(),children:"Terms of Service"})," ","Section 7A has the full rights structure."]})]});return e.jsxs(e.Fragment,{children:[e.jsx(Vn,{open:t&&!et,onOpenChange:()=>{},children:e.jsxs(Wn,{hideCloseButton:!0,className:h(Mi,"w-full max-h-[92dvh]",Il(Bn(bt),Ye)),onOpenAutoFocus:o=>o.preventDefault(),onPointerDownOutside:o=>o.preventDefault(),onInteractOutside:o=>o.preventDefault(),onFocusOutside:o=>o.preventDefault(),onEscapeKeyDown:o=>{o.preventDefault(),Ps()},children:[e.jsxs("div",{className:"flex-shrink-0 border-b studio-border-soft px-5 sm:px-7 pt-4 pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs(Gn,{className:"min-w-0 truncate text-base font-semibold tracking-tight text-foreground sm:text-lg",children:[y?"Edit entry · ":"",a]}),e.jsx("button",{type:"button",onClick:Ps,className:h(Fr(),"h-8 w-8 shrink-0"),"aria-label":"Close",children:e.jsx(qs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[!y&&e.jsx("ol",{"aria-label":"Submission steps",className:"flex items-center gap-2",children:[1,2].map((o,k)=>{const V=Ie===o,ae=Ie>o,Ne=o>Ie,ce={1:Xs?"Add your entry":tt?"Pick an image":Ye?"Pick videos":"Pick a video",2:"Your process"};return e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{o<Ie&&!Ne&&as(o)},disabled:Ne,className:h("flex shrink-0 items-center gap-2 rounded-full border py-1 pl-1 pr-1 sm:pr-3 text-xs font-medium transition-[background-color,border-color,color]",V?"border-violet-500/45 bg-violet-500/[0.14] text-foreground dark:border-violet-400/45 dark:bg-violet-400/[0.14] dark:text-white":ae?"border-transparent text-foreground/80 hover:bg-foreground
6/[0.06] dark:text-white/80 dark:hover:bg-white/[0.06]":"cursor-default border-transparent text-muted-foreground/60"),"aria-current":V?"step":void 0,children:[e.jsx("span",{className:h("flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-semibold tabular-nums",V?"bg-violet-500 text-white dark:bg-violet-400 dark:text-violet-950":ae?"bg-violet-500/25 text-violet-700 dark:bg-violet-400/25 dark:text-violet-200":"bg-foreground/10 text-muted-foreground dark:bg-white/10"),children:ae?e.jsx(ld,{className:"h-3 w-3"}):o}),e.jsx("span",{className:"hidden sm:inline",children:ce[o]})]}),k<1&&e.jsx("span",{"aria-hidden":!0,className:h("h-px w-5 shrink-0 transition-colors sm:w-8",Ie>o?"bg-violet-500/45 dark:bg-violet-400/45":"bg-foreground/12 dark:bg-white/12")})]},o)})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:ur,children:Xs?e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"h-3 w-3"}),"Video or image"]}):tt?e.jsxs(e.Fragment,{children:[e.jsx(gr,{className:"h-3 w-3"}),"Image"]}):e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"h-3 w-3"}),Ye?`${dt} videos`:"Video"]})}
6),!tt&&e.jsxs("span",{className:ur,children:[e.jsx(qn,{className:"h-3 w-3"}),Ye?`${Gr(mt)} each`:Gr(mt)]}),bt.length>0&&e.jsx("span",{className:ur,children:bt.join(" or ")}),Ye&&e.jsxs("span",{className:h(ur,"tabular-nums"),children:[er,"/",dt," ready",e.jsx("span",{className:"ml-1 h-1 w-10 overflow-hidden rounded-full bg-foreground/15 dark:bg-white/15",children:e.jsx("span",{className:"block h-full rounded-full bg-violet-500 transition-[width] duration-500 ease-out dark:bg-violet-400",style:{width:`${kt}%`}})})]})]})]})]}),e.jsxs("form",{onSubmit:o=>{o.preventDefault(),Ie===ks&&(Ys.current=null,$t(!0))},className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-thin",children:e.jsxs("div",{ref:yr,className:"px-5 sm:px-7 py-5",children:[e.jsxs("div",{className:h("space-y-4",Ie!==1&&"hidden"),children:[y&&!B&&E&&he===!1&&e.jsxs("div",{className:hs("rose"),children:[e.jsx(xs,{className:Qt("rose")}),e.jsx("p",{className:fs,children:ed(ke,q?.name)})]}),y&&!B&&E&&he===!0&&e.jsxs("div",{className:hs("emerald"),children:[e.jsx(Jt,{className:Qt("emerald")}),e.jsx("p",{className:fs,children:Da(ke,q?.name)})]}),Ht&&e.jsxs("div",{className:hs(Ht.tone),children:[Ht.tone==="amber"&&e.jsx(xs,{className:Qt("amber")}),Ht.tone==="emerald"&&e.jsx(Jt,{className:Qt("emerald")}),Ht.tone==="violet"&&e.jsx(Yr,{className:Qt("violet")}),e.jsx("p",{className:fs,children:Ht.text})]}),Be&&e.jsxs("section",{className:Bt,children:[e.jsxs("h3",{className:gs,children:[e.jsx(js,{className:"h-3.5 w-3.5"}),"Brand"]}),x.length===0?e.jsxs("div",{className:h(hs("amber"),"mt-3"),children:[e.jsx(xs,{className:Qt("amber")}),e.jsx("p",{className:fs,children:"Reserve a brand first. Close this window and pick one from the Brand Selection section on the contest page."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:h(Zt,"mt-1.5"),children:"Which of your reserved brands is this entry for?"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.map(o=>{const k=G===o.id;return e.jsxs("button",{type:"button",onClick:()=>_e(o.id),"aria-pressed":k,className:Ra(k),children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-foreground
6/10 bg-foreground/[0.06] dark:border-white/10 dark:bg-white/[0.06]",children:o.brand_logo_url?e.jsx("img",{src:o.brand_logo_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(js,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:o.brand_name}),k&&e.jsx(Jt,{className:"h-4 w-4 shrink-0 text-violet-500 dark:text-violet-300"})]},o.id)})})]})]}),$e&&e.jsxs("section",{className:Bt,children:[e.jsxs("h3",{className:gs,children:[e.jsx(ss,{className:"h-3.5 w-3.5"}),"Product"]}),v.length===0?e.jsxs("div",{className:h(hs("amber"),"mt-3"),children:[e.jsx(xs,{className:Qt("amber")}),e.jsx("p",{className:fs,children:"Reserve a product first. Close this window and pick one from the Product Selection section on the contest page."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:h(Zt,"mt-1.5"),children:"Which of your reserved products is this entry for?"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:v.map(o=>{const k=L===o.id;return e.jsxs("button",{type:"button",onClick:()=>Se(o.id),"aria-pressed":k,className:Ra(k),children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-foreground
6/10 bg-foreground/[0.06] dark:border-white/10 dark:bg-white/[0.06]",children:o.product_image_url?e.jsx("img",{src:o.product_image_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(ss,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:o.product_name}),k&&e.jsx(Jt,{className:"h-4 w-4 shrink-0 text-violet-500 dark:text-violet-300"})]},o.id)})})]})]}),b&&b.length>1&&e.jsx("section",{className:Bt,children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Lt,{className:h(gs,"font-semibold"),children:[e.jsx(dd,{className:"h-3.5 w-3.5"}),"Track"]}),e.jsx("div",{onKeyDown:o=>o.key==="Enter"&&o.preventDefault(),children:e.jsxs(dl,{value:g.selectedChallengeId,onValueChange:o=>J(k=>({...k,selectedChallengeId:o})),children:[e.jsx(cl,{className:h(cr,"max-w-sm"),children:e.jsx(ul,{placeholder:"Choose a track"})}),e.jsx(ml,{className:"studio-glass-panel border studio-border-soft rounded-xl",children:b.map(o=>{const k=Oe.get(o.id)??0,V=k>0,ce=!(He==null||He===0)&&k>=(He??0)&&!y;return e.jsx(pl,{value:o.id,disabled:ce,className:"rounded-lg text-foreground focus:bg-violet-500/[0.12] data-[disabled]:opacity-50",children:e.jsxs("span",{className:"flex items-center gap-2",children:[o.title,V&&e.jsx(es,{className:"h-3.5 w-3.5 text-emerald-500"})]})},o.id)})})]})})]})}),e.jsxs("div",{className:"flex flex-col gap-5 md:flex-row md:items-stretch",children:[e.jsxs("div",{className:h("mx-auto w-full max-w-[420px] space-y-3 md:mx-0 md:max-w-none md:shrink-0",Pl(Bn(bt))),children:[tt&&!Ut?e.jsx(Tl,{mode:fe,projectId:q?.id??null,acceptedAspects:bt,value:Z,onChange:w,onFileSelected:kr,onUploadingChange:ns,adPreview:Ue}):Ye?e.jsx(Ha,{variant:"bundle",mode:fe,projectId:q?.id??null,durationLimits:mt,acceptedAspects:bt,value:Ke,requiredVideos:dt,onChange:hn,onSlotFileSelected:is,onSlotUploaded:Js,onUploadingChange:ns,onUploadKeyAssigned:Wt}):e.jsx(Ha,{variant:"single",mode:fe,projectId:q?.id??null,durationLimits:mt,acceptedAspects:bt,acceptImages:Ut,imageValue:Ut?Z:null,onImageChange:Ut?Nr:void 0,value:g.cloudflareVideoId||g.uploadR2Key||g.pickedVideoId?{cloudflareUid:g.cloudflareVideoId,videoId:g.pickedVideoId||void 0,r2Key:g.uploadR2Key||void 0,localPreviewUrl:pe??void 0}:null,onChange:_r,onFileSelected:kr,onUploadingChange:ns,onUploadKeyAssigned:Wt,adPreview:Ue}),Ye&&!ht&&e.jsxs("section",{className:h(Bt,"flex flex-wrap items-center justify-between gap-3 py-3"),children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[e.jsx(zn,{className:"h-4 w-4 text-muted-foreground"}),"Bundle of ",It," videos"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button","aria-label":"One video fewer",disabled:It<=2,onClick:()=>{const o=It-1;Ns(o),Te(k=>k.slice(0,o))},className:h(Fr(),"disabled:cursor-not-allowed disabled:opacity-35"),children:e.jsx(cd,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"w-5 text-center text-sm font-semibold tabular-nums text-foreground",children:It}),e.jsx("button",{type:"button","aria-label":"One video more",disabled:It>=6,onClick:()=>{const o=It+1;Ns(o),Te(k=>[...k,{cloudflareUid:"",title:""}])},className:h(Fr(),"disabled:cursor-not-allowed disabled:opacity-35"),children:e.jsx(ud,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{const o=Ke[0];o?.cloudflareUid&&(J(k=>({...k,cloudflareVideoId:o.cloudflareUid,pickedVideoId:o.videoId??"",videoMedia:o.media??null,title:o.title||k.title})),Fe(o.localPreviewUrl??null)),jt(!1),Te([])},className:h(Wr,"ml-1"),children:"Undo bundle"})]})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-3",children:[!Ye&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Lt,{htmlFor:"title",className:lr,children:"Title"}),e.jsx(Kt,{id:"title",value:g.title,onChange:o=>J(k=>({...k,title:o.target.value})),placeholder:tt?"e.g. Summer launch key visual":"e.g. My 30s spot",className:cr,required:!0})]}),e.jsxs("div",{className:"flex flex-1 flex-col space-y-1.5",children:[e.jsxs(Lt,{htmlFor:"description",className:lr,children:["Description ",e.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}
6),e.jsx(Hn,{id:"description",value:g.description,onChange:o=>J(k=>({...k,description:o.target.value})),placeholder:B?"What were you going for?":"What were you going for? Judges read this.",className:h(Ll,"min-h-[96px] md:flex-1"),rows:3})]})]})]}),y&&Cr]}),e.jsxs("div",{className:h("mx-auto max-w-3xl space-y-4",Ie!==2&&"hidden"),children:[gt&&!y&&e.jsxs("section",{className:h(Bt,"space-y-3"),children:[e.jsxs("h3",{className:gs,children:[e.jsx(wi,{className:"h-3.5 w-3.5"}),"Your published post",e.jsx("span",{className:"ml-auto rounded-full border border-amber-500/30 bg-amber-500/[0.12] px-2 py-0.5 text-[10px] font-medium normal-case tracking-normal text-amber-700 dark:text-amber-300",children:"Required"})]}),e.jsx(Kt,{id:"socialPostUrl",type:"text",inputMode:"url",value:g.socialPostUrl,onChange:o=>J(k=>({...k,socialPostUrl:o.target.value})),placeholder:"https://â¦","aria-label":"Social post URL","aria-invalid":!!g.socialPostUrl.trim()&&!Es(g.socialPostUrl),className:h(cr,g.socialPostUrl.trim()&&!Es(g.socialPostUrl)&&"border-amber-500/50 focus-visible:border-amber-500/60 focus-visible:ring-amber-500/30")}),e.jsx("p",{className:h(Zt,g.socialPostUrl.trim()&&!Es(g.socialPostUrl)&&"text-amber-700 dark:text-amber-300"),children:g.socialPostUrl.trim()&&!Es(g.socialPostUrl)?"That link is not recognised. Paste the full post link, starting with https://":"Paste the link to your post on Instagram, TikTok, YouTube, X, Facebook, LinkedIn, or Threads."})]}),!y&&e.jsxs("section",{className:h(Bt,"space-y-5"),children:[e.jsxs("div",{children:[e.jsx("h3",{className:gs,children:"About your process"}),e.jsx("p",{className:h(Zt,"mt-1.5"),children:"All optional, and none of it is shown to other creators."})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(Lt,{className:h(lr,"flex items-center gap-2"),children:[e.jsx(md,{className:"h-4 w-4 text-muted-foreground"}),"Roughly what did it cost you to make?"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:el.map(o=>e.jsx("button",{type:"button","aria-pressed":Ct===o,onClick:()=>_s(k=>k===o?"":o),className:h(Er(Ct===o),"tabular-nums"),children:o},o))}),e.jsx("p",{className:Zt,children:"Your best guess in US dollars, across every tool you used and counting everything you generated along the way, not just the final cut."})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(Lt,{className:h(lr,"flex items-center gap-2"),children:[e.jsx(pd,{className:"h-4 w-4 text-muted-foreground"}),"What did you make it with?"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Pa.map(o=>{const k=pt.includes(o.label);return e.jsxs("button",{type:"button","aria-pressed":k,onClick:()=>{Ot(V=>k?V.filter(ae=>ae!==o.label):[...V,o.label])},className:Er(k),children:[e.jsx("svg",{viewBox:"0 0 24 24",className:"h-3.5 w-3.5 shrink-0 fill-current",children:e.jsx("path",{d:o.svgPath})}),o.label]},o.label)}),pt.filter(o=>!Pa.some(k=>k.label===o)).map(o=>e.jsxs("span",{className:Er(!0),children:[o,e.jsx("button",{type:"button",onClick:()=>Ot(k=>k.filter(V=>V!==o)),"aria-label":`Remove ${o}`,className:"-mr-1 rounded-full p-0.5 text-foreground/60 transition-colors hover:text-foreground dark:text-white/60 dark:hover:text-white",children:e.jsx(qs,{className:"h-3 w-3"})})]},o))]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Kt,{value:Qs,onChange:o=>Vt(o.target.value),onKeyDown:o=>{if(o.key==="Enter"){o.preventDefault();const k=Qs.trim();k&&!pt.includes(k)&&(Ot(V=>[...V,k]),Vt(""))}},placeholder:"Something elseâ¦","aria-label":"Add another tool",className:h(cr,"h-9 flex-1")}),e.jsx(Ee,{type:"button",variant:"ghost",size:"sm",className:h(mr,"h-9 px-4"),onClick:()=>{const o=Qs.trim();o&&!pt.includes(o)&&(Ot(k=>[...k,o]),Vt(""))},children:"Add"})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(Lt,{className:h(lr,"flex items-center gap-2"),children:[e.jsx(qn,{
6className:"h-4 w-4 text-muted-foreground"}),"How long did it take?"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:tl.map(o=>e.jsx("button",{type:"button","aria-pressed":St===o,onClick:()=>Zs(k=>k===o?"":o),className:Er(St===o),children:o},o))})]})]}),!y&&q&&e.jsxs("label",{htmlFor:"modal-archive-project",className:h(Bt,"flex cursor-pointer items-start gap-3 py-3.5"),children:[e.jsx(Ti,{id:"modal-archive-project",checked:rs,onCheckedChange:o=>pn(o),className:"mt-0.5 shrink-0 border-foreground/25 data-[state=checked]:border-violet-500 data-[state=checked]:bg-violet-500 data-[state=checked]:text-white dark:border-white/25","aria-describedby":"archive-project-desc"}),e.jsxs("span",{className:"text-sm leading-relaxed text-foreground",children:["Archive â",q.name,"â after submitting",e.jsx("span",{id:"archive-project-desc",className:h(Zt,"mt-0.5 block"),children:"You can restore it anytime from the Archived tab on the Projects page."})]})]}),Cr]})]})}),e.jsx("div",{className:"flex-shrink-0 border-t studio-border-soft px-5 sm:px-7 py-4",children:(()=>{const o=(!Be||!!Re)&&(!$e||!!Ce)&&(tt?!!Z&&g.title.trim().length>0:Ye?Ke.length===dt&&Ke.every(we=>we.cloudflareUid||we.r2Key||we.videoId)&&Ke.every(we=>we.title.trim().length>0):(!!g.cloudflareVideoId||!!g.uploadR2Key)&&g.title.trim().length>0),k=!gt||y||Es(g.socialPostUrl),V=Ie===ks,ae=()=>{Ie===1&&o&&as(2)},Ne=()=>{Ie===2&&as(1)},ce=V?re?y?"Savingâ¦":"Submittingâ¦":y?"Save changes":Ye?`Submit ${dt} videos`:"Submit entry":"Next",Pe=re||(Ie===1?!o:!k),ne=(()=>{if(!Pe||re)return null;if(Ie===1){if(Be&&!Re)return"Pick the brand this entry is for.";if($e&&!Ce)return"Pick the product this entry is for.";if(Xs)return fe==="pick-only"?"Choose one of your project videos or images to continue.":"Add a video or an image to continue.";if(tt)return Z?"Add a title to continue.":"Choose an image to continue.";if(Ye){const we=Ke.filter(Je=>Je.cloudflareUid||Je.r2Key||Je.videoId).length;if(we<dt){const Je=dt-we;return`Add ${Je} more ${Je===1?"video":"videos"} to continue.`}return"Give every video a title to continue."}return!g.cloudflareVideoId&&!g.uploadR2Key?fe==="pick-only"?"Choose one of your project videos to continue.":"Choose or upload a video to continue.":"Add a title to continue."}return Ie===2?"Add the link to your published post to continue.":null})(),Me=Ie===1?e.jsx(Ee,{type:"button",variant:"ghost",onClick:Ps,className:h(mr,"order-2 w-full sm:order-1 sm:w-auto"),children:"Cancel"}):e.jsx(Ee,{type:"button",variant:"ghost",onClick:Ne,className:h(mr,"order-2 w-full sm:order-1 sm:w-auto"),children:"Back"}),oe=Ie===1&&!B&&!tt&&!Ye&&!ht&&!y&&fe!=="pick-only"?e.jsxs("button",{type:"button",onClick:()=>{const we=g.cloudflareVideoId||g.uploadR2Key||g.pickedVideoId?{cloudflareUid:g.cloudflareVideoId,videoId:g.pickedVideoId||void 0,r2Key:g.uploadR2Key||void 0,title:g.title||"Video 1",localPreviewUrl:pe??void 0,media:g.videoMedia??void 0}:{cloudflareUid:"",title:""},Je=Array.from({length:It},(rt,ot)=>ot===0?we:{cloudflareUid:"",title:""});Te(Je),jt(!0)},className:Wr,children:[e.jsx(zn,{className:"h-3.5 w-3.5"}),"Make it a bundle"]}):null,Qe=Ie!==1?null:tt?Z&&!Hr(Z.width,Z.height,bt)?"image":null:(Ye?Ke.map(we=>we.media):[g.videoMedia]).some(we=>!!we&&!Hr(we.width,we.height,bt))?"video":null,it=Qe?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-amber-500/30 bg-amber-500/[0.12] px-2.5 py-1 text-xs font-medium text-amber-700 dark:text-amber-300",title:Dl(Qe,bt),children:[e.jsx(xs,{className:"h-3.5 w-3.5"}),"Not",e.jsx("span",{className:"rounded-full bg-amber-500/20 px-1.5 py-0.5 tabular-nums",children:bt.join(" or ")})]}):null;return e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"order-3 flex min-h-[1.75rem] flex-wrap items-center gap-x-3 gap-y-1 sm:order-1 sm:flex-1",children:[oe,e.jsx("p",{className:Zt,children:ne})]}),e.jsxs("div",{className:"order-1 flex flex-col-reverse gap-3 sm:order-2 sm:flex-row sm:items-center",children:[it,Me,e.jsx(Ee,{type:V?"submit":"button",onClick:V?void 0:ae,disabled:Pe,className:h(Ri,"order-1 w-full sm:order-2 sm:w-auto"),children:ce})]})]})})()})]})]})}),e.jsx(bc,{open:et,contestName:a,prizePoolUsd:B?void 0:ue.prizeAmount??void 0,numWinners:B?void 0:ue.numWinners??void 0,closesAt:ue.deadline??void 0,isPerformanceCampaign:B,isEditing:y,submitting:re,onCancel:()=>{re||$t(!1)},onClose:()=>{re||($t(!1),Ps())},onConfirm:async o=>{Ys.current=o,await Xe({preventDefault:()=>{}}),$t(!1)}}),e.jsx(sn,{open:fn,onOpenChange:tr,children:e.jsxs(rn,{className:"studio-glass-panel border studio-border-soft rounded-2xl",children:[e.jsxs(nn,{children:[e.jsx(an,{children:Ze?"Stop the upload and discard?":"Discard this entry?"}),e.jsx(zs,{children:Ze?"Your upload is still running. Discarding stops it and removes what has been stored so far. Nothing has been submitted yet.":"Your entry and everything you have filled
6in will be lost, and any upload will have to be done again. Nothing has been submitted yet."})]}),e.jsxs(on,{children:[e.jsx(ln,{className:mr,children:Ze?"Keep uploading":"Keep editing"}),e.jsx(dn,{onClick:()=>{tr(!1),ds(),s()},className:"h-11 rounded-xl border border-rose-500/40 bg-rose-500/90 px-5 text-sm font-semibold text-white hover:bg-rose-500 sm:h-10",children:"Discard"})]})]})})]})};function Za(t){return t.replace(/^[\u2022\u2023\u25E6\u2043\u2219â¢\-*]\s+/,"").replace(/^\d+[.)]\s+/,"").trim()}function Xa(t){const s=/^[\u2022\u2023\u25E6\u2043\u2219â¢\-*]\s+/,r=/^\d+[.)]\s+/,a=t.split(` 7`).map(d=>d.trim()).filter(Boolean);if(a.filter(d=>s.test(d)||r.test(d)).length>=a.length*.5&&a.length>1||a.length>1)return a.map(Za).filter(Boolean);const c=t.split(/(?<=\.)\s+/).filter(d=>d.trim().length>10);return c.length>1?c.map(d=>d.trim()):[t.trim()]}const yc=.75,to=2,jc=`calc(${yc}rem - ${to}px)`,_c={backdropFilter:"blur(14px) saturate(155%)",WebkitBackdropFilter:"blur(14px) saturate(155%)",background:"linear-gradient(165deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.03) 38%, transparent 100%), linear-gradient(180deg, rgba(251,191,36,0.16) 0%, rgba(40,22,8,0.88) 42%, rgba(14,8,4,0.96) 100%)",boxShadow:"0 1px 0 rgba(255,255,255,0.13) inset, 0 -1px 0 rgba(0,0,0,0.32) inset, inset 0 0 0 1px rgba(255,255,255,0.05)"},Nc={background:"linear-gradient(180deg, rgba(40,22,8,0.55) 0%, rgba(14,8,4,0.85) 100%)",boxShadow:"inset 0 0 0 1px rgba(251,191,36,0.12)"},kc={background:"linear-gradient(135deg, rgba(154,123,66,0.55) 0%, rgba(253,230,138,0.35) 50%, rgba(154,123,66,0.5) 100%)"};function Bs({onClick:t,disabled:s=!1,label:r="Submit",className:a,fullWidth:i=!1,icon:c=Di,disabledReason:d}){const[f,x]=n.useState(!1);n.useEffect(()=>{x(!0)},[]);const p=e.jsxs("button",{type:"button",onClick:t,disabled:s,className:h("group relative isolate overflow-hidden rounded-xl border-none bg-transparent p-0 text-left outline-none","transition-[box-shadow,filter] duration-300","focus-visible:ring-2 focus-visible:ring-[#fde68a]/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background",i?"block w-full":"inline-block",s&&"cursor-not-allowed opacity-55",!s&&"hover:shadow-[0_0_20px_rgba(251,191,36,0.28)]",a),style:{padding:to,boxShadow:s?void 0:"0 0 16px rgba(251,191,36,0.2)",...s?kc:void 0},children:[f&&!s&&e.jsx(mn,{colorBack:"#9a7b42",colorTint:"#fff8e7",speed:.28,repetition:5,distortion:.18,className:"rounded-xl"}),e.jsxs("span",{className:h("relative z-10 flex w-full min-h-[42px] items-center justify-center gap-1.5 px-3 sm:min-h-[48px] sm:px-4","text-xs font-medium transition-[filter,color] duration-300",!s&&"group-hover:brightness-[1.06]"),style:{borderRadius:jc,...s?Nc:_c},children:[!s&&e.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-[#fde8bd]/35 to-transparent"}),e.jsx(c,{className:"relative z-[1] h-4 w-4 shrink-0 text-[#fde68a] transition-colors duration-300 group-hover:text-[#fef3c7] group-disabled:text-[#fde68a]/50","aria-hidden":!0}),e.jsx("span",{className:"relative z-[1] text-[#fde8bd] transition-colors duration-300 group-hover:text-[#fff7e6] group-disabled:text-[#fde8bd]/50",children:r})]})]});return s&&d?e.jsx("span",{title:d,className:h("cursor-not-allowed",i?"block w-full":"inline-block"),children:p}):p}function Sc({tracks:t,prizeAmount:s,prizeDistribution:r,userSubmittedTrackIds:a,userTrackSubmissionCounts:i,maxSubmissionsPerTrack:c=null,isActive:d,onSubmitToTrack:f,compact:x=!1,submissions:p=[],winnerIds:m=[],top30Ids:v=new Set,showTop30Badges:A=!1,currentUserId:y,onSubmissionClick:N,onDeleteSubmission:P,hideSubmitButtons:R=!1,contestRequirements:B,sidebarCompact:S=!1,aspectRatio:K}){const b=n.useMemo(()=>B?.trim()?Xa(B):[],[B]),F=b.length>1,E=b.length>0,[Q,O]=n.useState(new Set),H=$=>{O(M=>{const D=new Set(M);return D.has($)?D.delete($):D.add($),D})},te=p.some($=>$.contest_challenge_id),z=$=>{if(!te)return p;const M=Array.isArray($)?$:[$];return p.filter(D=>D.contest_challenge_id!=null&&M.includes(D.contest_challenge_id))},ie=r?.grand_winner_bonus??0,se=r?.categories??[],Z=se.length>(t?.length??0),w=n.useMemo(()=>
7{if(!t?.length||Z)return[];const $=new Set,M=new Map;for(const Y of t){const W=Ds(Y.title)||Y.title||"Track";M.has(W)||M.set(W,[]),M.get(W).push(Y)}const D=[];for(const Y of t){const W=Ds(Y.title)||Y.title||"Track";if($.has(W))continue;$.add(W);const u=M.get(W)??[Y],ue=u[0];D.push({id:ue.id,title:W,trackIds:u.map(ve=>ve.id),track:ue})}return D},[t,Z]);if(!t||t.length===0)return null;const j=Z?se.length:w.length||t.length,T=$=>r?.categories?.[$]?.prize_tiers||[],_=$=>T($).reduce((D,Y)=>{const W=Y.rank_end-Y.rank_start+1;return D+Y.prize*W},0),U=$=>T($).reduce((D,Y)=>{const W=Y.rank_end-Y.rank_start+1;return D+(Y.credit??0)*W},0);return e.jsxs("div",{className:`min-w-0 ${x?"py-0":"pt-4"}`,children:[ie>0&&!S&&e.jsxs("div",{className:"mb-2 flex items-start gap-3",children:[e.jsx(wt,{className:"h-4 w-4 text-amber-400/80 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-amber-400/90 text-sm",children:["1 Grand Winner ($",ie.toLocaleString(),") selected from all winning submissions"]}),e.jsx("p",{className:"text-foreground text-xs mt-0.5",children:"Remaining winners receive prizes based on track placement"})]})]}),e.jsx("div",{className:"space-y-0",children:Array.from({length:j},($,M)=>{const Y=!Z&&w.length>0?w[M]:null,W=Z?t[0]?.id??"":Y?.id??t[M]?.id??"",u=Y?.trackIds??[W],ue=Y?.track??t[Math.min(M,t.length-1)],ve=se[M],q=u.some(he=>a.has(he)),me=c==null||c===0,X=i?u.reduce((he,je)=>he+(i.get(je)??0),0):q?1:0,fe=!me&&X>=(c??0),qe=z(u),Ve=Q.has(W),I=Z?ve?.name??`Track ${M+1}`:Y?.title??ue?.title??ve?.name,De=Z?ve?.description:ue?.description??ve?.description,Le=Z?ve?.requirements:ue?.requirements??ve?.requirements,Ae=Z&&ve?hl(ve):_(M),ke=Z&&ve?ve.prize_tiers?.reduce((he,je)=>he+(je.credit??0)*(je.rank_end-je.rank_start+1),0)??0:U(M);return e.jsxs("div",{className:`min-w-0 py-3 transition-opacity ${M>0?"border-t border-border":""} ${fe?"opacity-70":""}`,children:[e.jsxs("div",{className:`min-w-0 ${x?"space-y-1.5":"space-y-3"}`,children:[S&&e.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate text-sm font-medium text-foreground",title:I??void 0,children:I}),(Ae>0||ke>0)&&e.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-amber-400/90",children:[Ae>0?`$${Ae.toLocaleString()}`:"",Ae>0&&ke>0?" + ":"",ke>0?`${ke.toLocaleString()} credits`:""]})]}),!S&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 min-w-0",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("h4",{className:"text-base font-semibold text-foreground break-words",children:I})}),q&&e.jsxs("span",{className:"text-[11px] text-emerald-400/90 flex items-center gap-1 shrink-0",children:[e.jsx(es,{className:"h-3 w-3"}),"Submitted"]})]}),De&&e.jsx("p",{className:`text-muted-foreground break-words ${x?"text-xs":"text-sm"} leading-relaxed`,children:De})]}),!S&&(()=>{const he=Le?.trim()?Xa(Le):[],je=he.length>0,xe=je||d&&E;return!je&&!d?null:e.jsx("div",{className:"min-w-0 border-t border-border pt-3",children:e.jsxs("div",{className:"flex min-w-0 flex-col gap-4",children:[xe&&e.jsxs("div",{className:"min-w-0 w-full space-y-4",children:[je&&e.jsxs("div",{className:"min-w-0 w-full",children:[e.jsxs("div",{className:"mb-2 flex w-full items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Requirements"}),e.jsxs("span",{className:"ml-auto text-[10px] tabular-nums text-muted-foreground",children:[he.length," ",qt(he.length,"item")]})]}),e.jsx("ul",{className:"w-full list-none space-y-2.5 p-0",children:he.map((Be,G)=>e.jsx("li",{className:"w-full border-l-2 border-border pl-3 text-sm leading-relaxed text-foreground/90 [overflow-wrap:anywhere]",children:Be},G))})]}),d&&E&&e.jsxs("div",{className:"min-w-0 w-full",children:[e.jsx("p",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:je?"Contest requirements":"Requirements"}),F?e.jsx("ul",{className:"w-full list-none space-y-2.5 p-0",children:b.map((Be,G)=>e.jsx("li",{className:"w-full border-l-2 border-border pl-3 text-sm leading-relaxed text-foreground
7/90 [overflow-wrap:anywhere]",children:Be},G))}):e.jsx("div",{className:"w-full border-l-2 border-border pl-3",children:e.jsx(jd,{text:b[0]??"",className:"text-sm leading-relaxed text-foreground/90"})})]})]}),d&&e.jsx("div",{className:"flex w-full flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center",children:fe?e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-emerald-400/80",children:[e.jsx(es,{className:"h-3.5 w-3.5"}),"Already submitted"]}):R?null:e.jsx(Bs,{onClick:()=>f(W),label:q?"Submit Another Video":"Submit"})})]})})})()]}),qe.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>H(W),"aria-expanded":Ve,className:"w-full mt-2 pt-2 border-t border-border text-left hover:opacity-90 transition-opacity overflow-hidden",children:[!Ve&&e.jsxs("div",{className:"relative h-12 overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-transparent via-transparent to-card/95 z-10"}),e.jsxs("div",{className:"flex gap-2 px-3 sm:px-5 pt-2",children:[qe.slice(0,6).map((he,je)=>{const xe=ws(he),Be=ys(xe)||void 0;return e.jsx("div",{className:"flex-shrink-0 w-12 h-12 sm:w-16 sm:h-16 rounded-md overflow-hidden bg-muted",style:{transform:`translateY(-${4+je*1}px)`,opacity:1-je*.1},children:e.jsx(br,{videoUrl:Si(xe)||void 0,imageUrl:xe.type==="image"?Be:void 0,thumbnailUrl:xe.type!=="image"?Be:void 0,alt:"",className:"w-full h-full",imgClassName:"w-full h-full object-cover",width:64,showFallback:!0})},he.id)}),qe.length>6&&e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-16 sm:h-16 rounded-md bg-muted/50 flex items-center justify-center text-foreground text-xs font-medium",children:["+",qe.length-6]})]})]}),e.jsxs("div",{className:"px-3 sm:px-5 py-3 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-foreground font-medium",children:[qe.length," submission",qe.length!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx("span",{className:"text-xs font-medium",children:Ve?"Hide":"View All"}),Ve?e.jsx(Fi,{className:"h-4 w-4"}):e.jsx(Gs,{className:"h-4 w-4"})]})]})]}),Ve&&e.jsx("div",{className:"px-3 sm:px-5 pb-5 pt-3 border-t border-border/50 bg-background/30",children:e.jsx("div",{className:Ii,children:qe.map(he=>{const je=m.includes(he.id)||he.winner_rank,xe=v.has(he.id),Be=he.creator_id===y,G=Be&&d&&!je&&P;return e.jsxs("div",{className:`relative group ${Pi}`,children:[e.jsx(Xi,{submission:he,onClick:()=>N?.(he),isTop30:A&&xe&&!je,aspectRatio:K}),G&&e.jsx(Ee,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 z-20 h-8 w-8 bg-red-500/80 hover:bg-red-500 text-white md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100 transition-opacity",onClick:_e=>{_e.stopPropagation(),P(he)},title:"Delete submission","aria-label":"Delete submission",children:e.jsx(yi,{className:"h-4 w-4"})}),Be&&!je&&e.jsx("div",{className:"absolute bottom-2 left-2 z-10",children:e.jsx("div",{className:"px-2 py-0.5 bg-muted/90 rounded text-[10px] font-medium text-foreground backdrop-blur-sm",children:"Your Entry"})})]},he.id)})})})]})]},Z?`cat-${M}`:ue?.id)})})]})}const Cc=t=>{if(t<=0)return["0s","1s","2s","3s","4s"];const r=[.1,.35,.65,.9].map(a=>{const i=Math.floor(t*a);return`${Math.max(1,Math.min(i,Math.floor(t-.5)))}s`});return["0s",...new Set(r)]},Ic=t=>{const s=t.trim().toLowerCase();if(!s)return null;if(/^\d+(\.\d+)?s?$/.test(s)){const r=Number.parseFloat(s.replace(/s$/,""));return Number.isFinite(r)?r:null}if(/^\d{1,2}:\d{1,2}(:\d{1,2})?$/.test(s)){const r=s.split(":").map(a=>Number.parseInt(a,10));if(r.some(a=>Number.isNaN(a)))return null;if(r.length===2){const[a,i]=r;return a*60+i}if(r.length===3){const[a,i,c]=r;return a*3600+i*60+c}}return null},Pc=t=>`${Math.max(0,Math.round(t))}s`,Ja=t=>{const s=Number.parseFloat(t.replace(/s$/,""));return Number.isFinite(s)?s:0};function Tc({open:t,onOpenChange:s,submission:r,requireSocialPost:a=!1,onSuccess:i}){const c=On(),[d,f]=n.useState(!1),[x,p]=n.useState(""),[m,v]=n.useState({title:"",description:"",socialPostUrl:"",thumbnailTime:null}),[A,y]=n.useState(null);n.useEffect(()=>{async function b(){if(!t||!r?.video_id){y(null);return}const{data:F,error:E}=await be.from("videos").select("id, cloudflare_video_id, duration, thumbnail_time").eq("id",r.video_id).single();!E&&F&&y(F)}b()},[t,r?.video_id]),n.useEffect(()=>{t&&r&&v({title:r.title||"",description:r.description||"",socialPostUrl:r.social_post_url||"",thumbnailTime:A?.thumbnail_time||null})},[t,r,A]);const N=b=>{if(!b.trim())return!a;const F=b.trim().toLowerCase();return["twitter.com","x.com","instagram.com","tiktok.com","youtube.com","youtu.be","facebook.com","fb.com","linkedin.com","threads.net"].some(Q=>F.includes(Q))},P=async()=>
7{if(r){if(!m.title.trim()){ee.error("Title required",{description:"Please enter a title for your submission."});return}if(a&&!m.socialPostUrl.trim()){ee.error("Social media post required",{description:"This contest requires you to post on social media. Please add your post URL."});return}if(m.socialPostUrl.trim()&&!N(m.socialPostUrl)){ee.error("Invalid social media URL",{description:"Please enter a valid URL from Twitter/X, Instagram, TikTok, YouTube, Facebook, LinkedIn, or Threads."});return}f(!0);try{const{data:b,error:F}=await be.from("submissions").update({title:m.title.trim(),description:m.description.trim()||null,social_post_url:m.socialPostUrl.trim()||null}).eq("id",r.id).select("id");if(F)throw F;if(!b||b.length===0)throw new Error("PERMISSION_DENIED");if(A&&m.thumbnailTime!==A.thumbnail_time){const{error:E}=await be.from("videos").update({thumbnail_time:m.thumbnailTime}).eq("id",A.id);E&&console.error("Error updating thumbnail:",E)}await c.invalidateQueries({queryKey:["submissions"]}),await c.invalidateQueries({queryKey:["my-submissions"]}),await c.invalidateQueries({queryKey:["contest-submissions"]}),await c.invalidateQueries({queryKey:["videos"]}),await c.invalidateQueries({queryKey:["my-content"]}),ee("Submission updated",{description:"Your submission has been updated successfully."}),i?.(),s(!1)}catch(b){console.error("Error updating submission:",b);const F=b instanceof Error&&b.message==="PERMISSION_DENIED";ee.error("Update failed",{description:F?"Unable to update submission. The contest may no longer be accepting edits.":"Failed to update your submission. Please try again."})}finally{f(!1)}}},R=()=>{s(!1)},B=()=>{if(!x.trim())return;const b=Ic(x);if(b===null){ee.error("Invalid timestamp",{description:"Use formats like 15, 15s, 01:15, or 00:01:15."});return}if(b<0){ee.error("Invalid timestamp",{description:"Timestamp must be 0 or greater."});return}if(A?.duration&&b>A.duration){ee.error("Timestamp out of range",{description:`This video is about ${Math.floor(A.duration)} seconds long.`});return}const F=Pc(b);v(E=>({...E,thumbnailTime:F})),p(F)},S=a&&!m.socialPostUrl.trim(),K=A?.cloudflare_video_id?Array.from(new Set([...Cc(A.duration||0),...m.thumbnailTime?[m.thumbnailTime]:[]])).sort((b,F)=>Ja(b)-Ja(F)):[];return e.jsx(Vn,{open:t,onOpenChange:R,children:e.jsxs(Wn,{className:"sm:max-w-[500px] bg-card border-border",children:[e.jsxs(sl,{children:[e.jsxs(Gn,{className:"flex items-center gap-2 text-foreground",children:[e.jsx(Oi,{className:"h-5 w-5 text-primary"}),"Edit Submission"]}),e.jsx(Ni,{className:"text-muted-foreground",children:"Update your submission details below."})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[S&&e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[e.jsx(hr,{className:"h-5 w-5 text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-amber-400",children:"Social media post required"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This contest requires you to post on social media with the required tags and add the URL here."})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(Lt,{htmlFor:"title",className:"text-foreground",children:["Title ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx(Kt,{id:"title",value:m.title,onChange:b=>v(F=>({...F,title:b.target.value})),placeholder:"Give your submission a title",className:"bg-muted/60 border-border text-foreground"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"description",className:"text-foreground",children:"Description"}),e.jsx(Hn,{id:"description",value:m.description,onChange:b=>v(F=>({...F,description:b.target.value})),placeholder:"Add a description (optional)",rows:3,className:"bg-muted/60 border-border text-foreground resize-none"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(Lt,{htmlFor:"socialPostUrl",className:"text-foreground flex items-center gap-2",children:[e.jsx(wi,{className:"h-4 w-4 text-pink-400"}),"Social Media Post URL",a&&e.jsx("span",{className:"text-pink-400",children:"(required)"})]}),e.jsx(Kt,{id:"socialPostUrl",type:"url",value:m.socialPostUrl,onChange:b=>v(F=>({...F,socialPostUrl:b.target.value})),placeholder:"https://twitter.com/... or https://instagram.com/...",className:"bg-muted/60 border-border text-foreground placeholder:text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: Twitter/X, Instagram, TikTok, YouTube, Facebook, LinkedIn, Threads"})]}),A?.cloudflare_video_id&&e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(Lt,{className:"text-foreground flex items-center gap-2",children:[e.jsx(gr,{className:"h-4 w-4 text-indigo-400"}),"Thumbnail"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Kt,{value:x,onChange:b=>p(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),B())},placeholder:"Custom timestamp (e.g. 15s or 01:15)",className:"bg-muted/60 border-border text-foreground"}),e.jsx(Ee,{type:"button",variant:"outline",onClick:B,disabled:!x.trim(),className:"border-border text-foreground hover:bg-muted",children:"Use"})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:K.map(b=>e.jsxs("button",{type:"button",onClick:()=>v(F=>({...F,thumbnailTime:b})),className:h("relative aspect-[9/16] rounded-lg overflow-hidden border-2 transition-all hover:scale-[1.02] active:scale-[0.98]",m.thumbnailTime===b?"border-indigo-500 shadow-lg shadow-indigo-500/20":"border-border hover:border-border"),children:[e.jsx(br,{cloudflareVideoId:A.cloudflare_video_id,thumbnailTime:b,alt:`Thumbnail at ${b}`,imgClassName:"w-full h-full object-cover",width:150}),m.thumbnailTime===b&&e.jsx("div",{className:"absolute inset-0 bg-indigo-500/20 flex items-center justify-center",children:e.jsx(es,{className:"w-5 h-5 text-foreground drop-shadow-lg"})}),e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-foreground text-[9px] font-medium px-1.5 py-0.5 rounded",children:b})]},b))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select a thumbnail frame for your submission"})]})]}),e.jsxs(rl,{children:[e.jsx(Ee,{variant:"outline",onClick:R,disabled:d,className:"border-border text-foreground hover:bg-muted",children:"Cancel"}),e.jsxs(Ee,{onClick:P,disabled:d,className:"bg-primary hover:bg-primary/90",children:[d&&e.jsx(xt,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Changes"]})]})]})})}function Ln(t){return t.media_type==="image"||!!t.image_r2_key}const Lc="The brand has approved this entry, so it can no longer be deleted. Only the brand can take it out of its approved queue, and after that you can delete it.",Ac=new Set,Mc=new Set,Rc=new Set;function $c({submissions:t,winnerIds:s=[],top30Ids:r=new Set,onSubmissionClick:a,onDeleteSubmission:i,adLaunchedIds:c=Ac,adLockedIds:d=Rc,adActiveIds:f=Mc,approvalLocksDelete:x=!1,onSubmissionUpdated:p,showTop30Badges:m=!1,isPrivate:v=!1,contestId:A,currentUserId:y,communityJudgingEnabled:N=!1,isContestActive:P=!1,contestDeadline:R,requireSocialPost:B=!1,bundleSize:S,brandOptionsMap:K,productOptionsMap:b,challengeTracks:F=[],onOrderChange:E,aspectRatio:Q,isPerformanceCampaign:O=!1,perfApprovedIds:H,perfDeliveryBySubmissionId:te,perfCategoryTagsBySubmissionId:z,perfDisplayMetricsBySubmissionId:ie,perfRepublishingBySubmissionId:se,perfPlacementCountBySubmissionId:Z,perfActivePlacementCountBySubmissionId:w,perfDeliveringBySubmissionId:j,perfEarningsWonUsdBySubmissionId:T}){const[_,U]=n.useState(O?"performing":"newest"),[$,M]=n.useState(""),[D,Y]=n.useState("all"),[W,u]=n.useState("all"),[ue,ve]=n.useState(null),[q,me]=n.useState(null),X=d,{isPreviewMode:fe}=Vs(),{shouldAnonymize:qe}=cn(),Ve=fe||qe,I=t,De=n.useMemo(()=>!B||!y?[]:t.filter(L=>L.creator_id===y&&!L.social_post_url),[t,y,B]),Le=n.useMemo(()=>{const L=new Map;return I.forEach(Se=>{const Ce=Se.contest_challenge_id||Se.challenge_id;Ce&&L.set(Ce,(L.get(Ce)||0)+1)}),L},[I]),Ae=n.useMemo(()=>{let L=0,Se=0;for(const Ce of I)Ln(Ce)?L+=1:Se+=1;return{images:L,videos:Se}},[I]),ke=Ae.images>0&&Ae.videos>0,he=n.useMemo(()=>{let L=I;if(D!=="all"&&(L=L.filter(Se=>Se.contest_challenge_id===D||Se.challenge_id===D)),ke&&W==="image"?L=L.filter(Ln):ke&&W==="video"&&(L=L.filter(Se=>!Ln(Se))),$.trim()){const Se=$.toLowerCase();L=L.filter(Ce=>{const g=Ce.title?.toLowerCase()||"";if(Ve)return Ws(Ce.creator_id).toLowerCase().includes(Se)||g.includes(Se);const J=Ce.creator_profile?.display_name?.toLowerCase()||"",pe=Ce.creator_profile?.username?.toLowerCase()||"";return J.includes(Se)||pe.includes(Se)||g.includes(Se)})}return L},[I,$,Ve,D,W,ke]),je=L=>L==="brand_pick"?1:L==="judge_pick"?2:L==="community_pick"?3:999,xe=s.length>0,Be=n.useMemo(()=>{const L=J=>{if(!J)return 0;const pe=new Date(J).getTime();return Number.isFinite(pe)?pe:0},Se=new Set(H??[]),Ce=te??new Map,g=J=>[...J].sort((pe,Fe)=>
7{const Ue=je(pe.winner_category),re=je(Fe.winner_category);return Ue!==re?Ue-re:(pe.winner_rank||999)-(Fe.winner_rank||999)});if(O&&_==="performing"){const J=he.filter(Ue=>xe&&s.includes(Ue.id)),pe=he.filter(Ue=>!(xe&&s.includes(Ue.id))),Fe=vd(pe,{approvedIds:Se,deliveryBySubmissionId:Ce});return J.length===0?Fe:[...g(J),...Fe]}if(O&&(_==="newest"||_==="oldest")){const J=he.filter(Oe=>xe&&s.includes(Oe.id)),pe=he.filter(Oe=>!(xe&&s.includes(Oe.id))),Fe=pe.filter(Oe=>Se.has(Oe.id)),Ue=pe.filter(Oe=>!Se.has(Oe.id)),re=(Oe,lt)=>{const mt=_==="oldest"?L(Oe.submitted_at)-L(lt.submitted_at):L(lt.submitted_at)-L(Oe.submitted_at);return mt!==0?mt:_==="oldest"?Oe.id.localeCompare(lt.id):lt.id.localeCompare(Oe.id)},ze=[...Fe.sort(re),...Ue.sort(re)];return J.length===0?ze:[...g(J),...ze]}return[...he].sort((J,pe)=>{const Fe=s.includes(J.id),Ue=s.includes(pe.id);if(Fe&&!Ue)return-1;if(!Fe&&Ue)return 1;if(Fe&&Ue){const re=je(J.winner_category),ze=je(pe.winner_category);return re!==ze?re-ze:(J.winner_rank||999)-(pe.winner_rank||999)}if(_==="newest"||_==="performing"){const re=L(pe.submitted_at)-L(J.submitted_at);return re!==0?re:pe.id.localeCompare(J.id)}if(_==="oldest"){const re=L(J.submitted_at)-L(pe.submitted_at);return re!==0?re:J.id.localeCompare(pe.id)}if(_==="az"){const re=J.title?.toLowerCase()||"",ze=pe.title?.toLowerCase()||"";return re.localeCompare(ze)||J.id.localeCompare(pe.id)}if(_==="za"){const re=J.title?.toLowerCase()||"";return(pe.title?.toLowerCase()||"").localeCompare(re)||pe.id.localeCompare(J.id)}if(_==="elo_high"){const re=J.creator_profile?.current_elo??1e3,ze=pe.creator_profile?.current_elo??1e3;return ze!==re?ze-re:pe.id.localeCompare(J.id)}if(_==="elo_low"){const re=J.creator_profile?.current_elo??1e3,ze=pe.creator_profile?.current_elo??1e3;return re!==ze?re-ze:J.id.localeCompare(pe.id)}return L(J.submitted_at)-L(pe.submitted_at)})},[he,_,s,xe,O,H,te]),G=Be,_e=_==="elo_high"||_==="elo_low",Re=F.length<=1,$e=G.map(L=>L.id).join(",");if(n.useEffect(()=>{E&&E($e.split(",").filter(Boolean))},[$e,E]),v)return e.jsxs("div",{className:"py-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Br,{className:"h-5 w-5 text-foreground"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Community Submissions"})]}),e.jsxs("div",{className:"bg-card/50 border border-border rounded-xl p-8 text-center",children:[e.jsx(Qr,{className:"h-12 w-12 text-foreground mx-auto mb-4"}),e.jsx("h4",{className:"text-lg font-medium text-foreground mb-2",children:"Private Submissions"}),e.jsx("p",{className:"text-foreground text-sm mb-2",children:"This was a showcase campaign run before Anthum launched publicly."}),e.jsxs("p",{className:"text-foreground text-xs",children:["Winner videos are featured on our"," ",e.jsx("a",{href:"/campaigns",className:"text-primary hover:underline",children:"case study page"}),"."]})]})]});if(I.length===0){const L=!y,Se=A?`creator/contest/${A}`:"home",Ce=`/auth?type=creator&redirect=${encodeURIComponent(Se)}`;return e.jsxs("div",{className:"py-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Br,{className:"h-5 w-5 text-foreground"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Submissions"})]}),e.jsxs("div",{className:"bg-card/50 border border-border rounded-xl p-8 text-center",children:[e.jsx(Br,{className:"h-12 w-12 text-foreground mx-auto mb-4"}),L?e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-lg font-medium text-foreground mb-2",children:"No submissions yet"}),e.jsx("p",{className:"text-foreground text-sm mb-4",children:"Nothing has been entered here yet. Sign in to enter this contest yourself."}),e.jsx(Ee,{asChild:!0,className:"bg-violet-600 hover:bg-violet-500 text-white",children:e.jsx(Mt,{to:Ce,children:"Sign in"})})]}):P?e.jsx("p",{className:"text-foreground text-sm",children:"No submissions yet. Be the first!"}):e.jsx("p",{className:"text-foreground text-sm",children:"This contest has no submissions."})]})]})}return e.jsxs("div",{className:"py-6",children:[e.jsxs("div",{className:"flex flex-col gap-3 mb-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 sm:gap-0",children:[e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:[e.jsx(Br,{className:"h-5 w-5 text-foreground"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Submissions"}),S?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsxs("span",{className:"text-base text-muted-foreground",children:[I.length," ",qt(I.length,"Bundle")]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",I.length*S," ",qt(I.length*S,"entry","entries"),")"]})]}):e.jsxs("span",{className:"text-sm text-foreground",children:["(",I.length," ",qt(I.length,"submission"),")"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full sm:w-auto pb-2 sm:pb-0",children:[O&&e.jsxs(Ee,{variant:"ghost",size:"sm",className:`h-8 text-xs rounded-md gap-1 ${_==="performing"?"text-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>U("performing"),"aria-pressed":_==="performing",children:[e.jsx(ji,{className:"h-3 w-3"}),"Performing"]}),e.jsxs(Ee,{variant:"ghost",size:"sm",className:`h-8 text-xs rounded-md gap-1 ${_==="newest"||_==="oldest"?"text-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{U(_==="newest"?"oldest":"newest")}
7,"aria-pressed":_==="newest"||_==="oldest",children:[e.jsx(qn,{className:"h-3 w-3"}),_==="oldest"?"Oldest":"Newest",_==="newest"?e.jsx($s,{className:"h-3 w-3"}):_==="oldest"?e.jsx(zr,{className:"h-3 w-3"}):e.jsx($s,{className:"h-3 w-3 opacity-30"})]}),e.jsxs(Ee,{variant:"ghost",size:"sm",className:`h-8 text-xs rounded-md gap-1 ${_==="az"||_==="za"?"text-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{U(_==="az"?"za":"az")},"aria-pressed":_==="az"||_==="za",children:[e.jsx($d,{className:"h-3 w-3"}),_==="za"?"Z-A":"A-Z",_==="az"?e.jsx(zr,{className:"h-3 w-3"}):_==="za"?e.jsx($s,{className:"h-3 w-3"}):e.jsx(zr,{className:"h-3 w-3 opacity-30"})]}),!O&&e.jsxs(Ee,{variant:"ghost",size:"sm",className:`h-8 text-xs rounded-md gap-1 ${_==="elo_high"||_==="elo_low"?"text-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{U(_==="elo_high"?"elo_low":"elo_high")},"aria-pressed":_==="elo_high"||_==="elo_low",children:[e.jsx(wt,{className:"h-3 w-3"}),"Rank",_==="elo_high"?e.jsx($s,{className:"h-3 w-3"}):_==="elo_low"?e.jsx(zr,{className:"h-3 w-3"}):e.jsx($s,{className:"h-3 w-3 opacity-30"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[ke&&e.jsx("div",{className:"inline-flex h-10 items-center gap-1 rounded-full border border-border/70 bg-muted/40 p-1 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",role:"group","aria-label":"Filter by media type",children:[{id:"all",label:"All",count:I.length,icon:null},{id:"video",label:"Video",count:Ae.videos,icon:Fs},{id:"image",label:"Image",count:Ae.images,icon:gr}].map(({id:L,label:Se,count:Ce,icon:g})=>{const J=W===L;return e.jsxs("button",{type:"button",onClick:()=>u(L),className:h("inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium transition-[color,background-color,box-shadow]",J?"bg-background text-foreground shadow-sm ring-1 ring-border/60":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),"aria-pressed":J,children:[g?e.jsx(g,{className:h("h-3.5 w-3.5 shrink-0",J?"opacity-90":"opacity-70"),"aria-hidden":!0}):null,e.jsx("span",{children:Se}),e.jsx("span",{className:h("inline-flex min-w-[1.25rem] items-center justify-center rounded-full px-1.5 py-0.5 text-[10px] font-semibold tabular-nums leading-none",J?"bg-foreground
7/10 text-foreground/70":"bg-muted-foreground/10 text-muted-foreground"),children:Ce})]},L)})}),F.length>0&&e.jsxs(Ld,{children:[e.jsx(Ad,{asChild:!0,children:e.jsxs("button",{className:"inline-flex h-10 max-w-full items-center justify-between gap-2 rounded-full border border-border/70 bg-card px-3.5 text-sm text-foreground shadow-[0_1px_2px_rgba(16,24,40,0.04)] transition-colors hover:border-foreground/15 sm:max-w-xs",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(zn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:D==="all"?"All Tracks":F.find(L=>L.id===D)?.title||"Unknown Track"})]}),e.jsx($s,{className:"h-3 w-3 shrink-0 opacity-50"})]})}),e.jsxs(Md,{align:"start",className:"w-full border-border bg-popover sm:w-56",children:[e.jsxs(Oa,{onClick:()=>Y("all"),className:h("w-full justify-between",D==="all"&&"bg-accent/50"),children:[e.jsx("span",{children:"All Tracks"}),e.jsx("span",{className:"ml-4 rounded-full bg-muted px-2 py-0.5 text-[10px] font-semibold tabular-nums text-muted-foreground",children:I.length})]}),F.map(L=>e.jsxs(Oa,{onClick:()=>Y(L.id),className:h("w-full justify-between",D===L.id&&"bg-accent/50"),children:[e.jsx("span",{className:"truncate",children:L.title}),e.jsx("span",{className:"ml-4 rounded-full bg-muted px-2 py-0.5 text-[10px] font-semibold tabular-nums text-muted-foreground",children:Le.get(L.id)||0})]},L.id))]})]}),e.jsxs("div",{className:"relative w-full flex-1 sm:max-w-xs",children:[e.jsx(Td,{className:"pointer-events-none absolute left-3.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(Kt,{type:"text","aria-label":"Search submissions by username or title",placeholder:"Search by username or title...",value:$,onChange:L=>M(L.target.value),className:"h-10 rounded-full border-border/70 bg-card pl-9 text-sm shadow-[0_1px_2px_rgba(16,24,40,0.04)] placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-foreground/15"})]})]})]}),Be.length===0&&($||W!=="all"||D!=="all")&&e.jsx("p",{className:"text-foreground text-sm py-4",children:$?`No submissions found matching "${$}"`:W==="image"?"No image submissions match the current filters.":W==="video"?"No video submissions match the current filters.":"No submissions match the current filters."}),De.length>0&&e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(hr,{className:"h-4 w-4 text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-amber-400/90",children:"Social media post required"}),e.jsxs("p",{className:"text-xs text-foreground mt-0.5",children:["Edit your submission",De.length>1?"s":""," to add the post URL."]})]})]}),e.jsx("div",{className:Ii,children:G.map(L=>{const Se=r.has(L.id),Ce=s.includes(L.id),g=s.length>0,J=L.creator_id===y,pe=L.status==="approved",Fe=X.has(L.id),Ue=J&&P&&!Ce&&!Fe&&i,re=x&&L.status==="approved"?Lc:null,ze=J&&!g&&!Ce,Oe=J&&!g&&!Ce&&!Fe,lt=B&&J&&!L.social_post_url,mt=L.selected_brand_id?K?.get(L.selected_brand_id):void 0,Rt=L.selected_product_id?b?.get(L.selected_product_id):void 0,He=z?.get(L.id)??[],at=ie?.get(L.id)??null,gt=Z?.get(L.id)??0,Ft=w?.get(L.id)??0,yt=se?.get(L.id)??!1,Hs=T?.get(L.id)??null,Ke=j?.get(L.id),Te=Ke!==void 0?Ke:yt||f.has(L.id)||pe&&!c.has(L.id)&&Ft>0;return Math.max(gt,yt?2:0),gt>1,at?.impressions,Ft>1,e.jsxs("div",{className:`relative group ${Pi}`,children:[e.jsx(Xi,{submission:L,onClick:()=>a(L),isTop30:m&&Se&&!Ce,showWinnerBadges:g,anonymizeCreator:Ve,campaignsStyle:!0,showCreatorElo:_e,hideTrackLabel:Re,aspectRatio:Q,categoryTags:_==="performing"?He:[],earningsWonUsd:O?Hs:null,statusBadgeOverride:pe?Te?{label:"Active",className:"text-emerald-300/90"}:{label:"Inactive",className:"text-zinc-400/90"}:null}),at&&_==="performing"&&at.cells.length>0&&e.jsx("div",{className:h("mt-1.5 grid gap-1 px-0.5",at.cells.length===1&&"grid-cols-1",at.cells.length===2&&"grid-cols-2",at.cells.length===3&&"grid-cols-3",at.cells.length>=4&&"grid-cols-4"),children:at.cells.slice(0,4).map(et=>e.jsxs("div",{className:"min-w-0 text-center",children:[e.jsx("p",{className:"truncate text-[9px] uppercase tracking-wide text-muted-foreground",children:et.label}),e.jsx("p",{className:"truncate text-[11px] font-semibold tabular-nums text-foreground",children:et.value})]},et.label))}),(ze||Oe)&&e.jsxs("div",{className:"absolute top-2 right-2 z-20 flex gap-1 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100 transition-opacity",children:[Oe&&e.jsx(Ee,{variant:"ghost",size:"icon",className:"h-8 w-8 text-foreground bg-muted/80 hover:bg-muted",onClick:et=>{et.stopPropagation(),me(L)},title:L.media_type==="image"?"Replace image":"Replace video","aria-label":L.media_type==="image"?"Replace image":"Replace video",children:e.jsx(xi,{className:"h-4 w-4"})}),e.jsx(Ee,{variant:"ghost",size:"icon",className:`h-8 w-8 ${lt?"bg-amber-500/90 hover:bg-amber-500 text-white":"bg-muted/80 hover:bg-muted text-foreground"}`,onClick:et=>{et.stopPropagation(),ve(L)},title:lt?"Add social post URL (required)":"Edit submission","aria-label":lt?"Add social post URL (required)":"Edit submission",children:e.jsx(Oi,{className:"h-4 w-4"})}),Ue&&e.jsx(Ee,{variant:"ghost",size:"icon",className:h("h-8 w-8 text-white",re?"cursor-not-allowed bg-muted-foreground
7/60 hover:bg-muted-foreground/60":"bg-red-500/80 hover:bg-red-500"),onClick:et=>{if(et.stopPropagation(),re){ee.error(re);return}i(L)},title:re??"Delete submission","aria-label":re??"Delete submission","aria-disabled":re?!0:void 0,children:e.jsx(yi,{className:"h-4 w-4"})})]}),(mt||Rt)&&!lt&&e.jsxs("div",{className:"absolute top-2 left-2 z-10 flex flex-col gap-1",children:[mt&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-card/85 rounded-md backdrop-blur-sm border border-border",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-muted border border-border flex items-center justify-center shrink-0 overflow-hidden",children:mt.logoUrl?e.jsx("img",{src:mt.logoUrl,alt:"",className:"w-full h-full object-cover"}):e.jsx(js,{className:"w-2.5 h-2.5 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] font-medium text-foreground leading-none",children:mt.name})]}),Rt&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-card/85 rounded-md backdrop-blur-sm border border-border",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-muted border border-border flex items-center justify-center shrink-0 overflow-hidden",children:Rt.imageUrl?e.jsx("img",{src:Rt.imageUrl,alt:"",className:"w-full h-full object-cover"}):e.jsx(ss,{className:"w-2.5 h-2.5 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] font-medium text-foreground leading-none",children:Rt.name})]})]}),lt&&e.jsx("div",{className:"absolute top-2 left-2 z-10",children:e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 bg-amber-500/90 rounded-md text-xs font-medium text-white backdrop-blur-sm",children:[e.jsx(hr,{className:"h-3 w-3"}),"Add social URL"]})}),J&&!Ce&&!lt&&!pe&&(!L.status||L.status==="submitted"||L.status==="reviewed")&&e.jsx("div",{className:"absolute bottom-3 left-3 z-10 pointer-events-none",children:e.jsx("span",{className:h(Fn,"text-muted-foreground/90"),children:"Your entry"})})]},L.id)})}),e.jsx(Tc,{open:!!ue,onOpenChange:L=>!L&&ve(null),submission:ue,requireSocialPost:B,onSuccess:p}),e.jsx(Al,{open:!!q,onOpenChange:L=>!L&&me(null),submission:q,onSuccess:p})]})}const An=1,ei=7,Uc=80,Ec=3;function Zr(t){return t.community_rating_count??t.advanced_ratings_count??0}function so(t){if(t==null||!Number.isFinite(t))return null;const s=Math.max(An,Math.min(ei,t)),r=ei-An;return Math.round((s-An)/r*100)}function ro(t){const s=so(t.community_score);return s==null||Zr(t)<Ec?!1:s>=Uc}function Dc(t){const s=so(t.community_score);return s==null||!ro(t)?null:`Liked by ${s}% of creators`}function ti(t,s){const r=t.community_score??0,a=s.community_score??0;if(a!==r)return a-r;const i=Zr(t),c=Zr(s);if(c!==i)return c-i;const d=t.submitted_at?new Date(t.submitted_at).getTime():0,f=s.submitted_at?new Date(s.submitted_at).getTime():0;return f!==d?f-d:(s.id??"").localeCompare(t.id??"")}function Bc(t){return t.some(s=>(s.community_score??0)>0&&Zr(s)>0)}function zc({submission:t,className:s}){const r=Dc(t);return r?e.jsxs("span",{className:h("inline-flex max-w-full items-center gap-0.5 rounded-sm border border-emerald-500/20 bg-black/50 px-1 py-px text-[8px] font-medium leading-none text-emerald-300/90 backdrop-blur-sm",s),children:[e.jsx(Zn,{className:"h-2 w-2 shrink-0 opacity-80","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:r})]}):null}function Kc({mode:t,onChange:s,showCreatorSort:r}){return r?e.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border border-border bg-card/80 p-0.5 shrink-0",role:"group","aria-label":"Sort results",children:[e.jsxs("button",{type:"button",onClick:()=>s("official"),"aria-pressed":t==="official",className:h("h-6 px-2 text-[10px] rounded-full transition-colors font-medium flex items-center gap-1",t==="official"?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:[e.jsx(wt,{className:"h-2.5 w-2.5"}),"Official"]}),e.jsxs("button",{type:"button",onClick:()=>s("creators"),"aria-pressed":t==="creators",className:h("h-6 px-2 text-[10px] rounded-full transition-colors font-medium flex items-center gap-1",t==="creators"?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Zn,{className:"h-2.5 w-2.5"}),"Creators"]})]}):null}const qc=/^(.+?)\s+(?:#?\d+(?:st|nd|rd|th)?(?:\s*[-â]\s*\d+(?:st|nd|rd|th)?)?)/i;function Fc({submissions:t,winnerIds:s,tracks:r=[],prizeDistribution:a,onSubmissionClick:i,userWinningSubmission:c,prizeAmount:d,id:f}){const[x,p]=n.useState("official"),m=Bc(t),{isPreviewMode:v}=Vs(),{shouldAnonymize:A}=cn(),y=v||A,N=n.useMemo(()=>
7{if(!r.length)return[];const w=new Set,j=new Map;for(const _ of r){const U=Ds(_.title)||_.title||"Track";j.has(U)||j.set(U,[]),j.get(U).push(_)}const T=[];for(const _ of r){const U=Ds(_.title)||_.title||"Track";if(w.has(U))continue;w.add(U);const $=j.get(U)??[_];T.push({id:$[0].id,title:U,trackIds:$.map(M=>M.id)})}return T},[r]),P=n.useMemo(()=>{const w=t.filter(T=>s.includes(T.id)||T.status==="winner"||T.winner_rank!=null),j=new Map;return N.length?N.forEach((T,_)=>T.trackIds.forEach(U=>j.set(U,_))):r.forEach((T,_)=>j.set(T.id,_)),w.sort((T,_)=>{const U=j.get(T.contest_challenge_id??"")??999,$=j.get(_.contest_challenge_id??"")??999;if(U!==$)return U-$;const M=T.winner_rank??999,D=_.winner_rank??999;return M-D})},[t,s,r,N]),R=n.useMemo(()=>[...P].sort(ti),[P]),B=n.useMemo(()=>{if(!r.length||!a?.categories?.length)return null;const w=a.categories,j=M=>M?.trim()&&(M.match(qc)?.[1]?.trim()||M.trim())||"",T=(M,D,Y,W)=>{if(!Y?.length)return null;const u=new Map;for(const me of Y){const X=j(me.label)||"Prizes";u.has(X)||u.set(X,[]),u.get(X).push(me)}if(u.size<2)return null;const ve=[...Array.from(u.entries()).map(([me,X])=>({name:me,tiers:X}))].sort((me,X)=>Math.min(...me.tiers.map(fe=>fe.rank_start))-Math.min(...X.tiers.map(fe=>fe.rank_start)));let q=W;return ve.map((me,X)=>{const fe=me.tiers.reduce((Ve,I)=>Ve+(I.rank_end-I.rank_start+1),0),qe={key:`label-${M}-${X}-${me.name}`,label:me.name,trackId:M,rankOffset:q,slotCount:fe};return q+=fe,qe})};if(r.length===1&&w.length>=2){const M=r[0],D=[];let Y=0;for(const W of w){const u=fl(W),ue=T(M.id,W.name,W.prize_tiers??[],Y);ue?D.push(...ue):D.push({key:`cat-${M.id}-${W.name}`,label:W.name,trackId:M.id,rankOffset:Y,slotCount:u}),Y+=u}return D}const _=N.length>0?N:r.map(M=>({id:M.id,title:M.title??"",trackIds:[M.id]})),U=[];for(let M=0;M<_.length;M++){const D=_[M],Y=r.find(ve=>ve.id===D.id)??r[M],W=w[M]??(w.length===1?w[0]:null),u=W?.prize_tiers??[],ue=u.length?T(D.id,W?.name??D.title,u,0):null;ue?ue.forEach(ve=>U.push({...ve,trackIds:D.trackIds.length>1?D.trackIds:void 0})):U.push({key:D.id,label:W?.name??D.title,trackId:D.id,rankOffset:0,slotCount:Y?.winner_count||3,trackIds:D.trackIds.length>1?D.trackIds:void 0})}const $=new Map;for(const M of U){const D=_.find(W=>W.id===M.trackId),Y=$.get(M.trackId);Y?Y.slotCount+=M.slotCount:$.set(M.trackId,{key:M.trackId,label:D?.title??M.label,trackId:M.trackId,rankOffset:0,slotCount:M.slotCount,trackIds:M.trackIds??(D?.trackIds.length?D.trackIds:void 0)})}return _.map(M=>$.get(M.id)).filter(Boolean)},[r,a?.categories,N]),S=n.useMemo(()=>{const w=(j,T)=>T.trackIds?.length?j.contest_challenge_id!=null&&T.trackIds.includes(j.contest_challenge_id):j.contest_challenge_id===T.trackId;if(B?.length){const j=[];for(const T of B){const _=P.filter($=>w($,T)).sort(($,M)=>($.winner_rank??999)-(M.winner_rank??999));if(_.length===0)continue;const U=_.map(($,M)=>M+1);j.push({section:T,winners:_,displayRanks:U})}return j}return N.length>0?N.map(j=>{const T=P.filter($=>$.contest_challenge_id!=null&&j.trackIds.includes($.contest_challenge_id));if(T.length===0)return null;T.sort(($,M)=>($.winner_rank??999)-(M.winner_rank??999));const _={key:j.id,label:j.title,trackId:j.id,rankOffset:0,slotCount:T.length,trackIds:j.trackIds.length>1?j.trackIds:void 0},U=T.map(($,M)=>M+1);return{section:_,winners:T,displayRanks:U}}).filter(Boolean):r.length>0?r.map(j=>{const T=P.filter($=>$.contest_challenge_id===j.id);if(T.length===0)return null;T.sort(($,M)=>($.winner_rank??999)-(M.winner_rank??999));const _={key:j.id,label:Ds(j.title)||j.title,trackId:j.id,rankOffset:0,slotCount:j.winner_count||3},U=T.map(($,M)=>M+1);return{section:_,winners:T,displayRanks:U}}).filter(Boolean):null},[P,r,B,N]),K=n.useMemo(()=>{if(S)return null;if(N.length>0){const j={};return N.forEach(T=>{const _=P.filter(U=>U.contest_challenge_id!=null&&T.trackIds.includes(U.contest_challenge_id));_.sort((U,$)=>(U.winner_rank??999)-($.winner_rank??999)),j[T.id]=_}),j}if(r.length===0)return null;const w={};return r.forEach(j=>{const T=P.filter(_=>_.contest_challenge_id===j.id);T.sort((_,U)=>(_.winner_rank??999)-(U.winner_rank??999)),w[j.id]=T}),w},[P,r,S,N]),b=n.useMemo(()=>new Set(P.map(w=>w.id)),[P]),F=n.useMemo(()=>t.filter(w=>w.winner_category==="honorable_mention"&&!b.has(w.id)),[t,b]),E=n.useMemo(()=>[...F].sort(ti),[F]),Q=x==="creators"&&m,O=n.useMemo(()=>a?.categories?.length&&xl(a)||1/0,[a]),H=w=>w.winner_category==="purchased"||w.winner_rank!=null&&w.winner_rank>O,te=w=>{if(w.length===0)return null;const j=w.map(T=>
7T.winner_rank).filter(Boolean).sort((T,_)=>T-_);return j.length===0?null:j.length===1?`#${j[0]}`:`#${j[0]}-${j[j.length-1]}`},z=n.useMemo(()=>{if(!a?.categories?.length)return j=>null;const w=new Map;for(const j of a.categories)for(const T of j.prize_tiers??[])if(T.rank_end>T.rank_start){const _=`#${T.rank_start}-${T.rank_end}`;for(let U=T.rank_start;U<=T.rank_end;U++)w.set(U,_)}return j=>w.get(j)??null},[a]),ie=w=>{const j=[];let T;for(const _ of w){const U=z(_.winner_rank??0);U!==T||j.length===0?(j.push({tierLabel:U,winners:[_]}),T=U):j[j.length-1].winners.push(_)}return j};if(P.length===0&&F.length===0)return null;const se=w=>w?w===1?{icon:e.jsx(Ud,{className:"h-4 w-4 shrink-0",strokeWidth:2.25}),bg:"bg-amber-400 shadow-md ring-1 ring-amber-300/80 dark:bg-amber-500 dark:ring-amber-400/50",text:"text-amber-950 [&_svg]:text-amber-950",label:"1st Place"}:w===2?{icon:e.jsx(At,{className:"h-4 w-4 shrink-0",strokeWidth:2.25}),bg:"bg-gradient-to-br from-slate-200 via-slate-300 to-slate-400 shadow-md ring-1 ring-white/25 dark:from-slate-300 dark:via-slate-400 dark:to-slate-500",text:"text-slate-950 [&_svg]:text-slate-900",label:"2nd Place"}:w===3?{icon:e.jsx(Wi,{className:"h-4 w-4 shrink-0",strokeWidth:2.25}),bg:"bg-gradient-to-br from-amber-600 to-amber-800 shadow-md ring-1 ring-amber-500/40",text:"text-white [&_svg]:text-white",label:"3rd Place"}:{icon:e.jsx(fr,{className:"h-3.5 w-3.5 shrink-0"}),bg:"bg-muted",text:"text-foreground",label:`#${w}`}:null,Z=(w,j)=>gl(j,a??void 0,w.contest_challenge_id??void 0,r);return e.jsxs(Xt.div,{id:f,initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"py-8 scroll-mt-28",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between pb-5 border-b border-border mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(wt,{className:"h-5 w-5 text-amber-400 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:["Results Announced",e.jsx(ic,{className:"h-4 w-4 text-amber-400/80"})]}),e.jsxs("p",{className:"text-[13px] text-foreground mt-0.5",children:[P.length," submission",P.length>1?"s":""," ranked",d&&e.jsxs("span",{className:"text-foreground ml-1",children:["· $",d.toLocaleString()," prize pool"]})]})]})]}),e.jsx(Kc,{mode:x,onChange:p,showCreatorSort:m})]}),c&&c.status==="winner"&&e.jsx(Xt.div,{initial:{scale:.98,opacity:0}
7,animate:{scale:1,opacity:1},className:h("mb-6 py-3 px-4 border-l-2 border-y border-r border-border rounded-r-lg",c.status==="winner"?"border-amber-400 bg-amber-500/5":"border-border bg-muted/30"),children:e.jsxs("div",{className:"flex items-center gap-3",children:[c.status==="winner"?e.jsx(wt,{className:"h-4 w-4 text-amber-400 shrink-0"}):e.jsx(At,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[c.status==="winner"?e.jsx("p",{className:"text-sm font-medium text-amber-700/90 dark:text-amber-200/90",children:"Congratulations â you won!"}):e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Your placement"}),e.jsxs("p",{className:"text-[13px] text-foreground mt-0.5",children:['"',c.title,'"',c.winner_rank!=null&&e.jsxs("span",{className:h("ml-2 text-[11px] uppercase tracking-wider",c.status==="winner"?"text-amber-400/90":"text-muted-foreground"),children:[H(c)?te(P.filter(H))||`#${c.winner_rank}`:z(c.winner_rank)||`#${c.winner_rank}`," place"]})]})]})]})}),Q&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Sorted by creator peer ratings. Prizes follow official rank."}),e.jsx("div",{className:"flex flex-wrap justify-center gap-3 md:gap-4",children:R.map((w,j)=>e.jsx("div",{className:"w-[calc(50%-6px)] sm:w-48 transition-all",children:e.jsx(_t,{submission:w,rank:w.winner_rank??null,onClick:()=>i?.(w),getRankConfig:se,resolveWinnerCash:Z,isPodium:!1,delay:j*.03,rankLabel:H(w)?te(R.filter(H))||void 0:w.winner_rank!=null&&z(w.winner_rank)||void 0})},w.id))}),E.length>0&&e.jsxs("div",{className:"mt-8 pt-6 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-4",children:[e.jsx(At,{className:"h-3.5 w-3.5 text-amber-400/80"}),e.jsxs("h3",{className:"text-xs font-semibold text-amber-600/90 dark:text-amber-300/90 uppercase tracking-wider",children:["Honorable Mention",E.length!==1?"s":""]})]}),e.jsx("div",{className:"flex flex-wrap justify-center gap-3 md:gap-4",children:E.map((w,j)=>e.jsx("div",{className:"w-[calc(50%-6px)] sm:w-44",children:e.jsx(_t,{submission:w,rank:null,onClick:()=>i?.(w),getRankConfig:se,isPodium:!1,delay:j*.03})},w.id))})]})]}),!Q&&(S&&S.length>0?e.jsx("div",{className:"space-y-8",children:S.map(({section:w,winners:j},T)=>{const _=j.filter(D=>D.status==="winner"),U=_.filter(D=>!H(D)),$=_.filter(D=>H(D)),M=te($);return e.jsx(Xt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:T*.08},className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[w.label&&e.jsxs("div",{className:"flex items-center gap-2.5 mb-1",children:[e.jsx(wt,{className:"h-4 w-4 text-amber-400/80"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground uppercase tracking-wider",children:w.label}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),U.length>=1&&e.jsx("div",{className:"flex flex-wrap justify-center gap-4 lg:gap-6",children:U.slice(0,3).map((D,Y)=>e.jsx(_t,{submission:D,rank:D.winner_rank??Y+1,onClick:()=>
7i?.(D),getRankConfig:se,resolveWinnerCash:Z,isPodium:!0,delay:Y*.1},D.id))}),U.length>3&&ie(U.slice(3)).map((Y,W)=>e.jsxs("div",{children:[Y.tierLabel&&e.jsxs("div",{className:"flex items-center gap-2.5 mt-8 mb-3",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Prize ",Y.tierLabel," (",Y.winners.length,")"]}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:h("flex flex-wrap justify-center gap-3 md:gap-4",!Y.tierLabel&&"mt-6"),children:Y.winners.map((u,ue)=>e.jsx("div",{className:"w-[calc(50%-6px)] sm:w-48 transition-all",children:e.jsx(_t,{submission:u,rank:u.winner_rank??ue+4,onClick:()=>i?.(u),getRankConfig:se,resolveWinnerCash:Z,isPodium:!1,delay:ue*.05,rankLabel:Y.tierLabel||void 0})},u.id))})]},Y.tierLabel??`tier-${W}`)),$.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mt-8 mb-3",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Additional Winners",M?` (${M})`:""]}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:"flex flex-wrap justify-center gap-3 md:gap-4",children:$.map((D,Y)=>e.jsx("div",{className:"w-[calc(50%-6px)] sm:w-48 transition-all",children:e.jsx(_t,{submission:D,rank:D.winner_rank,onClick:()=>
7i?.(D),getRankConfig:se,resolveWinnerCash:Z,isPodium:!1,delay:Y*.05,rankLabel:M||void 0})},D.id))})]})]})},w.key)})}):K?e.jsx("div",{className:"space-y-8",children:(N.length?N:r).map((w,j)=>{const T=w.id,_=K[T]||[];if(_.length===0)return null;const U=_.filter(W=>W.status==="winner"),$=U.filter(W=>!H(W)),M=U.filter(W=>H(W)),D=te(M),Y=Ds(w.title)||w.title;return e.jsx(Xt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:j*.08},className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[Y&&e.jsxs("div",{className:"flex items-center gap-2.5 mb-1",children:[e.jsx(wt,{className:"h-4 w-4 text-amber-400/80"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground uppercase tracking-wider",children:Y}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),$.length>=1&&e.jsx("div",{className:"flex flex-wrap justify-center gap-4 lg:gap-6",children:$.slice(0,3).map((W,u)=>e.jsx(_t,{submission:W,rank:W.winner_rank??u+1,onClick:()=>i?.(W),getRankConfig:se,resolveWinnerCash:Z,isPodium:!0,delay:u*.1},W.id))}),$.length>3&&ie($.slice(3)).map((u,ue)=>e.jsxs("div",{children:[u.tierLabel&&e.jsxs("div",{className:"flex items-center gap-2.5 mt-8 mb-3",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Prize ",u.tierLabel," (",u.winners.length,")"]}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:h("flex flex-wrap justify-center gap-3 md:gap-4",!u.tierLabel&&"mt-6"),children:u.winners.map((ve,q)=>e.jsx("div",{className:"w-[calc(50%-6px)] sm:w-48 transition-all",children:e.jsx(_t,{submission:ve,rank:ve.winner_rank??q+4,onClick:()=>i?.(ve),getRankConfig:se,resolveWinnerCash:Z,isPodium:!1,delay:q*.05,rankLabel:u.tierLabel||void 0})},ve.id))})]},u.tierLabel??`tier-${ue}`)),M.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mt-8 mb-3",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Additional Winners",D?` (${D})`:""]}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:"flex flex-wrap justify-center gap-3 md:gap-4",children:M.map((W,u)=>e.jsx("div",{className:"w-[calc(50%-6px)] sm:w-48 transition-all",children:e.jsx(_t,{submission:W,rank:W.winner_rank,onClick:()=>i?.(W),getRankConfig:se,resolveWinnerCash:Z,isPodium:!1,delay:u*.05,rankLabel:D||void 0})},W.id))})]})]})},T)})}):(()=>{const w=P.filter(U=>U.status==="winner"),j=w.filter(U=>!H(U)),T=w.filter(U=>H(U)),_=te(T);return e.jsxs("div",{className:"space-y-6 pt-1",children:[j.length>=1&&e.jsx("div",{className:"flex flex-wrap justify-center gap-4 lg:gap-6",children:j.slice(0,3).map((U,$)=>e.jsx(_t,{submission:U,rank:U.winner_rank??$+1,onClick:()=>i?.(U),getRankConfig:se,resolveWinnerCash:Z,isPodium:!0,delay:$*.1},U.id))}),j.length>3&&ie(j.slice(3)).map(($,M)=>e.jsxs("div",{children:[$.tierLabel&&e.jsxs("div",{className:"flex items-center gap-2.5 mt-8 mb-3",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Prize ",$.tierLabel," (",$.winners.length,")"]}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:h("flex flex-wrap justify-center gap-3 md:gap-4",!$.tierLabel&&"mt-6"),children:$.winners.map((D,Y)=>e.jsx("div",{className:"w-[calc(50%-6px)] sm:w-48 transition-all",children:e.jsx(_t,{submission:D,rank:D.winner_rank??Y+4,onClick:()=>
7i?.(D),getRankConfig:se,resolveWinnerCash:Z,isPodium:!1,delay:Y*.05,rankLabel:$.tierLabel||void 0})},D.id))})]},$.tierLabel??`tier-${M}`)),T.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mt-8 mb-3",children:[e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Additional Winners",_?` (${_})`:""]}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:"flex flex-wrap justify-center gap-3 md:gap-4",children:T.map((U,$)=>e.jsx("div",{className:"w-[calc(50%-6px)] sm:w-48 transition-all",children:e.jsx(_t,{submission:U,rank:U.winner_rank,onClick:()=>i?.(U),getRankConfig:se,resolveWinnerCash:Z,isPodium:!1,delay:$*.05,rankLabel:_||void 0})},U.id))})]})]})})()),!Q&&(()=>{const w=P.filter(j=>j.status!=="winner");return w.length===0?null:e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Other Submissions"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:"flex flex-wrap justify-center gap-3 md:gap-4",children:w.map((j,T)=>e.jsx("div",{className:"w-[calc(50%-6px)] sm:w-48 transition-all",children:e.jsx(_t,{submission:j,rank:null,onClick:()=>i?.(j),getRankConfig:se,isPodium:!1,delay:T*.05})},j.id))})]})})(),!Q&&F.length>0&&e.jsxs(Xt.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.3},className:"mt-10 pt-8 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-5",children:[e.jsx(At,{className:"h-4 w-4 text-amber-400/80"}),e.jsxs("h3",{className:"text-sm font-semibold text-amber-600/90 dark:text-amber-300/90 uppercase tracking-wider",children:["Honorable Mention",F.length!==1?"s":""]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:F.length})]}),e.jsx("div",{className:"flex flex-wrap justify-center gap-3 md:gap-4",children:F.map((w,j)=>{const T=ws(w),_=T.type==="image",U=ys(T);return e.jsx(Xt.button,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.35+j*.06},onClick:()=>i?.(w),className:"group relative w-[calc(50%-6px)] text-left sm:w-44",children:e.jsx("div",{className:"relative overflow-hidden rounded-xl border border-white/[0.06] bg-zinc-900 transition-all duration-200 hover:border-white/[0.12] hover:shadow-lg hover:shadow-black/25",children:e.jsxs("div",{className:"relative aspect-[9/16]",children:[e.jsx(br,{imageUrl:_?U:void 0,thumbnailUrl:_?void 0:U,alt:w.title||"Honorable Mention",className:"h-full w-full",imgClassName:"h-full w-full object-cover"}),e.jsxs("div",{className:"absolute left-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-amber-500/30 bg-amber-500/20 px-2 py-1",children:[e.jsx(At,{className:"h-3 w-3 text-amber-400"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-300",children:"HM"})]}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-[5] opacity-0 transition-opacity duration-200 ease-out group-hover:opacity-100 [@media(hover:none)]:opacity-100",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/10 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-3 pb-10",children:[e.jsx("span",{className:"mb-0.5 block text-[9px] font-medium uppercase tracking-[0.2em] text-white/45",children:"Honorable mention"}),e.jsx("p",{className:"line-clamp-2 text-sm font-semibold leading-snug text-white",children:w.title||"Untitled"}),e.jsxs("p",{className:"mt-0.5 truncate text-[11px] text-white/50",children:["by"," ",y?Ws(w.creator_id):w.creator_profile?.display_name||w.creator_profile?.username||"Creator"]})]})]}),!_&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border border-white/10 bg-black/60 backdrop-blur-sm md:h-11 md:w-11",children:e.jsx(Os,{className:"h-4 w-4 fill-white text-white md:h-5 md:w-5"})})})]})})},w.id)})})]})]})}function _t({submission:t,rank:s,onClick:r,getRankConfig:a,resolveWinnerCash:i,isPodium:c,delay:d,rankLabel:f}){const{isPreviewMode:x}=Vs(),{shouldAnonymize:p}=cn(),m=x||p,v=a(s),A=s===1,y=s!=null&&s<=3,N=s!=null&&i?i(t,s):null,P=ws(t),R=P.type==="image",B=ys(P);return e.jsx(Xt.button,{initial:{opacity:0,y:20,scale:.9}
7,animate:{opacity:1,y:0,scale:1},transition:{delay:d,type:"spring",stiffness:200},whileHover:{opacity:.92},whileTap:{scale:.98},onClick:r,className:h("relative group text-left",c&&y&&"w-32 sm:w-40 md:w-48",!c&&"w-full"),children:e.jsx("div",{className:h("relative overflow-hidden rounded-xl border border-white/[0.06] bg-zinc-900 transition-all duration-200 hover:border-white/[0.12] hover:shadow-lg hover:shadow-black/25",A&&c&&"ring-2 ring-amber-500/40",s===2&&c&&"ring-1 ring-white/15",s===3&&c&&"ring-1 ring-amber-700/35"),children:e.jsxs("div",{className:"relative aspect-[9/16]",children:[e.jsx(br,{imageUrl:R?B:void 0,thumbnailUrl:R?void 0:B,alt:t.title||"Winner",className:"h-full w-full",imgClassName:"h-full w-full object-cover"}),(v||ro(t))&&e.jsxs("div",{className:"pointer-events-none absolute bottom-3 left-3 z-10 flex max-w-[calc(100%-4.5rem)] flex-col items-start gap-0.5",children:[v&&e.jsxs("div",{className:h("flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-bold shadow-md",v.bg,v.text),children:[!f&&v.icon,e.jsx("span",{className:"truncate",children:f||v.label})]}),e.jsx(zc,{submission:t})]}),(N!=null&&N>0||t.winner_category==="honorable_mention"||t.secondary_winner_category==="honorable_mention")&&e.jsxs("div",{className:"pointer-events-none absolute top-2.5 right-2.5 z-10 flex max-w-[min(55%,calc(100%-5rem))] flex-col items-end gap-1",children:[N!=null&&N>0&&e.jsx(qi,{amountUsd:N}),(t.winner_category==="honorable_mention"||t.secondary_winner_category==="honorable_mention")&&e.jsxs("div",{className:"flex items-center gap-1 rounded-md border border-amber-500/30 bg-amber-500/20 px-1.5 py-0.5",children:[e.jsx(At,{className:"h-3 w-3 text-amber-400"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-300",children:"Honorable"})]})]}),e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-[5] opacity-0 transition-opacity duration-200 ease-out group-hover:opacity-100 [@media(hover:none)]:opacity-100",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/10 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-3 pb-10",children:[v==null&&e.jsx("span",{className:"mb-0.5 block text-[9px] font-medium uppercase tracking-[0.2em] text-white/45",children:"Submission"}),e.jsx("p",{className:h("line-clamp-2 truncate font-semibold leading-snug text-white",c&&A?"text-base":"text-sm"),children:t.title||"Untitled"}),e.jsxs("p",{className:"mt-0.5 truncate text-[11px] text-white/50",children:["by"," ",m?Ws(t.creator_id):t.creator_profile?.display_name||t.creator_profile?.username||"Creator"]})]})]}),!R&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border border-white/10 bg-black/60 backdrop-blur-sm md:h-11 md:w-11",children:e.jsx(Os,{className:"h-4 w-4 fill-white text-white md:h-5 md:w-5"})})})]})})})}function Oc(t){return t===1?{Icon:wt,tierClassName:"text-[#fde68a]"}:t===2?{Icon:At,tierClassName:"text-slate-300"}:t===3?{Icon:Wi,tierClassName:"text-amber-600/95"}:t<=10?{Icon:Ed,tierClassName:"text-amber-500/80"}:t<=20?{Icon:fr,tierClassName:"text-amber-500/60"}:{Icon:Yr,tierClassName:"text-amber-500/40"}}function Mn(t){return`$${Number(t).toLocaleString()} Studio`}function Xr(t,s=0,r){const a=Number(t)||0,i=Number(s)||0,c=Number(r?.studioCash)||0,d=r?.formatCash??(x=>`$${x.toLocaleString()}`),f=[];return i>0&&f.push(`+${i.toLocaleString()} cr`),c>0&&f.push(`+${Mn(c)}`),a>0?{primary:d(a),subline:f.length>0?f.join(" "):null}:i>0?{primary:`${i.toLocaleString()} cr`,subline:c>0?`+${Mn(c)}`:null}:c>0?{primary:Mn(c),subline:null}:{primary:"â",subline:null}}function Vc(t){return t.label?.trim()?t.label.trim():t.rank_start===t.rank_end?`${t.rank_start}${no(t.rank_start)}`:`#${t.rank_start}â${t.rank_end}`}function no(t){const s=t%100;if(s>=11&&s<=13)return"th";switch(t%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}function Wc(t){return t.rank_end-t.rank_start+1}function Gc(t){return`${t}${no(t)}`}function Hc(t){const s=[];for(const r of t){const a=s[s.length-1];a&&a.prize===r.prize&&(a.credit??0)===r.credit&&(a.studio_cash??0)===r.studioCash&&a.rank_end===r.rank-1?a.rank_end=r.rank:s.push({rank_start:r.rank,rank_end:r.rank,prize:r.prize,credit:r.credit,studio_cash:r.studioCash,label:""})}return s}function Yc(t,s=5){const r=(t??[]).filter(m=>m&&m.rank_end>=m.rank_start),a=m=>m.prize>0?m.prize:(m.studio_cash??0)>0?m.studio_cash??0:m.credit??0,i=Array.from(new Set(r.map(a))).sort((m,v)=>v-m),c=m=>Math.max(0,i.indexOf(a(m))),d=[];for(const m of r)for(let v=m.rank_start;v<=m.rank_end;v++)d.push({rank:v,prize:m.prize,credit:m.credit??0,studioCash:m.studio_cash??0,level:c(m)});d.sort((m,v)=>m.rank-v.rank);const f=d.slice(0,s),x=Hc(d.slice(s)),p=new Set(f.map(m=>m.level));return{slots:f,rest:x,allCoEqual:f.length>1&&p.size===1&&x.length===0}}const ao=[{height:"h-[120px] sm:h-[150px]",glow:"rgba(245,158,11,0.4)",labelClass:"text-[#fde68a]"},{height:"h-[100px] sm:h-[126px]",glow:"rgba(148,163,184,0.3)",labelClass:"text-slate-300"},{height:"h-[84px] sm:h-[104px]",glow:"rgba(234,88,12,0.3)",labelClass:"text-amber-500/90"},{height:"h-[70px] sm:h-[88px]",glow:"rgba(45,212,191,0.28)",labelClass:"text-teal-300/90"},{height:"h-[58px] sm:h-[74px]",glow:"rgba(167,139,250,0.28)",labelClass:"text-violet-300/90"}
7],Qc=[{core:"#f59e0b",light:"#fef3c7",dark:"#78350f",accent:"#fbbf24"},{core:"#94a3b8",light:"#f8fafc",dark:"#0f172a",accent:"#cbd5e1"},{core:"#c2410c",light:"#ffedd5",dark:"#431407",accent:"#ea580c"},{core:"#0d9488",light:"#ccfbf1",dark:"#134e4a",accent:"#2dd4bf"},{core:"#7c3aed",light:"#ede9fe",dark:"#4c1d95",accent:"#a78bfa"}];function io(t){return Math.max(0,Math.min(t,ao.length-1))}function Zc(t){if(t===0)return 0;const s=Math.ceil(t/2);return t%2===1?s:-s}function Xc({level:t}){const s=io(t),r=`podium-${s}`,a=Qc[s];return e.jsxs("svg",{viewBox:"0 0 200 300",className:"h-full w-full drop-shadow-2xl","aria-hidden":!0,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:`${r}-core-fl`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:a.light,stopOpacity:"0.8"}),e.jsx("stop",{offset:"100%",stopColor:a.core,stopOpacity:"0.2"})]}),e.jsxs("linearGradient",{id:`${r}-core-fr`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:a.core,stopOpacity:"0.9"}),e.jsx("stop",{offset:"100%",stopColor:a.dark,stopOpacity:"0.4"})]}),e.jsxs("linearGradient",{id:`${r}-glass-fl`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#ffffff",stopOpacity:"0.5"}),e.jsx("stop",{offset:"50%",stopColor:a.light,stopOpacity:"0.05"}),e.jsx("stop",{offset:"100%",stopColor:a.dark,stopOpacity:"0.7"})]}),e.jsxs("linearGradient",{id:`${r}-glass-fr`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:a.light,stopOpacity:"0.25"}),e.jsx("stop",{offset:"100%",stopColor:"#000000",stopOpacity:"0.85"})]}),e.jsxs("linearGradient",{id:`${r}-glass-top`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#ffffff",stopOpacity:"0.7"}),e.jsx("stop",{offset:"100%",stopColor:a.light,stopOpacity:"0.15"})]}),e.jsxs("filter",{id:`${r}-glow`,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[e.jsx("feGaussianBlur",{stdDeviation:"12",result:"blur"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{in:"blur"}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),e.jsxs("filter",{id:`${r}-glow-sm`,x:"-30%",y:"-30%",width:"160%",height:"160%",children:[e.jsx("feGaussianBlur",{stdDeviation:"4",result:"blur"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{in:"blur"}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]})]}),e.jsx("path",{d:"M 20 240 L 100 280 L 180 240 L 100 200 Z",fill:a.core,filter:`url(#${r}-glow)`,opacity:"0.4"}),e.jsx("path",{d:"M 20 240 L 100 280 L 180 240 L 100 200 Z",fill:a.dark,stroke:a.accent,strokeWidth:"2",strokeLinejoin:"round"}),e.jsx("path",{d:"M 30 240 L 100 275 L 170 240 L 100 205 Z",fill:"none",stroke:a.light,strokeWidth:"1",opacity:"0.5",strokeLinejoin:"round"}),e.jsxs("g",{filter:`url(#${r}-glow-sm)`,children:[e.jsx("path",{d:"M 100 55 L 130 70 L 100 85 L 70 70 Z",fill:a.light,strokeLinejoin:"round"}),e.jsx("path",{d:"M 70 70 L 100 85 L 100 245 L 70 230 Z",fill:`url(#${r}-core-fl)`,strokeLinejoin:"round"}),e.jsx("path",{d:"M 100 85 L 130 70 L 130 230 L 100 245 Z",fill:`url(#${r}-core-fr)`,strokeLinejoin:"round"}),e.jsx("line",{x1:"100",y1:"85",x2:"100",y2:"245",stroke:"#ffffff",strokeWidth:"2",opacity:"0.9"})]}),e.jsx("path",{d:"M 40 70 L 100 40 L 160 70 L 100 100 Z",fill:a.dark,opacity:"0.3",strokeLinejoin:"round"}),e.jsx("path",{d:"M 40 70 L 100 100 L 100 260 L 40 230 Z",fill:`url(#${r}-glass-fl)`,stroke:a.light,strokeWidth:"1.5",strokeLinejoin:"round"}),e.jsx("path",{d:"M 100 100 L 160 70 L 160 230 L 100 260 Z",fill:`url(#${r}-glass-fr)`,stroke:a.accent,strokeWidth:"1.5",strokeLinejoin:"round"}),e.jsx("path",{d:"M 100 40 L 160 70 L 100 100 L 40 70 Z",fill:`url(#${r}-glass-top)`,stroke:"#ffffff",strokeWidth:"2",strokeLinejoin:"round"}),e.jsx("path",{d:"M 100 50 L 140 70 L 100 90 L 60 70 Z",fill:"none",stroke:"#ffffff",strokeWidth:"1",opacity:"0.6",strokeLinejoin:"round"}),e.jsx("path",{d:"M 45 75 L 95 100 L 95 250 L 45 225 Z",fill:"#ffffff",opacity:"0.08",strokeLinejoin:"round"}),e.jsx("path",{d:"M 105 100 L 155 75 L 155 225 L 105 250 Z",fill:"#000000",opacity:"0.2",strokeLinejoin:"round"}),e.jsx("path",{d:"M 40 70 L 100 100 L 100 260",fill:"none",stroke:"#ffffff",strokeWidth:"2",opacity:"0.7",strokeLinejoin:"round"}),e.jsx("path",{d:"M 100 100 L 160 70",fill:"none",stroke:"#ffffff",strokeWidth:"2",opacity:"0.5",strokeLinejoin:"round"}),e.jsx("path",{d:"M 25 140 L 100 177.5 L 175 140 L 100 102.5 Z",fill:"none",stroke:a.light,strokeWidth:"1.5",opacity:"0.9",filter:`url(#${r}-glow-sm)`,strokeLinejoin:"round"}),e.jsx("path",{d:"M 15 180 L 100 222.5 L 185 180 L 100 137.5 Z",fill:"none",stroke:a.accent,strokeWidth:"1",opacity:"0.5",strokeLinejoin:"round"}),e.jsxs("g",{transform:"translate(100, 22)",filter:`url(#${r}-glow-sm)`,children:[s===0&&e.jsx("path",{d:"M 0 -16 L 6 -5 L 18 -5 L 9 3 L 12 14 L 0 8 L -12 14 L -9 3 L -18 -5 L -6 -5 Z",fill:"#ffffff",strokeLinejoin:"round"}),s===1&&e.jsx("path",{d:"M 0 -14 L 12 0 L 0 14 L -12 0 Z",fill:"#ffffff",strokeLinejoin:"round"}),s===2&&e.jsx("path",{d:"M 0 -10 L 9 -5 L 9 5 L 0 10 L -9 5 L -9 -5 Z",fill:"#ffffff",strokeLinejoin:"round"}),s===3&&e.jsx("path",{d:"M 0 -10 L 9 0 L 0 10 L -9 0 Z",fill:"#ffffff",strokeLinejoin:"round"}),s>=4&&e.jsx("circle",{cx:"0",cy:"0",r:"7",fill:"#ffffff"})]})]})}
7function Jc({slot:t,order:s,allCoEqual:r,showAnthumBonusFraming:a}){const i=ao[io(t.level)],c=r?"Winner":Gc(t.rank),{primary:d,subline:f}=Xr(t.prize,t.credit,{studioCash:t.studioCash,formatCash:a&&t.prize>0?x=>Ki(x):void 0});return e.jsxs("div",{className:"flex min-w-[3.25rem] max-w-[7.5rem] flex-1 basis-0 flex-col items-center justify-end",style:{order:s},children:[e.jsxs("div",{className:"mb-2 flex min-h-0 w-full flex-col items-center justify-end gap-0.5 px-0.5 text-center",children:[e.jsx("p",{className:"text-sm font-bold tabular-nums leading-none text-[#fde68a] sm:text-base [text-shadow:0_0_16px_rgba(251,191,36,0.45)]",children:d}),f&&e.jsx("p",{className:"text-[9px] tabular-nums text-[#fde8bd]/75 sm:text-[10px]",children:f})]}),e.jsx("div",{className:h("relative w-full",i.height),style:{filter:`drop-shadow(0 8px 24px ${i.glow})`},children:e.jsx(Xc,{level:t.level})}),e.jsx("span",{className:h("mt-1.5 text-[10px] font-bold uppercase tracking-[0.2em]",i.labelClass),children:c})]})}function eu({slots:t,allCoEqual:s=!1,showAnthumBonusFraming:r=!1,className:a}){return t.length?e.jsxs("div",{className:h("relative w-full",a),children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-[8%] bottom-6 h-12 rounded-[100%] bg-[radial-gradient(ellipse_at_center,rgba(251,191,36,0.14),transparent_70%)]","aria-hidden":!0}),e.jsx("div",{className:"relative flex items-end justify-center gap-1.5 px-1 pb-1 sm:gap-2.5",children:t.map((i,c)=>e.jsx(Jc,{slot:i,order:Zc(c),allCoEqual:s,showAnthumBonusFraming:r},`${i.rank}-${c}`))}),s&&e.jsxs("p",{className:"mt-1.5 text-center text-[10px] font-medium uppercase tracking-[0.16em] text-white/45",children:[t.length," winners ·"," ",Xr(t[0].prize,t[0].credit,{studioCash:t[0].studioCash}).primary," each"]})]}):null}const si="max-w-[18rem] border-white/10 bg-zinc-950/95 px-3 py-2.5 text-left text-xs leading-[1.55] text-zinc-200";function tu({className:t,iconClassName:s="h-3.5 w-3.5"}){const r=un(),a=e.jsx("button",{type:"button","aria-label":"What is Studio Cash?",className:h("inline-flex shrink-0 items-center justify-center rounded-full text-emerald-300/90 transition-colors hover:text-emerald-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-emerald-300/60",t),onClick:i=>i.stopPropagation(),children:e.jsx(Fo,{className:s,"aria-hidden":!0})});return r?e.jsxs(bs,{children:[e.jsx(Ks,{asChild:!0,children:a}),e.jsx(vs,{side:"top",align:"end",className:h("w-auto z-[90]",si),children:Ba})]}):e.jsxs(Jr,{children:[e.jsx(en,{asChild:!0,children:a}),e.jsx(tn,{side:"top",align:"end",className:si,children:Ba})]})}const su={color:"#fff",backdropFilter:"blur(20px) saturate(160%)",WebkitBackdropFilter:"blur(20px) saturate(160%)",background:"linear-gradient(165deg, rgba(255,255,255,0.11) 0%, rgba(255,255,255,0.03) 45%, transparent 100%), linear-gradient(180deg, rgba(251,191,36,0.1) 0%, rgba(28,12,6,0.92) 28%, rgba(12,6,4,0.97) 100%)",boxShadow:"0 1px 0 rgba(255,255,255,0.16) inset, 0 -1px 0 rgba(0,0,0,0.35) inset, inset 0 0 0 1px rgba(255,255,255,0.06)"};function ru({bonusPct:t}){const s=un(),r=e.jsx("button",{type:"button","aria-label":"How placement prizes are paid out",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-white/90 transition-colors hover:text-white focus:outline-none focus-visible:ring-1 focus-visible:ring-white/60",children:e.jsx(hr,{className:"h-[18px] w-[18px]","aria-hidden":!0})}),a=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mb-2 block font-semibold text-zinc-50",children:td()}),sd(t)]}),i="max-w-[22rem] whitespace-pre-line border-white/10 bg-zinc-950/95 px-3.5 py-3 text-left text-xs leading-[1.6] text-zinc-200";return s?e.jsxs(bs,{children:[e.jsx(Ks,{asChild:!0,children:r}),e.jsx(vs,{side:"top",align:"end",className:h("w-auto z-[90]",i),children:a})]}):e.jsxs(Jr,{children:[e.jsx(en,{asChild:!0,children:r}),e.jsx(tn,{side:"top",align:"end",className:i,children:a})]})}function nu({prizeAmount:t,creditPrizeAmount:s,studioCashPrizeAmount:r,prizeDistribution:a,trackCount:i,phase:c,showAnthumBonusFraming:d=!1,bonusPct:f}){const x=c==="completed",[p,m]=n.useState(!1),[v,A]=n.useState(!1),[y,N]=n.useState(0);n.useEffect(()=>{m(!0)},[]);const P=a?.categories??[],R=P.length>1,B=[],S=a?.grand_winner_bonus??0;for(const w of P)w.prize_tiers&&B.push(...w.prize_tiers);const K=R?P[y]?.prize_tiers??[]:B,b=Yc(K),F=b.rest,E=b.slots.length>0,Q=4,O=F.length>Q,H=O&&!v?F.slice(0,Q):F,te=F.length-Q,{primary:z,subline:ie}=Xr(t,s??0,{studioCash:r??0,formatCash:d&&!x&&t>0?w=>rd(w):void 0}),se=(Number(r)||0)>0;function Z(w,j){const{Icon:T,tierClassName:_}=Oc(w.rank_start),U=Wc(w),$=w.studio_cash??0,{primary:M,subline:D}=Xr(w.prize,w.credit??0,{studioCash:$,formatCash:d&&w.prize>0?Y=>Ki(Y):void 0});return e.jsx("li",{className:"group relative overflow-hidden rounded-md border border-white/5 bg-gradient-to-r from-white/[0.04] to-transparent p-[1px] transition-colors hover:bg-white/[0.08]",children:e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-[calc(0.375rem-1px
7)] bg-black/20 px-2.5 py-1.5 sm:px-3 sm:py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-black/40 shadow-inner ring-1 ring-white/5",children:e.jsx(T,{className:`h-3 w-3 ${_}`})}),e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("span",{className:"text-[11px] font-semibold leading-none text-white/95 sm:text-[12px]",children:Vc(w)}),U>1&&e.jsxs("span",{className:"text-[9px] font-medium leading-none text-white/40 sm:text-[10px]",children:[U," winners"]})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-0.5 text-right",children:[e.jsx("span",{className:"text-[12px] font-bold tabular-nums leading-none text-[#fde68a] sm:text-[13px]",children:M}),D&&e.jsx("span",{className:"text-[9px] font-medium leading-none text-[#fde8bd]/60 sm:text-[10px]",children:D})]})]})},j)}return e.jsxs("div",{className:"relative w-full max-w-full rounded-lg",style:{padding:1.5,boxShadow:"0 0 14px rgba(251,191,36,0.18)"},children:[p&&e.jsx(mn,{colorBack:"#9a7b42",colorTint:"#fff8e7",speed:.28,repetition:5,distortion:.18,className:"rounded-lg"}),e.jsxs("div",{className:"relative z-10 overflow-hidden rounded-[calc(0.5rem-1.5px)] px-3.5 py-3 sm:px-4 sm:py-3.5",style:su,children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-white/25 to-transparent","aria-hidden":!0}),e.jsx("div",{className:"relative z-[1] flex flex-col",children:e.jsxs(gi,{delayDuration:180,children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[10px] font-bold uppercase leading-none tracking-[0.14em] text-[#fde8bd] sm:text-[11px]",children:[e.jsx(Dd,{className:"h-3.5 w-3.5 shrink-0 text-[#fde68a] sm:h-4 sm:w-4","aria-hidden":!0}),x?"Prize pool (awarded)":"Prize pool"]}),e.jsx("div",{className:"ml-auto flex flex-col items-end gap-0.5 text-right",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[e.jsx("span",{className:"text-2xl font-bold tabular-nums leading-none tracking-tight text-white sm:text-3xl [text-shadow:0_1px_14px_rgba(0,0,0,0.5)]",children:z}),ie&&e.jsx("span",{className:"text-[11px] font-medium tabular-nums leading-none text-white/80 sm:text-xs",children:ie})]}),se&&e.jsx(tu,{className:"h-6 w-6",iconClassName:"h-4 w-4"}),d&&!x&&f!=null&&t>0&&e.jsx(ru,{bonusPct:f})]})})]}),S>0&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-white/10 bg-black/30 px-2.5 py-2 text-xs text-[#fde8bd]/95 sm:text-sm",children:[e.jsx(wt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#fde68a]"}),e.jsxs("span",{children:["Includes $",S.toLocaleString()," Grand Winner Bonus"]})]})]}),(K.length>0||i>0)&&e.jsxs("div",{className:"mt-4 border-t border-amber-200/25 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.14em] text-[#fde8bd]/65",children:K.length>0?"By placement":"Distribution"}),R&&e.jsx("div",{className:"flex items-center gap-1 rounded-md border border-white/10 bg-black/40 p-0.5",children:P.map((w,j)=>e.jsx("button",{type:"button",onClick:()=>{N(j),A(!1)},"aria-pressed":y===j,className:h("rounded-[calc(0.375rem-2px)] px-2.5 py-1 text-[10px] font-semibold transition-colors",y===j?"bg-white/15 text-white":"text-white/40 hover:bg-white/5 hover:text-white/70"),children:w.name||`Track ${j+1}`},w.id))})]}),e.jsxs(e.Fragment,{children:[E&&e.jsx(eu,{slots:b.slots,allCoEqual:b.allCoEqual,showAnthumBonusFraming:d,className:"mb-4"}),H.length>0&&e.jsxs("ul",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5 list-none p-0",children:[H.map((w,j)=>Z(w,j)),O&&e.jsx("li",{className:"sm:col-span-2",children:e.jsxs("button",{type:"button",onClick:()=>A(w=>!w),"aria-expanded":v,className:"group flex w-full items-center justify-between gap-2 rounded-md border border-white/5 bg-black/20 px-3 py-2 text-left text-[10px] font-medium text-white/50 transition-colors hover:bg-white/[0.06] hover:text-white/80 focus:outline-none focus-visible:ring-1 focus-visible:ring-[#fde68a]
7/60 sm:px-3.5 sm:text-[11px]",children:[e.jsx("span",{children:v?"Show fewer tiers":`+ ${te} more tier${te!==1?"s":""}${!R&&i>0?` in ${i} track${i!==1?"s":""}`:""}`}),e.jsx(Gs,{className:`h-3 w-3 shrink-0 transition-transform group-hover:text-white/70 ${v?"rotate-180":""}`,"aria-hidden":!0})]})})]}),!E&&H.length===0&&i>0&&e.jsxs("p",{className:"rounded-lg border border-white/10 bg-black/35 px-3 py-2.5 text-xs text-white/50 ring-1 ring-inset ring-black/40",children:["Distributed across ",i," track",i!==1?"s":""]})]})]})]})})]})]})}const au={color:"#fff",backdropFilter:"blur(20px) saturate(160%)",WebkitBackdropFilter:"blur(20px) saturate(160%)",background:"linear-gradient(165deg, rgba(255,255,255,0.11) 0%, rgba(255,255,255,0.03) 45%, transparent 100%), linear-gradient(180deg, rgba(16,185,129,0.12) 0%, rgba(6,23,16,0.92) 28%, rgba(3,11,8,0.97) 100%)",boxShadow:"0 1px 0 rgba(255,255,255,0.16) inset, 0 -1px 0 rgba(0,0,0,0.35) inset, inset 0 0 0 1px rgba(255,255,255,0.06)"};function ri(t){return Number.isInteger(t)?`${t}`:`${t.toFixed(1).replace(/\.0$/,"")}`}function ni(t){switch(t.key){case"commission_pct":return`You earn ${t.amount} of every order your ad drives. It counts the product subtotal after discounts, and it keeps paying for as long as the campaign runs.`;case"flat_commission":return t.unit==="call"?`A flat ${t.amount} for every call that's booked and held through your link. Cancelled and no-show calls are reversed.`:`A flat ${t.amount} on every paid order your ad drives, on top of anything else this campaign pays.`;case"trial_bounty":return`You earn ${t.amount} the moment someone starts a free trial through your ad, credited before they pay anything.`;case"approval_bonus_video":return`A one-time ${t.amount} the moment the brand approves your video to run as an ad, whether or not it goes on to drive orders.`;case"approval_bonus_image":return`A one-time ${t.amount} the moment the brand approves your image to run as an ad, whether or not it goes on to drive orders.`;case"spend_share":return t.sentence?`You earn ${t.sentence}. It is worked out once a month from what the brand spends on ads made from your submission, and it keeps paying while those ads run, even before they drive a sale.`:`You earn ${t.amount} of whatever the brand spends running your ad. It is added up once a week, after the week closes, so it keeps paying while your ad is live even before it drives a sale.`;default:return`You earn ${t.amount} ${t.unitLabel}.`}}function ai({part:t,prominent:s=!1}){const[r,a]=n.useState(!1),i=n.useRef(!1),c=d=>f=>{f.pointerType==="mouse"&&a(d)};return e.jsxs(bs,{open:r,onOpenChange:a,children:[e.jsx(Ks,{asChild:!0,children:e.jsxs("button",{type:"button",onPointerDown:d=>{i.current=d.pointerType!=="mouse"},onPointerEnter:c(!0),onPointerLeave:c(!1),onFocus:d=>{d.target.matches(":focus-visible")&&a(!0)},onBlur:()=>a(!1),onClick:d=>{i.current||d.preventDefault()},"aria-label":ni(t),className:"group flex w-full flex-col items-start gap-1 rounded-md border border-emerald-200/20 bg-emerald-400/[0.07] px-2.5 py-2 text-left transition-colors hover:border-emerald-200/45 hover:bg-emerald-400/[0.13] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-emerald-300/70",children:[e.jsxs("span",{className:"flex w-full items-start gap-1.5",children:[e.jsx("span",{className:h("font-bold tabular-nums leading-none tracking-tight text-white [text-shadow:0_1px_14px_rgba(0,0,0,0.5)]",s?"text-2xl sm:text-3xl":"text-lg sm:text-xl"),children:t.amount}),e.jsx(Gi,{className:"ml-auto h-3 w-3 shrink-0 text-white/35 transition-colors group-hover:text-[#6ee7b7]","aria-hidden":!0})]}),e.jsx("span",{className:"text-[9px] font-bold uppercase leading-none tracking-[0.12em] text-[#6ee7b7]",children:t.unitLabel})]})}),e.jsx(vs,{side:"top",align:"start",onOpenAutoFocus:d=>d.preventDefault(),onCloseAutoFocus:d=>d.preventDefault(),className:"w-64 border-emerald-200/20 bg-[#08150f] p-3 text-[11.5px] leading-snug text-white/80",children:ni(t)})]})}function dr({index:t,children:s}){return e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx("span",{className:"mt-px flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border border-emerald-300/30 bg-emerald-400/10 text-[9px] font-bold leading-none text-emerald-200",children:t}),e.jsx("span",{className:"min-w-0 text-[12px] leading-relaxed text-white/75",children:s})]})}function iu({terms:t,submissionsClosed:s=!1}){const[r,a]=n.useState(!1);n.useEffect(()=>{a(!0)},[]);const i=t?.discount_enabled&&t.discount_pct?t.discount_pct:null,c=t?.attribution_window_days??null,d=t===null,f=t?.conversion_kind==="call",x=Number(t?.flat_commission_cents??0),p=x>0,m=Dr(x),v=!f&&t&&t.commission_pct>0?t.commission_pct:null,A=v!==null&&p,y=f?0:Number(t?.trial_bounty_cents??0),N=Dr(y),P=Number(t?.spend_share_pct??0),R=Number(t?.approval_bonus_video_cents??0),B=Number(t?.approval_bonus_image_cents??0),S=_i({commissionPct:t?.commission_pct,flatCommissionCents:t?.flat_commission_cents,trialBountyCents:t?.trial_bounty_cents,approvalBonusVideoCents:t?.approval_bonus_video_cents,approvalBonusImageCents:t?.approval_bonus_image_cents,spendSharePct:P,spendBasis:t?.spend_basis,conversionKind:t?.conversion_kind}),K=t?.spend_basis==="contract_tiered",b=S.parts,F=b.length>1,E=b.length%2===1?b[0]:null,Q=E?b.slice(1):b,O=F&&!S.sameUnit?"You earn":S.tagLabel,H=S.unit==="video"||S.unit==="image",te=f?"booked calls":y>0?v!==null||p?"orders and free-trial signups":"free-trial signups":"store orders",z=[];return f&&p?z.push(`You earn a flat ${m} for each call that's booked and held; cancelled and no-show calls are reversed.`):A?z.push(`The ${ri(v)}% share counts product subtotals after discounts and refunds; the flat ${m} applies to every paid order and is reversed if the order is fully refunded.`):p?z.push(`You earn a flat ${m} for each paid order;
7 refunded or returned orders are reversed.`):v!==null&&z.push("Sales count product subtotals after discounts and refunds; earnings from returned or refunded orders are reversed."),y>0&&z.push(`Free-trial signups pay ${N} each, credited at signup.`),P>0&&z.push(K?"Your share of ad spend is worked out once a month from what the brand spent on ads made from your submission, and paid after the brand pays for that month.":"Your share of ad spend is worked out once a week, after the week closes, from what the brand spent running your ad."),R>0&&z.push(`The ${Dr(R)} video bonus pays once per approved video.`),B>0&&z.push(`The ${Dr(B)} image bonus pays once per approved image.`),z.length===0&&z.push("Sales count product subtotals after discounts and refunds; earnings from returned or refunded orders are reversed."),e.jsxs("div",{className:"relative w-full max-w-full rounded-lg",style:{padding:1.5,boxShadow:"0 0 14px rgba(16,185,129,0.2)"},children:[r&&e.jsx(mn,{colorBack:"#2f7b5c",colorTint:"#eafff4",speed:.28,repetition:5,distortion:.18,className:"rounded-lg"}),e.jsxs("div",{className:"relative z-10 overflow-hidden rounded-[calc(0.5rem-1.5px)] px-3.5 py-3 sm:px-4 sm:py-3.5",style:au,children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-white/25 to-transparent","aria-hidden":!0}),e.jsxs("div",{className:"relative z-[1] flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[10px] font-bold uppercase leading-none tracking-[0.14em] text-[#d3f8e8] sm:text-[11px]",children:[f?e.jsx(il,{className:"h-3.5 w-3.5 shrink-0 text-[#6ee7b7] sm:h-4 sm:w-4","aria-hidden":!0}):e.jsx(ji,{className:"h-3.5 w-3.5 shrink-0 text-[#6ee7b7] sm:h-4 sm:w-4","aria-hidden":!0}),O]}),!F&&e.jsx("div",{className:"ml-auto flex items-baseline justify-end gap-1 text-right",children:e.jsx("span",{className:"text-2xl font-bold tabular-nums leading-none tracking-tight text-white sm:text-3xl [text-shadow:0_1px_14px_rgba(0,0,0,0.5)]",children:S.amount??"â"})})]}),F?e.jsxs("div",{className:"mt-2.5 flex flex-col gap-1.5",children:[E&&e.jsx(ai,{part:E,prominent:!0}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:Q.map(ie=>e.jsx(ai,{part:ie},ie.key))})]}):e.jsx("p",{className:"mt-1.5 text-right text-[11px] leading-snug text-white/60",children:f&&p?"for every call that's booked through your ad":p?"a flat payout on every paid order your ad drives":v!==null?"of every order your ad drives, for as long as the campaign runs":y>0?"for every free-trial signup your ad drives, credited at signup":P>0?K?"of what the brand spends on ads made from your submission, worked out monthly":"of what the brand spends running your ad, added up weekly":H?"a one-time bonus for every submission the brand approves":d?"You earn on the results your ad drives â this campaign's rate isn't available right now.":"You earn on the results your ad drives. The brand hasn't set a rate for this campaign yet."}),s&&e.jsx("div",{className:"mt-3 rounded-md border border-violet-300/25 bg-violet-400/10 px-2.5 py-2",children:e.jsxs("p",{className:"text-[11.5px] leading-snug text-white/85",children:[e.jsx("span",{className:"font-semibold text-white",children:"Submissions are closed"})," for new entries."," ",S.unit==="video"||S.unit==="image"?"Approved ads have already earned their bonus.":S.unit==="ad_spend"?"Ads already approved keep earning while the brand runs them.":`Ads already approved keep earning on every ${S.unit==="call"?"call they book":S.unit==="trial"?"free-trial signup they drive":"order they drive"}.`]})}),i!==null&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-md border border-white/10 bg-black/30 px-2.5 py-1.5",children:[e.jsx(Bd,{className:"h-3.5 w-3.5 shrink-0 text-[#6ee7b7]","aria-hidden":!0}),e.jsxs("span",{className:"text-[11.5px] leading-snug text-white/80",children:["Shoppers get ",e.jsxs("span",{className:"font-semibold text-white",children:[ri(i),"% off"]})," through your link, so it converts better"]})]}),e.jsxs("div",{className:"mt-4 border-t border-emerald-200/25 pt-3.5",children:[e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.14em] text-[#d3f8e8]/65",children:"How you get paid"}),e.jsxs("ol",{className:"mt-2.5 space-y-2",children:[e.jsx(dr,{index:1,children:s?"Entries were submitted to this campaign while it was open.":"Submit your work to this campaign."}),e.jsx(dr,{index:2,children:"It clears our quality check, then the brand approves it to run as an ad."}),e.jsx(dr,{index:3,children:"The brand launches it from their own ad account, on channels like Meta."}),e.jsx(dr,{index:4,children:K?e.jsx(e.Fragment,{children:"We read what the brand spends on ads made from your submission straight from its ad account."}):f?e.jsxs(e.Fragment,{children:["Our tracking matches booked calls back to your ad",c?` for ${c} ${qt(c,"day")} after each click`:"",", through your link."]}):e.jsxs(e.Fragment,{children:["Our tracking matches ",te," back to your ad",c?` for ${c} ${qt(c,"day")} after each click`:"",", through your ",i!==null?"ad link and discount code":"ad link","."]})}),e.jsx(dr,{index:5,children:f&&p?e.jsxs(e.Fragment,{children:["You earn your ",m," once the call is booked and held. It pays out automatically on a regular cycle; cancelled and no-show calls are reversed."]}):y>0&&v===null&&!p?e.jsx(e.Fragment,{children:"Free-trial payouts are credited the moment the signup happens, and pay out automatically on a regular cycle."}):y>
70?e.jsx(e.Fragment,{children:"Order earnings are credited as soon as each order is paid, and free-trial payouts the moment the signup happens. Everything pays out automatically on a regular cycle, and refunded orders are deducted."}):P>0&&v===null&&!p&&K?e.jsx(e.Fragment,{children:"Your share of ad spend is worked out once a month, and pays out automatically on a regular cycle after the brand pays for that month."}):P>0&&v===null&&!p?e.jsx(e.Fragment,{children:"Your share of ad spend is added up once a week, after the week closes, and pays out automatically on a regular cycle."}):e.jsx(e.Fragment,{children:"Your earnings are credited as soon as each order is paid and pay out automatically on a regular cycle. Refunded orders are deducted."})})]})]}),e.jsxs("p",{className:"mt-3 border-t border-white/10 pt-2.5 text-[10px] leading-relaxed text-white/45",children:[`${z.join(" ")} `,"You keep ownership of your work, and the brand gets a license to run it as an ad."," ",e.jsx("a",{href:"/terms#section-7c",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 text-white/60 hover:text-white/80",children:"See the campaign terms"}),"."]})]})]})]})}const ou={color:"#fff",backdropFilter:"blur(20px) saturate(160%)",WebkitBackdropFilter:"blur(20px) saturate(160%)",background:"linear-gradient(165deg, rgba(255,255,255,0.11) 0%, rgba(255,255,255,0.03) 45%, transparent 100%), linear-gradient(180deg, rgba(16,185,129,0.12) 0%, rgba(6,23,16,0.92) 28%, rgba(3,11,8,0.97) 100%)",boxShadow:"0 1px 0 rgba(255,255,255,0.16) inset, 0 -1px 0 rgba(0,0,0,0.35) inset, inset 0 0 0 1px rgba(255,255,255,0.06)"};function lu({challengeId:t}){const{data:s,isLoading:r}=gd(t),[a,i]=n.useState(!1);if(n.useEffect(()=>{i(!0)},[]),r)return null;const c=(s??[]).filter(A=>Vl(A));if(c.length===0)return null;const d=c.reduce((A,y)=>A+y.impressions,0),f=c.reduce((A,y)=>A+y.link_clicks,0),x=c.reduce((A,y)=>A+Wl(y),0),p=c.reduce((A,y)=>A+y.earnings_ready_cents+y.earnings_paid_cents+y.earnings_pending_cents,0),m=c[0].conversion_kind,v=d>0?`${Ea(d)} views`:f>0?`${Ea(f)} link clicks`:"0 views";return e.jsxs("div",{className:"relative w-full max-w-full rounded-lg",style:{padding:1.5,boxShadow:"0 0 14px rgba(16,185,129,0.2)"},children:[a&&e.jsx(mn,{colorBack:"#2f7b5c",colorTint:"#eafff4",speed:.28,repetition:5,distortion:.18,className:"rounded-lg"}),e.jsxs("div",{className:"relative z-10 overflow-hidden rounded-[calc(0.5rem-1.5px)] px-3.5 py-3.5 sm:px-4",style:ou,children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-white/25 to-transparent","aria-hidden":!0}),e.jsxs("div",{className:"relative z-[1] flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-emerald-300/25 bg-emerald-400/10",children:e.jsx(Oo,{className:"h-3.5 w-3.5 text-[#6ee7b7]","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-[#d3f8e8]",children:"Active ad"}),e.jsx("p",{className:"mt-1 text-sm font-semibold leading-snug text-white [text-shadow:0_1px_10px_rgba(0,0,0,0.35)]",children:c.length===1?"Your video has an active ad":`${c.length} of your videos have active ads`}),e.jsxs("p",{className:"mt-1 text-[12px] leading-relaxed text-white/65",children:[v,x>0?` · ${x} ${Gl(m,x).toLowerCase()}`:"",p>0?` · ${Hl(p)} earned`:""]})]})]}),e.jsxs(Mt,{to:"/creator/ad-performance",className:"inline-flex h-9 w-full items-center justify-center gap-1.5 rounded-brand-button border border-emerald-200/25 bg-emerald-400/15 px-3 text-[13px] font-semibold text-[#d3f8e8] transition-colors hover:border-emerald-200/40 hover:bg-emerald-400/25 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/40",children:["See how your ad is performing",e.jsx(nd,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0})]}),e.jsx(Mt,{to:"/creator-submission-agreement",className:"mt-2 inline-block text-[11px] font-medium text-white/55 underline-offset-2 hover:text-white/80 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400/40",children:"What running as an ad means"})]})]})]})}function du(t){if(!t)return{type:"other"};const s=t.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([A-Za-z0-9_-]+)/);if(s)return{type:"youtube",id:s[1]};const r=t.match(/vimeo\.com\/(?:video\/)?(\d+)/);return r?{type:"vimeo",id:r[1]}:{type:"other"}}function cu(t,s){return t==="youtube"?`https://www.youtube.com/embed/${s}`:t==="vimeo"?`https://player.vimeo.com/video/${s}`:""}const uu=n.memo(function({media:s,index:r,onMediaClick:a}){const i=n.useRef(null),[c,d]=n.useState(!1);if(n.useEffect(()=>{const m=i.current;if(!m)return;const v=new IntersectionObserver(A=>{A.some(y=>y.isIntersecting)&&(d(!0),v.disconnect())},{root:null,rootMargin:"160px",threshold:.01});return v.observe(m),()=>v.disconnect()},[]),s.type==="pdf")return e.jsx("div",{className:"space-y-1",children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"group relative flex aspect-square w-full flex-col items-center justify-center gap-1 overflow-hidden rounded-lg border border-border/40 bg-gradient-to-br from-rose-500/10 to-rose-500/[0.03] px-2 text-center transition-colors hover:border-border/60 hover:from-rose-500/20",title:s.filename||s.caption||"Open PDF",children:[e.jsx(ki,{className:"h-7 w-7 text-rose-400/85"}),e.jsx("span",{className:"line-clamp-2 break-all text-[10px] text-foreground
7/85",children:s.filename||s.caption||"PDF"}),e.jsx("span",{className:"absolute left-1.5 top-1.5 rounded bg-rose-500/90 px-1 py-0.5 text-[8px] font-medium text-white",children:"PDF"})]})});const f=s.type==="image"||s.type==="video"?Hi(s):null,x=f?{aspectRatio:String(f)}:void 0,p=f?"":"aspect-square";return e.jsx("div",{className:"mb-2 break-inside-avoid space-y-1",children:e.jsxs("button",{ref:i,type:"button",onClick:()=>a(s),className:"group relative w-full cursor-pointer overflow-hidden rounded-lg border border-border/40 text-left transition-colors hover:border-border/60",children:[s.type==="image"?c?e.jsx("img",{src:Xn(s,"card"),alt:s.caption||`Reference ${r+1}`,className:h("w-full object-cover",p),style:x,loading:"lazy",decoding:"async"}):e.jsx("div",{className:h("w-full bg-muted/60",p),style:x,"aria-hidden":!0}):c?e.jsxs("div",{className:h("relative bg-card",p),style:x,children:[e.jsx("video",{src:Yi(s.url),className:"h-full w-full object-cover",muted:!0,playsInline:!0,preload:"metadata"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/30 transition-colors group-hover:bg-background/20",children:e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted/90 backdrop-blur-sm",children:e.jsx(Os,{className:"ml-0.5 h-5 w-5 fill-white text-foreground"})})})]}):e.jsx("div",{className:h("relative flex w-full items-center justify-center bg-muted/60",p),style:x,"aria-hidden":!0,children:e.jsx(Os,{className:"h-8 w-8 text-muted-foreground/40"})}),s.caption&&e.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-visible:opacity-100",children:e.jsx("p",{className:"truncate text-[11px] text-foreground/90",children:s.caption})})]})})});function mu({referenceMedia:t,usefulLinks:s,exampleUrls:r,onDownloadAll:a,isDownloading:i,onMediaClick:c,variant:d="default"}){const f=t&&t.length>0,x=s&&s.length>0,p=r&&r.length>0,[m,v]=n.useState(!1),[A,y]=n.useState(!1);if(!f&&!x&&!p)return null;const N=(t?.length??0)+(s?.length??0)+(r?.length??0),P=p?A?r:r.slice(0,2):[],R=t?.slice(0,3)??[],S=e.jsxs("div",{className:"space-y-4",children:[f&&e.jsx("div",{className:h("columns-1 gap-2 sm:columns-2"),children:t.map((K,b)=>e.jsx(uu,{media:K,index:b,onMediaClick:c},`${K.url}-${b}`))}),x&&e.jsxs("div",{children:[e.jsx("h4",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Useful links"}),e.jsx("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:gap-x-6 sm:gap-y-1",children:s.map((K,b)=>e.jsxs("a",{href:K.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm leading-snug text-foreground/90 underline-offset-4 transition-colors hover:text-foreground hover:underline",children:[e.jsx(vr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),K.name]},b))})]}),p&&P.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Inspiration"}),e.jsx("div",{className:"grid grid-cols-1 gap-3",children:P.map((K,b)=>{const{type:F,id:E}=du(K);return F!=="other"&&E?e.jsx("div",{className:"aspect-video overflow-hidden rounded-lg border border-border/40 bg-foreground
7/[0.02]",children:e.jsx("iframe",{src:cu(F,E),className:"h-full w-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,title:`Inspiration ${b+1}`,loading:"lazy","data-sentry-ignore":"true","data-sentry-block":"true"})},b):e.jsxs("a",{href:K,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 rounded-lg border border-border/40 bg-foreground/[0.02] p-3 transition-colors hover:border-border/60",children:[e.jsx(Os,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"break-all text-sm text-foreground/90 transition-colors hover:text-foreground",children:K})]},b)})}),p&&r.length>2&&!A&&e.jsxs(Ee,{variant:"ghost",size:"sm",className:"h-auto px-0 py-1 text-xs text-muted-foreground hover:bg-transparent hover:text-foreground",onClick:()=>y(!0),children:["Show ",r.length-2," more"]})]})]});return d==="inline"?e.jsxs("section",{className:"min-w-0","aria-label":"Brand kit",children:[f&&t.length>0||p?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Brand kit"}),f&&t.length>0&&e.jsxs(Ee,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:K=>{K.preventDefault(),a()},disabled:i,children:[i?e.jsx(xt,{className:"h-3 w-3 animate-spin"}):e.jsx(Dn,{className:"h-3 w-3"}),"Download all"]})]}):null,S]}):e.jsxs("div",{className:"relative rounded-xl p-px overflow-hidden brief-glow-wrapper",children:[e.jsx("div",{className:"absolute inset-0 rounded-xl brief-glow-spin",style:{background:"conic-gradient(from var(--brief-glow-angle, 0deg), transparent 0%, transparent 60%, #a855f7 75%, #7c3aed 85%, #a855f7 95%, transparent 100%)"}}),e.jsx("div",{className:"absolute inset-[-2px] rounded-xl brief-glow-spin opacity-40 blur-sm",style:{background:"conic-gradient(from var(--brief-glow-angle, 0deg), transparent 0%, transparent 55%, #a855f7 75%, #7c3aed 85%, #a855f7 95%, transparent 100%)"}}),e.jsxs("div",{className:"relative rounded-[11px] bg-card/90 overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>v(K=>!K),"aria-expanded":m,className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-muted/40 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(Fs,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:"Brand Kit"}),!m&&R.length>0&&e.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[R.map((K,b)=>e.jsx("div",{className:"w-6 h-6 rounded overflow-hidden bg-muted flex-shrink-0 relative border border-border/60",children:K.type==="image"?e.jsx("img",{src:Xn(K,"card"),alt:"",className:"w-full h-full object-cover"}):K.type==="pdf"?e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-rose-500/10",children:e.jsx(ki,{className:"w-3 h-3 text-rose-400/85"})}):e.jsx("video",{src:Yi(K.url),className:"w-full h-full object-cover",muted:!0,playsInline:!0,preload:"metadata"})},b)),N>3&&e.jsxs("span",{className:"text-[10px] text-muted-foreground/70 ml-0.5",children:["+",N-3]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m&&f&&t.length>1&&e.jsxs(Ee,{variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground hover:text-foreground gap-1.5",onClick:K=>{K.stopPropagation(),a()},disabled:i,children:[i?e.jsx(xt,{className:"h-3 w-3 animate-spin"}):e.jsx(Dn,{className:"h-3 w-3"}),"Download All"]}),m?e.jsx(Fi,{className:"h-3.5 w-3.5 text-muted-foreground"}):e.jsx(Gs,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]}),m&&e.jsx("div",{className:"space-y-4 p-3",children:S})]})]})}const oo=["tracked_competitor"];function pu({businessId:t,contestId:s,enabled:r=!0,className:a}){const[i,c]=n.useState("all"),[d,f]=n.useState(null),x=n.useRef(null),p=n.useRef(null),m=Qi({businessId:t,contestId:s,sourceKinds:oo,mediaType:i,limit:48,enabled:r&&!!t&&!!s}),v=m.ads,A=n.useMemo(()=>Fd(v,i),[v,i]),y=m.data?.totals,N=n.useMemo(()=>!y&&v.length===0?null:Od(v,y?{visible:y.visible,videos:y.videos,images:y.images}:null),[v,y]);n.useEffect(()=>{const R=x.current,B=p.current;
7if(!R||!B||!m.hasNextPage||m.isFetchingNextPage)return;const S=new IntersectionObserver(K=>{K.some(b=>b.isIntersecting)&&m.fetchNextPage()},{root:R,rootMargin:"240px 0px",threshold:0});return S.observe(B),()=>S.disconnect()},[m.hasNextPage,m.isFetchingNextPage,m.fetchNextPage,A.length]),n.useEffect(()=>{if(!d)return;const R=Tn(d);A.some(B=>Tn(B)===R)||f(null)},[A,d]);const P=n.useCallback(R=>{f(R)},[]);return e.jsxs("div",{className:h("flex min-h-0 w-full flex-col gap-4",a),children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Inspiration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Contest-curated Meta ads plus this brand's monitored competitors â study the creative, then make your own."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[[{id:"all",label:"All",icon:null,count:N?.all},{id:"video",label:"Videos",icon:wd,count:N?.videos},{id:"image",label:"Images",icon:gr,count:N?.images}].map(R=>{const B=R.icon,S=i===R.id;return e.jsxs("button",{type:"button",onClick:()=>c(R.id),"aria-pressed":S,className:h("inline-flex h-8 items-center gap-1.5 rounded-full border px-3 text-xs font-medium transition-colors",S?"border-primary/40 bg-primary/15 text-foreground":"border-border bg-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground"),children:[B?e.jsx(B,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,R.label,typeof R.count=="number"?e.jsx("span",{className:"tabular-nums opacity-70",children:R.count}):null]},R.id)}),e.jsxs(Ee,{type:"button",size:"sm",variant:"outline",className:"h-8 gap-1.5 rounded-full",disabled:m.isFetching,onClick:()=>void m.refetch(),children:[m.isFetching?e.jsx(xt,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(xi,{className:"h-3.5 w-3.5"}),"Refresh"]})]})]}),e.jsx("div",{ref:x,className:"min-h-[280px] w-full",children:m.isLoading?e.jsxs("div",{className:"flex min-h-[280px] items-center justify-center gap-2 text-sm text-muted-foreground",children:[e.jsx(xt,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),"Loading inspirationâ¦"]}):m.error?e.jsxs("div",{className:"flex min-h-[280px] flex-col items-center justify-center gap-3 px-4 text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:m.error instanceof Error?m.error.message:"Failed to load inspiration"}),e.jsx(Ee,{type:"button",size:"sm",variant:"outline",onClick:()=>void m.refetch(),children:"Try again"})]}):A.length===0?e.jsxs("div",{className:"flex min-h-[280px] flex-col items-center justify-center gap-2 px-6 text-center",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"No ads in this filter"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Try All, or switch between Videos and Images."})]}):e.jsxs("div",{children:[e.jsx(zd,{children:A.map(R=>e.jsx(Kd,{ad:R,tone:"dark",likedByMe:!1,likeCount:0,hideLike:!0,showMonitorBrand:!1,onOpen:B=>P(B),onToggleLike:()=>{}},Tn(R)))}),e.jsx("div",{ref:p,className:"pt-1",children:m.isFetchingNextPage?e.jsxs("div",{className:"flex h-10 items-center justify-center gap-2",role:"status","aria-live":"polite",children:[e.jsx(xt,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground","aria-hidden":!0}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading more"})]}):m.hasNextPage?e.jsx("div",{className:"flex h-10 items-center justify-center",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Scroll for more"})}):A.length>0?e.jsx("div",{className:"flex h-10 items-center justify-center",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"All ads loaded"})}):null})]})}),e.jsx(qd,{open:!!d,ad:d,list:A,onClose:()=>f(null),onSelectAd:f})]})}function hu(t,s,r=!0){const a=Qi({businessId:t,contestId:s,sourceKinds:oo,mediaType:"all",limit:1,enabled:r&&!!t&&!!s}),i=a.data?.totals?.visible??a.ads.length;return{isLoading:a.isLoading,hasInspiration:i>0,visibleCount:i}}function fu({brand:t,isFull:s,maxSelectionsPerBrand:r,atCreatorLimit:a,isActive:i,onPickerClick:c,isReserving:d,canReserve:f}){const x=!f||s||a||d;return e.jsxs("button",{type:"button",disabled:!i||x,onClick:()=>c(t),className:h("w-full rounded-lg border px-3.5 py-3 flex items-center gap-3 transition-colors text-left",x?"border-border bg-card/50 opacity-40 cursor-not-allowed":"border-border bg-card/50 hover:border-violet-500/40 hover:bg-violet-500/[0.04] cursor-pointer"),children:[t.brand_logo_url?e.jsx("img",{src:t.brand_logo_url,alt:"",className:"w-9 h-9 rounded-md object-contain shrink-0 bg-card/10"}):e.jsx(js,{className:"w-5 h-5 text-text-subtle shrink-0"}),e.jsx("span",{className:"text-[13px] font-medium text-foreground truncate flex-1 leading-tight",children:t.brand_name}),e.jsxs("span",{className:h("text-[11px] font-mono shrink-0",s?"text-red-400":"text-muted-foreground"),children:[t.reservation_count,"/",r]})]})}function xu({brand:t,hasSubmitted:s,isActive:r,onSubmit:a,onCancel:i,isCancelling:c}){return e.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 space-y-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-muted border border-border flex items-center justify-center shrink-0 overflow-hidden",children:t.brand_logo_url?e.jsx("img",{src:t.brand_logo_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(js,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground truncate",children:t.brand_name}),t.brand_category&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:t.brand_category})]}),r&&!s&&e.jsx("button",{type:"button",onClick:()=>
7i(t.id),disabled:c,className:"text-muted-foreground hover:text-red-400 transition-colors p-1 -m-1",title:"Release reservation","aria-label":"Release reservation",children:c?e.jsx(xt,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(qs,{className:"w-3.5 h-3.5"})})]}),t.brand_description&&e.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed line-clamp-2",children:t.brand_description}),t.brand_website&&e.jsxs("a",{href:t.brand_website.startsWith("http")?t.brand_website:`https://${t.brand_website}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(vr,{className:"w-3 h-3"}),t.brand_website.replace(/^https?:\/\//,"").replace(/\/$/,"")]}),r&&e.jsx("div",{className:"pt-1",children:s?e.jsxs("div",{className:"flex items-center justify-center gap-1.5 rounded-lg border border-emerald-500/25 bg-emerald-500/10 py-2 text-emerald-400",children:[e.jsx(Jt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-semibold",children:"Done"})]}):e.jsx(Bs,{fullWidth:!0,label:"Submit Video",onClick:()=>a(t.id)})})]})}function gu({brandOptions:t,myReservedBrandIds:s,maxSelectionsPerBrand:r,maxBrandsPerCreator:a,isLoading:i,onReserve:c,onCancel:d,onSubmit:f,isReserving:x,isCancelling:p,submittedBrandIds:m=new Set,isActive:v,isPaused:A=!1,kindNoun:y,id:N,canReserve:P=!0}){const R=s.size,B=R>=a,[S,K]=n.useState(null),b=n.useMemo(()=>t.filter(z=>s.has(z.id)),[t,s]),F=n.useMemo(()=>t.filter(z=>!s.has(z.id)),[t,s]),E=b.length>0,Q=!B;function O(z){P&&K(z)}function H(){S&&c(S.id),K(null)}if(!t.length&&!i)return null;const te=a-R;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{id:N,className:"space-y-3 scroll-mt-24",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"h-4 w-4 text-violet-400"}),e.jsx("h3",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:"Brand Selection"})]}),e.jsxs("span",{className:h("text-[11px]",E?"text-violet-300":"text-muted-foreground"),children:[R,"/",a," reserved"]})]}),i&&e.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[e.jsx(xt,{className:"h-4 w-4 animate-spin mr-2"}),"Loading brandsâ¦"]}),!i&&e.jsxs("div",{className:"space-y-4",children:[E&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"grid grid-cols-2 gap-3",children:b.map(z=>e.jsx(xu,{brand:z,hasSubmitted:m.has(z.id),isActive:v,onSubmit:f,onCancel:d,isCancelling:p},z.id))})}),Q&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2",children:e.jsx("span",{className:"text-[11px] text-muted-foreground",children:v?P?R===0?`Click a brand to reserve it. You can pick up to ${a}.`:`${te} slot${te===1?"":"s"} remaining. Pick another brand, or submit above.`:"Reserving is limited to eligible creators for this contest.":A?`Brand selection is paused while this ${y??"contest"} is not taking entries. It reopens with the ${y??"contest"}.`:"Brand selection is closed for this contest."})}),v&&e.jsx("div",{className:"grid grid-cols-2 gap-2",children:F.map(z=>{const ie=z.reservation_count>=r;
7return e.jsx(fu,{brand:z,isFull:ie,maxSelectionsPerBrand:r,atCreatorLimit:B,isActive:v,onPickerClick:O,isReserving:x,canReserve:P},z.id)})})]})]})]}),e.jsx(sn,{open:!!S,onOpenChange:z=>{z||K(null)},children:e.jsx(rn,{className:"max-w-sm bg-background border-border",children:S&&e.jsxs(e.Fragment,{children:[e.jsxs(nn,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-muted border border-border flex items-center justify-center shrink-0 overflow-hidden",children:S.brand_logo_url?e.jsx("img",{src:S.brand_logo_url,alt:"",className:"w-full h-full object-contain p-1"}):e.jsx(js,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(an,{className:"text-base font-semibold text-foreground leading-snug",children:S.brand_name}),S.brand_category&&e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:S.brand_category})]})]}),S.brand_website&&e.jsxs("a",{href:S.brand_website.startsWith("http")?S.brand_website:`https://${S.brand_website}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-[12px] text-violet-300 hover:text-violet-200 transition-colors",onClick:z=>z.stopPropagation(),children:[e.jsx(vr,{className:"w-3 h-3 shrink-0"}),S.brand_website.replace(/^https?:\/\//,"").replace(/\/$/,"")]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-card border border-border px-3 py-2",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Slots available"}),e.jsxs("span",{className:"text-[11px] font-mono text-foreground",children:[r-S.reservation_count," of ",r]})]}),S.brand_description?e.jsx(zs,{className:"text-[12px] text-muted-foreground leading-relaxed",children:S.brand_description}):e.jsxs(zs,{className:"sr-only",children:["Reserve ",S.brand_name," as your brand for this contest."]})]}),e.jsxs(on,{children:[e.jsx(ln,{className:"bg-transparent border-border text-muted-foreground hover:bg-muted hover:text-foreground",children:"Cancel"}),e.jsx(dn,{onClick:H,className:"bg-violet-600 text-white hover:bg-violet-500",children:"Reserve Brand"})]})]})})})]})}function lo(t){const s=t.toLowerCase();return s.includes("/storage/v1/object/")||s.includes(".supabase.co/storage/")||s.includes(".r2.dev")||s.includes(".r2.cloudflarestorage.com")||s.includes("media.anthum.ai")||s.includes("media-dev.anthum.ai")}function bu({product:t,isFull:s,maxSelectionsPerProduct:r,atCreatorLimit:a,isActive:i,onPickerClick:c,isReserving:d,canReserve:f}){const x=!f||s||a||d;return e.jsxs("button",{type:"button",disabled:!i||x,onClick:()=>c(t),className:h("w-full rounded-lg border px-3.5 py-3 flex items-center gap-3 transition-colors text-left",x?"border-border bg-card/50 opacity-40 cursor-not-allowed":"border-border bg-card/50 hover:border-violet-500/40 hover:bg-violet-500/[0.04] cursor-pointer"),children:[t.product_image_url?e.jsx("img",{src:t.product_image_url,alt:"",className:"w-9 h-9 rounded-md object-contain shrink-0 bg-card/10"}):e.jsx(ss,{className:"w-5 h-5 text-text-subtle shrink-0"}),e.jsx("span",{className:"text-[13px] font-medium text-foreground truncate flex-1 leading-tight",children:t.product_name}),e.jsxs("span",{className:h("text-[11px] font-mono shrink-0",s?"text-red-400":"text-muted-foreground"),children:[t.reservation_count,"/",r]})]})}function vu({product:t,hasSubmitted:s,isActive:r,onSubmit:a,onCancel:i,isCancelling:c}){return e.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 space-y-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-muted border border-border flex items-center justify-center shrink-0 overflow-hidden",children:t.product_image_url?e.jsx("img",{src:t.product_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(ss,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground truncate",children:t.product_name}),t.product_category&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:t.product_category})]}),r&&!s&&e.jsx("button",{type:"button",onClick:()=>
7i(t.id),disabled:c,className:"text-muted-foreground hover:text-red-400 transition-colors p-1 -m-1",title:"Release reservation","aria-label":"Release reservation",children:c?e.jsx(xt,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(qs,{className:"w-3.5 h-3.5"})})]}),t.product_description&&e.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed line-clamp-2",children:t.product_description}),t.product_url&&!lo(t.product_url)&&e.jsxs("a",{href:t.product_url.startsWith("http")?t.product_url:`https://${t.product_url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(vr,{className:"w-3 h-3"}),t.product_url.replace(/^https?:\/\//,"").replace(/\/$/,"")]}),r&&e.jsx("div",{className:"pt-1",children:s?e.jsxs("div",{className:"flex items-center justify-center gap-1.5 rounded-lg border border-emerald-500/25 bg-emerald-500/10 py-2 text-emerald-400",children:[e.jsx(Jt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-semibold",children:"Done"})]}):e.jsx(Bs,{fullWidth:!0,label:"Submit Video",onClick:()=>a(t.id)})})]})}function wu({productOptions:t,myReservedProductIds:s,maxSelectionsPerProduct:r,maxProductsPerCreator:a,isLoading:i,onReserve:c,onCancel:d,onSubmit:f,isReserving:x,isCancelling:p,submittedProductIds:m=new Set,isActive:v,isPaused:A=!1,kindNoun:y,id:N,canReserve:P=!0}){const R=s.size,B=R>=a,[S,K]=n.useState(null),b=n.useMemo(()=>t.filter(z=>s.has(z.id)),[t,s]),F=n.useMemo(()=>t.filter(z=>!s.has(z.id)),[t,s]),E=b.length>0,Q=!B;function O(z){P&&K(z)}function H(){S&&c(S.id),K(null)}if(!t.length&&!i)return null;const te=a-R;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{id:N,className:"space-y-3 scroll-mt-24",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ss,{className:"h-4 w-4 text-violet-400"}),e.jsx("h3",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-medium",children:"Product Selection"})]}),e.jsxs("span",{className:h("text-[11px]",E?"text-violet-300":"text-muted-foreground"),children:[R,"/",a," reserved"]})]}),i&&e.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[e.jsx(xt,{className:"h-4 w-4 animate-spin mr-2"}),"Loading productsâ¦"]}),!i&&e.jsxs("div",{className:"space-y-4",children:[E&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"grid grid-cols-2 gap-3",children:b.map(z=>e.jsx(vu,{product:z,hasSubmitted:m.has(z.id),isActive:v,onSubmit:f,onCancel:d,isCancelling:p},z.id))})}),Q&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2",children:e.jsx("span",{className:"text-[11px] text-muted-foreground",children:v?P?R===0?`Click a product to reserve it. You can pick up to ${a}.`:`${te} slot${te===1?"":"s"} remaining. Pick another product, or submit above.`:"Reserving is limited to eligible creators for this contest.":A?`Product selection is paused while this ${y??"contest"} is not taking entries. It reopens with the ${y??"contest"}.`:"Product selection is closed for this contest."})}),v&&e.jsx("div",{className:"grid grid-cols-2 gap-2",children:F.map(z=>{const ie=z.reservation_count>=r;return e.jsx(bu,{product:z,isFull:ie,maxSelectionsPerProduct:r,atCreatorLimit:B,isActive:v,onPickerClick:O,isReserving:x,canReserve:P},z.id)})})]})]})]}),e.jsx(sn,{open:!!S,onOpenChange:z=>{z||K(null)},children:e.jsx(rn,{className:"max-w-sm bg-background border-border",children:S&&e.jsxs(e.Fragment,{children:[e.jsxs(nn,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-muted border border-border flex items-center justify-center shrink-0 overflow-hidden",children:S.product_image_url?e.jsx("img",{src:S.product_image_url,alt:"",className:"w-full h-full object-contain p-1"}):e.jsx(ss,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(an,{className:"text-base font-semibold text-foreground leading-snug",children:S.product_name}),S.product_category&&e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:S.product_category})]})]}),S.product_url&&!lo(S.product_url)&&e.jsxs("a",{href:S.product_url.startsWith("http")?S.product_url:`https://${S.product_url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-[12px] text-violet-300 hover:text-violet-200 transition-colors",onClick:z=>z.stopPropagation(),children:[e.jsx(vr,{className:"w-3 h-3 shrink-0"}),S.product_url.replace(/^https?:\/\//,"").replace(/\/$/,"")]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-card border border-border px-3 py-2",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Slots available"}),e.jsxs("span",{className:"text-[11px] font-mono text-foreground",children:[r-S.reservation_count," of ",r]})]}),S.product_description?e.jsx(zs,{className:"text-[12px] text-muted-foreground leading-relaxed",children:S.product_description}):e.jsxs(zs,{className:"sr-only",children:["Reserve ",S.product_name," as your product for this contest."]})]}),e.jsxs(on,{children:[e.jsx(ln,{className:"bg-transparent border-border text-muted-foreground hover:bg-muted hover:text-foreground",children:"Cancel"}),e.jsx(dn,{onClick:H,className:"bg-violet-600 text-white hover:bg-violet-500",children:"Reserve Product"})]})]})})})]})}
7function yu({item:t,isOwnPending:s}){const r=!!t.reply;return e.jsxs("article",{className:"space-y-4 py-6 first:pt-1 last:pb-0 border-b border-border/50 last:border-b-0",children:[e.jsx("p",{className:"text-[13px] sm:text-[0.9375rem] leading-[1.65] font-medium text-foreground whitespace-pre-wrap",children:t.question}),r?e.jsxs("div",{className:"space-y-2 border-l-2 border-primary/40 pl-3 sm:pl-4",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-foreground/55",children:"Brand reply"}),e.jsx("p",{className:"text-[13px] sm:text-[0.9375rem] leading-[1.65] text-foreground/90 whitespace-pre-wrap",children:t.reply})]}):s?e.jsx("p",{className:"text-xs font-medium text-amber-600 dark:text-amber-400",children:"Waiting for the brand to reply"}):null]})}function ii({draft:t,onDraftChange:s,onSubmit:r,isSubmitting:a,compact:i=!1}){return e.jsxs("div",{className:h("border transition-all duration-300",i?"rounded-2xl border-border bg-card p-3":"rounded-3xl border-border bg-card p-4 shadow-sm"),children:[!i&&e.jsx("div",{className:"mb-3",children:e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Ask the brand"})}),e.jsx(Hn,{value:t,onChange:c=>s(c.target.value),"aria-label":"Ask the brand a question",placeholder:"Partner creators can ask clarifying questions about the brief, deliverables, or anything unclear. Replies are visible to everyone on this contest.",rows:i?2:4,maxLength:2e3,className:h("resize-none border-0 focus:border-0 focus-visible:ring-0 focus-visible:outline-none",i?"min-h-[56px] rounded-lg bg-black/25 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground":"min-h-[100px] bg-transparent px-0 py-3 text-foreground placeholder:text-muted-foreground"),onKeyDown:c=>{c.key==="Enter"&&(c.metaKey||c.ctrlKey)&&(c.preventDefault(),r())}}),e.jsxs("div",{className:h("flex items-center justify-end gap-3",i?"mt-2.5":"mt-4"),children:[t.length>=1900?e.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-300",children:[t.length,"/2000"]}):null,e.jsx(Ee,{size:"sm",className:"rounded-full bg-white text-black hover:bg-white/90 whitespace-nowrap",onClick:r,disabled:!t.trim()||a,children:a?e.jsx(xt,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Wd,{className:"mr-1.5 h-3.5 w-3.5"}),"Ask the brand"]})})]})]})}function ju(t,s){const{data:r}=Zi(),{data:a=[],isLoading:i}=vi(t),c=r?.status==="active",d=s.isActive&&c&&!!s.userId,f=a.length>=1;return{questions:a,hasQaTab:f,canAsk:d,isActiveCpp:c,isLoading:i}}function oi({contestId:t,businessId:s,isActive:r,className:a,variant:i="tab",onAskSuccess:c}){const{user:d}=xr(),{data:f}=Zi(),{data:x=[],isLoading:p}=vi(t),m=zo(t,s),[v,A]=n.useState(""),y=f?.status==="active",N=r&&y&&!!d,P=n.useMemo(()=>{const B=x.filter(K=>K.reply),S=x.filter(K=>!K.reply&&K.creator_id===d?.id);return[...S,...B.filter(K=>!S.some(b=>b.id===K.id))].sort((K,b)=>new Date(b.created_at).getTime()-new Date(K.created_at).getTime())},[x,d?.id]),R=()=>{!v.trim()||m.isPending||m.mutate(v,{onSuccess:()=>{A(""),c?.()}})};return i==="prompt"?N?e.jsx(ii,{draft:v,onDraftChange:A,onSubmit:R,isSubmitting:m.isPending,compact:!0}):null:e.jsxs("div",{id:"contest-questions",className:h("space-y-4",a),children:[N&&e.jsx(ii,{draft:v,onDraftChange:A,onSubmit:R,isSubmitting:m.isPending}),!d&&r&&P.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sign in to view Q&A for this contest."}),d&&r&&!y&&P.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Only Creator Partner Program members can ask questions."," ",e.jsx(Mt,{to:"/creator/partner-program",className:"text-primary hover:underline",children:"Learn about the program"})]}),p?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading Q&Aâ¦"}):P.length>0?e.jsx("div",{children:P.map(B=>e.jsx(yu,{item:B,isOwnPending:!B.reply&&B.creator_id===d?.id},B.id))}):N?null:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No answered questions yet."})]})}const li={background:"linear-gradient(165deg, rgba(255,255,255,0.11) 0%, rgba(255,255,255,0.03) 40%, transparent 100%), linear-gradient(180deg, rgba(34,211,238,0.2) 0%, rgba(8,47,73,0.88) 35%, rgba(6,24,32,0.97) 100%)",boxShadow:"0 1px 0 rgba(255,255,255,0.14) inset, 0 -1px 0 rgba(0,0,0,0.35) inset, inset 0 0 0 1px rgba(255,255,255,0.05)"},_u=450;function di({content:t,disabled:s,className:r,children:a}
7){const i=un(),[c,d]=n.useState(!1),f=n.useRef(null),x=n.useRef(null),p=n.useRef(!1),m=n.useCallback(()=>{f.current!=null&&(window.clearTimeout(f.current),f.current=null),x.current!=null&&(window.clearTimeout(x.current),x.current=null)},[]);if(n.useEffect(()=>()=>m(),[m]),!i)return e.jsxs(Jr,{children:[e.jsx(en,{asChild:!0,children:e.jsx("span",{className:h("inline-flex",s&&"cursor-not-allowed",r),children:a})}),e.jsx(tn,{side:"top",className:"max-w-xs",children:t})]});const v=y=>{y.pointerType!=="mouse"&&(p.current=!1,m(),f.current=window.setTimeout(()=>{p.current=!0,d(!0)},_u))},A=()=>{f.current!=null&&(window.clearTimeout(f.current),f.current=null)};return e.jsxs(bs,{open:c,onOpenChange:d,children:[e.jsx(Jo,{asChild:!0,children:e.jsx("span",{className:h("inline-flex touch-manipulation",s&&"cursor-not-allowed",r),onPointerDown:v,onPointerUp:A,onPointerCancel:A,onPointerLeave:A,onClickCapture:y=>{if(p.current){y.preventDefault(),y.stopPropagation(),p.current=!1;return}d(!0),x.current!=null&&window.clearTimeout(x.current),x.current=window.setTimeout(()=>d(!1),1600)},children:a})}),e.jsx(vs,{side:"top",align:"center",className:"z-[90] w-auto max-w-xs p-3 text-xs leading-5",children:t})]})}function ci({onClick:t,disabled:s=!1,isOpening:r=!1,className:a,fullWidth:i=!1,disabledReason:c,participate:d}){const f=s&&c?c:d?.isParticipating?"Youâre shown as working on this contest. Tap to remove yourself.":"Show youâre working on this â youâll appear with the other entrants. You can still decide whether to submit.",x=e.jsx("button",{type:"button",onClick:t,disabled:s,className:h("relative min-w-0 flex-1 overflow-hidden text-center transition-[filter] duration-300 hover:brightness-[1.06] disabled:cursor-not-allowed",!d&&"rounded-[calc(0.75rem-1px)]",d&&"rounded-l-[calc(0.75rem-1px)]"),children:e.jsxs("span",{className:"relative flex min-h-[42px] w-full flex-col items-center justify-center px-3 py-2 sm:min-h-[48px] sm:px-4 sm:py-2.5",style:li,children:[e.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-cyan-200/40 to-transparent"}),e.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-1 left-[-28%] w-[44%] rotate-12 bg-[linear-gradient(90deg,transparent,rgba(255,255,255,0.22),transparent)] opacity-60 blur-md transition-[transform,opacity] duration-700 group-hover/studio:translate-x-[210%] group-hover/studio:opacity-80"}),e.jsxs("span",{className:"relative z-[1] flex flex-col items-center justify-center text-center leading-none",children:[e.jsx("span",{className:"hidden text-[9px] font-semibold uppercase tracking-[0.2em] text-electric-cyan/90 sm:block",children:"Create with Studio"}),e.jsx("span",{className:"text-xs font-semibold text-white [text-shadow:0_1px_8px_rgba(0,0,0,0.45)] sm:mt-1 sm:text-[15px]",children:r?"Opening Studio...":"Enter Studio"})]})]})});return e.jsxs("div",{className:h("group/studio relative isolate flex overflow-hidden rounded-xl border border-electric-cyan/40 bg-transparent p-0 shadow-[0_0_20px_hsl(var(--electric-cyan)/0.14)] transition-[border-color,box-shadow] duration-300",!s&&"hover:border-cyan-300/65 hover:shadow-[0_0_26px_hsl(var(--electric-cyan)/0.22)]",i&&"w-full",s&&"cursor-not-allowed opacity-55",a),children:[s&&c?e.jsx(di,{content:c,disabled:!0,className:"min-w-0 flex-1",children:e.jsx("span",{className:"flex min-w-0 w-full",children:x})}):x,d&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"relative z-[2] w-px shrink-0 self-stretch bg-white/20"}),e.jsx(di,{content:f,disabled:d.disabled||s,children:e.jsx("button",{type:"button","aria-label":d.isParticipating?"Stop participating":"Participate","aria-pressed":d.isParticipating,disabled:d.disabled||s,onClick:p=>{p.stopPropagation(),d.onClick()},className:h("relative flex w-11 shrink-0 items-center justify-center rounded-r-[calc(0.75rem-1px)] transition-[background-color,color,filter] duration-200 sm:w-12","focus-visible:z-[3] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-electric-cyan/70 focus-visible:ring-inset","disabled:cursor-not-allowed",!s&&d.isParticipating?"bg-electric-cyan/25 text-cyan-50 hover:bg-electric-cyan/35":"text-cyan-100/85 hover:bg-white/10 hover:text-white"),style:li,children:d.disabled&&!r&&!s?e.jsx(xt,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):e.jsx(fr,{className:h("h-4 w-4",d.isParticipating&&"fill-current"),"aria-hidden":!0})})})]})]})}function Nu({contestId:t,onEnterStudio:s,isOpening:r=!1}){const{eligible:a,amount:i}=Gd(t);return a?e.jsxs("button",{type:"button",disabled:r,onClick:s,className:"w-full rounded-xl border border-electric-cyan/25 bg-electric-cyan/10 px-3 py-2.5 text-left transition-colors hover:border-electric-cyan/40 hover:bg-electric-cyan/15 disabled:cursor-wait disabled:opacity-70",children:[e.jsxs("span",{className:"flex items-center gap-2 text-xs font-semibold text-electric-cyan",children:[r?e.jsx(xt,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Vd,{className:"h-3.5 w-3.5 shrink-0"}),"Claim ",Yd(i)," credits in this Studio project"]}),e.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:"Opens Studio for this contest. One-time bonus â verify your phone, add your concept, then generate here."})]}):null}const ku="fixed right-4 top-1/2 z-40 flex -translate-y-1/2 flex-col items-center gap-1 rounded-2xl border p-1 backdrop-blur-xl border-black/[0.08] bg-white/95 shadow-[0_18px_38px_-26px_rgba(148,163,184,0.4)] dark:border-white/[0.08] dark:bg-background/90 dark:shadow-[0_18px_38px_-26px_rgba(0,0,0,0.72)]",Rn="group relative flex h-9 w-9 items-center justify-center rounded-full border border-border bg-background/80 text-foreground
7/75 backdrop-blur-xl shadow-[0_12px_24px_-22px_rgba(0,0,0,0.5)] transition-all hover:border-foreground/25 hover:bg-background/95 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500/40 disabled:opacity-50 disabled:pointer-events-none",$n="absolute right-full top-1/2 z-50 mr-2 -translate-y-1/2 rounded-md border border-border bg-popover px-2 py-1 text-[10px] font-medium text-popover-foreground whitespace-nowrap opacity-0 shadow-md transition-opacity pointer-events-none group-hover:opacity-100 group-focus-visible:opacity-100";function Su({items:t,index:s,onIndexChange:r,onClose:a,onDownload:i}){const c=s!=null&&s>=0&&s<t.length,d=c?t[s]:null,f=c&&s>0,x=c&&s<t.length-1,[p,m]=n.useState(!1),[v,A]=n.useState(null),y=n.useRef(null),N=n.useRef(null),P=n.useCallback(()=>{s!=null&&s>0&&r(s-1)},[s,r]),R=n.useCallback(()=>{s!=null&&s<t.length-1&&r(s+1)},[s,t.length,r]);if(n.useEffect(()=>{if(!c)return;const E=Q=>{if(Q.key==="Escape")p?m(!1):a();else if(Q.key==="ArrowLeft")P();else if(Q.key==="ArrowRight")R();else if(Q.key==="Tab"&&!p){const O=y.current;if(!O)return;const H=Array.from(O.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(se=>se.offsetParent!==null);if(H.length===0)return;const te=H[0],z=H[H.length-1],ie=document.activeElement;Q.shiftKey&&ie===te?(Q.preventDefault(),z.focus()):!Q.shiftKey&&ie===z&&(Q.preventDefault(),te.focus())}};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[c,p,a,P,R]),n.useEffect(()=>{if(!c)return;N.current=document.activeElement;const E=window.setTimeout(()=>{y.current?.querySelector("button, a[href]")?.focus()},0);return()=>{window.clearTimeout(E),N.current?.focus?.()}},[c]),n.useEffect(()=>{A(null)},[s,d?.url]),n.useEffect(()=>{if(!c)return;const E=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=E}},[c]),typeof document>"u"||!c||!d)return null;const B=!!(d.caption||d.brand_likes||d.brand_dislikes),S=d.type==="video"?Hi(d):null,K=S??v,b=K?{"--media-ar":String(K)}:void 0,F=K?"w-[min(88vw,1280px,calc(88vh*var(--media-ar)))] h-[min(88vh,calc(min(88vw,1280px)/var(--media-ar)))]":"aspect-video max-h-[88vh] w-[min(88vw,1280px)]";return hi.createPortal(e.jsxs("div",{ref:y,className:"fixed inset-0 z-[9000] flex items-center justify-center bg-zinc-900/30 p-6 backdrop-blur-lg dark:bg-black/55",onMouseDown:E=>{E.target===E.currentTarget&&a()},role:"dialog","aria-modal":"true","aria-label":"Reference media viewer",children:[e.jsx("button",{type:"button",onClick:a,"aria-label":"Close viewer",className:"fixed left-4 top-4 z-40 flex h-9 w-9 items-center justify-center rounded-full border border-border bg-background/80 text-foreground/75 shadow-[0_12px_24px_-22px_rgba(0,0,0,0.5)] backdrop-blur-xl transition-all hover:border-foreground
7/25 hover:bg-background/95 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500/40",children:e.jsx(qs,{className:"h-5 w-5"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:P,disabled:!f,"aria-label":"Previous",className:h("fixed left-2 top-1/2 z-40 flex h-12 w-12 -translate-y-1/2 items-center justify-center text-white transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500/40 [filter:drop-shadow(0_0_5px_rgba(0,0,0,0.85))_drop-shadow(0_1px_3px_rgba(0,0,0,0.9))] hover:[filter:drop-shadow(0_0_9px_rgba(0,0,0,0.95))_drop-shadow(0_1px_4px_rgba(0,0,0,0.95))]",!f&&"pointer-events-none opacity-0"),children:e.jsx(Qd,{className:"h-8 w-8"})}),e.jsx("button",{type:"button",onClick:R,disabled:!x,"aria-label":"Next",className:h("fixed right-2 top-1/2 z-40 flex h-12 w-12 -translate-y-1/2 items-center justify-center text-white transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500/40 [filter:drop-shadow(0_0_5px_rgba(0,0,0,0.85))_drop-shadow(0_1px_3px_rgba(0,0,0,0.9))] hover:[filter:drop-shadow(0_0_9px_rgba(0,0,0,0.95))_drop-shadow(0_1px_4px_rgba(0,0,0,0.95))]",!x&&"pointer-events-none opacity-0"),children:e.jsx(Zd,{className:"h-8 w-8"})})]}),e.jsxs("div",{className:"relative flex max-h-full max-w-full items-center justify-center",onMouseDown:E=>E.stopPropagation(),children:[d.type==="video"?e.jsx("div",{className:h("overflow-hidden rounded-lg bg-black shadow-2xl",F),style:b,children:e.jsx(Yn,{src:d.url,className:"h-full w-full",objectFit:"contain",autoPlay:!0,controls:!0,onVideoSizeChange:S?void 0:E=>{E.width>0&&E.height>0&&A(E.width/E.height)}})}):e.jsx("img",{src:Xn(d,"detail"),alt:d.caption||"Reference",className:"max-h-[88vh] max-w-[min(88vw,1600px)] rounded-lg object-contain shadow-2xl",decoding:"async"}),d.caption&&e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center p-3",children:e.jsx("span",{className:"max-w-full truncate rounded-full border border-white/15 bg-black/55 px-3 py-1 text-xs font-medium text-white backdrop-blur-sm",children:d.caption})})]}),e.jsxs("div",{className:ku,children:[e.jsxs("button",{type:"button",onClick:()=>i(d),"aria-label":"Download",className:Rn,children:[e.jsx(Dn,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:$n,children:"Download"})]}),e.jsxs("a",{href:d.url,target:"_blank",rel:"noopener noreferrer","aria-label":"Open full size",className:Rn,onMouseDown:E=>E.stopPropagation(),children:[e.jsx(Xd,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:$n,children:"Open full size"})]}),B&&e.jsxs(bs,{open:p,onOpenChange:m,children:[e.jsx(Ks,{asChild:!0,children:e.jsxs("button",{type:"button","aria-label":"Details",className:Rn,children:[e.jsx(Gi,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:$n,children:"Details"})]})}),e.jsxs(vs,{align:"center",side:"left",sideOffset:10,className:"z-[10000] w-72 space-y-3 p-3",children:[d.caption&&e.jsx("p",{className:"text-sm font-medium text-foreground",children:d.caption}),d.brand_likes&&e.jsxs("div",{className:"rounded-lg border border-emerald-500/20 bg-emerald-500/[0.08] p-3",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[e.jsx(Zn,{className:"h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400"}),e.jsx("span",{className:"text-xs font-medium text-emerald-600 dark:text-emerald-400",children:"What the brand likes"})]}),e.jsx("p",{className:"text-sm leading-relaxed text-emerald-700 dark:text-emerald-300",children:d.brand_likes})]}),d.brand_dislikes&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/[0.08] p-3",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[e.jsx(Jd,{className:"h-3.5 w-3.5 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-xs font-medium text-red-600 dark:text-red-400",children:"What the brand dislikes"})]}),e.jsx("p",{className:"text-sm leading-relaxed text-red-700 dark:text-red-300",children:d.brand_dislikes})]})]})]})]})]}),document.body)}function ui(t){return ec(t)==="document"?!1:Vi(t)?t.pages.length>0:Array.isArray(t)&&t.length>0}function qr(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),r=t%60;return r>0?`${s}m ${r}s`:`${s}m`}function Cu(t){if(t.video?.cloudflare_video_id)return t.video.cloudflare_video_id;const s=t.cloudflare_video_id;return s||(t.bundle_videos?.find(a=>a.is_primary)??t.bundle_videos?.[0])?.video?.cloudflare_video_id}function Iu(t){return t.video_r2_key??t.video?.r2_key??(t.bundle_videos?.find(s=>
7s.is_primary)??t.bundle_videos?.[0])?.video?.r2_key??void 0}function Pu(t){return t.image_r2_key??t.image?.r2_key??null}function mi(t,s){const r=ws(t);if(r.type==="none")return null;const a=s.shouldAnonymizeNames?Ws(t.creator_id):t.creator_profile?.display_name||t.creator_profile?.username||"Creator",i=s.contestTitle||t.challenge?.title||"Contest",c={id:`contest-${t.id}`,submissionId:t.id,title:t.title||"Untitled",creatorName:a,creatorId:t.creator_id,contestTitle:i,brandName:"",type:t.winner_category||"submission",rank:t.winner_rank??void 0,trackTitle:t.winner_category?String(t.winner_category).replace(/_/g," "):void 0};if(r.type==="image")return!Pu(t)&&!r.url?null:{...c,cloudflareVideoId:void 0,playbackMode:null,thumbnail:ys(r)||void 0,imageUrl:wl(r)??r.url??void 0};const d=Cu(t)??(r.type==="cloudflare"?r.videoUid:void 0),f=Iu(t)??(r.type==="cloudflare"?r.r2Key??void 0:void 0);if(!d&&!f)return null;const x=t.bundle_videos&&t.bundle_videos.length>1?[...t.bundle_videos].sort((p,m)=>p.display_order-m.display_order).map(p=>({id:p.id,cloudflareVideoId:p.video?.cloudflare_video_id??"",r2Key:p.video?.r2_key??null,display_order:p.display_order,is_primary:!!p.is_primary,thumbnailTime:p.video?.thumbnail_time??null})).filter(p=>p.cloudflareVideoId||p.r2Key):void 0;return{...c,cloudflareVideoId:d,videoR2Key:f,playbackMode:t.video?.playback_mode??null,thumbnail:ys(r)||void 0,bundleVideos:x&&x.length>1?x:void 0}}const ts=t=>{const s=t?Date.parse(t):NaN;return Number.isFinite(s)?s:0},Tu=t=>{if(!t)return null;const s=new Date(t);return Number.isNaN(s.getTime())?null:ac(s,{addSuffix:!0})},Lu=(t,s)=>ts(t)>0&&ts(s)>ts(t);function pi({contestUpdates:t,updatesSectionRef:s,hasUnreadContestUpdates:r,unreadContestUpdateCount:a,lastSeenNewestCreatedAt:i,className:c}){return e.jsxs("section",{ref:s,id:"contest-updates",className:h("min-w-0 scroll-mt-28 border-t border-border/40 pt-8 transition-shadow duration-300",r&&"rounded-xl ring-1 ring-brand-purple/25 shadow-[0_0_0_1px_rgba(118,57,204,0.12)]",c),"aria-labelledby":"contest-updates-heading",children:[e.jsx("div",{className:"mb-5 flex flex-wrap items-center gap-2.5 border-b border-white/10 pb-4 sm:gap-3",children:e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5",children:[e.jsxs("span",{className:"relative shrink-0","aria-hidden":!0,children:[e.jsx(Id,{className:h("h-4 w-4 text-muted-foreground",r&&"text-brand-purple")}),r&&e.jsx("span",{className:"absolute -right-1 -top-1 flex h-2.5 min-w-2.5 items-center justify-center rounded-full bg-brand-purple px-0.5 text-[8px] font-bold leading-none text-white ring-2 ring-[#0a0a0b]",children:a>9?"9+":a})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[e.jsx("h2",{id:"contest-updates-heading",className:"text-sm font-semibold leading-snug tracking-tight text-foreground",children:"Updates"}),r&&e.jsx("span",{className:"inline-flex items-center rounded-full bg-brand-purple/15 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-[0.1em] text-brand-purple",children:"New"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground/85",children:r?`${a} unread ${qt(a,"message")} from the brand`:"Messages and clarifications from the brand"})]})]})}),e.jsx("div",{className:"min-w-0 space-y-7 sm:space-y-8",children:t.map(d=>{const f=!i||ts(d.created_at)>ts(i);return e.jsxs("article",{className:h("relative min-w-0 border-b border-border/40 pb-7 last:border-0 last:pb-0 sm:pb-8",r&&f&&"pl-3 sm:pl-4"),children:[r&&f&&e.jsx("span",{className:"absolute left-0 top-1.5 h-1.5 w-1.5 rounded-full bg-brand-purple shadow-[0_0_10px_rgba(118,57,204,0.65)] sm:top-2","aria-label":"Unread update"}),e.jsx("div",{className:"min-w-0 break-words text-[13px] leading-[1.65] text-foreground/90 sm:text-[0.9375rem] sm:leading-[1.7]",children:e.jsx(rc,{remarkPlugins:[nc],components:{p:({children:x})=>e.jsx("p",{className:"mb-2.5 last:mb-0",children:x}),ul:({children:x})=>e.jsx("ul",{className:"mb-2.5 list-disc space-y-1 pl-5 marker:text-muted-foreground/90",children:x}),ol:({children:x})=>e.jsx("ol",{className:"mb-2.5 list-decimal space-y-1 pl-5 marker:text-muted-foreground
7/90",children:x}),li:({children:x})=>e.jsx("li",{className:"leading-snug",children:x}),strong:({children:x})=>e.jsx("strong",{className:"font-semibold text-foreground",children:x})},children:d.message})}),e.jsxs("p",{className:"mt-3.5 text-[11px] tabular-nums text-muted-foreground sm:text-xs",children:[Tu(d.created_at)??"â",Lu(d.created_at,d.updated_at)&&" · Edited"]})]},d.id)})})]})}const Un=t=>{const{id:s}=fi(),r=Lo(),a=On(),{isPreviewMode:i}=Vs(),{shouldAnonymize:c}=cn(),d=i||c,f=un();Wo();const x=new URL(window.location.href).searchParams,p=x.get("tab"),m=p==="submissions"?"submissions":"overview";n.useState(m);const v=x.get("editSubmission"),A=x.get("openSubmit"),y=x.get("videoId"),N=x.get("imageId"),[P,R]=n.useState(!1),[B,S]=n.useState(null),[K,b]=n.useState(null),[F,E]=n.useState(!1),[Q,O]=n.useState(),[H,te]=n.useState(null),[z,ie]=n.useState(null),[se,Z]=n.useState([]),[w,j]=n.useState(Date.now()),[T,_]=n.useState(null),[U,$]=n.useState(!1),[M,D]=n.useState(()=>p==="qa"?"qa":"brief"),Y=Ia(1024),W=Ia(768),u=t.contest,ue=n.useMemo(()=>{const l=u?.reference_media;return Array.isArray(l)?l.filter(C=>C.type!=="pdf"):[]},[u]),ve=n.useCallback(l=>{const C=ue.findIndex(le=>le.url===l.url&&le.type===l.type);_(C>=0?C:0)},[ue]),q=n.useMemo(()=>"submissions"in t?t.submissions:[],[t]),me=n.useMemo(()=>"challenges"in t?t.challenges:[],[t]),X="user"in t?t.user:null,fe=!X&&!i,qe="lateSubmissionMode"in t?t.lateSubmissionMode===!0:!1,Ve=n.useMemo(()=>"refetchSubmissions"in t?t.refetchSubmissions:()=>{a.invalidateQueries({queryKey:["submissions",s]})},[t,a,s]),{isParticipating:I,isViewerLoading:De,participantCount:Le,participantSlots:Ae,setParticipation:ke,refreshParticipation:he}=uc(u?.id),{isPartiallyApproved:je,cashLimit:xe,usedFreePass:Be}=ol(),G=n.useMemo(()=>!X||!q?!1:q.some(l=>l.creator_id===X.id&&!["rejected","withdrawn","disqualified"].includes(l.status||"")),[X,q]),_e=n.useMemo(()=>u?ll(je,Be,xe,u.prize_type||"cash",u.prize_amount,G):{canEnter:!0,reason:""},[u,je,Be,xe,G]),Re=n.useCallback(()=>_e.canEnter?!0:(E(!0),!1),[_e]),$e=u?.id?`brief_viewed_${u.id}`:null,[L,Se]=n.useState(()=>{if(!$e)return!1;try{return window.localStorage.getItem($e)==="1"}catch{return!1}});n.useEffect(()=>{if($e&&!L)try{window.localStorage.getItem($e)==="1"&&Se(!0)}catch{}},[$e]);const Ce=n.useCallback(()=>{if(Se(!0),$e)try{window.localStorage.setItem($e,"1")}catch{}},[$e]);nl();const{project:g,ensureProject:J}=$i(u?.id,u?.title),[pe,Fe]=n.useState(!1),{data:Ue}=zt({queryKey:["contest-meta",u?.id],enabled:!!u?.id,staleTime:1e3*60*5,queryFn:async()=>{const{data:l}=await be.from("challenges_public").select("brand_selection_enabled, max_selections_per_brand, max_brands_per_creator, product_selection_enabled, max_selections_per_product, max_products_per_creator, participation_eligibility, submission_media_type").eq("id",u.id).maybeSingle();return l}}),re=!!Ue?.brand_selection_enabled,{brandOptions:ze,myReservedBrandIds:Oe,reserveBrand:lt,cancelReservation:mt,isLoading:Rt}=Ko(re?u?.id:void 0),He=!!Ue?.product_selection_enabled,{productOptions:at,myReservedProductIds:gt,reserveProduct:Ft,cancelReservation:yt,isLoading:Hs}=qo(He?u?.id:void 0),Ke=Ue?.participation_eligibility,{cppGateMet:Te,eligibility:et,isLoading:$t}=Go(Ke),[Ys,rs]=n.useState(),pn=n.useMemo(()=>!X||!q?new Set:new Set(q.filter(l=>l.creator_id===X.id&&l.selected_brand_id).map(l=>l.selected_brand_id)),[X,q]),pt=n.useMemo(()=>!re||!ze.length?[]:ze.filter(l=>Oe.has(l.id)),[re,ze,Oe]),Ot=n.useMemo(()=>{if(!re||!ze.length)return;const l=new Map;for(const C of ze)l.set(C.id,{name:C.brand_name,logoUrl:C.brand_logo_url});return l},[re,ze]),[Qs,Vt]=n.useState(),St=n.useMemo(()=>!X||!q?new Set:new Set(q.filter(l=>l.creator_id===X.id&&l.selected_product_id).map(l=>l.selected_product_id)),[X,q]),Zs=n.useMemo(()=>!He||!at.length?[]:at.filter(l=>gt.has(l.id)),[He,at,gt]),Ct=n.useMemo(()=>{if(!He||!at.length)return;const l=new Map;for(const C of at)l.set(C.id,{name:C.product_name,imageUrl:C.product_image_url});return l},[He,at]),_s=n.useCallback(async l=>{if(!Te){const de=u?.campaign_kind==="performance"?"campaign":"contest",We=et==="cpp_only"?`This ${de} is open to Creator Partners. See the Partner Program page to learn more.`:`This ${de} is open to creators outside the Partner Program.`;ee.error("Not eligible",{description:We});return}if(ui(u.brief_pages)&&!L&&!G){ee.error("Brief not read",{description:"Review the full brief above before submitting."});return}Fe(!0);try{await ke.mutateAsync(!0);const{project:de,wasCreated:We}=await J();We&&u?.id&&X?.id&&(await Ml(de.id,u.id,X.id).catch(()=>{}),await Rl(de.id,u.id).catch(()=>{}));const Et=l?.openClaim?"&claim=1":"";r(`/creator/studio?tool=image&projectId=${de.id}${Et}`)}catch(de){console.error("Failed to create/fetch project for studio:",de),Fe(!1)}},[J,u,L,G,X?.id,r,ke,Te,et]);n.useEffect(()=>{const l=setInterval(()=>{j(Date.now())},6e4);return()=>clearInterval(l)},[]);const Nt=n.useMemo(()=>
7{if(!X||!q)return new Set;const l=q.filter(C=>C.creator_id===X.id&&!["rejected","withdrawn","disqualified"].includes(C.status||""));return new Set(l.map(C=>C.contest_challenge_id).filter(Boolean))},[X,q]),Wt=n.useMemo(()=>{const l=new Map;return!X||!q||q.forEach(C=>{if(C.creator_id!==X.id||["rejected","withdrawn","disqualified"].includes(C.status||""))return;const le=C.contest_challenge_id;le&&l.set(le,(l.get(le)??0)+1)}),l},[X,q]),Ze=n.useMemo(()=>!X||!q?[]:q.filter(l=>l.creator_id===X.id),[X,q]),ns=n.useMemo(()=>!X||!q?0:q.filter(l=>l.creator_id===X.id&&!["rejected","withdrawn","disqualified"].includes(l.status||"")).length,[X,q]),wr=n.useMemo(()=>Ze.some(l=>!["rejected","withdrawn","disqualified"].includes(l.status||"")),[Ze]),jt=n.useMemo(()=>!H||!Ze.length?-1:Ze.findIndex(l=>l.id===H.id),[H,Ze]),It=()=>{Ze.length&&jt>0&&te(Ze[jt-1])},Ns=()=>{Ze.length&&jt<Ze.length-1&&te(Ze[jt+1])},Ie=u?.max_submissions_per_creator??null,as=n.useMemo(()=>Ie==null||Ie===0?!1:!me||me.length<=1?ns>=Ie:me.every(l=>(Wt.get(l.id)??0)>=Ie),[me,Wt,Ie,ns]),ks=n.useMemo(()=>{if(!me?.length)return;const l=Ie==null||Ie===0;for(const C of me){const le=Wt.get(C.id)??(Nt.has(C.id)?1:0);if(!(!l&&le>=(Ie??0)))return C.id}return me[0]?.id},[me,Nt,Wt,Ie]),yr=n.useMemo(()=>{if(!q||q.length===0)return new Set;const l=[...q].sort((C,le)=>(le.net_weighted_score||0)-(C.net_weighted_score||0)).slice(0,30);return new Set(l.map(C=>C.id))},[q]),bt=()=>{Ve(),he(),(v||A||y)&&r(window.location.pathname,{replace:!0})},{data:jr}=Eo(B||""),tt=Ka(u?.external_submission_url);n.useEffect(()=>{if(!P){if(v)S(v),R(!0);else if(A){if(tt){X&&(qa(tt)||ee.error("Pop-up blocked",{description:"Allow pop-ups, or click Submit to open the form in a new tab."}),r(window.location.pathname,{replace:!0}));return}y&&b(y),R(!0)}}},[v,A,y,X,tt]);const ht=n.useMemo(()=>{const l=u?.title,C=new Map(q.map(Ge=>[Ge.id,Ge.submitted_at])),le=new Map;for(const Ge of q){const ge=mi(Ge,{contestTitle:l,shouldAnonymizeNames:d});ge&&le.set(Ge.id,ge)}const We=(se.length>0?se:q.map(Ge=>Ge.id)).flatMap(Ge=>{const ge=le.get(Ge);return ge?[ge]:[]}),Et=[...We].sort((Ge,ge)=>new Date(C.get(Ge.submissionId)??0).getTime()-new Date(C.get(ge.submissionId)??0).getTime()),Pt=new Map(Et.map((Ge,ge)=>[Ge.submissionId,ge+1]));return We.map(Ge=>({...Ge,submissionNumber:Pt.get(Ge.submissionId)}))},[q,u?.title,d,se]);n.useEffect(()=>{if(!N||!q.length||!ht.length)return;const l=q.find(le=>le.image_id===N);if(!l)return;const C=ht.find(le=>le.submissionId===l.id);C&&ie(C)},[N,q,ht]);const Ye=n.useMemo(()=>[...ht].sort((l,C)=>{const le=l.rank!=null,de=C.rank!=null;return le&&de?(l.rank??0)-(C.rank??0):le?-1:de?1:0}),[ht]),Ut=n.useCallback(l=>{const C=ht.find(de=>de.submissionId===l.id);if(C){ie(C);return}const le=mi(l,{contestTitle:u?.title,shouldAnonymizeNames:d});if(le){ie(le);return}ee.error("This submission has no playable media yet.")},[u?.title,d,ht]),Xs=n.useCallback(l=>{Z(C=>C.length===l.length&&C.every((le,de)=>le===l[de])?C:l)},[]),dt=Do(),{launchedIds:Ss,publishedIds:_r,libraryDeliveredIds:Nr,lockedIds:kr,activeIds:hn}=xd(X?.id),[is,Js]=n.useState(null),os=n.useCallback(l=>{if(_r.has(l.id)){ee.error("This entry is running as an ad for the brand, so it cannot be deleted.");return}if(Nr.has(l.id)){ee.error("The brand already holds this entry in their ad account and it cannot be withdrawn. Ask them to remove it there first.");return}Js(l)},[_r,Nr]),{data:Gt}=zt({queryKey:["judging-session",s],queryFn:async()=>{const{data:l,error:C}=await be.from("judging_sessions").select("judging_end_at, status").eq("challenge_id",s).maybeSingle();if(C)throw C;return l},enabled:!!s&&t.contest?.campaign_kind!=="performance"&&(t.contest?.status!=="active"||(t.contest?.deadline?new Date(t.contest.deadline)<new Date:!1))}),Xe=t.contest?.campaign_kind==="performance",er=t.contest?.submissions_paused_at??null,kt=!!er&&u.status!=="completed",{data:Cs=[]}=bd(Xe?s:null),{data:st=null}=zt({queryKey:["perf-earnings-terms",s],queryFn:async()=>{const{data:l}=await Rd("commission_pct, approval_bonus_video_cents, approval_bonus_image_cents, discount_enabled, discount_pct, attribution_window_days, payout_mode, flat_commission_cents, trial_bounty_cents, spend_share_pct, conversion_kind",C=>be.from("performance_campaign_config").select(C).eq("challenge_id",s).maybeSingle());return l??null}
7,enabled:!!s&&Xe,staleTime:6e4}),{perfApprovedIds:Sr,perfDeliveryBySubmissionId:ls,perfCategoryTagsBySubmissionId:Ht,perfDisplayMetricsBySubmissionId:fn,adLaunchIdBySubmissionId:tr,republishingBySubmissionId:Is,placementCountBySubmissionId:ds,activePlacementCountBySubmissionId:Ps,deliveringBySubmissionId:Cr,perfEarningsWonUsdBySubmissionId:o}=n.useMemo(()=>yd(Cs,{conversionKind:st?.conversion_kind,flatCommissionCents:st?.flat_commission_cents,approvedSubmissionIds:new Set(q.filter(l=>l.status==="approved").map(l=>l.id))}),[Cs,st?.conversion_kind,st?.flat_commission_cents,q]),k=n.useMemo(()=>{const l=new Map;for(const C of Cs)l.has(C.ad_launch_id)||l.set(C.ad_launch_id,C);return l},[Cs]),V=Xe&&!!t.contest?.deadline&&new Date(t.contest.deadline).getTime()-Date.now()<180*24*3600*1e3,ae=_i({commissionPct:st?.commission_pct,flatCommissionCents:st?.flat_commission_cents,trialBountyCents:st?.trial_bounty_cents,approvalBonusVideoCents:st?.approval_bonus_video_cents,approvalBonusImageCents:st?.approval_bonus_image_cents,spendSharePct:st?.spend_share_pct!=null?Number(st.spend_share_pct):null,spendBasis:st?.spend_basis,conversionKind:st?.conversion_kind}),Ne=ae.unit==="ad_spend"?ae.tagLabel:`Earn on every ${ae.unit}`,{data:ce=[],isError:Pe}=zt({queryKey:["contest-updates",s],queryFn:async()=>{const{data:l,error:C}=await be.from("contest_updates").select("id, title, message, created_at, updated_at").eq("challenge_id",s).order("created_at",{ascending:!1});if(C)throw C;return l??[]},enabled:!!s}),ne=n.useRef(null),Me=s?`contest_updates_seen_effective_${s}`:"",[oe,Qe]=n.useState(null);n.useEffect(()=>{if(Me)try{Qe(localStorage.getItem(Me))}catch{Qe(null)}},[Me]);const it=l=>l.updated_at&&ts(l.updated_at)>ts(l.created_at)?l.updated_at:l.created_at,we=n.useMemo(()=>{if(ce.length===0)return 0;if(!oe){const l=Date.now()-2592e6;return ce.filter(C=>ts(it(C))>l).length}return ce.filter(l=>(it(l)??"")>oe).length},[ce,oe]),Je=we>0,rt=oe,ot=ce.length>0?ce.reduce((l,C)=>{const le=it(C)??"";return le>l?le:l},""):"";n.useEffect(()=>{if(!Je||!Me||ce.length===0)return;const l=ne.current;if(!l)return;const C=new IntersectionObserver(le=>{if(le.some(de=>de.isIntersecting)&&ot){try{localStorage.setItem(Me,ot),Qe(ot)}catch{}C.disconnect()}},{threshold:.18,rootMargin:"0px 0px -8% 0px"});return C.observe(l),()=>C.disconnect()},[Je,Me,ce.length,ot]);const ct=n.useMemo(()=>{if(!u)return!1;const l=u.allow_late_submission===!0;return Kn({status:u.status,deadline:u.deadline,allowLate:l,now:w,lateSubmissionMode:!0})},[u,w]),ut=ct||u?.status==="judging"||u?.status==="revisions",{hasQaTab:ft,canAsk:Ts}=ju(u?.id,{isActive:ct,userId:X?.id}),sr=!!(X&&u?.id&&u?.business_id&&!fe),{hasInspiration:xn}=hu(u?.business_id,u?.id,sr),Ir=n.useMemo(()=>{if(!u)return[];const l=u,C=[];if((u.description?.trim()||Vi(l.brief_pages)||Array.isArray(l.brief_pages)&&l.brief_pages.length>0)&&C.push({id:"brief",label:"Brief"}),ut&&ft){const de=C.findIndex(We=>We.id==="brief");de>=0?C.splice(de+1,0,{id:"qa",label:"Q&A"}):C.push({id:"qa",label:"Q&A"})}return(Array.isArray(l.reference_media)&&l.reference_media.length>0||Array.isArray(l.useful_links)&&l.useful_links.length>0||Array.isArray(l.example_urls)&&l.example_urls.length>0)&&C.push({id:"brand_kit",label:"Brand kit"}),xn&&C.push({id:"inspiration",label:"Inspiration"}),C},[u,ut,ft,xn]),Pr=n.useMemo(()=>ce.length===0&&!Pe||!Y?Ir:Ir.length===0?[{id:"updates",label:"Updates"}]:[...Ir,{id:"updates",label:"Updates"}],[Ir,ce.length,Pe,Y]),{briefText:Jn,isDocumentMode:co}=n.useMemo(()=>_d(u?.brief_pages,{contestTitle:u?.title,description:u?.description}),[u]);n.useEffect(()=>{const l=Pr.map(C=>C.id);l.length!==0&&(l.includes(M)||D(l[0]))},[Pr,M]),n.useEffect(()=>{if(p!=="winners"||!u?.id||u?.status!=="completed")return;const l=document.getElementById("winners");if(l){const C=setTimeout(()=>l.scrollIntoView({behavior:"smooth",block:"start"}),400);return()=>clearTimeout(C)}},[p,u?.id,u?.status]),n.useEffect(()=>{p==="qa"&&ft&&D("qa")},[p,ft]),n.useEffect(()=>{if(typeof window>"u"||window.location.hash!=="#contest-questions"||!ft)return;D("qa");const l=setTimeout(()=>{document.getElementById("contest-questions")?.scrollIntoView({behavior:"smooth",block:"start"})},300);return()=>clearTimeout(l)},[ft]);const{data:ea=[],isPending:uo}=Ho(t.contest?.id??""),{data:mo=za}=zt({queryKey:["app-settings","non_anthum_reward_penalty_pct"],queryFn:async()=>{const{data:l,error:C}=await be.from("app_settings").select("value").eq("key","non_anthum_reward_penalty_pct").maybeSingle();if(C)throw C;return Bi(l?.value)??za},staleTime:5*60*1e3});if(!u){const l="loadFailed"in t?!!t.loadFailed:!1;return e.jsxs("div",{className:"text-foreground flex flex-col min-h-screen bg-premium-dark",children:[e.jsxs("div",{className:"flex-1 container mx-auto px-4 py-8 pt-2 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-red-400 mb-4",children:l?"Could not load this contest":"Not Found"}),e.jsx("p",{className:"text-foreground mb-6",children:l?"Something went wrong on our side. It may well still be running â try again in a moment.":"The contest or campaign you're looking for doesn't exist."}),l?e.jsx(Ee,{onClick:()=>window.location.reload(),className:"bg-card text-foreground hover:bg-muted",children:"Try again"}):e.jsx("a",{href:"/creator",children:e.jsx(Ee,{className:"bg-card text-foreground hover:bg-muted",children:"Browse Contests & Campaigns"})})]}),e.jsx(Ta,{})]})}const ta=new Date(u.deadline),sa=u.allow_late_submission===!0,nt=Kn({status:u.status,deadline:u.deadline,allowLate:sa,now:w,lateSubmissionMode:qe,pausedAt:er}),ra=Xe&&!kt&&!nt&&u.status!=="completed",na=ta.getTime()-w,aa=!nt&&Gt?.status==="active",gn=u.winner_ids||[],cs=u.status==="completed"&&!Xe,ia=q.some(l=>gn.includes(l.id)||l.status==="winner"||l.winner_rank!=null),oa=!nt&&Gt?.status==="closed"&&!cs,us=cs?"completed":oa?"brand_judging":aa?"community_judging":nt?"active":"deciding",po=aa||oa,Tr=Gt?.judging_end_at?new Date(Gt.judging_end_at):null,bn=(()=>
7{if(!Tr||Tr<=new Date)return null;const l=Tr.getTime()-Date.now(),C=Math.floor(l/(1e3*60*60)),le=Math.floor(l%(1e3*60*60)/(1e3*60)),de=Tr.toLocaleString("en-US",{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"});let We;if(C<1)We=`${le}m`;else if(C<24)We=`${C}h ${le}m`;else{const Et=Math.floor(C/24),Pt=C%24;We=`${Et}d ${Pt}h`}return{timeRemaining:We,endTimeFormatted:de,hoursLeft:C}})(),ho=l=>{if(l<=0)return;const C=Math.floor(l/(1e3*60*60)),le=Math.floor(l%(1e3*60*60)/(1e3*60));return C<24?C===0?`${le}m`:`${C}h ${le}m`:`${Math.floor(C/24)}d`},fo=nt&&na<=0,la=sa?void 0:ho(ta.getTime()+od-w),rr=q?.length||0,Lr=ui(u.brief_pages),xo=Ue?.max_brands_per_creator??2,Ar=!re||Oe.size>=1,go=Ue?.max_products_per_creator??2,Mr=!He||gt.size>=1,vt=Xe?"campaign":"contest",Yt=et==="cpp_only"?`This ${vt} is open to Creator Partners. See the Partner Program page to learn more.`:`This ${vt} is open to creators outside the Partner Program.`,ye=u,ms=!!(ye.require_platform_generation&&ye.strict_studio_only),vn=Ka(ye.external_submission_url),Ls=!!vn,wn=X&&nt&&!i&&Te&&(Ls||!as&&Ar&&Mr),Rr=wn?void 0:kt?`Submissions are paused for this ${vt}. Your time remaining is held until it reopens.`:Te?Ls?void 0:Ar?Mr?as?Ie&&Ie>1?`You have used all ${Ie} entries for this ${vt}.`:`You have already submitted to this ${vt}.`:void 0:"Reserve at least one product before submitting.":"Reserve at least one brand before submitting.":Yt,As=(nt||kt)&&!i&&!fe,yn=rr>0||!Ls,da=u.status==="active"&&Le>0&&Ae.length>0,ca=As&&(Ls||!re&&!He&&!(ms&&!g));function jn(){return vn?Te?Lr&&!L&&!G?(ee.error("Brief not read",{description:"Review the full brief above before submitting."}),!0):(qa(vn)||ee.error("Pop-up blocked",{description:"Allow pop-ups, or click Submit again to open the form."}),!0):(ee.error("Not eligible",{description:Yt}),!0):!1}function ua(l){if(!i&&!jn()){if(!Te){ee.error("Not eligible",{description:Yt});return}if(re&&!Ar){ee.error("Brand required",{description:"Reserve at least one brand before submitting."});return}if(He&&!Mr){ee.error("Product required",{description:"Reserve at least one product before submitting."});return}if(Lr&&!L&&!G){ee.error("Brief not read",{description:"Review the full brief above before submitting."});return}Re()&&(rs(void 0),Vt(void 0),O(l??ks),R(!0))}}const ma=ms&&g?"Submit Entry":ks&&Nt.has(ks)?"Submit Another Entry":"Submit",pa=l=>{if(!jn()){if(!Te){ee.error("Not eligible",{description:Yt});return}if(Lr&&!L&&!G){ee.error("Brief not read",{description:"Review the full brief above before submitting."});return}Re()&&(Vt(l),O(void 0),R(!0))}},ha=l=>{if(!jn()){if(!Te){ee.error("Not eligible",{description:Yt});return}if(Lr&&!L&&!G){ee.error("Brief not read",{description:"Review the full brief above before submitting."});return}Re()&&(rs(l),O(void 0),R(!0))}},bo=re||He,$r=Ar&&Mr,fa=As&&bo&&!(ms&&!g),vo=$r?ma:He?"Pick your product":"Pick your brand",_n=()=>{document.getElementById("contest-pick-section")?.scrollIntoView({behavior:"smooth",block:"start"})};function wo(){if(!$r){_n();return}if(He){const C=[...gt];C.length===1?pa(C[0]):_n();return}const l=[...Oe];l.length===1?ha(l[0]):_n()}const Nn=u?.id?`/auth?type=creator&redirect=${encodeURIComponent(`creator/contest/${u.id}`)}`:"/auth?type=creator",xa=cs?gn:[],yo=cs?Ze.find(l=>gn.includes(l.id)):void 0,jo=async()=>{const l=u.reference_media;if(l?.length)try{$(!0);const C=new fd;let le=0;const de=[],We=l.map(async(ge,Tt)=>{try{const Dt=await fetch(ge.url);if(!Dt.ok){const or=`HTTP ${Dt.status} ${Dt.statusText}`;console.error(`[BrandKit DL] #${Tt+1} FAILED â ${or} â ${ge.url}`),de.push({index:Tt+1,url:ge.url,caption:ge.caption,reason:or});return}const ps=await Dt.blob();if(ps.size<100){const or=`Empty response (${ps.size} bytes)`;console.error(`[BrandKit DL] #${Tt+1} FAILED â ${or} â ${ge.url}`),de.push({index:Tt+1,url:ge.url,caption:ge.caption,reason:or});return}const Io=ge.type==="image"?"jpg":ge.type==="pdf"?"pdf":"mp4",Cn=ge.url.split(".").pop()?.split("?")[0]?.toLowerCase(),Sa=Cn&&["jpg","jpeg","png","mp4","mov","webm","webp","gif","pdf"].includes(Cn)?Cn:Io,Ca=ge.type==="pdf"&&ge.filename?`${Tt+1}_${ge.filename.replace(/\.[^.]+$/,"").slice(0,30).replace(/[^a-z0-9]/gi,"_")}`:ge.caption?`${Tt+1}_${ge.caption.slice(0,30).replace(/[^a-z0-9]/gi,"_")}`:`reference_${Tt+1}`;C.file(`${Ca}.${Sa}`,ps),le++,Tt+1,`${ps.size}${Ca}${Sa}`}catch(Dt){const ps=Dt instanceof Error?Dt.message:String(Dt);console.error(`[BrandKit DL] #${Tt+1} FAILED â ${ps} â ${ge.url}`,Dt),de.push({index:Tt+1,url:ge.url,caption:ge.caption,reason:ps})}});if(await Promise.all(We),de.length>0&&(console.group(`[BrandKit DL] ${de.length} file(s) failed:`),de.forEach(ge=>{console.table({"#":ge.index,caption:ge.caption??"â",reason:ge.reason,url:ge.url})}),console.groupEnd()),le===0){ee.error("Download failed",{description:"None of the files could be downloaded. They may be hosted externally with download restrictions."});return}const Et=await C.generateAsync({type:"blob"}),Pt=window.URL.createObjectURL(Et),Ge=document.createElement("a");if(Ge.href=Pt,Ge.download=`${u.title.slice(0,30).replace(/[^a-z0-9]/gi,"_")}_references.zip`,document.body.appendChild(Ge),Ge.click(),window.URL.revokeObjectURL(Pt),document.body.removeChild(Ge),de.length>0){const ge=de.length;ee.warning(`Brand kit downloaded â ${ge} file${ge===1?"":"s"} missing`,{description:`${le} of ${l.length} ${qt(l.length,"file")} are in the zip. Try downloading the rest individually.`})}else ee("Brand kit downloaded")}catch(C){console.error("Error zipping references:",C),ee.error("Download failed",{description:"Could not create zip file. Please try individual downloads."})}finally{$(!1)}},ga=async l=>{try{const C=await fetch(l.url);if(!C.ok)throw new Error(`HTTP ${C.status}`);const le=await C.blob(),de=window.URL.createObjectURL(le),We=document.createElement("a");We.href=de;const Et=l.type==="image"?"jpg":l.type==="pdf"?"pdf":"mp4",Pt=l.url.split(".").pop()?.split("?")[0]?.toLowerCase(),Ge=Pt&&["jpg","jpeg","png","mp4","mov","webm","webp","gif","pdf"].includes(Pt)?Pt:Et,ge=l.type==="pdf"&&l.filename?l.filename.replace(/\.[^.]+$/,"").slice(0,30).replace(/[^a-z0-9]/gi,"_"):l.caption?l.caption.slice(0,30).replace(/[^a-z0-9]/gi,"_"):"reference";We.download=`${ge}.${Ge}`,document.body.appendChild(We),We.click(),window.URL.revokeObjectURL(de),document.body.removeChild(We)}catch(C){console.error("Error downloading reference:",C),window.open(l.url,"_blank")}},nr=u.brand?.logo_url,kn=u.cover_image_url,ba=kn||nr,va=!!ye.require_platform_generation,_o=ms?W?"Studio required":"Anthum Studio generations required":W?"Studio recommended":"Anthum Studio generations recommended",wa=zi(u.deadline,mo),ya=ad(wa,ms),Ms="inline-flex items-center gap-1 rounded-md border border-white/15 bg-black/35 px-2 py-0.5 text-[10px] font-medium text-white/95 backdrop-blur-sm [text-shadow:0_1px_2px_rgba(0,0,0,0.85)] sm:gap-1.5 sm:px-2.5 sm:py-1 sm:text-[11px]",Ur="h-3 w-3 shrink-0 text-white/90 sm:h-3.5 sm:w-3.5",ja=e.jsxs("button",{type:"button",className:h(Ms,"transition-colors hover:border-white/25 hover:bg-black/45"),children:[e.jsx(Yr,{className:Ur,"aria-hidden":!0}),_o]}),_a="max-w-[22rem] border-white/10 bg-zinc-950/95 text-xs leading-relaxed text-zinc-100",No=va?f?e.jsxs(bs,{children:[e.jsx(Ks,{asChild:!0,children:ja}),e.jsx(vs,{side:"top",align:"center",className:h(_a,"w-auto p-3 z-[90]"),children:ya})]}):e.jsx(gi,{delayDuration:180,children:e.jsxs(Jr,{children:[e.jsx(en,{asChild:!0,children:ja}),e.jsx(tn,{side:"top",className:_a,children:ya})]})}):null,ko=et==="cpp_only"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-amber-300/35 bg-amber-500/15 px-2 py-0.5 text-[10px] font-semibold text-amber-100 backdrop-blur-sm [text-shadow:0_1px_2px_rgba(0,0,0,0.85)] sm:gap-1.5 sm:px-2.5 sm:py-1 sm:text-[11px]",children:[e.jsx(Qr,{className:"h-3 w-3 shrink-0 text-amber-300 sm:h-3.5 sm:w-3.5","aria-hidden":!0}),W?"Partners only":"Creator Partners only"]}):null,So=Array.isArray(ye.reference_media)&&ye.reference_media.length>0||Array.isArray(ye.useful_links)&&ye.useful_links.length>0||Array.isArray(ye.example_urls)&&ye.example_urls.length>0,Sn=Array.isArray(ye.accepted_aspect_ratios)?ye.accepted_aspect_ratios.filter(
7Boolean):ye.aspect_ratio?[ye.aspect_ratio]:null,Rs=ye.min_video_length_seconds??null,ar=ye.max_video_length_seconds??null,Na=Sn&&Sn.length>0||Rs!=null||ar!=null,ir=ye.max_submissions_per_creator??null,Co=ir==null||ir===0,ka=Ue?.submission_media_type==="image"||Ue?.submission_media_type==="both"?Ue.submission_media_type:null;return e.jsxs("div",{className:"min-h-screen bg-premium-dark text-foreground flex flex-col",children:[e.jsxs("div",{className:"fixed inset-0 pointer-events-none overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-1/4 w-96 h-96 bg-primary/5 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-80 h-80 bg-primary/3 rounded-full blur-3xl"})]}),e.jsxs("main",{id:"main",className:"flex-1 relative z-10",children:[u.status==="draft"&&e.jsx("div",{role:"status",className:"relative z-20 bg-amber-500/10 border-b border-amber-500/30",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 md:px-8 py-2.5 flex items-center gap-2 text-sm text-amber-200",children:[e.jsx(tc,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{className:"font-medium",children:"Preview"}),e.jsx("span",{className:"text-amber-200/80",children:`: this ${vt} isn't published yet. Only people with this link can see it.`})]})}),e.jsxs("div",{className:"relative w-full min-h-[220px] overflow-hidden bg-zinc-900 sm:min-h-[340px] md:min-h-[420px]",children:[ba?e.jsx("img",{src:ba,alt:"",className:"absolute right-0 top-0 h-full w-[72%] sm:w-[68%] md:w-[65%] object-cover object-center",decoding:"async"}):e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-violet-900/80 via-card to-purple-900/70"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(to_right,rgba(0,0,0,1)_0%,rgba(0,0,0,1)_30%,rgba(0,0,0,0.96)_38%,rgba(0,0,0,0.82)_48%,rgba(0,0,0,0.50)_60%,rgba(0,0,0,0.18)_74%,transparent_100%)]","aria-hidden":!0}),e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(to_right,rgba(0,0,0,0.7)_0%,rgba(0,0,0,0.32)_45%,rgba(0,0,0,0.06)_65%,transparent_80%)]","aria-hidden":!0}),e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(to_top,rgba(0,0,0,0.5)_0%,rgba(0,0,0,0.28)_32%,rgba(0,0,0,0.12)_58%,rgba(0,0,0,0.06)_78%,transparent_100%)]","aria-hidden":!0}),e.jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 z-[8] h-[min(56%,24rem)] w-full bg-[linear-gradient(to_top,rgba(0,0,0,0.36)_0%,rgba(0,0,0,0.16)_42%,rgba(0,0,0,0.05)_72%,transparent_100%)] sm:h-[min(50%,26rem)]","aria-hidden":!0}),e.jsxs("div",{className:"relative z-10 flex min-h-[220px] flex-col justify-between gap-3 px-4 py-3.5 sm:min-h-[340px] sm:gap-4 sm:px-6 sm:py-5 md:min-h-[420px] md:gap-5 md:px-8 md:py-6",children:[e.jsxs("div",{className:"shrink-0",children:[kt&&e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-0.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-white [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:"Paused"}),e.jsx("p",{className:"text-sm font-bold text-amber-300 [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:`Submissions are paused for this ${vt}`}),e.jsx("p",{className:"mt-0.5 text-[11px] font-medium text-white [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:"Your time remaining is held until it reopens."})]}),nt&&na>0&&u.deadline&&(!Xe||V)&&e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-0.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-white [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:Xe?"Submissions close in":"Ends in"}),e.jsx(Yo,{targetDate:new Date(u.deadline),variant:"compact",onDarkBackground:!0,showDueAt:!W,className:"justify-start gap-1.5"}),Xe&&e.jsx("p",{className:"mt-1 text-xs font-bold text-emerald-300 [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:Ne})]}),nt&&Xe&&!V&&e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-0.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-white [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:"Open campaign"}),e.jsx("p",{className:"text-sm font-bold text-emerald-300 [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:Ne})]}),fo&&e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-0.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-white [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:"Deadline passed"}),e.jsx("p",{className:"text-sm font-bold text-amber-300 [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:`Late entries still accepted for this ${vt}`}),la&&e.jsxs("p",{className:"mt-0.5 text-[11px] font-medium text-white [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:["Closes in ",la]})]}),!Xe&&!nt&&!kt&&u.status!=="draft"&&e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-0.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-white [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:us==="completed"?"Results":"Submissions closed"}),e.jsx("p",{className:"text-sm font-bold text-amber-300 [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:us==="completed"?ia?"Winners announced":"Closed without winners":us==="community_judging"?"Community voting on entries":us==="brand_judging"?"The brand is choosing winners":"Winners announced soon"}),us==="community_judging"&&bn&&e.jsxs("p",{className:"mt-0.5 text-[11px] font-medium text-white [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:["Ends in ",bn.timeRemaining,e.jsxs("span",{className:"hidden sm:inline",children:[" · ",bn.endTimeFormatted]})]})]}),ra&&e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-0.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-white [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:"Submissions closed"}),e.jsx("p",{className:"text-sm font-bold text-violet-300 [text-shadow:0_0_2px_rgba(0,0,0,1),0_1px_4px_rgba(0,0,0,0.95)]",children:"Approved ads keep earning"})]})]}),e.jsxs("div",{className:"w-full max-w-4xl flex flex-col gap-2 sm:gap-3 md:gap-4",children:[(yn||da)&&e.jsxs("div",{className:"flex flex-col gap-1.5 text-xs text-white [text-shadow:0_0_1px_rgba(0,0,0,0.95),0_1px_3px_rgba(0,0,0,0.88)] sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-3 sm:gap-y-2 sm:text-sm",children:[yn&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex -sp
7ace-x-2",children:uo?e.jsx("div",{className:"h-6 w-6 shrink-0 animate-pulse rounded-full border border-white/25 bg-white/5 sm:h-7 sm:w-7","aria-hidden":!0}):ea.length===0?e.jsx("div",{className:"h-6 w-6 shrink-0 rounded-full border border-dashed border-white/35 bg-black/20 sm:h-7 sm:w-7","aria-hidden":!0}):ea.slice(0,W?3:5).map(l=>e.jsx("div",{className:"relative h-6 w-6 shrink-0 overflow-hidden rounded-full border border-black/50 bg-zinc-800 ring-1 ring-white/35 sm:h-7 sm:w-7",children:e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-zinc-800/90",children:e.jsx(In,{userId:l.creatorId,defaultAvatarConfig:l.defaultAvatarConfig??void 0,size:"xs",className:"scale-110"})})},l.creatorId))}),e.jsx("span",{children:rr>0?`${rr.toLocaleString()} ${qt(rr,"entry","entries")} submitted`:"No submissions yet"})]}),da&&e.jsxs(e.Fragment,{children:[yn&&e.jsx("span",{className:"hidden h-4 w-px bg-white/35 sm:block","aria-hidden":!0}),(()=>{const l=e.jsxs("button",{type:"button",className:"flex items-center gap-2 rounded-md text-left outline-none transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-cyan-200/60 focus-visible:ring-offset-2 focus-visible:ring-offset-black",children:[e.jsx("div",{className:"flex -space-x-2",children:Ae.slice(0,W?3:Ae.length).map(de=>e.jsx("div",{className:"relative h-6 w-6 shrink-0 overflow-hidden rounded-full border border-black/50 bg-zinc-800 ring-1 ring-cyan-200/50 sm:h-7 sm:w-7",children:e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-zinc-800/90",children:e.jsx(In,{userId:de.creatorId,defaultAvatarConfig:d?void 0:de.defaultAvatarConfig??void 0,size:"xs",className:"scale-110"})})},de.creatorId))}),e.jsx("span",{children:`${Le.toLocaleString()} participating`})]}),C=e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mb-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-cyan-200/80",children:"Participating"}),e.jsx("ul",{className:"space-y-2",children:Ae.map(de=>{const We=d?Ws(de.creatorId):de.displayName||de.username||"Creator";return e.jsxs("li",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("div",{className:"relative h-7 w-7 shrink-0 overflow-hidden rounded-full border border-white/15 bg-zinc-800",children:e.jsx("div",{className:"flex h-full w-full items-center justify-center",children:e.jsx(In,{userId:de.creatorId,displayName:We,defaultAvatarConfig:d?void 0:de.defaultAvatarConfig??void 0,size:"xs",className:"scale-110"})})}),e.jsx("span",{className:"truncate text-sm font-medium text-white/90",children:We})]},de.creatorId)})}),Le>Ae.length&&e.jsxs("p",{className:"mt-2 text-[11px] text-white/50",children:["+",(Le-Ae.length).toLocaleString()," more"]})]}),le="w-56 border-white/10 bg-zinc-950/95 p-3 text-white shadow-xl backdrop-blur-md";return f?e.jsxs(bs,{children:[e.jsx(Ks,{asChild:!0,children:l}),e.jsx(vs,{side:"bottom",align:"start",className:h(le,"z-[90]"),children:C})]}):e.jsxs(Qo,{openDelay:120,closeDelay:80,children:[e.jsx(Zo,{asChild:!0,children:l}),e.jsx(Xo,{side:"bottom",align:"start",className:le,children:C})]})})()]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2",children:[ka&&e.jsxs("span",{className:Ms,children:[e.jsx(gr,{className:Ur,"aria-hidden":!0}),ka==="image"?W?"Images":"Image submissions":W?"Video or image":"Videos or images"]}),Na&&Sn?.map(l=>e.jsxs("span",{className:Ms,children:[e.jsx(Hd,{className:Ur,"aria-hidden":!0}),l]},l)),Na&&(Rs!=null||ar!=null)&&e.jsxs("span",{className:Ms,children:[e.jsx(Fs,{className:Ur,"aria-hidden":!0}),Rs!=null&&ar!=null?`${qr(Rs)} â ${qr(ar)}`:Rs!=null?`Min ${qr(Rs)}`:`Max ${qr(ar)}`]}),Co?e.jsx("span",{className:Ms,title:"Unlimited submissions per creator",children:e.jsx("span",{"aria-label":"Unlimited submissions per creator",children:W?"â / creator":"â submissions per creator"})}):e.jsx("span",{className:Ms,title:"Allowed submissions per creator",children:ir===1?W?"1 / creator":"Only 1 submission per creator":W?`Max ${ir} / creator`:`Max ${ir} submissions per creator`}),No,ko]}),e.jsx("div",{className:"min-w-0 max-w-full pb-px pr-14 sm:pr-16",children:e.jsx("h1",{className:"w-full min-w-0 py-0.5 text-base font-bold leading-[1.2] tracking-tight text-white break-words [overflow-wrap:anywhere] sm:text-xl sm:leading-snug md:text-2xl md:leading-snug lg:text-3xl lg:leading-snug xl:text-4xl [text-shadow:0_0_2px_rgba(0,0,0,0.95),0_1px_3px_rgba(0,0,0,0.9),0_2px_20px_rgba(0,0,0,0.65)]",children:u.title})})]})]}),kn&&nr&&e.jsx("div",{className:"absolute bottom-3 right-3 z-10 rounded-lg border border-white/10 bg-black/50 p-1.5 backdrop-blur-md sm:bottom-4 sm:right-4 sm:p-2",children:e.jsx("img",{src:nr,alt:"Brand",className:"h-8 w-8 object-contain sm:h-10 sm:w-10"})})]}),e.jsx("div",{className:"w-full max-w-none pb-8 px-3 sm:px-4 md:px-5 lg:px-8 xl:px-10",children:e.jsxs("div",{className:"mt-3 w-full max-w-none sm:mt-4",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)] gap-6 lg:gap-8 xl:gap-10",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-8",children:[nt&&!_e.canEnter&&e.jsx("div",{className:"rounded-lg bg-amber-500/10 border border-amber-500/30 px-4 py-4",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(Va,{className:"h-4.5 w-4.5 text-amber-400 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1.5 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-amber-300",children:"Contest Passes Used Up"}),e.jsx("p",{className:"text-xs text-amber-200/70 leading-relaxed",children:"You've used all your contest passes and are now only eligible for credit-only contests. To unlock cash contests again, participate and perform well in credit-only contests."})]})]})}),Pr.length>0&&e.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-3",children:[e.jsxs("div",{className:"flex w-full min-w-0 items-end justify-between gap-2 sm:gap-3",children:[e.jsx("nav",{className:"flex min-w-0 flex-1 flex-row flex-nowrap items-end gap-1 overflow-x-auto overflow-y-hidden border-b border-border [-ms-overflow-style:none] [scrollbar-width:none] sm:gap-2 [&::-webkit-scrollbar]:hidden","aria-label":Xe?"Campaign brief sections":"Contest brief sections",children:Pr.map(({id:l,label:C})=>e.jsx("button",{type:"button",onClick:()=>n.startTransition(()=>D(l)),"aria-current":M===l?"true":void 0,className:h("shrink-0 whitespace-nowrap rounded-t-md px-4 py-2.5 text-center text-base font-semibold transition-colors sm:px-6","-mb-px border-b-2",M===l?"border-primary bg-muted/50 text-foreground":"border-transparent bg-transparent text-muted-foreground hover:bg-muted/30 hover:text-foreground"),children:C},l))}),M==="brief"&&!co&&Jn&&e.jsx(Nd,{briefText:Jn,className:"mb-2 shrink-0"})]}
7),e.jsx("div",{className:"min-w-0 w-full",children:M==="updates"&&Pe&&ce.length===0?e.jsx("div",{className:"rounded-lg border border-border bg-muted/30 px-3 py-2.5 text-xs text-muted-foreground",children:"Updates could not be loaded right now. This contest may still have announcements â refresh to try again."}):M==="updates"&&ce.length>0?e.jsx(pi,{contestUpdates:ce,updatesSectionRef:ne,hasUnreadContestUpdates:Je,unreadContestUpdateCount:we,lastSeenNewestCreatedAt:rt,className:"border-t-0 pt-0"}):M==="qa"&&ut&&u.business_id?e.jsx(oi,{contestId:u.id,businessId:u.business_id,isActive:ct,variant:"tab"}):M==="brand_kit"&&So?e.jsx(mu,{variant:"inline",referenceMedia:ye.reference_media,usefulLinks:ye.useful_links,exampleUrls:ye.example_urls,brandLogoUrl:nr,companyName:u.business_profile?.company_name,onDownloadAll:jo,onDownloadSingle:ga,isDownloading:U,onMediaClick:ve}):M==="inspiration"&&xn?e.jsx(pu,{businessId:u.business_id,contestId:u.id,enabled:sr}):e.jsx("div",{className:"space-y-4",children:e.jsx(kd,{mode:"view",audience:"creator",hideCopyButton:!0,description:u.description,brief:ye.brief_pages,onAllViewed:Ce,contestTitle:u.title,brandName:u.business_profile?.company_name??u.brand?.name,brandLogoUrl:u.business_profile?.company_logo_url??nr??u.business_profile?.avatar_url,coverImageUrl:kn})})})]}),Pe&&ce.length===0&&!Y&&e.jsx("div",{className:"rounded-lg border border-border bg-muted/30 px-3 py-2.5 text-xs text-muted-foreground",children:"Updates could not be loaded right now. This contest may still have announcements â refresh to try again."}),ce.length>0&&!Y&&e.jsx(pi,{contestUpdates:ce,updatesSectionRef:ne,hasUnreadContestUpdates:Je,unreadContestUpdateCount:we,lastSeenNewestCreatedAt:rt}),(nt||kt)&&!fe&&Rr&&e.jsx("div",{className:"rounded-lg border border-border/80 bg-muted/30 px-4 py-3",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:Rr})}),!fe&&nt&&!Te&&!$t&&e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/[0.06] px-4 py-3",children:[e.jsx("span",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-amber-500/30 bg-amber-500/10",children:e.jsx(Qr,{className:"h-3.5 w-3.5 text-amber-400","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:et==="cpp_only"?"Open to Creator Partners":"Open to creators outside the Partner Program"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Yt}),et==="cpp_only"&&e.jsx(Mt,{to:"/creator/partner-program",className:"inline-block text-xs font-medium text-amber-300 underline underline-offset-2 hover:text-amber-200 transition-colors",children:"Learn about the Partner Program"})]})]}),re&&!fe&&e.jsx(gu,{id:"contest-pick-section",brandOptions:ze,myReservedBrandIds:Oe,maxSelectionsPerBrand:Ue?.max_selections_per_brand??2,maxBrandsPerCreator:xo,isLoading:Rt,onReserve:l=>lt.mutate(l),onCancel:l=>mt.mutate(l),onSubmit:ha,isReserving:lt.isPending,isCancelling:mt.isPending,submittedBrandIds:pn,isActive:nt,isPaused:kt,kindNoun:vt,canReserve:Te||$t}),He&&!fe&&e.jsx(wu,{id:"contest-pick-section",productOptions:at,myReservedProductIds:gt,maxSelectionsPerProduct:Ue?.max_selections_per_product??2,maxProductsPerCreator:go,isLoading:Hs,onReserve:l=>Ft.mutate(l),onCancel:l=>yt.mutate(l),onSubmit:pa,isReserving:Ft.isPending,isCancelling:yt.isPending,submittedProductIds:St,isActive:nt,isPaused:kt,kindNoun:vt,canReserve:Te||$t})]}),e.jsxs("div",{className:"order-first lg:order-none flex flex-col gap-6 min-w-0",children:[As&&e.jsxs("div",{className:h("grid min-w-0 gap-2 sm:gap-3",ca||fa?"grid-cols-2":"grid-cols-1"),children:[ca&&e.jsx(Bs,{fullWidth:!0,disabled:!wn,disabledReason:Rr,label:ma,onClick:()=>ua()}),fa&&e.jsx(Bs,{fullWidth:!0,disabled:kt||!Te||$r&&!wn,disabledReason:Rr,label:vo,icon:$r?void 0:sc,onClick:wo}),e.jsx(ci,{fullWidth:!0,onClick:()=>{_s()},disabled:!Te||pe||ke.isPending,disabledReason:!Te&&!$t?Yt:void 0,isOpening:pe,participate:u.status==="active"?{isParticipating:I,disabled:!Te||De||ke.isPending||pe,onClick:()=>
7{if(!Te){ee.error("Not eligible",{description:Yt});return}ke.mutate(!I)}}:void 0})," "]}),As&&X&&u?.id&&nt&&e.jsx(Nu,{contestId:u.id,isOpening:pe,onEnterStudio:()=>{_s({openClaim:!0})}}),As&&ms&&!g&&!Ls&&e.jsx("p",{className:"text-sm text-violet-300",children:`This ${vt} requires Anthum Studio. Create your entry in the Studio first.`}),fe&&nt&&e.jsxs("div",{className:"grid min-w-0 grid-cols-2 gap-2 sm:gap-3",children:[e.jsx(Bs,{fullWidth:!0,label:"Submit",onClick:()=>r(Nn)}),e.jsx(ci,{fullWidth:!0,onClick:()=>r(Nn),participate:u.status==="active"?{isParticipating:!1,onClick:()=>r(Nn)}:void 0})]}),Xe&&wr&&e.jsx(lu,{challengeId:u.id}),Xe?e.jsx(iu,{terms:st,submissionsClosed:ra}):e.jsx(nu,{prizeAmount:u.prize_amount,creditPrizeAmount:ye.credit_prize_amount,studioCashPrizeAmount:ye.studio_cash_prize_amount??(ye.prize_distribution?bl(ye.prize_distribution):null),prizeDistribution:ye.prize_distribution,trackCount:me?.length||0,phase:us==="deciding"?"brand_judging":us,showAnthumBonusFraming:va,bonusPct:wa}),ut&&u.business_id&&Ts&&!ft&&e.jsx(oi,{contestId:u.id,businessId:u.business_id,isActive:ct,variant:"prompt",onAskSuccess:()=>n.startTransition(()=>D("qa"))}),me&&me.length>0?e.jsx(Sc,{compact:!0,sidebarCompact:!0,tracks:me,prizeAmount:u.prize_amount,prizeDistribution:ye.prize_distribution||null,userSubmittedTrackIds:Nt,userTrackSubmissionCounts:Wt,maxSubmissionsPerTrack:ye.max_submissions_per_creator??null,isActive:nt&&!i&&!fe,contestRequirements:ye.requirements,onSubmitToTrack:ua,hideSubmitButtons:!0,aspectRatio:ye.aspect_ratio}):As&&ms&&g?e.jsx("p",{className:"text-sm text-violet-300",children:"Select an entry from your Studio project to submit."}):null]})]}),cs&&e.jsx(Fc,{id:"winners",submissions:q,winnerIds:xa,tracks:me,prizeDistribution:ye.prize_distribution??void 0,onSubmissionClick:Ut,userWinningSubmission:yo,prizeAmount:u.prize_amount})]})}),(!cs||!ia)&&!(Ls&&rr===0)&&e.jsx("div",{className:"w-full max-w-none mt-6 px-3 sm:px-4 md:px-5 lg:px-8 xl:px-10",children:e.jsx($c,{submissions:q,winnerIds:xa,top30Ids:yr,onSubmissionClick:Ut,onDeleteSubmission:os,adLaunchedIds:Ss,adLockedIds:kr,adActiveIds:hn,approvalLocksDelete:st?.spend_basis==="contract_tiered",onSubmissionUpdated:Ve,showTop30Badges:po,isPrivate:ye._privateSubmissions,contestId:u.id,currentUserId:X?.id,communityJudgingEnabled:ye.community_judging_enabled,isContestActive:nt,contestDeadline:u.deadline,requireSocialPost:ye.require_social_post,bundleSize:ye.bundle_size??void 0,brandOptionsMap:Ot,productOptionsMap:Ct,challengeTracks:me,onOrderChange:Xs,aspectRatio:ye.aspect_ratio,isPerformanceCampaign:Xe,perfApprovedIds:Sr,perfDeliveryBySubmissionId:ls,perfCategoryTagsBySubmissionId:Ht,perfDisplayMetricsBySubmissionId:fn,perfRepublishingBySubmissionId:Is,perfPlacementCountBySubmissionId:ds,perfActivePlacementCountBySubmissionId:Ps,perfDeliveringBySubmissionId:Cr,perfEarningsWonUsdBySubmissionId:o})})]}),e.jsx(Ta,{}),e.jsx(Su,{items:ue,index:T,onIndexChange:_,onClose:()=>_(null),onDownload:ga}),X&&u&&!i&&e.jsx(wc,{isOpen:P,onClose:()=>{R(!1),rs(void 0),Vt(void 0),S(null),b(null),(v||A||y)&&r(window.location.pathname,{replace:!0})},challengeId:u.id,challengeTitle:u.title,onSubmissionCreated:bt,preSelectedChallengeId:Q,bundleSize:u.bundle_size,selectedBrandOptionId:Ys,reservedBrands:pt,brandSelectionRequired:re,selectedProductOptionId:Qs,reservedProducts:Zs,productSelectionRequired:He,isEditing:!!B&&!!jr,existingSubmission:B?jr??void 0:void 0,initialVideoId:K??void 0,lateSubmissionMode:qe,isPerformanceCampaign:Xe}),e.jsx(Vn,{open:F,onOpenChange:E,children:e.jsxs(Wn,{className:"sm:max-w-md bg-card border-border",children:[e.jsxs(Gn,{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Va,{className:"h-5 w-5 text-amber-400"}),"Contest Passes Used Up"]}),e.jsx(Ni,{className:"text-muted-foreground text-sm leading-relaxed",children:_e.reason}),e.jsx("div",{className:"flex flex-col gap-3 mt-2",children:e.jsx(Ee,{className:"w-full",onClick:()=>E(!1),children:"Got it"})})]})}),H&&e.jsx(al,{submission:H,open:!!H,onOpenChange:l=>!l&&te(null),contestTitle:u?.title,onNavigatePrevious:It,onNavigateNext:Ns,hasPrevious:jt>0,hasNext:jt<Ze.length-1,submissions:Ze,onSelectSubmission:te}),e.jsx(hd,{open:!!z,onClose:()=>ie(null),video:z,list:cs?Ye:ht,onSelectVideo:ie,title:u?.title??(Xe?"Campaign":"Contest"),listTitle:"More submissions",adLaunchIdBySubmissionId:Xe?tr:void 0,videoPerfByAdLaunchId:Xe?k:void 0}),e.jsx(sn,{open:!!is,onOpenChange:l=>{l||Js(null)},children:e.jsxs(rn,{children:[e.jsxs(nn,{children:[e.jsx(an,{children:"Delete this entry?"}),e.jsx(zs,{children:is?.title?`"${is.title}" will be removed from this ${vt}. This cannot be undone.`:`This entry will be removed from this ${vt}. This cannot be undone.`})]}),e.jsxs(on,{children:[e.jsx(ln,{children:"Keep entry"}),e.jsx(dn,{className:"bg-red-600 text-white hover:bg-red-700",onClick:()=>{is&&dt.mutate(is.id),Js(null)},children:"Delete"})]})]})})]})},En=()=>e.jsxs("div",{className:"container py-8 space-y-6",children:[e.jsxs("div",{className:"space-y-4 animate-pulse",children:[e.jsx("div",{className:"h-10 bg-foreground
7/5 rounded-lg w-2/3"}),e.jsx("div",{className:"h-5 bg-foreground/5 rounded w-1/2"})]}),e.jsx("div",{className:"flex gap-4 animate-pulse",children:[1,2,3,4].map(t=>e.jsx("div",{className:"h-20 w-32 bg-foreground/5 rounded-lg"},t))}),e.jsxs("div",{className:"space-y-2 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-foreground/5 rounded w-full"}),e.jsx("div",{className:"h-4 bg-foreground/5 rounded w-5/6"}),e.jsx("div",{className:"h-4 bg-foreground/5 rounded w-4/6"})]}),e.jsxs("div",{className:"mt-8 animate-pulse",children:[e.jsx("div",{className:"h-6 bg-foreground/5 rounded w-40 mb-4"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(t=>e.jsx(Xt.div,{className:"aspect-video bg-foreground/5 rounded-lg",initial:{opacity:.3},animate:{opacity:[.3,.5,.3]},transition:{duration:1.5,repeat:1/0,delay:t*.1}},t))})]})]});function Au({contestId:t,contestTitle:s,brandName:r,onAccessGranted:a,className:i}){const{session:c,user:d}=xr(),[f,x]=n.useState(""),[p,m]=n.useState(!1),[v,A]=n.useState(!1),y=async()=>{if(!(!c?.access_token||!f.trim())){m(!0);try{const{data:P,error:R}=await be.functions.invoke("contest-keys-redeem-v1",{headers:{Authorization:`Bearer ${c.access_token}`},body:{contest_id:t,key_code:f.trim()}});if(R)throw R;P?.success&&(A(!0),ee("Access Granted!",{description:"You now have access to this contest."}),setTimeout(()=>{a()},1500))}catch(P){console.error("Failed to redeem key:",P);const R=P instanceof Error?P.message:"Unknown error";ee.error("Invalid Access Key",{description:R.includes("already been used")?"This key has already been used by someone else.":R.includes("already have access")?"You already have access to this contest!":"The access key you entered is invalid. Please check and try again."})}finally{m(!1)}}},N=P=>(P.replace(/[^a-zA-Z0-9]/g,"").toUpperCase().match(/.{1,4}/g)||[]).join("-").substring(0,14);return v?e.jsx($a,{className:h("bg-green-500/10 border-green-500/30",i),children:e.jsxs(Ua,{className:"py-12 text-center",children:[e.jsx(es,{className:"w-16 h-16 mx-auto mb-4 text-green-400"}),e.jsx("h3",{className:"text-xl font-bold text-green-400 mb-2",children:"Access Granted!"}),e.jsx("p",{className:"text-foreground/70",children:"Loading contest details..."})]})}):e.jsxs($a,{className:h("bg-card/80 border-purple-500/30",i),children:[e.jsxs(ql,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-purple-500/20 flex items-center justify-center mb-4",children:e.jsx(Qr,{className:"w-8 h-8 text-purple-400"})}),e.jsx(Fl,{className:"text-xl",children:"Private Contest"}),e.jsxs(Ol,{className:"text-foreground/60",children:[s,r&&e.jsxs("span",{className:"block text-sm mt-1",children:["by ",r]})]})]}),e.jsxs(Ua,{className:"space-y-4",children:[e.jsx("p",{className:"text-center text-foreground/70 text-sm",children:"This contest requires an access key to participate. If you have a key, enter it below."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-purple-400"}),e.jsx(Kt,{value:f,onChange:P=>x(N(P.target.value)),placeholder:"XXXX-XXXX-XXXX",className:"pl-10 bg-muted border-purple-500/30 text-center font-mono tracking-wider uppercase",maxLength:14,disabled:p})]}),e.jsx(Ee,{onClick:y,disabled:p||f.length<12,className:"w-full bg-purple-600 hover:bg-purple-500",children:p?e.jsxs(e.Fragment,{children:[e.jsx(xt,{className:"w-4 h-4 mr-2 animate-spin"}),"Verifying..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Wa,{className:"w-4 h-4 mr-2"}),"Unlock Contest"]})})]}),e.jsx("p",{className:"text-center text-foreground/40 text-xs",children:"Don't have a key? Contact the brand directly to request access."})]})]})}function Mu({lateSubmissionMode:t=!1}={}){const{id:s}=fi(),{user:r,session:a,profile:i,loading:c}=xr(),{hasCreatorRole:d}=Ro(),{isPreviewMode:f}=Vs(),{data:x,isLoading:p,error:m,refetch:v}=$o(s,r?.id,i?.user_type),A=!r&&!f,y=!!s&&(A||!!r&&!!a),{data:N,refetch:P,isFetched:R}=Bo(s,{enabled:y}),{data:B,isLoading:S}=bi(s),{hasAccess:K,isLoading:b,refetch:F}=lc(s,r?.id,x?.visibility,x?.business_id,i?.user_type),E=p||!A&&!f&&(c&&(!r||!i)||b||r&&!i||y&&!R);if(!f&&r&&!i)return e.jsx("div",{className:"min-h-screen bg-premium-dark",children:e.jsx(En,{})});if(!f&&r&&i&&!d)return window.location.href=`/contest/${s}`,e.jsx(En,{});if(E)return e.jsx("div",{className:"min-h-screen bg-premium-dark",children:e.jsx(En,{})});if(m||!x)return e.jsx("div",{className:"min-h-screen bg-premium-dark",children:e.jsx(Un,{contest:null,loadFailed:!!m})});if(x.visibility==="private_invite"&&!K&&!f)return e.jsx("div",{className:"min-h-screen bg-premium-dark flex flex-col items-center justify-center px-4 py-8",children:e.jsx(Au,{contestId:x.id,contestTitle:x.title,brandName:x.business_profile?.company_name,onAccessGranted:()=>{F(),v()}})});if(A)return e.jsx(Un,{contest:x,submissions:N||[],challenges:B||[],refetchSubmissions:P,lateSubmissionMode:t});const O={contest:x,submissions:N||[],challenges:B||[],user:r,profile:i,refetchSubmissions:P,lateSubmissionMode:t};return e.jsx(Un,{...O})}const Pp=Object.freeze(Object.defineProperty({__proto__:null,default:Mu},Symbol.toStringTag,{value:"Module"}));
7export{En as C,Xi as V,Un as a,Au as b,Pp as c,lc 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.