1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1797],{14418:function(e,t,n){n.r(t),n.d(t,{default:function(){return eE}});var i=n(57437),o=n(2265),r=n(73005),a=n(20287),l=n(24728),s=n(42421),d=n(63550),c=n(30690),u=n(23787),p=n(27422),f=n(37164),h=n(6884),g=n(62990),x=n(55347),b=n(95268),m=n(54817),y=n(66706),v=n(53937),j=n(84129),w=n(97608),S=n(74232),k=n(40933),D=n(24501),C=n(82726),I=n(33114),z=n(85621),R=n(16463),T=n(64042),E=n(74697);let A=[{id:"overview",label:"Overview"},{id:"creatives",label:"Creatives"},{id:"hooks",label:"Hooks"},{id:"adcopy",label:"Ad copy"},{id:"headlines",label:"Headlines"},{id:"landing",label:"Landing pages"},{id:"personas",label:"Personas"},{id:"angles",label:"Ad angles"},{id:"usps",label:"USPs"},{id:"desires",label:"Desires"},{id:"emotions",label:"Emotions"},{id:"themes",label:"Themes"}],W=[{label:"All time",days:0},{label:"7d",days:7},{label:"30d",days:30},{label:"90d",days:90},{label:"180d",days:180}],B=["#141d15","#1e3a5f","#4a1942","#3a1a1a","#1a3a38","#2d3a1a","#3a2a1a"];function L(e){let t=0;for(let n of e)t=(31*t+n.charCodeAt(0))%B.length;return B[t]}function F(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/864e5);return 0===t?"Today":1===t?"Yesterday":t<30?"".concat(t,"d ago"):t<365?"".concat(Math.floor(t/30),"mo ago"):"".concat(Math.floor(t/365),"y ago")}function _(e){let{label:t,count:n,max:o,color:r="#141d15"}=e;return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,i.jsx)("div",{style:{width:140,fontSize:12,color:"#374151",fontWeight:500,flexShrink:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),(0,i.jsx)("div",{style:{flex:1,height:8,background:"#f1f5f9",borderRadius:4,overflow:"hidden"},children:(0,i.jsx)("div",{style:{height:"100%",background:r,borderRadius:4,width:"".concat(Math.max(4,n/o*100),"%"),transition:"width 0.4s ease"}})}),(0,i.jsx)("div",{style:{width:28,fontSize:11,color:"#6b7280",textAlign:"right",flexShrink:0},children:n})]})}function M(e){let{items:t,color:n="#141d15",bg:o="#fff7f3",border:r="#f6d8cc"}=e;return t.length?(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:t.map(e=>{let{text:t,count:a}=e;return(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"5px 12px",background:o,color:n,border:"1px solid ".concat(r),borderRadius:100,fontSize:13,fontWeight:500},children:[t,(0,i.jsx)("span",{style:{fontSize:10,opacity:.6,fontWeight:700},children:a})]},t)})}):(0,i.jsx)(N,{text:"No data yet â run AI classification first"})}function N(e){let{text:t}=e;return(0,i.jsxs)("div",{style:{textAlign:"center",padding:"48px 24px",color:"#9ca3af"},children:[(0,i.jsx)("div",{style:{fontSize:32,marginBottom:10},children:"\uD83E\uDD37"}),(0,i.jsx)("div",{style:{fontSize:14},children:t})]})}function P(e){let{ad:t}=e,[n,r]=(0,o.useState)(!1),a=t.thumbnail_url||(t.page_id?"https://graph.facebook.com/".concat(t.page_id,"/picture?type=large"):null),s=(t.page_name||"?").split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2),d=L(t.page_name||"");return(0,i.jsx)("a",{href:t.snapshot_url,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none",display:"block"},children:(0,i.jsxs)("div",{style:{background:"#fff",borderRadius:12,border:"1px solid #e2e8f0",overflow:"hidden",transition:"box-shadow 0.15s"},onMouseEnter:e=>e.currentTarget.style.boxShadow="0 4px 16px rgba(0,0,0,0.1)",onMouseLeave:e=>e.currentTarget.style.boxShadow="none",children:[(0,i.jsxs)("div",{style:{position:"relative",aspectRatio:"4/3",background:d,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:[(0,i.jsx)("span",{style:{fontSize:32,fontWeight:800,color:"#ff5a2c"},children:s}),a&&!n&&(0,i.jsx)("img",{src:a,alt:"",onError:()=>r(!0),style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),("Video"===t.format||t.video_url)&&(0,i.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.25)"},children:(0,i.jsx)("div",{style:{width:36,height:36,borderRadius:"50%",background:"rgba(255,255,255,0.9)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,i.jsx)("span",{style:{fontSize:14,marginLeft:2},children:"â¶"})})}),(0,i.jsx)("div",{style:{position:"absolute",top:6,left:6},children:(0,i.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:t.is_active?"#ef4a1e":"#9ca3af",display:"inline-block",border:"1.5px solid #fff"}})}),t.days_running>0&&(0,i.jsxs)("div",{style:{position:"absolute",bottom:6,right:6,fontSize:9,fontWeight:700,padding:"2px 5px",background:"rgba(0,0,0,0.6)",color:"#fff",borderRadius:4},children:[t.days_running,"d"]})]}),(()=>{let e=(0,l.l)(t.title),n=(0,l.l)(t.body);return e||n?(0,i.jsxs)("div",{style:{padding:"8px 10px"},children:[e&&(0,i.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"#111",marginBottom:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}
1),n&&(0,i.jsx)("div",{style:{fontSize:10,color:"#6b7280",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:n})]}):null})()]})})}function U(e){var t,n;let{data:o}=e,{brand:r,hooks:a,angles:l,emotions:s,themes:d}=o,c=(null===(t=a[0])||void 0===t?void 0:t.count)||1,u=(null===(n=l[0])||void 0===n?void 0:n.count)||1;return(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(150px,100%), 1fr))",gap:12},children:[{icon:"\uD83D\uDCE6",label:"Total Ads",value:r.total_ads.toLocaleString(),color:"#141d15"},{icon:"\uD83D\uDFE2",label:"Active Now",value:r.active_ads.toLocaleString(),color:"#ef4a1e"},{icon:"\uD83D\uDCC5",label:"Avg Runtime",value:"".concat(r.avg_days_running,"d"),color:"#7c3aed"},{icon:"\uD83C\uDFAC",label:"Video Ads",value:r.video_ads.toLocaleString(),color:"#0891b2"},{icon:"\uD83D\uDDBC",label:"With Creative",value:r.with_creative.toLocaleString(),color:"#b45309"},{icon:"\uD83D\uDCCA",label:"Image Ads",value:(r.total_ads-r.video_ads).toLocaleString(),color:"#dc2626"}].map(e=>(0,i.jsxs)("div",{style:{background:"#f8fafc",borderRadius:10,padding:"14px 16px",border:"1px solid #f1f5f9"},children:[(0,i.jsx)("div",{style:{fontSize:20,marginBottom:6},children:e.icon}),(0,i.jsx)("div",{style:{fontSize:20,fontWeight:800,color:e.color},children:e.value}),(0,i.jsx)("div",{style:{fontSize:11,color:"#6b7280",marginTop:2},children:e.label})]},e.label))}),a.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,fontWeight:700,color:"#111",marginBottom:12},children:"Top Hooks"}),a.slice(0,6).map(e=>(0,i.jsx)(_,{label:e.type,count:e.count,max:c,color:"#141d15"},e.type))]}),l.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,fontWeight:700,color:"#111",marginBottom:12},children:"Top Ad Angles"}),l.slice(0,5).map(e=>(0,i.jsx)(_,{label:e.text,count:e.count,max:u,color:"#7c3aed"},e.text))]}),d.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,fontWeight:700,color:"#111",marginBottom:10},children:"Themes Used"}),(0,i.jsx)(M,{items:d.slice(0,12),color:"#9a3412",bg:"#fff7f3",border:"#f6d8cc"})]}),!a.length&&!l.length&&(0,i.jsx)(N,{text:"No AI classification yet. Run the crawler with AI classification to unlock this tab."})]})}function O(e){let{hooks:t}=e;return t.length?(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:t.map(e=>(0,i.jsxs)("div",{style:{background:"#f8fafc",borderRadius:12,padding:16,border:"1px solid #f1f5f9"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:700,color:"#111"},children:e.type}),(0,i.jsxs)("span",{style:{fontSize:11,fontWeight:700,padding:"3px 10px",background:"#ef4a1e",color:"#fff",borderRadius:100},children:[e.count," ads"]})]}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:e.examples.map(e=>{let t=(0,l.l)(e.body);return t?(0,i.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.thumb&&(0,i.jsx)("img",{src:e.thumb,alt:"",style:{width:40,height:40,borderRadius:6,objectFit:"cover",flexShrink:0,border:"1px solid #e2e8f0"},onError:e=>{e.target.style.display="none"}}),(0,i.jsxs)("div",{style:{fontSize:12,color:"#374151",lineHeight:1.6,fontStyle:"italic"},children:['"',t,t.length>=160?"â¦":"",'"']})]},e.id):null})})]},e.type))}):(0,i.jsx)(N,{text:"No hooks classified yet. Run AI classification first."})}function H(e){let{items:t,emptyMsg:n}=e,o=t.map(e=>({...e,text:(0,l.l)(e.text)})).filter(e=>e.text);return o.length?(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:o.map(e=>(0,i.jsx)("a",{href:e.snapshot_url,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:(0,i.jsx)("div",{style:{padding:"12px 14px",background:"#fff",borderRadius:10,border:"1px solid #f1f5f9",transition:"border-color 0.15s, box-shadow 0.15s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="#141d15",e.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="#f1f5f9",e.currentTarget.style.boxShadow="none"},children:(0,i.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",ga
1p:10},children:[e.thumb&&(0,i.jsx)("img",{src:e.thumb,alt:"",style:{width:36,height:36,borderRadius:6,objectFit:"cover",flexShrink:0,border:"1px solid #e2e8f0"},onError:e=>{e.target.style.display="none"}}),(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{fontSize:13,color:"#1f2937",lineHeight:1.6},children:e.text}),(0,i.jsxs)("div",{style:{marginTop:6,display:"flex",alignItems:"center",gap:8},children:[(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:e.isActive?"#ef4a1e":"#d1d5db",display:"inline-block"}}),(0,i.jsxs)("span",{style:{fontSize:10,color:"#9ca3af"},children:[e.isActive?"Active":"Ended",e.date&&" \xb7 ".concat(new Date(e.date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"2-digit"}))]}),(0,i.jsx)(u.Z,{size:10,style:{color:"#d1d5db",marginLeft:"auto"}})]})]})]})})},e.id))}):(0,i.jsx)(N,{text:n})}function Z(e){let{pageId:t,pageName:n,onClose:r}=e,[a,l]=(0,o.useState)("overview"),[s,d]=(0,o.useState)(0),[c,p]=(0,o.useState)(null),[f,h]=(0,o.useState)(!0),[g,x]=(0,o.useState)(""),[b,m]=(0,o.useState)(!1),y=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]);let[v,j]=(0,o.useState)(!1);(0,o.useEffect)(()=>{h(!0),x("");let e=new URLSearchParams({page_id:t});s>0&&e.set("days",String(s)),fetch("/api/discovery/brand?".concat(e)).then(e=>e.json()).then(e=>{e.error?x(e.error):p(e)}).catch(e=>x(e.message)).finally(()=>h(!1))},[t,s]),(0,o.useEffect)(()=>{let e=!1;return fetch("/api/discovery/brand-spy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pageId:t,name:n,crawlOnly:!0})}).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&t.crawlOnly&&!t.alreadyFresh&&j(!0)}).catch(()=>{}),()=>{e=!0}},[t,n]);let w=n.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)||"?",S=L(n),k=null==c?void 0:c.brand;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg) } } @keyframes slideIn { from { transform: translateX(100%) } to { transform: translateX(0) } }"}),(0,i.jsx)("div",{onClick:r,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:200,backdropFilter:"blur(2px)"}}),(0,i.jsxs)("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"100%",maxWidth:820,background:"#fff",zIndex:201,display:"flex",flexDirection:"column",boxShadow:"-8px 0 40px rgba(0,0,0,0.2)",animation:"slideIn 0.25s cubic-bezier(0.4,0,0.2,1)"},children:[(0,i.jsxs)("div",{style:{padding:"20px 24px 0",borderBottom:"1px solid #f1f5f9",flexShrink:0},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,marginBottom:16},children:[(0,i.jsx)("div",{style:{width:48,height:48,borderRadius:"50%",background:S,display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:800,color:"#ff5a2c",flexShrink:0,letterSpacing:-.5},children:w}),(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{fontSize:18,fontWeight:800,color:"#111",marginBottom:2},children:n||"Brand"}),k&&(0,i.jsxs)("div",{style:{fontSize:12,color:"#6b7280",display:"flex",alignItems:"center",gap:10},children:[(0,i.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:k.active_ads>0?"#ef4a1e":"#9ca3af",display:"inline-block"}}),k.active_ads>0?"".concat(k.active_ads," active"):"No active ads"]}),k.first_seen&&(0,i.jsxs)("span",{children:["First seen ",F(k.first_seen)]}),k.last_seen&&(0,i.jsxs)("span",{children:["Updated ",F(k.last_seen)]})]})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[v&&(0,i.jsxs)("span",{title:"We're pulling this brand's latest ads â refresh in a moment to see them",style:{display:"flex",alignItems:"center",gap:6,padding:"7px 12px",background:"#fff7f3",border:"1.5px solid #f6d8cc",borderRadius:8,fontSize:12,fontWeight:700,color:"#9a3412"},children:[(0,i.jsx)("span",{style:{width:12,height:12,border:"2px solid #f6d8cc",borderTopColor:"#9a3412",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),"Fetching latest adsâ¦"]}),(0,i.jsxs)("button",{onClick:()=>m(e=>!e),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 14px",background:b?"#141d15":"#fff",border:"1.5px solid ".concat(b?"#141d15":"#e2e8f0"),borderRadius:8,fontSize:13,fontWeight:700,color:b?"#ff5a2c":"#374151",cursor:"pointer",fontFamily:"inherit"},children:[(0,i.jsx)(T.Z,{size:13,fill:b?"#ff5a2c":"none"}),b?"Following":"Follow"]}),(0,i.jsxs)("a",{href:"https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=US&view_all_page_id=".concat(t),target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:"#f8fafc",border:"1.5px solid #e2e8f0",borderRadius:8,fontSize:12,color:"#374151",textDecoration:"none",fontWeight:600,fontFamily:"inherit"},children:["Meta library ",(0,i.jsx)(u.Z,{size:11})]}),(0,i.jsx)("button",{onClick:r,style:{padding:8,background:"#f1f5f9",border:"none",borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",color:"#6b7280"},children:(0,i.jsx)(E.Z,{size:16})})]})]}),(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:0},children:W.map(e=>(0,i.jsx)("button",{onClick:()=>d(e.days),style:{padding:"5px 12px",borderRadius:6,fontSize:12,fontWeight:600,background:s===e.days?"#ef4a1e":"transparent",color:s===e.days?"#fff":"#6b7280",border:"none",cursor:"pointer",fontFamily:"inherit"},children:e.label},e.days))}),(0,i.jsx)("div",{ref:y,style:{display:"flex",gap:0,overflowX:"auto",marginTop:4,paddingBottom:0},className:"hide-scrollbar",children:A.map(e=>(0,i.jsx)("button",{onClick:()=>l(e.id),style:{padding:"10px 14px",fontSize:13,fontWeight:600,whiteSpace:"nowrap",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit",color:a===e.id?"#141d15":"#6b7280",borderBottom:"2px s
1olid ".concat(a===e.id?"#141d15":"transparent"),transition:"color 0.15s, border-color 0.15s"},children:e.label},e.id))})]}),(0,i.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px"},children:(()=>{if(f)return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:200,flexDirection:"column",gap:12},children:[(0,i.jsx)("div",{style:{width:28,height:28,border:"3px solid #e2e8f0",borderTopColor:"#141d15",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),(0,i.jsx)("div",{style:{fontSize:13,color:"#9ca3af"},children:"Loading brand dataâ¦"})]});if(g)return(0,i.jsx)(N,{text:"Error: ".concat(g)});if(!c)return(0,i.jsx)(N,{text:"No data available"});switch(a){case"overview":return(0,i.jsx)(U,{data:c});case"creatives":return c.creatives.length?(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(160px,100%), 1fr))",gap:12},children:c.creatives.map(e=>(0,i.jsx)(P,{ad:e},e.ad_id))}):(0,i.jsx)(N,{text:"No creatives yet. Run the crawler with Bright Data to get real ad images."});case"hooks":return(0,i.jsx)(O,{hooks:c.hooks});case"adcopy":return(0,i.jsx)(H,{items:c.adCopies.map(e=>({...e,thumb:e.thumb})),emptyMsg:"No ad copy found for this brand."});case"headlines":return(0,i.jsx)(H,{items:c.headlines.map(e=>({...e,thumb:null})),emptyMsg:"No headlines found for this brand."});case"landing":return(0,i.jsxs)("div",{style:{textAlign:"center",padding:"60px 24px"},children:[(0,i.jsx)("div",{style:{fontSize:36,marginBottom:12},children:"\uD83D\uDEA7"}),(0,i.jsx)("div",{style:{fontSize:15,fontWeight:700,color:"#111",marginBottom:8},children:"Landing Pages â Coming Soon"}),(0,i.jsxs)("div",{style:{fontSize:13,color:"#6b7280",lineHeight:1.7},children:["We'll scrape each ad's destination URL and capture",(0,i.jsx)("br",{}),"screenshots + extracted copy. Requires Bright Data setup."]})]});case"personas":return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:"Who this brand targets in their ads, based on AI classification."}),(0,i.jsx)(M,{items:c.personas,color:"#1d4ed8",bg:"#eff6ff",border:"#bfdbfe"}),!c.personas.length&&(0,i.jsx)(N,{text:"No personas classified yet. Run AI classification first."})]});case"angles":return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:"The persuasion angles this brand uses most in their ads."}),c.angles.length?c.angles.map(e=>{var t;return(0,i.jsx)(_,{label:e.text,count:e.count,max:(null===(t=c.angles[0])||void 0===t?void 0:t.count)||1,color:"#7c3aed"},e.text)}):(0,i.jsx)(N,{text:"No ad angles classified yet."})]});case"usps":return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:"Unique selling points this brand emphasizes across their ads."}),(0,i.jsx)(M,{items:c.usps,color:"#0891b2",bg:"#f0f9ff",border:"#bae6fd"}),!c.usps.length&&(0,i.jsx)(N,{text:"No USPs classified yet. Run AI classification first."})]});case"desires":return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:"Core desires this brand taps into in their ad creative."}),(0,i.jsx)(M,{items:c.desires,color:"#dc2626",bg:"#fef2f2",border:"#fecaca"}),!c.desires.length&&(0,i.jsx)(N,{text:"No desires classified yet."})]});case"emotions":return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:"Emotions this brand triggers in their ads."}),c.emotions.length?c.emotions.map(e=>{var t;return(0,i.jsx)(_,{label:e.text,count:e.count,max:(null===(t=c.emotions[0])||void 0===t?void 0:t.count)||1,color:"#ea580c"},e.text)}):(0,i.jsx)(N,{text:"No emotions classified yet."})]});case"themes":return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:"Recurring themes detected across this brand's ads."}),c.themes.length?c.themes.map(e=>{var t;return(0,i.jsx)(_,{label:e.text,count:e.count,max:(null===(t=c.themes[0])||void 0===t?void 0:t.count)||1,color:"#059669"},e.text)}):(0,i.jsx)(N,{text:"No themes detected yet."})]});default:return null}})()})]})]})}
1var G=n(98039),V=n(20357);class q extends o.Component{static getDerivedStateFromError(){return{errored:!0}}componentDidCatch(){this.state.k<30&&setTimeout(()=>this.setState(e=>({errored:!1,k:e.k+1})),50)}render(){return this.state.errored?(0,i.jsx)("div",{style:{textAlign:"center",padding:24,color:"#9ca3af",fontSize:13},children:"Loadingâ¦"}):(0,i.jsx)(o.Fragment,{children:this.props.children},this.state.k)}constructor(...e){super(...e),this.state={k:0,errored:!1}}}let Y=[["Apparel & Accessories",/cloth|fashion|dress|shoes|apparel|outfit|hoodie|jeans|bag|purse|handbag|accessori|shirt|jacket|pants|skirt/i],["Beauty & Personal Care",/beauty|skincare|makeup|cosmetic|serum|moistur|lipstick|mascara|cream|lotion|facial|glow|anti-ag|fragrance|perfume|cleanser|toner/i],["Baby, Kids & Maternity",/baby|toddler|kids|children|infant|maternity|pregnant|nursery|diaper|stroller/i],["Food & Beverage",/food|meal|recipe|restaurant|delivery|snack|drink|coffee|tea|juice|beverage|cuisine|chef|cook|chocolate|candy/i],["Health & Fitness",/fitness|gym|workout|weight loss|exercise|yoga|pilates|health|wellness|diet|supplement|vitamin|protein|keto/i],["Electronics & Technology",/tech|software|app|device|phone|laptop|computer|electronic|gadget|digital|smart|wireless|battery/i],["Finance & Insurance",/financ|insur|invest|loan|credit|banking|money|wealth|trading|crypto|tax|mortgage|fund/i],["Home & Garden",/home|furniture|decor|garden|kitchen|bedroom|clean|interior|house|living room|sofa|rug|curtain/i],["Travel & Tourism",/travel|hotel|flight|vacation|holiday|tour|destination|trip|resort|cruise|airbnb/i],["Pets",/\bpet\b|dog|cat|puppy|kitten|animal|vet|paw|leash|collar|bird|fish tank/i],["Education",/course|learn|education|training|skill|class|university|degree|certif|bootcamp/i],["Real Estate",/real estate|property|apartment|rent|buy home|mortgage|listing|realty|condo/i],["Jewelry & Watches",/jewelry|jewellery|ring|necklace|bracelet|watch|diamond|gold|silver|gem|pendant/i],["Sports & Outdoors",/sport|outdoor|hiking|camping|running|cycling|tennis|golf|soccer|football|athletic|basketball/i],["Business Services",/\bbusiness\b|marketing|agency|consult|b2b|enterprise|saas|crm|erp|automation|lead gen/i],["E-Commerce",/shop now|add to cart|order now|free shipping|buy \d|get yours|limited stock/i],["Charity & NGO",/charity|nonprofit|donate|ngo|cause|foundation|volunteer|relief/i]],J=[["Before & After",/before[\s\S]{0,60}after|after[\s\S]{0,60}before|transformation|results in \d|see the results/i],["Question",/\?/],["Testimonial",/\bi (was|tried|used|am|have been|love|hate|switched|started)\b|changed my|my experience|customer says|they said|she said|he said/i],["Announcement",/introducing|we'?re launching|just dropped|announcing|now available|coming soon|new arrival|meet the new/i],["Sale/Discount",/\d+\s*%\s*off|\bsale\b|discount|bogo|deal|save \$|free shipping|limited time|offer ends|coupon|promo/i],["Pain Point",/struggling|tired of|sick of|problem|solution|fix|stop suffering|never again|hate when|can't sleep|hard to/i],["Tutorial",/how to|step \d|tutorial|guide|learn how|\btip\b|\btricks?\b|what happens when|watch us/i],["Social Proof",/\d[\d,]+\s*(customer|review|sold|people|order|unit)|trusted by|join \d|rated \d|#1|best seller|award/i],["UGC / Review",/unboxing|honest review|i bought|first impression|worth it|would i recommend|rating/i]],X={en:"English",es:"Spanish",fr:"French",de:"German",it:"Italian",pt:"Portuguese",nl:"Dutch",ar:"Arabic",zh:"Chinese",ja:"Japanese",ko:"Korean",ru:"Russian",hi:"Hindi",tr:"Turkish",pl:"Polish",sv:"Swedish",da:"Danish",no:"Norwegian",fi:"Finnish",id:"Indonesian",th:"Thai",vi:"Vietnamese",uk:"Ukrainian",ro:"Romanian",el:"Greek",he:"Hebrew",cs:"Czech",hu:"Hungarian"},K=["facebook","instagram","audience_network","messenger"],$={facebook:"Facebook",instagram:"Instagram",audience_network:"Audience Network",messenger:"Messenger"},Q={facebook:"\uD83D\uDCD8",instagram:"\uD83D\uDCF8",audience_network:"\uD83C\uDF10",messenger:"\uD83D\uDCAC"},ee=["Image","Video","Carousel"],et=Y.map(e=>{let[t]=e;return t}).concat(["Other"]),en=J.map(e=>{let[t]=e;return t}),ei=[{value:"ALL",label:"All"},{value:"ACTIVE",label:"\uD83D\uDFE2 Active"},{value:"INACTIVE",label:"â« Inactive"}],eo=[{value:"recommended",label:"⨠Recommended"},{value:"performance",label:"\uD83C\uDFC6 Performance"},{value:"newest",label:"Newest"},{value:"recent",label:"Most Recent"},{value:"longest",label:"Longest Running"},{value:"most_used",label:"Most Used"},{value:"latest_added",label:"Latest Added"},{value:"oldest",label:"Oldest First"}],er=[{value:"winning",label:"\uD83C\uDFC6 Winning"},{value:"optimized",label:"â¡ Optimized"},{value:"growing",label:"\uD83D\uDCC8 Growing"},{value:"scaling",label:"\uD83D\uDE80 Scaling"},{value:"testing",label:"\uD83E\uDDEA Testing"}],ea=[{value:"Beauty",label:"\uD83D\uDC84 Beauty"},{value:"Skincare",label:"\uD83E\uDDF4 Skincare"},{value:"Fashion",label:"\uD83D\uDC57 Fashion"},{value:"Accessories",label:"\uD83D\uDC5C Accessories"},{value:"Jewelry & Watches",label:"\uD83D\uDC8D Jewelry & Watches"},{value:"Health & Wellness",label:"\uD83E\uDDD8 Health & Wellness"},{value:"Supplements",label:"\uD83D\uDC8A Supplements"},{value:"Medical",label:"\uD83E\uDE7A Medical"},{value:"Sports & Outdoors",label:"\uD83C\uDFC0 Sports & Outdoors"},{value:"Pets",label:"\uD83D\uDC3E Pets"},{value:"Food & Drink",label:"\uD83C\uDF54 Food & Drink"},{value:"Home & Garden",label:"\uD83C\uDFE0 Home & Garden"},{value:"Tech",label:"\uD83D\uDCBB Tech"},{value:"App / Software",label:"\uD83D\uDCF2 App / Software"},{value:"Subscription Box",label:"\uD83D\uDCE6 Subscription Box"},{value:"Kids & Baby",label:"\uD83C\uDF7C Kids & Baby"},{value:"Travel",label:"âï¸ Travel"},{value:"Finance",label:"\uD83D\uDCB0 Finance"},{value:"Insurance",label:"\uD83D\uDEE1ï¸ Insurance"},{value:"Automotive",label:"\uD83D\uDE97 Automotive"},{value:"CBD / Cannabis",label:"\uD83C\uDF3F CBD / Cannabis"},{value:"Alcohol",label:"\uD83C\uDF77 Alcohol"},{value:"Entertainment",label:"\uD83C\uDFAC Entertainment"},{value:"Games",label:"\uD83C\uDFAE Games"},{value:"Media / News",label:"\uD83D\uDCF0 Media / News"},{value:"Book / Publishing",label:"\uD83D\uDCDA Book / Publishing"},{value:"Info Products",label:"\uD83D\uDCC8 Info Products"},{value:"Business / Professional",label:"\uD83D\uDCBC Business / Professional"},{value:"Service Business",label:"\uD83D\uDD27 Service Business"},{value:"Real Estate",label:"\uD83C\uDFE1 Real Estate"},{value:"Charity / Non-Profit",label:"\uD83E\uDD1D Charity / Non-Profit"},{value:"Government",label:"\uD83C\uDFDBï¸ Government"},{value:"Other",label:"\uD83D\uDDC2ï¸ Other"}],el=["Pain Point","Testimonial","Social Proof","Before & After","Question","Story","Announcement","Educational","Urgency","Discount","Unboxing","Us vs Them"].map(e=>({value:e,label:e})),es=["fear","curiosity","desire","trust","urgency","hope","excitement","relatability","aspiration","guilt","pride"].map(e=>({value:e,label:e})),ed=["Pain Point","Aspiration","Social Proof","Authority","Scarcity","Curiosity","Value","Story","Comparison"].map(e=>({value:e,label:e})),ec=[{value:"UGC",label:"\uD83E\uDD33 UGC"},{value:"Studio / Produced",label:"\uD83C\uDFAC Studio / Produced"},{value:"Graphic / Text",label:"\uD83D\uDD24 Graphic / Text"},{value:"Mixed",label:"Mixed"}],eu=["Selfie / Handheld","Bathroom / Mirror","Kitchen / Home","Outdoor / Lifestyle","Studio Product Shot","Before & After","Text Overlay Graphic","Unboxing","Talking Head","Demo / How-to","Flat Lay","Lifestyle Person","Other"].map(e=>({value:e,label:e}));function ep(e){let{label:t,options:n,selected:r,onToggle:a,onClear:l,searchable:d,comingSoon:c,leadIcon:u}=e,[p,f]=(0,o.useState)(!1),[h,g]=(0,o.useState)(""),[x,b]=(0,o.useState)(null),m=(0,o.useRef)(null),y=(0,o.useRef)(null);(0,o.useEffect)(()=>
1{if(!p)return;let e=e=>{m.current&&!m.current.contains(e.target)&&f(!1)},t=e=>{m.current&&m.current.contains(e.target)||f(!1)};return document.addEventListener("mousedown",e),window.addEventListener("scroll",t,{passive:!0,capture:!0}),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,{capture:!0})}},[p]);let v=d?n.filter(e=>e.label.toLowerCase().includes(h.toLowerCase())):n;return c?(0,i.jsxs)("button",{disabled:!0,title:"Coming soon",style:{display:"flex",alignItems:"center",gap:6,padding:"7px 13px",background:"#fafbf8",border:"1px solid #edf0ec",borderRadius:999,fontSize:12.5,fontWeight:600,color:"#9aa79a",cursor:"not-allowed",whiteSpace:"nowrap",fontFamily:"inherit"},children:[t,(0,i.jsx)("span",{style:{background:"#eef1ec",color:"#8b978d",borderRadius:100,fontSize:8.5,fontWeight:800,padding:"2px 5px",textTransform:"uppercase",letterSpacing:".06em"},children:"Soon"})]}):(0,i.jsxs)("div",{ref:m,style:{position:"relative"},children:[(0,i.jsxs)("button",{ref:y,onClick:()=>{var e;let t=null===(e=y.current)||void 0===e?void 0:e.getBoundingClientRect();t&&b({top:t.bottom+4,left:t.left}),f(e=>!e)},style:{display:"flex",alignItems:"center",gap:7,padding:"7px 13px",background:r.length?"#f4fbe6":"#fff",border:"1px solid ".concat(r.length?"#f6b9a3":"#efece2"),borderRadius:999,fontSize:12.5,fontWeight:600,color:r.length?"#2c4a1f":"#333d35",cursor:"pointer",whiteSpace:"nowrap",fontFamily:"inherit"},children:[u&&(0,i.jsx)("span",{style:{display:"inline-flex",color:r.length?"#5f9032":"#7d8a7f"},children:u}),t,r.length>0&&(0,i.jsx)("span",{style:{background:"#ef4a1e",color:"#fff",borderRadius:100,fontSize:10,fontWeight:800,padding:"1px 6px"},children:r.length}),(0,i.jsx)(s.Z,{size:12,style:{opacity:.55,transform:p?"rotate(180deg)":"none",transition:"transform .15s"}})]}),p&&x&&(0,i.jsxs)("div",{style:{position:"fixed",top:x.top,left:x.left,background:"#fff",border:"1px solid #e2e8f0",borderRadius:12,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",zIndex:1e3,minWidth:200,maxHeight:320,display:"flex",flexDirection:"column"},children:[d&&(0,i.jsx)("div",{style:{padding:"8px 10px",borderBottom:"1px solid #f1f5f9"},children:(0,i.jsx)("input",{autoFocus:!0,value:h,onChange:e=>g(e.target.value),placeholder:"Searchâ¦",style:{width:"100%",padding:"6px 10px",border:"1px solid #e2e8f0",borderRadius:6,fontSize:13,outline:"none",fontFamily:"inherit",boxSizing:"border-box"}})}),(0,i.jsxs)("div",{style:{overflowY:"auto",padding:"4px 0",flex:1,minHeight:0},children:[r.length>0&&(0,i.jsx)("button",{onClick:()=>{l(),f(!1)},style:{width:"100%",textAlign:"left",padding:"7px 14px",fontSize:12,color:"#dc2626",fontWeight:600,background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:"Clear filter"}),v.map(e=>(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 14px",cursor:"pointer",fontSize:13,color:"#111"},children:[(0,i.jsx)("input",{type:"checkbox",checked:r.includes(e.value),onChange:()=>a(e.value),style:{accentColor:"#141d15"}}),e.icon&&(0,i.jsx)("span",{children:e.icon}),e.label]},e.value))]})]})]})}function ef(e){let{value:t,onChange:n}=e,[r,a]=(0,o.useState)(!1),l=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=e=>{l.current&&!l.current.contains(e.target)&&a(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let d=eo.find(e=>e.value===t)||eo[0];return(0,i.jsxs)("div",{ref:l,style:{position:"relative"},children:[(0,i.jsxs)("button",{onClick:()=>a(e=>!e),style:{display:"flex",alignItems:"center",gap:6,padding:"7px 14px",background:"#fff",border:"1px solid #efece2",borderRadius:999,fontSize:12.5,fontWeight:650,color:"#333d35",cursor:"pointer",fontFamily:"inherit",whiteSpace:"nowrap"},children:[(0,i.jsx)("span",{style:{color:"#f5b301"},children:"â¦"})," Sort: ",(0,i.jsx)("b",{children:d.label})," ",(0,i.jsx)(s.Z,{size:12,style:{opacity:.55,transform:r?"rotate(180deg)":"none",transition:"transform .15s"}})]}),r&&(0,i.jsx)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:4,background:"#fff",border:"1px solid #e2e8f0",borderRadius:12,boxShadow:"0 8px 24px rgba(0,0,0,0.1)",zIndex:100,minWidth:180,padding:"6px 0"},children:eo.map(e=>(0,i.jsx)("button",{onClick:()=>{n(e.value),a(!1)},style:{display:"block",width:"100%",textAlign:"left",padding:"9px 14px",fontSize:13,color:e.value===t?"#141d15":"#374151",fontWeight:e.value===t?700:400,background:e.value===t?"#fff7f3":"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:e.label},e.value))})]})}function eh(e){let{ad:t,onClose:n}=e,[a,l]=(0,o.useState)([]),[s,d]=(0,o.useState)(!0),[c,u]=(0,o.useState)(null),[p,f]=(0,o.useState)([]),[h,g]=(0,o.useState)(""),[x,b]=(0,o.useState)(!1);(0,o.useEffect)(()=>{fetch("/api/discovery/boards").then(e=>e.json()).then(e=>{l(e.boards||[]),d(!1)})},[]);let m=async e=>{p.includes(e)||(u(e),await fetch("/api/discovery/saved",{method:"POST",headers:{"Content-Type":"application/json"}
1,body:JSON.stringify({board_id:e,ad_id:t.id,page_id:t.pageId,page_name:t.pageName,snapshot_url:t.snapshotUrl,ad_data:t})}),f(t=>[...t,e]),u(null),(0,r.V)("Saved to Board"))},y=async()=>{if(!h.trim())return;b(!0);let e=await fetch("/api/discovery/boards",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:h.trim()})}),t=await e.json();t.board&&(l(e=>[t.board,...e]),await m(t.board.id),g("")),b(!1)};return(0,i.jsx)("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:20},onClick:n,children:(0,i.jsxs)("div",{style:{background:"#fff",borderRadius:16,padding:24,minWidth:320,maxWidth:400,width:"100%",boxShadow:"0 20px 60px rgba(0,0,0,0.2)"},onClick:e=>e.stopPropagation(),children:[(0,i.jsx)("div",{style:{fontSize:16,fontWeight:800,color:"#111",marginBottom:16},children:"\uD83D\uDCBE Save Ad to Board"}),s?(0,i.jsx)("div",{style:{color:"#9ca3af",fontSize:13,padding:"20px 0"},children:"Loading boardsâ¦"}):0===a.length?(0,i.jsx)("div",{style:{color:"#6b7280",fontSize:13,marginBottom:16},children:"No boards yet â create one below."}):(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:16,maxHeight:200,overflowY:"auto"},children:a.map(e=>{let t=p.includes(e.id);return(0,i.jsxs)("button",{onClick:()=>m(e.id),disabled:t||c===e.id,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 14px",background:t?"#fff7f3":"#f8fafc",border:"1px solid ".concat(t?"#f6d8cc":"#e2e8f0"),borderRadius:10,cursor:t?"default":"pointer",textAlign:"left",fontFamily:"inherit"},children:[(0,i.jsx)("span",{style:{fontSize:20},children:e.emoji}),(0,i.jsx)("span",{style:{flex:1,fontSize:14,fontWeight:600,color:"#111"},children:e.name}),t?(0,i.jsx)("span",{style:{color:"#ef4a1e",fontSize:18},children:"â"}):c===e.id?(0,i.jsx)("span",{style:{fontSize:12,color:"#9ca3af"},children:"â¦"}):null]},e.id)})}),(0,i.jsxs)("div",{style:{borderTop:"1px solid #f1f5f9",paddingTop:14},children:[(0,i.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",marginBottom:8},children:"+ New Board"}),(0,i.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,i.jsx)("input",{value:h,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&y(),placeholder:"Board nameâ¦",style:{flex:1,padding:"8px 12px",border:"1px solid #e2e8f0",borderRadius:8,fontSize:13,outline:"none",fontFamily:"inherit"}}),(0,i.jsx)("button",{onClick:y,disabled:x||!h.trim(),style:{padding:"8px 14px",background:"#ef4a1e",color:"#fff",border:"none",borderRadius:8,fontSize:13,fontWeight:700,cursor:"pointer",fontFamily:"inherit"},children:x?"â¦":"Save"})]})]}),(0,i.jsx)("button",{onClick:n,style:{marginTop:14,width:"100%",padding:"8px",background:"none",border:"1px solid #e2e8f0",borderRadius:8,fontSize:13,color:"#6b7280",cursor:"pointer",fontFamily:"inherit"},children:"Done"})]})})}let eg=["#141d15","#1e3a5f","#4a1942","#3a1a1a","#1a3a38","#2d3a1a","#3a2a1a"];function ex(e){let{ad:t}=e,[n,r]=(0,o.useState)(!1),[a,l]=(0,o.useState)(!1),s=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!n)return;let e=e=>{s.current&&!s.current.contains(e.target)&&r(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]);let h=async()=>{try{await navigator.clipboard.writeText(t.snapshotUrl),l(!0),setTimeout(()=>{l(!1),r(!1)},1200)}catch(e){}};return(0,i.jsxs)("div",{ref:s,style:{position:"relative"},children:[(0,i.jsx)("button",{onClick:()=>r(e=>!e),title:"More",style:{background:"none",border:"none",cursor:"pointer",color:"#9ca3af",padding:4,borderRadius:6,display:"flex",alignItems:"center"},children:(0,i.jsx)(d.Z,{size:16})}),n&&(0,i.jsxs)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:6,background:"#fff",border:"1px solid #e2e8f0",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",minWidth:160,zIndex:100,padding:4,fontFamily:"inherit"},children:[(0,i.jsxs)("a",{href:"/discovery/".concat(t.id),onClick:()=>{eT(),r(!1)},style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",fontSize:13,color:"#1f2937",textDecoration:"none",borderRadius:6,cursor:"pointer"},onMouseEnter:e=>e.currentTarget.style.background="#f8fafc",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,i.jsx)(c.Z,{size:14})," Ad details"]}
1),(0,i.jsxs)("a",{href:t.snapshotUrl,target:"_blank",rel:"noopener noreferrer",onClick:()=>r(!1),style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",fontSize:13,color:"#1f2937",textDecoration:"none",borderRadius:6,cursor:"pointer"},onMouseEnter:e=>e.currentTarget.style.background="#f8fafc",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,i.jsx)(u.Z,{size:14})," View on Meta"]}),(0,i.jsxs)("button",{onClick:h,style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"8px 10px",fontSize:13,color:"#1f2937",background:"none",border:"none",cursor:"pointer",borderRadius:6,textAlign:"left",fontFamily:"inherit"},onMouseEnter:e=>e.currentTarget.style.background="#f8fafc",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,i.jsx)(p.Z,{size:14})," ",a?"Copied!":"Copy link"]}),(0,i.jsxs)("button",{onClick:()=>{var e,n,i,o;let a=(null===(n=t.creatives)||void 0===n?void 0:null===(e=n.find(e=>"image"===e.asset_type))||void 0===e?void 0:e.r2_url)||t.thumbnailUrl,l=(null===(o=t.creatives)||void 0===o?void 0:null===(i=o.find(e=>"video"===e.asset_type))||void 0===i?void 0:i.r2_url)||t.videoUrl||a;if(!l)return;let s="".concat(t.pageName||"creative","-").concat(t.id,".").concat(l.endsWith(".mp4")?"mp4":"jpg"),d=document.createElement("a");d.href="/api/download?url=".concat(encodeURIComponent(l),"&name=").concat(encodeURIComponent(s)),d.download=s,document.body.appendChild(d),d.click(),document.body.removeChild(d),r(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"8px 10px",fontSize:13,color:"#1f2937",background:"none",border:"none",cursor:"pointer",borderRadius:6,textAlign:"left",fontFamily:"inherit"},onMouseEnter:e=>e.currentTarget.style.background="#f8fafc",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,i.jsx)(f.Z,{size:14})," Download"]})]})]})}function eb(e){let{adId:t}=e,n=(0,R.useRouter)();return(0,i.jsx)("div",{style:{position:"relative"},onClick:e=>e.stopPropagation(),children:(0,i.jsx)("button",{onClick:()=>n.push("/discovery/".concat(encodeURIComponent(t),"?script=1")),style:{background:"#ff5a2c",color:"#fff",border:"none",padding:"7px 14px",borderRadius:8,fontSize:12,fontWeight:700,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:4,boxShadow:"0 4px 12px rgba(0,0,0,0.25)"},children:"\uD83D\uDCDD Scripts â"})})}
1let em=V.env.NEXT_PUBLIC_IMG_CDN||"",ey="1"===V.env.NEXT_PUBLIC_IMG_TRANSFORM,ev=/^https?:\/\/[^/]*(r2\.dev|r2\.cloudflarestorage\.com)/i,ej=/fbcdn\.net|\.facebook\.com|\bscontent/i,ew=[256,384,480,640],eS=(e,t)=>{if(!e)return e;if(em){if(ev.test(e)){let n=e.replace(/^https?:\/\/[^/]+/,"");return ey?"https://".concat(em,"/cdn-cgi/image/width=").concat(t,",quality=75,format=auto").concat(n):"https://".concat(em).concat(n)}if(ey)return"https://".concat(em,"/cdn-cgi/image/width=").concat(t,",quality=75,format=auto/").concat(e)}return ej.test(e)?"https://images.weserv.nl/?url=".concat(encodeURIComponent(e),"&w=").concat(t,"&q=72&output=webp"):e},ek=e=>eS(e,480),eD=e=>e?ew.map(t=>"".concat(eS(e,t)," ").concat(t,"w")).join(", "):void 0;function eC(e){let{ad:t,avatarBg:n,iframeVisible:r,onDead:a}=e,l=(0,R.useRouter)(),[s,d]=(0,o.useState)(!1),[c,u]=(0,o.useState)(!1),p=(0,o.useMemo)(()=>{if(t.creatives&&t.creatives.length>0)return[...t.creatives].sort((e,t)=>e.asset_type!==t.asset_type?"image"===e.asset_type?-1:1:e.position-t.position).map(e=>({type:e.asset_type,url:e.r2_url,width:e.width,height:e.height,poster:e.poster_url}));let e=[];return t.thumbnailUrl&&!t.thumbnailUrl.includes("graph.facebook.com")&&e.push({type:"image",url:t.thumbnailUrl}),t.videoUrl&&e.push({type:"video",url:t.videoUrl}),e},[t]),[f,x]=(0,o.useState)(0),[b,m]=(0,o.useState)(!1),[y,v]=(0,o.useState)(!1),[j,w]=(0,o.useState)(!1);(0,o.useRef)(null);let S=p.length,k=p[f];if((0,o.useEffect)(()=>{v(!1),w(!1)},[null==k?void 0:k.url]),!k)return null;let D=p[0],T=(null==D?void 0:D.width)&&(null==D?void 0:D.height)?D.height/D.width*100:null,E=null!=T?Math.min(178,Math.max(56,T)):(null==D?void 0:D.type)==="video"?125:100,A=(null==k?void 0:k.type)==="video"&&k.poster?ek(k.poster):void 0,W=(null==k?void 0:k.type)==="video",B=W?(null==k?void 0:k.poster)||void 0:null==k?void 0:k.url,L=W?null==k?void 0:k.url:void 0,F="/studio?ad=".concat(encodeURIComponent(t.id)).concat(W?"&type=video":"").concat(B?"&img=".concat(encodeURIComponent(B)):"").concat(L?"&vid=".concat(encodeURIComponent(L)):"").concat(t.pageName?"&brand=".concat(encodeURIComponent(t.pageName)):""),_=e=>{e.stopPropagation(),eT(),l.push(F)};return(0,i.jsxs)(i.Fragment,{children:[s&&(0,i.jsx)(C.default,{ad:{id:t.id,pageId:t.pageId,pageName:t.pageName,sourceThumb:(null==k?void 0:k.poster)||(null==k?void 0:k.url)},onClose:()=>d(!1)}),c&&(0,i.jsx)(I.default,{sourceAdId:t.id,sourcePoster:(null==k?void 0:k.poster)||void 0,onClose:()=>u(!1)}),(0,i.jsxs)("div",{className:"ad-card-visual sf-thumb",onClick:()=>{eT(),l.push("/discovery/".concat(t.id))},style:{position:"relative",width:"100%",paddingBottom:"".concat(E,"%"),overflow:"hidden",lineHeight:0,cursor:"pointer"},children:["image"===k.type?(0,i.jsxs)(i.Fragment,{children:[!y&&!j&&(0,i.jsx)("div",{className:"thumb-skeleton",style:{position:"absolute",inset:0,zIndex:1}}),j?(0,i.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"#adb5bd",fontSize:13},children:"image unavailable"}):(0,i.jsx)("img",{src:ek(k.url),srcSet:eD(k.url),sizes:"(max-width: 700px) 50vw, 343px",alt:t.pageName,loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",className:"sf-thumb-img",onLoad:()=>v(!0),onError:()=>{w(!0),0===f&&(null==a||a())},style:{position:"absolute",inset:0,opacity:y?1:0,transition:"opacity 0.12s linear",zIndex:2}})]}):(0,i.jsx)(z.Z,{src:k.url,poster:A,brandBg:n,initials:(t.pageName||"?").split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2),onPlayingChange:m}),S>1&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{onClick:e=>{null==e||e.stopPropagation(),x(e=>(e-1+S)%S),m(!1)},"aria-label":"Previous",style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",background:"rgba(255,255,255,0.92)",color:"#111",border:"none",width:30,height:30,borderRadius:"50%",cursor:"pointer",fontSize:16,fontWeight:700,padding:0,zIndex:4,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:"â¹"}),(0,i.jsx)("button",{onClick:e=>{null==e||e.stopPropagation(),x(e=>(e+1)%S),m(!1)},"aria-label":"Next",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",background:"rgba(255,255,255,0.92)",color:"#111",border:"none",width:30,height:30,borderRadius:"50%",cursor:"pointer",fontSize:16,fontWeight:700,padding:0,zIndex:4,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:"âº"}),(0,i.jsx)("div",{style:{position:"absolute",bottom:10,left:0,right:0,display:"flex",justifyContent:"center",gap:5,zIndex:4},children:p.map((e,t)=>(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:t===f?"#fff":"rgba(255,255,255,0.5)",boxShadow:"0 1px 2px rgba(0,0,0,0.4)"}},t))}),(0,i.jsxs)("div",{style:{position:"absolute",top:8,left:8,fontSize:10,fontWeight:700,padding:"3px 7px",borderRadius:8,background:"rgba(0,0,0,0.6)",color:"#fff",zIndex:4},children:[f+1," / ",S]})]}),(0,i.jsx)("div",{style:{position:"absolute",top:8,right:8,zIndex:5},children:(0,i.jsx)("span",{style:{fontSize:10,fontWeight:700,padding:"3px 7px",borderRadius:8,background:"rgba(0,0,0,0.6)",color:"#fff"},children:"video"===k.type?"\uD83C\uDFAC Video":S>1?"\uD83D\uDD01 Carousel":"\uD83D\uDDBC Image"})}),(0,i.jsxs)("div",{className:"hover-overlay",style:{position:"absolute",inset:0,background:"linear-gradient(to top, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.30) 26%, rgba(0,0,0,0) 52%)",display:b?"n
1one":"flex",alignItems:"flex-end",justifyContent:"flex-start",padding:12,opacity:0,transition:"opacity .18s",pointerEvents:"none",zIndex:6},children:["video"===k.type&&(0,i.jsx)("div",{style:{position:"absolute",top:10,left:10,pointerEvents:"auto"},children:(0,i.jsx)(eb,{adId:t.id})}),"video"!==k.type&&(0,i.jsxs)("button",{onClick:_,style:{pointerEvents:"auto",background:"#ef4a1e",color:"#fff",border:"none",padding:"8px 14px",borderRadius:10,fontSize:13,fontWeight:600,letterSpacing:"-0.01em",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:7,boxShadow:"0 4px 14px rgba(0,0,0,0.35)"},onMouseEnter:e=>e.currentTarget.style.background="#d63f16",onMouseLeave:e=>e.currentTarget.style.background="#ef4a1e",children:[(0,i.jsx)(h.Z,{size:14,strokeWidth:2.4})," Remake"]})]}),"video"===k.type&&(0,i.jsx)("div",{className:"hover-overlay",style:{position:"absolute",bottom:44,left:12,opacity:0,transition:"opacity .18s",pointerEvents:"none",zIndex:8},children:(0,i.jsxs)("button",{onClick:_,style:{pointerEvents:"auto",background:"#ef4a1e",color:"#fff",border:"none",padding:"8px 14px",borderRadius:10,fontSize:13,fontWeight:600,letterSpacing:"-0.01em",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:7,boxShadow:"0 4px 14px rgba(0,0,0,0.45)"},onMouseEnter:e=>e.currentTarget.style.background="#d63f16",onMouseLeave:e=>e.currentTarget.style.background="#ef4a1e",children:[(0,i.jsx)(g.Z,{size:14,strokeWidth:2.4})," Remake"]})})]})]})}function eI(e){var t,n,r,a,s,d;let{ad:c,onBrandClick:u,onBrandHover:p,onBrandLeave:f}=e,h=(0,R.useRouter)(),[g,m]=(0,o.useState)(!1),[y,v]=(0,o.useState)(!1),[j,w]=(0,o.useState)(!1),S=c.pageId?"https://graph.facebook.com/".concat(c.pageId,"/picture?type=large"):null,[k]=(0,o.useState)(null!==(n=c.videoUrl)&&void 0!==n?n:null),[D,C]=(0,o.useState)(!1),[I,z]=(0,o.useState)(!1),[T,E]=(0,o.useState)(!1),[A,W]=(0,o.useState)(null);(0,o.useRef)(null);let B=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!c.snapshotUrl||k)return;let e=B.current;if(!e)return;let t=new IntersectionObserver(e=>{let[n]=e;n.isIntersecting&&(z(!0),t.disconnect())},{rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[c.snapshotUrl,k]),c.daysRunning>365?"".concat(Math.floor(c.daysRunning/365),"y ").concat(Math.floor(c.daysRunning%365/30),"mo"):c.daysRunning>30?"".concat(Math.floor(c.daysRunning/30),"mo ").concat(c.daysRunning%30,"d"):c.daysRunning>0&&c.daysRunning;let L=(null===(t=c.pageName)||void 0===t?void 0:t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2))||"?",F=function(e){let t=0;for(let n of e)t=(31*t+n.charCodeAt(0))%eg.length;return eg[t]}(c.pageName||""),_=(0,l.l)(c.body,c.onScreenText,c.title),M=_.length>220;return(j||!M||_.slice(0,220),T)?null:(0,i.jsxs)(i.Fragment,{children:[g&&(0,i.jsx)(eh,{ad:c,onClose:()=>{m(!1),v(!0)}}),(0,i.jsxs)("div",{style:{background:"#fff",borderRadius:12,border:"1px solid #e2e8f0",overflow:"hidden",display:"flex",flexDirection:"column",transition:"box-shadow .2s, transform .2s",cursor:"default"},onMouseEnter:e=>{e.currentTarget.style.boxShadow="0 10px 28px rgba(0,0,0,0.12)",e.currentTarget.style.transform="translateY(-3px)"},onMouseLeave:e=>{e.currentTarget.style.boxShadow="none",e.currentTarget.style.transform="none"},children:[(0,i.jsxs)("div",{style:{padding:"8px 10px",display:"flex",alignItems:"center",gap:7},children:[(0,i.jsx)("div",{style:{width:22,height:22,borderRadius:"50%",background:F,color:"#ff5a2c",display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:800,flexShrink:0,letterSpacing:"-0.3px",overflow:"hidden",position:"relative"},children:S?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{style:{position:"absolute"},children:L}),(0,i.jsx)("img",{src:S,alt:c.pageName,onError:e=>{e.currentTarget.style.display="none"},style:{position:"relative",zIndex:1,width:"100%",height:"100%",objectFit:"cover"}})]}):L}),(0,i.jsx)("button",{onClick:()=>null==u?void 0:u(c.pageId,c.pageName),onMouseEnter:e=>null==p?void 0:p(c.pageId,e.currentTarget),onMouseLeave:f,style:{flex:1,minWidth:0,fontSize:12,fontWeight:700,color:"#111",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:"none",border:"none",cursor:"pointer",padding:0,fontFamily:"inherit",textAlign:"left"},children:c.pageName||"Unknown Brand"}),c.isAffiliate&&(0,i.jsx)("span",{title:c.affiliateOf?"Affiliate ad promoting ".concat(c.affiliateOf):"Affiliate ad",style:{flexShrink:0,fontSize:9,fontWeight:800,letterSpacing:".02em",color:"#9a3412",background:"#ffedd5",border:"1px solid #fed7aa",padding:"2px 6px",borderRadius:100,textTransform:"uppercase",whiteSpace:"nowrap"}
1,children:"â Affiliate"}),("winning"===c.performanceTier||"optimized"===c.performanceTier)&&(0,i.jsxs)("span",{style:{position:"relative",flexShrink:0,display:"inline-flex",fontSize:9,fontWeight:800,letterSpacing:".02em",whiteSpace:"nowrap",padding:"2px 6px",borderRadius:100,textTransform:"uppercase",cursor:"help",color:"winning"===c.performanceTier?"#9a3412":"#92600a",background:"winning"===c.performanceTier?"#fdeee7":"#fef9c3",border:"1px solid ".concat("winning"===c.performanceTier?"#f6d8cc":"#fde68a")},onMouseEnter:e=>{let t=e.currentTarget.getBoundingClientRect();W({top:t.bottom+4,left:Math.min(t.left,window.innerWidth-230)})},onMouseLeave:()=>W(null),children:["winning"===c.performanceTier?"\uD83C\uDFC6 Winning":"â¡ Optimized",A&&(0,i.jsxs)("span",{style:{position:"fixed",top:A.top,left:A.left,width:214,zIndex:9999,background:"#fff",border:"1px solid #e2e8f0",borderRadius:10,boxShadow:"0 10px 30px rgba(0,0,0,0.18)",padding:"10px 11px",fontSize:11,lineHeight:1.45,color:"#334155",textTransform:"none",letterSpacing:0,fontWeight:400,textAlign:"left",pointerEvents:"none"},children:[(0,i.jsx)("span",{style:{display:"block",fontWeight:800,fontSize:11.5,color:"#0f172a",marginBottom:5},children:"winning"===c.performanceTier?"\uD83C\uDFC6 Why âWinningâ?":"â¡ Why âOptimizedâ?"}),(0,i.jsxs)("span",{style:{display:"block",marginBottom:6},children:["A percentile rank across our ",(0,i.jsx)("b",{children:"entire"})," library â it rewards ",(0,i.jsx)("b",{children:"proven"})," ads, not guesses:"]}),(0,i.jsxs)("span",{style:{display:"block",marginBottom:6},children:["\uD83D\uDCC5 ",(0,i.jsxs)("b",{children:[c.daysRunning,"d"]})," running ",(0,i.jsx)("span",{style:{color:"#94a3b8"},children:"â longevity (40%)"}),(0,i.jsx)("br",{}),"\uD83D\uDD01 creative reused ",(0,i.jsxs)("b",{children:[null!==(r=c.creativeReuseCount)&&void 0!==r?r:0,"\xd7"]})," ",(0,i.jsx)("span",{style:{color:"#94a3b8"},children:"â re-run = it works (25%)"}),(0,i.jsx)("br",{}),"\uD83D\uDCCA brand runs ",(0,i.jsx)("b",{children:null!==(a=c.brandActiveAds)&&void 0!==a?a:0})," active ads ",(0,i.jsx)("span",{style:{color:"#94a3b8"},children:"â scale (20%)"})]}),(0,i.jsxs)("span",{style:{display:"block",fontWeight:700,color:"#0f172a",marginBottom:6},children:["Score ",Math.round((null!==(s=c.performanceScore)&&void 0!==s?s:0)*100),"/100 \xb7 must run â¥14 days to qualify"]}),(0,i.jsx)("span",{style:{display:"block",fontSize:10,color:"#64748b",borderTop:"1px solid #f1f5f9",paddingTop:5},children:"â Meta doesnât publish impressions â so we rank by public signals advertisers canât fake (how long it runs, how often itâs reused, brand scale)."})]})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:0,position:"relative"},children:[(0,i.jsx)("button",{onClick:()=>m(!0),title:"Save to board",style:{background:"none",border:"none",cursor:"pointer",color:y?"#141d15":"#9ca3af",padding:3,borderRadius:4,transition:"color .15s",display:"inline-flex"},children:(0,i.jsx)("span",{style:{display:"inline-flex",animation:y?"savepop .3s ease":"none"},children:y?(0,i.jsx)(x.Z,{size:14}):(0,i.jsx)(b.Z,{size:14})},y?"saved":"unsaved")}),(0,i.jsx)(ex,{ad:c})]})]}),(0,i.jsxs)("div",{style:{padding:"0 10px 6px",fontSize:10,color:"#6b7280",display:"flex",alignItems:"center",flexWrap:"wrap",gap:4,rowGap:4},children:[(0,i.jsx)("span",{style:{width:5,height:5,borderRadius:"50%",flexShrink:0,background:c.isActive?"#ef4a1e":"#d1d5db",animation:c.isActive?"livepulse 2s infinite":"none"}}),(0,i.jsxs)("span",{style:{whiteSpace:"nowrap"},children:[c.startDate?new Date(c.startDate).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"â"," - ",c.stopDate?new Date(c.stopDate).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"Present"]}),(null!==(d=c.creativeReuseCount)&&void 0!==d?d:0)>1&&(0,i.jsxs)("span",{title:"This creative runs as ".concat(c.creativeReuseCount," separate ads (across countries / retailers) â shown once here"),style:{flexShrink:0,fontSize:9,fontWeight:800,color:"#3730a3",background:"#e0e7ff",border:"1px solid #c7d2fe",padding:"1px 6px",borderRadius:100,whiteSpace:"nowrap"},children:["â» ",c.creativeReuseCount," placements"]})]}),_&&(0,i.jsxs)("div",{style:{padding:"0 10px 8px",fontSize:12,color:"#1f2937",lineHeight:1.4},children:[(0,i.jsx)("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:j?"none":2,WebkitBoxOrient:"vertical"},children:_}),M&&(0,i.jsx)("button",{onClick:()=>w(e=>!e),style:{fontSize:11,color:"#6b7280",background:"none",border:"none",cursor:"pointer",padding:"2px 0 0",fontFamily:"inherit",fontWeight:600},children:j?"less":"more"})]}),(0,i.jsx)("div",{ref:B,onClick:e=>{e.target.closest("button, a, video")||(eT(),h.push("/discovery/".concat(c.id)))},style:{cursor:"pointer"},children:(0,i.jsx)(eC,{ad:c,avatarBg:F,iframeVisible:I,onDead:()=>E(!0)})}),(c.caption||c.title)&&(0,i.jsxs)("div",{style:{padding:"8px 10px",display:"flex",alignItems:"center",gap:8,background:"#fff"},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:0}
1,children:[c.caption&&(0,i.jsx)("div",{style:{fontSize:10,color:"#6b7280",textTransform:"lowercase",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.caption}),c.title&&(0,i.jsx)("div",{style:{fontSize:11,fontWeight:700,color:"#111",marginTop:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.title})]}),(0,i.jsx)("a",{href:c.snapshotUrl,target:"_blank",rel:"noopener noreferrer",style:{flexShrink:0,fontSize:10,fontWeight:600,padding:"5px 10px",borderRadius:6,background:"#f1f5f9",border:"1px solid #e2e8f0",color:"#111",textDecoration:"none",cursor:"pointer",fontFamily:"inherit"},children:c.cta||"Learn more"})]})]})]})}let ez="discovery:snap:v1",eR={};function eT(){try{let e=eR||{};sessionStorage.setItem(ez,JSON.stringify({...e,rawAds:Array.isArray(e.rawAds)?e.rawAds.slice(0,150):[],scrollY:window.scrollY||0,t:Date.now()}))}catch(e){}}function eE(){var e,t,n,r,l,s,d,c,p,f,h,g,x,b,C,I,z,T,E,A,W,B,L,F,_,M,N,P,U,O,H,V;let eo=(0,R.useRouter)(),eh=(0,G.d)(),eg=(0,o.useRef)(void 0);void 0===eg.current&&(eg.current=null!==(e=function(){try{let e=new URLSearchParams(window.location.search),t=t=>(e.get(t)||"").split(",").map(e=>e.trim()).filter(Boolean),n={},i=(e.get("q")||"").trim();i&&(n.query=i,n.searchInput=i),t("hook").length&&(n.hookTypes=t("hook")),t("format_style").length&&(n.formatStyles=t("format_style")),t("format").length&&(n.format=t("format")),t("visual_style").length&&(n.visualStyles=t("visual_style")),t("emotion").length&&(n.emotions=t("emotion")),t("angle").length&&(n.angles=t("angle")),(e.get("niche")||"").trim()&&(n.niches=(e.get("niche")||"").split("|").map(e=>e.trim()).filter(Boolean));let o=parseInt(e.get("days")||"");Number.isFinite(o)&&o>0&&(n.timeDays=o);let r=parseInt(e.get("run_time")||"");Number.isFinite(r)&&r>0&&(n.minDaysStr=String(r));let a=(e.get("sort")||"").trim();return a&&(n.sort=a),Object.keys(n).length?n:null}catch(e){return null}}())&&void 0!==e?e:function(){try{let e=sessionStorage.getItem(ez);if(!e)return null;let t=JSON.parse(e);if(!t||"number"!=typeof t.t||Date.now()-t.t>18e5)return null;return t}catch(e){return null}}());let ex=eg.current,eb=(0,o.useRef)(!!(ex&&Array.isArray(ex.rawAds)&&ex.rawAds.length)),em=(0,o.useRef)(0),ey=(0,o.useRef)((null==ex?void 0:ex.scrollY)||0),ev=(0,o.useRef)(!1),ej=(0,o.useRef)({}),[ew,eS]=(0,o.useState)(null!==(t=null==ex?void 0:ex.searchInput)&&void 0!==t?t:""),[eD,eC]=(0,o.useState)(null!==(n=null==ex?void 0:ex.query)&&void 0!==n?n:""),[eT,eE]=(0,o.useState)(null!==(r=null==ex?void 0:ex.searchMode)&&void 0!==r?r:"adcopy"),[eA,eW]=(0,o.useState)(null),[eB,eL]=(0,o.useState)(null),[eF,e_]=(0,o.useState)(null!==(l=null==ex?void 0:ex.rawAds)&&void 0!==l?l:[]),eM=(0,o.useRef)([]),eN=(0,o.useRef)(0);(0,o.useEffect)(()=>{eM.current=eF},[eF]);let[eP,eU]=(0,o.useState)(!ex),[eO,eH]=(0,o.useState)(null!==(s=null==ex?void 0:ex.nextCursor)&&void 0!==s?s:null),[eZ,eG]=(0,o.useState)(null!==(d=null==ex?void 0:ex.hasMore)&&void 0!==d&&d),[eV,eq]=(0,o.useState)(""),[eY,eJ]=(0,o.useState)(null!==(c=null==ex?void 0:ex.sort)&&void 0!==c?c:"recommended"),[eX,eK]=(0,o.useState)(null!==(p=null==ex?void 0:ex.status)&&void 0!==p?p:"ALL"),[e$,eQ]=(0,o.useState)(null!==(f=null==ex?void 0:ex.platforms)&&void 0!==f?f:[]),[e0,e1]=(0,o.useState)(null!==(h=null==ex?void 0:ex.country)&&void 0!==h?h:"ALL"),[e2,e3]=(0,o.useState)(null!==(g=null==ex?void 0:ex.format)&&void 0!==g?g:[]),[e8,e4]=(0,o.useState)(null!==(x=null==ex?void 0:ex.industry)&&void 0!==x?x:[]),[e5,e6]=(0,o.useState)(null!==(b=null==ex?void 0:ex.language)&&void 0!==b?b:[]),[e7,e9]=(0,o.useState)(null!==(C=null==ex?void 0:ex.theme)&&void 0!==C?C:[]),[te,tt]=(0,o.useState)(null!==(I=null==ex?void 0:ex.minDaysStr)&&void 0!==I?I:""),[tn,ti]=(0,o.useState)(null!==(z=null==ex?void 0:ex.minBrandAdsStr)&&void 0!==z?z:""),[to,tr]=(0,o.useState)(null!==(T=null==ex?void 0:ex.tiers)&&void 0!==T?T:[]),[ta,tl]=(0,o.useState)(null!==(E=null==ex?void 0:ex.niches)&&void 0!==E?E:[]),[ts,td]=(0,o.useState)(null!==(A=null==ex?void 0:ex.adsPerBrandStr)&&void 0!==A?A:""),[tc,tu]=(0,o.useState)(null!==(W=null==ex?void 0:ex.minReuseStr)&&void 0!==W?W:""),[tp,tf]=(0,o.useState)(null!==(B=null==ex?void 0:ex.hookTypes)&&void 0!==B?B:[]),[th,tg]=(0,o.useState)(null!==(L=null==ex?void 0:ex.emotions)&&void 0!==L?L:[]),[tx,tb]=(0,o.useState)(null!==(F=null==ex?void 0:ex.angles)&&void 0!==F?F:[]),[tm,ty]=(0,o.useState)(null!==(_=null==ex?void 0:ex.formatStyles)&&void 0!==_?_:[]),[tv,tj]=(0,o.useState)(null!==(M=null==ex?void 0:ex.visualStyles)&&void 0!==M?M:[]),[tw,tS]=(0,o.useState)(null!==(N=null==ex?void 0:ex.ctaStyles)&&void 0!==N?N:[]),[tk,tD]=(0,o.useState)([]),[tC,tI]=(0,o.useState)(!1),[tz,tR]=(0,o.useState)(null),[tT,tE]=(0,o.useState)(null),tA=(0,o.useRef)(null),tW=(e,t)=>{tA.current&&clearTimeout(tA.current);let n=t.getBoundingClientRect(),i=window.innerWidth,o=window.innerHeight,r=n.left;r+300>i-12&&(r=i-300-12),r<12&&(r=12);let a=n.bottom+8;a+300>o-12&&n.top-300-8>12&&(a=n.top-300-8),tE({left:r,top:a}),tR(e)},tB=()=>{tA.current&&clearTimeout(tA.current),tA.current=setTimeout(()=>tR(null),140)},tL=()=>{tA.current&&clearTimeout(tA.current)},[tF,t_]=(0,o.useState)(4);(0,o.useEffect)(()=>{let e=()=>{let e=window.innerWidth;
1t_(e<480?1:e<700?2:e<1050?3:e<1450?4:5)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let[tM,tN]=(0,o.useState)(!1);(0,o.useEffect)(()=>{tN(!0)},[]);let[tP,tU]=(0,o.useState)(new Set);(0,o.useEffect)(()=>{fetch("/api/follows").then(e=>e.json()).then(e=>tU(new Set(e.pageIds||[]))).catch(()=>{})},[]);let tO=async(e,t)=>{tU(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});try{let n=await fetch("/api/follows",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pageId:e,brandName:t,action:"toggle"})}),i=await n.json();tU(t=>{let n=new Set(t);return i.following?n.add(e):n.delete(e),n})}catch(e){}},[tH,tZ]=(0,o.useState)(!1),[tG,tV]=(0,o.useState)([]),[tq,tY]=(0,o.useState)(!1),[tJ,tX]=(0,o.useState)(!1),[tK,t$]=(0,o.useState)(""),tQ=(0,o.useRef)(null),t0=e=>/facebook\.com\/ads\/library|view_all_page_id=|[?&]id=\d|^\d{6,}$|\/\d{7,}(?:[/?]|$)/.test((e||"").trim()),t1=async()=>{let e=ew.trim();if(e&&!tJ){tX(!0),t$("");try{let t=await fetch("/api/discovery/brand-spy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})}).then(e=>e.json());(null==t?void 0:t.pageId)?(tZ(!1),eo.push("/discovery/brand-spy/".concat(t.pageId))):t$((null==t?void 0:t.error)||"Couldnât find that brand. Try the exact name, or paste their Meta Ad Library link.")}catch(e){t$("Something went wrong â try again.")}finally{tX(!1)}}};(0,o.useEffect)(()=>{let e=e=>{tQ.current&&!tQ.current.contains(e.target)&&tZ(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,o.useEffect)(()=>{if(!ew.trim()||ew.trim().length<2){tV([]);return}let e=setTimeout(async()=>{tY(!0);try{let e=ew.trim(),[t,n]=await Promise.all([fetch("/api/discovery/pages?q=".concat(encodeURIComponent(e))).then(e=>e.json()).catch(()=>({pages:[]})),fetch("/api/discovery/brands?q=".concat(encodeURIComponent(e))).then(e=>e.json()).catch(()=>({brands:[]}))]),i=t.pages||[],o=new Set(i.map(e=>String(e.pageId))),r=(n.brands||[]).filter(e=>!o.has(String(e.pageId))).map(e=>({pageId:e.pageId,name:e.name,picture:e.avatar||null,category:e.industry||"",adCount:e.adCount||0}));tV([...i,...r].slice(0,8))}catch(e){tV([])}finally{tY(!1)}},350);return()=>clearTimeout(e)},[ew]);let[t2,t3]=(0,o.useState)(null!==(P=null==ex?void 0:ex.timeDays)&&void 0!==P?P:0),[t8,t4]=(0,o.useState)(null),[t5,t6]=(0,o.useState)(null!==(U=null==ex?void 0:ex.searchSource)&&void 0!==U?U:"indexed"),[t7,t9]=(0,o.useState)(null!==(O=null==ex?void 0:ex.dbPage)&&void 0!==O?O:0),[ne,nt]=(0,o.useState)(null!==(H=null==ex?void 0:ex.dbTotal)&&void 0!==H?H:0),[nn,ni]=(0,o.useState)(null!==(V=null==ex?void 0:ex.totalInDB)&&void 0!==V?V:0),no=(0,o.useCallback)(async function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=(arguments.length>1&&arguments[1],arguments.length>2?arguments[2]:void 0);eU(!0),eq("");let n=e?0:null!=t?t:t7+1;e&&t9(0);try{var i,r;let t=new URLSearchParams({q:eD,mode:eT,sort:eY,status:eX,page:String(n),..."brand"===eT&&(null==t8?void 0:t8.pageId)?{pageId:t8.pageId,brandName:t8.name}:{},...e$.length?{platforms:e$.join(",")}:{},...1===e2.length?{format:e2[0]}:{},...e8.length?{industry:e8.join(",")}:{},...e7.length?{theme:e7.join(",")}:{},...t2>0?{days:String(t2)}:{},...to.length?{performance_scores:to.join(",")}:{},...ta.length?{niche:ta.join("|")}:{},...parseInt(tn)>0?{active_ads_count:String(parseInt(tn))}:{},...parseInt(te)>0?{run_time:"".concat(parseInt(te),"+")}:{},...parseInt(tc)>0?{min_reuse:String(parseInt(tc))}:{},...parseInt(ts)>0?{ads_per_brand:String(parseInt(ts))}:{},...tp.length?{hook_type:tp.join(",")}:{},...th.length?{emotion:th.join(",")}:{},...tx.length?{angle:tx.join(",")}:{},...tm.length?{format_style:tm.join(",")}:{},...tv.length?{visual_style:tv.join(",")}:{},...tw.length?{cta_style:tw.join(",")}:{}}),a=async()=>{try{let e=await fetch("/api/discovery/db-search?".concat(t)),n=null;try{n=await e.json()}catch(e){n=null}return{ok:!(!e.ok||null==n||(null==n?void 0:n.searchMethod)==="error"),data:n}}catch(e){return{ok:!1,data:null}}},{ok:l,data:s}=await a();if(l||(await new Promise(e=>setTimeout(e,900)),{ok:l,data:s}=await a()),!l){eG(!1),e&&(eq("Search hit a snag â the index was busy. Try again in a moment."),nt(0));return}if(!(s=s||{}).error&&(null===(i=s.ads)||void 0===i?void 0:i.length)>0){let t=s.ads.map(e=>(function(e){let t="".concat(e.body," ").concat(e.title," ").concat(e.caption," ").concat(e.pageName),n=e.format||function(e){if(!e)return"Image";let t=e.toUpperCase();return t.includes("VIDEO")?"Video":t.includes("CAROUSEL")||"DCO"===t?"Carousel":"Image"}(e.mediaType),i=e.industries&&e.industries.length>
10?e.industries:function(e){let t=Y.filter(t=>{let[,n]=t;return n.test(e)}).map(e=>{let[t]=e;return t});return t.length?t:["Other"]}(t);return{...e,thumbnailUrl:e.thumbnailUrl||e.thumbnail_url||null,videoUrl:e.videoUrl||e.video_url||null,creatives:e.creatives||[],format:n,industries:i,themes:J.filter(e=>{let[,n]=e;return n.test(t)}).map(e=>{let[t]=e;return t}),langNames:(e.languages||[]).map(e=>X[e]||e.toUpperCase())}})({...e,mediaType:e.format||""}));for(let e of t){let t=null===(r=e.creatives)||void 0===r?void 0:r[0],n=t&&("video"===t.asset_type?t.poster_url:t.r2_url);if(n){let e=new window.Image;e.decoding="async",e.src=ek(n)}}let i=()=>{if(e_(n=>{if(e)return t;let i=e=>e.image_hash||e.video_hash||"id:".concat(e.id),o=new Set;for(let e of n)o.add(i(e));let r=t.filter(e=>{let t=i(e);return!o.has(t)&&(o.add(t),!0)});return[...n,...r]}),nt(s.total||0),ni(s.totalInDB||0),t6("indexed"),eH(null),!e&&s.hasMore){let e=e=>e.image_hash||e.video_hash||"id:".concat(e.id),n=new Set(eM.current.map(e));t.some(t=>!n.has(e(t)))?eN.current=0:(eN.current+=1,eN.current<=6&&setTimeout(()=>np.current(),160))}else eN.current=0};t9(n),eG(s.hasMore),e?i():(0,o.startTransition)(i);return}e&&e_([]),eG(!1),eH(null),nt(t=>s.total||(e?0:t)),ni(s.totalInDB||0),t6("indexed")}catch(e){eq(e.message)}finally{eU(!1)}},[eD,eT,eY,eX,e$,e0,e2,e8,e7,t7,t2,null==t8?void 0:t8.pageId,to,ta,tn,te,tc,ts,tp,th,tx,tm,tv,tw]);(0,o.useEffect)(()=>{if(eb.current){eb.current=!1;return}no(!0)},[eD,eT,eY,eX,e$,e0,e2,e8,e7,t2,null==t8?void 0:t8.pageId,to,ta,tn,te,tc,ts,tp,th,tx,tm,tv,tw]),(0,o.useEffect)(()=>{let e=()=>{em.current=window.scrollY||window.pageYOffset||0},t=()=>{try{let e=ej.current||{},t={...e,rawAds:Array.isArray(e.rawAds)?e.rawAds.slice(0,150):[],scrollY:em.current||window.scrollY||0,t:Date.now()};sessionStorage.setItem(ez,JSON.stringify(t))}catch(e){}},n=()=>t(),i=()=>{"hidden"===document.visibilityState&&t()};return window.addEventListener("scroll",e,{passive:!0}),window.addEventListener("pagehide",n),document.addEventListener("visibilitychange",i),()=>{window.removeEventListener("scroll",e),window.removeEventListener("pagehide",n),document.removeEventListener("visibilitychange",i),t()}},[]),(0,o.useEffect)(()=>{let e={};for(let t of eF)t.pageId&&(e[t.pageId]||(e[t.pageId]={pageId:t.pageId,name:t.pageName,total:0,loaded:0,picture:null}),e[t.pageId].loaded++,t.brandActiveAds&&t.brandActiveAds>e[t.pageId].total&&(e[t.pageId].total=t.brandActiveAds));tD(Object.values(e).map(e=>({pageId:e.pageId,name:e.name,adCount:e.total||e.loaded,picture:e.picture})).sort((e,t)=>t.adCount-e.adCount).slice(0,20)),tI(!1)},[eF]),(0,o.useMemo)(()=>{let e=new Set;return eF.forEach(t=>t.langNames.forEach(t=>{t&&e.add(t)})),Array.from(e).sort()},[eF]);let nr=parseInt(te)||0,na=parseInt(tn)||0,nl=(0,o.useMemo)(()=>eF.filter(e=>!!(e&&e.id&&(!e2.length||e2.includes(e.format))&&(!e8.length||e.industries.some(e=>e8.includes(e)))&&(!e5.length||e.langNames.some(e=>e5.includes(e)))&&(!e7.length||e.themes.some(e=>e7.includes(e))))),[eF,e2,e8,e5,e7]);(0,o.useEffect)(()=>{if(!ex||ev.current||!tM)return;if(!ey.current||0===nl.length){ev.current=!0;return}let e=0,t=()=>{window.scrollTo(0,ey.current),++e<10&&Math.abs((window.scrollY||0)-ey.current)>6?requestAnimationFrame(t):ev.current=!0};requestAnimationFrame(t)},[tM,nl.length]);let ns=(0,o.useMemo)(()=>[eD,eT,(null==t8?void 0:t8.pageId)||"",eY,eX,e0,t2,e$.join(","),e2.join(","),e8.join(","),e5.join(","),e7.join(","),to.join(","),ta.join("|"),tn,te,tc,ts,tp.join(","),th.join(","),tx.join(","),tm.join(","),tv.join(","),tw.join(",")].join("|"),[eD,eT,null==t8?void 0:t8.pageId,eY,eX,e0,t2,e$,e2,e8,e5,e7,to,ta,tn,te,tc,ts,tp,th,tx,tm,tv,tw]),nd=(0,o.useRef)({setSelectedBrand:t4,openHover:tW,closeHover:tB});nd.current={setSelectedBrand:t4,openHover:tW,closeHover:tB};let nc=(0,o.useMemo)(()=>{let e=e=>{let{data:t}=e;return t?(0,i.jsx)(eI,{ad:t,onBrandClick:(e,t)=>nd.current.setSelectedBrand({pageId:e,name:t}),onBrandHover:(e,t)=>nd.current.openHover(e,t),onBrandLeave:()=>nd.current.closeHover()}):null};return e.displayName="MasonryCard",e},[]),nu=(0,o.useRef)(!1),np=(0,o.useRef)(()=>{});np.current=()=>{nu.current||eP||!eZ||"indexed"!==t5||(nu.current=!0,Promise.resolve(no(!1,void 0,t7+1)).finally(()=>{nu.current=!1}))};let nf=(0,o.useCallback)((e,t,n)=>{t>=n.length-12&&np.current()},[]);(0,o.useEffect)(()=>{!eP&&!nu.current&&eZ&&"indexed"===t5&&t7<1&&np.current()},[t7,eP,eZ,t5,eF.length]);let nh=e=>t=>e(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]),ng=e2.length+e8.length+e5.length+e7.length+("ALL"!==eX?1:0)+e$.length+(nr>0?1:0)+(na>0?1:0)+to.length+ta.length+((parseInt(tc)||0)>0?1:0)+((parseInt(ts)||0)>0?1:0)+tp.length+th.length+tx.length+tm.length+tv.length+tw.length,nx=eV.toLowerCase().includes("permission")||eV.toLowerCase().includes("application does not");return(ej.current={searchInput:ew,query:eD,searchMode:eT,sort:eY,status:eX,platforms:e$,country:e0,format:e2,industry:e8,language:e5,theme:e7,minDaysStr:te,minBrandAdsStr:tn,tiers:to,niches:ta,adsPerBrandStr:ts,minReuseStr:tc,hookTypes:tp,emotions:th,angles:tx,formatStyles:tm,visualStyles:tv,ctaStyles:tw,timeDays:t2,searchSource:t5,dbPage:t7,dbTotal:ne,totalInDB:nn,nextCursor:eO,hasMore:eZ,rawAds:eF},eR=ej.current,tM)?(0,i.jsxs)("div",{style:{minHeight:"100vh",background:"#f8fafc",fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif"},children:[(0,i.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg) } } @keyframes fadeUp { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } } .hide-scrollbar::-webkit-scrollbar { display: none } .hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none }"}),t8&&(0,i.jsx)(Z,{pageId:t8.pageId,pageName:t8.name,onClose:()=>t4(null)}),tz&&tT&&(()=>{var e,t;let n=eF.filter(e=>e.pageId===tz),o=(null===(e=n[0])||void 0===e?void 0:e.pageName)||(null===(t=tk.find(e=>e.pageId===tz))||void 0===t?void 0:t.name)||"Brand",r=7*(o.charCo
1deAt(0)||65)%360,a=n.map(e=>{var t,n;return e.thumbnailUrl||(null===(n=e.creatives)||void 0===n?void 0:null===(t=n[0])||void 0===t?void 0:t.r2_url)}).filter(Boolean).slice(0,3),l=tP.has(tz);return(0,i.jsxs)("div",{onMouseEnter:tL,onMouseLeave:tB,style:{position:"fixed",top:tT.top,left:tT.left,width:300,background:"#fff",border:"1px solid #e2e8f0",borderRadius:14,boxShadow:"0 14px 36px rgba(0,0,0,0.18)",zIndex:300,padding:14},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:10},children:[(0,i.jsx)("div",{style:{width:40,height:40,borderRadius:"50%",background:"hsl(".concat(r,",50%,85%)"),display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:800,color:"hsl(".concat(r,",50%,30%)"),overflow:"hidden",flexShrink:0},children:(0,i.jsx)("img",{src:"https://graph.facebook.com/".concat(tz,"/picture?type=large"),alt:"",style:{width:"100%",height:"100%",objectFit:"cover"},onError:e=>{e.currentTarget.style.display="none"}})}),(0,i.jsxs)("div",{style:{minWidth:0},children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:800,color:"#111",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o}),(0,i.jsxs)("div",{style:{fontSize:11,color:"#6b7280"},children:[n.length," ad",1===n.length?"":"s"," in results"]})]})]}),a.length>0&&(0,i.jsx)("div",{style:{display:"flex",gap:6,marginBottom:12},children:a.map((e,t)=>(0,i.jsx)("img",{src:e,alt:"",style:{width:"33%",aspectRatio:"3/4",objectFit:"cover",borderRadius:8,background:"#f1f3f5"}},t))}),(0,i.jsx)("button",{onClick:()=>tO(tz,o),style:{width:"100%",padding:"9px",marginBottom:8,borderRadius:9,cursor:"pointer",fontFamily:"inherit",fontWeight:700,fontSize:13,border:l?"1px solid #141d15":"1px solid #ef4444",background:l?"#fff7f3":"#fff",color:l?"#141d15":"#ef4444"},children:l?"â Following":"â¡ Follow"}),(0,i.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,i.jsx)("button",{onClick:()=>{eS(o),eC(o),eE("brand"),t4(null),tR(null)},style:{flex:1,padding:"9px",borderRadius:9,border:"none",background:"#ef4a1e",color:"#fff",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:"View ads"}),(0,i.jsx)("button",{onClick:()=>{window.open("/discovery/brand/".concat(tz),"_blank","noopener"),tR(null)},style:{flex:1,padding:"9px",borderRadius:9,border:"1px solid #e2e8f0",background:"#fff",color:"#374151",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:"Details"})]})]})})(),(0,i.jsxs)("div",{style:{borderBottom:"1px solid #efece2",position:eh?"static":"sticky",top:0,zIndex:40,background:"#fff",padding:eh?"12px 14px":"14px 24px"},children:[(0,i.jsxs)("div",{style:{display:"flex",flexWrap:eh?"wrap":"nowrap",alignItems:"center",gap:12,marginBottom:10},children:[(0,i.jsxs)("div",{style:{marginRight:4,flexShrink:0},children:[(0,i.jsx)("div",{style:{fontSize:17,fontWeight:800,color:"#161c17",letterSpacing:"-.015em"},children:"Ad Discovery"}),(0,i.jsx)("div",{style:{fontSize:11,color:"#5b6a55"},children:"Live creative intelligence from Meta"})]}),(0,i.jsx)("div",{style:{display:"flex",gap:4,background:"rgba(255,255,255,0.75)",border:"1px solid #dcebc4",borderRadius:12,padding:3,flexShrink:0},children:[{label:"\uD83D\uDD0D Explore",href:"/discovery"},{label:"\uD83C\uDFF7ï¸ Brands",href:"/discovery/brands"}].map(e=>(0,i.jsx)("a",{href:e.href,style:{padding:"6px 15px",borderRadius:9,fontSize:13,fontWeight:700,background:"/discovery"===e.href?"#ef4a1e":"transparent",color:"/discovery"===e.href?"#fff":"#5b6a55",textDecoration:"none",boxShadow:"/discovery"===e.href?"0 2px 6px rgba(20,29,21,0.25)":"none"},children:e.label},e.href))}),(0,i.jsxs)("div",{ref:tQ,"data-tour":"spy-search",style:{flex:eh?"1 1 100%":1,order:eh?3:0,maxWidth:eh?"100%":520,minWidth:eh?"100%":0,position:"relative"},children:[(0,i.jsx)("form",{onSubmit:e=>{e.preventDefault(),ew.trim()&&(eC(ew),tZ(!1))},children:(0,i.jsxs)("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[(0,i.jsx)(m.Z,{size:15,style:{position:"absolute",left:12,color:"#9ca3af",pointerEvents:"none"}}),(0,i.jsx)("input",{value:ew,onChange:e=>{eS(e.target.value),tZ(!0)},onFocus:()=>{ew.trim()&&tZ(!0)},onKeyDown:e=>{"Escape"===e.key&&tZ(!1)},placeholder:"Search for ads or brands with AIâ¦",style:{width:"100%",padding:"10px 36px",border:"1.5px solid ".concat(tH&&ew?"#141d15":"#dcebc4"),borderRadius:tH&&ew?"12px 12px 0 0":12,fontSize:14,outline:"none",fontFamily:"inherit",background:"#fff",color:"#161c17",boxSizing:"border-box",transition:"border-color 0.15s",boxShadow:"0 2px 8px rgba(20,29,21,0.05)"}}),ew&&(0,i.jsx)("button",{type:"button",onClick:()=>{eS(""),eC(""),tZ(!1)},style:{position:"absolute",right:10,background:"none",border:"none",cursor:"pointer",color:"#9ca3af",fontSize:16},children:"\xd7"})]})}),tH&&ew.trim().length>=1&&(0,i.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,background:"#fff",border:"1.5px solid #e2e8f0",borderTop:"none",borderRadius:"0 0 14px 14px",boxShadow:"0 12px 32px rgba(0,0,0,0.13)",zIndex:200,overflow:"hidden"},children:[(0,i.jsx)("div",{style:{padding:"4px 6px 4px"},children:[{label:"Ad copy",key:"adcopy",hint:"Ads that mention this keyword"},{label:"Brand",key:"brand",hint:"Brands with this name"},{label:"Categories",key:"category",hint:"Ads in this industry/niche"}].map(e=>(0,i.jsxs)("button",{onMouseDown:t=>{if(t.preventDefault(),eE(e.key),eC(ew),"category"===e.key){let e=ew.toLowerCase(),t=et.filter(t=>t.toLowerCase().includes(e)||e.includes(t.toLowerCase().split(" ")[0]));t.length&&e4(t.slice(0,3))}tZ(!1)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"9px 12px",background:"none",border:"none",borderRadius:8,cursor:"pointer",textAlign:"left",fontFamily:"inherit"},onMouseEnter:e=>e.currentTarget.style.background="#f8fafc",onMouseLeave:e=>e.currentTarget.style.background="none",children:[(0,i.jsxs)("span",{style:{fontSize:13,color:"#374151"},children:[(0,i.jsx)("span",{style:{fontWeight:600},children:e.label}),(0,i.jsx)("span",{style:{color:"#9ca3af",fontWeight:400},children:" contains "}),(0,i.jsxs)("span",{style:{fontWeight:600},children:['"',ew,'"']})]}),(0,i.jsx)("span",{style:{fontSize:11,color:"#9ca3af",fontWeight:400,marginLeft:8,flexShrink:0},children:e.hint})]},e.key))}),(0,i.jsx)("div",{style:{height:1,background:"#f1f5f9"}}),(0,i.jsxs)("div",{style:{padding:"6px 6px 4px"},children:[tq&&(0,i.jsxs)("div",{style:{padding:"12px 14px",fontSize:12,color:"#9ca3af",display:"flex",alignItems:"center",gap:8},children:[(0,i.jsx)("div",{style:{width:14,height:14,border:"2px s
1olid #e2e8f0",borderTopColor:"#6b7280",borderRadius:"50%",animation:"spin 0.8s linear infinite",flexShrink:0}}),"Searching brandsâ¦"]}),!tq&&tG.map(e=>(0,i.jsxs)("button",{onMouseDown:t=>{t.preventDefault(),tZ(!1),eo.push("/discovery/brand-spy/".concat(e.pageId))},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 10px",background:"none",border:"none",borderRadius:8,cursor:"pointer",textAlign:"left",fontFamily:"inherit"},onMouseEnter:e=>e.currentTarget.style.background="#f8fafc",onMouseLeave:e=>e.currentTarget.style.background="none",children:[e.picture?(0,i.jsx)("img",{src:e.picture,alt:e.name,style:{width:36,height:36,borderRadius:"50%",objectFit:"cover",border:"1px solid #e2e8f0",flexShrink:0}}):(0,i.jsx)("div",{style:{width:36,height:36,borderRadius:"50%",background:"linear-gradient(135deg,#e2e8f0,#cbd5e1)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,flexShrink:0},children:"\uD83C\uDFF7ï¸"}),(0,i.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,i.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"#111",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name}),(0,i.jsxs)("div",{style:{fontSize:11,color:"#6b7280",display:"flex",alignItems:"center",gap:5,marginTop:1},children:[(0,i.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"#1877F2",children:(0,i.jsx)("path",{d:"M24 12.073C24 5.404 18.627 0 12 0S0 5.404 0 12.073C0 18.1 4.388 23.094 10.125 24v-8.437H7.078v-3.49h3.047V9.41c0-3.025 1.792-4.697 4.533-4.697 1.313 0 2.686.236 2.686.236v2.97h-1.514c-1.491 0-1.956.93-1.956 1.886v2.267h3.328l-.532 3.49h-2.796V24C19.612 23.094 24 18.1 24 12.073z"})}),(0,i.jsx)("span",{children:"Meta ad library"}),void 0!==e.adCount&&0!==e.adCount&&(0,i.jsxs)("span",{style:{color:"#374151",fontWeight:600},children:["\xb7 ","number"==typeof e.adCount?e.adCount.toLocaleString():e.adCount," Ads"]})]})]})]},e.pageId)),!tq&&tG.length>0&&(0,i.jsx)("button",{onMouseDown:e=>{e.preventDefault(),eC(ew),tZ(!1)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",padding:"9px 12px",background:"none",border:"none",borderRadius:8,cursor:"pointer",fontFamily:"inherit",fontSize:13,fontWeight:600,color:"#1877F2",marginTop:2},onMouseEnter:e=>e.currentTarget.style.background="#f0f7ff",onMouseLeave:e=>e.currentTarget.style.background="none",children:"See more brands"}),!tq&&0===tG.length&&(0,i.jsxs)("div",{style:{padding:"8px 8px 4px"},children:[(0,i.jsxs)("button",{onMouseDown:e=>{e.preventDefault(),t1()},disabled:tJ,style:{display:"flex",alignItems:"center",gap:9,width:"100%",padding:"9px 10px",background:"#f0f7ff",border:"1px solid #d6e6ff",borderRadius:8,cursor:tJ?"default":"pointer",textAlign:"left",fontFamily:"inherit"},children:[(0,i.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"#1877F2",children:(0,i.jsx)("path",{d:"M24 12.073C24 5.404 18.627 0 12 0S0 5.404 0 12.073C0 18.1 4.388 23.094 10.125 24v-8.437H7.078v-3.49h3.047V9.41c0-3.025 1.792-4.697 4.533-4.697 1.313 0 2.686.236 2.686.236v2.97h-1.514c-1.491 0-1.956.93-1.956 1.886v2.267h3.328l-.532 3.49h-2.796V24C19.612 23.094 24 18.1 24 12.073z"})}),(0,i.jsx)("span",{style:{fontSize:12.5,color:"#1877F2",fontWeight:700},children:tJ?"Pulling their adsâ¦":t0(ew)?"Pull this brandâs live ads â":"Pull â".concat(ew,"â from the Meta Ad Library â")})]}),tK?(0,i.jsx)("div",{style:{padding:"7px 4px 2px",fontSize:11.5,color:"#b42318",lineHeight:1.5},children:tK}):(0,i.jsxs)("div",{style:{padding:"7px 4px 2px",fontSize:11,color:"#9ca3af",lineHeight:1.5},children:["Not in our library yet. ",t0(ew)?"Weâll pull their live ads now.":"Type the exact brand name and weâll search the Meta Ad Library â or paste their Ad Library link."]})]})]})]})]}),(0,i.jsx)("button",{onClick:()=>{eD.trim()&&no(!0)},disabled:eP||!eD.trim(),title:eD.trim()?"Refresh results":"Enter a search term first",style:{padding:"8px 10px",background:"#fff",border:"1px solid #dcebc4",borderRadius:10,cursor:eP||!eD.trim()?"not-allowed":"pointer",color:eD.trim()?"#3a382f":"#9aa79a",display:"flex",alignItems:"center",flexShrink:0,opacity:eD.trim()?1:.5},children:(0,i.jsx)(y.Z,{size:13,style:{animation:eP?"spin 1s linear infinite":"none"}})})]}),(0,i.jsxs)("div",{"data-tour":"spy-filters",style:{display:"flex",gap:8,rowGap:10,flexWrap:"wrap",alignItems:"center",background:"#fcfdfb",border:"1px solid #efe
1ce2",borderRadius:16,padding:"10px 12px"},children:[(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",gap:2,padding:"3px",background:"#fff",borderRadius:11,border:"1px solid #efece2",flexShrink:0},children:[{label:"All time",days:0},{label:"7d",days:7},{label:"30d",days:30},{label:"90d",days:90},{label:"180d",days:180}].map(e=>(0,i.jsx)("button",{onClick:()=>t3(e.days),style:{padding:"5px 11px",borderRadius:8,fontSize:11.5,fontWeight:700,background:t2===e.days?"#ef4a1e":"transparent",color:t2===e.days?"#fff":"#6f6d5a",border:"none",cursor:"pointer",fontFamily:"inherit"},children:e.label},e.days))}),(0,i.jsx)(ep,{label:"Performance",leadIcon:(0,i.jsx)(v.Z,{size:14}),options:er,selected:to,onToggle:nh(tr),onClear:()=>tr([])}),(0,i.jsx)(ep,{label:"Format",leadIcon:(0,i.jsx)(j.Z,{size:14}),options:ee.map(e=>({value:e,label:e,icon:"Video"===e?"\uD83C\uDFAC":"Carousel"===e?"\uD83D\uDD01":"\uD83D\uDDBC"})),selected:e2,onToggle:nh(e3),onClear:()=>e3([])}),(0,i.jsx)(ep,{label:"Platform",leadIcon:(0,i.jsx)(w.Z,{size:14}),options:K.map(e=>({value:e,label:$[e],icon:Q[e]})),selected:e$,onToggle:nh(eQ),onClear:()=>eQ([])}),(0,i.jsx)(ep,{label:"Industry",leadIcon:(0,i.jsx)(S.Z,{size:14}),options:et.map(e=>({value:e,label:e})),selected:e8,onToggle:nh(e4),onClear:()=>e4([]),searchable:!0}),(0,i.jsx)(ep,{label:"Status",leadIcon:(0,i.jsx)(k.Z,{size:14}),options:ei,selected:"ALL"!==eX?[eX]:[],onToggle:e=>eK(t=>t===e?"ALL":e),onClear:()=>eK("ALL")}),(0,i.jsx)(ep,{label:"Theme",leadIcon:(0,i.jsx)(D.Z,{size:14}),options:en.map(e=>({value:e,label:e})),selected:e7,onToggle:nh(e9),onClear:()=>e9([]),searchable:!0}),(0,i.jsx)(ep,{label:"Niche",options:ea,selected:ta,onToggle:nh(tl),onClear:()=>tl([]),searchable:!0,comingSoon:!0}),(0,i.jsx)(ep,{label:"Hook",options:el,selected:tp,onToggle:nh(tf),onClear:()=>tf([]),searchable:!0,comingSoon:!0}),(0,i.jsx)(ep,{label:"Emotion",options:es,selected:th,onToggle:nh(tg),onClear:()=>tg([]),comingSoon:!0}),(0,i.jsx)(ep,{label:"Angle",options:ed,selected:tx,onToggle:nh(tb),onClear:()=>tb([]),comingSoon:!0}),(0,i.jsx)(ep,{label:"UGC / Studio",options:ec,selected:tm,onToggle:nh(ty),onClear:()=>ty([]),comingSoon:!0}),(0,i.jsx)(ep,{label:"Visual",options:eu,selected:tv,onToggle:nh(tj),onClear:()=>tj([]),searchable:!0,comingSoon:!0}),ng>0&&(0,i.jsxs)("button",{onClick:()=>{e3([]),e4([]),e6([]),e9([]),eK("ALL"),eQ([]),tt(""),ti(""),tr([]),tl([]),tu(""),td(""),tf([]),tg([]),tb([]),ty([]),tj([]),tS([])},style:{fontSize:12,color:"#dc2626",background:"none",border:"none",cursor:"pointer",fontWeight:600,padding:"4px 8px",fontFamily:"inherit"},children:["Clear all (",ng,")"]}),(0,i.jsx)("div",{style:{marginLeft:"auto"},children:(0,i.jsx)(ef,{value:eY,onChange:eJ})})]})]}),(0,i.jsxs)("div",{"data-tour":"spy-feed",style:{padding:"24px",overflowX:"hidden",minWidth:0,maxWidth:"100%",boxSizing:"border-box"},children:[nx&&(0,i.jsxs)("div",{style:{maxWidth:560,margin:"60px auto",textAlign:"center",padding:"0 20px"},children:[(0,i.jsx)("div",{style:{fontSize:48,marginBottom:16},children:"\uD83D\uDD10"}),(0,i.jsx)("div",{style:{fontSize:22,fontWeight:800,color:"#111",marginBottom:10},children:"API Access Needed"}),(0,i.jsxs)("div",{style:{fontSize:14,color:"#6b7280",lineHeight:1.7,marginBottom:28},children:["Meta requires identity confirmation before allowing Ads Library access.",(0,i.jsx)("br",{}),(0,i.jsx)("br",{}),(0,i.jsx)("strong",{style:{color:"#111"},children:"One-time setup (~ 1 min):"}),(0,i.jsx)("br",{}),"1. Go to ",(0,i.jsx)("a",{href:"https://www.facebook.com/ads/library/api/",target:"_blank",rel:"noopener noreferrer",style:{color:"#141d15",fontWeight:700},children:"facebook.com/ads/library/api"}),(0,i.jsx)("br",{}),"2. Click ",(0,i.jsx)("strong",{children:'"Confirm Identity"'})," and complete verification",(0,i.jsx)("br",{}),"3. Come back here and refresh"]}),(0,i.jsxs)("div",{style:{display:"flex",gap:12,justifyContent:"center",flexWrap:"wrap"},children:[(0,i.jsx)("a",{href:"https://www.facebook.com/ads/library/api/",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:8,padding:"12px 24px",background:"#ef4a1e",color:"#fff",borderRadius:10,fontSize:14,fontWeight:700,textDecoration:"none"},children:"\uD83D\uDD11 Confirm Identity on Meta"}),(0,i.jsxs)("a",{href:"https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=".concat("ALL"===e0?"US":e0).concat(eD?"&q=".concat(encodeURIComponent(eD)):"","&media_type=all"),target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:8,padding:"12px 24px",background:"#f1f5f9",color:"#374151",borderRadius:10,fontSize:14,fontWeight:700,textDecoration:"none",border:"1px solid #e2e8f0"},children:[(0,i.jsx)(u.Z,{size:14})," Browse Meta Ads Library"]})]})]}),eV&&!nx&&(0,i.jsxs)("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",borderRadius:12,padding:"14px 18px",marginBottom:20,color:"#dc2626",fontSize:13},children:["â ï¸ ",eV]}),eP&&0===eF.length&&(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(200px,100%), 1fr))",gap:12},children:[...Array(12)].map((e,t)=>(0,i.jsxs)("div",{style:{background:"#fff",borderRadius:16,border:"1px solid #e2e8f0",overflow:"hidden"},children:[(0,i.jsxs)("div",{style:{padding:"12px 14px",display:"flex",gap:10,alignItems:"center",borderBottom:"1px solid #f1f5f9"},children:[(0,i.jsx)("div",{style:{width:36,height:36,borderRadius:"50%",background:"#e2e8f0"},className:"shimmer"}),(0,i.jsxs)("div",{style:{flex:1},children:[(0,i.jsx)("div",{style:{height:12,background:"#e2e8f0",borderRadius:6,marginBottom:6,width:"60%"},className:"shimmer"}),(0,i.jsx)("div",{style:{height:10,background:"#e2e8f0",borderRadius:6,width:"40%"},className:"shimmer"})]})]}),(0,i.jsx)("div",{style:{aspectRatio:"4 / 5",background:"#e2e8f0"},className:"shimmer"}),(0,i.jsxs)("div",{style:{padding:"10px 14px 12px"},children:[(0,i.jsx)("div",{style:{height:10,background:"#e2e8f0",borderRadius:6,marginBottom:6},className:"shimmer"}),(0,i.jsx)("div",{style:{height:10,background:"#e2e8f0",borderRadius:6,width:"80%"},className:"shimmer"})]})]},t))}),!eP&&!eV&&0===eF.length&&!eD&&(0,i.jsxs)("div",{style:{textAlign:"center",padding:"80px 20px"},children:[(0,i.jsx)("div",{style:{fontSize:56,marginBottom:20},children:"\uD83D\uDD0D"}),(0,i.jsx)("div",{style:{fontSize:22,fontWeight:800,color:"#111",marginBottom:10},children:"Search the Meta Ads Library"}),(0,i.jsxs)("div",{style:{fontSize:15,color:"#6b7280",marginBottom:32,lineHeight:1.7},children:["Type a brand name, keyword, or product to discover",(0,i.jsx)("br",{}),"ads currently running on Facebook & Instagram"]}),(0,i.jsx)("div",{style:{display:"flex",gap:8,justifyContent:"center",flexWrap:"wrap"},children:["Nike","Skincare","Weight loss","SAAS","Fashion","Coffee","Gym","Travel"].map(e=>(0,i.jsx)("button",{onClick:()=>{eS(e),eC(e)},style:{padding:"8px 18px",background:"#fff",border:"1.5px solid #e2e8f0",borderRadius:100,fontSize:13,fontWeight:600,color:"#374151",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:e=>{e.currentTarget.style.borderColor="#141d15",e.currentTarget.style.color="#141d15"},onMouseLeave:e=>{e.currentTarget.style.borderColor="#e2e8f0",e.currentTarget.style.color="#374151"},children:e},e))})]}),!eP&&!eV&&0===eF.length&&eD&&(0,i.jsxs)("div",{style:{textAlign:"center",padding:"80px 20px",color:"#6b7280"},children:[(0,i.jsx)("div",{style:{fontSize:48,marginBottom:16},children:"\uD83E\uDD37"}),(0,i.jsxs)("div",{style:{fontSize:18,fontWeight:700,color:"#111",marginBottom:8},children:['No ads found for "',eD,'"']}
1),(0,i.jsx)("div",{style:{fontSize:14},children:"Try a different search term or adjust your filters"})]}),!eP&&!eV&&eF.length>0&&0===nl.length&&(0,i.jsxs)("div",{style:{textAlign:"center",padding:"60px 20px",color:"#6b7280"},children:[(0,i.jsx)("div",{style:{fontSize:36,marginBottom:12},children:"\uD83C\uDF9Bï¸"}),(0,i.jsx)("div",{style:{fontSize:16,fontWeight:700,color:"#111",marginBottom:6},children:"No ads match your filters"}),(0,i.jsxs)("div",{style:{fontSize:13},children:[eF.length," ads loaded â try adjusting the filters above"]})]}),nl.length>0&&(0,i.jsxs)(i.Fragment,{children:[tM&&(0,i.jsx)(q,{children:(0,i.jsx)(a.R,{items:nl,columnGutter:12,columnCount:tF,overscanBy:3,itemKey:(e,t)=>{var n;return null!==(n=null==e?void 0:e.id)&&void 0!==n?n:"_".concat(t)},render:nc,onRender:nf},ns)}),eP&&eZ&&nl.length>0&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:10,padding:"30px 0 40px",color:"#64748b",fontSize:13.5,fontWeight:600},children:[(0,i.jsx)("span",{style:{width:16,height:16,borderRadius:"50%",border:"2px solid #e2e8f0",borderTopColor:"#141d15",display:"inline-block",animation:"spin 0.7s linear infinite"}}),"Finding more winning adsâ¦"]})]})]})]}):(0,i.jsxs)("div",{style:{minHeight:"100vh",background:"#f8fafc",padding:"14px 24px"},children:[(0,i.jsx)("div",{style:{height:38,width:360,maxWidth:"60%",background:"#e9edf2",borderRadius:10,marginBottom:16},className:"shimmer"}),(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(230px,100%), 1fr))",gap:14,alignItems:"start"},children:Array.from({length:15}).map((e,t)=>(0,i.jsxs)("div",{style:{background:"#fff",borderRadius:12,border:"1px solid #e9edf2",overflow:"hidden"},children:[(0,i.jsx)("div",{style:{aspectRatio:t%3==0?"3 / 4":t%3==1?"1 / 1":"4 / 5",background:"#e9edf2"},className:"shimmer"}),(0,i.jsxs)("div",{style:{padding:12},children:[(0,i.jsx)("div",{style:{height:10,background:"#e9edf2",borderRadius:6,marginBottom:7,width:"72%"},className:"shimmer"}),(0,i.jsx)("div",{style:{height:9,background:"#eef1f5",borderRadius:6,width:"45%"},className:"shimmer"})]})]},t))})]})}},18569:function(e,t,n){n.d(t,{Bg:function(){return c},XD:function(){return p},hp:function(){return u},qq:function(){return l}});var i=n(57437),o=n(2265),r=n(56648);let a="credits:refresh";function l(){window.dispatchEvent(new Event(a))}let s="credits:lastBalance",d=null;function c(){let[e,t]=(0,o.useState)(null!=d?d:{balance:0,plan:"trial",reset_at:null,trialing:!1,trial_ends_at:null,pricing:{},loading:!0}),n=(0,o.useCallback)(async()=>{try{var e,n,i,o,r,a;let l=await fetch("/api/credits/balance");if(!l.ok)return;let c=await l.json(),u=null!==(e=c.balance)&&void 0!==e?e:0;localStorage.setItem(s,String(u));let p={balance:u,plan:null!==(n=c.plan)&&void 0!==n?n:"trial",reset_at:null!==(i=c.reset_at)&&void 0!==i?i:null,trialing:!!c.trialing,trial_ends_at:null!==(o=c.trial_ends_at)&&void 0!==o?o:null,pricing:null!==(r=c.pricing)&&void 0!==r?r:{},loading:!1,subscriptionStatus:null!==(a=c.subscription_status)&&void 0!==a?a:null,canceled:!!c.canceled,isOwner:!1!==c.is_owner};d=p,t(p)}catch(e){t(e=>({...e,loading:!1}))}},[]);return(0,o.useEffect)(()=>{if(!d){let e=Number(localStorage.getItem(s));Number.isFinite(e)&&e>0&&t(t=>({...t,balance:e,loading:!1}))}n();let e=()=>n();return window.addEventListener(a,e),window.addEventListener("focus",e),()=>{window.removeEventListener(a,e),window.removeEventListener("focus",e)}},[n]),{...e,refetch:n}}function u(e,t,n){return!(n<t)||((0,r._f)("buy","Not enough credits â ".concat(e," needs ").concat(t,", you have ").concat(n.toLocaleString(),". Top up to continue.")),!1)}function p(e){let{compact:t=!1}=e,{balance:n,loading:o,plan:a,trialing:l}=c(),s=n<50,d=l?"Trial \xb7 ".concat(n," credits â your full plan credits unlock when the trial ends, or click to pay now & unlock"):"Plan: ".concat(a," \xb7 ").concat(n," credits");return(0,i.jsxs)("button",{type:"button",onClick:()=>(0,r._f)(s?"buy":"plan"),title:d,style:{display:"inline-flex",alignItems:"center",gap:6,cursor:"pointer",fontFamily:"inherit",padding:t?"4px 10px":"6px 12px",borderRadius:999,background:s?"#fef2f2":"#fff",border:"1px solid ".concat(s?"#fecaca":"#efece2"),color:s?"#b91c1c":"#141d15",fontSize:12,fontWeight:700},children:[(0,i.jsx)("span",{style:{fontSize:13,color:s?"#b91c1c":"#ef4a1e"}
1,children:"â"}),(0,i.jsx)("span",{children:o&&!n?"â¦":n.toLocaleString()}),(0,i.jsx)("span",{style:{opacity:.7,fontWeight:600},children:"credits"}),s&&!o&&(0,i.jsx)("span",{style:{marginLeft:4,fontWeight:800},children:"\xb7 Top\xa0up"})]})}},85621:function(e,t,n){n.d(t,{Z:function(){return r}});var i=n(57437),o=n(2265);function r(e){var t,n;let{src:r,poster:a,brandBg:l="#1c2b1c",initials:s="",onPlayingChange:d,onError:c}=e,u=(0,o.useRef)(null),p=(0,o.useRef)(null),[f,h]=(0,o.useState)(!1),[g,x]=(0,o.useState)(!1),[b,m]=(0,o.useState)(!1),[y,v]=(0,o.useState)(!1),[j,w]=(0,o.useState)(0),[S,k]=(0,o.useState)(!1),D=!!(null===(t=(n=window).matchMedia)||void 0===t?void 0:t.call(n,"(prefers-reduced-motion: reduce)").matches),C=e=>{m(e),null==d||d(e)},I=f||b,z=f&&!b&&!D;return(0,i.jsxs)("div",{ref:u,onMouseEnter:()=>h(!0),onMouseLeave:()=>{h(!1),b||w(0)},onMouseMove:e=>{if(D||b)return;let t=u.current;if(!t)return;let n=t.getBoundingClientRect(),i=Math.min(1,Math.max(0,(e.clientX-n.left)/n.width));w(i);let o=p.current;if(o&&o.duration&&isFinite(o.duration))try{o.currentTime=i*o.duration}catch(e){}},style:{position:"absolute",inset:0,overflow:"hidden",background:"linear-gradient(140deg, ".concat(l," 0%, #14181c 130%)")},children:[!S&&!g&&s&&(0,i.jsx)("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:72,fontWeight:900,color:"rgba(255,255,255,0.10)",letterSpacing:"-.05em",userSelect:"none"},children:s}),a&&(0,i.jsx)("img",{src:a,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",className:"sf-thumb-img",onLoad:()=>k(!0),style:{position:"absolute",inset:0,opacity:S&&!(I&&g)?1:I&&g?0:S?1:0,transition:"opacity .15s"}}),I&&(0,i.jsx)("video",{ref:p,src:r,muted:!0,playsInline:!0,preload:"metadata",className:"sf-thumb-img",onLoadedMetadata:()=>x(!0),onCanPlay:()=>v(!1),onWaiting:()=>v(!0),onError:()=>null==c?void 0:c(),onPlaying:()=>v(!1),onTimeUpdate:()=>{if(b){let e=p.current;w(e.duration?e.currentTime/e.duration:0)}},onEnded:()=>{C(!1),w(0)},style:{position:"absolute",inset:0,background:"#000",opacity:g?1:0,transition:"opacity .15s",zIndex:2}},r),z&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{style:{position:"absolute",top:0,bottom:0,left:"".concat(100*j,"%"),width:2,background:"#fff",transform:"translateX(-1px)",boxShadow:"0 0 8px rgba(0,0,0,.5)",zIndex:9,pointerEvents:"none"}}),(0,i.jsx)("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:3,background:"rgba(0,0,0,.25)",zIndex:9,pointerEvents:"none"},children:(0,i.jsx)("div",{style:{height:"100%",width:"".concat(100*j,"%"),background:"#fff"}})})]}),!b&&(0,i.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9,pointerEvents:"none"},children:(0,i.jsx)("button",{onClick:e=>{e.stopPropagation();let t=p.current;t&&(v(!0),t.muted=!1,t.currentTime=0,t.play().then(()=>C(!0)).catch(()=>{t.muted=!0,t.play().then(()=>C(!0)).catch(()=>{})}))},"aria-label":"Play",style:{pointerEvents:"auto",width:48,height:48,borderRadius:"50%",background:"#ff5a2c",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:"0 6px 20px rgba(0,0,0,.35)",padding:0,transition:"transform .12s"},onMouseEnter:e=>e.currentTarget.style.transform="scale(1.08)",onMouseLeave:e=>e.currentTarget.style.transform="scale(1)",children:(0,i.jsx)("span",{style:{fontSize:17,marginLeft:3,color:"#0e1b12"},children:"â¶"})})}),b&&(0,i.jsxs)("div",{style:{position:"absolute",bottom:10,right:10,width:40,height:40,zIndex:9},children:[(0,i.jsx)("button",{onClick:e=>{var t;e.stopPropagation(),null===(t=p.current)||void 0===t||t.pause(),C(!1)},"aria-label":"Pause",style:{position:"absolute",inset:0,width:40,height:40,borderRadius:"50%",background:"rgba(14,27,18,.6)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#ff5a2c",fontSize:13,backdropFilter:"blur(4px)"},children:y?"":"â¸"}),(0,i.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",style:{position:"absolute",inset:0,transform:"rotate(-90deg)",pointerEvents:"none"},children:[(0,i.jsx)("circle",{cx:"20",cy:"20",r:"15",fill:"none",stroke:"rgba(255,255,255,.18)",strokeWidth:"3"}),(0,i.jsx)("circle",{cx:"20",cy:"20",r:"15",fill:"none",stroke:"#ff5a2c",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:94.25,strokeDashoffset:y?70.687
15:94.25*(1-j),style:y?{animation:"hsv-spin 0.8s linear infinite",transformOrigin:"20px 20px"}:{transition:"stroke-dashoffset .2s linear"}})]})]}),(0,i.jsx)("style",{children:"@keyframes hsv-spin{to{transform:rotate(360deg)}}"})]})}},73005:function(e,t,n){n.d(t,{A:function(){return l},V:function(){return r}});var i=n(57437),o=n(2265);function r(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Saved to Board";window.dispatchEvent(new CustomEvent("sm:saved",{detail:{label:e}}))}let a=[{tx:"0px",ty:"-22px",c:"#ff5a2c",d:"0s"},{tx:"20px",ty:"-8px",c:"#141d15",d:".04s"},{tx:"15px",ty:"16px",c:"#ff5a2c",d:".02s"},{tx:"-16px",ty:"14px",c:"#fff",d:".06s"},{tx:"-20px",ty:"-9px",c:"#8fbf3d",d:"0s"}];function l(){let[e,t]=(0,o.useState)(null);return((0,o.useEffect)(()=>{let e=e=>{var n;return t({label:(null===(n=e.detail)||void 0===n?void 0:n.label)||"Saved to Board",key:Date.now()})};return window.addEventListener("sm:saved",e),()=>window.removeEventListener("sm:saved",e)},[]),(0,o.useEffect)(()=>{if(!e)return;let n=setTimeout(()=>t(null),1700);return()=>clearTimeout(n)},[e]),e)?(0,i.jsxs)("div",{style:{position:"fixed",left:"50%",bottom:34,zIndex:9998,display:"flex",alignItems:"center",gap:8,background:"#0e1b12",padding:"9px 16px 9px 12px",borderRadius:999,boxShadow:"0 12px 30px -10px rgba(0,0,0,.5)",fontFamily:"Inter, sans-serif",animation:"sv-toast 1.6s ease both"},children:[(0,i.jsx)("style",{children:"\n@keyframes sv-toast { 0%{opacity:0;transform:translate(-50%,12px);} 12%{opacity:1;transform:translate(-50%,0);} 84%{opacity:1;transform:translate(-50%,0);} 100%{opacity:0;transform:translate(-50%,-5px);} }\n@keyframes sv-ring { 0%{transform:translate(-50%,-50%) scale(.3);opacity:.9;} 100%{transform:translate(-50%,-50%) scale(2.6);opacity:0;} }\n@keyframes sv-confetti { 0%{transform:translate(-50%,-50%) scale(0);opacity:0;} 25%{opacity:1;} 100%{transform:translate(calc(-50% + var(--tx)),calc(-50% + var(--ty))) scale(1);opacity:0;} }\n@keyframes sv-catch { 0%{transform:scale(1);} 35%{transform:scale(1.38);} 60%{transform:scale(.92);} 100%{transform:scale(1);} }\n@media (prefers-reduced-motion: reduce){ .sv-anim{animation-duration:.01s !important;} .sv-confetti,.sv-ring{display:none !important;} }\n"}),(0,i.jsxs)("span",{className:"sv-anim",style:{position:"relative",width:18,height:18,borderRadius:"50%",background:"#ff5a2c",display:"flex",alignItems:"center",justifyContent:"center",transformOrigin:"center",animation:"sv-catch .5s cubic-bezier(.34,1.56,.64,1) both"},children:[(0,i.jsx)("svg",{width:10,height:10,viewBox:"0 0 10 10",fill:"none",children:(0,i.jsx)("path",{d:"M1.5 5.2l2.2 2.3L8.5 2.5",stroke:"#0e1b12",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"})}),(0,i.jsx)("span",{className:"sv-ring",style:{position:"absolute",top:"50%",left:"50%",width:24,height:24,borderRadius:"50%",border:"2px solid #ff5a2c",animation:"sv-ring .6s ease-out both"}}),a.map((e,t)=>(0,i.jsx)("span",{className:"sv-confetti",style:{position:"absolute",top:"50%",left:"50%",width:5,height:5,borderRadius:1,background:e.c,"--tx":e.tx,"--ty":e.ty,animation:"sv-confetti .6s ease-out ".concat(e.d," both")}},t))]}),(0,i.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"#f6f7f5"},children:e.label})]},e.key):null}},24728:function(e,t,n){n.d(t,{l:function(){return i}});function i(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];let o=e=>(e||"").replace(/\{\{[^}]*\}\}/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,"\n\n").replace(/\s*([,.;:!?])\s*\1+/g,"$1").trim(),r=o(e);if(r.length>=3)return r;for(let e of n){let t=o(e);if(t.length>=3)return t}return""}},98039:function(e,t,n){n.d(t,{d:function(){return o}});var i=n(2265);function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:768,[t,n]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{let t=window.matchMedia("(max-width: ".concat(e,"px)")),i=()=>n(t.matches);return i(),t.addEventListener?t.addEventListener("change",i):t.addListener(i),()=>{t.removeEventListener?t.removeEventListener("change",i):t.removeListener(i)}},[e]),t}}}]);
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.