PageSourceSearch

https://app.adcero.io/_next/static/chunks/54919.e313a499d5356824.js?dpl=dpl_A3WZAd9iA7JUzYF5tt6ZKzZ5AhxD

js adcero.io collected 2026-09-24 15:04:02 UTC 67,522 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[54919],{31856:(e,t,n)=>{n.d(t,{CG:()=>c,Fm:()=>h,Qs:()=>x,XW:()=>g,cj:()=>o,h:()=>f,qp:()=>p});var r=n(95155);n(12115);var a=n(89511),s=n(65229),l=n(83101),i=n(25016);function o(e){let{...t}=e;return(0,r.jsx)(a.bL,{"data-slot":"sheet",...t})}function c(e){let{...t}=e;return(0,r.jsx)(a.l9,{"data-slot":"sheet-trigger",...t})}function u(e){let{...t}=e;return(0,r.jsx)(a.ZL,{"data-slot":"sheet-portal",...t})}function d(e){let{className:t,...n}=e;return(0,r.jsx)(a.hJ,{"data-slot":"sheet-overlay",className:(0,i.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...n})}let m=(0,l.F)("bg-background fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-xl"}},defaultVariants:{side:"right"}});function f(e){let{side:t="right",className:n,children:l,...o}=e;return(0,r.jsxs)(u,{children:[(0,r.jsx)(d,{}),(0,r.jsxs)(a.UC,{"data-slot":"sheet-content",className:(0,i.cn)(m({side:t}),n),...o,children:[(0,r.jsxs)(a.bm,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute right-4 top-4 roun
1ded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,r.jsx)(s.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]}),l]})]})}function h(e){let{className:t,...n}=e;return(0,r.jsx)("div",{"data-slot":"sheet-header",className:(0,i.cn)("flex flex-col gap-2 p-6 pb-0",t),...n})}function g(e){let{className:t,...n}=e;return(0,r.jsx)("div",{"data-slot":"sheet-footer",className:(0,i.cn)("mt-auto flex flex-col-reverse gap-2 p-6 pt-0 sm:flex-row sm:justify-end",t),...n})}function p(e){let{className:t,...n}=e;return(0,r.jsx)(a.hE,{"data-slot":"sheet-title",className:(0,i.cn)("text-foreground text-lg font-semibold",t),...n})}function x(e){let{className:t,...n}=e;return(0,r.jsx)(a.VY,{"data-slot":"sheet-description",className:(0,i.cn)("text-muted-foreground text-sm",t),...n})}},32118:(e,t,n)=>{n.d(t,{Ww:()=>i});var r=n(42291),a=n(37138),s=n(95704);function l(e){return e?e.split(",").map(e=>e.trim()).filter(e=>e.length>0):[]}function i(e){var t;let{organizationId:n,organizationName:i}=e;return!!(n&&new Set([r.Oh,a.ED,...l(s.env.CREATIVE_QA_ORG_IDS),...l(s.env.NEXT_PUBLIC_CREATIVE_QA_ORG_IDS)]).has(n))||"production"!==((t="production",void 0!==t)?t:s.env.VERCEL_ENV)&&!!i&&"nimbus"===i.trim().toLowerCase()}},52099:(e,t,n)=>{n.d(t,{Lh:()=>m,Ml:()=>c,Vz:()=>o,bR:()=>u,ur:()=>d});let r=null,a=!1,s=!0;function l(){return r||(r=n.e(8229).then(n.bind(n,26614)).then(e=>{var t;return null!=(t=e.default)?t:e}).catch(()=>null)),r}function i(e){try{var t,n,r,a;s?(null==(t=e.opt_in_capturing)||t.call(e),null==(n=e.startSessionRecording)||n.call(e)):(null==(r=e.stopSessionRecording)||r.call(e),null==(a=e.opt_out_capturing)||a.call(e))}catch(e){}}function o(){let e="phc_pWPmFKrvRjMdKtUaMmsRGGa5ZxqD4YHaVSwTSVZWxMEj";e&&l().then(t=>{if(t)try{a||(t.init(e,{api_host:"https://us.i.posthog.com",person_profiles:"identified_only",autocapture:!0,capture_pageview:!0,session_recording:{maskAllInputs:!0,maskTextSelector:"[data-ph-mask], [data-ph-mask] *"}}),a=!0),i(t)}catch(e){}})}function c(e){s=e,a&&l().then(e=>{e&&i(e)})}function u(e){let{id:t,organization_id:n}=e;t&&l().then(e=>{if(e&&a)try{if(e.identify(t,n?{organization_id:n}:void 0),n){var r;null==(r=e.group)||r.call(e,"organization",n)}}catch(e){}})}function d(){a&&l().then(e=>{if(e)try{e.reset()}catch(e){}})}function m(e,t){l().then(n=>{if(n&&a)try{n.capture(e,t)}catch(e){}})}},52120:(e,t,n)=>{n.d(t,{C_:()=>k,Dl:()=>h,ZZ:()=>x,aU:()=>b,ax:()=>f,d:()=>C,jd:()=>g,mg:()=>S,xS:()=>w,xl:()=>N,xw:()=>v});var r=n(47691),a=n(9941),s=n(39089),l=n(63146),i=n(90231),o=n(79894),c=n(73181),u=n(50788),d=n(19056);function m(e){if(!e)return(0,r.o)(new Date);try{var t,n,a,s,l,i;let r=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date),o=parseInt(null!=(s=null==(t=r.find(e=>"year"===e.type))?void 0:t.value)?s:"0",10),c=parseInt(null!=(l=null==(n=r.find(e=>"month"===e.type))?void 0:n.value)?l:"0",10)-1,u=parseInt(null!=(i=null==(a=r.find(e=>"day"===e.type))?void 0:a.value)?i:"0",10);return new Date(o,c,u)}catch(e){return(0,r.o)(new Date)}}let f=[{id:"today",label:"Today",getValue:e=>{let t=m(e);return{from:t,to:t}}},{id:"yesterday",label:"Yesterday",getValue:e=>{let t=m(e),n=(0,a.e)(t,1);return{from:n,to:n}}},{id:"last_7_days",label:"Last 7 days",getValue:e=>{let t=m(e);return{from:(0,a.e)(t,6),to:t}}},{id:"last_30_days",label:"Last 30 days",getValue:e=>{let t=m(e);return{from:(0,a.e)(t,29),to:t}}},{id:"this_week",label:"This week",getValue:e=>{let t=m(e);return{from:(0,s.k)(t),to:(0,l.$)(t)}}},{id:"last_week",label:"Last week",getValue:e=>{let t=m(e),n=(0,a.e)(t,7);return{from:(0,s.k)(n),to:(0,l.$)(n)}}},{id:"this_month",label:"This month",getValue:e=>{let t=m(e);return{from:(0,i.w)(t),to:(0,o.p)(t)}}},{id:"last_month",label:"Last month",getValue:e=>{let t=m(e),n=(0,c.a)(t,1);return{from:(0,i.w)(n),to:(0,o.p)(n)}}},{id:"maximum",label:"Maximum",getValue:e=>{let t=m(e);return{from:(0,u.d)(t,5),to:t}}}],h="last_30_days";function g(e){let t=m(e);return{from:(0,a.e)(t,29),to:t}}let p=/^last_(\d+)_days$/;function x(e){return"last_".concat(e,"_days")}function v(e,t){if(!e)return null;let n=f.find(t=>
1t.id===e);if(n)return n.getValue(t);let r=p.exec(e);if(r){let e=Number(r[1]);if(!Number.isInteger(e)||e<1)return null;let n=m(t);return{from:(0,a.e)(n,e-1),to:n}}return null}let b="206fe1d0-bd57-43c4-9d64-46846bfa6c20",j={[b]:{from:"2026-05-15",to:"2026-08-13"}};function y(e){return(0,r.o)((0,d.H)(e+"T00:00:00"))}function w(e){if(!e)return null;let t=j[e];return t?{from:y(t.from),to:y(t.to)}:null}let N="adcero_global_date_range";function k(e){return"".concat(N,":").concat(e)}let C="preference",S="date_range"},54919:(e,t,n)=>{n.r(t),n.d(t,{AuthenticatedAppShell:()=>tC});var r=n(95155),a=n(12115),s=n(20063),l=n(59427),i=n(37494),o=n(36369),c=n(26550),u=n(9540),d=n(52619),m=n.n(d),f=n(97003),h=n(31856),g=n(54679),p=n(82180),x=n(82734),v=n(65283),b=n(83875),j=n(65555),y=n(50088),w=n(25016),N=n(5917),k=n(27937),C=n(18953);let S={meta:function(e){let{className:t}=e;return(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M6.915 4.03c-1.968 0-3.683 1.28-4.871 3.113C.704 9.208 0 11.883 0 14.449c0 .706.07 1.369.21 1.973a6.624 6.624 0 0 0 .265.86 5.297 5.297 0 0 0 .371.761c.696 1.159 1.818 1.927 3.593 1.927 1.497 0 2.633-.671 3.965-2.444.76-1.012 1.144-1.626 2.663-4.32l.756-1.339.186-.325c.061.1.121.196.183.3l2.152 3.595c.724 1.21 1.665 2.556 2.47 3.314 1.046.987 1.992 1.22 3.06 1.22 1.075 0 1.876-.355 2.455-.843a3.743 3.743 0 0 0 .81-.973c.542-.939.861-2.127.861-3.745 0-2.72-.681-5.357-2.084-7.45-1.282-1.912-2.957-2.93-4.716-2.93-1.047 0-2.088.467-3.053 1.308-.652.57-1.257 1.29-1.82 2.05-.69-.875-1.335-1.547-1.958-2.056-1.182-.966-2.315-1.303-3.454-1.303zm10.16 2.053c1.147 0 2.188.758 2.992 1.999 1.132 1.748 1.647 4.195 1.647 6.4 0 1.548-.368 2.9-1.839 2.9-.58 0-1.027-.23-1.664-1.004-.496-.601-1.343-1.878-2.832-4.358l-.617-1.028a44.908 44.908 0 0 0-1.255-1.98c.07-.109.141-.224.211-.327 1.12-1.667 2.118-2.602 3.358-2.602zm-10.201.553c1.265 0 2.058.791 2.675 1.446.307.327.737.871 1.234 1.579l-1.02 1.566c-.757 1.163-1.882 3.017-2.837 4.338-1.191 1.649-1.81 1.817-2.486 1.817-.524 0-1.038-.237-1.383-.794-.263-.426-.464-1.13-.464-2.046 0-2.221.63-4.535 1.66-6.088.454-.687.964-1.226 1.533-1.533a2.264 2.264 0 0 1 1.088-.285z"})})},tiktok:function(e){let{className:t}=e;return(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M19.59 6.69a4.83 4.83 0 0 1-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 0 1-5.2 1.74 2.89 2.89 0 0 1 2.31-4.64 2.93 2.93 0 0 1 .88.13V9.4a6.84 6.84 0 0 0-1-.05A6.33 6.33 0 0 0 5 20.1a6.34 6.34 0 0 0 10.86-4.43v-7a8.16 8.16 0 0 0 4.77 1.52v-3.4a4.85 4.85 0 0 1-1-.1z"})})},google:function(e){let{className:t}=e;return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),(0,r.jsx)("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),(0,r.jsx)("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),(0,r.jsx)("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]})},twitter:C.uv,linkedin:C.ky};function A(e){var t;let{isCollapsed:n=!1,className:s}=e,[l,i]=(0,a.useState)(!1),{currentOrganization:o,selectedPlatform:c,setSelectedPlatform:u,organizationAccounts:d,isLoadingPlatformPreference:m}=(0,x.Z5)(),f=(0,a.useMemo)(()=>(0,b.IW)({organizationId:null==o?void 0:o.id,organizationName:null==o?void 0:o.name}),[null==o?void 0:o.id,null==o?void 0:o.name]),h=(0,a.useMemo)(()=>{let e={meta:0,google:0,tiktok:0,twitter:0,linkedin:0};for(let t of d){let n=(0,y.FL)(t.platform);n&&(e[n]+=1)}return{counts:e,availablePlatforms:(0,b.US)(d)}},[d]),C=(0,a.useCallback)(e=>(u(e),i(!1),!0),[!0,!0,u]);if((0,a.useEffect)(()=>(0,v.q0)({getPlatform:()=>c,openPicker:()=>i(!0),closePicker:()=>i(!1),selectPlatform:e=>!!f.includes(e)&&C(e)}),[C,c,f]),m)return n?(0,r.jsx)("div",{className:(0,w.cn)("px-2 py-2 flex justify-center",s
1),children:(0,r.jsx)("div",{className:"w-4 h-4 rounded-full bg-muted animate-pulse"})}):(0,r.jsx)("div",{className:(0,w.cn)("px-2",s),children:(0,r.jsxs)("div",{className:"w-full flex items-center gap-3 px-2 py-1.5 animate-pulse",children:[(0,r.jsx)("div",{className:"w-3.5 h-3.5 2xl:w-4 2xl:h-4 rounded-full bg-muted"}),(0,r.jsx)("div",{className:"h-4 w-20 bg-muted rounded"})]})});let A=c?S[c]:null,_=c?j.Y_[c]:null,E=(0,r.jsx)(g.lG,{open:l,onOpenChange:i,children:(0,r.jsxs)(g.Cf,{className:"sm:max-w-sm",children:[(0,r.jsx)(g.c7,{children:(0,r.jsx)(g.L3,{children:"Select Platform"})}),(0,r.jsx)("div",{className:"grid gap-2 py-4",children:f.map(e=>{let t=S[e],n=j.Y_[e],a=c===e,s=h.availablePlatforms.includes(e),l=h.counts[e],i="tiktok"===e&&!1;return(0,r.jsxs)("button",{"data-cursor-target":"platform-option-".concat(e),onClick:()=>C(e),disabled:i,className:(0,w.cn)("flex items-center gap-3 w-full px-4 py-3 rounded-lg border transition-all text-left",i?"border-border bg-muted/30 cursor-not-allowed opacity-60":a?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-muted/50"),children:[(0,r.jsx)("div",{className:(0,w.cn)("p-2 rounded-md shrink-0 flex items-center justify-center",i?"bg-muted-foreground/30":n.bgColor),children:(0,r.jsx)(t,{className:(0,w.cn)("h-5 w-5",i?"text-muted-foreground":"text-white")})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("p",{className:"font-semibold text-sm truncate flex items-center gap-2",children:[n.shortName,i&&(0,r.jsx)("span",{className:"text-[10px] font-normal text-muted-foreground bg-muted px-1.5 py-0.5 rounded leading-none",children:"Coming Soon"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:i?"google"===e?"Google Ads integration coming soon":"tiktok"===e?"TikTok integration coming soon":"Coming soon":s?"".concat(l," account").concat(1!==l?"s":""," connected"):"No accounts connected"})]}),a&&!i&&(0,r.jsx)(N.A,{className:"h-4 w-4 text-foreground ml-2"})]},e)})})]})});return n?(0,r.jsxs)(p.Bc,{children:[(0,r.jsx)("div",{className:(0,w.cn)("px-2 py-2 flex justify-center",s),children:(0,r.jsxs)(p.m_,{children:[(0,r.jsx)(p.k$,{asChild:!0,children:(0,r.jsx)("button",{"data-cursor-target":"platform-selector","aria-label":_?"Platform: ".concat(_.shortName):"Select platform",onClick:()=>i(!0),className:"hover:bg-brand-secondary/10 transition-opacity flex items-center justify-center",children:A&&_?(0,r.jsx)("div",{className:(0,w.cn)("p-1.5 rounded-md flex items-center justify-center",_.bgColor),children:(0,r.jsx)(A,{className:"h-4 w-4 text-white"})}):(0,r.jsx)("div",{className:"p-1.5 rounded-md flex items-center justify-center bg-muted text-muted-foreground",children:(0,r.jsx)(k.A,{className:"h-4 w-4"})})})}),(0,r.jsx)(p.ZI,{side:"right",children:(0,r.jsx)("p",{children:_?"Platform: ".concat(_.shortName):"Select platform"})})]})}),E]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:(0,w.cn)("px-2",s),children:(0,r.jsxs)("button",{"data-cursor-target":"platform-selector","aria-label":_?void 0:"Select platform",onClick:()=>i(!0),className:"w-full flex items-center gap-3 px-2 py-1.5 hover:bg-brand-secondary/10 group transition-all text-left cursor-pointer rounded-md",children:[A&&_&&(0,r.jsx)("div",{className:(0,w.cn)("p-1 rounded-md flex-shrink-0 flex items-center justify-center",_.bgColor),children:(0,r.jsx)(A,{className:"h-3 w-3 2xl:h-3.5 2xl:w-3.5 text-white"})}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)("p",{className:"text-sm 2xl:text-base font-semibold tracking-tight truncate text-foreground/70 group-hover:text-foreground transition-colors",children:null!=(t=null==_?void 0:_.shortName)?t:"Select platform"})}),(0,r.jsx)(k.A,{className:"h-3.5 w-3.5 text-muted-foreground/70 group-hover:text-foreground transition-colors shrink-0"})]})}),E]})}var _=n(80073),E=n(99914);let z="dark",R="dark",I="theme_preferences",P="user_preferences",T=(0,a.createContext)(void 0);function O(e){var t;let{children:n,session:s}=e,{theme:l,setTheme:i,isLoading:o,error:c}=function(e){let{user:t,accessToken:n}=e,[r,s]=(0,a.useState)(()=>(null==t?void 0:t.id)?z:R),[l,i]=(0,a.useState)(!0),[o,c]=(0,a.useState)(null),u=(0,a.useCallback)(async()=>
1{if(!(null==t?void 0:t.id)||!n){s(R),i(!1);return}c(null),i(!0);try{var e;let{data:t,error:r}=await (0,_.T3)({settingType:P,settingKey:I,accessToken:n});if(r){c(r),s(z);return}let a=Array.isArray(t)?t[0]:t,l=null==a?void 0:a.setting_value;s(null!=(e=null==l?void 0:l.theme)?e:z)}catch(e){c(e instanceof Error?e.message:"Failed to load theme settings"),s(z)}finally{i(!1)}},[null==t?void 0:t.id,n]),d=(0,a.useCallback)(async e=>{if(!(null==t?void 0:t.id))return!1;c(null);try{let t=await (0,E.getAuthHeaders)(),n=await fetch("/api/user-settings",{method:"POST",headers:t,body:JSON.stringify({settingType:P,settingKey:I,settingValue:{theme:e}})});if(!n.ok){let e=await n.json();throw Error(e.reason||e.error||"Failed to save theme settings")}return s(e),!0}catch(e){return console.error("Error saving theme settings:",e),c(e instanceof Error?e.message:"Failed to save theme settings"),!1}},[null==t?void 0:t.id]),m=(0,a.useCallback)(async e=>{s(e);let t=await d(e);return t||await u(),t},[d,u]);return(0,a.useEffect)(()=>{u()},[u]),{theme:r,setTheme:m,isLoading:l,error:o,loadThemeSettings:u}}({user:null!=(t=null==s?void 0:s.user)?t:null,accessToken:null==s?void 0:s.access_token}),u=()=>window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":"dark",[d,m]=(0,a.useState)(()=>"system"===l?u():l);return(0,a.useEffect)(()=>{if(!o)try{window.localStorage.setItem("adcero-theme",l)}catch(e){}},[l,o]),(0,a.useEffect)(()=>{let e=()=>{"system"===l?m(u()):m(l)};if(e(),window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{"system"===l&&e()};return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}},[l]),(0,a.useEffect)(()=>{if(!o&&"undefined"!=typeof document){let e=document.documentElement;e.classList.remove("light","dark"),e.classList.add(d),e.setAttribute("data-theme",d)}},[d,o]),(0,r.jsx)(T.Provider,{value:{theme:l,resolvedTheme:d,setTheme:i,isLoading:o,error:c},children:n})}var L=n(65993),F=n(79397),M=n(11696),D=n(25664),V=n(40878),U=n(20032),q=n(21786),B=n(86651),W=n(80598),J=n(76489),Z=n(5937),$=n(95740),H=n(18154),G=n(85998),K=n(17666),Y=n(46927),Q=n(15870),X=n(37138),ee=n(32118);let et=[{href:"/dashboard",label:"Dashboard",icon:L.A},{href:"/ads-manager",label:"Ads Manager",icon:F.A},{href:"/attribution",label:"Attribution",icon:M.A},{href:"/analytics",label:"Analytics",icon:D.A},{href:"/report-builder",label:"Report Builder",icon:V.A},{href:"/assets",label:"Assets",icon:U.A},{href:"/bulk-uploader",label:"Bulk Uploader",icon:q.A,hiddenPlatforms:["google"]},{href:"/keyword-research",label:"Keyword Research",icon:B.A,visiblePlatforms:["google"]},{href:"/optimize",label:"Optimize",icon:W.A,visiblePlatforms:["google","meta"]},{href:"/brand-identity",label:"Brand Identity",icon:J.A},{href:"/ask-adcero",label:"Ask Adcero",icon:Z.A},{href:"/creative-studio",label:"Creative Studio",icon:$.A,isVisible:e=>{let{organizationId:t,organizationName:n}=e;return(0,X.ic)({organizationId:t,organizationName:n})}},{href:"/internal/creative-qa",label:"Creative QA",icon:H.A,isVisible:e=>{let{organizationId:t,organizationName:n}=e;return(0,ee.Ww)({organizationId:t,organizationName:n})}}],en=[{href:"/pulse",label:"Pulse",icon:G.A},{href:"#",label:"Request Feature",icon:K.A,action:"request-feature"},{href:"#",label:"Report Bug",icon:Y.A,action:"report-bug"},{href:"/settings",label:"Settings",icon:Q.A}];function er(e,t){var n;return(null==(n=e.hiddenPlatforms)||!n.includes(t||""))&&(!e.visiblePlatforms||!!e.visiblePlatforms.includes(t||""))}function ea(e){let{label:t,isCollapsed:n}=e;return n?null:(0,r.jsx)("div",{className:"px-4 py-2 mt-2 first:mt-0",children:(0,r.jsx)("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:t})})}var es=n(6191),el=n(24033),ei=n(7220),eo=n(46276),ec=n(35885),eu=n(42600),ed=n(57285);let em=e=>[...e].sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"}));function ef(e){let{isCollapsed:t}=e,n=(0,s.useRouter)(),{toast:l}=(0,eo.dj)(),{currentOrganization:i,userOrganizations:o,switchOrganization:c,createOrganization:u,isLoading:d,isSwitchingOrganization:m}=(0,x.Z5)(),{getLogoUrl:f,handleLogoError:h}=(0,eu.z)(o),[g,p]=(0,a.useState)(!1),[v,b]=(0,a.useState)(""),[j,y]=(0,a.useState)(""),[k,C]=(0,a.useState)(!1),[S,A]=(0,a.useState)("merchant"),_=(0,a.useCallback)(async e=>{m||await c(e)},[m,c]),E=(0,a.useMemo)(()=>(null==i?void 0:i.id)||"",[null==i?void 0:i.id]),z=(0,a.useMemo)(()=>{let e=em(o.filter(e=>"agency"===e.type)),t=em(o.filter(e=>"agency"!==e.type&&!e.parent_organization_id)),n=o.filter(e=>"agency"!==e.type&&!!e.parent_organization_id),r=[];for(let t of e)for(let e of(r.push({org:t,isChild:!1,isAgency:!0}),em(n.filter(e=>e.parent_organization_id===t.id))))r.push({org:e,isChild:!0,isAgency:!1});for(let e of t)r.push({org:e,isChild:!1,isAgency:!1});return r},[o]),R=(0,a.useCallback)(async()=>
1{if(v.trim()&&j.trim()&&u){C(!0);try{let e=await u({name:v,website_url:j,type:S});l({title:"Success",description:'Organization "'.concat(v,'" created successfully')}),b(""),y(""),A("merchant"),p(!1),n.push((null==e?void 0:e.type)!=="agency"||e.parent_organization_id?"/settings#organization":"/settings?expand=merchants#organization")}catch(e){l({title:"Error",description:e instanceof Error?e.message:"Failed to create organization",variant:"destructive"})}finally{C(!1)}}},[v,j,S,u,l,n]);return t?i?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"px-2 py-2 flex justify-center",children:(0,r.jsxs)(ei.rI,{children:[(0,r.jsx)(ei.ty,{asChild:!0,children:(0,r.jsx)("button",{className:"hover:bg-brand-secondary/10 transition-opacity flex items-center justify-center",children:(0,r.jsx)(ed.O,{name:i.name,logoUrl:f(i.id),size:"sm",onError:()=>h(i.id)})})}),(0,r.jsxs)(ei.SQ,{side:"right",align:"start",className:"w-56",children:[z.map(e=>{let{org:t,isChild:n,isAgency:a}=e;return(0,r.jsx)(ei._2,{onClick:()=>_(t.id),disabled:m,className:(0,w.cn)("cursor-pointer",n&&"pl-6"),children:(0,r.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[(0,r.jsx)(ed.O,{name:t.name,logoUrl:f(t.id),size:"sm",onError:()=>h(t.id)}),(0,r.jsx)("span",{className:"flex-1 truncate",children:t.name}),a&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:"Agency"}),t.id===E&&(0,r.jsx)(N.A,{className:"h-4 w-4 text-primary shrink-0"})]})},t.id)}),(0,r.jsx)(ei.mB,{}),(0,r.jsx)(ei._2,{onClick:()=>p(!0),disabled:m,className:"cursor-pointer",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 w-full text-primary",children:[(0,r.jsx)(es.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{children:"Create Organization"})]})})]})]})}),(0,r.jsx)(ec.S,{open:g,onOpenChange:p,orgName:v,onOrgNameChange:b,orgWebsiteUrl:j,onOrgWebsiteUrlChange:y,orgType:S,onOrgTypeChange:A,onCreate:R,isCreating:k})]}):null:d&&0===o.length?(0,r.jsx)("div",{className:"px-2 2xl:px-3 py-2 2xl:py-3 border-b",children:(0,r.jsx)("div",{className:"h-8 2xl:h-10 bg-muted animate-pulse rounded-md"})}):i?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"px-2",children:(0,r.jsxs)(ei.rI,{children:[(0,r.jsx)(ei.ty,{asChild:!0,children:(0,r.jsxs)("button",{className:"w-full flex items-center gap-2 px-2 py-1.5 hover:bg-brand-secondary/10 group transition-colors text-left cursor-pointer rounded-md",children:[(0,r.jsx)(ed.O,{name:i.name,logoUrl:f(i.id),size:"sm",onError:()=>h(i.id)}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)("p",{className:"text-sm 2xl:text-base font-semibold tracking-tight truncate text-foreground/70 hover:text-black dark:hover:text-white transition-colors",children:i.name})}),(0,r.jsx)(el.A,{className:"h-4 w-4 text-muted-foreground/70 group-hover:text-black dark:hover:text-white transition-colors shrink-0"})]})}),(0,r.jsxs)(ei.SQ,{align:"start",className:"w-56",children:[z.map(e=>{let{org:t,isChild:n,isAgency:a}=e;return(0,r.jsx)(ei._2,{onClick:()=>_(t.id),disabled:m,className:(0,w.cn)("cursor-pointer",n&&"pl-6"),children:(0,r.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[(0,r.jsx)(ed.O,{name:t.name,logoUrl:f(t.id),size:"sm",onError:()=>h(t.id)}),(0,r.jsx)("span",{className:"flex-1 truncate",children:t.name}),a&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:"Agency"}),t.id===E&&(0,r.jsx)(N.A,{className:"h-4 w-4 text-primary shrink-0"})]})},t.id)}),(0,r.jsx)(ei.mB,{}),(0,r.jsx)(ei._2,{onClick:()=>p(!0),disabled:m,className:"cursor-pointer",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 w-full text-primary",children:[(0,r.jsx)(es.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{children:"Create Organization"})]})})]})]})}),(0,r.jsx)(ec.S,{open:g,onOpenChange:p,orgName:v,onOrgNameChange:b,orgWebsiteUrl:j,onOrgWebsiteUrlChange:y,orgType:S,onOrgTypeChange:A,onCreate:R,isCreating:k})]}):null}function eh(e){let{item:t,isActive:n,isCollapsed:a,onClick:s,size:l="default",onMouseEnter:i,onFocus:o}=e,c=t.icon,u=(0,r.jsxs)("div",{className:"flex items-center ".concat("mobile"===l?"gap-3":"gap-2"),children:[(0,r.jsx)(c,{className:(0,w.cn)("".concat("mobile"===l?"size-5":"size-4"," flex-shrink-0 transition-colors"),n?"text-white group-hover:text-white":"text-muted-foreground group-hover:text-fuchsia-700")}),!a&&(0,r.jsx)("span",{className:"text-sm font-medium tracking-tight",children:t.label})]}),d=(0,w.cn)("w-full ".concat("mobile"===l?"h-10":"h-8"," px-2 justify-start rounded-md transition-all duration-200"),n?"border border-white/20 bg-gradient-to-r from-brand-primary/85 via-brand-secondary/85 to-brand-primary/85 bg-[size:200%_auto] bg-[position:0%_50%] text-white shadow-sm shadow-brand-primary/25 hover:bg-[position:100%_50%] hover:from-brand-primary hover:via-brand-secondary hover:to-brand-primary hover:text-white":"text-muted-foreground hover:text-fuchsia-700 hover:bg-brand-secondary/10",a&&"justify-center px-0");return t.action?(0,r.jsx)("div",{className:"relative group px-2 cursor-pointer",onClick:s,children:(0,r.jsx)(f.$,{asChild:!0,variant:"ghost",className:d,children:u})}):(0,r.jsx)(m(),{href:t.href,className:"relative group px-2",onClick:s,onMouseEnter:i,onFocus:o,children:(0,r.jsx)(f.$,{asChild:!0,variant:"ghost",className:d,"aria-current":n?"page":void 0,children:u})})}function eg(e){let{isCollapsed:t,onClick:n}=e;return(0,r.jsx)("div",{className:(0,w.cn)("flex h-12 items-center mb-4 px-4",t&&"px-0 justify-center mb-4"),children:(0,r.jsx)(m(),{href:"/dashboard",className:(0,w.cn)("flex items-center",t&&"justify-center"),onClick:n,children:t?(0,r.jsx)("div",{className:"w-[28px] h-[28px]",children:(0,r.jsx)("img",{src:"/images/adcero-icon-v2.svg",alt:"Adcero Logo",width:28,height:28,style:{objectFit:"contain",maxWidth:"100%",height:"auto"}})}):(0,r.jsx)("div",{className:"w-[120px]",children:(0,r.jsx)("img",{src:"/images/adcero-logo-v2.svg",alt:"Adcero Logo",width:120,height:30,style:{objectFit:"contain",maxWidth:"100%",height:"auto"}})})})})}var ep=n(35299),ex=n(65820),ev=n(33789),eb=n(67001),ej=n(90235),ey=n(29293),ew=n(8525),eN=n(30613);async function ek(e){let{data:{session:t}}=await ew.supabase.auth.getSession();if(!(null==t?void 0:t.access_token))throw Error("No active session");let n=await fetch("".concat("https://odjzupnfscavznbqbvac.supabase.co\n","/functions/v1/send-support-email"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t.access_token),apikey:(0,eN.Q)().key},body:JSON.stringify(e)}),r=await n.json();if(!n.ok)throw Error(r.error||r.details||"Failed to send email");return{success:!0}}let eC={feature:{title:"Request Feature",description:"Have a feature in mind that would make Adcero better? We'd love to hear about it!",subjectPrefix:"[Feature Request]"},bug:{title:"Report Bug",description:"Found something not working as expected? Help us improve by reporting the issue.",subjectPrefix:"[Bug Report]"}};function eS(e){var t;let{open:n,onOpenChange:s,type:l}=e,{session:i}=(0,ey.A)(),o=eC[l],[c,u]=(0,a.useState)(""),[d,m]=(0,a.useState)(""),[h,p]=(0,a.useState)(""),[x,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>{var e;n&&(null==i||null==(e=i.user)?void 0:e.email)&&m(i.user.email)},[n,null==i||null==(t=i.user)?void 0:t.email]),(0,a.useEffect)(()=>{n||(u(""),p(""))},[n]);let b=c.trim().length>0&&d.trim().length>0&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d)&&h.trim().length>=25,j=async()=>
1{if(b){v(!0);try{await ek({subject:"".concat(o.subjectPrefix," ").concat(c),email:d.trim(),message:h.trim(),type:l}),ex.oR.success("Your feedback has been sent. Thank you!"),s(!1)}catch(e){console.error("Failed to send feedback:",e),ex.oR.error("Failed to send feedback. Please try again.")}finally{v(!1)}}};return(0,r.jsx)(g.lG,{open:n,onOpenChange:s,children:(0,r.jsxs)(g.Cf,{children:[(0,r.jsxs)(g.c7,{children:[(0,r.jsx)(g.L3,{children:o.title}),(0,r.jsx)(g.rr,{children:o.description})]}),(0,r.jsxs)("div",{className:"space-y-4 py-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ej.J,{htmlFor:"feedback-subject",children:"Subject *"}),(0,r.jsx)(ev.p,{id:"feedback-subject",value:c,onChange:e=>u(e.target.value),placeholder:"Brief summary of your request"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ej.J,{htmlFor:"feedback-email",children:"Email *"}),(0,r.jsx)(ev.p,{id:"feedback-email",type:"email",value:d,onChange:e=>m(e.target.value),placeholder:"[email protected]"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ej.J,{htmlFor:"feedback-message",children:"Message *"}),(0,r.jsx)(eb.T,{id:"feedback-message",value:h,onChange:e=>p(e.target.value),placeholder:"feature"===l?"Describe the feature you would like to see...":"Describe the bug and steps to reproduce...",rows:5}),(0,r.jsxs)("p",{className:"text-xs ".concat(h.trim().length>=25?"text-muted-foreground":"text-destructive"),children:[h.trim().length,"/",25," characters minimum"]})]})]}),(0,r.jsxs)(g.Es,{children:[(0,r.jsx)(f.$,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(f.$,{onClick:j,disabled:!b||x,children:x?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send"})]})]})})}var eA=n(99520),e_=n(25698),eE=n(95704);function ez(e,t){return e===t||e.startsWith("".concat(t,"/"))}function eR(){var e;let{selectedPlatform:t,currentOrganization:n}=(0,x.Z5)();return e={selectedPlatform:t,organizationId:null==n?void 0:n.id,organizationName:null==n?void 0:n.name},et.filter(t=>!!er(t,e.selectedPlatform)&&(!t.isVisible||!!t.isVisible(e)))}function eI(e){let{isCollapsed:t,size:n="default"}=e,{resolvedTheme:s,setTheme:o}=function(){let e=(0,a.useContext)(T);if(void 0===e)throw Error("useTheme must be used within a ThemeProvider");return e}(),c="dark"===s?l.A:i.A,u=(0,w.cn)("w-full ".concat("mobile"===n?"h-10":"h-8"," px-2 justify-start rounded-md transition-all duration-200"),"text-muted-foreground hover:bg-brand-secondary/10 hover:text-fuchsia-700 ".concat("mobile"===n?"gap-3":"gap-2"),t&&"justify-center px-0");return(0,r.jsx)("div",{className:"relative group px-2",children:(0,r.jsx)(f.$,{asChild:!0,variant:"ghost",className:u,children:(0,r.jsxs)("button",{type:"button","aria-label":"Switch to ".concat("dark"===s?"light":"dark"," mode"),"aria-pressed":"dark"===s,onClick:()=>{o("dark"===s?"light":"dark")},children:[(0,r.jsx)(c,{className:(0,w.cn)("".concat("mobile"===n?"size-5":"size-4"," flex-shrink-0 transition-colors"),"text-muted-foreground group-hover:text-fuchsia-700")}),!t&&(0,r.jsx)("span",{className:"text-sm font-medium tracking-tight",children:"dark"===s?"Light mode":"Dark mode"})]})})})}function eP(e){let{isCollapsed:t,setIsCollapsed:n}=e,l=(0,s.usePathname)(),{selectedPlatform:i}=(0,x.Z5)(),u=function(){let e=(0,e_.v)(),{session:t}=(0,ey.A)(),{confirmedDateRange:n}=(0,eA.F)(),r="1"===eE.env.NEXT_PUBLIC_ENABLE_ADS_MANAGER_PREFETCH,s=(0,a.useRef)(null),l=(0,a.useRef)(!1),i=(0,a.useCallback)(()=>{var a,i;if(!r)return;let o=null==t||null==(a=t.user)?void 0:a.id,c=e.organizationId,u=null==(i=e.selectedAccount)?void 0:i.ad_account_id,d=e.platform,m=null==n?void 0:n.from,f=null==n?void 0:n.to;if(!o||!e.isScopeReady||!c||!u||!d||!m||!f)return;let h="".concat(c,"-").concat(u,"-").concat(d,"-").concat(m.toISOString(),"-").concat(f.toISOString());if(s.current===h||l.current)return;s.current=h,l.current=!0;let g=async()=>{try{let e=await (0,E.getAuthHeaders)(),t=m.toISOString(),n=f.toISOString(),r=new URLSearchParams({organizationId:c,accountId:u,platform:d});await Promise.allSettled([fetch("/api/ads-manager/list",{method:"POST",headers:{...e,"Content-Type":"application/json"},body:JSON.stringify({tab:"Campaigns",accountId:u,startDate:t,endDate:n,organizationId:c,platform:d}),credentials:"include"}),fetch("/api/ads-manager/sync-dates?".concat(r),{headers:e,credentials:"include"}),fetch("/api/user-settings?settingType=view&organizationId=".concat(encodeURIComponent(c)),{headers:e,credentials:"include"})])}catch(e){}finally{l.current=!1}};"requestIdleCallback"in window?window.requestIdleCallback(g,{timeout:500}):setTimeout(g,0)},[t,e,n,r]);return{onMouseEnter:i,onFocus:i}}(),[d,m]=(0,a.useState)({open:!1,type:"feature"}),h=eR();return(0,r.jsxs)("aside",{className:(0,w.cn)("fixed inset-y-0 left-0 z-50 hidden flex-col md:flex transition-[width] duration-300 ease-in-out","sidebar-glass",i?"sidebar-glass-".concat(i):"sidebar-glass-meta",t?"w-16":"w-44 2xl:w-48"),children:[(0,r.jsxs)("nav",{className:"flex flex-col h-full overflow-hidden py-4",children:[(0,r.jsx)("div",{className:"border-b border-border/40 pb-2 mb-2",children:(0,r.jsx)(eg,{isCollapsed:t})}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto no-scrollbar",children:[(0,r.jsxs)("div",{className:"flex flex-col mb-4",children:[(0,r.jsx)(ea,{label:"Platform",isCollapsed:t}),(0,r.jsx)(A,{isCollapsed:t})]}),(0,r.jsxs)("div",{className:"flex flex-col mb-4",children:[(0,r.jsx)(ea,{label:"Organization",isCollapsed:t}),(0,r.jsx)(ef,{isCollapsed:t})]}),(0,r.jsxs)("div",{className:"flex flex-col mb-4",children:[(0,r.jsx)(ea,{label:"Navigation",isCollapsed:t}),(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:h.map(e=>(0,r.jsx)(eh,{item:e,isActive:ez(l,e.href),isCollapsed:t,onMouseEnter:"/ads-manager"===e.href?u.onMouseEnter:void 0,onFocus:"/ads-manager"===e.href?u.onFocus:void 0},e.href))})]})]}),(0,r.jsxs)("div",{className:(0,w.cn)("mt-auto flex-shrink-0 border-t border-border/40 pt-2",t&&"py-2"),children:[(0,r.jsx)("div",{className:"px-2",children:(0,r.jsxs)(f.$,{variant:"ghost",className:"w-full h-8 mb-1 justify-center opacity-50 hover:opacity-100 dark:opacity-100 dark:text-white dark:hover:text-white",onClick:()=>n(!t),children:[t?(0,r.jsx)(o.A,{className:"h-4 w-4"}):(0,r.jsx)(c.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:t?"Expand sidebar":"Collapse sidebar"})]})}),(0,r.jsx)("div",{className:"space-y-0.5",children:en.map(e=>(0,r.jsxs)(a.Fragment,{children:["/settings"===e.href&&(0,r.jsx)(eI,{isCollapsed:t}),(0,r.jsx)(eh,{item:e,isActive:ez(l,e.href),isCollapsed:t,onClick:e.action?()=>{"request-feature"===e.action?m({open:!0,type:"feature"}):"report-bug"===e.action&&m({open:!0,type:"bug"})}:void 0})]},e.label))})]})]}),(0,r.jsx)(eS,{open:d.open,onOpenChange:e=>m(t=>({...t,open:e})),type:d.type})]})}function eT(){let e=(0,s.usePathname)(),{selectedPlatform:t}=(0,x.Z5)(),[n,l]=(0,a.useState)(!1),[i,o]=(0,a.useState)({open:!1,type:"feature"}),c=eR();return(0,r.jsxs)("header",{className:(0,w.cn)("fixed top-0 left-0 right-0 z-50 flex md:hidden items-center justify-between h-14 px-4 border-b border-border/40","sidebar-glass",t?"sidebar-glass-".concat(t):"sidebar-glass-meta"),children:[(0,r.jsx)(m(),{href:"/dashboard",className:"flex items-center",children:(0,r.jsx)("div",{className:"w-[120px]",children:(0,r.jsx)("img",{src:"/images/adcero-logo-v2.svg",alt:"Adcero Logo",width:120,height:30,style:{objectFit:"contain",maxWidth:"100%",height:"auto"}})})}),(0,r.jsxs)(h.cj,{open:n,onOpenChange:l,children:[(0,r.jsx)(h.CG,{asChild:!0,children:(0,r.jsxs)(f.$,{variant:"ghost",size:"icon",className:"h-9 w-9",children:[(0,r.jsx)(u.A,{className:"h-5 w-5"}),(0,r.jsx)("span",{className:"sr-only",children:"Open menu"})]})}),(0,r.jsx)(h.h,{side:"left",className:"w-64 p-0 bg-background border-r-0",children:(0,r.jsxs)("nav",{className:"flex flex-col h-full overflow-hidden py-4",children:[(0,r.jsx)("div",{className:"border-b border-border/40 pb-2 mb-2",children:(0,r.jsx)(eg,{isCollapsed:!1,onClick:()=>l(!1)})}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:[(0,r.jsxs)("div",{className:"flex flex-col mb-4",children:[(0,r.jsx)(ea,{label:"Platform",isCollapsed:!1}),(0,r.jsx)(A,{isCollapsed:!1})]}),(0,r.jsxs)("div",{className:"flex flex-col mb-4",children:[(0,r.jsx)(ea,{label:"Organization",isCollapsed:!1}),(0,r.jsx)(ef,{isCollapsed:!1})]}),(0,r.jsxs)("div",{className:"flex flex-col mb-4",children:[(0,r.jsx)(ea,{label:"Navigation",isCollapsed:!1}),(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:c.map(t=>(0,r.jsx)(eh,{item:t,isActive:ez(e,t.href),isCollapsed:!1,onClick:()=>l(!1),size:"mobile"},t.href))})]})]}),(0,r.jsx)("div",{className:"mt-auto flex-shrink-0 border-t border-border/40 pt-2",children:(0,r.jsx)("div",{className:"space-y-0.5",children:en.map(t=>(0,r.jsxs)(a.Fragment,{children:["/settings"===t.href&&(0,r.jsx)(eI,{isCollapsed:!1,size:"mobile"}),(0,r.jsx)(eh,{item:t,isActive:ez(e,t.href),isCollapsed:!1,onClick:t.action?()=>{"request-feature"===t.action?(o({open:!0,type:"feature"}),l(!1)):"report-bug"===t.action&&(o({open:!0,type:"bug"}),l(!1))}:()=>l(!1),size:"mobile"})]},t.label))})})]})})]}),(0,r.jsx)(eS,{open:i.open,onOpenChange:e=>o(t=>({...t,open:e})),type:i.type})]})}var eO=n(67092),eL=n(58210),eF=n(35261),eM=n(52056);function eD(e){var t;return e.length<=1?null!=(t=e[0])?t:"":2===e.length?"".concat(e[0]," and ").concat(e[1]):"".concat(e.slice(0,-1).join(", ")," and ").concat(e[e.length-1])}function eV(){let e=(0,s.useRouter)(),{organizationAccounts:t}=(0,x.Z5)(),n=(0,a.useMemo)(()=>(function(e){let t=[];for(let r of e){var n;if(!1===r.is_active||"active"!==(0,eO.n)(r))continue;let e=(0,y.FL)(r.platform);if(!e)continue;let a=(0,eL.kL)(r.metadata);if(!a)continue;let s=(0,eF.lo)(e);t.push({platform:e,platformLabel:s,accountDisplayName:(null==(n=r.account_name)?void 0:n.trim())||"".concat(s," ad account"),detectedAt:a.detectedAt,lastSyncedAt:a.lastSyncedAt})}return t.sort((e,t)=>
1e.detectedAt.localeCompare(t.detectedAt))})(t),[t]);if(0===n.length)return null;let l=[];for(let e of n)l.includes(e.platformLabel)||l.push(e.platformLabel);let i=n[0],o=1===n.length,c=function(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}(n.map(e=>e.lastSyncedAt).filter(e=>!!e).sort()[0]),u=1===l.length?"".concat(l[0]," connection needs to be re-linked"):"".concat(eD(l)," connections need to be re-linked"),d=o?"".concat(i.platformLabel," signed you out of ").concat(!function(e,t){let n=0;for(let r of e)if(!1!==r.is_active&&"active"===(0,eO.n)(r)&&(0,y.FL)(r.platform)===t&&++n>1)return!0;return!1}(t,i.platform)?"your account":i.accountDisplayName):"".concat(eD(l)," signed these accounts out");return(0,r.jsx)("div",{className:"sticky top-14 z-30 bg-background/90 px-4 py-3 backdrop-blur-md sm:px-6 md:top-0",children:(0,r.jsxs)("div",{role:"alert",className:"banner-resume flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,r.jsx)(eM.A,{className:"mt-0.5 h-4 w-4 flex-none text-amber-600 dark:text-amber-400"}),(0,r.jsxs)("div",{className:"min-w-0 space-y-0.5 text-sm",children:[(0,r.jsx)("p",{className:"font-semibold text-foreground",children:u}),(0,r.jsxs)("p",{className:"text-muted-foreground",children:[d," — this usually happens after a password change.",c?" No new ad data since ".concat(c,"."):" Ad data syncing is paused until you reconnect."]})]})]}),(0,r.jsxs)("button",{type:"button",className:"btn-frost-warn w-full sm:w-auto sm:flex-none",onClick:()=>e.push("/settings?token_expired=".concat(i.platform,"#organization")),children:["Reconnect ",i.platformLabel]})]})})}var eU=n(49341),eq=n(4702),eB=n(67909);let eW=(0,eB.default)(()=>Promise.all([n.e(67826),n.e(43163),n.e(18539)]).then(n.bind(n,54945)).then(e=>({default:e.OnboardingWidget})),{loadableGenerated:{webpack:()=>[54945]},loading:()=>null,ssr:!1}),eJ=(0,eB.default)(()=>Promise.all([n.e(8751),n.e(76130)]).then(n.bind(n,76130)).then(e=>({default:e.InteractiveCursorOverlay})),{loadableGenerated:{webpack:()=>[76130]},loading:()=>null,ssr:!1}),eZ=(0,eB.default)(()=>n.e(61525).then(n.bind(n,61525)).then(e=>({default:e.DateRangeActuatorBridge})),{loadableGenerated:{webpack:()=>[61525]},loading:()=>null,ssr:!1}),e$=(0,eB.default)(()=>Promise.all([n.e(8751),n.e(6504),n.e(42714),n.e(46310),n.e(63586),n.e(87553),n.e(43482)]).then(n.bind(n,38853)).then(e=>({default:e.AgentDock})),{loadableGenerated:{webpack:()=>[38853]},loading:()=>null,ssr:!1});function eH(e){let{children:t}=e,[n,l]=(0,a.useState)(!1),[i,o]=(0,a.useState)(!1),c=(0,s.usePathname)(),u=(0,eq.M)(c),d=(0,s.useRouter)(),m=(0,eU.i)(e=>e.platform),f=(0,eU.i)(e=>e.clear),h=(0,a.useRef)(!1);return((0,a.useEffect)(()=>{if(m&&!h.current){h.current=!0;let e=(0,eF.lo)(m);ex.oR.error("Your ".concat(e," connection has expired. Please reconnect.")),d.push("/settings?token_expired=".concat(m,"#organization")),f(),setTimeout(()=>{h.current=!1},5e3)}},[m,d,f]),!function(){let{enabled:e=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,s.useRouter)(),n=(0,s.usePathname)(),{selectedPlatform:r}=(0,x.Z5)();(0,a.useEffect)(()=>{if(!e)return;let a=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"/dashboard";if(!n)return null;let a=t.find(t=>"#"!==t.href&&(e===t.href||e.startsWith("".concat(t.href,"/"))));return!a||er(a,n)?null:r}(n,et,r);a&&t.replace(a)},[e,n,r,t])}({enabled:!u}),(0,a.useEffect)(()=>{if(u)return void o(!1);let e=window;if("function"==typeof e.requestIdleCallback){let t=e.requestIdleCallback(()=>o(!0),{timeout:1200});return()=>{var n;return null==(n=e.cancelIdleCallback)?void 0:n.call(e,t)}}let t=window.setTimeout(()=>o(!0),150);return()=>window.clearTimeout(t)},[u,c]),u)?(0,r.jsx)("main",{className:"flex-1 min-w-0 bg-background text-foreground",children:t}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eT,{}),(0,r.jsx)(eP,{isCollapsed:n,setIsCollapsed:l}),(0,r.jsxs)("main",{className:(0,w.cn)("flex-1","pt-14 md:pt-0",n?"md:pl-16":"md:pl-44 2xl:pl-48","min-w-0 bg-background text-foreground relative"),children:[(0,r.jsx)(eV,{}),t]}),i?(0,r.jsx)(eW,{}):null,i?(0,r.jsx)(eJ,{}):null,i?(0,r.jsx)(e$,{}):null,i?(0,r.jsx)(eZ,{}):null]})}var eG=n(32559),eK=n(52099);let eY="Sign-in is taking longer than expected. The authentication service may be temporarily unavailable. Please try again.",eQ="Unable to sign in. Check your email and password and try again.",eX="Sign-up is taking longer than expected. The authentication service may be temporarily unavailable. Please try again.",e0="/signup";async function e1(e,t,n){let r=null;try{return await Promise.race([e,new Promise((e,a)=>{r=setTimeout(()=>{a(Error(n))},t)})])}finally{null!==r&&clearTimeout(r)}}function e2(){let e=(0,s.useRouter)(),t=(0,s.usePathname)(),[n,l]=(0,a.useState)(""),[i,o]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[d,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(()=>t===e0),[p,x]=(0,a.useState)(null),[v,b]=(0,a.useState)(null),j=async t=>{t.preventDefault(),m(!0),x(null),b(null);try{if(h){if(i!==c){x("Passwords do not match"),m(!1);return}let{error:e}=await e1(ew.supabase.auth.signUp({email:n,password:i,options:{emailRedirectTo:new URL("/ads-manager",window.location.origin).toString()}}),15e3,eX);if(e)throw e;(0,eK.Lh)("user_signed_up"),b("Check your email for the confirmation link!")}else{let{error:t}=await e1(ew.supabase.auth.signInWithPassword({email:n,password:i}),15e3,eY);if(t)throw t;(0,eK.Lh)("user_signed_in"),e.push("/ads-manager")}}catch(e){x(function(e,t){if(e instanceof Error){let n=e.message.trim(),r
1=n.toLowerCase();if(n===eY||n===eX)return n;if("sign-up"===t){if(r.includes("already registered")||r.includes("already been registered")||r.includes("user already exists"))return"An account with this email already exists. Try signing in, or check your email for the confirmation link."}else if(r.includes("invalid login credentials")||r.includes("invalid email or password")||r.includes("email not confirmed"))return eQ;if(n)return n}return"sign-up"===t?"Unable to sign up. Please try again.":eQ}(e,h?"sign-up":"sign-in"))}finally{m(!1)}},y=async()=>{if(!n)return void x("Please enter your email address first");m(!0),x(null),b(null);try{let{error:e}=await ew.supabase.auth.resetPasswordForEmail(n);if(e)throw e;(0,eK.Lh)("password_reset_requested"),b("Check your email for the password reset link!")}catch(e){x(e instanceof Error?e.message:"Unable to send the password reset email. Please try again.")}finally{m(!1)}};return(0,r.jsx)("div",{className:"w-full max-w-sm mx-auto",children:(0,r.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ej.J,{htmlFor:"email",children:"Email address"}),(0,r.jsx)(ev.p,{id:"email",type:"email",placeholder:"Your email address",value:n,onChange:e=>l(e.target.value),required:!0,disabled:d,className:"w-full"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ej.J,{htmlFor:"password",children:"Your Password"}),(0,r.jsx)(ev.p,{id:"password",type:"password",placeholder:"Your password",value:i,onChange:e=>o(e.target.value),required:!0,disabled:d,className:"w-full"})]}),h&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ej.J,{htmlFor:"confirmPassword",children:"Confirm Password"}),(0,r.jsx)(ev.p,{id:"confirmPassword",type:"password",placeholder:"Confirm your password",value:c,onChange:e=>u(e.target.value),required:!0,disabled:d,className:"w-full"})]}),p&&(0,r.jsx)(eG.Fc,{variant:"destructive",children:(0,r.jsx)(eG.TN,{children:p})}),v&&(0,r.jsx)(eG.Fc,{children:(0,r.jsx)(eG.TN,{children:v})}),(0,r.jsx)(f.$,{type:"submit",className:"w-full",disabled:d,size:"lg",children:d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep.A,{className:"mr-2 h-4 w-4 animate-spin"}),h?"Signing up...":"Signing in..."]}):(0,r.jsx)(r.Fragment,{children:h?"Sign up":"Sign in"})}),(0,r.jsxs)("div",{className:"text-center space-y-2 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:y,className:"text-sm text-muted-foreground hover:underline",disabled:d,children:"Forgot your password?"}),(0,r.jsx)("div",{children:(0,r.jsx)("button",{type:"button",onClick:()=>{g(!h),x(null),b(null),u("")},className:"text-sm text-muted-foreground hover:underline",disabled:d,children:h?"Already have an account? Sign in":"Don't have an account? Sign up"})})]})]})})}var e5=n(37517);function e4(e){let{children:t}=e;return(0,a.useEffect)(()=>{(0,e5.e0)()&&n.e(17224).then(n.bind(n,17224)).then(e=>{let{initClientLogger:t}=e;t()})},[]),(0,r.jsx)(r.Fragment,{children:t})}var e3=n(8641);function e6(e){let{children:t}=e,{session:n}=(0,ey.A)();return(0,r.jsx)(O,{session:n,children:t})}var e9=n(92853),e8=n(65476),e7=n(83101),te=n(65229);let tt=e8.Kq,tn=a.forwardRef((e,t)=>{let{className:n,...a}=e;return(0,r.jsx)(e8.LM,{ref:t,className:(0,w.cn)("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:right-0 sm:top-auto sm:bottom-0 sm:flex-col md:max-w-[420px]",n),...a})});tn.displayName=e8.LM.displayName;let tr=(0,e7.F)("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),ta=a.forwardRef((e,t)=>
1{let{className:n,variant:a,...s}=e;return(0,r.jsx)(e8.bL,{ref:t,className:(0,w.cn)(tr({variant:a}),n),...s})});ta.displayName=e8.bL.displayName,a.forwardRef((e,t)=>{let{className:n,...a}=e;return(0,r.jsx)(e8.rc,{ref:t,className:(0,w.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",n),...a})}).displayName=e8.rc.displayName;let ts=a.forwardRef((e,t)=>{let{className:n,...a}=e;return(0,r.jsx)(e8.bm,{ref:t,className:(0,w.cn)("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-100 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",n),"toast-close":"",...a,children:(0,r.jsx)(te.A,{className:"h-4 w-4"})})});ts.displayName=e8.bm.displayName;let tl=a.forwardRef((e,t)=>{let{className:n,...a}=e;return(0,r.jsx)(e8.hE,{ref:t,className:(0,w.cn)("text-sm font-semibold",n),...a})});tl.displayName=e8.hE.displayName;let ti=a.forwardRef((e,t)=>{let{className:n,...a}=e;return(0,r.jsx)(e8.VY,{ref:t,className:(0,w.cn)("text-sm opacity-90",n),...a})});function to(){let{toasts:e}=(0,eo.dj)();return(0,r.jsxs)(tt,{duration:5e3,children:[e.map(function(e){let{id:t,title:n,description:a,action:s,...l}=e;return(0,r.jsxs)(ta,{duration:l.duration||5e3,...l,children:["destructive"===l.variant&&(0,r.jsx)(e9.Le,{state:"uhoh",size:20,className:"shrink-0 self-start"}),(0,r.jsxs)("div",{className:"grid gap-1",children:[n&&(0,r.jsx)(tl,{children:n}),a&&(0,r.jsx)(ti,{children:a})]}),s,(0,r.jsx)(ts,{})]},t)}),(0,r.jsx)(tn,{})]})}ti.displayName=e8.VY.displayName;var tc=n(96159);function tu(e){let{children:t}=e,n=(0,s.usePathname)(),a=!(null==n?void 0:n.startsWith("/ads-manager"));return(0,tc.K)(a),(0,r.jsx)(r.Fragment,{children:t})}var td=n(10075),tm=n(25022),tf=n(34975),th=n(99776),tg=n(53455),tp=n(17759),tx=n(49259);let tv="/settings",tb="#account";var tj=n(22656),ty=n(15239);function tw(e){var t,n,l;let{children:i}=e,{session:o,isLoading:c}=(0,ey.A)(),{isLoading:u,userOrganizations:d,currentOrganization:m}=(0,x.Z5)(),{isServerOrganizationReady:f}=(0,x.Sg)(),h=(0,s.useRouter)(),g=(0,s.usePathname)(),[p,v]=(0,a.useState)(null),[b,j]=(0,a.useState)(null),y=(0,eq.M)(g),w=null!=(n=null==o||null==(t=o.user)?void 0:t.id)?n:null,N=null!=(l=null==m?void 0:m.id)?l:null;(0,a.useEffect)(()=>{w?(0,tj.fV)({id:w,...N?{organization_id:N}:{}}):(0,tj.ek)()},[w,N]);let k=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(y)return void(0,eK.Ml)(!1);w?((0,eK.Vz)(),(0,eK.bR)({id:w,organization_id:N}),(0,eK.Ml)(!0)):k.current&&(0,eK.ur)(),k.current=w},[y,w,N]),(0,a.useEffect)(()=>{v(null),j(null)},[w]),(0,a.useEffect)(()=>{w&&u&&v(e=>e===w?e:w)},[w,u]),(0,a.useEffect)(()=>{let e=p===w;w&&e&&!u&&j(e=>e===w?e:w)},[w,u,p,j]);let C=!!w&&b===w,S=!!o&&C&&0===d.length,A=!!(null==g?void 0:g.startsWith("/settings")),{needsName:_}=function(e){var t,n,r;let{enabled:l}=e,{session:i}=(0,ey.A)(),o=(0,s.useRouter)(),c=(0,s.usePathname)(),u=null!=(r=null==i||null==(t=i.user)?void 0:t.id)?r:null,d=null!==(0,tp.K)(null==i||null==(n=i.user)?void 0:n.app_metadata),m=l&&!!u&&!d,f=(0,tg.I)({queryKey:(0,tx._i)(u),queryFn:tx.l2,enabled:m,staleTime:3e5}),h=m&&f.isSuccess&&!f.data.isComplete,g=(0,a.useRef)(!1);return(0,a.useEffect)(()=>{if(!h){g.current=!1;return}let e=()=>{let e=function(e){let{needsName:t,pathname:n,hash:r}=e;return t&&n?n!==tv?"redirect-to-account":r===tb?"none":"show-account-tab":"none"}({needsName:h,pathname:c,hash:window.location.hash});"none"!==e&&(g.current||(g.current=!0,ex.oR.error("Add your first and last name to continue using Adcero.")),"redirect-to-account"===e?o.replace("".concat(tv).concat(tb)):(window.history.replaceState(window.history.state,"",tb),window.dispatchEvent(new HashChangeEvent("hashchange"))))};return e(),window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[h,c,o]),{needsName:h}}({enabled:!y&&!!o}),E=d.length>0&&!f,z=!!w&&!C&&(u||E);return((0,a.useEffect)(()=>{o&&"/"===g&&h.push("/dashboard")},[o,g,h]),(0,a.useEffect)(()=>
1{(function(e){let{hasNoOrganization:t,isOnSettings:n,needsProfileName:r}=e;return t&&!n&&!r})({hasNoOrganization:S,isOnSettings:A,needsProfileName:_})&&h.push("/settings#organization")},[S,A,_,h]),y)?(0,r.jsx)(r.Fragment,{children:i}):null===g||function(e){let{pathname:t,session:n,isAuthLoading:r=!1,isInitialOrgLoad:a=!1}=e;return null===t||!n&&r&&!a}({pathname:g,session:o,isAuthLoading:c,isInitialOrgLoad:z})?(0,r.jsx)(e3.LoadingOverlay,{}):!function(e){let{isPublic:t,pathname:n,session:r,isAuthLoading:a}=e;return!t&&null!==n&&!r&&!a}({isPublic:y,pathname:g,session:o,isAuthLoading:c})?i:(0,r.jsx)("div",{className:"light w-full h-screen flex justify-center items-center bg-background text-foreground",children:(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center w-full max-w-sm px-6",children:[(0,r.jsx)("div",{className:"mb-2",children:(0,r.jsx)(ty.default,{src:"/images/adcero-logo-v2.svg",alt:"Adcero",width:250,height:80,className:"mx-auto",priority:!0})}),(0,r.jsxs)("div",{className:"text-center mb-4",children:[(0,r.jsx)("h1",{className:"text-3xl font-bold",children:"Welcome to Adcero"}),(0,r.jsx)("p",{className:"text-muted-foreground mt-1",children:g===e0?"create your account to get started":"sign in to access your advertising dashboard"})]}),(0,r.jsx)(e2,{})]})})}function tN(e){let{children:t}=e,[n]=(0,a.useState)(()=>new td.E({queryCache:new tm.$({onSuccess:e=>{(0,eU.v)(e)}}),mutationCache:new tf.q({onSuccess:e=>{(0,eU.v)(e)}})}));return(0,a.useEffect)(()=>{if("undefined"==typeof PerformanceObserver||!(0,e5.N$)())return;let e=new PerformanceObserver(e=>{for(let t of e.getEntries())t.name.includes("/_next/static/chunks/")&&"number"==typeof t.duration&&(0,tj.jE)("app.chunk.load.duration",t.duration,{unit:"millisecond",attributes:{route:window.location.pathname,entry_type:t.entryType}})});return e.observe({entryTypes:["resource"]}),()=>e.disconnect()},[]),(0,r.jsx)(e4,{children:(0,r.jsx)(th.Ht,{client:n,children:(0,r.jsx)(ey.O,{children:(0,r.jsx)(x.TS,{children:(0,r.jsx)(eA.j,{children:(0,r.jsx)(tu,{children:(0,r.jsxs)(e6,{children:[(0,r.jsx)(tw,{children:t}),(0,r.jsx)(to,{}),(0,r.jsx)(e9.y3,{})]})})})})})})})}[...eq.d];var tk=n(70954);function tC(e){let{children:t}=e;return(0,r.jsx)(tN,{children:(0,r.jsx)(tk.g,{children:(0,r.jsx)(a.Suspense,{fallback:null,children:(0,r.jsx)(eH,{children:t})})})})}},83139:(e,t,n)=>{n.d(t,{l$:()=>r.l$});var r=n(18720)},92853:(e,t,n)=>{n.d(t,{Le:()=>v,y3:()=>y,EP:()=>g,dp:()=>h,zQ:()=>S,aZ:()=>A,L5:()=>_});var r=n(95155),a=n(12115),s=n(25016),l=n(82734),i=n(42291),o=n(37138),c=n(67501),u=n(95704);let d=c.aO,m=new Set(["0","false","off","no"]);function f(e){return e?e.split(",").map(e=>e.trim()).filter(e=>e.length>0):[]}function h(){var e,t,n;let r=(0,a.useContext)(l.tI),s=null!=(e=null==r?void 0:r.currentOrganization)?e:null;return function(e){var t;if(!function(){var e;let t=null==(e=u.env.NEXT_PUBLIC_CHROMA_ENABLED)?void 0:e.trim().toLowerCase();return!t||!m.has(t)}())return!1;let{organizationId:n,organizationName:r}=e;return!!(n&&new Set([i.Oh,o.ED,d,...f(u.env.CHROMA_ORG_IDS),...f(u.env.NEXT_PUBLIC_CHROMA_ORG_IDS)]).has(n))||!!("production"!==((t="production",void 0!==t)?t:u.env.VERCEL_ENV)&&r&&"nimbus"===r.trim().toLowerCase())}({organizationId:null!=(t=null==s?void 0:s.id)?t:null,organizationName:null!=(n=null==s?void 0:s.name)?n:null})}function g(e){return"twitter"===e?"x":"linkedin"===e?"meta":null!=e?e:"meta"}let p=["idle","talking","thinking","happy","uhoh"];function x(e,t){return"/assets/chroma/chroma-".concat(e,"-").concat(t,".svg")}function v(e){let{state:t,size:n=44,skin:i,fallback:o,label:c,className:u}=e,d=h(),m=function(){var e;let t=(0,a.useContext)(l.tI);return g(null!=(e=null==t?void 0:t.selectedPlatform)?e:null)}(),f=null!=i?i:m,[v,b]=(0,a.useState)(f),[j,y]=(0,a.useState)(null),[w,N]=(0,a.useState)(!1),k=(0,a.useRef)(f);if((0,a.useEffect)(()=>{if(!d){k.current=f,b(f),y(null),N(!1);return}if(f===k.current)return;for(let e of p)new window.Image().src=x(f,e);y(k.current),b(f),k.current=f,N(!0);let e=window.requestAnimationFrame(()=>{N(!1)}),t=window.setTimeout(()=>{y(null)},350);return()=>{window.cancelAnimationFrame(e),window.clearTimeout(t)}},[d,f]),!d)return(0,r.jsx)(r.Fragment,{children:null!=o?o:null});let C=Math.max(2,Math.ceil(.1*n));return(0,r.jsx)("span",{"data-chroma":!0,className:(0,s.cn)("inline-flex shrink-0 overflow-visible",u),style:{width:n,height:n,padding:C,boxSizing:"content-box"},children:(0,r.jsxs)("span",{className:"relative block overflow-visible",style:{width:n,height:n},children:[(0,r.jsx)("img",{src:x(v,t),alt:null!=c?c:"","aria-hidden":!c||void 0,className:"absolute inset-0 block h-full w-full",width:n,height:n,draggable:!1}),j?(0,r.jsx)("img",{src:x(j,t),alt:"","aria-hidden":"true",className:(0,s.cn)("absolute inset-0 block h-full w-full transition-opacity duration-[350ms] ease-[cubic-bezier(0.22,1,0.36,1)]",w?"opacity-100":"opacity-0"),width:n,height:n,draggable:!1}):null]})})}var b=n(83139);let j={success:"happy",error:"uhoh",warning:"uhoh",loading:"thinking"};function y(){let e=h()?{success:(0,r.jsx)(v,{state:j.success,size:40}),error:(0,r.jsx)(v,{state:j.error,size:40}),warning:(0,r.jsx)(v,{state:j.warning,size:40}),loading:(0,r.jsx)(v,{state:j.loading,size:40})}:void 0;return(0,r.jsx)(b.l$,{position:"bottom-right",richColors:!0,closeButton:!0,icons:e})}var w=n(25959);let N=["uhoh","happy","talking","thinking","idle"],k=()=>({sourceStates:{}}),C=(0,w.v)(e=>({...k(),setSourceState:(t,n)=>{e(e=>e.sourceStates[t]===n?e:{sourceStates:{...e.sourceStates,[t]:n}})},clearSourceState:t=>{e(e=>
1{if(!(t in e.sourceStates))return e;let n={...e.sourceStates};return delete n[t],{sourceStates:n}})},reset:()=>e(k())})),S=()=>C(e=>(function(e){var t;let n=new Set(Object.values(e));return null!=(t=N.find(e=>n.has(e)))?t:"idle"})(e.sourceStates));function A(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],r=C(e=>e.setSourceState),s=C(e=>e.clearSourceState);(0,a.useEffect)(()=>{n?r(e,t):s(e)},[s,n,r,e,t]),(0,a.useEffect)(()=>()=>{s(e)},[s,e])}function _(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"idle",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3,[n,r]=(0,a.useState)(e),s=(0,a.useRef)(null),l=(0,a.useRef)(e);l.current=e;let i=(0,a.useCallback)(()=>{null!==s.current&&(clearTimeout(s.current),s.current=null)},[]),o=(0,a.useCallback)(e=>{i(),r(e),s.current=setTimeout(()=>{s.current=null,r(l.current)},t)},[i,t]);return(0,a.useEffect)(()=>{null===s.current&&r(e)},[e]),(0,a.useEffect)(()=>i,[i]),{state:n,flash:o}}},96159:(e,t,n)=>{n.d(t,{K:()=>m});var r=n(12115
1),a=n(18558),s=n(37517),l=n(40399),i=n(25698),o=n(83875),c=n(8525),u=n(91094);let d=new Map;function m(){var e,t,n;let m=!(arguments.length>0)||void 0===arguments[0]||arguments[0],[f,h]=(0,r.useState)(!1),[g,p]=(0,r.useState)(!0),[x,v]=(0,r.useState)(0),b=(0,r.useRef)(0),j=(0,l.Jv)(e=>e.setAccessToken),y=(0,l.Jv)(e=>e.setAdAccountId),w=(0,l.Jv)(e=>e.setCurrency),N=(0,i.v)(),k="meta"===N.platform&&null!=(n=null==(e=N.selectedAccount)?void 0:e.ad_account_id)?n:null,C=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let e=C.current;e&&e!==k&&N.organizationId&&d.delete("".concat(N.organizationId,":").concat((0,o.Jz)(e))),C.current=k},[k,N.organizationId]),(0,r.useEffect)(()=>{let{data:{subscription:e}}=c.supabase.auth.onAuthStateChange(()=>{v(e=>e+1)});return()=>{e.unsubscribe()}},[]),(0,r.useEffect)(()=>{var e,t;let n=++b.current,r=new AbortController,l=()=>{j(""),y(""),w("USD")},i=N.organizationId,f=N.platform,g="meta"===f&&null!=(t=null==(e=N.selectedAccount)?void 0:e.ad_account_id)?t:null,x=i&&g?"".concat(i,":").concat((0,o.Jz)(g)):null;return(async()=>{if(p(!0),!N.isScopeReady&&"no-organization"!==N.readinessReason){console.log("[useApiConfigInitializer] Waiting for canonical active scope readiness:",N.readinessReason),b.current===n&&h(!1);return}let e=(0,s.oz)()?(0,a.ok)({flow:"ads-manager.meta-api-config.init",source:"client",attributes:{organization_id:null!=i?i:"none",platform:null!=f?f:"none",enabled:m}}):null;if(console.log("[useApiConfigInitializer] Starting initialization, orgId:",i,"platform:",f),!function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return t&&"meta"===e}(f,m)){console.log("[useApiConfigInitializer] Meta config inactive for current platform"),b.current===n&&(l(),h(!0),p(!1)),e&&(0,a.h9)(e,{attributes:{result:"skipped",organization_id:null!=i?i:"none",platform:null!=f?f:"none"}});return}if(!g){console.log("[useApiConfigInitializer] No active Meta account selected for bootstrap"),b.current===n&&(l(),h(!0),p(!1)),e&&(0,a.h9)(e,{attributes:{result:"no_active_account",organization_id:null!=i?i:"none",platform:null!=f?f:"none"}});return}if(i&&x){let s=d.get(x);if(s&&Date.now()-s.timestamp<3e5){console.log("[useApiConfigInitializer] Using cached token for active Meta scope:",x),b.current===n&&(j(s.accessToken),y(s.adAccountId),w(s.currency),h(!0),p(!1)),e&&(0,a.h9)(e,{attributes:{result:"cache_hit",organization_id:null!=i?i:"none",platform:null!=f?f:"none"}});return}let o=!1;try{let{data:{session:s}}=await c.supabase.auth.getSession(),u=fetch("/api/integrations/meta/token",{method:"POST",headers:{"Content-Type":"application/json",...(null==s?void 0:s.access_token)?{Authorization:"Bearer ".concat(s.access_token)}:{}},body:JSON.stringify({organizationId:i,adAccountId:g}),signal:r.signal}),m=setTimeout(()=>{o=!0,r.abort()},5e3),f=await u.finally(()=>clearTimeout(m));if(b.current!==n)return;if(console.log("[useApiConfigInitializer] API response status:",f.status),f.ok){var t;let r=await f.json(),{accessToken:s,adAccountId:l,currency:o}=null!=(t=r.data)?t:r;if(console.log("[useApiConfigInitializer] Received values:",{hasAccessToken:!!s,accessTokenLength:(null==s?void 0:s.length)||0,adAccountId:l,currency:o}),b.current!==n)return;j(s||""),y(l||""),w(o||"USD"),s&&x&&d.set(x,{accessToken:s,adAccountId:l||"",currency:o||"USD",timestamp:Date.now()}),e&&(0,a.h9)(e,{attributes:{result:"fetched",has_access_token:!!s,organization_id:null!=i?i:"none"}})}else{let t=await f.text();console.log("[useApiConfigInitializer] API error:",f.status,t),b.current===n&&l(),e&&(0,a.h9)(e,{status:"error",attributes:{result:"http_error",status_code:f.status,organization_id:null!=i?i:"none"}})}}catch(t){if((0,u.z)(t)&&!o)return;console.log("[useApiConfigInitializer] Fetch error:",t),b.current===n&&l(),e&&(0,a.h9)(e,{status:(0,u.z)(t)?"aborted":"error",error:t,attributes:{result:o?"timeout":"fetch_error",organization_id:null!=i?i:"none"}})}}else console.log("[useApiConfigInitializer] No organization, clearing store"),b.current===n&&l(),e&&(0,a.h9)(e,{attributes:{result:"no_organization",organization_id:"none"}});b.current===n&&(h(!0),p(!1),console.log("[useApiConfigInitializer] Initialization complete"))})(),()=>{r.abort()}},[N.isScopeReady,N.organizationId,N.platform,N.readinessReason,null==(t=N.selectedAccount)?void 0:t.ad_account_id,x,m]),{isInitialized:f,isLoading:g}}},99520:(e,t,n)=>{n.d(t,{j:()=>k,F:()=>C});var r=n(95155),a=n(12115),s=n(99914),l=n(52120),i=n(38621),o=n(19056),c=n(19456),u=n(47691),d=n(91195);let m=e=>(0,i.GP)(e,"yyyy-MM-dd");function f(e){if("string"!=typeof e||!e)return null;let t=/^\d{4}-\d{2}-\d{2}$/.test(e)?(0,o.H)("".concat(e,"T00:00:00")):new Date(e);return(0,c.f)(t)?(0,u.o)(t):null}function h(e,t){var n,r,a;let s=new Date;return{from:m(null!=(n=e.from)?n:s),to:m(null!=(a=null!=(r=e.to)?r:e.from)?a:s),preset:t}}function g(e,t){if(!e||"object"!=typeof e)return null;let n=f(e.from),r=f(e.to);if(!n||!r||n>r)return null;if("string"==typeof e.preset){let t=(0,l.xw)(e.preset);if(t)return{range:t,preset:e.preset}}let a=!("preset"in e),s=f(t);
1if(a&&s&&0===(0,d.m)(r,s)){let e=(0,l.ZZ)((0,d.m)(r,n)+1),t=(0,l.xw)(e);if(t)return{range:t,preset:e}}return{range:{from:n,to:r},preset:null}}let p=()=>({range:(0,l.jd)(),preset:l.Dl});function x(e){if(!e)return null;try{let t=localStorage.getItem((0,l.C_)(e));return t?g(JSON.parse(t)):null}catch(e){return null}}function v(e,t){if(e)try{localStorage.setItem((0,l.C_)(e),JSON.stringify(h(t.range,t.preset)))}catch(e){}}async function b(e){try{let t=await (0,s.getAuthHeaders)(),n=await fetch("/api/user-settings",{method:"POST",headers:t,body:JSON.stringify({settingType:l.d,settingKey:l.mg,settingValue:h(e.range,e.preset)})});if(!n.ok){let e=await n.json();console.error("Error saving date range:",e.reason||e.error)}}catch(e){console.error("Error saving date range to API:",e)}}let j=(e,t)=>{var n,r,a,s;return(null==e||null==(n=e.from)?void 0:n.toISOString())===(null==t||null==(r=t.from)?void 0:r.toISOString())&&(null==e||null==(a=e.to)?void 0:a.toISOString())===(null==t||null==(s=t.to)?void 0:s.toISOString())};var y=n(29293),w=n(82734);let N=(0,a.createContext)(void 0);function k(e){var t,n;let{children:i}=e,{session:o}=(0,y.A)(),c=null==o||null==(t=o.user)?void 0:t.id,{currentOrganization:u}=(0,w.Z5)(),{pendingDateRange:d,confirmedDateRange:m,setPendingDateRange:f,confirmDateRange:h,confirmWithRange:k,resetToConfirmed:C,hasUnsavedChanges:S,isLoading:A}=function(e,t){let n=(0,a.useMemo)(()=>(0,l.xS)(t),[t]),r=(0,a.useRef)(n);r.current=n;let i=(0,a.useRef)(e);i.current=e;let[o,c]=(0,a.useState)(()=>{var n;let r=(0,l.xS)(t);return r?{range:r,preset:null}:null!=(n=x(e))?n:p()}),[u,d]=(0,a.useState)(()=>o),m=(0,a.useRef)(u);m.current=u;let f=(0,a.useCallback)(e=>{c(e),d(e)},[]),h=(0,a.useRef)((0,l.xS)(t)?t:void 0),y=(0,a.useRef)(e),w=(0,a.useRef)(0),[N,k]=(0,a.useState)(!!e),C=!j(o.range,u.range);(0,a.useEffect)(()=>{try{localStorage.removeItem(l.xl)}catch(e){}},[]),(0,a.useEffect)(()=>{var e;let r=null!=t?t:null;if(h.current===r)return;let a=h.current;if(h.current=r,n)return void f({range:n,preset:null});void 0!==a&&null!==(0,l.xS)(a)&&f(null!=(e=x(i.current))?e:p())},[t,n,f]),(0,a.useEffect)(()=>{if(!e)return void k(!1);if(y.current!==e&&(y.current=e,!r.current)){var t;f(null!=(t=x(e))?t:p())}let n=!1,a=w.current;return k(!0),(async()=>{try{let t=await (0,s.getAuthHeaders)(),i=await fetch("/api/user-settings?settingType=".concat(l.d,"&settingKey=").concat(l.mg),{headers:t});if(!i.ok||n)return;let o=(await i.json()).data,c=g(null==o?void 0:o.setting_value,null==o?void 0:o.updated_at);if(!c||n||(v(e,c),r.current||w.current!==a))return;f(c)}catch(e){console.error("Error loading date range from Supabase:",e)}finally{n||k(!1)}})(),()=>{n=!0}},[e,f]),(0,a.useEffect)(()=>{let e=e=>{let t=i.current;if(t&&e.key===(0,l.C_)(t)&&e.newValue&&!r.current)try{let t=g(JSON.parse(e.newValue));t&&!j(t.range,m.current.range)&&f(t)}catch(e){}};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[f]),(0,a.useEffect)(()=>{let e=()=>{if("hidden"===document.visibilityState)return;let{preset:e,range:t}=m.current,n=(0,l.xw)(e);n&&!j(n,t)&&f({range:n,preset:e})};return window.addEventListener("focus",e),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("focus",e),document.removeEventListener("visibilitychange",e)}},[f]);let S=(0,a.useCallback)((e,t)=>{c({range:e,preset:e&&null!=t?t:null})},[]),A=(0,a.useCallback)(e=>{w.current+=1,d(e),v(i.current,e),i.current&&b(e)},[]),_=(0,a.useCallback)(()=>{var e;(null==(e=o.range)?void 0:e.from)&&A({range:o.range,preset:o.preset})},[o,A]),E=(0,a.useCallback)((e,t)=>{let n={range:e,preset:null!=t?t:null};c(n),A(n)},[A]),z=(0,a.useCallback)(()=>{c(u)},[u]);return{pendingDateRange:o.range,confirmedDateRange:u.range,setPendingDateRange:S,confirmDateRange:_,confirmWithRange:E,resetToConfirmed:z,hasUnsavedChanges:C,isLoading:N}}(c,null!=(n=null==u?void 0:u.id)?n:null),_=(0,a.useMemo)(()=>({dateRange:d,setDateRange:f,confirmedDateRange:m,confirmDateRange:h,confirmWithRange:k,resetToConfirmed:C,hasUnsavedChanges:S,isLoading:A}),[d,m,f,h,k,C,S,A]);return(0,r.jsx)(N.Provider,{value:_,children:i})}function C(){let e=(0,a.useContext)(N);if(void 0===e)throw Error("useDateRange must be used within a DateRangeProvider");return e}}}]);

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.