1import{j as e}from"./vendor-query-CniT1WJL.js";import{u as ie,r as n,L as Z}from"./vendor-react-69GsFwrV.js";import{u as de,F as A,V as P,P as ce,at as me,er as ue,f as U,es as xe,et as pe,S as T,b as D,c as $,d as E,e as w,eu as fe,ev as he,ew as ge,G as be}from"./index-KjAD5lCC.js";import{P as je}from"./PartnerNav-CPlF75u7.js";import{S as ve,bI as ye,J as Ne,aw as we,aa as Ce,bN as R,bO as z,bP as O,ao as F,aM as M,_ as Q,ap as Se,bQ as ke,ab as ze,X as Y,D as J,aC as Pe,aj as Le}from"./vendor-ui-Ad3ANzF6.js";import"./vendor-forms-q6h4WU-p.js";const Ae=new Set(["canva.com","www.canva.com"]),Te=new Set(["marketplace.canva.com","media-public.canva.com","static-cse.canva.com","www.canva.com"]),De={youtube:new Set(["i.ytimg.com","img.youtube.com","www.youtube-nocookie.com","www.youtube.com"]),vimeo:new Set(["i.vimeocdn.com","player.vimeo.com","secure-b.vimeocdn.com","vimeo.com"]),peertube:new Set(["video.vidapeps.com"])};function I(s,t){if(typeof s!="string")return null;try{const a=new URL(s);return a.protocol!=="https:"||!t.has(a.hostname)||a.port!==""||a.username!==""||a.password!==""?null:a.toString()}catch{return null}}function q(s){return I(s,Ae)}function $e(s){return I(s,Te)}function ee(s,t){return typeof t!="string"?null:s==="youtube"&&/^[A-Za-z0-9_-]{11}$/.test(t)?`https://www.youtube-nocookie.com/embed/${t}`:s==="vimeo"&&/^[1-9]\d{0,14}$/.test(t)?`https://player.vimeo.com/video/${t}`:s==="peertube"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)?`https://video.vidapeps.com/videos/embed/${t.toLowerCase()}`:null}function Ee(s,t,a){return!ee(s,t)||typeof t!="string"?null:s==="youtube"?`https://i.ytimg.com/vi/${t}/maxresdefault.jpg`:s==="vimeo"||s==="peertube"?I(a,De[s]):null}function se(s,t=!1){if(!Number.isSafeInteger(s)||s<=0)throw new Error("Invalid partner asset ID");const a=`/api/partners/resources/assets/${s}/content`;return t?`${a}?download=1`:a}function Ue(s,t){const a=se(s);return t===a?a:null}const Re=/^[A-Za-z0-9][A-Za-z0-9-]{0,119}\.[a-z0-9]{1,10}$/;function Oe(s,t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Invalid partner asset download response");const a=t;if(Object.keys(a).sort().join(",")!=="downloadPath,filename"||a.downloadPath!==se(s,!0)||typeof a.filename!="string"||a.filename.length>131||!Re.test(a.filename))throw new Error("Invalid partner asset download response");return{downloadPath:a.downloadPath,filename:a.filename}}const Fe=[{value:"assets",label:"Brand Studio",icon:R},{value:"canva",label:"Canva Templates",icon:z},{value:"video",label:"Video Library",icon:O},{value:"resources",label:"Marketing Resources",icon:F}];function Me(s){return s==null?"":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(0)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function Ie(s){if(!s)return"";const t=Math.floor(s/60),a=s%60;return`${t}:${a.toString().padStart(2,"0")}`}function Be(s){return s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):""}const te={"swipe-copy":"Swipe Copy","email-template":"Email Template","ad-script":"Ad Script","compliance-guide":"Compliance Guide","claim-sheet":"Claim Sheet",faq:"FAQ"};function Ve({active:s,onSelect:t}){return e.jsx("div",{role:"tablist","aria-label":"Resource hub sections",className:"mb-6 grid grid-cols-2 gap-1 rounded-pill bg-muted p-1 sm:grid-cols-4",children:Fe.map(a=>{const o=s===a.value,c=a.icon;return e.jsxs("button",{type:"button",role:"tab","aria-selected":o,onClick:()=>
1t(a.value),className:U("flex items-center justify-center gap-1.5 rounded-pill px-3 py-2 text-xs font-semibold sm:text-sm transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",o?"bg-card text-ink shadow-sm":"text-ink-3 hover:text-ink"),children:[e.jsx(c,{className:"size-4"}),e.jsx("span",{className:"hidden sm:inline",children:a.label}),e.jsx("span",{className:"sm:hidden",children:a.label.split(" ")[0]})]},a.value)})})}function _e({collection:s,onOpen:t}){return e.jsxs("button",{type:"button",onClick:()=>t(s.slug),className:"group flex flex-col items-start rounded-card border border-card-border bg-card p-5 text-left hover:border-primary/40 hover:shadow-sm transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:[e.jsx("div",{className:"mb-3 flex size-12 items-center justify-center rounded-card",style:{backgroundColor:s.accentColor?`${s.accentColor}20`:"var(--vida-mint-soft, #e8f5e9)"},children:e.jsx(ze,{className:"size-6",style:{color:s.accentColor??"var(--vida-green-700, #1b5e20)"}})}),e.jsx("h3",{className:"font-display text-lg font-bold text-foreground leading-tight",children:s.name}),s.description&&e.jsx("p",{className:"mt-1 text-sm text-muted-foreground line-clamp-2",children:s.description}),e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(R,{className:"size-3.5"}),e.jsxs("span",{children:[s.assetCount," ",s.assetCount===1?"file":"files"]})]})]})}function He({collection:s,onClose:t,onDownload:a}){const[o,c]=n.useState(""),[f,l]=n.useState("all"),[m,g]=n.useState("manual"),h=["all",...Array.from(new Set(s.items.map(r=>r.asset.kind)))],i=[...s.items].filter(r=>f==="all"||r.asset.kind===f).filter(r=>{const u=o.trim().toLowerCase();return u?[r.displayLabel,r.asset.alt,r.asset.filename,r.asset.kind,r.asset.mime].filter(Boolean).some(y=>String(y).toLowerCase().includes(u)):!0}).sort((r,u)=>m==="name"?(r.displayLabel??r.asset.alt??r.asset.filename).localeCompare(u.displayLabel??u.asset.alt??u.asset.filename):m==="kind"?r.asset.kind.localeCompare(u.asset.kind):m==="size"?(u.asset.bytes??0)-(r.asset.bytes??0):r.sortOrder-u.sortOrder);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:t,children:e.jsxs("div",{className:"relative flex max-h-[90vh] w-full max-w-4xl flex-col overflow-hidden rounded-card bg-card shadow-2xl",onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-card-border p-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold text-foreground",children:s.name}),s.description&&e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.description})]}),e.jsx("button",{type:"button",onClick:t,"aria-label":"Close",className:"shrink-0 rounded-pill p-2 text-muted-foreground hover:bg-muted",children:e.jsx(Y,{className:"size-5"})})]}),e.jsxs("div",{className:"overflow-y-auto p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(M,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"text",value:o,onChange:r=>c(r.target.value),placeholder:"Search this collectionâ¦",className:"w-full rounded-pill border border-card-border bg-card py-2 pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"})]}),e.jsxs(T,{value:f,onValueChange:l,children:[e.jsx(D,{className:"rounded-pill border border-card-border bg-card px-3 py-2 text-sm text-foreground",children:e.jsx($,{})}),e.jsx(E,{children:h.map(r=>e.jsx(w,{value:r,children:r==="all"?"All kinds":r},r))})]}),e.jsxs(T,{value:m,onValueChange:r=>g(r),children:[e.jsx(D,{className:"rounded-pill border border-card-border bg-card px-3 py-2 text-sm text-foreground",children:e.jsx($,{})}),e.jsxs(E,{children:[e.jsx(w,{value:"manual",children:"Manual order"}),e.jsx(w,{value:"name",children:"Name A-Z"}),e.jsx(w,{value:"kind",children:"Kind"}),e.jsx(w,{value:"size",children:"Largest files"})]})]})]}),s.items.length===0?e.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:"No assets in this collection yet."}):i.length===0?e.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:"No assets match this collection filter."}):e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:i.map(r=>{const u=r.asset.mime.startsWith("image/"),y=r.asset.mime==="image/svg+xml",x=Ue(r.asset.id,r.asset.previewPath);return e.jsxs("div",{className:"flex flex-col rounded-card border border-card-border bg-muted/30 overflow-hidden",children:[e.jsx("div",{className:"aspect-video bg-muted flex items-center justify-center overflow-hidden",children:u&&!y&&x?e.jsx("img",{src:x,alt:r.displayLabel??r.asset.alt??"",loading:"lazy",className:"h-full w-full object-contain"}):e.jsx(F,{className:"size-10 text-muted-foreground"})}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 p-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground line-clamp-2",children:r.displayLabel??r.asset.alt??r.asset.filename}),e.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[y?"SVG":r.asset.mime.split("/")[1]?.toUpperCase(),r.asset.bytes?` · ${Me(r.asset.bytes)}`:"",r.asset.width?` · ${r.asset.width}Ã${r.asset.height}`:""]})]}),e.jsxs("button",{type:"button",onClick:()=>a(r),className:"inline-flex items-center justify-center gap-1.5 rounded-pill border border-card-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30 transition-colors",children:[e.jsx(J,{className:"size-3.5"}),"Download"]})]})]},r.id)})})]})]})})}function Ge({collections:s}){const[t,a]=n.useState(null),[o,c]=n.useState(null),[f,l]=n.useState(null),[m,g]=n.useState(""),[h,i]=n.useState("manual"),r=n.useMemo(()=>{const x=m.trim().toLowerCase();return[...s].filter(b=>!x||b.name.toLowerCase().includes(x)||b.description?.toLowerCase().includes(x)||b.slug.toLowerCase().includes(x)).sort((b,N)=>h==="name"?b.name.localeCompare(N.name):h==="count"?N.assetCount-b.assetCount:b.sortOrder-N.sortOrder)},[s,m,h]),u=n.useCallback(async x=>{c(x);try{const b=await xe(x,{credentials:"include"});a(b)}catch{}finally{c(null)}},[]),y=n.useCallback(async x=>
1{try{const b=await pe(x.asset.id,{credentials:"include"}),{downloadPath:N,filename:C}=Oe(x.asset.id,b),v=document.createElement("a");v.href=N,v.download=C,document.body.appendChild(v),v.click(),v.remove(),l(x.id),setTimeout(()=>l(null),2e3)}catch{}},[]);return s.length===0?e.jsxs("div",{className:"rounded-card border border-card-border bg-card p-10 text-center",children:[e.jsx(R,{className:"mx-auto mb-3 size-10 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"No collections available yet."}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Check back soon for brand assets."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(M,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"text",value:m,onChange:x=>g(x.target.value),placeholder:"Search collectionsâ¦",className:"w-full rounded-pill border border-card-border bg-card py-2 pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"})]}),e.jsxs(T,{value:h,onValueChange:x=>i(x),children:[e.jsx(D,{className:"rounded-pill border border-card-border bg-card px-3 py-2 text-sm text-foreground",children:e.jsx($,{})}),e.jsxs(E,{children:[e.jsx(w,{value:"manual",children:"Featured order"}),e.jsx(w,{value:"name",children:"Name A-Z"}),e.jsx(w,{value:"count",children:"Most assets"})]})]})]}),r.length===0?e.jsx("div",{className:"rounded-card border border-card-border bg-card p-10 text-center text-sm text-muted-foreground",children:"No collections match your search."}):e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:r.map(x=>e.jsx(_e,{collection:x,onOpen:u},x.id))}),o&&e.jsx("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:"Loading collectionâ¦"}),t&&e.jsx(He,{collection:t,onClose:()=>a(null),onDownload:y}),f!==null&&e.jsxs("div",{className:"fixed bottom-[calc(var(--vp-tabbar-h)+env(safe-area-inset-bottom)+1rem)] left-1/2 -translate-x-1/2 rounded-pill bg-foreground px-4 py-2 text-xs font-medium text-background shadow-lg z-50 shell:bottom-4",children:[e.jsx(Q,{className:"mr-1 inline size-3.5"}),"Download started"]})]})}function Xe({templates:s,referralCode:t}){const[a,o]=n.useState(null),c=n.useMemo(()=>s.flatMap(l=>{const m=q(l.canvaDesignUrl);return m?[{...l,canvaDesignUrl:m,thumbnailUrl:$e(l.thumbnailUrl)}]:[]}),[s]),f=n.useCallback(l=>{const m=q(l.canvaDesignUrl);m&&(fe(l.id,{credentials:"include"}).catch(()=>{}),window.open(m,"_blank","noopener,noreferrer"))},[]);return c.length===0?e.jsxs("div",{className:"rounded-card border border-card-border bg-card p-10 text-center",children:[e.jsx(z,{className:"mx-auto mb-3 size-10 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"No Canva templates yet."}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Canva designs will appear here once published."})]}):e.jsxs("div",{children:[e.jsx("div",{className:"mb-5 rounded-card border border-primary/20 bg-primary/5 p-4",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(z,{className:"mt-0.5 size-5 shrink-0 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"How Canva templates work"}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground leading-relaxed",children:["Click any template to open it in Canva. Once it loads, use"," ",e.jsx("strong",{children:"File â Make a Copy"})," to save a version to your own Canva workspace, then customize it freely. For brand templates, click ",e.jsx("strong",{children:"Use template"})," for a one-click start. Or use the ",e.jsx("strong",{children:"Customize"})," button to overlay your referral code on a graphic right here - no Canva account needed."]})]})]})}),e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>e.jsxs("div",{className:"group flex flex-col rounded-card border border-card-border bg-card overflow-hidden hover:border-primary/40 hover:shadow-sm transition-all",children:[e.jsx("div",{className:"aspect-video bg-muted overflow-hidden relative",children:l.thumbnailUrl?e.jsx("img",{src:l.thumbnailUrl,alt:l.name,loading:"lazy",className:"h-full w-full object-cover group-hover:scale-105 transition-transform"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-gradient-to-br from-primary/10 to-accent/10",children:e.jsx(z,{className:"size-10 text-primary/40"})})}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 p-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground line-clamp-1",children:l.name}),l.description&&e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground line-clamp-2",children:l.description})]}),l.width&&l.height&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.width,"Ã",l.height,"px"]}),e.jsxs("div",{className:"mt-auto flex gap-2",children:[e.jsxs(P,{size:"sm",className:"flex-1",onClick:()=>f(l),children:[e.jsx(Se,{className:"mr-1 size-3.5"}),"Open in Canva"]}),l.thumbnailUrl&&e.jsxs(P,{size:"sm",variant:"light",onClick:()=>o(l),title:"Add your referral code to this graphic",children:[e.jsx(ke,{className:"mr-1 size-3.5"}),"Customize"]})]})]})]},l.id))}),a&&e.jsx(We,{template:a,referralCode:t,onClose:()=>o(null)})]})}function We({template:s,referralCode:t,onClose:a}){const o=n.useRef(null),[c,f]=n.useState(t?`Code: ${t}`:""),[l,m]=n.useState(48),[g,h]=n.useState("#ffffff"),[i,r]=n.useState({x:.5,y:.9}),[u,y]=n.useState(60),[x,b]=n.useState(!1),[N,C]=n.useState(!1),v=n.useId(),B=`${v}-overlay-text`,V=`${v}-font-size`,_=`${v}-bg-opacity`;n.useEffect(()=>{const d=o.current;
1if(!d||!N)return;const p=d.getContext("2d");if(!p)return;const j=new Image;j.crossOrigin="anonymous",j.onload=()=>{const H=Math.min(1,1080/j.width);if(d.width=j.width*H,d.height=j.height*H,p.drawImage(j,0,0,d.width,d.height),c.trim()){const G=d.width*i.x,X=d.height*i.y,k=l*(d.width/1080);p.font=`bold ${k}px Inter, system-ui, sans-serif`,p.textAlign="center",p.textBaseline="middle";const ae=p.measureText(c),le=k*.6,ne=k*.35,W=ae.width+le*2,L=k+ne*2;if(u>0){p.fillStyle=`rgba(12, 42, 31, ${u/100})`;const oe=L/2;p.beginPath(),p.roundRect(G-W/2,X-L/2,W,L,oe),p.fill()}p.shadowColor="rgba(0,0,0,0.4)",p.shadowBlur=4,p.shadowOffsetY=2,p.fillStyle=g,p.fillText(c,G,X),p.shadowColor="transparent",p.shadowBlur=0,p.shadowOffsetY=0}},j.src=s.thumbnailUrl??""},[c,l,g,i,u,N,s.thumbnailUrl]),n.useEffect(()=>{C(!1);const d=setTimeout(()=>C(!0),100);return()=>clearTimeout(d)},[s.thumbnailUrl]);const re=()=>{const d=o.current;d&&(b(!0),d.toBlob(p=>{if(!p)return;const j=URL.createObjectURL(p),S=document.createElement("a");S.href=j,S.download=`${s.slug}-customized.png`,S.click(),URL.revokeObjectURL(j),b(!1)},"image/png"))};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:a,children:e.jsxs("div",{className:"relative flex max-h-[90vh] w-full max-w-3xl flex-col overflow-hidden rounded-card bg-card shadow-2xl",onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-card-border p-4",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"font-display text-lg font-bold text-foreground",children:["Customize: ",s.name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Overlay your referral code or handle. Download as PNG - no Canva needed."})]}),e.jsx("button",{type:"button",onClick:a,"aria-label":"Close",className:"shrink-0 rounded-pill p-2 text-muted-foreground hover:bg-muted",children:e.jsx(Y,{className:"size-5"})})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:flex-row",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/30 rounded-card p-2 min-h-[200px]",children:e.jsx("canvas",{ref:o,className:"max-w-full max-h-[50vh] rounded shadow-lg"})}),e.jsxs("div",{className:"w-full md:w-64 space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:B,className:"text-xs font-semibold text-foreground",children:"Overlay Text"}),e.jsx("input",{id:B,type:"text",value:c,onChange:d=>f(d.target.value),placeholder:"Code: PV-XXXX or @yourhandle",className:"w-full rounded-pill border border-card-border bg-card px-3 py-1.5 text-sm text-foreground"}),t&&e.jsxs("button",{type:"button",onClick:()=>f(`Code: ${t}`),className:"text-xs text-primary hover:underline",children:["Use my referral code (",t,")"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{htmlFor:V,className:"text-xs font-semibold text-foreground",children:["Font Size: ",l,"px"]}),e.jsx("input",{id:V,type:"range",min:20,max:100,value:l,onChange:d=>m(Number(d.target.value)),className:"w-full"})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"text-xs font-semibold text-foreground",children:"Text Color"}),e.jsx("div",{className:"flex gap-2",children:["#ffffff","#d4af37","#1b5e20","#000000"].map(d=>e.jsx("button",{type:"button",onClick:()=>h(d),className:`size-8 rounded-full border-2 ${g===d?"border-primary scale-110":"border-card-border"} transition-transform`,style:{backgroundColor:d},"aria-label":`Color ${d}`},d))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{htmlFor:_,className:"text-xs font-semibold text-foreground",children:["Background Pill: ",u,"%"]}),e.jsx("input",{id:_,type:"range",min:0,max:100,value:u,onChange:d=>y(Number(d.target.value)),className:"w-full"})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"text-xs font-semibold text-foreground",children:"Position"}),e.jsx("div",{className:"grid grid-cols-3 gap-1",children:[{x:.5,y:.1,label:"Top"},{x:.1,y:.5,label:"Left"},{x:.5,y:.5,label:"Center"},{x:.9,y:.5,label:"Right"},{x:.5,y:.9,label:"Bottom"},{x:.5,y:.75,label:"Lower"}].map(d=>e.jsx("button",{type:"button",onClick:()=>r({x:d.x,y:d.y}),className:`rounded-pill px-2 py-1 text-xs font-medium ${i.x===d.x&&i.y===d.y?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:d.label},d.label))})]}),e.jsxs(P,{className:"w-full",onClick:re,disabled:x,children:[e.jsx(J,{className:"mr-1.5 size-4"}),x?"Preparingâ¦":"Download PNG"]})]})]})]})})}function K({video:s}){const[t,a]=n.useState(!1),o=Ee(s.provider,s.externalId,s.thumbnailUrl),c=n.useMemo(()=>ee(s.provider,s.externalId),[s.provider,s.externalId]),f=n.useCallback(()=>{c&&(a(!0),ge(s.id,{credentials:"include"}).catch(()=>{}))},[c,s.id]);return t&&c?e.jsxs("div",{className:"col-span-1 sm:col-span-2",children:[e.jsx("div",{className:"aspect-video rounded-card overflow-hidden bg-black",children:e.jsx("iframe",{src:c,title:s.title,className:"h-full w-full",frameBorder:"0",sandbox:"allow-same-origin allow-scripts allow-popups",allowFullScreen:!0})}),e.jsx("p",{className:"mt-2 text-sm font-medium text-foreground",children:s.title})]}):e.jsxs("button",{type:"button",onClick:f,className:"group flex flex-col rounded-card border border-card-border bg-card overflow-hidden text-left hover:border-primary/40 hover:shadow-sm transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:[e.jsxs("div",{className:"aspect-video bg-muted relative overflow-hidden",children:[o?e.jsx("img",{src:o,alt:s.title,loading:"lazy",className:"h-full w-full object-cover group-hover:scale-105 transition-transform"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-gradient-to-br from-primary/10 to-accent/10",children:e.jsx(O,{className:"size-10 text-primary/40"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/20 transition-colors",children:e.jsx("div",{className:"flex size-14 items-center justify-center rounded-full bg-white/90 shadow-lg op
1acity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Pe,{className:"size-6 text-foreground ml-0.5",fill:"currentColor"})})}),s.durationSec&&e.jsx("span",{className:"absolute bottom-2 right-2 rounded bg-black/80 px-1.5 py-0.5 text-xs font-medium text-white",children:Ie(s.durationSec)})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground line-clamp-2",children:s.title}),s.description&&e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground line-clamp-2",children:s.description})]})]})}function Ze({playlists:s,standaloneVideos:t}){return s.length>0||t.length>0?e.jsxs("div",{className:"space-y-8",children:[s.map(o=>e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"font-display text-lg font-bold text-foreground",children:o.name}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]}),o.videos.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No videos in this playlist yet."}):e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:o.videos.map(c=>e.jsx(K,{video:c},c.id))})]},o.id)),t.length>0&&e.jsxs("div",{children:[s.length>0&&e.jsx("h3",{className:"mb-3 font-display text-lg font-bold text-foreground",children:"More Videos"}),e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:t.map(o=>e.jsx(K,{video:o},o.id))})]})]}):e.jsxs("div",{className:"rounded-card border border-card-border bg-card p-10 text-center",children:[e.jsx(O,{className:"mx-auto mb-3 size-10 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"No videos available yet."}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Training and product videos will appear here soon."})]})}function qe({resource:s,onCopy:t,copied:a}){const[o,c]=n.useState(!1),[f,l]=n.useState(!1),m=()=>{t(s),l(!0),setTimeout(()=>l(!1),2e3)};return e.jsxs(be,{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-primary",children:te[s.kind]??s.kind}),e.jsx("h3",{className:"mt-1 font-display text-lg font-bold text-foreground leading-tight",children:s.title}),s.description&&e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.description})]}),e.jsx("button",{type:"button",onClick:m,className:"shrink-0 rounded-pill border border-card-border p-2 text-muted-foreground hover:text-primary hover:border-primary/30 transition-colors","aria-label":"Copy to clipboard",children:f||a?e.jsx(Q,{className:"size-4 text-green-600"}):e.jsx(Le,{className:"size-4"})})]}),s.tags.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.tags.map(g=>e.jsx("span",{className:"rounded-pill bg-muted px-2 py-0.5 text-xs text-muted-foreground",children:g},g))}),e.jsx("div",{className:"mt-3 flex-1",children:e.jsx("div",{className:U("whitespace-pre-wrap rounded-card bg-muted/40 p-3 text-sm text-foreground/90 font-mono",!o&&"max-h-32 overflow-hidden"),children:s.body})}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",Be(s.updatedAt)]}),s.body.length>500&&e.jsx("button",{type:"button",onClick:()=>c(g=>!g),className:"text-xs font-medium text-primary hover:underline",children:o?"Show less":"Show all"})]})]})}function Ke({resources:s}){const[t,a]=n.useState("all"),[o,c]=n.useState(""),[f,l]=n.useState(null),m=n.useCallback(async i=>{try{await navigator.clipboard.writeText(i.body),l(i.id),setTimeout(()=>l(null),2e3),he(i.id,{credentials:"include"}).catch(()=>{})}catch{}},[]),g=["all",...new Set(s.map(i=>i.kind))],h=s.filter(i=>t==="all"||i.kind===t).filter(i=>!o||i.title.toLowerCase().includes(o.toLowerCase())||i.body.toLowerCase().includes(o.toLowerCase()));return s.length===0?e.jsxs("div",{className:"rounded-card border border-card-border bg-card p-10 text-center",children:[e.jsx(F,{className:"mx-auto mb-3 size-10 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"No marketing resources yet."}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Swipe copy, scripts, and compliance guides will appear here."})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:g.map(i=>e.jsx("button",{type:"button",onClick:()=>
1a(i),className:U("rounded-pill px-3 py-1.5 text-xs font-medium transition-colors",t===i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"),children:i==="all"?"All":te[i]??i},i))}),e.jsxs("div",{className:"relative sm:max-w-xs sm:ml-auto",children:[e.jsx(M,{className:"absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground"}),e.jsx("input",{type:"text",value:o,onChange:i=>c(i.target.value),placeholder:"Search resourcesâ¦",className:"w-full rounded-pill border border-card-border bg-card pl-9 pr-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"})]})]}),e.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:h.map(i=>e.jsx(qe,{resource:i,onCopy:m,copied:f===i.id},i.id))}),h.length===0&&e.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No resources match your filter."})]})}function rs(){const{isAuthenticated:s,isLoading:t}=de(),[,a]=ie(),[o,c]=n.useState(!0),[f,l]=n.useState(null),[m,g]=n.useState(null),[h,i]=n.useState("assets");return n.useEffect(()=>{if(t)return;if(!s){a("/login?redirect=/partners/resources");return}async function r(){try{const u=await ue({credentials:"include"});g(u)}catch(u){l(u instanceof Error?u.message:"Failed to load resource hub")}finally{c(!1)}}r()},[s,t,a]),o?e.jsx(A,{className:"py-8 md:py-12",children:e.jsx("div",{className:"mx-auto max-w-5xl",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 rounded bg-muted w-64"}),e.jsx("div",{className:"h-10 rounded bg-muted w-full max-w-sm"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:6}).map((r,u)=>e.jsx("div",{className:"h-40 rounded bg-muted"},u))})]})})}):f||!m?e.jsx(A,{className:"py-12",children:e.jsxs("div",{className:"mx-auto max-w-md text-center",children:[e.jsx("p",{className:"text-red-600",children:f??"Failed to load resource hub"}),e.jsx(P,{asChild:!0,variant:"light",className:"mt-4",children:e.jsx(Z,{href:"/partners/portal",children:"Back to portal"})})]})}):e.jsxs(e.Fragment,{children:[e.jsx(je,{}),e.jsx(A,{className:"py-6 md:py-10",children:e.jsxs("div",{className:"mx-auto max-w-5xl",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs(ce,{variant:"mint",children:[e.jsx(ve,{className:"inline size-3.5 mr-1"}),"Partner Resource Hub"]}),e.jsx(me,{as:"h1",className:"mt-3",title:"Marketing Assets & Resources"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground max-w-2xl",children:"Everything you need to promote VidaPeps - brand assets, Canva templates, training videos, and ready-to-use marketing copy. Approved sales also unlock VidaMerch thank-you bonuses: a $40 premium item after 5 approved sales and the $600 VidaSwag pack after 50."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs font-medium text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-pill border border-card-border bg-card px-2.5 py-1",children:[e.jsx(ye,{className:"size-3.5 text-primary"}),"Approved, compliance-safe assets"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-pill border border-card-border bg-card px-2.5 py-1",children:[e.jsx(Ne,{className:"size-3.5 text-primary"}),"Ready-to-use copy and training"]})]})]}),!m.isPartner&&e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 rounded-pill bg-amber-50 border border-amber-200 px-3 py-1.5 text-xs text-amber-800",children:[e.jsx(we,{className:"size-3.5"}),"Limited preview - partner-only content locked"]})]}),e.jsx(Ve,{active:h,onSelect:i}),h==="assets"&&e.jsx(Ge,{collections:m.collections}),h==="canva"&&e.jsx(Xe,{templates:m.canvaTemplates,referralCode:m.referralCode}),h==="video"&&e.jsx(Ze,{playlists:m.playlists,standaloneVideos:m.standaloneVideos}),h==="resources"&&e.jsx(Ke,{resources:m.resources}),e.jsx("div",{className:"mt-10 border-t border-card-border pt-6",children:e.jsxs(Z,{href:"/partners/portal",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Ce,{className:"size-4"}),"Back to Partner Dashboard"]})})]})})]})}export{rs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.