1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5825],{4729:(e,t,n)=>{n.d(t,{k:()=>c});var r=n(95155),a=n(12115),s=n(85921),l=n(42196),i=n(93499),o=n(37657);function d(e){var t,n,i,d;let{card:c}=e,[u,m]=(0,a.useState)(!1),p=(0,o.m2)(null!=(t=c.poster_r2)?t:c.image_r2_url,null!=(n=c.poster)?n:c.image_url),x=(0,o.m2)(c.video_r2_url,c.video_url);if("video"===c.type&&x)return(0,r.jsx)("video",{src:x,poster:p||void 0,controls:!0,muted:!0,loop:!0,playsInline:!0,preload:"none",className:"aspect-[4/5] w-full rounded-kd border border-kd-border bg-black object-contain"});let v=(0,o.m2)(null!=(i=c.image_r2_url)?i:c.poster_r2,null!=(d=c.image_url)?d:c.poster);return v&&!u?(0,r.jsx)("img",{src:v,alt:c.title||"",loading:"lazy",onError:()=>m(!0),className:"aspect-[4/5] w-full rounded-kd border border-kd-border bg-kd-card object-cover"}):(0,r.jsx)("div",{className:"grid aspect-[4/5] w-full place-items-center rounded-kd border border-kd-border bg-kd-card text-kd-subtle",children:"video"===c.type?(0,r.jsx)(s.A,{className:"size-7",strokeWidth:1.5,"aria-hidden":"true"}):(0,r.jsx)(l.A,{className:"size-7",strokeWidth:1.5,"aria-hidden":"true"})})}function c(e){let{media:t}=e,n=(t||[]).filter(Boolean);return 0===n.length?null:(0,r.jsxs)("section",{"aria-label":"Carousel cards (".concat(n.length,")"),children:[(0,r.jsxs)("div",{className:"mb-2 text-[11px] font-medium uppercase tracking-wide text-kd-subtle",children:[n.length," carousel card",1===n.length?"":"s"]}),(0,r.jsx)("div",{className:"-mx-1 flex snap-x snap-mandatory gap-3 overflow-x-auto px-1 pb-2",children:n.map((e,t)=>(0,r.jsxs)("article",{className:"flex w-[200px] shrink-0 snap-start flex-col gap-2 rounded-kd border border-kd-border bg-kd-card p-2",children:[(0,r.jsx)(d,{card:e}),e.title?(0,r.jsx)("h5",{className:"line-clamp-2 text-[13px] font-semibold leading-snug text-kd-text",children:e.title}):null,e.body?(0,r.jsx)("p",{className:"line-clamp-3 text-[12px] leading-snug text-kd-muted",children:e.body}):null,(0,r.jsxs)("div",{className:"mt-auto flex flex-col gap-1.5 pt-1",children:[e.cta_text?(0,r.jsx)("span",{className:"inline-flex w-fit items-center rounded-kd bg-kd-accent-soft px-2 py-0.5 text-[11px] font-semibold text-kd-accent",children:e.cta_text}):null,e.link_url&&/^https?:\/\//i.test(e.link_url.trim())?(0,r.jsxs)("a",{href:e.link_url.trim(),target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"inline-flex items-center gap-1 truncate text-[11px] font-medium text-kd-accent hover:underline",children:[e.landing_domain||"landing page",(0,r.jsx)(i.A,{className:"size-3 shrink-0",strokeWidth:2})]}):e.landing_domain?(0,r.jsx)("span",{className:"inline-flex items-center gap-1 truncate text-[11px] font-medium text-kd-subtle",children:e.landing_domain}):null]})]},t))})]})}},11884:(e,t,n)=>{n.d(t,{C:()=>d});var r=n(95155),a=n(12115),s=n(47650),l=n(65229),i=n(91456),o=n(35299);function d(e){let{open:t,onClose:n,onCreated:d,workspaceId:c}=e,[u,m]=(0,a.useState)(""),[p,x]=(0,a.useState)(!1),[v,b]=(0,a.useState)(null),[f,h]=(0,a.useState)(!1),k=(0,a.useRef)(null),g=(0,a.useRef)(null);async function y(){let e=u.trim();if(e&&!p){x(!0),b(null);try{let t=await fetch("/api/boards",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,workspaceId:c||void 0})}).then(e=>e.json());if(!(null==t?void 0:t.ok)||!t.board)throw Error((null==t?void 0:t.error)||"Couldn't create the board.");null==d||d(t.board),n()}catch(e){b((null==e?void 0:e.message)||"Couldn't create the board."),x(!1)}}}return((0,a.useEffect)(()=>{var e,n;if(!t)return;m(""),b(null),x(!1),h(null!=(n=null==(e=document.querySelector(".kd"))?void 0:e.classList.contains("dark"))&&n);let r=document.activeElement,a=setTimeout(()=>{var e;return null==(e=k.current)?void 0:e.focus()},40);return()=>{var e;clearTimeout(a),null==r||null==(e=r.focus)||e.call(r)}},[t]),(0,a.useEffect)(()=>{if(!t)return;document.body.style.overflow="hidden";let e=e=>{if("Escape"===e.key&&!p)return void n();if("Tab"!==e.key)return;let t=g.current;if(!t)return;let r=Array.from(t.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not
1([tabindex="-1"])'));if(0===r.length)return;let a=r[0],s=r[r.length-1],l=document.activeElement;e.shiftKey?l!==a&&t.contains(l)||(e.preventDefault(),s.focus()):l!==s&&t.contains(l)||(e.preventDefault(),a.focus())};return window.addEventListener("keydown",e),()=>{document.body.style.overflow="",window.removeEventListener("keydown",e)}},[t,p,n]),t)?(0,s.createPortal)((0,r.jsxs)("div",{ref:g,className:"kd".concat(f?" dark":""," fixed inset-0 z-[75] flex items-center justify-center p-4"),role:"dialog","aria-modal":"true","aria-labelledby":"create-board-title","aria-describedby":"create-board-desc",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/55 backdrop-blur-sm",onClick:()=>!p&&n()}),(0,r.jsxs)("div",{className:"relative z-10 w-full max-w-md overflow-hidden rounded-kd border border-kd-border bg-kd-bg shadow-[0_24px_64px_rgba(17,17,26,0.28)]",children:[(0,r.jsx)("button",{type:"button",onClick:()=>!p&&n(),"aria-label":"Close",className:"absolute right-3 top-3 grid size-8 place-items-center rounded-kd text-kd-muted outline-none transition-colors hover:bg-kd-hover hover:text-kd-text focus-visible:ring-2 focus-visible:ring-kd-ring",children:(0,r.jsx)(l.A,{className:"size-4"})}),(0,r.jsxs)("div",{className:"p-6",children:[(0,r.jsx)("div",{className:"mb-3 inline-flex size-10 items-center justify-center rounded-kd bg-kd-card text-kd-accent",children:(0,r.jsx)(i.A,{className:"size-5"})}),(0,r.jsx)("h2",{id:"create-board-title",className:"text-[17px] font-bold tracking-tight text-kd-text",children:"Create a new board"}),(0,r.jsx)("p",{id:"create-board-desc",className:"mt-1 text-[13.5px] leading-snug text-kd-muted",children:"Group saved ads into a collection you can filter, sort, and share with your team."}),(0,r.jsx)("label",{htmlFor:"board-name",className:"mt-5 block text-[12px] font-semibold text-kd-muted",children:"Board name"}),(0,r.jsx)("input",{id:"board-name",ref:k,value:u,maxLength:80,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:"e.g. Winning hooks","aria-invalid":!!v||void 0,"aria-describedby":v?"board-name-error":void 0,className:"mt-1.5 h-10 w-full rounded-kd border border-kd-border bg-kd-bg px-3 text-[14px] text-kd-text outline-none transition-colors placeholder:text-kd-subtle focus:border-kd-accent focus:ring-2 focus:ring-kd-ring"}),v?(0,r.jsx)("p",{id:"board-name-error",role:"alert",className:"mt-2 text-[12.5px] font-medium text-kd-destructive",children:v}):null,(0,r.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>!p&&n(),className:"h-9 rounded-kd px-3.5 text-[13px] font-semibold text-kd-muted outline-none transition-colors hover:bg-kd-hover hover:text-kd-text focus-visible:ring-2 focus-visible:ring-kd-ring",children:"Cancel"}),(0,r.jsxs)("button",{type:"button",onClick:y,disabled:p||!u.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-kd bg-kd-accent px-4 text-[13px] font-semibold text-kd-accent-text outline-none transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-kd-ring disabled:cursor-not-allowed disabled:opacity-50",children:[p?(0,r.jsx)(o.A,{className:"size-4 animate-spin"}):null,"Create board"]})]})]})]})]}),document.body):null}},16443:(e,t,n)=>{n.d(t,{ToastProvider:()=>o,d:()=>l});var r=n(95155),a=n(12115);let s=(0,a.createContext)(null);function l(){let e=(0,a.useContext)(s);return e||{toast:e=>{}}}let i=0;function o(e){let{children:t}=e,[n,l]=(0,a.useState)([]),o=(0,a.useRef)({}),d=(0,a.useCallback)(e=>{l(t=>t.filter(t=>t.id!==e));let t=o.current[e];t&&(clearTimeout(t),delete o.current[e])},[]),c=(0,a.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error";if(!e)return;let n=++i;l(r=>[...r.slice(-2),{id:n,kind:t,msg:e}]),o.current[n]=setTimeout(()=>d(n),"error"===t?6e3:8e3)},[d]);return(0,r.jsxs)(s.Provider,{value:{toast:c},children:[t,(0,r.jsx)("div",{className:"kt-wrap",role:"region","aria-live":"polite","aria-label":"Notifications",children:n.map(e=>(0,r.jsxs)("button",{type:"button",className:"kt kt-".concat(e.kind),onClick:()=>d(e.id),"aria-label":"Dismiss notification",children:[(0,r.jsx)("span",{className:"kt-ico","aria-hidden":"true",children:"error"===e.kind?"!":"success"===e.kind?"â":"i"}),(0,r.jsx)("span",{className:"kt-msg",children:e.msg})]},e.id))})]})}},21170:(e,t,n)=>{n.d(t,{DialogHost:()=>c,T3:()=>d,Vb:()=>o,ZD:()=>i});var r=n(95155),a=n(12115);let s=null;function l(e,t){return new Promise(n=>{if(!s)return void n("prompt"===e?null:"alert"===e&&void 0);s({...t,kind:e,resolve:n})})}function i(e){return l("confirm",e)}function o(e){return l("prompt",e)}function d(e){return l("alert",e)}function c(){let[e,t]=(0,a.useState)(null),[n,l]=(0,a.useState)(""),i=(0,a.useRef)(null),o=(0,a.useRef)(null),d=(0,a.useRef)(null),c=(0,a.useRef)("");d.current=e,c.current=n,(0,a.useEffect)(()=>(s=e=>{var n;let r=d.current;r&&r.resolve("prompt"===r.kind?null:"alert"===r.kind&&void 0),l(null!=(n=e.defaultValue)?n:""),t(e)},()=>{s=null}),[]);let u=e=>{let n=d.current;t(null),null==n||n.resolve(e)},m=()=>{let e=d.current;e&&u("prompt"===e.kind?c.current:"alert"!==e.kind||void 0)},p=()=>{let e=d.current;e&&u("prompt"===e.kind?null:"alert"===e.kind&&void 0)};if((0,a.useEffect)(()=>
1{if((null==e?void 0:e.kind)!=="prompt")return;let t=setTimeout(()=>{var e,t;null==(e=i.current)||e.focus(),null==(t=i.current)||t.select()},20);return()=>clearTimeout(t)},[e]),(0,a.useEffect)(()=>{if(!e)return;let t=document.activeElement;return()=>{var e;null==t||null==(e=t.focus)||e.call(t)}},[e]),(0,a.useEffect)(()=>{if(!e)return;let t=e=>{var t;if("Escape"===e.key)e.preventDefault(),p();else if("Enter"===e.key&&(null==(t=d.current)?void 0:t.kind)!=="prompt")e.preventDefault(),m();else if("Tab"===e.key){let t=o.current;if(!t)return;let n=Array.from(t.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(0===n.length)return void e.preventDefault();let r=n[0],a=n[n.length-1],s=document.activeElement;e.shiftKey?s!==r&&t.contains(s)||(e.preventDefault(),a.focus()):s!==a&&t.contains(s)||(e.preventDefault(),r.focus())}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),!e)return null;let x=e.confirmLabel||("alert"===e.kind?"OK":e.destructive?"Remove":"Confirm");return(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":e.title,className:"fixed inset-0 z-[200] flex items-center justify-center p-4",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px]",onClick:p}),(0,r.jsxs)("div",{ref:o,className:"relative w-full max-w-[420px] rounded-2xl border border-zinc-200 bg-white p-5 shadow-2xl dark:border-zinc-700 dark:bg-zinc-900",children:[(0,r.jsx)("h2",{className:"text-[15px] font-semibold text-zinc-900 dark:text-zinc-100",children:e.title}),e.message?(0,r.jsx)("p",{className:"mt-1.5 text-[13px] leading-relaxed text-zinc-500 dark:text-zinc-400",children:e.message}):null,"prompt"===e.kind?(0,r.jsx)("input",{ref:i,value:n,onChange:e=>l(e.target.value),placeholder:e.placeholder,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),m())},className:"mt-3 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2 text-[14px] text-zinc-900 placeholder:text-zinc-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#F0541F] dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-100"}):null,(0,r.jsxs)("div",{className:"mt-5 flex items-center justify-end gap-2",children:["alert"!==e.kind?(0,r.jsx)("button",{type:"button",onClick:p,className:"rounded-lg border border-zinc-300 px-3.5 py-2 text-[13px] font-medium text-zinc-700 hover:bg-zinc-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-800",children:e.cancelLabel||"Cancel"}):null,(0,r.jsx)("button",{type:"button",autoFocus:"prompt"!==e.kind,onClick:m,className:"rounded-lg px-3.5 py-2 text-[13px] font-semibold text-white focus-visible:outline-none focus-visible:ring-2 ".concat(e.destructive?"bg-red-600 hover:bg-red-700 focus-visible:ring-red-500":"bg-[#F0541F] hover:opacity-90 focus-visible:ring-[#F0541F]"),children:x})]})]})]})}},37657:(e,t,n)=>{n.d(t,{Er:()=>R,FS:()=>P,Lb:()=>S,Ox:()=>N.Ox,TK:()=>N.TK,Uo:()=>D,gv:()=>E,m2:()=>w,nk:()=>N.nk,yo:()=>z});var r=n(95155),a=n(12115),s=n(73155),l=n(67161),i=n(5937),o=n(39068),d=n(18756),c=n(85921),u=n(79397),m=n(42196),p=n(93499),x=n(35299),v=n(93141),b=n(65229),f=n(26983),h=n(57828),k=n(39856),g=n(84151),y=n(52998),j=n(4729),N=n(39418);let _=/fbcdn\.net|cdninstagram\.com|fbsbx\.com|cdn\.klipio\.io|cdn\.shopify\.com|shopifycdn\.net/i,w=(e,t)=>{let n=e||t||"";if(!n||!_.test(n))return n;let r=new URLSearchParams({u:n});return t&&t!==n&&_.test(t)&&r.set("fallback",t),"/api/img?".concat(r.toString())},C={FACEBOOK:s.A,INSTAGRAM:l.A,MESSENGER:i.A,AUDIENCE_NETWORK:o.A,THREADS:d.A},S=e=>"video"===e?c.A:"carousel"===e?u.A:m.A;function z(e){return"number"==typeof e.start_date&&e.start_date>0?new Date(1e3*e.start_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):e.start_date_formatted?String(e.start_date_formatted).split(" ")[0]:null}function E(e){var t;return{ad_archive_id:e.ad_archive_id,thumb_url:e.thumb_src,thumb_src:e.thumb_src,hook_text:e.hook,hook:e.hook,hook_type:null,creative_type:e.creative_type,longevity_days:e.longevity_days,cta:e.cta,link_url:e.link_url,landing_domain:e.landing_domain,advertiser:(null==(t=e.brand)?void 0:t.name)||void 0,thumb_r2_url:e.thumb_r2_url,video_url:e.video_url,video_r2_url:e.video_r2_url,media:e.media,title:e.title,start_date:e.start_date,start_date_formatted:e.start_date_formatted,variations:e.variations,platforms:e.platforms,cta_type:e.cta_type,brand:e.brand,is_active:e.is_active}}function A(e){return(e.media||[]).find(Boolean)}function T(e){let t=A(e);return w(e.thumb_r2_url||(null==t?void 0:t.image_r2_url)||(null==t?void 0:t.poster_r2),e.thumb_src||(null==t?void 0:t.image_url)||(null==t?void 0:t.poster))}function L(e){let t=A(e);return w(e.video_r2_url||(null==t?void 0:t.video_r2_url),e.video_url||(null==t?void 0:t.video_url))}function D(e){var t;let{ad:n,play:s,onUnavailable:l}=e,i=(0,a.useRef)(null),[o,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(!1),m=T(n),p=L(n);(0,a.useEffect)(()=>{let e=i.current;e&&(s?e.play().catch(()=>{}):e.pause())},[s]);let x=(0,r.jsxs)("div",{className:"kg-ph",children:[(0,r.jsx)("span",{className:"kg-ph-mono",children:(((null==(t=n.brand)?void 0:t.name)||n.title||"Ad").trim()[0]||"A").toUpperCase()}),(0,r.jsx)("em",{className:"kg-ph-fmt",children:(0,N.TK)(n.creative_type)})]}),v=!!p,b=!!m&&!o,f=!v&&(!m||o);return((0,a.useEffect)(()=>{f&&(null==l||l())},[f,l]),v)?s||b?(0,r.jsx)("video",{ref:i,muted:!0,loop:!0,playsInl
1ine:!0,preload:"none",poster:b?m:void 0,src:s?p:void 0,onLoadedData:e=>{s&&e.currentTarget.play().catch(()=>{})},style:{background:b?"var(--ds-hover, #eee)":"transparent"},className:"kg-media"}):x:b?(0,r.jsxs)(r.Fragment,{children:[c?null:(0,r.jsx)("span",{className:"kd-skel",style:{position:"absolute",inset:0,borderRadius:0},"aria-hidden":!0}),(0,r.jsx)("img",{ref:(0,g.E)(u),src:m,alt:"",loading:"lazy",className:"kg-media",onLoad:()=>u(!0),onError:()=>d(!0)})]}):x}function R(e){var t,n,s;let{ad:l,onOpen:i}=e,[o,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(!1),m=(0,a.useCallback)(()=>u(!0),[]),x=(0,N.TK)(l.creative_type),v=S(x),b=l.longevity_days;return c||!(T(l)||L(l))?null:(0,r.jsxs)("div",{className:"kg-tile",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[(0,r.jsxs)("div",{className:"kg-thumb",onClick:()=>i(l),role:"button",children:[(0,r.jsx)(D,{ad:l,play:o,onUnavailable:m}),(0,r.jsxs)("div",{className:"kg-tl",children:[l.isNew?(0,r.jsx)("span",{className:"kg-new",children:"NEW"}):null,(0,r.jsxs)("span",{className:"kg-fmt",children:[(0,r.jsx)(v,{size:12})," ",x]})]}),(0,r.jsx)("span",{className:"kg-save",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(k.k,{ad:E(l),advertiser:(null==(t=l.brand)?void 0:t.name)||l.title||void 0,variant:"icon"})}),(0,r.jsxs)("div",{className:"kg-thumb-foot",children:["number"==typeof b?(0,r.jsxs)("span",{className:"kg-days",title:"Days running (proxy winner signal, not spend)",children:[b,"d running"]}):null,l.is_active?(0,r.jsxs)("span",{className:"kg-live",children:[(0,r.jsx)("i",{})," Live"]}):(0,r.jsxs)("span",{className:"kg-live off",children:[(0,r.jsx)("i",{})," Inactive"]})]})]}),(0,r.jsxs)("div",{className:"kg-meta",children:[(null==(n=l.brand)?void 0:n.name)?(0,r.jsxs)("div",{className:"kg-brandtag",children:[l.brand.logo?(0,r.jsx)("img",{src:w(l.brand.logo),alt:"",loading:"lazy",onError:e=>{e.currentTarget.style.display="none"}}):null,(0,r.jsx)("span",{children:l.brand.name})]}):null,(null==(s=l.brand)?void 0:s.verifiedAt)?(0,r.jsx)(y.A,{since:l.brand.verifiedAt,className:"mb-1"}):null,l.hook?(0,r.jsx)("p",{className:"kg-hook",children:l.hook}):null,(0,r.jsxs)("div",{className:"kg-row",children:[(0,r.jsxs)("div",{className:"kg-plats",children:[(l.platforms||[]).slice(0,5).map(e=>{let t=C[e];return t?(0,r.jsx)(t,{size:13},e):null}),l.variations&&l.variations>1?(0,r.jsxs)("span",{className:"kg-vars",children:["\xd7",l.variations]}):null]}),l.cta?(0,r.jsx)("span",{className:"kg-cta",children:l.cta}):null]}),l.landing_domain?(0,r.jsxs)("a",{className:"kg-land",href:l.link_url||"#",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:[l.landing_domain," ",(0,r.jsx)(p.A,{size:11})]}):null]})]})}function I(e){let{ad:t}=e,[n,s]=(0,a.useState)("idle"),[l,i]=(0,a.useState)(null),[o,d]=(0,a.useState)(0),c=t.video_r2_url||t.video_url;return((0,a.useEffect)(()=>{if(!c)return;let e=!0;return s("loading"),i(null),fetch("/api/hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ad_archive_id:t.ad_archive_id,video_url:c})}).then(e=>{if(!e.ok)throw Error("http "+e.status);return e.json()}).then(t=>{e&&(i(t.hook_text||null),s("done"))}).catch(()=>{e&&s("error")}),()=>{e=!1}},[t.ad_archive_id,c,o]),c)?(0,r.jsxs)("div",{className:"kg-spoken",children:[(0,r.jsx)("div",{className:"kg-spoken-h",children:"Spoken hook"}),"loading"===n?(0,r.jsxs)("div",{className:"kg-spoken-load",children:[(0,r.jsx)(x.A,{size:13,className:"animate-spin"})," Transcribing the first secondsâ¦"]}):"error"===n?(0,r.jsxs)("button",{type:"button",className:"kg-spoken-none",style:{cursor:"pointer",width:"100%",textAlign:"left",display:"inline-flex",alignItems:"center",gap:6},onClick:()=>d(e=>e+1),children:[(0,r.jsx)(v.A,{size:13})," Transcription failed â tap to retry"]}):l?(0,r.jsxs)("blockquote",{className:"kg-spoken-q",children:["â",l,"â"]}):(0,r.jsx)("div",{className:"kg-spoken-none",children:"No spoken words in this ad (music or visual-only)."})]}):null}function P(e){var t,n,s;let{ad:l,onClose:i}=e;return(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&i()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i]),(0,a.useEffect)(()=>{let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[]),(0,r.jsx)("div",{className:"kg-drawer-overlay",onClick:i,children:(0,r.jsxs)("aside",{className:"kg-drawer",onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":(null==(t=l.brand)?void 0:t.name)?"Ad details for ".concat(l.brand.name):"Ad details",children:[(0,r.jsx)("button",{className:"kg-drawer-x",onClick:i,"aria-label":"Close details",title:"Close",children:(0,r.jsx)(b.A,{size:18})}),(()=>{if("carousel"===(0,N.TK)(l.creative_type)&&l.media&&l.media.length>0)return(0,r.jsx)("div",{className:"kg-drawer-media",style:{background:"transparent",padding:"16px 20px 0"},children:(0,r.jsx)(j.k,{media:l.media})});let e=w(l.video_r2_url,l.video_url),t=w(l.thumb_r2_url,l.thumb_src);return(0,r.jsx)("div",{className:"kg-drawer-media",children:e?(0,r.jsx)("video",{src:e,poster:t,controls:!0,autoPlay:!0,muted:!0,loop:!0,playsInl
1ine:!0,className:"kg-drawer-vid"}):t?(0,r.jsx)("img",{src:t,alt:"",className:"kg-drawer-vid"}):null})})(),(0,r.jsxs)("div",{className:"kg-drawer-body",children:[(null==(n=l.brand)?void 0:n.name)?(0,r.jsxs)("div",{className:"kg-brandtag",style:{marginBottom:12},children:[l.brand.logo?(0,r.jsx)("img",{src:w(l.brand.logo),alt:"",onError:e=>{e.currentTarget.style.display="none"}}):null,(0,r.jsx)("span",{children:l.brand.name})]}):null,(0,r.jsxs)("div",{className:"kg-chips",children:["number"==typeof l.longevity_days?(0,r.jsxs)("span",{className:"kg-chip",children:[(0,r.jsx)(f.A,{size:13}),(0,r.jsxs)("b",{children:[l.longevity_days,"d"]}),"\xa0running"]}):null,(0,r.jsxs)("span",{className:"kg-chip"+(l.is_active?" on":""),children:[(0,r.jsx)("span",{className:"kg-dot"}),l.is_active?"Active":"Inactive"]}),(0,r.jsxs)("span",{className:"kg-chip kg-chip-cap",children:[(()=>{let e=S((0,N.TK)(l.creative_type));return(0,r.jsx)(e,{size:13})})(),(0,N.TK)(l.creative_type)]}),l.variations&&l.variations>1?(0,r.jsxs)("span",{className:"kg-chip",children:[(0,r.jsx)(u.A,{size:13}),l.variations,"\xa0variants"]}):null,z(l)?(0,r.jsxs)("span",{className:"kg-chip",children:[(0,r.jsx)(h.A,{size:13}),z(l)]}):null]}),l.title?(0,r.jsx)("h4",{children:l.title}):null,l.hook?(0,r.jsx)("p",{className:"kg-drawer-copy",children:l.hook}):null,(0,r.jsx)(I,{ad:l}),(0,r.jsxs)("div",{className:"kg-drawer-pills",children:[(l.platforms||[]).map(e=>(0,r.jsx)("span",{className:"kg-pill",children:e.replace(/_/g," ").toLowerCase()},e)),l.cta?(0,r.jsx)("span",{className:"kg-pill kg-pill-cta",children:l.cta}):null]}),l.link_url?(0,r.jsxs)("a",{className:"kg-drawer-link",href:l.link_url,target:"_blank",rel:"noopener noreferrer",children:[l.landing_domain||"landing page"," ",(0,r.jsx)(p.A,{size:13})]}):null,(0,r.jsxs)("div",{className:"kg-drawer-save",children:[(0,r.jsx)(k.k,{ad:E(l),advertiser:(null==(s=l.brand)?void 0:s.name)||l.title||void 0,variant:"icon"})," ",(0,r.jsx)("span",{children:"Save to a board"})]})]})]})})}},39418:(e,t,n)=>{function r(e){return"video"===e||"carousel"===e?e:"image"}function a(e){return"number"==typeof e.start_date&&e.start_date>0?e.start_date:e.start_date_formatted&&Date.parse(e.start_date_formatted)/1e3||0}function s(e,t,n){if("longest"===n){let n=(t.longevity_days||0)-(e.longevity_days||0);if(0!==n)return n}else{let r=a(e),s=a(t);if(0===r!=(0===s))return 0===r?1:-1;if(r!==s)return"oldest"===n?r-s:s-r}return String(e.ad_archive_id||"").localeCompare(String(t.ad_archive_id||""))}n.d(t,{Ox:()=>a,TK:()=>r,nk:()=>s})},39856:(e,t,n)=>{n.d(t,{k:()=>y});var r=n(95155),a=n(12115),s=n(47650),l=n(52619),i=n.n(l),o=n(48754),d=n(60235),c=n(35299),u=n(71360),m=n(93141),p=n(5917),x=n(6191),v=n(7013),b=n(64269),f=n(11884),h=n(83411),k=n(21170),g=n(16443);function y(e){var t;let{ad:n,adKey:l,saved:y,boardIds:j,advertiser:N,workspaceId:_,onSavedChange:w,variant:C="icon",className:S}=e,{toast:z}=(0,g.d)(),[E,A]=(0,a.useState)(!1),[T,L]=(0,a.useState)(null),[D,R]=(0,a.useState)(!1),[I,P]=(0,a.useState)(new Set(j||[])),[O,K]=(0,a.useState)(!!y||(null!=(t=null==j?void 0:j.length)?t:0)>0),[F,M]=(0,a.useState)(null),[U,W]=(0,a.useState)(!1),[q,B]=(0,a.useState)(!1),[J,G]=(0,a.useState)(null),H=(0,a.useRef)(null),V=(0,a.useRef)(null),[X,Z]=(0,a.useState)(!1),[Q,$]=(0,a.useState)(null);async function Y(){R(!1);try{let e=await fetch("/api/boards".concat((0,h.Xy)(_))).then(e=>e.json());L(e.boards||[])}catch(e){R(!0)}}function ee(){var e;let t=null==(e=H.current)?void 0:e.getBoundingClientRect();t&&$({top:t.bottom+8,right:Math.max(8,window.innerWidth-t.right)})}function et(){let e=!E;if(A(e),e){var t,n;Z(null!=(n=null==(t=document.querySelector(".kd"))?void 0:t.classList.contains("dark"))&&n),ee(),null!==T||D||Y()}}async function en(){if(O)return!0;K(!0),null==w||w(!0,l||"");try{let e=await fetch("/api/saved",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ad:{...n,advertiser:N},workspaceId:_||void 0})});if(!e.ok)throw Error(String(e.status));return!0}catch(e){return K(!1),null==w||w(!1,l||""),G("Couldn't save â check your connection and try again."),z("Couldn't save â please try again.","error"),!1}}async function er(e){if(!F&&!I.has(e.id)){M(e.id),G(null),P(t=>new Set(t).add(e.id));try{if(!(await fetch("/api/boards/".concat(e.id,"/items"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ad:{...n,advertiser:N},workspaceId:_||void 0})})).ok)throw Error("save failed");z('Saved to "'.concat(e.name,'"'),"success"),await en()}catch(t){P(t=>{let n=new Set(t);return n.delete(e.id),n}),G("Couldn't add to \"".concat(e.name,'" â please try again.')),z("Couldn't add to \"".concat(e.name,'" â please try again.'),"error")}finally{M(null)}}}async function ea(){if(U)return;let e=I.size;if(await (0,k.ZD)({title:"Remove from Saved?",message:e>0?"This removes the ad from your Saved list. It stays in ".concat(e," board").concat(1===e?"":"s"," until you remove it there."):"This removes the ad from your Saved list.",confirmLabel:"Unsave",destructive:!0})){W(!0),G(null);try{if(!(await fetch("/api/saved",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({unsave:!0,ad_key:l,ad:n,workspaceId:_||void 0})})).ok)throw Error("unsave failed");K(!1),null==w||w(!1,l||""),A(!1),z("Removed from Saved","success")}catch(e){G("Couldn't unsave â please try again."),z("Couldn't unsave â please try again.","error")}finally{W(!1)}}}return(0,a.useEffect)(()=>P(new Set(j||[])),[j]),(0,a.useEffect)(()=>{void 0!==y&&K(y)},[y]),(0,a.useEffect)(()=>
1{if(!E)return;let e=e=>{var t,n;if(q)return;let r=e.target;(null==(t=H.current)?void 0:t.contains(r))||(null==(n=V.current)?void 0:n.contains(r))||A(!1)},t=e=>"Escape"===e.key&&!q&&A(!1),n=()=>ee();return document.addEventListener("mousedown",e),window.addEventListener("keydown",t),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("keydown",t),window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0)}},[E,q]),(0,r.jsxs)("div",{ref:H,className:(0,b.cn)("relative",S),children:["icon"===C?(0,r.jsx)("button",{type:"button","aria-label":O?"Saved â edit boards":"Save","aria-haspopup":"dialog","aria-expanded":E,onClick:e=>{e.stopPropagation(),et()},className:(0,b.cn)("grid size-8 place-items-center rounded-kd border backdrop-blur outline-none transition-colors focus-visible:ring-2 focus-visible:ring-kd-ring",O?"border-kd-accent bg-kd-accent text-kd-accent-text":"border-white/30 bg-black/45 text-white hover:bg-black/65"),children:O?(0,r.jsx)(o.A,{className:"size-4"}):(0,r.jsx)(d.A,{className:"size-4"})}):(0,r.jsxs)("button",{type:"button","aria-haspopup":"dialog","aria-expanded":E,onClick:e=>{e.stopPropagation(),et()},className:(0,b.cn)("inline-flex h-9 items-center gap-1.5 rounded-kd border px-3 text-[13px] font-semibold outline-none transition-colors focus-visible:ring-2 focus-visible:ring-kd-ring",O?"border-kd-accent bg-kd-accent text-kd-accent-text":"border-kd-border bg-kd-bg text-kd-muted hover:bg-kd-hover hover:text-kd-text"),children:[O?(0,r.jsx)(o.A,{className:"size-4"}):(0,r.jsx)(d.A,{className:"size-4"}),O?"In a board":"Add to board"]}),E&&Q?(0,s.createPortal)((0,r.jsxs)("div",{ref:V,role:"dialog","aria-label":"Save to board",onClick:e=>e.stopPropagation(),style:{top:Q.top,right:Q.right},className:(0,b.cn)(X?"kd dark":"kd","fixed z-[70] w-64 overflow-hidden rounded-kd border border-kd-border bg-kd-bg text-left shadow-[0_16px_44px_rgba(17,17,26,0.22)]"),children:[J?(0,r.jsx)("div",{role:"alert",className:"border-b border-kd-border bg-kd-destructive-soft px-3 py-2 text-[12px] font-medium text-kd-destructive",children:J}):null,(0,r.jsxs)("button",{type:"button",onClick:ea,disabled:!O||U,className:(0,b.cn)("flex w-full items-center gap-2 border-b border-kd-border px-3 py-2.5 text-[13px] font-semibold outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-kd-ring",O?"text-kd-destructive hover:bg-kd-destructive-soft":"cursor-not-allowed text-kd-subtle"),children:[U?(0,r.jsx)(c.A,{className:"size-4 animate-spin"}):(0,r.jsx)(u.A,{className:"size-4"}),"Unsave"]}),(0,r.jsx)("div",{className:"px-3 pb-1 pt-2 text-[11px] font-bold uppercase tracking-wide text-kd-subtle",children:"Add to board"}),(0,r.jsx)("div",{className:"max-h-56 overflow-y-auto px-1.5 pb-1.5",children:D?(0,r.jsxs)("div",{className:"px-2 py-3 text-[13px] text-kd-muted",children:["Couldn't load boards."," ",(0,r.jsxs)("button",{type:"button",onClick:Y,className:"inline-flex items-center gap-1 font-semibold text-kd-accent outline-none hover:underline focus-visible:ring-2 focus-visible:ring-kd-ring",children:[(0,r.jsx)(m.A,{className:"size-3.5"})," Retry"]})]}):null===T?(0,r.jsx)("div",{className:"space-y-1 px-1 py-1.5","aria-hidden":!0,children:Array.from({length:3}).map((e,t)=>(0,r.jsx)("div",{className:"h-8 kd-skel rounded-[6px] bg-kd-hover"},t))}):0===T.length?(0,r.jsx)("div",{className:"px-2 py-3 text-[13px] text-kd-muted",children:"No boards yet â create one below."}):T.map(e=>{let t=I.has(e.id),n=_?"/boards/".concat(e.id,"?ws=").concat(encodeURIComponent(_)):"/boards/".concat(e.id);return(0,r.jsxs)("div",{className:"flex items-center gap-0.5",children:[F===e.id?(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center justify-between gap-2 rounded-[6px] px-2 py-2 text-[13px] text-kd-muted",children:[(0,r.jsx)("span",{className:"truncate",children:e.name}),(0,r.jsx)(c.A,{className:"size-4 shrink-0 animate-spin text-kd-subtle"})]}):t?(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center justify-between gap-2 rounded-[6px] px-2 py-2 text-[13px] text-kd-text",title:"Open the board to remove this ad",children:[(0,r.jsx)("span",{className:"truncate",children:e.name}),(0,r.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 text-[11px] font-semibold text-kd-accent",children:[(0,r.jsx)(p.A,{className:"size-3.5"})," In board"]})]}):(0,r.jsxs)("button",{type:"button",onClick:()=>er(e),disabled:!!F,className:(0,b.cn)("flex min-w-0 flex-1 items-center justify-between gap-2 rounded-[6px] px-2 py-2 text-[13px] text-kd-muted outline-none transition-colors hover:bg-kd-hover hover:text-kd-text focus-visible:ring-2 focus-visible:ring-kd-ring disabled:opacity-60"),children:[(0,r.jsx)("span",{className:"truncate",children:e.name}),(0,r.jsx)(x.A,{className:"size-4 shrink-0 text-kd-subtle"})]}),(0,r.jsx)(i(),{href:n,onClick:e=>e.stopPropagation(),"aria-label":"Open board â".concat(e.name,"â"),title:"Open board",className:"grid size-7 shrink-0 place-items-center rounded-[6px] text-kd-subtle outline-none transition-colors hover:bg-kd-hover hover:text-kd-text focus-visible:ring-2 focus-visible:ring-kd-ring",children:(0,r.jsx)(v.A,{className:"size-3.5"})})]},e.id)})}),(0,r.jsxs)("button",{type:"button",onClick:()=>B(!0),className:"flex w-full items-center gap-2 border-t border-kd-border px-3 py-2.5 text-[13px] font-semibold text-kd-accent outline-none transition-colors hover:bg-kd-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-kd-ring",children:[(0,r.jsx)(x.A,{className:"size-4"})," Create board"]})]}),document.body):null,(0,r.jsx)(f.C,{open:q,onClose:()=>B(!1),onCreated:function(e){L(t=>[e,...t||[]]),er(e)},workspaceId:_})]})}}
1,52998:(e,t,n)=>{n.d(t,{A:()=>i});var r=n(95155),a=n(76907),s=n(26983);function l(e){if(null==e||""===e)return"never";let t="number"==typeof e?e:Date.parse(e);if(!Number.isFinite(t))return"never";let n=Math.max(0,(Date.now()-t)/1e3);if(n<45)return"just now";if(n<3600)return Math.floor(n/60)+"m ago";if(n<86400)return Math.floor(n/3600)+"h ago";let r=Math.floor(n/86400);return r<7?r+"d ago":r<35?Math.floor(r/7)+"w ago":r<365?Math.floor(r/30)+"mo ago":Math.floor(r/365)+"y ago"}function i(e){let{since:t,className:n=""}=e,i=function(e){if(null==e||""===e)return"never";let t="number"==typeof e?e:Date.parse(e);if(!Number.isFinite(t))return"never";let n=(Date.now()-t)/36e5;return n<24?"fresh":n<168?"recent":"stale"}(t);if("never"===i)return null;let{cls:o,Icon:d,label:c}={fresh:{cls:"text-ds-accent bg-ds-accent-soft",Icon:a.A,label:"Verified live \xb7 "+l(t)},recent:{cls:"text-ds-muted bg-ds-hover",Icon:a.A,label:"Checked "+l(t)},stale:{cls:"text-ds-subtle bg-ds-hover",Icon:s.A,label:"Checked "+l(t)}}[i];return(0,r.jsxs)("span",{suppressHydrationWarning:!0,className:"inline-flex items-center gap-1 text-[11px] font-semibold px-1.5 py-0.5 rounded-full whitespace-nowrap ".concat(o," ").concat(n),title:"When Klipio last re-checked this advertiser's live ads",children:[(0,r.jsx)(d,{size:11})," ",c]})}},64269:(e,t,n)=>{n.d(t,{cn:()=>s});var r=n(2821),a=n(75889);function s(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,a.QP)((0,r.$)(t))}},83411:(e,t,n)=>{n.d(t,{Xy:()=>r});function r(e){return e?"?workspaceId=".concat(encodeURIComponent(e)):""}},84151:(e,t,n)=>{n.d(t,{E:()=>r});function r(e){return t=>{t&&t.complete&&t.naturalWidth>0&&e(!0)}}}}]);
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.